summaryrefslogtreecommitdiffstats
path: root/controller-server/src
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@oath.com>2018-01-08 15:59:30 +0100
committerBjørn Christian Seime <bjorncs@oath.com>2018-01-08 16:03:29 +0100
commit1765bb74bf71fd25b56d1f5d71eba64801a88ee4 (patch)
tree95bb05ef2639df00c473a4e4b9922d097fbe5a30 /controller-server/src
parent697a8dbca3d75ba0e3df558439afdd83aa3adad0 (diff)
Remove getNodeList from ConfigServerClient
The implementation is just a wrapper around node repository client.
Diffstat (limited to 'controller-server/src')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java14
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java29
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ConfigServerClientMock.java25
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java1
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/NodeRepositoryClientMock.java125
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java1
6 files changed, 155 insertions, 40 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java
index 44e4cf0740f..1f386b662aa 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java
@@ -7,6 +7,7 @@ import com.yahoo.component.AbstractComponent;
import com.yahoo.component.Version;
import com.yahoo.component.Vtag;
import com.yahoo.config.provision.SystemName;
+import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryClientInterface;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.api.identifiers.AthenzDomain;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
@@ -66,6 +67,7 @@ public class Controller extends AbstractComponent {
private final GlobalRoutingService globalRoutingService;
private final ZoneRegistry zoneRegistry;
private final ConfigServerClient configServerClient;
+ private final NodeRepositoryClientInterface nodeRepositoryClient;
private final MetricsService metricsService;
private final Chef chefClient;
private final Organization organization;
@@ -81,19 +83,19 @@ public class Controller extends AbstractComponent {
public Controller(ControllerDb db, CuratorDb curator, RotationsConfig rotationsConfig,
GitHub gitHub, EntityService entityService, Organization organization,
GlobalRoutingService globalRoutingService,
- ZoneRegistry zoneRegistry, ConfigServerClient configServerClient,
+ ZoneRegistry zoneRegistry, ConfigServerClient configServerClient, NodeRepositoryClientInterface nodeRepositoryClient,
MetricsService metricsService, NameService nameService,
RoutingGenerator routingGenerator, Chef chefClient, AthenzClientFactory athenzClientFactory) {
this(db, curator, rotationsConfig,
gitHub, entityService, organization, globalRoutingService, zoneRegistry,
- configServerClient, metricsService, nameService, routingGenerator, chefClient,
+ configServerClient, nodeRepositoryClient, metricsService, nameService, routingGenerator, chefClient,
Clock.systemUTC(), athenzClientFactory);
}
public Controller(ControllerDb db, CuratorDb curator, RotationsConfig rotationsConfig,
GitHub gitHub, EntityService entityService, Organization organization,
GlobalRoutingService globalRoutingService,
- ZoneRegistry zoneRegistry, ConfigServerClient configServerClient,
+ ZoneRegistry zoneRegistry, ConfigServerClient configServerClient, NodeRepositoryClientInterface nodeRepositoryClient,
MetricsService metricsService, NameService nameService,
RoutingGenerator routingGenerator, Chef chefClient, Clock clock,
AthenzClientFactory athenzClientFactory) {
@@ -106,6 +108,7 @@ public class Controller extends AbstractComponent {
Objects.requireNonNull(globalRoutingService, "GlobalRoutingService cannot be null");
Objects.requireNonNull(zoneRegistry, "ZoneRegistry cannot be null");
Objects.requireNonNull(configServerClient, "ConfigServerClient cannot be null");
+ Objects.requireNonNull(nodeRepositoryClient, "NodeRepositoryClientInterface cannot be null");
Objects.requireNonNull(metricsService, "MetricsService cannot be null");
Objects.requireNonNull(nameService, "NameService cannot be null");
Objects.requireNonNull(routingGenerator, "RoutingGenerator cannot be null");
@@ -120,6 +123,7 @@ public class Controller extends AbstractComponent {
this.globalRoutingService = globalRoutingService;
this.zoneRegistry = zoneRegistry;
this.configServerClient = configServerClient;
+ this.nodeRepositoryClient = nodeRepositoryClient;
this.metricsService = metricsService;
this.chefClient = chefClient;
this.clock = clock;
@@ -239,6 +243,10 @@ public class Controller extends AbstractComponent {
return curator;
}
+ public NodeRepositoryClientInterface nodeRepositoryClient() {
+ return nodeRepositoryClient;
+ }
+
private String printableVersion(Optional<VespaVersion> vespaVersion) {
return vespaVersion.map(v -> v.versionNumber().toFullString()).orElse("Unknown");
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java
index cf0600f87bd..100fb11d68c 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java
@@ -2,11 +2,12 @@
package com.yahoo.vespa.hosted.controller.maintenance;
import com.yahoo.config.provision.ClusterSpec;
-import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
-import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeList;
+import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList;
+import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode;
+import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.application.ApplicationList;
import com.yahoo.vespa.hosted.controller.application.ClusterInfo;
import com.yahoo.vespa.hosted.controller.application.Deployment;
@@ -38,24 +39,24 @@ public class ClusterInfoMaintainer extends Maintainer {
this.controller = controller;
}
- private static String clusterid(NodeList.Node node) {
- return node.membership.clusterId;
+ private static String clusterid(NodeRepositoryNode node) {
+ return node.getMembership().clusterid;
}
private Map<ClusterSpec.Id, ClusterInfo> getClusterInfo(NodeList nodes, ZoneId zone) {
Map<ClusterSpec.Id, ClusterInfo> infoMap = new HashMap<>();
// Group nodes by clusterid
- Map<String, List<NodeList.Node>> clusters = nodes.nodes.stream()
- .filter(node -> node.membership != null)
+ Map<String, List<NodeRepositoryNode>> clusters = nodes.nodes().stream()
+ .filter(node -> node.getMembership() != null)
.collect(Collectors.groupingBy(ClusterInfoMaintainer::clusterid));
// For each cluster - get info
for (String id : clusters.keySet()) {
- List<NodeList.Node> clusterNodes = clusters.get(id);
+ List<NodeRepositoryNode> clusterNodes = clusters.get(id);
// Assume they are all equal and use first node as a representative for the cluster
- NodeList.Node node = clusterNodes.get(0);
+ NodeRepositoryNode node = clusterNodes.get(0);
// Extract flavor info
double cpu = 0;
@@ -73,9 +74,9 @@ public class ClusterInfoMaintainer extends Maintainer {
}*/
// Add to map
- List<String> hostnames = clusterNodes.stream().map(node1 -> node1.hostname).collect(Collectors.toList());
- ClusterInfo inf = new ClusterInfo(node.flavor, node.cost, cpu, mem, disk,
- ClusterSpec.Type.from(node.membership.clusterType), hostnames);
+ List<String> hostnames = clusterNodes.stream().map(NodeRepositoryNode::getHostname).collect(Collectors.toList());
+ ClusterInfo inf = new ClusterInfo(node.getFlavor(), node.getCost(), cpu, mem, disk,
+ ClusterSpec.Type.from(node.getMembership().clustertype), hostnames);
infoMap.put(new ClusterSpec.Id(id), inf);
}
@@ -88,7 +89,11 @@ public class ClusterInfoMaintainer extends Maintainer {
for (Deployment deployment : application.deployments().values()) {
DeploymentId deploymentId = new DeploymentId(application.id(), deployment.zone());
try {
- NodeList nodes = controller().applications().configserverClient().getNodeList(deploymentId);
+ NodeList nodes = controller.nodeRepositoryClient()
+ .listNodes(deploymentId.zoneId(),
+ deploymentId.applicationId().tenant().value(),
+ deploymentId.applicationId().application().value(),
+ deploymentId.applicationId().instance().value());
Map<ClusterSpec.Id, ClusterInfo> clusterInfo = getClusterInfo(nodes, deployment.zone());
controller().applications().lockIfPresent(application.id(), lockedApplication ->
controller.applications().store(lockedApplication.withClusterInfo(deployment.zone(), clusterInfo)));
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ConfigServerClientMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ConfigServerClientMock.java
index bf7f19a996c..e966cff652b 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ConfigServerClientMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ConfigServerClientMock.java
@@ -15,7 +15,6 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.Hostname;
import com.yahoo.vespa.hosted.controller.api.identifiers.TenantId;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerClient;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.Log;
-import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeList;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse;
import com.yahoo.vespa.hosted.controller.api.rotation.Rotation;
import com.yahoo.vespa.serviceview.bindings.ApplicationView;
@@ -201,28 +200,4 @@ public class ConfigServerClientMock extends AbstractComponent implements ConfigS
return endpoints.getOrDefault(endpoint, result);
}
- @Override
- public NodeList getNodeList(DeploymentId deployment) {
- NodeList list = new NodeList();
- list.nodes = new ArrayList<>();
- NodeList.Node hostA = new NodeList.Node();
- hostA.hostname = "hostA";
- hostA.cost = 10;
- hostA.flavor = "C-2B/24/500";
- hostA.membership = new NodeList.Node.Membership();
- hostA.membership.clusterId = "clusterA";
- hostA.membership.clusterType = "container";
- list.nodes.add(hostA);
-
- NodeList.Node hostB = new NodeList.Node();
- hostB.hostname = "hostB";
- hostB.cost = 20;
- hostB.flavor = "C-2C/24/500";
- hostB.membership = new NodeList.Node.Membership();
- hostB.membership.clusterId = "clusterB";
- hostB.membership.clusterType = "content";
- list.nodes.add(hostB);
-
- return list;
- }
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java
index b3ca5491e91..06bde36afc6 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java
@@ -241,6 +241,7 @@ public final class ControllerTester {
new MemoryGlobalRoutingService(),
zoneRegistryMock,
configServerClientMock,
+ new NodeRepositoryClientMock(),
new MockMetricsService(),
nameService,
new MockRoutingGenerator(),
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/NodeRepositoryClientMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/NodeRepositoryClientMock.java
new file mode 100644
index 00000000000..f73f2e992d9
--- /dev/null
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/NodeRepositoryClientMock.java
@@ -0,0 +1,125 @@
+// 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;
+
+import com.yahoo.vespa.hosted.controller.api.integration.noderepository.MaintenanceJobList;
+import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList;
+import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeMembership;
+import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryClientInterface;
+import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode;
+import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeState;
+import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * @author bjorncs
+ */
+public class NodeRepositoryClientMock implements NodeRepositoryClientInterface {
+ @Override
+ public void addNodes(ZoneId zone, Collection<NodeRepositoryNode> nodes) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public NodeRepositoryNode getNode(ZoneId zone, String hostname) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void deleteNode(ZoneId zone, String hostname) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public NodeList listNodes(ZoneId zone, boolean recursive) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public NodeList listNodes(ZoneId zone, String tenant, String applicationId, String instance) throws IOException {
+ NodeRepositoryNode nodeA = createNodeA();
+ NodeRepositoryNode nodeB = createNodeB();
+ return new NodeList(Arrays.asList(nodeA, nodeB));
+ }
+
+ private static NodeRepositoryNode createNodeA() {
+ NodeRepositoryNode node = new NodeRepositoryNode();
+ node.setHostname("hostA");
+ node.setCost(10);
+ node.setFlavor("C-2B/24/500");
+ NodeMembership membership = new NodeMembership();
+ membership.clusterid = "clusterA";
+ membership.clustertype = "container";
+ node.setMembership(membership);
+ return node;
+ }
+
+ private static NodeRepositoryNode createNodeB() {
+ NodeRepositoryNode node = new NodeRepositoryNode();
+ node.setHostname("hostB");
+ node.setCost(20);
+ node.setFlavor("C-2C/24/500");
+ NodeMembership membership = new NodeMembership();
+ membership.clusterid = "clusterB";
+ membership.clustertype = "content";
+ node.setMembership(membership);
+ return node;
+ }
+
+ @Override
+ public String resetFailureInformation(ZoneId zone, String nodename) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String restart(ZoneId zone, String nodename) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String reboot(ZoneId zone, String nodename) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String cancelReboot(ZoneId zone, String nodename) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String wantTo(ZoneId zone, String nodename, WantTo... actions) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String cancelRestart(ZoneId zone, String nodename) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String setHardwareFailureDescription(ZoneId zone, String nodename, String hardwareFailureDescription) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setState(ZoneId zone, NodeState nodeState, String nodename) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String enableMaintenanceJob(ZoneId zone, String jobName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String disableMaintenanceJob(ZoneId zone, String jobName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public MaintenanceJobList listMaintenanceJobs(ZoneId zone) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java
index 631ceab98a5..92753ff3205 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java
@@ -57,6 +57,7 @@ public class ControllerContainerTest {
" <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.DummyOwnershipIssues'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.api.integration.organization.MockOrganization'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.ConfigServerClientMock'/>\n" +
+ " <component id='com.yahoo.vespa.hosted.controller.NodeRepositoryClientMock'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.ZoneRegistryMock'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.Controller'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.ConfigServerProxyMock'/>\n" +