diff options
Diffstat (limited to 'node-admin/src')
16 files changed, 23 insertions, 30 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java index 1a2f5799d94..2caf216c533 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java @@ -2,8 +2,6 @@ package com.yahoo.vespa.hosted.node.admin.component; import java.util.logging.Level; - -import java.util.logging.Level; import java.util.logging.Logger; public interface TaskContext { diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeAttributes.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeAttributes.java index 328b6b19a0b..8c58022b67f 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeAttributes.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeAttributes.java @@ -138,11 +138,10 @@ public class NodeAttributes { } @Override - public boolean equals(final Object o) { - if (!(o instanceof NodeAttributes)) { + public boolean equals(Object o) { + if (!(o instanceof NodeAttributes other)) { return false; } - final NodeAttributes other = (NodeAttributes) o; return Objects.equals(hostId, other.hostId) && Objects.equals(restartGeneration, other.restartGeneration) diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeSpec.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeSpec.java index 6e31e699e2c..3cca7deeeae 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeSpec.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeSpec.java @@ -294,9 +294,7 @@ public class NodeSpec { @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof NodeSpec)) return false; - - NodeSpec that = (NodeSpec) o; + if (!(o instanceof NodeSpec that)) return false; return Objects.equals(hostname, that.hostname) && Objects.equals(id, that.id) && diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/orchestrator/OrchestratorImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/orchestrator/OrchestratorImpl.java index 858bce27ed8..895515a2cff 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/orchestrator/OrchestratorImpl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/orchestrator/OrchestratorImpl.java @@ -57,7 +57,7 @@ public class OrchestratorImpl implements Orchestrator { } catch (HttpException.NotFoundException n) { throw new OrchestratorNotFoundException("Failed to suspend " + hostName + ", host not found"); } catch (HttpException e) { - throw new OrchestratorException("Failed to suspend " + hostName + ": " + e.toString()); + throw new OrchestratorException("Failed to suspend " + hostName + ": " + e); } catch (ConnectionException e) { throw ConvergenceException.ofTransient("Failed to suspend " + hostName + ": " + e.getMessage()); } catch (RuntimeException e) { @@ -70,7 +70,7 @@ public class OrchestratorImpl implements Orchestrator { } private static ConfigServerApi.RetryPolicy<UpdateHostResponse> createRetryPolicyForSuspend() { - return new ConfigServerApi.RetryPolicy<UpdateHostResponse>() { + return new ConfigServerApi.RetryPolicy<>() { @Override public boolean tryNextConfigServer(URI configServerEndpoint, UpdateHostResponse response) { HostStateChangeDenialReason reason = response.reason(); @@ -103,7 +103,7 @@ public class OrchestratorImpl implements Orchestrator { parentHostName, hostnames); batchOperationResult = configServerApi.put(url, Optional.empty(), BatchOperationResult.class, params); } catch (HttpException e) { - throw new OrchestratorException("Failed to batch suspend for " + parentHostName + ": " + e.toString()); + throw new OrchestratorException("Failed to batch suspend for " + parentHostName + ": " + e); } catch (ConnectionException e) { throw ConvergenceException.ofTransient("Failed to batch suspend for " + parentHostName + ": " + e.getMessage()); } catch (RuntimeException e) { @@ -124,7 +124,7 @@ public class OrchestratorImpl implements Orchestrator { } catch (HttpException.NotFoundException n) { throw new OrchestratorNotFoundException("Failed to resume " + hostName + ", host not found"); } catch (HttpException e) { - throw new OrchestratorException("Failed to resume " + hostName + ": " + e.toString()); + throw new OrchestratorException("Failed to resume " + hostName + ": " + e); } catch (ConnectionException e) { throw ConvergenceException.ofTransient("Failed to resume " + hostName + ": " + e.getMessage()); } catch (RuntimeException e) { diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/container/ContainerName.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/container/ContainerName.java index 6e3b5b3f703..d059de18325 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/container/ContainerName.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/container/ContainerName.java @@ -36,13 +36,11 @@ public class ContainerName implements Comparable<ContainerName> { } @Override - public boolean equals(final Object o) { - if (!(o instanceof ContainerName)) { + public boolean equals(Object o) { + if (!(o instanceof ContainerName other)) { return false; } - final ContainerName other = (ContainerName) o; - return Objects.equals(name, other.name); } diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/AclMaintainer.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/AclMaintainer.java index cb2134b36af..e8d10805a45 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/AclMaintainer.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/acl/AclMaintainer.java @@ -123,7 +123,7 @@ public class AclMaintainer { } private void writeUtf8Content(String content) throws IOException { - Files.write(path, content.getBytes(StandardCharsets.UTF_8)); + Files.writeString(path, content); } private String absolutePath() { diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java index 025723fe71c..ea352791b36 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java @@ -547,7 +547,7 @@ public class NodeAgentImpl implements NodeAgent { StringBuilder builder = new StringBuilder(); appendIfDifferent(builder, "state", lastNode, node, NodeSpec::state); if (builder.length() > 0) { - context.log(logger, Level.INFO, "Changes to node: " + builder.toString()); + context.log(logger, Level.INFO, "Changes to node: " + builder); } } diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/DefaultEnvWriter.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/DefaultEnvWriter.java index 7073142a8f9..05b33cad2be 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/DefaultEnvWriter.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/DefaultEnvWriter.java @@ -62,7 +62,7 @@ public class DefaultEnvWriter { return false; } else { context.log(logger, "Updating " + defaultEnvFile.toString()); - Path tempFile = Paths.get(defaultEnvFile.toString() + ".tmp"); + Path tempFile = Paths.get(defaultEnvFile + ".tmp"); uncheck(() -> Files.write(tempFile, newDefaultEnvLines)); uncheck(() -> Files.move(tempFile, defaultEnvFile, ATOMIC_MOVE)); return true; diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java index 88bb1f49582..8fbb2d4e8e9 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java @@ -104,7 +104,7 @@ public class Editor { return false; } - String diffDescription = diffTooLarge() ? ": Diff too large (" + diffSize + ")" : ":\n" + diff.toString(); + String diffDescription = diffTooLarge() ? ": Diff too large (" + diffSize + ")" : ":\n" + diff; logConsumer.accept("Patching file " + name + diffDescription); consumer.accept(newLines); return true; diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystem.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystem.java index 4167ba2d76e..9be677fa6d6 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystem.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystem.java @@ -68,7 +68,7 @@ public class ContainerFileSystem extends FileSystem { } @Override - public void close() throws IOException { + public void close() { throw new UnsupportedOperationException(); } diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java index d98ca5d84f2..6db0bf0c730 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/StorageMaintainerTest.java @@ -141,7 +141,7 @@ public class StorageMaintainerTest { } @Test - void not_run_if_not_enough_used() throws IOException { + void not_run_if_not_enough_used() { NodeAgentContext context = NodeAgentContextImpl.builder( NodeSpec.Builder.testSpec("h123a.domain.tld").realResources(new NodeResources(1, 1, 1, 1)).build()) .fileSystem(fileSystem).build(); @@ -152,7 +152,7 @@ public class StorageMaintainerTest { } @Test - void deletes_correct_amount() throws IOException { + void deletes_correct_amount() { NodeAgentContext context = NodeAgentContextImpl.builder( NodeSpec.Builder.testSpec("h123a.domain.tld").realResources(new NodeResources(1, 1, 1, 1)).build()) .fileSystem(fileSystem).build(); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandlerTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandlerTest.java index 31579fb7c9b..082a1f3de58 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandlerTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandlerTest.java @@ -174,14 +174,14 @@ public class CoredumpHandlerTest { } @Test - void cant_get_metadata_if_no_core_file() throws IOException { + void cant_get_metadata_if_no_core_file() { assertThrows(IllegalStateException.class, () -> { coredumpHandler.getMetadata(context, context.paths().of("/fake/path"), Map::of); }); } @Test - void fails_to_get_core_file_if_only_compressed() throws IOException { + void fails_to_get_core_file_if_only_compressed() { assertThrows(IllegalStateException.class, () -> { ContainerPath coredumpDirectory = context.paths().of("/path/to/coredump/proccessing/id-123"); Files.createDirectories(coredumpDirectory); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/ZstdCompressingInputStreamTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/ZstdCompressingInputStreamTest.java index e6963175977..4eb5ca8a1cd 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/ZstdCompressingInputStreamTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/maintenance/sync/ZstdCompressingInputStreamTest.java @@ -19,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class ZstdCompressingInputStreamTest { @Test - void compression_test() throws Exception { + void compression_test() { Random rnd = new Random(); byte[] data = new byte[(int) (100_000 * (10 + rnd.nextDouble()))]; rnd.nextBytes(data); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminStateUpdaterTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminStateUpdaterTest.java index 1197fd1469b..75dc4fffff8 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminStateUpdaterTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeadmin/NodeAdminStateUpdaterTest.java @@ -58,7 +58,7 @@ public class NodeAdminStateUpdaterTest { mockNodeRepo(NodeState.active, 4); List<String> activeHostnames = nodeRepository.getNodes(hostHostname.value()).stream() .map(NodeSpec::hostname) - .collect(Collectors.toList()); + .toList(); List<String> suspendHostnames = new ArrayList<>(activeHostnames); suspendHostnames.add(hostHostname.value()); when(nodeAdmin.subsystemFreezeDuration()).thenReturn(Duration.ofSeconds(1)); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystemTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystemTest.java index b26f0fe5bf8..29a78519724 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystemTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/fs/ContainerFileSystemTest.java @@ -60,7 +60,7 @@ class ContainerFileSystemTest { unixPath.setOwnerId(500).setGroupId(200); assertOwnership(containerPath, 500, 200, 10500, 11200); - Files.write(containerPath, " world".getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND); + Files.writeString(containerPath, " world", StandardOpenOption.APPEND); assertOwnership(containerPath, 500, 200, 10500, 11200); // Owner should not have been updated as the file already existed assertEquals("hello world", unixPath.readUtf8File()); diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/process/ChildProcess2ImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/process/ChildProcess2ImplTest.java index f209290cb14..53fdb52102b 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/process/ChildProcess2ImplTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/process/ChildProcess2ImplTest.java @@ -100,7 +100,7 @@ public class ChildProcess2ImplTest { when(processApi.waitFor(anyLong(), any())).thenReturn(true); - Files.write(temporaryFile, "1234567890123".getBytes(StandardCharsets.UTF_8)); + Files.writeString(temporaryFile, "1234567890123"); try (ChildProcess2Impl child = new ChildProcess2Impl(commandLine, processApi, temporaryFile, timer)) { @@ -130,7 +130,7 @@ public class ChildProcess2ImplTest { when(processApi.waitFor(anyLong(), any())).thenReturn(false); - Files.write(temporaryFile, "1234567890123".getBytes(StandardCharsets.UTF_8)); + Files.writeString(temporaryFile, "1234567890123"); try (ChildProcess2Impl child = new ChildProcess2Impl(commandLine, processApi, temporaryFile, timer)) { |