diff options
author | Harald Musum <musum@oath.com> | 2018-02-15 08:44:41 +0100 |
---|---|---|
committer | Harald Musum <musum@oath.com> | 2018-02-15 08:44:41 +0100 |
commit | 30bc00c22e93aec39d7223c92c82e2bce99b406e (patch) | |
tree | 3b5d8942de1e01824b58a5dab368e7c462bf7d5e /configserver | |
parent | 374122e84540bfe867437bde39e890db349d0221 (diff) |
Avoid creating ConfigCurator when we already have one
Diffstat (limited to 'configserver')
5 files changed, 11 insertions, 16 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantBuilder.java index b9aa23c93d6..934ba9b754d 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantBuilder.java @@ -139,7 +139,7 @@ public class TenantBuilder { private void createSessionCounter() { if (sessionCounter == null) { - sessionCounter = new SessionCounter(componentRegistry.getCurator(), tenant); + sessionCounter = new SessionCounter(componentRegistry.getConfigCurator(), tenant); } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounter.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounter.java index 8901bb5b115..dc93886e0c0 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounter.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounter.java @@ -3,7 +3,6 @@ package com.yahoo.vespa.config.server.zookeeper; import com.yahoo.log.LogLevel; import com.yahoo.vespa.curator.recipes.CuratorCounter; -import com.yahoo.vespa.curator.Curator; import java.util.ArrayList; import java.util.Collections; @@ -13,8 +12,7 @@ import java.util.List; * A counter that sets its initial value to the number of apps in zookeeper if no counter value is set. Subclass * this to get that behavior. * - * @author lulf - * @since 5.1 + * @author Ulf Lilleengen */ public class InitializedCounter { @@ -22,10 +20,10 @@ public class InitializedCounter { protected final CuratorCounter counter; private final String sessionsDirPath; - public InitializedCounter(Curator curator, String counterPath, String sessionsDirPath) { + public InitializedCounter(ConfigCurator configCurator, String counterPath, String sessionsDirPath) { this.sessionsDirPath = sessionsDirPath; - this.counter = new CuratorCounter(curator, counterPath); - initializeCounterValue(getLatestSessionId(ConfigCurator.create(curator), sessionsDirPath)); + this.counter = new CuratorCounter(configCurator.curator(), counterPath); + initializeCounterValue(getLatestSessionId(configCurator, sessionsDirPath)); } private void initializeCounterValue(Long latestSessionId) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/SessionCounter.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/SessionCounter.java index 4df292dd204..b8f5acdb225 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/SessionCounter.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/SessionCounter.java @@ -3,18 +3,16 @@ package com.yahoo.vespa.config.server.zookeeper; import com.yahoo.config.provision.TenantName; import com.yahoo.vespa.config.server.tenant.Tenants; -import com.yahoo.vespa.curator.Curator; /** * A counter keeping track of session ids in an atomic fashion across multiple config servers. * - * @author lulf - * @since 5.1 + * @author Ulf Lilleengen */ public class SessionCounter extends InitializedCounter { - public SessionCounter(Curator curator, TenantName tenantName) { - super(curator, + public SessionCounter(ConfigCurator configCurator, TenantName tenantName) { + super(configCurator, Tenants.getTenantPath(tenantName).append("sessionCounter").getAbsolute(), Tenants.getSessionsPath(tenantName).getAbsolute()); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java index ac68307f42d..2d182f03de7 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java @@ -50,7 +50,7 @@ public class LocalSessionRepoTest extends TestWithCurator { } clock = new ManualClock(Instant.ofEpochSecond(1)); LocalSessionLoader loader = new SessionFactoryImpl(globalComponentRegistry, - new SessionCounter(globalComponentRegistry.getCurator(), tenantName), + new SessionCounter(globalComponentRegistry.getConfigCurator(), tenantName), new MemoryTenantApplications(), tenantFileSystemDirs, new HostRegistry<>(), tenantName); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java index 67932726df1..b444e09f558 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java @@ -11,8 +11,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; /** - * @author lulf - * @since 5.1 + * @author Ulf Lilleengen */ public class InitializedCounterTest extends TestWithCurator { @@ -28,7 +27,7 @@ public class InitializedCounterTest extends TestWithCurator { @Test public void requireThatCounterIsInitializedFromNumberOfSessions() { - InitializedCounter counter = new InitializedCounter(curator, "/counter", "/sessions"); + InitializedCounter counter = new InitializedCounter(configCurator, "/counter", "/sessions"); assertThat(counter.counter.get(), is(2l)); } |