summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantBuilder.java22
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java25
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java14
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantTest.java19
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java8
7 files changed, 27 insertions, 67 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java
index def78a3d9d8..f260fade41c 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java
@@ -55,7 +55,6 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader {
private final Clock clock;
public SessionFactoryImpl(GlobalComponentRegistry globalComponentRegistry,
- SessionCounter sessionCounter,
TenantApplications applicationRepo,
TenantFileSystemDirs tenantFileSystemDirs,
HostValidator<ApplicationId> hostRegistry,
@@ -65,7 +64,7 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader {
this.sessionPreparer = globalComponentRegistry.getSessionPreparer();
this.curator = globalComponentRegistry.getCurator();
this.configCurator = globalComponentRegistry.getConfigCurator();
- this.sessionCounter = sessionCounter;
+ this.sessionCounter = new SessionCounter(globalComponentRegistry.getConfigCurator(), tenant);;
this.sessionsPath = TenantRepository.getSessionsPath(tenant);
this.applicationRepo = applicationRepo;
this.tenantFileSystemDirs = tenantFileSystemDirs;
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 95a507ede21..cd437704f9a 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
@@ -15,7 +15,6 @@ import com.yahoo.vespa.config.server.application.ZKTenantApplications;
import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs;
import com.yahoo.vespa.config.server.monitoring.Metrics;
import com.yahoo.vespa.config.server.session.*;
-import com.yahoo.vespa.config.server.zookeeper.SessionCounter;
import com.yahoo.vespa.defaults.Defaults;
import java.io.File;
@@ -39,7 +38,6 @@ public class TenantBuilder {
private SessionFactory sessionFactory;
private LocalSessionLoader localSessionLoader;
private TenantApplications applicationRepo;
- private SessionCounter sessionCounter;
private ReloadHandler reloadHandler;
private RequestHandler requestHandler;
private RemoteSessionFactory remoteSessionFactory;
@@ -81,11 +79,6 @@ public class TenantBuilder {
return this;
}
- public TenantBuilder withReloadHandler(ReloadHandler reloadHandler) {
- this.reloadHandler = reloadHandler;
- return this;
- }
-
/**
* Create a real tenant from the properties given by this builder.
*
@@ -96,7 +89,6 @@ public class TenantBuilder {
createApplicationRepo();
createRemoteSessionFactory(componentRegistry.getClock());
createRemoteSessionRepo();
- createSessionCounter();
createServerDbDirs();
createSessionFactory();
createLocalSessionRepo();
@@ -120,8 +112,8 @@ public class TenantBuilder {
private void createSessionFactory() {
if (sessionFactory == null || localSessionLoader == null) {
- SessionFactoryImpl impl = new SessionFactoryImpl(componentRegistry, sessionCounter,
- applicationRepo, tenantFileSystemDirs, hostValidator, tenant);
+ SessionFactoryImpl impl = new SessionFactoryImpl(componentRegistry, applicationRepo,
+ tenantFileSystemDirs, hostValidator, tenant);
if (sessionFactory == null) {
sessionFactory = impl;
}
@@ -137,12 +129,6 @@ public class TenantBuilder {
}
}
- private void createSessionCounter() {
- if (sessionCounter == null) {
- sessionCounter = new SessionCounter(componentRegistry.getConfigCurator(), tenant);
- }
- }
-
private void createTenantRequestHandler() {
if (requestHandler == null || reloadHandler == null) {
TenantRequestHandler impl = new TenantRequestHandler(componentRegistry.getMetrics(),
@@ -156,9 +142,7 @@ public class TenantBuilder {
if (requestHandler == null) {
requestHandler = impl;
}
- if (reloadHandler == null) {
- reloadHandler = impl;
- }
+ reloadHandler = impl;
}
}
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 06c64acab33..0a193f7eedd 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
@@ -17,7 +17,6 @@ import com.yahoo.jdisc.Response;
import com.yahoo.path.Path;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.GlobalComponentRegistry;
-import com.yahoo.vespa.config.server.MockReloadHandler;
import com.yahoo.vespa.config.server.SuperModelGenerationCounter;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.ApplicationConvergenceChecker;
@@ -83,23 +82,15 @@ public class ApplicationHandlerTest {
public void setup() {
TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().build();
tenantRepository = new TenantRepository(componentRegistry, false);
-
- TenantBuilder tenantBuilder1 = TenantBuilder.create(componentRegistry, mytenantName)
- .withReloadHandler(new MockReloadHandler());
- tenantRepository.addTenant(tenantBuilder1);
-
- TenantBuilder tenantBuilder2 = TenantBuilder.create(componentRegistry, foobar)
- .withReloadHandler(new MockReloadHandler());
- tenantRepository.addTenant(tenantBuilder2);
-
+ tenantRepository.addTenant(TenantBuilder.create(componentRegistry, mytenantName));
+ tenantRepository.addTenant(TenantBuilder.create(componentRegistry, foobar));
provisioner = new SessionHandlerTest.MockProvisioner();
- mockHandler = createMockApplicationHandler(
- provisioner,
- new ApplicationConvergenceChecker(stateApiFactory),
- mockHttpProxy);
- listApplicationsHandler = new ListApplicationsHandler(
- ListApplicationsHandler.testOnlyContext(),
- tenantRepository, Zone.defaultZone());
+ mockHandler = createMockApplicationHandler(provisioner,
+ new ApplicationConvergenceChecker(stateApiFactory),
+ mockHttpProxy);
+ listApplicationsHandler = new ListApplicationsHandler(ListApplicationsHandler.testOnlyContext(),
+ tenantRepository,
+ Zone.defaultZone());
}
private ApplicationHandler createMockApplicationHandler(
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java
index 537ab5a9f3e..0ac08bfcfb0 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java
@@ -40,8 +40,7 @@ public class HostHandlerTest {
public void setup() {
TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().build();
tenantRepository = new TenantRepository(componentRegistry, false);
- TenantBuilder tb = TenantBuilder.create(componentRegistry, mytenant)
- .withReloadHandler(new MockReloadHandler());
+ TenantBuilder tb = TenantBuilder.create(componentRegistry, mytenant);
tenantRepository.addTenant(tb);
handler = createHostHandler();
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java
index b036dc4400e..6e56d3c30c3 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java
@@ -26,10 +26,8 @@ public class TenantHandlerTest extends TenantTest {
private final TenantName a = TenantName.from("a");
@Before
- public void setup() throws Exception {
- handler = new TenantHandler(
- TenantHandler.testOnlyContext(),
- tenantRepository);
+ public void setup() {
+ handler = new TenantHandler(TenantHandler.testOnlyContext(), tenantRepository);
}
@Test
@@ -50,7 +48,7 @@ public class TenantHandlerTest extends TenantTest {
}
@Test(expected=NotFoundException.class)
- public void testGetNonExisting() throws Exception {
+ public void testGetNonExisting() {
handler.handleGET(HttpRequest.createTestRequest("http://deploy.example.yahoo.com:80/application/v2/tenant/x", Method.GET));
}
@@ -76,7 +74,7 @@ public class TenantHandlerTest extends TenantTest {
}
@Test
- public void testDelete() throws IOException, InterruptedException {
+ public void testDelete() throws IOException {
putSync(HttpRequest.createTestRequest("http://deploy.example.yahoo.com:80/application/v2/tenant/a", Method.PUT));
assertEquals(tenantRepository.getTenant(a).getName(), a);
TenantDeleteResponse delResp = (TenantDeleteResponse) handler.handleDELETE(
@@ -86,7 +84,7 @@ public class TenantHandlerTest extends TenantTest {
}
@Test
- public void testDeleteTenantWithActiveApplications() throws Exception {
+ public void testDeleteTenantWithActiveApplications() {
putSync(HttpRequest.createTestRequest("http://deploy.example.yahoo.com:80/application/v2/tenant/" + a, Method.PUT));
Tenant tenant = tenantRepository.getTenant(a);
assertEquals(a, tenant.getName());
@@ -109,7 +107,7 @@ public class TenantHandlerTest extends TenantTest {
}
@Test(expected=BadRequestException.class)
- public void testIllegalNameSlashes() throws InterruptedException {
+ public void testIllegalNameSlashes() {
putSync(HttpRequest.createTestRequest("http://deploy.example.yahoo.com:80/application/v2/tenant/a/b", Method.PUT));
}
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 040c28b8f96..7814266f815 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
@@ -16,7 +16,7 @@ import org.junit.Before;
/**
* Supertype for tests in the multi tenant application API
*
- * @author vegardh
+ * @author Vegard Havdal
*
*/
public class TenantTest extends TestWithCurator {
@@ -24,29 +24,20 @@ public class TenantTest extends TestWithCurator {
protected TenantRepository tenantRepository;
@Before
- public void setupTenants() throws Exception {
+ public void setupTenants() {
tenantRepository = createTenants();
}
@After
- public void closeTenants() throws IOException {
+ public void closeTenants() {
tenantRepository.close();
}
- protected TenantRepository createTenants() throws Exception {
+ private TenantRepository createTenants() {
return new TenantRepository(new TestComponentRegistry.Builder().curator(curator).build());
}
- protected Executor testExecutor() {
- return new Executor() {
- @Override
- public void execute(Runnable command) {
- command.run();
- }
- };
- }
-
- protected void assertResponseEquals(SessionResponse response, String payload) throws IOException {
+ void assertResponseEquals(SessionResponse response, String payload) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.render(baos);
assertEquals(baos.toString("UTF-8"), payload);
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 2d182f03de7..73caf770512 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
@@ -12,7 +12,6 @@ import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs;
import com.yahoo.io.IOUtils;
import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.SessionHandlerTest;
-import com.yahoo.vespa.config.server.zookeeper.SessionCounter;
import org.junit.Before;
import org.junit.Test;
@@ -50,10 +49,9 @@ public class LocalSessionRepoTest extends TestWithCurator {
}
clock = new ManualClock(Instant.ofEpochSecond(1));
LocalSessionLoader loader = new SessionFactoryImpl(globalComponentRegistry,
- new SessionCounter(globalComponentRegistry.getConfigCurator(), tenantName),
- new MemoryTenantApplications(),
- tenantFileSystemDirs, new HostRegistry<>(),
- tenantName);
+ new MemoryTenantApplications(),
+ tenantFileSystemDirs, new HostRegistry<>(),
+ tenantName);
repo = new LocalSessionRepo(tenantFileSystemDirs, loader, clock, 5);
}