summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-09-16 10:09:57 +0200
committerGitHub <noreply@github.com>2020-09-16 10:09:57 +0200
commitce45c8e71e760d563bfb4102927fe7a3e4ec4569 (patch)
tree05a2092a5be4dbcddf113df90278d37c5147db77
parenta6b848e49d1aef3758b923f858186ba254ba4ec7 (diff)
Revert "Stop creating RemoteSessions in addLocalSession"
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java14
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java24
3 files changed, 18 insertions, 22 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 4b7cc853d46..824d6701233 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
@@ -367,7 +367,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
SessionRepository sessionRepository = tenant.getSessionRepository();
LocalSession newSession = sessionRepository.createSessionFromExisting(activeSession, logger, true, timeoutBudget);
sessionRepository.addLocalSession(newSession);
- sessionRepository.createRemoteSession(newSession.getSessionId());
return Optional.of(Deployment.unprepared(newSession, this, hostProvisioner, tenant, timeout, clock,
false /* don't validate as this is already deployed */, bootstrap));
@@ -816,7 +815,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
timeoutBudget,
activeSessionId);
tenant.getSessionRepository().addLocalSession(session);
- tenant.getSessionRepository().createRemoteSession(session.getSessionId());
return session.getSessionId();
}
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 18c8c6ffdec..3c18a51f22c 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
@@ -124,6 +124,9 @@ public class SessionRepository {
public synchronized void addLocalSession(LocalSession session) {
localSessionCache.put(session.getSessionId(), session);
+ long sessionId = session.getSessionId();
+ RemoteSession remoteSession = createRemoteSession(sessionId);
+ addSessionStateWatcher(sessionId, remoteSession);
}
public LocalSession getLocalSession(long sessionId) {
@@ -140,8 +143,7 @@ public class SessionRepository {
for (File session : sessions) {
try {
- long sessionId = Long.parseLong(session.getName());
- addLocalSession(createSessionFromId(sessionId));
+ addLocalSession(createSessionFromId(Long.parseLong(session.getName())));
} catch (IllegalArgumentException e) {
log.log(Level.WARNING, "Could not load session '" +
session.getAbsolutePath() + "':" + e.getMessage() + ", skipping it.");
@@ -461,11 +463,7 @@ public class SessionRepository {
public RemoteSession createRemoteSession(long sessionId) {
SessionZooKeeperClient sessionZKClient = createSessionZooKeeperClient(sessionId);
- RemoteSession session = new RemoteSession(tenantName, sessionId, componentRegistry, sessionZKClient);
- remoteSessionCache.put(session.getSessionId(), session);
- addSessionStateWatcher(session.getSessionId(), session);
- metrics.incAddedSessions();
- return session;
+ return new RemoteSession(tenantName, sessionId, componentRegistry, sessionZKClient);
}
private void ensureSessionPathDoesNotExist(long sessionId) {
@@ -632,7 +630,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.FINE, () -> "File reference for session id " + sessionId + ": " + fileReference + " not found in " + fileDirectory);
+ log.log(Level.INFO, "File reference for session id " + sessionId + ": " + fileReference + " not found in " + fileDirectory);
return;
}
ApplicationId applicationId = sessionZKClient.readApplicationId()
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java
index f33bf518190..c6c08beea17 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java
@@ -24,18 +24,18 @@ public class SessionStateWatcher {
private static final Logger log = Logger.getLogger(SessionStateWatcher.class.getName());
private final Curator.FileCache fileCache;
- private final RemoteSession session;
+ private final RemoteSession remoteSession;
private final MetricUpdater metrics;
private final Executor zkWatcherExecutor;
private final SessionRepository sessionRepository;
SessionStateWatcher(Curator.FileCache fileCache,
- RemoteSession session,
+ RemoteSession remoteSession,
MetricUpdater metrics,
Executor zkWatcherExecutor,
SessionRepository sessionRepository) {
this.fileCache = fileCache;
- this.session = session;
+ this.remoteSession = remoteSession;
this.metrics = metrics;
this.fileCache.addListener(this::nodeChanged);
this.fileCache.start();
@@ -44,24 +44,24 @@ public class SessionStateWatcher {
}
private void sessionStatusChanged(Status newStatus) {
- long sessionId = session.getSessionId();
+ long sessionId = remoteSession.getSessionId();
switch (newStatus) {
case NEW:
case NONE:
break;
case PREPARE:
createLocalSession(sessionId);
- sessionRepository.prepare(session);
+ sessionRepository.prepare(remoteSession);
break;
case ACTIVATE:
createLocalSession(sessionId);
- sessionRepository.activate(session);
+ sessionRepository.activate(remoteSession);
break;
case DEACTIVATE:
- sessionRepository.deactivate(session);
+ sessionRepository.deactivate(remoteSession);
break;
case DELETE:
- sessionRepository.delete(session);
+ sessionRepository.delete(remoteSession);
break;
default:
throw new IllegalStateException("Unknown status " + newStatus);
@@ -75,7 +75,7 @@ public class SessionStateWatcher {
}
public long getSessionId() {
- return session.getSessionId();
+ return remoteSession.getSessionId();
}
public void close() {
@@ -93,12 +93,12 @@ public class SessionStateWatcher {
ChildData node = fileCache.getCurrentData();
if (node != null) {
newStatus = Status.parse(Utf8.toString(node.getData()));
- log.log(Level.FINE, session.logPre() + "Session change: Session " +
- getSessionId() + " changed status to " + newStatus.name());
+ log.log(Level.FINE, remoteSession.logPre() + "Session change: Session "
+ + remoteSession.getSessionId() + " changed status to " + newStatus.name());
sessionStatusChanged(newStatus);
}
} catch (Exception e) {
- log.log(Level.WARNING, session.logPre() + "Error handling session change to " +
+ log.log(Level.WARNING, remoteSession.logPre() + "Error handling session change to " +
newStatus.name() + " for session " + getSessionId(), e);
metrics.incSessionChangeErrors();
}