diff --git a/modules/dcache/src/main/java/org/dcache/pool/nearline/HsmSet.java b/modules/dcache/src/main/java/org/dcache/pool/nearline/HsmSet.java index c2f9fb24bf3..6f918124e6a 100644 --- a/modules/dcache/src/main/java/org/dcache/pool/nearline/HsmSet.java +++ b/modules/dcache/src/main/java/org/dcache/pool/nearline/HsmSet.java @@ -18,6 +18,8 @@ package org.dcache.pool.nearline; import static java.util.Collections.unmodifiableSet; +import static java.util.Objects.requireNonNull; +import static org.dcache.util.Exceptions.messageOrClassName; import com.google.common.collect.Maps; import diskCacheV111.util.FileNotInCacheException; @@ -66,9 +68,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import static java.util.Objects.requireNonNull; -import static org.dcache.util.Exceptions.messageOrClassName; - /** * An HsmSet encapsulates information about attached HSMs. The HsmSet also acts as a cell command * interpreter, allowing the user to add, remove or alter the information. @@ -85,18 +84,20 @@ */ public class HsmSet implements CellCommandListener, CellSetupProvider, CellLifeCycleAware, - CellDynamicCommandProvider { + CellDynamicCommandProvider { private static final Logger LOGGER = LoggerFactory.getLogger(HsmSet.class); /** - * Nearline storage provides that are part of the dCache on located in standard plugin classpath. + * Nearline storage provides that are part of the dCache on located in standard plugin + * classpath. */ private static final Map EMBEDDED_PROVIDERS = ServiceLoader.load(NearlineStorageProvider.class) - .stream() - .map(Provider::get) - .collect(Collectors.toUnmodifiableMap(NearlineStorageProvider::getName, Function.identity())); + .stream() + .map(Provider::get) + .collect(Collectors.toUnmodifiableMap(NearlineStorageProvider::getName, + Function.identity())); /** * Nearline storage provides that dynamically at the runtime. @@ -118,6 +119,7 @@ public class HsmSet /** * Looks for an embedded on dynamically loaded configured provided. + * * @param name of the nearline storage provider to find. * @return nearline storage provider. * @throws IllegalArgumentException if provider with a given name not found. @@ -300,6 +302,7 @@ public NearlineStorage getNearlineStorage() { /** * Call the NearlineStorage start method. This method may only be called once and must be * called before calling any other method, other than {@literal configure}. + * * @throws IOException if the underlying NearlinePlugin threw an exception. */ public void start() throws IOException { @@ -389,7 +392,6 @@ public String call() throws CommandException { writer.header("PROVIDER").left("provider").space(); writer.header("DESCRIPTION").left("description"); - var f = new File(path); if (!f.exists()) { throw new CommandException(1, "No such directory: " + path); @@ -434,9 +436,10 @@ public String call() throws CommandException { } @Command(name = "hsm unload provider", hint = "Unload user provided nearline storage provider", - description = "Unloads user loaded provide. After unloading, the provider can be used anymore." - + " The system behaviour in undefined, if plugin is removed while corresponding hsm still" - + " in use.") + description = + "Unloads user loaded provide. After unloading, the provider can be used anymore." + + " The system behaviour in undefined, if plugin is removed while corresponding hsm still" + + " in use.") public class UnloadProvider implements Callable { @Argument(usage = "Provider name to unload") @@ -458,7 +461,8 @@ public String call() throws CommandException { try { ((URLClassLoader) (p.getClass().getClassLoader())).close(); } catch (IOException e) { - throw new CommandException(1, "Can't unload " + provider + " : " + e.getMessage()); + throw new CommandException(1, + "Can't unload " + provider + " : " + e.getMessage()); } } @@ -535,7 +539,7 @@ public String call() throws CommandException { info.start(); } catch (IOException e) { throw new CommandException(1, "Nearline plugin failed on start: " - + messageOrClassName(e)); + + messageOrClassName(e)); } _hsm.put(instance, info); } @@ -698,9 +702,9 @@ public synchronized void afterSetup() { /* Remove the stores that are not in the new configuration. */ - Iterator> iterator = _hsm.entrySet().iterator(); + Iterator> iterator = _hsm.entrySet().iterator(); while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); + Map.Entry entry = iterator.next(); if (_newConfig.containsKey(entry.getKey())) { continue; @@ -718,7 +722,8 @@ public synchronized void afterSetup() { try { hsm.refresh(); } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("Error configuring hsm \"" + hsm.getInstance() + "\": " + e.getMessage()); + throw new IllegalArgumentException( + "Error configuring hsm \"" + hsm.getInstance() + "\": " + e.getMessage()); } } @@ -733,13 +738,13 @@ public synchronized void afterSetup() { entry.getValue().start(); } catch (IOException e) { LOGGER.warn( - AlarmMarkerFactory.getMarker( - PredefinedAlarm.HSM_STARTUP_FAILED, - _poolName, - instance), - "Removing HSM \"{}\" as it failed to start: {}", - instance, - messageOrClassName(e)); + AlarmMarkerFactory.getMarker( + PredefinedAlarm.HSM_STARTUP_FAILED, + _poolName, + instance), + "Removing HSM \"{}\" as it failed to start: {}", + instance, + messageOrClassName(e)); itr.remove(); } } @@ -763,13 +768,13 @@ public void afterStart() { } catch (IOException e) { String instance = entry.getKey(); LOGGER.warn( - AlarmMarkerFactory.getMarker( - PredefinedAlarm.HSM_STARTUP_FAILED, - _poolName, - instance), - "Removing HSM \"{}\" as it failed to start: {}", - instance, - messageOrClassName(e)); + AlarmMarkerFactory.getMarker( + PredefinedAlarm.HSM_STARTUP_FAILED, + _poolName, + instance), + "Removing HSM \"{}\" as it failed to start: {}", + instance, + messageOrClassName(e)); itr.remove(); } }