diff options
Diffstat (limited to 'node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java index a5ebc6b3efc..e5f02b38d29 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java @@ -87,7 +87,7 @@ public class CuratorDatabaseClient { } public List<String> cluster() { - return db.cluster().stream().map(HostName::value).collect(Collectors.toUnmodifiableList()); + return db.cluster().stream().map(HostName::value).toList(); } private void initZK() { @@ -162,7 +162,7 @@ public class CuratorDatabaseClient { } /** - * Writes the given nodes to the given state (whether or not they are already in this state or another), + * Writes the given nodes to the given state (whether they are already in this state or another), * and returns a copy of the incoming nodes in their persisted state. * * @param toState the state to write the nodes to @@ -305,19 +305,18 @@ public class CuratorDatabaseClient { } private String toDir(Node.State state) { - switch (state) { - case active: return "allocated"; // legacy name - case dirty: return "dirty"; - case failed: return "failed"; - case inactive: return "deallocated"; // legacy name - case parked : return "parked"; - case provisioned: return "provisioned"; - case ready: return "ready"; - case reserved: return "reserved"; - case deprovisioned: return "deprovisioned"; - case breakfixed: return "breakfixed"; - default: throw new RuntimeException("Node state " + state + " does not map to a directory name"); - } + return switch (state) { + case active -> "allocated"; // legacy name + case dirty -> "dirty"; + case failed -> "failed"; + case inactive -> "deallocated"; // legacy name + case parked -> "parked"; + case provisioned -> "provisioned"; + case ready -> "ready"; + case reserved -> "reserved"; + case deprovisioned -> "deprovisioned"; + case breakfixed -> "breakfixed"; + }; } /** Acquires the single cluster-global, reentrant lock for all non-active nodes */ @@ -513,7 +512,7 @@ public class CuratorDatabaseClient { return db.getChildren(loadBalancersPath).stream() .map(LoadBalancerId::fromSerializedForm) .filter(predicate) - .collect(Collectors.toUnmodifiableList()); + .toList(); } /** Returns a given number of unique provision indices */ @@ -524,7 +523,7 @@ public class CuratorDatabaseClient { int firstIndex = (int) provisionIndexCounter.add(count) - count; return IntStream.range(0, count) .mapToObj(i -> firstIndex + i) - .collect(Collectors.toList()); + .toList(); } public CacheStats cacheStats() { |