diff options
author | Håkon Hallingstad <hakon@verizonmedia.com> | 2021-01-06 14:32:27 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@verizonmedia.com> | 2021-01-06 14:32:27 +0100 |
commit | 25bdcc87f06449e94888ecd8f9c27cd71fad3195 (patch) | |
tree | 900bff7205767222665480d4e87033d025b8a0ab /controller-api | |
parent | 21da42e562beb1cf132118d47170e65b4750efee (diff) |
Serialize null OrchestratorStatus in NodeRepositoryNode in patch to null/nothing
Diffstat (limited to 'controller-api')
3 files changed, 18 insertions, 7 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java index 76055e4ddf2..be3189eb1cf 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java @@ -210,7 +210,6 @@ public interface NodeRepository { case ALLOWED_TO_BE_DOWN: return Node.ServiceState.allowedDown; case PERMANENTLY_DOWN: return Node.ServiceState.permanentlyDown; case NO_REMARKS: return Node.ServiceState.expectedUp; - case OTHER: return Node.ServiceState.unknown; } return Node.ServiceState.unknown; 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 a63058572f9..8b027cb229a 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 @@ -11,7 +11,6 @@ import com.fasterxml.jackson.databind.JsonNode; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Stream; @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) @@ -328,15 +327,19 @@ public class NodeRepositoryNode { this.history = history; } + + @JsonGetter("orchestratorStatus") + public String getOrchestratorStatusOrNull() { + return orchestratorStatus; + } + + @JsonIgnore public OrchestratorStatus getOrchestratorStatus() { if (orchestratorStatus == null) { return OrchestratorStatus.NO_REMARKS; } - return Stream.of(OrchestratorStatus.values()) - .filter(status -> status.name().equalsIgnoreCase(orchestratorStatus)) - .findAny() - .orElse(OrchestratorStatus.OTHER); + return OrchestratorStatus.fromString(orchestratorStatus); } public Long suspendedSinceMillis() { 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 index 51942b56b3d..74fdc8ebe92 100644 --- 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 @@ -1,6 +1,15 @@ // 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, OTHER + 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)); + } } |