summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-07-01 07:32:36 +0200
committerHarald Musum <musum@verizonmedia.com>2020-07-01 07:32:36 +0200
commit8b4b46eaaa01f022a5dd075dc6a88a01664f135a (patch)
tree3e047fadd3791e886831c688ca8a298a8086a5d6
parentf4b107073f2b8352a63f981c290909fc10ba6c8e (diff)
Minor refactoring, no functional changes
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java6
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java21
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java4
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java2
5 files changed, 17 insertions, 18 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index 0557fa6e552..e57fc104dd3 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -307,7 +307,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
if (activeSession == null) return Optional.empty();
TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout);
LocalSession newSession = tenant.getSessionRepository().createSessionFromExisting(activeSession, logger, true, timeoutBudget);
- tenant.getSessionRepository().addSession(newSession);
+ tenant.getSessionRepository().addLocalSession(newSession);
return Optional.of(Deployment.unprepared(newSession, this, hostProvisioner, tenant, timeout, clock,
false /* don't validate as this is already deployed */, bootstrap));
@@ -646,7 +646,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
SessionRepository sessionRepository = tenant.getSessionRepository();
RemoteSession fromSession = getExistingSession(tenant, applicationId);
LocalSession session = sessionRepository.createSessionFromExisting(fromSession, logger, internalRedeploy, timeoutBudget);
- sessionRepository.addSession(session);
+ sessionRepository.addLocalSession(session);
return session.getSessionId();
}
@@ -669,7 +669,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
applicationId,
timeoutBudget,
activeSessionId);
- tenant.getSessionRepository().addSession(session);
+ tenant.getSessionRepository().addLocalSession(session);
return session.getSessionId();
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java
index 2da93b7f243..b039aeda318 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java
@@ -119,12 +119,12 @@ public class SessionRepository {
// ---------------- Local sessions ----------------------------------------------------------------
- public synchronized void addSession(LocalSession session) {
+ public synchronized void addLocalSession(LocalSession session) {
localSessionCache.addSession(session);
long sessionId = session.getSessionId();
Curator.FileCache fileCache = curator.createFileCache(getSessionStatePath(sessionId).getAbsolute(), false);
- RemoteSession remoteSession = new RemoteSession(tenantName, sessionId, componentRegistry, createSessionZooKeeperClient(sessionId));
- addWatcher(sessionId, fileCache, remoteSession, Optional.of(session));
+ RemoteSession remoteSession = createRemoteSession(sessionId);
+ addSesssionStateWatcher(sessionId, fileCache, remoteSession, Optional.of(session));
}
public LocalSession getLocalSession(long sessionId) {
@@ -137,12 +137,11 @@ public class SessionRepository {
private void loadLocalSessions() {
File[] sessions = tenantFileSystemDirs.sessionsPath().listFiles(sessionApplicationsFilter);
- if (sessions == null) {
- return;
- }
+ if (sessions == null) return;
+
for (File session : sessions) {
try {
- addSession(createSessionFromId(Long.parseLong(session.getName())));
+ addLocalSession(createSessionFromId(Long.parseLong(session.getName())));
} catch (IllegalArgumentException e) {
log.log(Level.WARNING, "Could not load session '" +
session.getAbsolutePath() + "':" + e.getMessage() + ", skipping it.");
@@ -327,7 +326,7 @@ public class SessionRepository {
Optional<LocalSession> localSession = Optional.empty();
if (distributeApplicationPackage())
localSession = createLocalSessionUsingDistributedApplicationPackage(sessionId);
- addWatcher(sessionId, fileCache, remoteSession, localSession);
+ addSesssionStateWatcher(sessionId, fileCache, remoteSession, localSession);
}
private boolean distributeApplicationPackage() {
@@ -553,7 +552,6 @@ public class SessionRepository {
return Optional.of(createSessionFromId(sessionId));
}
- log.log(Level.INFO, "Creating local session for session id " + sessionId);
SessionZooKeeperClient sessionZKClient = createSessionZooKeeperClient(sessionId);
FileReference fileReference = sessionZKClient.readApplicationPackageReference();
log.log(Level.FINE, "File reference for session id " + sessionId + ": " + fileReference);
@@ -570,8 +568,9 @@ public class SessionRepository {
return Optional.empty();
}
ApplicationId applicationId = sessionZKClient.readApplicationId();
+ log.log(Level.INFO, "Creating local session for session id " + sessionId);
LocalSession localSession = createLocalSession(sessionDir, applicationId, sessionId);
- addSession(localSession);
+ addLocalSession(localSession);
return Optional.of(localSession);
}
return Optional.empty();
@@ -615,7 +614,7 @@ public class SessionRepository {
return new TenantFileSystemDirs(componentRegistry.getConfigServerDB(), tenantName).getUserApplicationDir(sessionId);
}
- private void addWatcher(long sessionId, Curator.FileCache fileCache, RemoteSession remoteSession, Optional<LocalSession> localSession) {
+ private void addSesssionStateWatcher(long sessionId, Curator.FileCache fileCache, RemoteSession remoteSession, Optional<LocalSession> localSession) {
// Remote session will always be present in an existing state watcher, but local session might not
if (sessionStateWatchers.containsKey(sessionId)) {
localSession.ifPresent(session -> sessionStateWatchers.get(sessionId).addLocalSession(session));
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
index 4cf81d22e3c..97085416073 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
@@ -54,13 +54,13 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase {
session2 = new MockLocalSession(2, FilesApplicationPackage.fromFile(new File("src/test/apps/content")));
Tenant tenant1 = tenantRepository.getTenant(tenantName1);
- tenant1.getSessionRepository().addSession(session2);
+ tenant1.getSessionRepository().addLocalSession(session2);
tenant1.getApplicationRepo().createApplication(idTenant1);
tenant1.getApplicationRepo().createPutTransaction(idTenant1, 2).commit();
MockLocalSession session3 = new MockLocalSession(3, FilesApplicationPackage.fromFile(new File("src/test/apps/content2")));
Tenant tenant2 = tenantRepository.getTenant(tenantName2);
- tenant2.getSessionRepository().addSession(session3);
+ tenant2.getSessionRepository().addLocalSession(session3);
tenant2.getApplicationRepo().createApplication(idTenant2);
tenant2.getApplicationRepo().createPutTransaction(idTenant2, 3).commit();
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 d8724cb4db2..20e4ef56166 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
@@ -52,7 +52,7 @@ public class HostHandlerTest {
tenant.getApplicationRepo().createApplication(applicationId);
tenant.getApplicationRepo().createPutTransaction(applicationId, sessionId).commit();
ApplicationPackage app = FilesApplicationPackage.fromFile(testApp);
- tenant.getSessionRepository().addSession(new SessionHandlerTest.MockLocalSession(sessionId, app, applicationId));
+ tenant.getSessionRepository().addLocalSession(new SessionHandlerTest.MockLocalSession(sessionId, app, applicationId));
TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder()
.modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry()))))
.build();
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
index f639843ac08..20d9be080e9 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
@@ -43,7 +43,7 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
public void setupHandler() throws Exception {
tenantRepository = new TenantRepository(componentRegistry, false);
tenantRepository.addTenant(tenant);
- tenantRepository.getTenant(tenant).getSessionRepository().addSession(new MockLocalSession(1L, FilesApplicationPackage.fromFile(createTestApp())));
+ tenantRepository.getTenant(tenant).getSessionRepository().addLocalSession(new MockLocalSession(1L, FilesApplicationPackage.fromFile(createTestApp())));
handler = createHandler();
pathPrefix = "/application/v2/tenant/" + tenant + "/session/";
baseUrl = "http://foo:1337/application/v2/tenant/" + tenant + "/session/1/content/";