summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-09-08 10:10:58 +0200
committerHarald Musum <musum@verizonmedia.com>2020-09-08 10:10:58 +0200
commitca25b29442cc8ec5955bea1b06f496c7b1c3be18 (patch)
treed97c65de99611da33e24ccf3281bf57ef8e104c1 /configserver
parentf2f6dd4bcfe2f37656ed2b95336006ab42857d38 (diff)
Add activated method to RemoteSession
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java18
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java17
2 files changed, 17 insertions, 18 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java
index ed401e65f20..f551fcb6005 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java
@@ -5,6 +5,7 @@ import com.yahoo.config.provision.TenantName;
import com.yahoo.transaction.Transaction;
import com.yahoo.vespa.config.server.application.ApplicationSet;
+import java.util.Objects;
import java.util.Optional;
/**
@@ -24,9 +25,7 @@ public class RemoteSession extends Session {
* @param sessionId The session id for this session.
* @param zooKeeperClient a SessionZooKeeperClient instance
*/
- public RemoteSession(TenantName tenant,
- long sessionId,
- SessionZooKeeperClient zooKeeperClient) {
+ public RemoteSession(TenantName tenant, long sessionId, SessionZooKeeperClient zooKeeperClient) {
this(tenant, sessionId, zooKeeperClient, Optional.empty());
}
@@ -37,10 +36,10 @@ public class RemoteSession extends Session {
* @param sessionId The session id for this session.
* @param zooKeeperClient a SessionZooKeeperClient instance
*/
- public RemoteSession(TenantName tenant,
- long sessionId,
- SessionZooKeeperClient zooKeeperClient,
- Optional<ApplicationSet> applicationSet) {
+ private RemoteSession(TenantName tenant,
+ long sessionId,
+ SessionZooKeeperClient zooKeeperClient,
+ Optional<ApplicationSet> applicationSet) {
super(tenant, sessionId, zooKeeperClient);
this.applicationSet = applicationSet;
}
@@ -49,6 +48,11 @@ public class RemoteSession extends Session {
return applicationSet;
}
+ public synchronized RemoteSession activated(ApplicationSet applicationSet) {
+ Objects.requireNonNull(applicationSet, "applicationSet cannot be null");
+ return new RemoteSession(tenant, sessionId, sessionZooKeeperClient, Optional.of(applicationSet));
+ }
+
public synchronized RemoteSession deactivated() {
return new RemoteSession(tenant, sessionId, sessionZooKeeperClient, Optional.empty());
}
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 d71b8f4d46d..84379b629dd 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
@@ -417,18 +417,13 @@ public class SessionRepository {
}
public ApplicationSet ensureApplicationLoaded(RemoteSession session) {
- Optional<ApplicationSet> applicationSet = session.applicationSet();
- if (applicationSet.isPresent()) {
- return applicationSet.get();
+ if (session.applicationSet().isPresent()) {
+ return session.applicationSet().get();
}
- ApplicationSet newApplicationSet = loadApplication(session);
- RemoteSession newSession = new RemoteSession(session.getTenantName(),
- session.getSessionId(),
- session.getSessionZooKeeperClient(),
- Optional.of(newApplicationSet));
- remoteSessionCache.putSession(newSession);
- return newApplicationSet;
+ ApplicationSet applicationSet = loadApplication(session);
+ remoteSessionCache.putSession(session.activated(applicationSet));
+ return applicationSet;
}
void confirmUpload(RemoteSession session) {
@@ -700,7 +695,7 @@ public class SessionRepository {
} catch (IllegalArgumentException e) {
// We cannot be guaranteed that the file reference exists (it could be that it has not
// been downloaded yet), and e.g when bootstrapping we cannot throw an exception in that case
- log.log(Level.INFO, "File reference for session id " + sessionId + ": " + fileReference + " not found in " + fileDirectory);
+ log.log(Level.FINE, () -> "File reference for session id " + sessionId + ": " + fileReference + " not found in " + fileDirectory);
return Optional.empty();
}
ApplicationId applicationId = sessionZKClient.readApplicationId()