diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-07-20 08:46:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 08:46:55 +0200 |
commit | db5535c6dc23e82881bbb013861132b5df4affc2 (patch) | |
tree | eaf9af01abbd7e5f6ae7832fa91fe93e4441b1cd | |
parent | b8a1426317d81829ddb0e97f3b829fc9668a3404 (diff) | |
parent | aaa061e6f4038d19e26507c3a051933210dd13dc (diff) |
Merge pull request #18636 from vespa-engine/mpolden/controller-node-cleanup-5
Stop using enums in NodeRepositoryNode fields
4 files changed, 26 insertions, 48 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java index 3dec7772ad0..337b2110063 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java @@ -451,7 +451,7 @@ public class Node { private DockerImage wantedDockerImage = DockerImage.EMPTY; private Optional<Instant> currentFirmwareCheck = Optional.empty(); private Optional<Instant> wantedFirmwareCheck = Optional.empty(); - private ServiceState serviceState = ServiceState.unknown; + private ServiceState serviceState = ServiceState.expectedUp; private Optional<Instant> suspendedSince = Optional.empty(); private long restartGeneration = 0; private long wantedRestartGeneration = 0; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeEnvironment.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeEnvironment.java deleted file mode 100644 index 8510aacf3a8..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeEnvironment.java +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.noderepository; - -/** - * @author bjorncs - */ -public enum NodeEnvironment { - BARE_METAL, - VIRTUAL_MACHINE, - DOCKER_CONTAINER -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java index 80d710eda2b..a12bc93ebd8 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryNode.java @@ -15,6 +15,8 @@ import java.util.Set; /** * The wire format of a node retrieved from the node repository. * + * All fields in this are nullable. + * * @author bjorncs */ @JsonIgnoreProperties(ignoreUnknown = true) @@ -26,7 +28,7 @@ public class NodeRepositoryNode { @JsonProperty("id") private String id; @JsonProperty("state") - private NodeState state; + private String state; @JsonProperty("hostname") private String hostname; @JsonProperty("ipAddresses") @@ -70,9 +72,9 @@ public class NodeRepositoryNode { @JsonProperty("failCount") private Integer failCount; @JsonProperty("environment") - private NodeEnvironment environment; + private String environment; @JsonProperty("type") - private NodeType type; + private String type; @JsonProperty("wantedDockerImage") private String wantedDockerImage; @JsonProperty("currentDockerImage") @@ -120,11 +122,11 @@ public class NodeRepositoryNode { this.id = id; } - public NodeState getState() { + public String getState() { return state; } - public void setState(NodeState state) { + public void setState(String state) { this.state = state; } @@ -264,19 +266,19 @@ public class NodeRepositoryNode { this.failCount = failCount; } - public NodeEnvironment getEnvironment() { + public String getEnvironment() { return environment; } - public void setEnvironment(NodeEnvironment environment) { + public void setEnvironment(String environment) { this.environment = environment; } - public NodeType getType() { + public String getType() { return type; } - public void setType(NodeType type) { + public void setType(String type) { this.type = type; } @@ -342,21 +344,10 @@ public class NodeRepositoryNode { this.history = history; } - - @JsonGetter("orchestratorStatus") - public String getOrchestratorStatusOrNull() { + public String getOrchestratorStatus() { return orchestratorStatus; } - @JsonIgnore - public OrchestratorStatus getOrchestratorStatus() { - if (orchestratorStatus == null) { - return OrchestratorStatus.NO_REMARKS; - } - - return OrchestratorStatus.fromString(orchestratorStatus); - } - public Long suspendedSinceMillis() { return suspendedSinceMillis; } @@ -433,6 +424,19 @@ public class NodeRepositoryNode { this.switchHostname = switchHostname; } + + // --- Helper methods for code that (wrongly) consume this directly + + public boolean hasType(NodeType type) { + return type.name().equals(getType()); + } + + public boolean hasState(NodeState state) { + return state.name().equals(getState()); + } + + // --- end + @Override public String toString() { return "NodeRepositoryNode{" + diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/OrchestratorStatus.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/OrchestratorStatus.java deleted file mode 100644 index 74fdc8ebe92..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/OrchestratorStatus.java +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.noderepository; - -import java.util.stream.Stream; - -public enum OrchestratorStatus { - NO_REMARKS, ALLOWED_TO_BE_DOWN, PERMANENTLY_DOWN; - - public static OrchestratorStatus fromString(String statusString) { - return Stream.of(OrchestratorStatus.values()) - .filter(status -> status.name().equalsIgnoreCase(statusString)) - .findAny() - .orElseThrow(() -> new IllegalArgumentException("Unknown orchestrator status: " + statusString)); - } -} |