diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-02-15 12:45:49 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-03-13 09:37:16 +0100 |
commit | 16b55f4d4311e7142037476f12568d6118f00ade (patch) | |
tree | c7db792d15c68c1e68eb04c46d819ea8f9895a22 /node-repository | |
parent | 9553cd2709c0791aa530f5388cf156116e857795 (diff) |
Use switch expression
Diffstat (limited to 'node-repository')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java | 12 | ||||
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java | 6 |
2 files changed, 9 insertions, 9 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java index b2becc7ecfd..bee14321435 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java @@ -158,12 +158,12 @@ public class IP { if (node.parentHostname().isPresent() == existingNode.parentHostname().isPresent()) return false; // Not a parent-child node if (node.parentHostname().isEmpty()) return canAssignIpOf(node, existingNode); if (!node.parentHostname().get().equals(existingNode.hostname())) return false; // Wrong host - switch (node.type()) { - case proxy: return existingNode.type() == proxyhost; - case config: return existingNode.type() == confighost; - case controller: return existingNode.type() == controllerhost; - } - return false; + return switch (node.type()) { + case proxy -> existingNode.type() == proxyhost; + case config -> existingNode.type() == confighost; + case controller -> existingNode.type() == controllerhost; + default -> false; + }; } public static Node verify(Node node, LockedNodeList allNodes) { diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java index fa07782057b..b194730727f 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java @@ -181,11 +181,11 @@ public abstract class NodeCandidate implements Nodelike, Comparable<NodeCandidat if ( ! lessThanHalfTheHost(this) && lessThanHalfTheHost(other)) return 1; } - // Prefer host with least skew + // Prefer host with the least skew int hostPriority = hostPriority(other); if (hostPriority != 0) return hostPriority; - // Prefer node with cheapest flavor + // Prefer node with the cheapest flavor if (this.flavor().cost() < other.flavor().cost()) return -1; if (other.flavor().cost() < this.flavor().cost()) return 1; @@ -199,7 +199,7 @@ public abstract class NodeCandidate implements Nodelike, Comparable<NodeCandidat return Integer.compare(this.allocation().get().membership().index(), other.allocation().get().membership().index()); - // Prefer host with latest OS version + // Prefer host with the latest OS version Version thisHostOsVersion = this.parent.flatMap(host -> host.status().osVersion().current()).orElse(Version.emptyVersion); Version otherHostOsVersion = other.parent.flatMap(host -> host.status().osVersion().current()).orElse(Version.emptyVersion); if (thisHostOsVersion.isAfter(otherHostOsVersion)) return -1; |