diff options
author | Harald Musum <musum@oath.com> | 2017-11-09 11:31:21 +0100 |
---|---|---|
committer | Harald Musum <musum@oath.com> | 2017-11-09 11:31:21 +0100 |
commit | b48b47867cdd9551896c9c3651b5b2d6a38165c7 (patch) | |
tree | 914ac0bb71caf1a751f8b30d1258f23b7040f821 /configserver | |
parent | 3143f748bbe39f480f44611bb814a2387983f913 (diff) |
Metrics is available in component registry, remove from constructor args
Diffstat (limited to 'configserver')
7 files changed, 13 insertions, 22 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java index 866d1563e3f..f256d46218c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java @@ -11,7 +11,6 @@ import com.yahoo.log.LogLevel; import com.yahoo.path.Path; import com.yahoo.vespa.config.server.GlobalComponentRegistry; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; -import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.curator.Curator; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; @@ -78,10 +77,10 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen * @throws Exception is creating the Tenants instance fails */ @Inject - public Tenants(GlobalComponentRegistry globalComponentRegistry, Metrics metrics) throws Exception { + public Tenants(GlobalComponentRegistry globalComponentRegistry) throws Exception { this.globalComponentRegistry = globalComponentRegistry; this.curator = globalComponentRegistry.getCurator(); - metricUpdater = metrics.getOrCreateMetricUpdater(Collections.emptyMap()); + metricUpdater = globalComponentRegistry.getMetrics().getOrCreateMetricUpdater(Collections.emptyMap()); this.tenantListeners.add(globalComponentRegistry.getTenantListener()); curator.framework().getConnectionStateListenable().addListener(this); @@ -99,13 +98,12 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen /** * New instance containing the given tenants. This will not create Zookeeper watches. For testing only * @param globalComponentRegistry a {@link com.yahoo.vespa.config.server.GlobalComponentRegistry} instance - * @param metrics a {@link com.yahoo.vespa.config.server.monitoring.Metrics} instance * @param tenants a collection of {@link Tenant}s */ - public Tenants(GlobalComponentRegistry globalComponentRegistry, Metrics metrics, Collection<Tenant> tenants) { + public Tenants(GlobalComponentRegistry globalComponentRegistry, Collection<Tenant> tenants) { this.globalComponentRegistry = globalComponentRegistry; this.curator = globalComponentRegistry.getCurator(); - metricUpdater = metrics.getOrCreateMetricUpdater(Collections.emptyMap()); + metricUpdater = globalComponentRegistry.getMetrics().getOrCreateMetricUpdater(Collections.emptyMap()); this.tenantListeners.add(globalComponentRegistry.getTenantListener()); curator.create(tenantsPath); createSystemTenants(globalComponentRegistry.getConfigserverConfig()); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java index 43fd8a92189..dea468eb0be 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java @@ -96,14 +96,12 @@ public class DeployTester { } public DeployTester(String appPath, List<ModelFactory> modelFactories, ConfigserverConfig configserverConfig, Clock clock) { - Metrics metrics = Metrics.createTestMetrics(); - Curator curator = new MockCurator(); this.clock = clock; - TestComponentRegistry componentRegistry = createComponentRegistry(curator, metrics, modelFactories, - configserverConfig, clock); + TestComponentRegistry componentRegistry = createComponentRegistry(new MockCurator(), Metrics.createTestMetrics(), + modelFactories, configserverConfig, clock); try { this.testApp = new File(appPath); - this.tenants = new Tenants(componentRegistry, metrics, Collections.emptySet()); + this.tenants = new Tenants(componentRegistry, Collections.emptySet()); } catch (Exception e) { throw new IllegalArgumentException(e); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java index 892c821950e..5552758a0a6 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java @@ -292,7 +292,7 @@ public class ApplicationHandlerTest { Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))) .build(); - Tenants tenants = new Tenants(componentRegistry, Metrics.createTestMetrics()); // Creates the application path element in zk + Tenants tenants = new Tenants(componentRegistry); // Creates the application path element in zk tenants.addTenant(tenantName); Tenant tenant = tenants.getTenant(tenantName); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantTest.java index d82f62cfc1a..9dbb193ab3d 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantTest.java @@ -9,7 +9,6 @@ import java.util.concurrent.Executor; import com.yahoo.vespa.config.server.*; import com.yahoo.vespa.config.server.http.SessionResponse; -import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.tenant.Tenants; import org.junit.After; import org.junit.Before; @@ -35,7 +34,7 @@ public class TenantTest extends TestWithCurator { } protected Tenants createTenants() throws Exception { - return new Tenants(new TestComponentRegistry.Builder().curator(curator).build(), Metrics.createTestMetrics()); + return new Tenants(new TestComponentRegistry.Builder().curator(curator).build()); } protected Executor testExecutor() { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java index 2b1000c2211..959dfab1bee 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java @@ -7,7 +7,6 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.path.Path; import com.yahoo.vespa.config.server.*; import com.yahoo.vespa.config.server.application.MemoryTenantApplications; -import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.session.LocalSessionRepo; import com.yahoo.vespa.config.server.session.RemoteSessionRepo; import com.yahoo.vespa.config.server.tenant.Tenant; @@ -57,6 +56,6 @@ public class TestTenantBuilder { } } }); - return new Tenants(componentRegistry, Metrics.createTestMetrics(), tenantList); + return new Tenants(componentRegistry, tenantList); } } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantsTestCase.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantsTestCase.java index 59dec6946f9..45be489952f 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantsTestCase.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantsTestCase.java @@ -11,7 +11,6 @@ import com.yahoo.vespa.config.server.TestComponentRegistry; import com.yahoo.vespa.config.server.TestWithCurator; import com.yahoo.vespa.config.server.application.Application; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; -import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.model.VespaModel; import org.junit.After; import org.junit.Before; @@ -47,7 +46,7 @@ public class TenantsTestCase extends TestWithCurator { listener = (TenantRequestHandlerTest.MockReloadListener)globalComponentRegistry.getReloadListener(); tenantListener = (MockTenantListener)globalComponentRegistry.getTenantListener(); tenantListener.tenantsLoaded = false; - tenants = new Tenants(globalComponentRegistry, Metrics.createTestMetrics()); + tenants = new Tenants(globalComponentRegistry); assertTrue(tenantListener.tenantsLoaded); tenants.addTenant(tenant1); tenants.addTenant(tenant2); @@ -115,7 +114,7 @@ public class TenantsTestCase extends TestWithCurator { @Test public void testTenantsChanged() throws Exception { tenants.close(); // close the Tenants instance created in setupSession, we do not want to use one with a PatchChildrenCache listener - tenants = new Tenants(globalComponentRegistry, Metrics.createTestMetrics(), new ArrayList<>()); + tenants = new Tenants(globalComponentRegistry, new ArrayList<>()); TenantName defaultTenant = TenantName.defaultName(); tenants.addTenant(tenant2); tenants.addTenant(defaultTenant); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestWithTenant.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestWithTenant.java index c11480f5335..4573f785842 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestWithTenant.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestWithTenant.java @@ -3,7 +3,6 @@ package com.yahoo.vespa.config.server.tenant; import com.yahoo.vespa.config.server.TestComponentRegistry; import com.yahoo.vespa.config.server.TestWithCurator; -import com.yahoo.vespa.config.server.monitoring.Metrics; import org.junit.Before; /** @@ -19,8 +18,7 @@ public class TestWithTenant extends TestWithCurator { @Before public void setupTenant() throws Exception { - final Metrics metrics = Metrics.createTestMetrics(); - tenants = new Tenants(new TestComponentRegistry.Builder().curator(curator).metrics(metrics).build(), metrics); + tenants = new Tenants(new TestComponentRegistry.Builder().curator(curator).build()); tenant = tenants.defaultTenant(); } |