summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-10-16 09:37:08 +0200
committerHarald Musum <musum@verizonmedia.com>2020-10-16 09:37:08 +0200
commitbe344ad6591a9b5d31d6ad56c42a6904444b96ea (patch)
tree0ead3f3c0c49e90a0cc5ab5b77e19f9293e419ba /configserver
parent76602902918085b557cdbcce537e27da12457a45 (diff)
Use Session where possible
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java62
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java30
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentRequest.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ApplicationPackageMaintainer.java4
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java5
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java27
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java23
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java5
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java5
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java4
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java4
13 files changed, 88 insertions, 88 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 a8d86947dc0..8ded1f4c573 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
@@ -293,7 +293,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
private Deployment prepare(long sessionId, PrepareParams prepareParams, DeployHandlerLogger logger) {
Tenant tenant = getTenant(prepareParams.getApplicationId());
- LocalSession session = validateThatLocalSessionIsNotActive(tenant, sessionId);
+ Session session = validateThatLocalSessionIsNotActive(tenant, sessionId);
Deployment deployment = Deployment.unprepared(session, this, hostProvisioner, tenant, prepareParams, logger, clock);
deployment.prepare();
logConfigChangeActions(deployment.configChangeActions(), logger);
@@ -381,12 +381,12 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
Tenant tenant = tenantRepository.getTenant(application.tenant());
if (tenant == null) return Optional.empty();
- LocalSession activeSession = getActiveLocalSession(tenant, application);
+ Session activeSession = getActiveLocalSession(tenant, application);
if (activeSession == null) return Optional.empty();
TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout);
SessionRepository sessionRepository = tenant.getSessionRepository();
DeployLogger logger = new SilentDeployLogger();
- LocalSession newSession = sessionRepository.createSessionFromExisting(activeSession, true, timeoutBudget);
+ Session newSession = sessionRepository.createSessionFromExisting(activeSession, true, timeoutBudget);
return Optional.of(Deployment.unprepared(newSession, this, hostProvisioner, tenant, logger, timeout, clock,
false /* don't validate as this is already deployed */, bootstrap));
@@ -396,7 +396,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
public Optional<Instant> lastDeployTime(ApplicationId application) {
Tenant tenant = tenantRepository.getTenant(application.tenant());
if (tenant == null) return Optional.empty();
- RemoteSession activeSession = getActiveSession(tenant, application);
+ Session activeSession = getActiveSession(tenant, application);
if (activeSession == null) return Optional.empty();
return Optional.of(activeSession.getCreateTime());
}
@@ -406,13 +406,13 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
TimeoutBudget timeoutBudget,
boolean force) {
DeployLogger logger = new SilentDeployLogger();
- LocalSession localSession = getLocalSession(tenant, sessionId);
- Deployment deployment = Deployment.prepared(localSession, this, hostProvisioner, tenant, logger, timeoutBudget.timeout(), clock, false, force);
+ Session session = getLocalSession(tenant, sessionId);
+ Deployment deployment = Deployment.prepared(session, this, hostProvisioner, tenant, logger, timeoutBudget.timeout(), clock, false, force);
deployment.activate();
- return localSession.getApplicationId();
+ return session.getApplicationId();
}
- public Transaction deactivateCurrentActivateNew(Session active, LocalSession prepared, boolean force) {
+ public Transaction deactivateCurrentActivateNew(Session active, Session prepared, boolean force) {
Tenant tenant = tenantRepository.getTenant(prepared.getTenantName());
Transaction transaction = tenant.getSessionRepository().createActivateTransaction(prepared);
if (active != null) {
@@ -433,7 +433,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
return tenantRepository.getTenantMetaData(tenant);
}
- static void checkIfActiveHasChanged(LocalSession session, Session activeSession, boolean ignoreStaleSessionFailure) {
+ static void checkIfActiveHasChanged(Session session, Session activeSession, boolean ignoreStaleSessionFailure) {
long activeSessionAtCreate = session.getActiveSessionAtCreate();
log.log(Level.FINE, activeSession.logPre() + "active session id at create time=" + activeSessionAtCreate);
if (activeSessionAtCreate == 0) return; // No active session at create time
@@ -485,8 +485,8 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
// Deleting an application is done by deleting the remote session, other config
// servers will pick this up and clean up through the watcher in this class
try {
- RemoteSession remoteSession = getRemoteSession(tenant, activeSession.get());
- tenant.getSessionRepository().delete(remoteSession);
+ Session session = getRemoteSession(tenant, activeSession.get());
+ tenant.getSessionRepository().delete(session);
} catch (NotFoundException e) {
log.log(Level.INFO, TenantRepository.logPre(applicationId) + "Active session exists, but has not been deleted properly. Trying to cleanup");
}
@@ -591,7 +591,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
return getOptionalApplication(applicationId).map(app -> app.getModel().fileReferences()).orElse(Set.of());
}
- public ApplicationFile getApplicationFileFromSession(TenantName tenantName, long sessionId, String path, LocalSession.Mode mode) {
+ public ApplicationFile getApplicationFileFromSession(TenantName tenantName, long sessionId, String path, Session.Mode mode) {
Tenant tenant = tenantRepository.getTenant(tenantName);
return getLocalSession(tenant, sessionId).getApplicationFile(Path.fromString(path), mode);
}
@@ -648,7 +648,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
public Optional<String> getApplicationPackageReference(ApplicationId applicationId) {
Optional<String> applicationPackage = Optional.empty();
- RemoteSession session = getActiveSession(applicationId);
+ Session session = getActiveSession(applicationId);
if (session != null) {
FileReference applicationPackageReference = session.getApplicationPackageReference();
File downloadDirectory = new File(Defaults.getDefaults().underVespaHome(configserverConfig().fileReferencesDir()));
@@ -727,7 +727,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
// ---------------- Session operations ----------------------------------------------------------------
- public CompletionWaiter activate(LocalSession session, Session previousActiveSession, ApplicationId applicationId, boolean force) {
+ public CompletionWaiter activate(Session session, Session previousActiveSession, ApplicationId applicationId, boolean force) {
CompletionWaiter waiter = session.getSessionZooKeeperClient().createActiveWaiter();
NestedTransaction transaction = new NestedTransaction();
transaction.add(deactivateCurrentActivateNew(previousActiveSession, session, force));
@@ -752,7 +752,16 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
*
* @return the active session, or null if there is no active session for the given application id.
*/
- public RemoteSession getActiveSession(ApplicationId applicationId) {
+ public Session getActiveSession(ApplicationId applicationId) {
+ return getActiveRemoteSession(applicationId);
+ }
+
+ /**
+ * Gets the active Session for the given application id.
+ *
+ * @return the active session, or null if there is no active session for the given application id.
+ */
+ public RemoteSession getActiveRemoteSession(ApplicationId applicationId) {
Tenant tenant = getTenant(applicationId);
if (tenant == null) throw new IllegalArgumentException("Could not find any tenant for '" + applicationId + "'");
return getActiveSession(tenant, applicationId);
@@ -787,8 +796,8 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
public long createSessionFromExisting(ApplicationId applicationId, boolean internalRedeploy, TimeoutBudget timeoutBudget) {
Tenant tenant = getTenant(applicationId);
SessionRepository sessionRepository = tenant.getSessionRepository();
- RemoteSession fromSession = getExistingSession(tenant, applicationId);
- LocalSession session = sessionRepository.createSessionFromExisting(fromSession, internalRedeploy, timeoutBudget);
+ Session fromSession = getExistingSession(tenant, applicationId);
+ Session session = sessionRepository.createSessionFromExisting(fromSession, internalRedeploy, timeoutBudget);
return session.getSessionId();
}
@@ -806,7 +815,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
public long createSession(ApplicationId applicationId, TimeoutBudget timeoutBudget, File applicationDirectory) {
SessionRepository sessionRepository = getTenant(applicationId).getSessionRepository();
- LocalSession session = sessionRepository.createSessionFromApplicationPackage(applicationDirectory, applicationId, timeoutBudget);
+ Session session = sessionRepository.createSessionFromApplicationPackage(applicationDirectory, applicationId, timeoutBudget);
return session.getSessionId();
}
@@ -823,7 +832,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
Map<ApplicationId, Long> activeSessions = new HashMap<>();
applicationIds.forEach(applicationId -> {
- RemoteSession activeSession = getActiveSession(applicationId);
+ Session activeSession = getActiveSession(applicationId);
if (activeSession != null)
activeSessions.put(applicationId, activeSession.getSessionId());
});
@@ -905,16 +914,16 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
return applicationId.orElse(null);
}
- private LocalSession validateThatLocalSessionIsNotActive(Tenant tenant, long sessionId) {
- LocalSession session = getLocalSession(tenant, sessionId);
+ private Session validateThatLocalSessionIsNotActive(Tenant tenant, long sessionId) {
+ Session session = getLocalSession(tenant, sessionId);
if (Session.Status.ACTIVATE.equals(session.getStatus())) {
throw new IllegalStateException("Session is active: " + sessionId);
}
return session;
}
- private LocalSession getLocalSession(Tenant tenant, long sessionId) {
- LocalSession session = tenant.getSessionRepository().getLocalSession(sessionId);
+ private Session getLocalSession(Tenant tenant, long sessionId) {
+ Session session = tenant.getSessionRepository().getLocalSession(sessionId);
if (session == null) throw new NotFoundException("Session " + sessionId + " was not found");
return session;
@@ -954,12 +963,13 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
}
}
- private RemoteSession getExistingSession(Tenant tenant, ApplicationId applicationId) {
+ // TODO: Merge this and getActiveSession(), they are almost identical
+ private Session getExistingSession(Tenant tenant, ApplicationId applicationId) {
TenantApplications applicationRepo = tenant.getApplicationRepo();
return getRemoteSession(tenant, applicationRepo.requireActiveSessionOf(applicationId));
}
- private RemoteSession getActiveSession(Tenant tenant, ApplicationId applicationId) {
+ public RemoteSession getActiveSession(Tenant tenant, ApplicationId applicationId) {
TenantApplications applicationRepo = tenant.getApplicationRepo();
if (applicationRepo.activeApplications().contains(applicationId)) {
return tenant.getSessionRepository().getRemoteSession(applicationRepo.requireActiveSessionOf(applicationId));
@@ -967,7 +977,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
return null;
}
- public LocalSession getActiveLocalSession(Tenant tenant, ApplicationId applicationId) {
+ public Session getActiveLocalSession(Tenant tenant, ApplicationId applicationId) {
TenantApplications applicationRepo = tenant.getApplicationRepo();
if (applicationRepo.activeApplications().contains(applicationId)) {
return tenant.getSessionRepository().getLocalSession(applicationRepo.requireActiveSessionOf(applicationId));
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
index de074886721..7d58682947f 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
@@ -14,9 +14,7 @@ import com.yahoo.vespa.config.server.TimeoutBudget;
import com.yahoo.vespa.config.server.configchange.ConfigChangeActions;
import com.yahoo.vespa.config.server.configchange.RestartActions;
import com.yahoo.vespa.config.server.http.InternalServerException;
-import com.yahoo.vespa.config.server.session.LocalSession;
import com.yahoo.vespa.config.server.session.PrepareParams;
-import com.yahoo.vespa.config.server.session.RemoteSession;
import com.yahoo.vespa.config.server.session.Session;
import com.yahoo.vespa.config.server.tenant.Tenant;
import com.yahoo.vespa.curator.Lock;
@@ -44,7 +42,7 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
private static final Logger log = Logger.getLogger(Deployment.class.getName());
/** The session containing the application instance to activate */
- private final LocalSession session;
+ private final Session session;
private final ApplicationRepository applicationRepository;
private final Supplier<PrepareParams> params;
private final Optional<Provisioner> provisioner;
@@ -56,7 +54,7 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
private boolean prepared;
private ConfigChangeActions configChangeActions;
- private Deployment(LocalSession session, ApplicationRepository applicationRepository, Supplier<PrepareParams> params,
+ private Deployment(Session session, ApplicationRepository applicationRepository, Supplier<PrepareParams> params,
Optional<Provisioner> provisioner, Tenant tenant, DeployLogger deployLogger, Clock clock,
boolean internalRedeploy, boolean prepared) {
this.session = session;
@@ -70,19 +68,19 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
this.prepared = prepared;
}
- public static Deployment unprepared(LocalSession session, ApplicationRepository applicationRepository,
+ public static Deployment unprepared(Session session, ApplicationRepository applicationRepository,
Optional<Provisioner> provisioner, Tenant tenant, PrepareParams params, DeployLogger logger, Clock clock) {
return new Deployment(session, applicationRepository, () -> params, provisioner, tenant, logger, clock, false, false);
}
- public static Deployment unprepared(LocalSession session, ApplicationRepository applicationRepository,
+ public static Deployment unprepared(Session session, ApplicationRepository applicationRepository,
Optional<Provisioner> provisioner, Tenant tenant, DeployLogger logger,
Duration timeout, Clock clock, boolean validate, boolean isBootstrap) {
Supplier<PrepareParams> params = createPrepareParams(clock, timeout, session, isBootstrap, !validate, false);
return new Deployment(session, applicationRepository, params, provisioner, tenant, logger, clock, true, false);
}
- public static Deployment prepared(LocalSession session, ApplicationRepository applicationRepository,
+ public static Deployment prepared(Session session, ApplicationRepository applicationRepository,
Optional<Provisioner> provisioner, Tenant tenant, DeployLogger logger,
Duration timeout, Clock clock, boolean isBootstrap, boolean force) {
Supplier<PrepareParams> params = createPrepareParams(clock, timeout, session, isBootstrap, false, force);
@@ -113,7 +111,7 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
TimeoutBudget timeoutBudget = params.getTimeoutBudget();
timeoutBudget.assertNotTimedOut(() -> "Timeout exceeded when trying to activate '" + applicationId + "'");
- RemoteSession previousActiveSession;
+ Session previousActiveSession;
CompletionWaiter waiter;
try (Lock lock = tenant.getApplicationRepo().lock(applicationId)) {
previousActiveSession = applicationRepository.getActiveSession(applicationId);
@@ -165,7 +163,7 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
}
/** Exposes the session of this for testing only */
- public LocalSession session() { return session; }
+ public Session session() { return session; }
/**
* @return config change actions that need to be performed as result of prepare
@@ -176,12 +174,12 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
throw new IllegalArgumentException("No config change actions: " + (prepared ? "was already prepared" : "not yet prepared"));
}
- private void validateSessionStatus(LocalSession localSession) {
- long sessionId = localSession.getSessionId();
- if (Session.Status.NEW.equals(localSession.getStatus())) {
- throw new IllegalStateException(localSession.logPre() + "Session " + sessionId + " is not prepared");
- } else if (Session.Status.ACTIVATE.equals(localSession.getStatus())) {
- throw new IllegalStateException(localSession.logPre() + "Session " + sessionId + " is already active");
+ private void validateSessionStatus(Session session) {
+ long sessionId = session.getSessionId();
+ if (Session.Status.NEW.equals(session.getStatus())) {
+ throw new IllegalStateException(session.logPre() + "Session " + sessionId + " is not prepared");
+ } else if (Session.Status.ACTIVATE.equals(session.getStatus())) {
+ throw new IllegalStateException(session.logPre() + "Session " + sessionId + " is already active");
}
}
@@ -194,7 +192,7 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
* @param force whether activation of this model should be forced
*/
private static Supplier<PrepareParams> createPrepareParams(
- Clock clock, Duration timeout, LocalSession session,
+ Clock clock, Duration timeout, Session session,
boolean isBootstrap, boolean ignoreValidationErrors, boolean force) {
// Supplier because shouldn't/cant create this before validateSessionStatus() for prepared deployments
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentRequest.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentRequest.java
index 2c0d409725c..32d2f99e5f5 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentRequest.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentRequest.java
@@ -6,7 +6,7 @@ import com.yahoo.container.jdisc.HttpRequest;
import java.io.InputStream;
-import static com.yahoo.vespa.config.server.session.LocalSession.Mode;
+import static com.yahoo.vespa.config.server.session.Session.Mode;
/**
* Represents a {@link ContentRequest}, and contains common functionality for content requests for all content handlers.
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ApplicationPackageMaintainer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ApplicationPackageMaintainer.java
index 31f8f28531d..aa709b3bf37 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ApplicationPackageMaintainer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/ApplicationPackageMaintainer.java
@@ -5,7 +5,7 @@ import com.yahoo.config.FileReference;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.config.ConnectionPool;
import com.yahoo.vespa.config.server.ApplicationRepository;
-import com.yahoo.vespa.config.server.session.RemoteSession;
+import com.yahoo.vespa.config.server.session.Session;
import com.yahoo.vespa.config.server.session.SessionRepository;
import com.yahoo.vespa.config.server.tenant.Tenant;
import com.yahoo.vespa.curator.Curator;
@@ -53,7 +53,7 @@ public class ApplicationPackageMaintainer extends ConfigServerMaintainer {
try (var fileDownloader = new FileDownloader(connectionPool, downloadDirectory)) {
for (var applicationId : applicationRepository.listApplications()) {
log.fine(() -> "Verifying application package for " + applicationId);
- RemoteSession session = applicationRepository.getActiveSession(applicationId);
+ Session session = applicationRepository.getActiveSession(applicationId);
if (session == null) continue; // App might be deleted after call to listApplications()
FileReference applicationPackage = session.getApplicationPackageReference();
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 1eeac5c7280..de5f1392242 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
@@ -41,9 +41,8 @@ public class RemoteSession extends Session {
this.applicationSet = applicationSet;
}
- Optional<ApplicationSet> applicationSet() {
- return applicationSet;
- }
+ @Override
+ Optional<ApplicationSet> applicationSet() { return applicationSet; }
public synchronized RemoteSession activated(ApplicationSet applicationSet) {
Objects.requireNonNull(applicationSet, "applicationSet cannot be null");
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 871b8e75bd6..69dfc4d627d 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
@@ -13,6 +13,7 @@ import com.yahoo.config.provision.DockerImage;
import com.yahoo.config.provision.TenantName;
import com.yahoo.path.Path;
import com.yahoo.transaction.Transaction;
+import com.yahoo.vespa.config.server.application.ApplicationSet;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
import java.time.Instant;
@@ -187,6 +188,8 @@ public abstract class Session implements Comparable<Session> {
return getApplicationPackage().getFile(relativePath);
}
+ Optional<ApplicationSet> applicationSet() { return Optional.empty(); };
+
private void markSessionEdited() {
setStatus(Session.Status.NEW);
}
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 05c7bb364f0..59146c339d3 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
@@ -147,7 +147,7 @@ public class SessionRepository {
}
}
- public ConfigChangeActions prepareLocalSession(LocalSession session, DeployLogger logger, PrepareParams params, Instant now) {
+ public ConfigChangeActions prepareLocalSession(Session session, DeployLogger logger, PrepareParams params, Instant now) {
applicationRepo.createApplication(params.getApplicationId()); // TODO jvenstad: This is wrong, but it has to be done now, since preparation can change the application ID of a session :(
logger.log(Level.FINE, "Created application " + params.getApplicationId());
long sessionId = session.getSessionId();
@@ -235,7 +235,7 @@ public class SessionRepository {
return remoteSessionCache.get(sessionId);
}
- public List<Long> getRemoteSessions() {
+ public List<Long> getRemoteSessionsFromZooKeeper() {
return getSessionList(curator.getChildren(sessionsPath));
}
@@ -250,8 +250,8 @@ public class SessionRepository {
public int deleteExpiredRemoteSessions(Clock clock, Duration expiryTime) {
int deleted = 0;
- for (long sessionId : getRemoteSessions()) {
- RemoteSession session = remoteSessionCache.get(sessionId);
+ for (long sessionId : getRemoteSessionsFromZooKeeper()) {
+ Session session = remoteSessionCache.get(sessionId);
if (session == null) continue; // Internal sessions not in sync with zk, continue
if (session.getStatus() == Session.Status.ACTIVATE) continue;
if (sessionHasExpired(session.getCreateTime(), expiryTime, clock)) {
@@ -268,7 +268,7 @@ public class SessionRepository {
remoteSessionCache.put(session.getSessionId(), session);
}
- public void deleteRemoteSessionFromZooKeeper(RemoteSession session) {
+ public void deleteRemoteSessionFromZooKeeper(Session session) {
SessionZooKeeperClient sessionZooKeeperClient = createSessionZooKeeperClient(session.getSessionId());
Transaction transaction = sessionZooKeeperClient.deleteTransaction();
transaction.commit();
@@ -290,7 +290,7 @@ public class SessionRepository {
}
private void loadRemoteSessions() throws NumberFormatException {
- getRemoteSessions().forEach(this::sessionAdded);
+ getRemoteSessionsFromZooKeeper().forEach(this::sessionAdded);
}
/**
@@ -300,7 +300,7 @@ public class SessionRepository {
*/
public synchronized void sessionAdded(long sessionId) {
log.log(Level.FINE, () -> "Adding remote session " + sessionId);
- RemoteSession session = createRemoteSession(sessionId);
+ Session session = createRemoteSession(sessionId);
if (session.getStatus() == Session.Status.NEW) {
log.log(Level.FINE, () -> session.logPre() + "Confirming upload for session " + sessionId);
confirmUpload(session);
@@ -320,7 +320,7 @@ public class SessionRepository {
log.log(Level.INFO, session.logPre() + "Session activated: " + sessionId);
}
- public void delete(RemoteSession remoteSession) {
+ public void delete(Session remoteSession) {
long sessionId = remoteSession.getSessionId();
// TODO: Change log level to FINE when debugging is finished
log.log(Level.INFO, () -> remoteSession.logPre() + "Deactivating and deleting remote session " + sessionId);
@@ -360,7 +360,6 @@ public class SessionRepository {
}
public ApplicationSet ensureApplicationLoaded(RemoteSession session) {
-
if (session.applicationSet().isPresent()) {
return session.applicationSet().get();
}
@@ -374,7 +373,7 @@ public class SessionRepository {
return applicationSet;
}
- void confirmUpload(RemoteSession session) {
+ void confirmUpload(Session session) {
Curator.CompletionWaiter waiter = session.getSessionZooKeeperClient().getUploadWaiter();
long sessionId = session.getSessionId();
log.log(Level.FINE, "Notifying upload waiter for session " + sessionId);
@@ -382,7 +381,7 @@ public class SessionRepository {
log.log(Level.FINE, "Done notifying upload for session " + sessionId);
}
- void notifyCompletion(Curator.CompletionWaiter completionWaiter, RemoteSession session) {
+ void notifyCompletion(Curator.CompletionWaiter completionWaiter, Session session) {
try {
completionWaiter.notifyCompletion();
} catch (RuntimeException e) {
@@ -406,7 +405,7 @@ public class SessionRepository {
}
}
- private ApplicationSet loadApplication(RemoteSession session) {
+ private ApplicationSet loadApplication(Session session) {
log.log(Level.FINE, () -> "Loading application for " + session);
SessionZooKeeperClient sessionZooKeeperClient = createSessionZooKeeperClient(session.getSessionId());
ApplicationPackage applicationPackage = sessionZooKeeperClient.loadApplicationPackage();
@@ -428,7 +427,7 @@ public class SessionRepository {
private void nodeChanged() {
zkWatcherExecutor.execute(() -> {
Multiset<Session.Status> sessionMetrics = HashMultiset.create();
- for (RemoteSession session : remoteSessionCache.values()) {
+ for (Session session : remoteSessionCache.values()) {
sessionMetrics.add(session.getStatus());
}
metrics.setNewSessions(sessionMetrics.count(Session.Status.NEW));
@@ -708,7 +707,7 @@ public class SessionRepository {
}
private void checkForRemovedSessions(List<Long> sessions) {
- for (RemoteSession session : remoteSessionCache.values())
+ for (Session session : remoteSessionCache.values())
if ( ! sessions.contains(session.getSessionId()))
sessionRemoved(session.getSessionId());
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
index 7429dc022dd..b71d1b99cf0 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
@@ -8,7 +8,6 @@ import com.yahoo.config.SimpletypesConfig;
import com.yahoo.config.application.api.ApplicationMetaData;
import com.yahoo.config.model.NullConfigModelRegistry;
import com.yahoo.config.model.api.ApplicationRoles;
-import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.config.model.application.provider.FilesApplicationPackage;
import com.yahoo.config.provision.AllocatedHosts;
import com.yahoo.config.provision.ApplicationId;
@@ -36,11 +35,9 @@ import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs;
import com.yahoo.vespa.config.server.http.v2.PrepareResult;
import com.yahoo.vespa.config.server.session.LocalSession;
import com.yahoo.vespa.config.server.session.PrepareParams;
-import com.yahoo.vespa.config.server.session.RemoteSession;
import com.yahoo.vespa.config.server.session.Session;
import com.yahoo.vespa.config.server.session.SessionRepository;
import com.yahoo.vespa.config.server.session.SessionZooKeeperClient;
-import com.yahoo.vespa.config.server.session.SilentDeployLogger;
import com.yahoo.vespa.config.server.tenant.ApplicationRolesStore;
import com.yahoo.vespa.config.server.tenant.Tenant;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
@@ -155,8 +152,7 @@ public class ApplicationRepositoryTest {
assertTrue(result.configChangeActions().getRestartActions().isEmpty());
Tenant tenant = applicationRepository.getTenant(applicationId());
- LocalSession session = tenant.getSessionRepository().getLocalSession(tenant.getApplicationRepo()
- .requireActiveSessionOf(applicationId()));
+ Session session = applicationRepository.getActiveLocalSession(tenant, applicationId());
session.getAllocatedHosts();
}
@@ -228,8 +224,7 @@ public class ApplicationRepositoryTest {
assertNotEquals(firstSessionId, secondSessionId);
Tenant tenant = applicationRepository.getTenant(applicationId());
- LocalSession session = tenant.getSessionRepository().getLocalSession(
- tenant.getApplicationRepo().requireActiveSessionOf(applicationId()));
+ Session session = applicationRepository.getActiveLocalSession(tenant, applicationId());
assertEquals(firstSessionId, session.getMetaData().getPreviousActiveGeneration());
}
@@ -314,7 +309,7 @@ public class ApplicationRepositoryTest {
{
PrepareResult result = deployApp(testApp);
long sessionId = result.sessionId();
- LocalSession applicationData = sessionRepository.getLocalSession(sessionId);
+ Session applicationData = sessionRepository.getLocalSession(sessionId);
assertNotNull(applicationData);
assertNotNull(applicationData.getApplicationId());
assertNotNull(sessionRepository.getLocalSession(sessionId));
@@ -383,7 +378,7 @@ public class ApplicationRepositoryTest {
assertTrue(deployment3.isPresent());
deployment3.get().prepare(); // session 4 (not activated)
- LocalSession deployment3session = ((com.yahoo.vespa.config.server.deploy.Deployment) deployment3.get()).session();
+ Session deployment3session = ((com.yahoo.vespa.config.server.deploy.Deployment) deployment3.get()).session();
assertNotEquals(activeSessionId, deployment3session.getSessionId());
// No change to active session id
assertEquals(activeSessionId, tester.tenant().getApplicationRepo().requireActiveSessionOf(tester.applicationId()));
@@ -402,8 +397,8 @@ public class ApplicationRepositoryTest {
// All sessions except 3 should be removed after the call to deleteExpiredRemoteSessions
assertEquals(2, tester.applicationRepository().deleteExpiredRemoteSessions(clock, Duration.ofSeconds(0)));
- ArrayList<Long> remoteSessions = new ArrayList<>(sessionRepository.getRemoteSessions());
- RemoteSession remoteSession = sessionRepository.getRemoteSession(remoteSessions.get(0));
+ ArrayList<Long> remoteSessions = new ArrayList<>(sessionRepository.getRemoteSessionsFromZooKeeper());
+ Session remoteSession = sessionRepository.getRemoteSession(remoteSessions.get(0));
assertEquals(3, remoteSession.getSessionId());
// Deploy, but do not activate
@@ -485,7 +480,7 @@ public class ApplicationRepositoryTest {
prepareAndActivate(testAppJdiscOnly);
Tenant tenant = applicationRepository.getTenant(applicationId());
- LocalSession session = tenant.getSessionRepository().getLocalSession(tenant.getApplicationRepo().requireActiveSessionOf(applicationId()));
+ Session session = applicationRepository.getActiveLocalSession(tenant, applicationId());
List<NetworkPorts.Allocation> list = new ArrayList<>();
list.add(new NetworkPorts.Allocation(8080, "container", "container/container.0", "http"));
@@ -532,7 +527,7 @@ public class ApplicationRepositoryTest {
exceptionRule.expectMessage(containsString("tenant:test1 Session 3 is not prepared"));
applicationRepository.activate(applicationRepository.getTenant(applicationId()), sessionId, timeoutBudget, false);
- RemoteSession activeSession = applicationRepository.getActiveSession(applicationId());
+ Session activeSession = applicationRepository.getActiveSession(applicationId());
assertEquals(firstSession, activeSession.getSessionId());
assertEquals(Session.Status.ACTIVATE, activeSession.getStatus());
}
@@ -549,7 +544,7 @@ public class ApplicationRepositoryTest {
exceptionRule.expectMessage(containsString("Timeout exceeded when trying to activate 'test1.testapp'"));
applicationRepository.activate(applicationRepository.getTenant(applicationId()), sessionId, new TimeoutBudget(clock, Duration.ofSeconds(0)), false);
- RemoteSession activeSession = applicationRepository.getActiveSession(applicationId());
+ Session activeSession = applicationRepository.getActiveSession(applicationId());
assertEquals(firstSession, activeSession.getSessionId());
assertEquals(Session.Status.ACTIVATE, activeSession.getStatus());
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java
index eb77d6e4081..5b5f830c737 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java
@@ -29,8 +29,8 @@ import com.yahoo.vespa.config.server.application.OrchestratorMock;
import com.yahoo.vespa.config.server.http.v2.PrepareResult;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.monitoring.Metrics;
-import com.yahoo.vespa.config.server.session.LocalSession;
import com.yahoo.vespa.config.server.session.PrepareParams;
+import com.yahoo.vespa.config.server.session.Session;
import com.yahoo.vespa.config.server.tenant.Tenant;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
import com.yahoo.vespa.curator.Curator;
@@ -159,8 +159,7 @@ public class DeployTester {
public AllocatedHosts getAllocatedHostsOf(ApplicationId applicationId) {
Tenant tenant = tenant();
- LocalSession session = tenant.getSessionRepository().getLocalSession(tenant.getApplicationRepo()
- .requireActiveSessionOf(applicationId));
+ Session session = applicationRepository.getActiveSession(tenant, applicationId);
return session.getAllocatedHosts();
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
index 24694e3a585..126dfe88141 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
@@ -13,7 +13,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
import com.yahoo.vespa.config.server.http.ContentHandlerTestBase;
-import com.yahoo.vespa.config.server.session.LocalSession;
import com.yahoo.vespa.config.server.session.PrepareParams;
import com.yahoo.vespa.config.server.session.Session;
import com.yahoo.vespa.config.server.tenant.Tenant;
@@ -39,8 +38,6 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase {
private static final File testApp = new File("src/test/apps/content");
private static final File testApp2 = new File("src/test/apps/content2");
-
-
private final TenantName tenantName1 = TenantName.from("mofet");
private final TenantName tenantName2 = TenantName.from("bla");
private final String baseServer = "http://foo:1337";
@@ -126,7 +123,7 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase {
@Test
public void require_that_get_does_not_set_write_flag() throws IOException {
Tenant tenant1 = applicationRepository.getTenant(appId1);
- LocalSession session = applicationRepository.getActiveLocalSession(tenant1, appId1);
+ Session session = applicationRepository.getActiveLocalSession(tenant1, appId1);
assertContent("/test.txt", "foo\n");
assertThat(session.getStatus(), is(Session.Status.ACTIVATE));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
index 0147dde5d95..23b711adc02 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
@@ -19,8 +19,8 @@ import com.yahoo.vespa.config.server.http.HandlerTest;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.model.TestModelFactory;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
-import com.yahoo.vespa.config.server.session.LocalSession;
import com.yahoo.vespa.config.server.session.PrepareParams;
+import com.yahoo.vespa.config.server.session.Session;
import com.yahoo.vespa.config.server.tenant.Tenant;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
import com.yahoo.vespa.curator.mock.MockCurator;
@@ -141,7 +141,7 @@ public class SessionActiveHandlerTest {
applicationRepository.prepare(sessionId, new PrepareParams.Builder().applicationId(applicationId()).build());
actResponse = handler.handle(createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.ACTIVE, sessionId, subPath));
Tenant tenant = applicationRepository.getTenant(applicationId());
- LocalSession session = applicationRepository.getActiveLocalSession(tenant, applicationId());
+ Session session = applicationRepository.getActiveLocalSession(tenant, applicationId());
metaData = session.getMetaData();
this.sessionId = sessionId;
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
index 4d7702eec9e..4ee8cf81e4a 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
@@ -64,7 +64,7 @@ public class RpcServerTest {
ApplicationRepository applicationRepository = tester.applicationRepository();
applicationRepository.deploy(testApp, new PrepareParams.Builder().applicationId(applicationId).build());
TenantApplications applicationRepo = tester.tenant().getApplicationRepo();
- ApplicationSet applicationSet = tester.tenant().getSessionRepository().ensureApplicationLoaded(applicationRepository.getActiveSession(applicationId));
+ ApplicationSet applicationSet = tester.tenant().getSessionRepository().ensureApplicationLoaded(applicationRepository.getActiveRemoteSession(applicationId));
applicationRepo.reloadConfig(applicationSet);
testPrintStatistics(tester);
testGetConfig(tester);
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
index a4a9579a21d..bfcfc7d6e43 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
@@ -175,9 +175,9 @@ public class SessionRepositoryTest {
curator.set(TenantRepository.getApplicationsPath(mytenant).append("mytenant:appX:default"), new byte[0]); // Invalid data
tenantRepository.addTenant(mytenant);
curator.create(TenantRepository.getSessionsPath(mytenant));
- assertThat(sessionRepository.getRemoteSessions().size(), is(0));
+ assertThat(sessionRepository.getRemoteSessionsFromZooKeeper().size(), is(0));
createSession(sessionId, true);
- assertThat(sessionRepository.getRemoteSessions().size(), is(1));
+ assertThat(sessionRepository.getRemoteSessionsFromZooKeeper().size(), is(1));
}
@Test(expected = InvalidApplicationException.class)