diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-06-16 10:51:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-16 10:51:47 +0200 |
commit | 11f5939ca4f131f176a2b2d6d0838c23acfbe880 (patch) | |
tree | 56e606e366a5edf97dafc430624b13c67df866d2 /configserver | |
parent | c0d8eff2873a2a352b368fe0e616caf812673a33 (diff) | |
parent | be48fcf39b281641203f369ee8d3cf16528c2927 (diff) |
Merge pull request #13583 from vespa-engine/hmusum/add-localsession-to-session-cache
Add local session to session cache
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionCache.java | 4 | ||||
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java | 8 |
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) { |