summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-06-15 11:52:53 +0200
committerHarald Musum <musum@verizonmedia.com>2020-06-15 11:52:53 +0200
commitbe48fcf39b281641203f369ee8d3cf16528c2927 (patch)
treeffd7a8d8bc1ee148e984765e7c294f5cbd13375a /configserver
parentf23863f6f7698d4fc34392c59977447988a86754 (diff)
Add local session to session cache
If we managed to created a local session, add it to the session cache
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionCache.java4
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java8
2 files changed, 6 insertions, 6 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionCache.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionCache.java
index 8808dc0cf75..501d4918996 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionCache.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionCache.java
@@ -16,9 +16,7 @@ public class SessionCache<SESSIONTYPE extends Session> {
private final HashMap<Long, SESSIONTYPE> sessions = new HashMap<>();
public synchronized void addSession(SESSIONTYPE session) {
- if (sessions.containsKey(session.getSessionId()))
- throw new IllegalArgumentException("There already exists a session with id '" + session.getSessionId() + "'");
- sessions.put(session.getSessionId(), session);
+ sessions.putIfAbsent(session.getSessionId(), session);
}
synchronized void removeSession(long id) {
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 1a99259c6ef..8317dc02e90 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
@@ -57,7 +57,7 @@ import java.util.stream.Collectors;
/**
*
- * Session repository for config server. Stores session state in zookeeper and file system. There are two
+ * Session repository for a tenant. Stores session state in zookeeper and file system. There are two
* different session types (RemoteSession and LocalSession).
*
* @author Ulf Lilleengen
@@ -325,8 +325,10 @@ public class SessionRepository {
loadSessionIfActive(session);
addRemoteSession(session);
remoteSessionStateWatchers.put(sessionId, new RemoteSessionStateWatcher(fileCache, reloadHandler, session, metrics, zkWatcherExecutor));
- if (distributeApplicationPackage.value())
- createLocalSessionUsingDistributedApplicationPackage(sessionId);
+ if (distributeApplicationPackage.value()) {
+ Optional<LocalSession> localSession = createLocalSessionUsingDistributedApplicationPackage(sessionId);
+ localSession.ifPresent(this::addSession);
+ }
}
private void sessionRemoved(long sessionId) {