summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerij Fredriksen <valerij92@gmail.com>2019-06-07 19:48:35 +0200
committerValerij Fredriksen <valerij92@gmail.com>2019-06-07 20:16:36 +0200
commit7b4dabbd0e84169c591ac52de4df346a54b4b0ac (patch)
tree0375143230960574358eaab05b20334a17ab232e
parent22ee83497950a29b71652adc8dd5d3551d839241 (diff)
Remove ZoneApplication
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/ZoneApplication.java108
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/duper/TestZoneApplication.java90
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java9
3 files changed, 5 insertions, 202 deletions
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ZoneApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ZoneApplication.java
deleted file mode 100644
index bcf5f096e7f..00000000000
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ZoneApplication.java
+++ /dev/null
@@ -1,108 +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.service.duper;
-
-import com.yahoo.config.model.api.ServiceInfo;
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.ApplicationName;
-import com.yahoo.config.provision.ClusterSpec;
-import com.yahoo.config.provision.NodeType;
-import com.yahoo.config.provision.TenantName;
-import com.yahoo.vespa.applicationmodel.ClusterId;
-import com.yahoo.vespa.applicationmodel.ServiceType;
-import com.yahoo.vespa.service.model.ApplicationInstanceGenerator;
-
-import java.util.Objects;
-
-/**
- * @author hakon
- *
- * TODO: This does not extend InfraApplication because
- * 1) It is not deployed same as the other HostedVespaApplications
- * 2) ZoneApplication has multiple clusters
- */
-public class ZoneApplication {
-
- private ZoneApplication() {}
-
- private static final ApplicationId ZONE_APPLICATION_ID = InfraApplication
- .createHostedVespaApplicationId("routing");
- private static final ClusterId NODE_ADMIN_CLUSTER_ID = new ClusterId("node-admin");
- private static final ClusterId ROUTING_CLUSTER_ID = new ClusterId("routing");
-
- public static ApplicationId getApplicationId() {
- return ZONE_APPLICATION_ID;
- }
-
- public static TenantName getTenantName() {
- return ZONE_APPLICATION_ID.tenant();
- }
-
- public static ApplicationName getApplicationName() {
- return ZONE_APPLICATION_ID.application();
- }
-
- public static NodeType getNodeAdminNodeType() {
- return NodeType.host;
- }
-
- public static ClusterId getNodeAdminClusterId() {
- return NODE_ADMIN_CLUSTER_ID;
- }
-
- public static ClusterSpec.Type getNodeAdminClusterSpecType() {
- return ClusterSpec.Type.container;
- }
-
- public static ClusterSpec.Id getNodeAdminClusterSpecId() {
- return new ClusterSpec.Id(getNodeAdminClusterId().s());
- }
-
- public static ServiceType getNodeAdminServiceType() {
- return ServiceType.CONTAINER;
- }
-
- public static int getNodeAdminHealthPort() {
- return HostAdminApplication.HOST_ADMIN_HEALT_PORT;
- }
-
- public static NodeType getRoutingNodeType() {
- return NodeType.proxy;
- }
-
- public static ClusterId getRoutingClusterId() {
- return ROUTING_CLUSTER_ID;
- }
-
- public static ClusterSpec.Type getRoutingClusterSpecType() {
- return ClusterSpec.Type.container;
- }
-
- public static ClusterSpec.Id getRoutingClusterSpecId() {
- return new ClusterSpec.Id(getRoutingClusterId().s());
- }
-
- public static ServiceType getRoutingServiceType() {
- return ServiceType.CONTAINER;
- }
-
- public static int getRoutingHealthPort() {
- return 4088;
- }
-
- public static boolean isNodeAdminService(ApplicationId applicationId,
- ClusterId clusterId,
- ServiceType serviceType) {
- return Objects.equals(applicationId, getApplicationId()) &&
- Objects.equals(serviceType, getNodeAdminServiceType()) &&
- Objects.equals(clusterId, getNodeAdminClusterId());
- }
-
- /** Whether a {@link ServiceInfo} belongs to the zone application's node-admin cluster. */
- public static boolean isNodeAdminServiceInfo(ApplicationId applicationId, ServiceInfo serviceInfo) {
- return isNodeAdminService(
- applicationId,
- ApplicationInstanceGenerator.getClusterId(serviceInfo),
- ApplicationInstanceGenerator.toServiceType(serviceInfo));
- }
-
-}
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/duper/TestZoneApplication.java b/service-monitor/src/test/java/com/yahoo/vespa/service/duper/TestZoneApplication.java
deleted file mode 100644
index 773643c1d09..00000000000
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/duper/TestZoneApplication.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.duper;
-
-import com.yahoo.config.model.api.ApplicationInfo;
-import com.yahoo.config.model.api.HostInfo;
-import com.yahoo.config.provision.HostName;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- * @author hakonhall
- */
-public class TestZoneApplication {
-
- private final List<HostName> nodeAdminHostnames;
- private final List<HostName> routingHostnames;
-
- private TestZoneApplication(List<HostName> nodeAdminHostnames, List<HostName> routingHostnames) {
- this.nodeAdminHostnames = nodeAdminHostnames;
- this.routingHostnames = routingHostnames;
- }
-
- public ApplicationInfo makeApplicationInfo() {
- // Make a test ApplicationInfo by:
- // 1. Make an ApplicationInfo as-if the node-admin cluster of the zone application were the only cluster.
- // Make sure to get the correct tenant name, application name, cluster id, service type, hostnames,
- // services, and ports. This should be easy with the help of InfraApplication.
- ApplicationInfo nodeAdminPart = new NodeAdminPartOfZoneApplication().makeApplicationInfo(nodeAdminHostnames);
-
- // 2. Make an ApplicationInfo as-if the routing cluster of the zone application were the only cluster.
- // Don't care if the application is not perfect.
- ApplicationInfo routingPart = new RoutingPartOfZoneApplication().makeApplicationInfo(routingHostnames);
-
- // 3. Take HostInfo from (1) and (2) to make a single ApplicationInfo.
- List<HostInfo> allHostInfos = new ArrayList<>();
- allHostInfos.addAll(nodeAdminPart.getModel().getHosts());
- allHostInfos.addAll(routingPart.getModel().getHosts());
-
- return new ApplicationInfo(nodeAdminPart.getApplicationId(), 0, new HostsModel(allHostInfos));
- }
-
- public static class Builder {
- private List<HostName> nodeAdminHostnames = null;
- private List<HostName> routingHostnames = null;
-
- public Builder addNodeAdminCluster(String... hostnames) {
- this.nodeAdminHostnames = Stream.of(hostnames).map(HostName::from).collect(Collectors.toList());
- return this;
- }
-
- public Builder addRoutingCluster(String... hostnames) {
- this.routingHostnames = Stream.of(hostnames).map(HostName::from).collect(Collectors.toList());
- return this;
- }
-
- public TestZoneApplication build() {
- return new TestZoneApplication(Objects.requireNonNull(nodeAdminHostnames), Objects.requireNonNull(routingHostnames));
- }
- }
-
- private static class NodeAdminPartOfZoneApplication extends InfraApplication {
- public NodeAdminPartOfZoneApplication() {
- super(ZoneApplication.getApplicationName().value(),
- ZoneApplication.getNodeAdminNodeType(),
- ZoneApplication.getNodeAdminClusterSpecType(),
- ZoneApplication.getNodeAdminClusterSpecId(),
- ZoneApplication.getNodeAdminServiceType(),
- ZoneApplication.getNodeAdminHealthPort());
- }
- }
-
- /**
- * This InfraApplication is bogus (containing host admin instead of jdisc container), but the tests are
- * not supposed to explore this cluster.
- */
- private static class RoutingPartOfZoneApplication extends InfraApplication {
- public RoutingPartOfZoneApplication() {
- super(ZoneApplication.getApplicationName().value(),
- ZoneApplication.getRoutingNodeType(),
- ZoneApplication.getRoutingClusterSpecType(),
- ZoneApplication.getRoutingClusterSpecId(),
- ZoneApplication.getRoutingServiceType(),
- ZoneApplication.getRoutingHealthPort());
- }
- }
-}
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java
index 5cfe70fae5f..f6ef3977a56 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java
@@ -4,7 +4,7 @@ package com.yahoo.vespa.service.manager;
import com.yahoo.vespa.applicationmodel.ConfigId;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.vespa.applicationmodel.ServiceStatusInfo;
-import com.yahoo.vespa.service.duper.ZoneApplication;
+import com.yahoo.vespa.service.duper.ConfigServerHostApplication;
import com.yahoo.vespa.service.health.HealthMonitorManager;
import com.yahoo.vespa.service.slobrok.SlobrokMonitorManagerImpl;
import org.junit.Test;
@@ -18,6 +18,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class UnionMonitorManagerTest {
+ private final ConfigServerHostApplication application = new ConfigServerHostApplication();
private final SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
private final HealthMonitorManager healthMonitorManager = mock(HealthMonitorManager.class);
@@ -38,9 +39,9 @@ public class UnionMonitorManagerTest {
when(healthMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(new ServiceStatusInfo(healthStatus));
when(slobrokMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(new ServiceStatusInfo(slobrokStatus));
ServiceStatus status = manager.getStatus(
- ZoneApplication.getApplicationId(),
- ZoneApplication.getNodeAdminClusterId(),
- ZoneApplication.getNodeAdminServiceType(), new ConfigId("config-id")).serviceStatus();
+ application.getApplicationId(),
+ application.getClusterId(),
+ application.getServiceType(), new ConfigId("config-id")).serviceStatus();
assertSame(expectedStatus, status);
}
} \ No newline at end of file