summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2019-07-17 13:09:37 +0200
committerHarald Musum <musum@verizonmedia.com>2019-07-17 13:09:37 +0200
commit628639871c09050b2ed15bab8d35967311eb322d (patch)
treeafc02553a791a4656090e34b63acb5e2dc70151b /configserver
parentc4dfcdbff503e42684251c8d230da093ba836148 (diff)
Create TenantFileShystemDirs where needed
No functional changes
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java47
-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/Tenant.java11
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantBuilder.java16
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java16
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java5
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java12
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java31
8 files changed, 62 insertions, 79 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java
index f6d73f33504..ad7a5116ac4 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java
@@ -1,8 +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.config.server.session;
-import com.yahoo.concurrent.InThreadExecutorService;
-import com.yahoo.concurrent.StripedExecutor;
import com.yahoo.config.provision.TenantName;
import com.yahoo.log.LogLevel;
import com.yahoo.path.Path;
@@ -16,7 +14,6 @@ import com.yahoo.vespa.curator.Curator;
import java.io.File;
import java.io.FilenameFilter;
import java.time.Clock;
-import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -40,23 +37,20 @@ public class LocalSessionRepo extends SessionRepo<LocalSession> {
private final Clock clock;
private final Curator curator;
private final Executor zkWatcherExecutor;
+ private final TenantFileSystemDirs tenantFileSystemDirs;
- public LocalSessionRepo(TenantName tenantName, GlobalComponentRegistry registry, TenantFileSystemDirs tenantFileSystemDirs, LocalSessionLoader loader) {
- this(registry.getClock(), registry.getCurator(), registry.getConfigserverConfig().sessionLifetime(),
- command -> registry.getZkWatcherExecutor().execute(tenantName, command));
- loadSessions(tenantFileSystemDirs.sessionsPath(), loader);
+ public LocalSessionRepo(TenantName tenantName, GlobalComponentRegistry componentRegistry, LocalSessionLoader loader) {
+ this(tenantName, componentRegistry);
+ loadSessions(loader);
}
// Constructor public only for testing
- public LocalSessionRepo(Clock clock, Curator curator) {
- this(clock, curator, Duration.ofDays(1).toMillis(), Runnable::run);
- }
-
- private LocalSessionRepo(Clock clock, Curator curator, long sessionLifetime, Executor zkWatcherExecutor) {
- this.clock = clock;
- this.curator = curator;
- this.sessionLifetime = sessionLifetime;
- this.zkWatcherExecutor = zkWatcherExecutor;
+ public LocalSessionRepo(TenantName tenantName, GlobalComponentRegistry componentRegistry) {
+ this.clock = componentRegistry.getClock();
+ this.curator = componentRegistry.getCurator();
+ this.sessionLifetime = componentRegistry.getConfigserverConfig().sessionLifetime();
+ this.zkWatcherExecutor = command -> componentRegistry.getZkWatcherExecutor().execute(tenantName, command);
+ this.tenantFileSystemDirs = new TenantFileSystemDirs(componentRegistry.getConfigServerDB(), tenantName);
}
@Override
@@ -68,17 +62,17 @@ public class LocalSessionRepo extends SessionRepo<LocalSession> {
sessionStateWatchers.put(sessionId, new LocalSessionStateWatcher(fileCache, session, this, zkWatcherExecutor));
}
- private void loadSessions(File applicationsDir, LocalSessionLoader loader) {
- File[] applications = applicationsDir.listFiles(sessionApplicationsFilter);
- if (applications == null) {
+ private void loadSessions(LocalSessionLoader loader) {
+ File[] sessions = tenantFileSystemDirs.sessionsPath().listFiles(sessionApplicationsFilter);
+ if (sessions == null) {
return;
}
- for (File application : applications) {
+ for (File session : sessions) {
try {
- addSession(loader.loadSession(Long.parseLong(application.getName())));
+ addSession(loader.loadSession(Long.parseLong(session.getName())));
} catch (IllegalArgumentException e) {
- log.log(LogLevel.WARNING, "Could not load application '" +
- application.getAbsolutePath() + "':" + e.getMessage() + ", skipping it.");
+ log.log(LogLevel.WARNING, "Could not load session '" +
+ session.getAbsolutePath() + "':" + e.getMessage() + ", skipping it.");
}
}
}
@@ -118,7 +112,12 @@ public class LocalSessionRepo extends SessionRepo<LocalSession> {
transaction.commit();
}
- public void deleteAllSessions() {
+ public void close() {
+ deleteAllSessions();
+ tenantFileSystemDirs.delete();
+ }
+
+ private void deleteAllSessions() {
List<LocalSession> sessions = new ArrayList<>(listSessions());
for (LocalSession session : sessions) {
deleteSession(session);
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 cc46a157b34..fad5685d6fa 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
@@ -54,7 +54,6 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader {
public SessionFactoryImpl(GlobalComponentRegistry globalComponentRegistry,
TenantApplications applicationRepo,
- TenantFileSystemDirs tenantFileSystemDirs,
HostValidator<ApplicationId> hostRegistry,
TenantName tenant) {
this.hostRegistry = hostRegistry;
@@ -65,7 +64,7 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader {
this.sessionCounter = new SessionCounter(globalComponentRegistry.getConfigCurator(), tenant);
this.sessionsPath = TenantRepository.getSessionsPath(tenant);
this.applicationRepo = applicationRepo;
- this.tenantFileSystemDirs = tenantFileSystemDirs;
+ this.tenantFileSystemDirs = new TenantFileSystemDirs(globalComponentRegistry.getConfigServerDB(), tenant);
this.serverId = globalComponentRegistry.getConfigserverConfig().serverId();
this.nodeFlavors = globalComponentRegistry.getZone().nodeFlavors();
this.clock = globalComponentRegistry.getClock();
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java
index 0aed3977625..bbd3ae55f10 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java
@@ -6,7 +6,6 @@ import com.yahoo.path.Path;
import com.yahoo.vespa.config.server.ReloadHandler;
import com.yahoo.vespa.config.server.RequestHandler;
import com.yahoo.vespa.config.server.application.TenantApplications;
-import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs;
import com.yahoo.vespa.config.server.session.LocalSessionRepo;
import com.yahoo.vespa.config.server.session.RemoteSessionRepo;
import com.yahoo.vespa.config.server.session.SessionFactory;
@@ -22,13 +21,11 @@ import java.util.Optional;
*
* @author vegardh
* @author Ulf Lilleengen
- * @since 5.1.26
*/
public class Tenant implements TenantHandlerProvider {
static final String SESSIONS = "sessions";
static final String APPLICATIONS = "applications";
- static final String LOCKS = "locks";
private final TenantName name;
private final RemoteSessionRepo remoteSessionRepo;
@@ -38,7 +35,6 @@ public class Tenant implements TenantHandlerProvider {
private final TenantApplications applicationRepo;
private final RequestHandler requestHandler;
private final ReloadHandler reloadHandler;
- private final TenantFileSystemDirs tenantFileSystemDirs;
private final Curator curator;
Tenant(TenantName name,
@@ -49,8 +45,7 @@ public class Tenant implements TenantHandlerProvider {
RequestHandler requestHandler,
ReloadHandler reloadHandler,
TenantApplications applicationRepo,
- Curator curator,
- TenantFileSystemDirs tenantFileSystemDirs) {
+ Curator curator) {
this.name = name;
this.path = path;
this.requestHandler = requestHandler;
@@ -59,7 +54,6 @@ public class Tenant implements TenantHandlerProvider {
this.sessionFactory = sessionFactory;
this.localSessionRepo = localSessionRepo;
this.applicationRepo = applicationRepo;
- this.tenantFileSystemDirs = tenantFileSystemDirs;
this.curator = curator;
}
@@ -147,10 +141,9 @@ public class Tenant implements TenantHandlerProvider {
* Called by watchers as a reaction to {@link #delete()}.
*/
void close() {
- tenantFileSystemDirs.delete(); // Deletes all local files.
remoteSessionRepo.close(); // Closes watchers and clears memory.
applicationRepo.close(); // Closes watchers.
- localSessionRepo.deleteAllSessions(); // Closes watchers, clears memory, and deletes some local files and ZK session state.
+ localSessionRepo.close(); // Closes watchers, clears memory, and deletes local files and ZK session state.
}
/** Deletes the tenant tree from ZooKeeper (application and session status for the tenant) and triggers {@link #close()}. */
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 861b2f91c8f..23a6abb2c6c 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
@@ -33,7 +33,6 @@ public class TenantBuilder {
private TenantRequestHandler reloadHandler;
private RequestHandler requestHandler;
private RemoteSessionFactory remoteSessionFactory;
- private TenantFileSystemDirs tenantFileSystemDirs;
private HostValidator<ApplicationId> hostValidator;
private TenantBuilder(GlobalComponentRegistry componentRegistry, TenantName tenant) {
@@ -81,7 +80,6 @@ public class TenantBuilder {
createApplicationRepo();
createRemoteSessionFactory();
createRemoteSessionRepo();
- createServerDbDirs();
createSessionFactory();
createLocalSessionRepo();
return new Tenant(tenant,
@@ -92,20 +90,18 @@ public class TenantBuilder {
requestHandler,
reloadHandler,
applicationRepo,
- componentRegistry.getCurator(),
- tenantFileSystemDirs);
+ componentRegistry.getCurator());
}
private void createLocalSessionRepo() {
if (localSessionRepo == null) {
- localSessionRepo = new LocalSessionRepo(tenant, componentRegistry, tenantFileSystemDirs, localSessionLoader);
+ localSessionRepo = new LocalSessionRepo(tenant, componentRegistry, localSessionLoader);
}
}
private void createSessionFactory() {
if (sessionFactory == null || localSessionLoader == null) {
- SessionFactoryImpl impl = new SessionFactoryImpl(componentRegistry, applicationRepo,
- tenantFileSystemDirs, hostValidator, tenant);
+ SessionFactoryImpl impl = new SessionFactoryImpl(componentRegistry, applicationRepo, hostValidator, tenant);
if (sessionFactory == null) {
sessionFactory = impl;
}
@@ -155,11 +151,5 @@ public class TenantBuilder {
}
}
- private void createServerDbDirs() {
- if (tenantFileSystemDirs == null) {
- tenantFileSystemDirs = new TenantFileSystemDirs(componentRegistry.getConfigServerDB(), tenant);
- }
- }
-
public TenantName getTenantName() { return tenant; }
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
index d94194e58d9..7fa417ea287 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
@@ -21,7 +21,6 @@ import com.yahoo.jdisc.http.HttpRequest;
import com.yahoo.slime.JsonFormat;
import com.yahoo.vespa.config.server.ApplicationRepository;
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.OrchestratorMock;
import com.yahoo.vespa.config.server.application.TenantApplications;
@@ -81,7 +80,6 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
private static final String activatedMessage = " for tenant '" + tenantName + "' activated.";
private final InMemoryFlagSource flagSource = new InMemoryFlagSource();
- private final Clock clock = Clock.systemUTC();
private Curator curator;
private RemoteSessionRepo remoteSessionRepo;
private LocalSessionRepo localRepo;
@@ -106,7 +104,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
.build();
tenantRepository = new TenantRepository(componentRegistry, false);
applicationRepo = TenantApplications.create(componentRegistry, new MockReloadHandler(), tenantName);
- localRepo = new LocalSessionRepo(clock, curator);
+ localRepo = new LocalSessionRepo(tenantName, componentRegistry);
pathPrefix = "/application/v2/tenant/" + tenantName + "/session/";
hostProvisioner = new MockProvisioner();
TenantBuilder tenantBuilder = TenantBuilder.create(componentRegistry, tenantName)
@@ -155,7 +153,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
activateAndAssertOK(sessionId, 1);
sessionId++;
- ActivateRequest activateRequest = new ActivateRequest(sessionId, 1, "", clock).invoke();
+ ActivateRequest activateRequest = new ActivateRequest(sessionId, 1, "", componentRegistry.getClock()).invoke();
HttpResponse actResponse = activateRequest.getActResponse();
String message = getRenderedString(actResponse);
assertThat(message, actResponse.getStatus(), Is.is(CONFLICT));
@@ -180,7 +178,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
@Test
public void testActivationWithActivationInBetween() throws Exception {
activateAndAssertOK(90l, 0l);
- activateAndAssertError(92l, 89l, clock,
+ activateAndAssertError(92l, 89l, componentRegistry.getClock(),
Response.Status.CONFLICT, HttpErrorResponse.errorCodes.ACTIVATION_CONFLICT,
"tenant:" + tenantName + " app:default:default Cannot activate session 92 because the currently active session (90) has changed since session 92 was created (was 89 at creation time)");
}
@@ -190,7 +188,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
// Needed so we can test that previous active session is still active after a failed activation
RemoteSession firstSession = activateAndAssertOK(90l, 0l);
long sessionId = 91L;
- ActivateRequest activateRequest = new ActivateRequest(sessionId, 0l, Session.Status.NEW, "", clock).invoke();
+ ActivateRequest activateRequest = new ActivateRequest(sessionId, 0l, Session.Status.NEW, "", componentRegistry.getClock()).invoke();
HttpResponse actResponse = activateRequest.getActResponse();
RemoteSession session = activateRequest.getSession();
assertThat(actResponse.getStatus(), is(Response.Status.BAD_REQUEST));
@@ -211,7 +209,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
public void require_that_handler_gives_error_when_provisioner_activated_fails() throws Exception {
hostProvisioner = new FailingMockProvisioner();
hostProvisioner.activated = false;
- activateAndAssertError(1, 0, clock, BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Cannot activate application");
+ activateAndAssertError(1, 0, componentRegistry.getClock(), BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Cannot activate application");
assertFalse(hostProvisioner.activated);
}
@@ -237,7 +235,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
}
private ActivateRequest activateAndAssertOKPut(long sessionId, long previousSessionId, String subPath) throws Exception {
- ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, subPath, clock);
+ ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, subPath, componentRegistry.getClock());
activateRequest.invoke();
HttpResponse actResponse = activateRequest.getActResponse();
String message = getRenderedString(actResponse);
@@ -370,7 +368,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
new ApplicationRepository(tenantRepository,
hostProvisioner,
new OrchestratorMock(),
- clock),
+ componentRegistry.getClock()),
tenantRepository,
Zone.defaultZone());
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
index ac4b4ea9005..06e1c36b3f2 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
@@ -18,8 +18,6 @@ import com.yahoo.vespa.config.server.http.SessionHandlerTest;
import com.yahoo.vespa.config.server.session.LocalSessionRepo;
import com.yahoo.vespa.config.server.tenant.TenantBuilder;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
-import com.yahoo.vespa.curator.Curator;
-import com.yahoo.vespa.curator.mock.MockCurator;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -71,9 +69,8 @@ public class SessionCreateHandlerTest extends SessionHandlerTest {
@Before
public void setupRepo() {
- Curator curator = new MockCurator();
applicationRepo = TenantApplications.create(componentRegistry, new MockReloadHandler(), tenant);
- localSessionRepo = new LocalSessionRepo(Clock.systemUTC(), curator);
+ localSessionRepo = new LocalSessionRepo(tenant, componentRegistry);
tenantRepository = new TenantRepository(componentRegistry, false);
sessionFactory = new MockSessionFactory();
TenantBuilder tenantBuilder = TenantBuilder.create(componentRegistry, tenant)
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java
index b6c3de8a1b1..ec64ef2e3ba 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java
@@ -63,10 +63,9 @@ import static org.junit.Assert.assertThat;
public class SessionPrepareHandlerTest extends SessionHandlerTest {
private static final TenantName tenant = TenantName.from("test");
- private final TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().build();
+ private Curator curator = new MockCurator();
+ private final TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().curator(curator).build();
private final Clock clock = componentRegistry.getClock();
-
- private Curator curator;
private LocalSessionRepo localRepo;
private String preparedMessage = " prepared.\"}";
@@ -76,8 +75,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
@Before
public void setupRepo() {
- curator = new MockCurator();
- localRepo = new LocalSessionRepo(clock, curator);
+ localRepo = new LocalSessionRepo(tenant, componentRegistry);
pathPrefix = "/application/v2/tenant/" + tenant + "/session/";
preparedMessage = " for tenant '" + tenant + "' prepared.\"";
tenantMessage = ",\"tenant\":\"" + tenant + "\"";
@@ -244,9 +242,9 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
@Test
public void require_that_preparing_with_multiple_tenants_work() throws Exception {
- // Need different repo for 'test2' tenant
- LocalSessionRepo localRepoDefault = new LocalSessionRepo(clock, curator);
final TenantName defaultTenant = TenantName.from("test2");
+ // Need different repo for 'test2' tenant
+ LocalSessionRepo localRepoDefault = new LocalSessionRepo(defaultTenant, componentRegistry);
TenantBuilder defaultTenantBuilder = TenantBuilder.create(componentRegistry, defaultTenant)
.withLocalSessionRepo(localRepoDefault)
.withRemoteSessionRepo(new RemoteSessionRepo(defaultTenant))
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 d3f364e30ac..23fde190297 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
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.session;
+import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.model.application.provider.FilesApplicationPackage;
import com.yahoo.test.ManualClock;
import com.yahoo.config.provision.TenantName;
@@ -8,7 +9,6 @@ import com.yahoo.vespa.config.server.GlobalComponentRegistry;
import com.yahoo.vespa.config.server.MockReloadHandler;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.TenantApplications;
-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;
@@ -20,6 +20,8 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.time.Duration;
import java.time.Instant;
@@ -46,21 +48,28 @@ public class LocalSessionRepoTest {
}
private void setupSessions(TenantName tenantName, boolean createInitialSessions) throws Exception {
- TenantFileSystemDirs tenantFileSystemDirs = new TenantFileSystemDirs(temporaryFolder.newFolder(), tenantName);
+ File configserverDbDir = temporaryFolder.newFolder().getAbsoluteFile();
if (createInitialSessions) {
- IOUtils.copyDirectory(testApp, new File(tenantFileSystemDirs.sessionsPath(), "1"));
- IOUtils.copyDirectory(testApp, new File(tenantFileSystemDirs.sessionsPath(), "2"));
- IOUtils.copyDirectory(testApp, new File(tenantFileSystemDirs.sessionsPath(), "3"));
+ Path sessionsPath = Paths.get(configserverDbDir.getAbsolutePath(), "tenants", tenantName.value(), "sessions");
+ IOUtils.copyDirectory(testApp, sessionsPath.resolve("1").toFile());
+ IOUtils.copyDirectory(testApp, sessionsPath.resolve("2").toFile());
+ IOUtils.copyDirectory(testApp, sessionsPath.resolve("3").toFile());
}
clock = new ManualClock(Instant.ofEpochSecond(1));
- GlobalComponentRegistry globalComponentRegistry = new TestComponentRegistry.Builder().curator(new MockCurator())
- .clock(clock)
- .build();
+ GlobalComponentRegistry globalComponentRegistry = new TestComponentRegistry.Builder()
+ .curator(new MockCurator())
+ .clock(clock)
+ .configServerConfig(new ConfigserverConfig.Builder()
+ .configServerDBDir(configserverDbDir.getAbsolutePath())
+ .configDefinitionsDir(temporaryFolder.newFolder().getAbsolutePath())
+ .sessionLifetime(5)
+ .build())
+ .build();
LocalSessionLoader loader = new SessionFactoryImpl(globalComponentRegistry,
TenantApplications.create(globalComponentRegistry, new MockReloadHandler(), tenantName),
- tenantFileSystemDirs, new HostRegistry<>(),
+ new HostRegistry<>(),
tenantName);
- repo = new LocalSessionRepo(tenantName, globalComponentRegistry, tenantFileSystemDirs, loader);
+ repo = new LocalSessionRepo(tenantName, globalComponentRegistry, loader);
}
@Test
@@ -97,7 +106,7 @@ public class LocalSessionRepoTest {
@Test
public void require_that_all_sessions_are_deleted() {
- repo.deleteAllSessions();
+ repo.close();
assertNull(repo.getSession(1l));
assertNull(repo.getSession(2l));
assertNull(repo.getSession(3l));