aboutsummaryrefslogtreecommitdiffstats
path: root/service-monitor
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@oath.com>2018-12-06 14:38:57 +0100
committerHåkon Hallingstad <hakon@oath.com>2018-12-06 14:38:57 +0100
commit790f43668c9f6a1ed0e86cfec730a76c31666cf6 (patch)
tree1726ce9fae98dd7f2c533733d69f0458d96cf8af /service-monitor
parent0daac4e48cea934f1849d5be486c8506641214b6 (diff)
Make service monitors aware of infra applications in duper model.
- Notify monitors of infrastructure application activation. Live-flipping the content of the duper model is non-trivial and has been removed. - Split out DuperModel as a simple mutable and thread-unsafe container of the applications in the duper model, that also handles calls listeners on changes. The previous DuperModel has been renamed to DuperModelManager. - Replace SuperModelProvider::snapshot method (fast but difficult to use right) with registerListener. - Shorten the fully qualified package names by 1-2 levels for mosts classes. Next steps: - Make HA query the real orchestrator - Start experimenting with health monitoring of infra apps
Diffstat (limited to 'service-monitor')
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/ConfigServerApplication.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ConfigServerApplication.java)6
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/ConfigServerHostApplication.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ConfigServerHostApplication.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/ControllerApplication.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ControllerApplication.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/ControllerHostApplication.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ControllerHostApplication.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModel.java45
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelListener.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/DuperModelListener.java)10
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java225
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/HostsModel.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/HostsModel.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/InfraApplication.java)7
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/ProxyHostApplication.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ProxyHostApplication.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/duper/ZoneApplication.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ZoneApplication.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/health/ApplicationHealthMonitor.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/ApplicationHealthMonitor.java)11
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthClient.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthClient.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthEndpoint.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthEndpoint.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthInfo.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthInfo.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthMonitor.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitor.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthMonitorManager.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitorManager.java)34
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthResponse.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthResponse.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/health/HttpHealthEndpoint.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpHealthEndpoint.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/health/HttpsHealthEndpoint.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpsHealthEndpoint.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/manager/MonitorManager.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/MonitorManager.java)6
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/manager/UnionMonitorManager.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/UnionMonitorManager.java)16
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/model/ApplicationInstanceGenerator.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ApplicationInstanceGenerator.java)5
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/model/LatencyMeasurement.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/LatencyMeasurement.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/model/ModelGenerator.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ModelGenerator.java)3
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceId.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceId.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceModelCache.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceModelCache.java)7
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceModelProvider.java54
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceMonitorImpl.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceMonitorImpl.java)35
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceMonitorMetrics.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceMonitorMetrics.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/DuperModelInfraApi.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/DuperModelInfraApi.java)4
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/InfraApplicationApi.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/InfraApplicationApi.java)6
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceModel.java2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceStatusProvider.java5
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/DuperModel.java153
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/package-info.java8
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/SuperModelListenerImpl.java86
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/slobrok/SlobrokMonitor.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitor.java)2
-rw-r--r--service-monitor/src/main/java/com/yahoo/vespa/service/slobrok/SlobrokMonitorManagerImpl.java (renamed from service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitorManagerImpl.java)17
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelManagerTest.java184
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelTest.java63
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/health/ApplicationHealthMonitorTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/ApplicationHealthMonitorTest.java)7
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthClientTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/HealthClientTest.java)2
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitorManagerTest.java)25
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitorTest.java)2
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/UnionMonitorManagerTest.java)10
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/application/ApplicationInstanceGeneratorTest.java)7
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/model/ExampleModel.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ExampleModel.java)4
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/model/ExampleModelTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ExampleModelTest.java)2
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/model/LatencyMeasurementTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/LatencyMeasurementTest.java)2
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/model/ModelGeneratorTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ModelGeneratorTest.java)34
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceModelCacheTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ServiceModelCacheTest.java)2
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceModelProviderTest.java44
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceMonitorMetricsTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ServiceMonitorMetricsTest.java)2
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/monitor/ConfigserverUtil.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ConfigserverUtil.java)11
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/monitor/application/DuperModelTest.java104
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/SuperModelListenerImplTest.java56
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/slobrok/SlobrokMonitorManagerImplTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitorManagerImplTest.java)2
-rw-r--r--service-monitor/src/test/java/com/yahoo/vespa/service/slobrok/SlobrokMonitorTest.java (renamed from service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitorTest.java)4
59 files changed, 772 insertions, 574 deletions
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ConfigServerApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ConfigServerApplication.java
index f1041835a39..f93f25a4eb3 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ConfigServerApplication.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ConfigServerApplication.java
@@ -1,5 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.application;
+package com.yahoo.vespa.service.duper;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.model.api.ApplicationInfo;
@@ -13,8 +13,8 @@ import com.yahoo.vespa.applicationmodel.ClusterId;
import com.yahoo.vespa.applicationmodel.ConfigId;
import com.yahoo.vespa.applicationmodel.ServiceType;
import com.yahoo.vespa.applicationmodel.TenantId;
-import com.yahoo.vespa.service.monitor.internal.ModelGenerator;
-import com.yahoo.vespa.service.monitor.internal.health.ApplicationHealthMonitor;
+import com.yahoo.vespa.service.model.ModelGenerator;
+import com.yahoo.vespa.service.health.ApplicationHealthMonitor;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ConfigServerHostApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ConfigServerHostApplication.java
index 9925e2ac69b..f29cc89e987 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ConfigServerHostApplication.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ConfigServerHostApplication.java
@@ -1,5 +1,5 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.duper;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.NodeType;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ControllerApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ControllerApplication.java
index ec4cb73383e..1fb01ce0897 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ControllerApplication.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ControllerApplication.java
@@ -1,5 +1,5 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.duper;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.NodeType;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ControllerHostApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ControllerHostApplication.java
index c23794b3835..b8e8ead5b7e 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ControllerHostApplication.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ControllerHostApplication.java
@@ -1,5 +1,5 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.duper;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.NodeType;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModel.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModel.java
new file mode 100644
index 00000000000..c90b37a4c2a
--- /dev/null
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModel.java
@@ -0,0 +1,45 @@
+// 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.ApplicationInfo;
+import com.yahoo.config.provision.ApplicationId;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * A non-thread-safe mutable container of ApplicationInfo in the DuperModel, also taking care of listeners on changes.
+ *
+ * @author hakonhall
+ */
+public class DuperModel {
+ private final Map<ApplicationId, ApplicationInfo> applications = new TreeMap<>();
+ private final List<DuperModelListener> listeners = new ArrayList<>();
+
+ public void registerListener(DuperModelListener listener) {
+ applications.values().forEach(listener::applicationActivated);
+ listeners.add(listener);
+ }
+
+ public boolean contains(ApplicationId applicationId) {
+ return applications.containsKey(applicationId);
+ }
+
+ public void add(ApplicationInfo applicationInfo) {
+ applications.put(applicationInfo.getApplicationId(), applicationInfo);
+ listeners.forEach(listener -> listener.applicationActivated(applicationInfo));
+ }
+
+ public void remove(ApplicationId applicationId) {
+ if (applications.remove(applicationId) != null) {
+ listeners.forEach(listener -> listener.applicationRemoved(applicationId));
+ }
+ }
+
+ public List<ApplicationInfo> getApplicationInfos() {
+ return Collections.unmodifiableList(new ArrayList<>(applications.values()));
+ }
+}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/DuperModelListener.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelListener.java
index 34b8109ce53..a969b6c3f40 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/DuperModelListener.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelListener.java
@@ -1,5 +1,5 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.duper;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.SuperModel;
@@ -20,9 +20,15 @@ public interface DuperModelListener {
* {@link com.yahoo.config.model.api.SuperModelListener#applicationActivated(SuperModel, ApplicationInfo)
* SuperModelListener}
* </ul>
+ *
+ * No other threads will concurrently call any methods on this interface.
*/
void applicationActivated(ApplicationInfo application);
- /** Application has been removed. */
+ /**
+ * Application has been removed.
+ *
+ * No other threads will concurrently call any methods on this interface.
+ */
void applicationRemoved(ApplicationId id);
}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java
new file mode 100644
index 00000000000..1f8fa35d1cf
--- /dev/null
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java
@@ -0,0 +1,225 @@
+// 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.google.inject.Inject;
+import com.yahoo.cloud.config.ConfigserverConfig;
+import com.yahoo.config.model.api.ApplicationInfo;
+import com.yahoo.config.model.api.SuperModel;
+import com.yahoo.config.model.api.SuperModelListener;
+import com.yahoo.config.model.api.SuperModelProvider;
+import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.config.provision.HostName;
+import com.yahoo.log.LogLevel;
+import com.yahoo.vespa.flags.FeatureFlag;
+import com.yahoo.vespa.flags.FlagSource;
+import com.yahoo.vespa.service.monitor.DuperModelInfraApi;
+import com.yahoo.vespa.service.monitor.InfraApplicationApi;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * @author hakonhall
+ */
+public class DuperModelManager implements DuperModelInfraApi {
+ private static Logger logger = Logger.getLogger(DuperModelManager.class.getName());
+
+ // Infrastructure applications
+ private static final ConfigServerApplication configServerApplication = new ConfigServerApplication();
+ private static final ConfigServerHostApplication configServerHostApplication = new ConfigServerHostApplication();
+ private static final ProxyHostApplication proxyHostApplication = new ProxyHostApplication();
+ private static final ControllerApplication controllerApplication = new ControllerApplication();
+ private static final ControllerHostApplication controllerHostApplication = new ControllerHostApplication();
+
+ private static final Map<ApplicationId, InfraApplication> supportedInfraApplications = Stream.of(
+ configServerApplication,
+ configServerHostApplication,
+ proxyHostApplication,
+ controllerApplication,
+ controllerHostApplication)
+ .collect(Collectors.toMap(InfraApplication::getApplicationId, Function.identity()));
+
+ private final boolean containsInfra;
+ private final boolean useConfigserverConfig;
+ private final boolean multitenant;
+
+ private final Object monitor = new Object();
+ private final DuperModel duperModel;
+ // The set of active infrastructure ApplicationInfo. Not all is necessarily in the DuperModel for historical reasons.
+ private final Set<ApplicationId> activeInfraInfos = new HashSet<>(2 * supportedInfraApplications.size());
+
+ /**
+ * Returns true if application is considered an infrastructure application by the DuperModel.
+ *
+ * <p>Note: The tenant host "application" is NOT considered an infrastructure application: It is just a
+ * cluster in the {@link ZoneApplication zone application}.
+ */
+ public static boolean isInfrastructureApplication(ApplicationId applicationId) {
+ return supportedInfraApplications.containsKey(applicationId);
+ }
+
+ @Inject
+ public DuperModelManager(ConfigserverConfig configServerConfig, FlagSource flagSource, SuperModelProvider superModelProvider) {
+ this(
+ // Whether to include activate infrastructure applications (except from controller/config apps - see below).
+ new FeatureFlag("dupermodel-contains-infra", true, flagSource).value(),
+ // For historical reasons, the ApplicationInfo in the DuperModel for controllers and config servers
+ // is based on the ConfigserverConfig (this flag is true). We want to transition to use the
+ // infrastructure application activated by the InfrastructureProvisioner once that supports health.
+ new FeatureFlag("dupermodel-use-configserverconfig", true, flagSource).value(),
+ configServerConfig.multitenant(),
+ configServerApplication.makeApplicationInfoFromConfig(configServerConfig),
+ superModelProvider,
+ new DuperModel());
+ }
+
+ /** For testing */
+ public DuperModelManager(boolean containsInfra,
+ boolean useConfigserverConfig,
+ boolean multitenant,
+ ApplicationInfo configServerApplicationInfoFromConfig,
+ SuperModelProvider superModelProvider,
+ DuperModel duperModel) {
+ this.containsInfra = containsInfra;
+ this.useConfigserverConfig = useConfigserverConfig;
+ this.multitenant = multitenant;
+ this.duperModel = duperModel;
+
+ if (isConfigServerFromConfigInDuperModel()) {
+ duperModel.add(configServerApplicationInfoFromConfig);
+ }
+
+ superModelProvider.registerListener(new SuperModelListener() {
+ @Override
+ public void applicationActivated(SuperModel superModel, ApplicationInfo application) {
+ synchronized (monitor) {
+ duperModel.add(application);
+ }
+ }
+
+ @Override
+ public void applicationRemoved(SuperModel superModel, ApplicationId applicationId) {
+ synchronized (monitor) {
+ duperModel.remove(applicationId);
+ }
+ }
+ });
+ }
+
+ /**
+ * Synchronously call {@link DuperModelListener#applicationActivated(ApplicationInfo) listener.applicationActivated()}
+ * for each currently active application, and forward future changes.
+ */
+ public void registerListener(DuperModelListener listener) {
+ synchronized (monitor) {
+ duperModel.registerListener(listener);
+ }
+ }
+
+ public ConfigServerApplication getConfigServerApplication() {
+ return configServerApplication;
+ }
+
+ public ConfigServerHostApplication getConfigServerHostApplication() {
+ return configServerHostApplication;
+ }
+
+ public ProxyHostApplication getProxyHostApplication() {
+ return proxyHostApplication;
+ }
+
+ public ControllerApplication getControllerApplication() {
+ return controllerApplication;
+ }
+
+ public ControllerHostApplication getControllerHostApplication() {
+ return controllerHostApplication;
+ }
+
+ @Override
+ public List<InfraApplicationApi> getSupportedInfraApplications() {
+ return new ArrayList<>(supportedInfraApplications.values());
+ }
+
+ @Override
+ public boolean infraApplicationIsActive(ApplicationId applicationId) {
+ synchronized (monitor) {
+ return activeInfraInfos.contains(applicationId);
+ }
+ }
+
+ @Override
+ public void infraApplicationActivated(ApplicationId applicationId, List<HostName> hostnames) {
+ InfraApplication application = supportedInfraApplications.get(applicationId);
+ if (application == null) {
+ throw new IllegalArgumentException("There is no infrastructure application with ID '" + applicationId + "'");
+ }
+
+ synchronized (monitor) {
+ activeInfraInfos.add(applicationId);
+ if (infraApplicationBelongsInDuperModel(applicationId)) {
+ duperModel.add(application.makeApplicationInfo(hostnames));
+ }
+ }
+ }
+
+ @Override
+ public void infraApplicationRemoved(ApplicationId applicationId) {
+ synchronized (monitor) {
+ activeInfraInfos.remove(applicationId);
+ if (duperModel.contains(applicationId)) {
+ duperModel.remove(applicationId);
+ }
+ }
+ }
+
+ public List<ApplicationInfo> getApplicationInfos() {
+ synchronized (monitor) {
+ return duperModel.getApplicationInfos();
+ }
+ }
+
+ private boolean isConfigServerFromConfigInDuperModel() {
+ return multitenant && useConfigserverConfig;
+ }
+
+ private boolean infraApplicationBelongsInDuperModel(ApplicationId applicationId) {
+ // At most 1 of the following 3 applications can be in the duper model:
+ // - config server built from ConfigserverConfig (legacy on both controller and config server)
+ // - config server
+ // - controller
+ // The problem of allowing more than 1 is that orchestration will fail since hostname -> application lookup
+ // will not be unique.
+ if (!containsInfra) {
+ return false;
+ }
+ if (applicationId.equals(controllerApplication.getApplicationId())) {
+ if (isConfigServerFromConfigInDuperModel()) return false;
+ if (!multitenant) return false;
+ if (duperModel.contains(configServerApplication.getApplicationId())) {
+ logger.log(LogLevel.WARNING, "Refusing to add controller application to duper model " +
+ "since it already contains config server");
+ return false;
+ }
+ return true;
+ } else if (applicationId.equals(configServerApplication.getApplicationId())) {
+ if (isConfigServerFromConfigInDuperModel()) return false;
+ if (!multitenant) return false;
+ if (duperModel.contains(controllerApplication.getApplicationId())) {
+ logger.log(LogLevel.WARNING, "Refusing to add config server application to duper model " +
+ "since it already contains controller");
+ return false;
+ }
+ return true;
+ } else {
+ return true;
+ }
+ }
+}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/HostsModel.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/HostsModel.java
index 225ffb0adbc..48e20fb5989 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/HostsModel.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/HostsModel.java
@@ -1,5 +1,5 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.duper;
import com.yahoo.config.FileReference;
import com.yahoo.config.model.api.FileDistribution;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/InfraApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java
index 1c4f6ea3d2a..89aabbfe2b0 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/InfraApplication.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java
@@ -1,5 +1,5 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.duper;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.HostInfo;
@@ -14,8 +14,9 @@ import com.yahoo.config.provision.TenantName;
import com.yahoo.component.Version;
import com.yahoo.vespa.applicationmodel.ConfigId;
import com.yahoo.vespa.applicationmodel.ServiceType;
-import com.yahoo.vespa.service.monitor.internal.ModelGenerator;
-import com.yahoo.vespa.service.monitor.internal.health.ApplicationHealthMonitor;
+import com.yahoo.vespa.service.monitor.InfraApplicationApi;
+import com.yahoo.vespa.service.model.ModelGenerator;
+import com.yahoo.vespa.service.health.ApplicationHealthMonitor;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ProxyHostApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ProxyHostApplication.java
index 2debec5d299..b6b0964a82d 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ProxyHostApplication.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ProxyHostApplication.java
@@ -1,5 +1,5 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.duper;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.NodeType;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ZoneApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ZoneApplication.java
index 4a4189cddd7..65198e72c89 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ZoneApplication.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/ZoneApplication.java
@@ -1,5 +1,5 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.duper;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.applicationmodel.ClusterId;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/ApplicationHealthMonitor.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/ApplicationHealthMonitor.java
index 7c78d61da30..2d81474853c 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/ApplicationHealthMonitor.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/ApplicationHealthMonitor.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.HostInfo;
@@ -12,8 +12,8 @@ import com.yahoo.vespa.applicationmodel.ConfigId;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.vespa.applicationmodel.ServiceType;
import com.yahoo.vespa.service.monitor.ServiceStatusProvider;
-import com.yahoo.vespa.service.monitor.application.ApplicationInstanceGenerator;
-import com.yahoo.vespa.service.monitor.internal.ServiceId;
+import com.yahoo.vespa.service.model.ApplicationInstanceGenerator;
+import com.yahoo.vespa.service.model.ServiceId;
import java.util.Arrays;
import java.util.Collections;
@@ -52,6 +52,11 @@ public class ApplicationHealthMonitor implements ServiceStatusProvider, AutoClos
}
@Override
+ public boolean wouldMonitor(ApplicationId applicationId) {
+ return true;
+ }
+
+ @Override
public ServiceStatus getStatus(ApplicationId applicationId,
ClusterId clusterId,
ServiceType serviceType,
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthClient.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthClient.java
index 7ee736d7020..129cc799a25 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthClient.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthClient.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpEntity;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthEndpoint.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthEndpoint.java
index c74124da862..e15d82ea70b 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthEndpoint.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthEndpoint.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.yahoo.config.provision.HostName;
import com.yahoo.vespa.athenz.api.AthenzIdentity;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthInfo.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthInfo.java
index 8b724afba5f..17d9e6b7b49 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthInfo.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthInfo.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.yolean.Exceptions;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitor.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthMonitor.java
index 28e1fc88816..d6dc1942404 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitor.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthMonitor.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.yahoo.log.LogLevel;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitorManager.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthMonitorManager.java
index 383cb6961a7..daf9fd1931b 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitorManager.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthMonitorManager.java
@@ -1,17 +1,16 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.google.inject.Inject;
-import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.applicationmodel.ClusterId;
import com.yahoo.vespa.applicationmodel.ConfigId;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.vespa.applicationmodel.ServiceType;
-import com.yahoo.vespa.service.monitor.application.ConfigServerApplication;
-import com.yahoo.vespa.service.monitor.application.ZoneApplication;
-import com.yahoo.vespa.service.monitor.internal.MonitorManager;
+import com.yahoo.vespa.service.duper.ConfigServerApplication;
+import com.yahoo.vespa.service.duper.ZoneApplication;
+import com.yahoo.vespa.service.manager.MonitorManager;
import java.util.concurrent.ConcurrentHashMap;
@@ -21,20 +20,15 @@ import java.util.concurrent.ConcurrentHashMap;
* @author hakon
*/
public class HealthMonitorManager implements MonitorManager {
- private final ConcurrentHashMap<ApplicationId, ApplicationHealthMonitor> healthMonitors =
- new ConcurrentHashMap<>();
- private final ConfigserverConfig configserverConfig;
+ private final ConcurrentHashMap<ApplicationId, ApplicationHealthMonitor> healthMonitors = new ConcurrentHashMap<>();
@Inject
- public HealthMonitorManager(ConfigserverConfig configserverConfig) {
- this.configserverConfig = configserverConfig;
- }
+ public HealthMonitorManager() { }
@Override
public void applicationActivated(ApplicationInfo application) {
- if (applicationMonitoredForHealth(application.getApplicationId())) {
- ApplicationHealthMonitor monitor =
- ApplicationHealthMonitor.startMonitoring(application);
+ if (wouldMonitor(application.getApplicationId())) {
+ ApplicationHealthMonitor monitor = ApplicationHealthMonitor.startMonitoring(application);
healthMonitors.put(application.getApplicationId(), monitor);
}
}
@@ -52,8 +46,7 @@ public class HealthMonitorManager implements MonitorManager {
ClusterId clusterId,
ServiceType serviceType,
ConfigId configId) {
- if (!configserverConfig.nodeAdminInContainer() &&
- ZoneApplication.isNodeAdminService(applicationId, clusterId, serviceType)) {
+ if (ZoneApplication.isNodeAdminService(applicationId, clusterId, serviceType)) {
// If node admin doesn't run in a JDisc container, it must be monitored with health.
// TODO: Do proper health check
return ServiceStatus.UP;
@@ -67,7 +60,12 @@ public class HealthMonitorManager implements MonitorManager {
return monitor.getStatus(applicationId, clusterId, serviceType, configId);
}
- private boolean applicationMonitoredForHealth(ApplicationId id) {
- return id.equals(ConfigServerApplication.CONFIG_SERVER_APPLICATION.getApplicationId());
+ @Override
+ public boolean wouldMonitor(ApplicationId id) {
+ if (id.equals(ConfigServerApplication.CONFIG_SERVER_APPLICATION.getApplicationId())) {
+ return true;
+ }
+
+ return false;
}
}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthResponse.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthResponse.java
index 574523ad564..5d97d773a53 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HealthResponse.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HealthResponse.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpHealthEndpoint.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HttpHealthEndpoint.java
index 97357fc0e2e..793c1a93379 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpHealthEndpoint.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HttpHealthEndpoint.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpsHealthEndpoint.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HttpsHealthEndpoint.java
index 5201ac48dd3..42e408256c5 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/health/HttpsHealthEndpoint.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/HttpsHealthEndpoint.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.yahoo.vespa.athenz.identity.ServiceIdentityProvider;
import com.yahoo.vespa.athenz.identity.ServiceIdentitySslSocketFactory;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/MonitorManager.java b/service-monitor/src/main/java/com/yahoo/vespa/service/manager/MonitorManager.java
index 965c425b91e..dd781a02cef 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/MonitorManager.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/manager/MonitorManager.java
@@ -1,11 +1,11 @@
// 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.monitor.internal;
+package com.yahoo.vespa.service.manager;
-import com.yahoo.vespa.service.monitor.application.DuperModelListener;
+import com.yahoo.vespa.service.duper.DuperModelListener;
import com.yahoo.vespa.service.monitor.ServiceStatusProvider;
/**
- * @author hakon
+ * @author hakonhall
*/
public interface MonitorManager extends DuperModelListener, ServiceStatusProvider {
}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/UnionMonitorManager.java b/service-monitor/src/main/java/com/yahoo/vespa/service/manager/UnionMonitorManager.java
index 81cf6f2af5e..eacaf820f3d 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/UnionMonitorManager.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/manager/UnionMonitorManager.java
@@ -1,5 +1,5 @@
// 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.monitor.internal;
+package com.yahoo.vespa.service.manager;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.provision.ApplicationId;
@@ -7,18 +7,17 @@ import com.yahoo.vespa.applicationmodel.ClusterId;
import com.yahoo.vespa.applicationmodel.ConfigId;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.vespa.applicationmodel.ServiceType;
-import com.yahoo.vespa.service.monitor.internal.health.HealthMonitorManager;
-import com.yahoo.vespa.service.monitor.internal.slobrok.SlobrokMonitorManagerImpl;
+import com.yahoo.vespa.service.health.HealthMonitorManager;
+import com.yahoo.vespa.service.slobrok.SlobrokMonitorManagerImpl;
/**
- * @author hakon
+ * @author hakonhall
*/
public class UnionMonitorManager implements MonitorManager {
private final SlobrokMonitorManagerImpl slobrokMonitorManager;
private final HealthMonitorManager healthMonitorManager;
- UnionMonitorManager(SlobrokMonitorManagerImpl slobrokMonitorManager,
- HealthMonitorManager healthMonitorManager) {
+ public UnionMonitorManager(SlobrokMonitorManagerImpl slobrokMonitorManager, HealthMonitorManager healthMonitorManager) {
this.slobrokMonitorManager = slobrokMonitorManager;
this.healthMonitorManager = healthMonitorManager;
}
@@ -39,6 +38,11 @@ public class UnionMonitorManager implements MonitorManager {
}
@Override
+ public boolean wouldMonitor(ApplicationId id) {
+ return healthMonitorManager.wouldMonitor(id) || slobrokMonitorManager.wouldMonitor(id);
+ }
+
+ @Override
public void applicationActivated(ApplicationInfo application) {
slobrokMonitorManager.applicationActivated(application);
healthMonitorManager.applicationActivated(application);
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ApplicationInstanceGenerator.java b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ApplicationInstanceGenerator.java
index cbdcce125cc..9bcb3f07cf6 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/ApplicationInstanceGenerator.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ApplicationInstanceGenerator.java
@@ -1,5 +1,5 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.model;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.HostInfo;
@@ -18,7 +18,6 @@ import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.vespa.applicationmodel.ServiceType;
import com.yahoo.vespa.applicationmodel.TenantId;
import com.yahoo.vespa.service.monitor.ServiceStatusProvider;
-import com.yahoo.vespa.service.monitor.internal.ServiceId;
import java.util.HashMap;
import java.util.HashSet;
@@ -26,7 +25,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import static com.yahoo.vespa.service.monitor.application.ConfigServerApplication.CONFIG_SERVER_APPLICATION;
+import static com.yahoo.vespa.service.duper.ConfigServerApplication.CONFIG_SERVER_APPLICATION;
/**
* Class to generate an ApplicationInstance given service status for a standard (deployed) application.
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/LatencyMeasurement.java b/service-monitor/src/main/java/com/yahoo/vespa/service/model/LatencyMeasurement.java
index c7b9782972a..edfd58258ed 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/LatencyMeasurement.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/model/LatencyMeasurement.java
@@ -1,6 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.jdisc.Timer;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ModelGenerator.java b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ModelGenerator.java
index ad2f223acf8..a6bf41d6c9b 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ModelGenerator.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ModelGenerator.java
@@ -1,5 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.provision.Zone;
@@ -7,7 +7,6 @@ import com.yahoo.vespa.applicationmodel.ApplicationInstance;
import com.yahoo.vespa.applicationmodel.ApplicationInstanceReference;
import com.yahoo.vespa.service.monitor.ServiceModel;
import com.yahoo.vespa.service.monitor.ServiceStatusProvider;
-import com.yahoo.vespa.service.monitor.application.ApplicationInstanceGenerator;
import java.util.List;
import java.util.Map;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceId.java b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceId.java
index 993ea7fed5c..b695b0b19f8 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceId.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceId.java
@@ -1,5 +1,5 @@
// 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.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.applicationmodel.ClusterId;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceModelCache.java b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceModelCache.java
index 89a961e1037..7a6f37b2c94 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceModelCache.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceModelCache.java
@@ -1,12 +1,17 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.jdisc.Timer;
import com.yahoo.vespa.service.monitor.ServiceModel;
import java.util.function.Supplier;
+/**
+ * Adds caching of a supplier of ServiceModel.
+ *
+ * @author hakonhall
+ */
public class ServiceModelCache implements Supplier<ServiceModel> {
public static final long EXPIRY_MILLIS = 10000;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceModelProvider.java b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceModelProvider.java
new file mode 100644
index 00000000000..dbcc6ff7b9b
--- /dev/null
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceModelProvider.java
@@ -0,0 +1,54 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.service.model;
+
+import com.yahoo.config.model.api.ApplicationInfo;
+import com.yahoo.config.provision.Zone;
+import com.yahoo.vespa.service.monitor.ServiceModel;
+import com.yahoo.vespa.service.monitor.ServiceStatusProvider;
+import com.yahoo.vespa.service.manager.MonitorManager;
+import com.yahoo.vespa.service.duper.DuperModelManager;
+
+import java.util.List;
+import java.util.function.Supplier;
+
+/**
+ * An uncached supplier of ServiceModel based on the DuperModel and MonitorManager.
+ *
+ * @author hakonhall
+ */
+public class ServiceModelProvider implements Supplier<ServiceModel> {
+ private final ServiceMonitorMetrics metrics;
+ private final DuperModelManager duperModelManager;
+ private final ModelGenerator modelGenerator;
+ private final Zone zone;
+ private final MonitorManager monitorManager;
+
+ public ServiceModelProvider(MonitorManager monitorManager,
+ ServiceMonitorMetrics metrics,
+ DuperModelManager duperModelManager,
+ ModelGenerator modelGenerator,
+ Zone zone) {
+ this.monitorManager = monitorManager;
+ this.metrics = metrics;
+ this.duperModelManager = duperModelManager;
+ this.modelGenerator = modelGenerator;
+ this.zone = zone;
+ }
+
+ @Override
+ public ServiceModel get() {
+ try (LatencyMeasurement measurement = metrics.startServiceModelSnapshotLatencyMeasurement()) {
+ // Reference 'measurement' in a dummy statement, otherwise the compiler
+ // complains about "auto-closeable resource is never referenced in body of
+ // corresponding try statement". Why hasn't javac fixed this!?
+ dummy(measurement);
+
+ // WARNING: The monitor manager may be out-of-sync with duper model (no locking)
+ List<ApplicationInfo> applicationInfos = duperModelManager.getApplicationInfos();
+
+ return modelGenerator.toServiceModel(applicationInfos, zone, (ServiceStatusProvider) monitorManager);
+ }
+ }
+
+ private void dummy(LatencyMeasurement measurement) {}
+}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceMonitorImpl.java b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceMonitorImpl.java
index 728c761c71d..cff98957590 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceMonitorImpl.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceMonitorImpl.java
@@ -1,55 +1,50 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.google.inject.Inject;
-import com.yahoo.cloud.config.ConfigserverConfig;
-import com.yahoo.config.model.api.SuperModelProvider;
import com.yahoo.config.provision.Zone;
import com.yahoo.jdisc.Metric;
import com.yahoo.jdisc.Timer;
import com.yahoo.vespa.applicationmodel.ApplicationInstance;
import com.yahoo.vespa.applicationmodel.ApplicationInstanceReference;
-import com.yahoo.vespa.service.monitor.application.DuperModel;
+import com.yahoo.vespa.service.duper.DuperModelManager;
+import com.yahoo.vespa.service.health.HealthMonitorManager;
+import com.yahoo.vespa.service.manager.UnionMonitorManager;
import com.yahoo.vespa.service.monitor.ServiceModel;
import com.yahoo.vespa.service.monitor.ServiceMonitor;
-import com.yahoo.vespa.service.monitor.internal.health.HealthMonitorManager;
-import com.yahoo.vespa.service.monitor.internal.slobrok.SlobrokMonitorManagerImpl;
+import com.yahoo.vespa.service.slobrok.SlobrokMonitorManagerImpl;
import java.util.Map;
public class ServiceMonitorImpl implements ServiceMonitor {
- private final ServiceModelCache serviceModelCache;
+ private final ServiceModelCache serviceModelProvider;
@Inject
- public ServiceMonitorImpl(SuperModelProvider superModelProvider,
- ConfigserverConfig configserverConfig,
+ public ServiceMonitorImpl(DuperModelManager duperModelManager,
SlobrokMonitorManagerImpl slobrokMonitorManager,
HealthMonitorManager healthMonitorManager,
Metric metric,
Timer timer,
- Zone zone,
- DuperModel duperModel) {
- ServiceMonitorMetrics metrics = new ServiceMonitorMetrics(metric, timer);
-
+ Zone zone) {
UnionMonitorManager monitorManager = new UnionMonitorManager(slobrokMonitorManager, healthMonitorManager);
+ duperModelManager.registerListener(monitorManager);
- SuperModelListenerImpl superModelListener = new SuperModelListenerImpl(
+ ServiceModelProvider uncachedServiceModelProvider = new ServiceModelProvider(
monitorManager,
- metrics,
- duperModel,
+ new ServiceMonitorMetrics(metric, timer),
+ duperModelManager,
new ModelGenerator(),
zone);
- superModelListener.start(superModelProvider);
- serviceModelCache = new ServiceModelCache(superModelListener, timer);
+ serviceModelProvider = new ServiceModelCache(uncachedServiceModelProvider, timer);
}
@Override
public Map<ApplicationInstanceReference, ApplicationInstance> getAllApplicationInstances() {
- return serviceModelCache.get().getAllApplicationInstances();
+ return serviceModelProvider.get().getAllApplicationInstances();
}
@Override
public ServiceModel getServiceModelSnapshot() {
- return serviceModelCache.get();
+ return serviceModelProvider.get();
}
}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceMonitorMetrics.java b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceMonitorMetrics.java
index e55a66473bb..368868a43f9 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/ServiceMonitorMetrics.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceMonitorMetrics.java
@@ -1,6 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.jdisc.Metric;
import com.yahoo.jdisc.Timer;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/DuperModelInfraApi.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/DuperModelInfraApi.java
index 2faeca55fa4..c5c96921fa1 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/DuperModelInfraApi.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/DuperModelInfraApi.java
@@ -1,5 +1,5 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.monitor;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.HostName;
@@ -18,7 +18,7 @@ public interface DuperModelInfraApi {
/** Returns true if the DuperModel has registered the infrastructure application as active. */
boolean infraApplicationIsActive(ApplicationId applicationId);
- /** Update the DuperModel: A supported infrastructure application has been activated or is active. */
+ /** Update the DuperModel: A supported infrastructure application has been (re)activated or is active. */
void infraApplicationActivated(ApplicationId applicationId, List<HostName> hostnames);
/** Update the DuperModel: A supported infrastructure application has been removed or is not active. */
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/InfraApplicationApi.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/InfraApplicationApi.java
index 3777a50b531..dbb326b3c50 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/InfraApplicationApi.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/InfraApplicationApi.java
@@ -1,14 +1,10 @@
// 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.monitor.application;
+package com.yahoo.vespa.service.monitor;
import com.yahoo.component.Version;
-import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.Capacity;
import com.yahoo.config.provision.ClusterSpec;
-import com.yahoo.config.provision.HostName;
-
-import java.util.List;
/**
* API of infrastructure application that is accessible via DuperModelInfraApi.
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceModel.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceModel.java
index 2432abcc2d4..a9071e3ab94 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceModel.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceModel.java
@@ -37,6 +37,6 @@ public class ServiceModel {
return applications.values().stream()
.flatMap(application -> application.serviceClusters().stream())
.flatMap(cluster -> cluster.serviceInstances().stream())
- .collect(Collectors.groupingBy(service -> service.hostName(), Collectors.toList()));
+ .collect(Collectors.groupingBy(ServiceInstance::hostName, Collectors.toList()));
}
}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceStatusProvider.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceStatusProvider.java
index 75e61eef772..848cf68c48b 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceStatusProvider.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/ServiceStatusProvider.java
@@ -8,7 +8,7 @@ import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.vespa.applicationmodel.ServiceType;
/**
- * @author hakon
+ * @author hakonhall
*/
public interface ServiceStatusProvider {
/**
@@ -22,4 +22,7 @@ public interface ServiceStatusProvider {
ClusterId clusterId,
ServiceType serviceType,
ConfigId configId);
+
+ /** Returns true if the status provider would start monitoring the application. */
+ boolean wouldMonitor(ApplicationId applicationId);
}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/DuperModel.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/DuperModel.java
deleted file mode 100644
index f74d436bb2e..00000000000
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/DuperModel.java
+++ /dev/null
@@ -1,153 +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.monitor.application;
-
-import com.google.inject.Inject;
-import com.yahoo.cloud.config.ConfigserverConfig;
-import com.yahoo.config.model.api.ApplicationInfo;
-import com.yahoo.config.model.api.SuperModel;
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.HostName;
-import com.yahoo.vespa.flags.FeatureFlag;
-import com.yahoo.vespa.flags.FlagSource;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- * The {@code DuperModel} unites the {@link com.yahoo.config.model.api.SuperModel SuperModel}
- * with synthetic applications like the config server application.
- *
- * @author hakon
- */
-public class DuperModel implements DuperModelInfraApi {
- // Infrastructure applications
- private static final ConfigServerApplication configServerApplication = new ConfigServerApplication();
- private static final ConfigServerHostApplication configServerHostApplication = new ConfigServerHostApplication();
- private static final ProxyHostApplication proxyHostApplication = new ProxyHostApplication();
- private static final ControllerApplication controllerApplication = new ControllerApplication();
- private static final ControllerHostApplication controllerHostApplication = new ControllerHostApplication();
-
- private static final Map<ApplicationId, InfraApplication> supportedInfraApplications = Stream.of(
- configServerApplication,
- configServerHostApplication,
- proxyHostApplication,
- controllerApplication,
- controllerHostApplication)
- .collect(Collectors.toMap(InfraApplication::getApplicationId, Function.identity()));
-
- private final FeatureFlag containsInfra;
- private final FeatureFlag useConfigserverConfig;
- private final boolean multitenant;
-
- // Each of the above infrastructure applications may be active, in case their ApplicationInfo is present here
- private final ConcurrentHashMap<ApplicationId, ApplicationInfo> infraInfos =
- new ConcurrentHashMap<>(2 * supportedInfraApplications.size());
-
- private final ApplicationInfo configServerApplicationFromConfig;
-
- @Inject
- public DuperModel(ConfigserverConfig configServerConfig, FlagSource flagSource) {
- this(
- // Whether to include activate infrastructure applications (except from controller/config apps - see below).
- new FeatureFlag("dupermodel-contains-infra", true, flagSource),
-
- // For historical reasons, the ApplicationInfo in the DuperModel for controllers and config servers
- // is based on the ConfigserverConfig (this flag is true). We want to transition to use the
- // infrastructure application activated by the InfrastructureProvisioner once that supports health.
- new FeatureFlag("dupermodel-use-configserverconfig", true, flagSource),
- configServerConfig.multitenant(),
- configServerApplication.makeApplicationInfoFromConfig(configServerConfig));
- }
-
- /** For testing */
- public DuperModel(FeatureFlag containsInfra,
- FeatureFlag useConfigserverConfig,
- boolean multitenant,
- ApplicationInfo configServerApplicationInfo) {
- this.containsInfra = containsInfra;
- this.useConfigserverConfig = useConfigserverConfig;
- this.multitenant = multitenant;
- this.configServerApplicationFromConfig = configServerApplicationInfo;
- }
-
- public ConfigServerApplication getConfigServerApplication() {
- return configServerApplication;
- }
-
- public ConfigServerHostApplication getConfigServerHostApplication() {
- return configServerHostApplication;
- }
-
- public ProxyHostApplication getProxyHostApplication() {
- return proxyHostApplication;
- }
-
- public ControllerApplication getControllerApplication() {
- return controllerApplication;
- }
-
- public ControllerHostApplication getControllerHostApplication() {
- return controllerHostApplication;
- }
-
- @Override
- public List<InfraApplicationApi> getSupportedInfraApplications() {
- return new ArrayList<>(supportedInfraApplications.values());
- }
-
- @Override
- public boolean infraApplicationIsActive(ApplicationId applicationId) {
- return infraInfos.containsKey(applicationId);
- }
-
- @Override
- public void infraApplicationActivated(ApplicationId applicationId, List<HostName> hostnames) {
- InfraApplication application = supportedInfraApplications.get(applicationId);
- if (application == null) {
- throw new IllegalArgumentException("There is no infrastructure application with ID '" + applicationId + "'");
- }
-
- infraInfos.put(application.getApplicationId(), application.makeApplicationInfo(hostnames));
- }
-
- @Override
- public void infraApplicationRemoved(ApplicationId applicationId) {
- infraInfos.remove(applicationId);
- }
-
- public List<ApplicationInfo> getApplicationInfos(SuperModel superModelSnapshot) {
- List<ApplicationInfo> infos = new ArrayList<>();
-
- // Single-tenant applications have the config server as part of the application model.
- if (multitenant) {
- if (useConfigserverConfig.value()) {
- infos.add(configServerApplicationFromConfig);
- } else {
- ApplicationInfo info = infraInfos.get(controllerApplication.getApplicationId());
- if (info == null) {
- info = infraInfos.get(configServerApplication.getApplicationId());
- }
-
- if (info != null) {
- infos.add(info);
- }
- }
- }
-
- if (containsInfra.value()) {
- // All infra apps, excluding controller and config server which handled above.
- infraInfos.values().stream()
- .filter(info -> !info.getApplicationId().equals(controllerApplication.getApplicationId()) &&
- !info.getApplicationId().equals(configServerApplication.getApplicationId()))
- .forEach(infos::add);
- }
-
- infos.addAll(superModelSnapshot.getAllApplicationInfos());
- return infos;
- }
-}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/package-info.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/package-info.java
deleted file mode 100644
index a5b98074567..00000000000
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/application/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/*
- * @author freva
- */
-@ExportPackage
-package com.yahoo.vespa.service.monitor.application;
-
-import com.yahoo.osgi.annotation.ExportPackage;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/SuperModelListenerImpl.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/SuperModelListenerImpl.java
deleted file mode 100644
index 7e2b61af090..00000000000
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/SuperModelListenerImpl.java
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
-
-import com.yahoo.config.model.api.ApplicationInfo;
-import com.yahoo.config.model.api.SuperModel;
-import com.yahoo.config.model.api.SuperModelListener;
-import com.yahoo.config.model.api.SuperModelProvider;
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.Zone;
-import com.yahoo.vespa.service.monitor.application.DuperModel;
-import com.yahoo.vespa.service.monitor.ServiceModel;
-import com.yahoo.vespa.service.monitor.ServiceStatusProvider;
-
-import java.util.List;
-import java.util.function.Supplier;
-import java.util.logging.Logger;
-
-public class SuperModelListenerImpl implements SuperModelListener, Supplier<ServiceModel> {
- private static final Logger logger = Logger.getLogger(SuperModelListenerImpl.class.getName());
-
- private final ServiceMonitorMetrics metrics;
- private final DuperModel duperModel;
- private final ModelGenerator modelGenerator;
- private final Zone zone;
-
- // superModel and monitorManager are always updated together
- // and atomically using this monitor.
- private final Object monitor = new Object();
- private final MonitorManager monitorManager;
- private SuperModel superModel;
-
- SuperModelListenerImpl(MonitorManager monitorManager,
- ServiceMonitorMetrics metrics,
- DuperModel duperModel,
- ModelGenerator modelGenerator,
- Zone zone) {
- this.monitorManager = monitorManager;
- this.metrics = metrics;
- this.duperModel = duperModel;
- this.modelGenerator = modelGenerator;
- this.zone = zone;
- }
-
- void start(SuperModelProvider superModelProvider) {
- synchronized (monitor) {
- // This snapshot() call needs to be within the synchronized block,
- // since applicationActivated()/applicationRemoved() may be called
- // asynchronously even before snapshot() returns.
- this.superModel = superModelProvider.snapshot(this);
- duperModel.getApplicationInfos(superModel).forEach(monitorManager::applicationActivated);
- }
- }
-
- @Override
- public void applicationActivated(SuperModel superModel, ApplicationInfo application) {
- synchronized (monitor) {
- this.superModel = superModel;
- monitorManager.applicationActivated(application);
- }
- }
-
- @Override
- public void applicationRemoved(SuperModel superModel, ApplicationId id) {
- synchronized (monitor) {
- this.superModel = superModel;
- monitorManager.applicationRemoved(id);
- }
- }
-
- @Override
- public ServiceModel get() {
- try (LatencyMeasurement measurement = metrics.startServiceModelSnapshotLatencyMeasurement()) {
- // Reference 'measurement' in a dummy statement, otherwise the compiler
- // complains about "auto-closeable resource is never referenced in body of
- // corresponding try statement". Why hasn't javac fixed this!?
- dummy(measurement);
-
- // WARNING: The slobrok monitor manager may be out-of-sync with super model (no locking)
- List<ApplicationInfo> applicationInfos = duperModel.getApplicationInfos(superModel);
-
- return modelGenerator.toServiceModel(applicationInfos, zone, (ServiceStatusProvider) monitorManager);
- }
- }
-
- private void dummy(LatencyMeasurement measurement) {}
-}
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitor.java b/service-monitor/src/main/java/com/yahoo/vespa/service/slobrok/SlobrokMonitor.java
index a857be84cc7..482969c6625 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitor.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/slobrok/SlobrokMonitor.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.slobrok;
+package com.yahoo.vespa.service.slobrok;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.HostInfo;
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitorManagerImpl.java b/service-monitor/src/main/java/com/yahoo/vespa/service/slobrok/SlobrokMonitorManagerImpl.java
index 68958c94dfd..39da5040ca0 100644
--- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitorManagerImpl.java
+++ b/service-monitor/src/main/java/com/yahoo/vespa/service/slobrok/SlobrokMonitorManagerImpl.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.slobrok;
+package com.yahoo.vespa.service.slobrok;
import com.google.inject.Inject;
import com.yahoo.config.model.api.ApplicationInfo;
@@ -10,9 +10,9 @@ import com.yahoo.vespa.applicationmodel.ClusterId;
import com.yahoo.vespa.applicationmodel.ConfigId;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.vespa.applicationmodel.ServiceType;
+import com.yahoo.vespa.service.duper.DuperModelManager;
+import com.yahoo.vespa.service.manager.MonitorManager;
import com.yahoo.vespa.service.monitor.SlobrokApi;
-import com.yahoo.vespa.service.monitor.application.ConfigServerApplication;
-import com.yahoo.vespa.service.monitor.internal.MonitorManager;
import java.util.HashMap;
import java.util.List;
@@ -40,7 +40,7 @@ public class SlobrokMonitorManagerImpl implements SlobrokApi, MonitorManager {
@Override
public void applicationActivated(ApplicationInfo application) {
- if (!applicationMonitoredWithSlobrok(application.getApplicationId())) {
+ if (!wouldMonitor(application.getApplicationId())) {
return;
}
@@ -54,7 +54,7 @@ public class SlobrokMonitorManagerImpl implements SlobrokApi, MonitorManager {
@Override
public void applicationRemoved(ApplicationId id) {
- if (!applicationMonitoredWithSlobrok(id)) {
+ if (!wouldMonitor(id)) {
return;
}
@@ -86,7 +86,7 @@ public class SlobrokMonitorManagerImpl implements SlobrokApi, MonitorManager {
ClusterId clusterId,
ServiceType serviceType,
ConfigId configId) {
- if (!applicationMonitoredWithSlobrok(applicationId)) {
+ if (!wouldMonitor(applicationId)) {
return ServiceStatus.NOT_CHECKED;
}
@@ -106,8 +106,9 @@ public class SlobrokMonitorManagerImpl implements SlobrokApi, MonitorManager {
}
}
- private boolean applicationMonitoredWithSlobrok(ApplicationId applicationId) {
- if (applicationId.equals(ConfigServerApplication.CONFIG_SERVER_APPLICATION.getApplicationId())) {
+ @Override
+ public boolean wouldMonitor(ApplicationId applicationId) {
+ if (DuperModelManager.isInfrastructureApplication(applicationId)) {
return false;
}
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelManagerTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelManagerTest.java
new file mode 100644
index 00000000000..da693df77ce
--- /dev/null
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelManagerTest.java
@@ -0,0 +1,184 @@
+// 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.cloud.config.ConfigserverConfig;
+import com.yahoo.config.model.api.ApplicationInfo;
+import com.yahoo.config.model.api.SuperModel;
+import com.yahoo.config.model.api.SuperModelListener;
+import com.yahoo.config.model.api.SuperModelProvider;
+import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.config.provision.HostName;
+import com.yahoo.vespa.service.monitor.ConfigserverUtil;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * @author hakonhall
+ */
+public class DuperModelManagerTest {
+ private final ConfigserverConfig configserverConfig = ConfigserverUtil.createExampleConfigserverConfig();
+ private final ApplicationInfo configServerApplicationFromConfig = new ConfigServerApplication().makeApplicationInfoFromConfig(configserverConfig);
+ private final SuperModelProvider superModelProvider = mock(SuperModelProvider.class);
+ private final SuperModel superModel = mock(SuperModel.class);
+ private final DuperModel duperModel = mock(DuperModel.class);
+
+ private DuperModelManager manager;
+ private SuperModelListener superModelListener;
+
+ private void makeManager() {
+ makeManager(true);
+ }
+
+ private void makeManager(boolean containsInfra) {
+ makeManager(containsInfra, true);
+ }
+
+ private void makeManager(boolean containsInfra, boolean useConfigServerConfig) {
+ manager = new DuperModelManager(
+ containsInfra,
+ useConfigServerConfig,
+ true,
+ configServerApplicationFromConfig,
+ superModelProvider,
+ duperModel);
+
+ when(superModelProvider.getSuperModel()).thenReturn(superModel);
+ verify(duperModel, times(useConfigServerConfig ? 1 : 0)).add(any());
+
+ ArgumentCaptor<SuperModelListener> superModelListenerCaptor = ArgumentCaptor.forClass(SuperModelListener.class);
+ verify(superModelProvider, times(1)).registerListener(superModelListenerCaptor.capture());
+ superModelListener = superModelListenerCaptor.getValue();
+ }
+
+ @Test
+ public void testSuperModelAffectsDuperModel() {
+ makeManager();
+
+ superModelListener.applicationActivated(superModel, mock(ApplicationInfo.class));
+ verify(duperModel, times(2)).add(any());
+
+ verify(duperModel, times(0)).remove(any());
+ superModelListener.applicationRemoved(superModel, ApplicationId.from("tenant", "app", "default"));
+ verify(duperModel, times(1)).remove(any());
+ }
+
+ @Test
+ public void testInfraApplicationsAffectsDuperModel() {
+ makeManager();
+
+ ApplicationId id = manager.getProxyHostApplication().getApplicationId();
+ List<HostName> proxyHostHosts = Stream.of("proxyhost1", "proxyhost2").map(HostName::from).collect(Collectors.toList());
+ manager.infraApplicationActivated(id, proxyHostHosts);
+ verify(duperModel, times(2)).add(any());
+ when(duperModel.contains(id)).thenReturn(true);
+
+ verify(duperModel, times(0)).remove(any());
+ manager.infraApplicationRemoved(id);
+ verify(duperModel, times(1)).remove(any());
+ }
+
+ @Test
+ public void testDisableInfraApplications() {
+ makeManager(false);
+
+ List<HostName> proxyHostHosts = Stream.of("proxyhost1", "proxyhost2").map(HostName::from).collect(Collectors.toList());
+ manager.infraApplicationActivated(manager.getProxyHostApplication().getApplicationId(), proxyHostHosts);
+ verify(duperModel, times(1)).add(any());
+
+ verify(duperModel, times(0)).remove(any());
+ manager.infraApplicationRemoved(manager.getProxyHostApplication().getApplicationId());
+ verify(duperModel, times(0)).remove(any());
+ }
+
+ @Test
+ public void testConfigServerInfraApplications() {
+ makeManager();
+ testConfigServerLikeInfraApplication(manager.getConfigServerApplication().getApplicationId());
+ }
+
+ @Test
+ public void testControllerInfraApplications() {
+ makeManager();
+ testConfigServerLikeInfraApplication(manager.getControllerApplication().getApplicationId());
+ }
+
+ private void testConfigServerLikeInfraApplication(ApplicationId configServerLikeId) {
+ List<HostName> hostnames = Stream.of("node1", "node2").map(HostName::from).collect(Collectors.toList());
+ manager.infraApplicationActivated(configServerLikeId, hostnames);
+ verify(duperModel, times(1)).add(any());
+
+ verify(duperModel, times(0)).remove(any());
+ manager.infraApplicationRemoved(configServerLikeId);
+ verify(duperModel, times(0)).remove(any());
+ }
+
+ @Test
+ public void testEnabledConfigServerInfraApplications() {
+ makeManager(true, false);
+ testEnabledConfigServerLikeInfraApplication(
+ manager.getConfigServerApplication().getApplicationId(),
+ manager.getControllerApplication().getApplicationId());
+ }
+
+ @Test
+ public void testEnabledControllerInfraApplications() {
+ makeManager(true, false);
+ testEnabledConfigServerLikeInfraApplication(
+ manager.getControllerApplication().getApplicationId(),
+ manager.getConfigServerApplication().getApplicationId());
+ }
+
+ private void testEnabledConfigServerLikeInfraApplication(ApplicationId firstId, ApplicationId secondId) {
+ List<HostName> hostnames1 = Stream.of("node11", "node12").map(HostName::from).collect(Collectors.toList());
+ manager.infraApplicationActivated(firstId, hostnames1);
+ verify(duperModel, times(1)).add(any());
+ when(duperModel.contains(firstId)).thenReturn(true);
+
+ // Adding the second config server like application will be ignored
+ List<HostName> hostnames2 = Stream.of("node21", "node22").map(HostName::from).collect(Collectors.toList());
+ manager.infraApplicationActivated(secondId, hostnames2);
+ verify(duperModel, times(1)).add(any());
+
+ verify(duperModel, times(0)).remove(any());
+ manager.infraApplicationRemoved(firstId);
+ verify(duperModel, times(1)).remove(any());
+ when(duperModel.contains(firstId)).thenReturn(false);
+
+ // Removing the second config server like application cannot be removed since it wasn't added
+ verify(duperModel, times(1)).remove(any());
+ manager.infraApplicationRemoved(secondId);
+ verify(duperModel, times(1)).remove(any());
+ }
+
+ @Test
+ public void testSingleTenant() {
+ manager = new DuperModelManager(
+ true,
+ true,
+ false,
+ configServerApplicationFromConfig,
+ superModelProvider,
+ duperModel);
+
+ when(superModelProvider.getSuperModel()).thenReturn(superModel);
+ verify(duperModel, times(0)).add(any());
+
+ List<HostName> hostnames = Stream.of("node1", "node2").map(HostName::from).collect(Collectors.toList());
+ manager.infraApplicationActivated(manager.getConfigServerApplication().getApplicationId(), hostnames);
+ verify(duperModel, times(0)).add(any());
+
+ verify(duperModel, times(0)).remove(any());
+ manager.infraApplicationRemoved(manager.getConfigServerApplication().getApplicationId());
+ verify(duperModel, times(0)).remove(any());
+ }
+} \ No newline at end of file
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelTest.java
new file mode 100644
index 00000000000..31fd266649a
--- /dev/null
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelTest.java
@@ -0,0 +1,63 @@
+// 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.ApplicationInfo;
+import com.yahoo.config.provision.ApplicationId;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+/**
+ * @author hakonhall
+ */
+public class DuperModelTest {
+ private final DuperModel duperModel = new DuperModel();
+ private final ApplicationInfo application1 = mock(ApplicationInfo.class);
+ private final ApplicationId id1 = ApplicationId.fromSerializedForm("tenant:app1:default");
+ private final ApplicationId id2 = ApplicationId.fromSerializedForm("tenant:app2:default");
+ private final ApplicationInfo application2 = mock(ApplicationInfo.class);
+ private final DuperModelListener listener1 = mock(DuperModelListener.class);
+
+ @Before
+ public void setUp() {
+ when(application1.getApplicationId()).thenReturn(id1);
+ when(application2.getApplicationId()).thenReturn(id2);
+ }
+
+ @Test
+ public void test() {
+ duperModel.add(application1);
+ assertTrue(duperModel.contains(id1));
+ assertEquals(Arrays.asList(application1), duperModel.getApplicationInfos());
+
+ duperModel.registerListener(listener1);
+ verify(listener1, times(1)).applicationActivated(application1);
+ verifyNoMoreInteractions(listener1);
+
+ duperModel.remove(id2);
+ verifyNoMoreInteractions(listener1);
+
+ duperModel.add(application2);
+ verify(listener1, times(1)).applicationActivated(application2);
+ verifyNoMoreInteractions(listener1);
+
+ duperModel.remove(id1);
+ assertFalse(duperModel.contains(id1));
+ verify(listener1, times(1)).applicationRemoved(id1);
+ verifyNoMoreInteractions(listener1);
+ assertEquals(Arrays.asList(application2), duperModel.getApplicationInfos());
+
+ duperModel.remove(id1);
+ verifyNoMoreInteractions(listener1);
+ }
+} \ No newline at end of file
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/ApplicationHealthMonitorTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/health/ApplicationHealthMonitorTest.java
index 945d6c633af..078f34b84d1 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/ApplicationHealthMonitorTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/health/ApplicationHealthMonitorTest.java
@@ -1,10 +1,9 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
-import com.yahoo.vespa.service.monitor.application.ConfigServerApplication;
-import com.yahoo.vespa.service.monitor.application.DuperModel;
-import com.yahoo.vespa.service.monitor.internal.ConfigserverUtil;
+import com.yahoo.vespa.service.duper.ConfigServerApplication;
+import com.yahoo.vespa.service.monitor.ConfigserverUtil;
import org.junit.Test;
import java.util.HashMap;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/HealthClientTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthClientTest.java
index 43200a8fa2e..157b5565071 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/HealthClientTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthClientTest.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.yahoo.config.provision.HostName;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitorManagerTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java
index b9d25406f9b..0b9d7e123b5 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitorManagerTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java
@@ -1,14 +1,13 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
-import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.vespa.applicationmodel.ClusterId;
import com.yahoo.vespa.applicationmodel.ConfigId;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.vespa.applicationmodel.ServiceType;
-import com.yahoo.vespa.service.monitor.application.ZoneApplication;
-import com.yahoo.vespa.service.monitor.internal.ConfigserverUtil;
+import com.yahoo.vespa.service.duper.ZoneApplication;
+import com.yahoo.vespa.service.monitor.ConfigserverUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -16,29 +15,15 @@ import static org.junit.Assert.assertEquals;
public class HealthMonitorManagerTest {
@Test
public void addRemove() {
- ConfigserverConfig config = ConfigserverUtil.createExampleConfigserverConfig();
- HealthMonitorManager manager = new HealthMonitorManager(config);
+ HealthMonitorManager manager = new HealthMonitorManager();
ApplicationInfo applicationInfo = ConfigserverUtil.makeExampleConfigServer();
manager.applicationActivated(applicationInfo);
manager.applicationRemoved(applicationInfo.getApplicationId());
}
@Test
- public void withNodeAdmin() {
- ConfigserverConfig config = ConfigserverUtil.createExampleConfigserverConfig();
- HealthMonitorManager manager = new HealthMonitorManager(config);
- ServiceStatus status = manager.getStatus(
- ZoneApplication.ZONE_APPLICATION_ID,
- ClusterId.NODE_ADMIN,
- ServiceType.CONTAINER,
- new ConfigId("config-id-1"));
- assertEquals(ServiceStatus.NOT_CHECKED, status);
- }
-
- @Test
public void withHostAdmin() {
- ConfigserverConfig config = ConfigserverUtil.createExampleConfigserverConfig(false, true);
- HealthMonitorManager manager = new HealthMonitorManager(config);
+ HealthMonitorManager manager = new HealthMonitorManager();
ServiceStatus status = manager.getStatus(
ZoneApplication.ZONE_APPLICATION_ID,
ClusterId.NODE_ADMIN,
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitorTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorTest.java
index 2a203027353..94ba4726ad0 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/health/HealthMonitorTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorTest.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.health;
+package com.yahoo.vespa.service.health;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
import org.junit.Test;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/UnionMonitorManagerTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java
index 79916e43712..a0c7aca5869 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/UnionMonitorManagerTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/manager/UnionMonitorManagerTest.java
@@ -1,18 +1,18 @@
// 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.monitor.internal;
+package com.yahoo.vespa.service.manager;
import com.yahoo.vespa.applicationmodel.ConfigId;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
-import com.yahoo.vespa.service.monitor.internal.health.HealthMonitorManager;
-import com.yahoo.vespa.service.monitor.internal.slobrok.SlobrokMonitorManagerImpl;
+import com.yahoo.vespa.service.health.HealthMonitorManager;
+import com.yahoo.vespa.service.slobrok.SlobrokMonitorManagerImpl;
import org.junit.Test;
import static com.yahoo.vespa.applicationmodel.ClusterId.NODE_ADMIN;
-import static com.yahoo.vespa.applicationmodel.ServiceStatus.*;
+import static com.yahoo.vespa.applicationmodel.ServiceStatus.DOWN;
import static com.yahoo.vespa.applicationmodel.ServiceStatus.NOT_CHECKED;
import static com.yahoo.vespa.applicationmodel.ServiceStatus.UP;
import static com.yahoo.vespa.applicationmodel.ServiceType.CONTAINER;
-import static com.yahoo.vespa.service.monitor.application.ZoneApplication.ZONE_APPLICATION_ID;
+import static com.yahoo.vespa.service.duper.ZoneApplication.ZONE_APPLICATION_ID;
import static org.junit.Assert.assertSame;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/application/ApplicationInstanceGeneratorTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java
index 4608e8b0aa8..a59206d14e2 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/application/ApplicationInstanceGeneratorTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java
@@ -1,5 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.application;
+package com.yahoo.vespa.service.model;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.model.api.ApplicationInfo;
@@ -7,14 +7,15 @@ import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.applicationmodel.ApplicationInstance;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.vespa.service.monitor.ServiceStatusProvider;
-import com.yahoo.vespa.service.monitor.internal.ConfigserverUtil;
+import com.yahoo.vespa.service.monitor.ConfigserverUtil;
+import com.yahoo.vespa.service.duper.ConfigServerApplication;
import org.junit.Test;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import static com.yahoo.vespa.service.monitor.application.ConfigServerApplication.CONFIG_SERVER_APPLICATION;
+import static com.yahoo.vespa.service.duper.ConfigServerApplication.CONFIG_SERVER_APPLICATION;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ExampleModel.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ExampleModel.java
index 2fb7828821d..96e69f3cb69 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ExampleModel.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ExampleModel.java
@@ -1,5 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.HostInfo;
@@ -9,7 +9,7 @@ import com.yahoo.config.model.api.ServiceInfo;
import com.yahoo.config.model.api.SuperModel;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.InstanceName;
-import com.yahoo.vespa.service.monitor.internal.slobrok.SlobrokMonitor;
+import com.yahoo.vespa.service.slobrok.SlobrokMonitor;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ExampleModelTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ExampleModelTest.java
index 64ba2ba5097..59a0d520918 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ExampleModelTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ExampleModelTest.java
@@ -1,6 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.HostInfo;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/LatencyMeasurementTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/LatencyMeasurementTest.java
index 6efde340a16..4ec4f3cec9c 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/LatencyMeasurementTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/LatencyMeasurementTest.java
@@ -1,6 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.jdisc.Timer;
import org.junit.Test;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ModelGeneratorTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ModelGeneratorTest.java
index 6574f592b60..bcc136f80e3 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ModelGeneratorTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ModelGeneratorTest.java
@@ -1,9 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.model.api.ApplicationInfo;
-import com.yahoo.config.model.api.SuperModel;
import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.Zone;
@@ -12,14 +11,15 @@ import com.yahoo.vespa.applicationmodel.ApplicationInstanceReference;
import com.yahoo.vespa.applicationmodel.ServiceCluster;
import com.yahoo.vespa.applicationmodel.ServiceInstance;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
-import com.yahoo.vespa.flags.FeatureFlag;
import com.yahoo.vespa.service.monitor.ServiceModel;
-import com.yahoo.vespa.service.monitor.application.ConfigServerApplication;
-import com.yahoo.vespa.service.monitor.application.DuperModel;
-import com.yahoo.vespa.service.monitor.internal.slobrok.SlobrokMonitorManagerImpl;
+import com.yahoo.vespa.service.monitor.ConfigserverUtil;
+import com.yahoo.vespa.service.duper.ConfigServerApplication;
+import com.yahoo.vespa.service.slobrok.SlobrokMonitorManagerImpl;
import org.junit.Test;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -36,15 +36,6 @@ public class ModelGeneratorTest {
@Test
public void toApplicationModel() throws Exception {
- SuperModel superModel = ExampleModel.createExampleSuperModelWithOneRpcPort(HOSTNAME, PORT);
-
- ConfigserverConfig config = ConfigserverUtil.createExampleConfigserverConfig();
- ApplicationInfo configServerInfo = new ConfigServerApplication().makeApplicationInfoFromConfig(config);
- FeatureFlag containsInfra = mock(FeatureFlag.class);
- when(containsInfra.value()).thenReturn(false);
- FeatureFlag useConfigserverConfig = mock(FeatureFlag.class);
- when(useConfigserverConfig.value()).thenReturn(true);
- DuperModel duperModel = new DuperModel(containsInfra, useConfigserverConfig, true, configServerInfo);
ModelGenerator modelGenerator = new ModelGenerator();
Zone zone = new Zone(Environment.from(ENVIRONMENT), RegionName.from(REGION));
@@ -55,7 +46,7 @@ public class ModelGeneratorTest {
ServiceModel serviceModel =
modelGenerator.toServiceModel(
- duperModel.getApplicationInfos(superModel),
+ getExampleApplicationInfos(),
zone,
slobrokMonitorManager);
@@ -66,7 +57,7 @@ public class ModelGeneratorTest {
assertEquals(2, applicationInstances.size());
Iterator<Map.Entry<ApplicationInstanceReference,
- ApplicationInstance>> iterator =
+ ApplicationInstance>> iterator =
applicationInstances.entrySet().iterator();
ApplicationInstance applicationInstance1 = iterator.next().getValue();
@@ -82,6 +73,14 @@ public class ModelGeneratorTest {
}
}
+ private List<ApplicationInfo> getExampleApplicationInfos() {
+ List<ApplicationInfo> applicationInfos = new ArrayList<>();
+ ConfigserverConfig config = ConfigserverUtil.createExampleConfigserverConfig();
+ applicationInfos.add(new ConfigServerApplication().makeApplicationInfoFromConfig(config));
+ applicationInfos.addAll(ExampleModel.createExampleSuperModelWithOneRpcPort(HOSTNAME, PORT).getAllApplicationInfos());
+ return applicationInfos;
+ }
+
private void verifyOtherApplication(ApplicationInstance applicationInstance) {
assertEquals(String.format("%s:%s:%s:%s:%s",
ExampleModel.TENANT,
@@ -112,5 +111,4 @@ public class ModelGeneratorTest {
assertEquals(ConfigServerApplication.APPLICATION_INSTANCE_ID,
applicationInstance.applicationInstanceId());
}
-
}
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ServiceModelCacheTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceModelCacheTest.java
index 2ba6ce0deb8..2d6921df374 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ServiceModelCacheTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceModelCacheTest.java
@@ -1,6 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.jdisc.Timer;
import com.yahoo.vespa.service.monitor.ServiceModel;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceModelProviderTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceModelProviderTest.java
new file mode 100644
index 00000000000..13f6da1534d
--- /dev/null
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceModelProviderTest.java
@@ -0,0 +1,44 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.service.model;
+
+import com.yahoo.config.model.api.ApplicationInfo;
+import com.yahoo.config.provision.Zone;
+import com.yahoo.vespa.service.monitor.ServiceModel;
+import com.yahoo.vespa.service.duper.DuperModelManager;
+import com.yahoo.vespa.service.slobrok.SlobrokMonitorManagerImpl;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class ServiceModelProviderTest {
+ @Test
+ public void sanityCheck() {
+ SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
+ DuperModelManager duperModelManager = mock(DuperModelManager.class);
+ ModelGenerator modelGenerator = mock(ModelGenerator.class);
+ Zone zone = mock(Zone.class);
+ ServiceModelProvider provider = new ServiceModelProvider(
+ slobrokMonitorManager,
+ mock(ServiceMonitorMetrics.class),
+ duperModelManager,
+ modelGenerator,
+ zone);
+
+ ApplicationInfo application1 = mock(ApplicationInfo.class);
+ ApplicationInfo application2 = mock(ApplicationInfo.class);
+ List<ApplicationInfo> applications = Stream.of(application1, application2)
+ .collect(Collectors.toList());
+ when(duperModelManager.getApplicationInfos()).thenReturn(applications);
+
+ ServiceModel serviceModel = provider.get();
+ verify(duperModelManager, times(1)).getApplicationInfos();
+ verify(modelGenerator).toServiceModel(applications, zone, slobrokMonitorManager);
+ }
+} \ No newline at end of file
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ServiceMonitorMetricsTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceMonitorMetricsTest.java
index 45920a436cf..8654068d7d1 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ServiceMonitorMetricsTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceMonitorMetricsTest.java
@@ -1,6 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
+package com.yahoo.vespa.service.model;
import com.yahoo.jdisc.Metric;
import com.yahoo.jdisc.Timer;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ConfigserverUtil.java b/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/ConfigserverUtil.java
index 16963797ac8..c334fad2334 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ConfigserverUtil.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/ConfigserverUtil.java
@@ -1,9 +1,9 @@
// 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.monitor.internal;
+package com.yahoo.vespa.service.monitor;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.model.api.ApplicationInfo;
-import com.yahoo.vespa.service.monitor.application.ConfigServerApplication;
+import com.yahoo.vespa.service.duper.ConfigServerApplication;
/**
* @author hakon
@@ -26,12 +26,7 @@ public class ConfigserverUtil {
}
public static ConfigserverConfig createExampleConfigserverConfig() {
- return create(true, true, "cfg1", "cfg2", "cfg3");
- }
-
- public static ConfigserverConfig createExampleConfigserverConfig(boolean nodeAdminInContainer,
- boolean multitenant) {
- return create(nodeAdminInContainer, multitenant, "cfg1", "cfg2", "cfg3");
+ return create(false, true, "cfg1", "cfg2", "cfg3");
}
public static ApplicationInfo makeConfigServerApplicationInfo(
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/application/DuperModelTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/application/DuperModelTest.java
deleted file mode 100644
index 9801f80acc9..00000000000
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/application/DuperModelTest.java
+++ /dev/null
@@ -1,104 +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.monitor.application;
-
-import com.yahoo.cloud.config.ConfigserverConfig;
-import com.yahoo.config.model.api.ApplicationInfo;
-import com.yahoo.config.model.api.SuperModel;
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.HostName;
-import com.yahoo.vespa.applicationmodel.ServiceStatus;
-import com.yahoo.vespa.flags.FeatureFlag;
-import com.yahoo.vespa.service.monitor.ServiceStatusProvider;
-import com.yahoo.vespa.service.monitor.internal.ConfigserverUtil;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * @author hakon
- */
-public class DuperModelTest {
- private final ServiceStatusProvider statusProvider = mock(ServiceStatusProvider.class);
- private final ConfigserverConfig configserverConfig = ConfigserverUtil.createExampleConfigserverConfig();
- private final ApplicationInfo configServerApplicationInfo = new ConfigServerApplication().makeApplicationInfoFromConfig(configserverConfig);
- private final SuperModel superModel = mock(SuperModel.class);
- private final FeatureFlag containsInfra = mock(FeatureFlag.class);
- private final FeatureFlag useConfigserverConfig = mock(FeatureFlag.class);
-
- @Before
- public void setUp() {
- when(statusProvider.getStatus(any(), any(), any(), any())).thenReturn(ServiceStatus.NOT_CHECKED);
- }
-
- @Test
- public void toApplicationInstance() {
- when(containsInfra.value()).thenReturn(false);
- when(useConfigserverConfig.value()).thenReturn(true);
- DuperModel duperModel = new DuperModel(containsInfra, useConfigserverConfig, true, configServerApplicationInfo);
- ApplicationInfo superModelApplicationInfo = mock(ApplicationInfo.class);
- when(superModel.getAllApplicationInfos()).thenReturn(Collections.singletonList(superModelApplicationInfo));
- List<ApplicationInfo> applicationInfos = duperModel.getApplicationInfos(superModel);
- assertEquals(2, applicationInfos.size());
- assertEquals(ConfigServerApplication.CONFIG_SERVER_APPLICATION.getApplicationId(), applicationInfos.get(0).getApplicationId());
- assertSame(superModelApplicationInfo, applicationInfos.get(1));
- }
-
- @Test
- public void toApplicationInstanceInSingleTenantMode() {
- when(containsInfra.value()).thenReturn(false);
- when(useConfigserverConfig.value()).thenReturn(true);
- DuperModel duperModel = new DuperModel(containsInfra, useConfigserverConfig, false, configServerApplicationInfo);
- ApplicationInfo superModelApplicationInfo = mock(ApplicationInfo.class);
- when(superModel.getAllApplicationInfos()).thenReturn(Collections.singletonList(superModelApplicationInfo));
- List<ApplicationInfo> applicationInfos = duperModel.getApplicationInfos(superModel);
- assertEquals(1, applicationInfos.size());
- assertSame(superModelApplicationInfo, applicationInfos.get(0));
- }
-
- @Test
- public void testInfraApplications() {
- when(containsInfra.value()).thenReturn(true);
- when(useConfigserverConfig.value()).thenReturn(true);
- DuperModel duperModel = new DuperModel(containsInfra, useConfigserverConfig, true, configServerApplicationInfo);
- ApplicationInfo infraApplicationInfo = mock(ApplicationInfo.class);
- when(superModel.getAllApplicationInfos()).thenReturn(Collections.emptyList());
-
- List<ApplicationInfo> applicationInfos = duperModel.getApplicationInfos(superModel);
- assertEquals(1, applicationInfos.size());
- assertEquals(duperModel.getConfigServerApplication().getApplicationId(), applicationInfos.get(0).getApplicationId());
-
- List<InfraApplicationApi> infraApis = duperModel.getSupportedInfraApplications();
- assertEquals(5, infraApis.size());
-
- InfraApplication proxyHostApp = duperModel.getProxyHostApplication();
- assertFalse(duperModel.infraApplicationIsActive(proxyHostApp.getApplicationId()));
-
- List<HostName> hostnames = Stream.of("host1").map(HostName::from).collect(Collectors.toList());
- duperModel.infraApplicationActivated(proxyHostApp.getApplicationId(), hostnames);
-
- assertTrue(duperModel.infraApplicationIsActive(proxyHostApp.getApplicationId()));
- applicationInfos = duperModel.getApplicationInfos(superModel);
- assertEquals(2, applicationInfos.size());
- List<ApplicationId> applicationIds = applicationInfos.stream()
- .map(ApplicationInfo::getApplicationId)
- .collect(Collectors.toList());
- assertThat(applicationIds, hasItem(proxyHostApp.getApplicationId()));
-
- duperModel.infraApplicationRemoved(proxyHostApp.getApplicationId());
- assertFalse(duperModel.infraApplicationIsActive(proxyHostApp.getApplicationId()));
- }
-}
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/SuperModelListenerImplTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/SuperModelListenerImplTest.java
deleted file mode 100644
index e2da7b98f56..00000000000
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/SuperModelListenerImplTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.service.monitor.internal;
-
-import com.yahoo.config.model.api.ApplicationInfo;
-import com.yahoo.config.model.api.SuperModel;
-import com.yahoo.config.model.api.SuperModelProvider;
-import com.yahoo.config.provision.Zone;
-import com.yahoo.vespa.service.monitor.application.DuperModel;
-import com.yahoo.vespa.service.monitor.ServiceModel;
-import com.yahoo.vespa.service.monitor.internal.slobrok.SlobrokMonitorManagerImpl;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class SuperModelListenerImplTest {
- @Test
- public void sanityCheck() {
- SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
- ServiceMonitorMetrics metrics = mock(ServiceMonitorMetrics.class);
- DuperModel duperModel = mock(DuperModel.class);
- ModelGenerator modelGenerator = mock(ModelGenerator.class);
- Zone zone = mock(Zone.class);
- SuperModelListenerImpl listener = new SuperModelListenerImpl(
- slobrokMonitorManager,
- metrics,
- duperModel,
- modelGenerator,
- zone);
-
- SuperModelProvider superModelProvider = mock(SuperModelProvider.class);
- SuperModel superModel = mock(SuperModel.class);
- when(superModelProvider.snapshot(listener)).thenReturn(superModel);
-
- ApplicationInfo application1 = mock(ApplicationInfo.class);
- ApplicationInfo application2 = mock(ApplicationInfo.class);
- List<ApplicationInfo> applications = Stream.of(application1, application2)
- .collect(Collectors.toList());
- when(duperModel.getApplicationInfos(superModel)).thenReturn(applications);
-
- listener.start(superModelProvider);
- verify(duperModel, times(1)).getApplicationInfos(superModel);
- verify(slobrokMonitorManager).applicationActivated(application1);
- verify(slobrokMonitorManager).applicationActivated(application2);
-
- ServiceModel serviceModel = listener.get();
- verify(duperModel, times(2)).getApplicationInfos(superModel);
- verify(modelGenerator).toServiceModel(applications, zone, slobrokMonitorManager);
- }
-} \ No newline at end of file
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitorManagerImplTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/slobrok/SlobrokMonitorManagerImplTest.java
index a567559980b..c3ee1d078bf 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitorManagerImplTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/slobrok/SlobrokMonitorManagerImplTest.java
@@ -1,5 +1,5 @@
// 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.monitor.internal.slobrok;
+package com.yahoo.vespa.service.slobrok;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.provision.ApplicationId;
diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitorTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/slobrok/SlobrokMonitorTest.java
index 5b230e81cf7..907e52298bf 100644
--- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/slobrok/SlobrokMonitorTest.java
+++ b/service-monitor/src/test/java/com/yahoo/vespa/service/slobrok/SlobrokMonitorTest.java
@@ -1,10 +1,10 @@
// 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.monitor.internal.slobrok;
+package com.yahoo.vespa.service.slobrok;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.jrt.slobrok.api.Mirror;
import com.yahoo.jrt.slobrok.api.SlobrokList;
-import com.yahoo.vespa.service.monitor.internal.ExampleModel;
+import com.yahoo.vespa.service.model.ExampleModel;
import org.junit.Test;
import static org.mockito.Mockito.mock;