summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-06-26 07:45:33 +0200
committerHarald Musum <musum@verizonmedia.com>2020-06-26 07:45:33 +0200
commite8ce57c2efd44a3e50590e6646a2aceec06fe25d (patch)
tree8531050763f53b0bf732caf57f44c59380cb2f7d /configserver
parent8109d90cf0249356c21a1f65d009381646e2540b (diff)
Avoid adding local session to session cache twice
createLocalSessionUsingDistributedApplicationPackage already adds the session to session cache
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java15
1 files changed, 9 insertions, 6 deletions
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 2110e6476b6..43b1b84c1e6 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
@@ -323,13 +323,15 @@ public class SessionRepository {
loadSessionIfActive(remoteSession);
addRemoteSession(remoteSession);
Optional<LocalSession> localSession = Optional.empty();
- if (distributeApplicationPackage.value()) {
+ if (distributeApplicationPackage())
localSession = createLocalSessionUsingDistributedApplicationPackage(sessionId);
- localSession.ifPresent(this::addSession);
- }
addWatcher(sessionId, fileCache, remoteSession, localSession);
}
+ private boolean distributeApplicationPackage() {
+ return distributeApplicationPackage.value();
+ }
+
private void sessionRemoved(long sessionId) {
SessionStateWatcher watcher = sessionStateWatchers.remove(sessionId);
if (watcher != null) watcher.close();
@@ -462,7 +464,7 @@ public class SessionRepository {
LocalSession session = create(existingApp, existingApplicationId, activeSessionId, internalRedeploy, timeoutBudget);
// Note: Needs to be kept in sync with calls in SessionPreparer.writeStateToZooKeeper()
session.setApplicationId(existingApplicationId);
- if (distributeApplicationPackage.value() && existingSession.getApplicationPackageReference() != null) {
+ if (distributeApplicationPackage() && existingSession.getApplicationPackageReference() != null) {
session.setApplicationPackageReference(existingSession.getApplicationPackageReference());
}
session.setVespaVersion(existingSession.getVespaVersion());
@@ -526,7 +528,8 @@ public class SessionRepository {
}
/**
- * Returns a new session instance for the given session id.
+ * Returns a new local session for the given session id if it does not already exist.
+ * Will also add the session to the local session cache if necessary
*/
public Optional<LocalSession> createLocalSessionUsingDistributedApplicationPackage(long sessionId) {
if (applicationRepo.hasLocalSession(sessionId)) {
@@ -596,7 +599,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) {
+ public void addWatcher(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));