diff options
author | Harald Musum <musum@yahooinc.com> | 2022-07-12 20:49:17 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2022-07-12 21:17:58 +0200 |
commit | ccec8757af8195b76e6716832b3b2cc63a131957 (patch) | |
tree | c6002f856d0d611651bdc0ad8e53153521639b0c /configserver | |
parent | 1e3f96034d625fa542aa5984becc954a2550dadd (diff) |
Don't expose SessionZooKeeperClient from Session
Diffstat (limited to 'configserver')
3 files changed, 5 insertions, 10 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 ffb6c038b70..2a15f724b29 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 @@ -797,7 +797,8 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye .map(lock -> new ApplicationTransaction(lock, transaction)); try (var sessionLock = tenant.getApplicationRepo().lock(applicationId)) { Optional<Session> activeSession = getActiveSession(applicationId); - CompletionWaiter waiter = session.getSessionZooKeeperClient().createActiveWaiter(); + var sessionZooKeeperClient = tenant.getSessionRepository().createSessionZooKeeperClient(session.getSessionId()); + CompletionWaiter waiter = sessionZooKeeperClient.createActiveWaiter(); transaction.add(deactivateCurrentActivateNew(activeSession, session, force)); if (applicationTransaction.isPresent()) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java index edc166d0989..82faeae01e8 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java @@ -61,10 +61,6 @@ public abstract class Session implements Comparable<Session> { return sessionZooKeeperClient.readStatus(); } - public SessionZooKeeperClient getSessionZooKeeperClient() { - return sessionZooKeeperClient; - } - @Override public String toString() { return "Session,id=" + sessionId + ",status=" + getStatus(); 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 64011726733..676c39329bb 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 @@ -363,10 +363,8 @@ public class SessionRepository { int deleteMax = (int) Math.min(1000, Math.max(10, remoteSessionsFromZooKeeper.size() * 0.01)); for (long sessionId : remoteSessionsFromZooKeeper) { Session session = remoteSessionCache.get(sessionId); - if (session == null) { - log.log(Level.FINE, () -> "Remote session " + sessionId + " is null, creating a new one"); + if (session == null) session = new RemoteSession(tenantName, sessionId, createSessionZooKeeperClient(sessionId)); - } if (session.getStatus() == Session.Status.ACTIVATE) continue; if (sessionHasExpired(session.getCreateTime(), expiryTime, clock)) { log.log(Level.FINE, () -> "Remote session " + sessionId + " for " + tenantName + " has expired, deleting it"); @@ -499,7 +497,7 @@ public class SessionRepository { } void confirmUpload(Session session) { - CompletionWaiter waiter = session.getSessionZooKeeperClient().getUploadWaiter(); + CompletionWaiter waiter = createSessionZooKeeperClient(session.getSessionId()).getUploadWaiter(); long sessionId = session.getSessionId(); log.log(Level.FINE, () -> "Notifying upload waiter for session " + sessionId); notifyCompletion(waiter); @@ -879,7 +877,7 @@ public class SessionRepository { return getSessionPath(sessionId).append(ZKApplication.SESSIONSTATE_ZK_SUBPATH); } - private SessionZooKeeperClient createSessionZooKeeperClient(long sessionId) { + public SessionZooKeeperClient createSessionZooKeeperClient(long sessionId) { return new SessionZooKeeperClient(curator, tenantName, sessionId, |