public PersistentStorage getPersistentStorage(String deploymentName) { NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setPersistentStorage(); List<PersistentStorage> matching = lookupService.getMatchingNodesOfType(filter, PersistentStorage.class); switch (matching.size()) { case 0: PersistentStorage persistentStorage = new PersistentStorage(); setPersistentStorage(deploymentName, persistentStorage); return persistentStorage; case 1: return matching.get(0); default: throw new RuntimeException("It shouldn't be possible to have multiple persistentStorage nodes. This is a bug."); } }
public PersistentStorage getPersistentStorage(String deploymentName) { NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setPersistentStorage(); List<PersistentStorage> matching = lookupService.getMatchingNodesOfType(filter, PersistentStorage.class); switch (matching.size()) { case 0: PersistentStorage persistentStorage = new PersistentStorage(); setPersistentStorage(deploymentName, persistentStorage); return persistentStorage; case 1: return matching.get(0); default: throw new RuntimeException("It shouldn't be possible to have multiple persistentStorage nodes. This is a bug."); } }
@RequestMapping(value = "/", method = RequestMethod.PUT) DaemonTask<Halconfig, Void> setPersistentStorage(@PathVariable String deploymentName, @ModelAttribute ValidationSettings validationSettings, @RequestBody PersistentStorage persistentStorage) { return GenericUpdateRequest.<PersistentStorage>builder(halconfigParser) .stagePath(halconfigDirectoryStructure.getStagingPath(deploymentName)) .updater(p -> persistentStorageService.setPersistentStorage(deploymentName, p)) .validator(() -> persistentStorageService.validatePersistentStorage(deploymentName)) .description("Edit persistent storage settings") .build() .execute(validationSettings, persistentStorage); }