diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-02-15 12:45:49 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-02-15 12:45:49 +0100 |
commit | 4430dad21dcfe07cb0a6662d44b916dd2f06a40b (patch) | |
tree | c27a148e90fb5379ab9e6c75687ea5a6f14d4368 | |
parent | c5fe5b6be07e57115cd72738a5afd928b0df60ef (diff) |
Use switch expression
-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; |