summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2018-05-08 11:24:33 +0200
committerMartin Polden <mpolden@mpolden.no>2018-05-08 11:47:09 +0200
commit868cedffb8e18af5cce6a5ae80b3d00dc1abbaaf (patch)
treea8474bca2bc26336b22160fa4968b69319bc7d0c /controller-api
parent39909e7998f6578ee2e324ebc91fbb79fe8c9e72 (diff)
Only consider operational nodes for upgrade
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java18
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java17
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java3
3 files changed, 37 insertions, 1 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 3de43e9040b..d75f0e90d63 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
@@ -17,14 +17,16 @@ import java.util.Optional;
public class Node {
private final HostName hostname;
+ private final State state;
private final Optional<ApplicationId> owner;
private final NodeType type;
private final Version currentVersion;
private final Version wantedVersion;
- public Node(HostName hostname, NodeType type, Optional<ApplicationId> owner, Version currentVersion,
+ public Node(HostName hostname, State state, NodeType type, Optional<ApplicationId> owner, Version currentVersion,
Version wantedVersion) {
this.hostname = hostname;
+ this.state = state;
this.type = type;
this.owner = owner;
this.currentVersion = currentVersion;
@@ -35,6 +37,8 @@ public class Node {
return hostname;
}
+ public State state() { return state; }
+
public NodeType type() {
return type;
}
@@ -64,4 +68,16 @@ public class Node {
return Objects.hash(hostname);
}
+ /** Known node states */
+ public enum State {
+ provisioned,
+ ready,
+ reserved,
+ active,
+ inactive,
+ dirty,
+ failed,
+ parked
+ }
+
}
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 ccf020b9af6..741fee0210c 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
@@ -7,6 +7,7 @@ import com.yahoo.config.provision.NodeType;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
import java.util.List;
+import java.util.stream.Collectors;
/**
* A minimal interface to the node repository, providing only the operations used by the controller.
@@ -18,6 +19,22 @@ public interface NodeRepository {
/** List all nodes in zone owned by given application */
List<Node> list(ZoneId zone, ApplicationId application);
+ /** List all operational nodes in zone owned by given application */
+ default List<Node> listOperational(ZoneId zone, ApplicationId application) {
+ return list(zone, application).stream()
+ .filter(node -> {
+ switch (node.state()) {
+ case ready:
+ case active:
+ case inactive:
+ case reserved:
+ return true;
+ }
+ return false;
+ })
+ .collect(Collectors.toList());
+ }
+
/** Upgrade all nodes of given type to a new version */
void upgrade(ZoneId zone, NodeType type, Version version);
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java
index aa276f8e792..8151cce3d76 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java
@@ -13,6 +13,9 @@ import java.util.Collection;
* @author bjorncs
*/
// TODO: Get rid of all the checked exceptions
+// TODO: Replace remaining controller-server usages of this with
+// com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository and move this package back to internal
+// repo
public interface NodeRepositoryClientInterface {
enum WantTo {