summaryrefslogtreecommitdiffstats
path: root/configserver/src
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-07-07 13:44:42 +0200
committerHarald Musum <musum@verizonmedia.com>2020-07-07 13:44:42 +0200
commit514b7f58f61403fd1209b45bf02a0668c41e8720 (patch)
tree9c29437fd5bdcce677994a645b9c8409f36c2e85 /configserver/src
parent2c0ac4d1adca7cb5687c6fe053f87c53cb550a7a (diff)
Minor simplifications
Diffstat (limited to 'configserver/src')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java18
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java4
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java4
3 files changed, 13 insertions, 13 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 e57fc104dd3..8ba4581e158 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
@@ -306,8 +306,9 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
LocalSession activeSession = getActiveLocalSession(tenant, application);
if (activeSession == null) return Optional.empty();
TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout);
- LocalSession newSession = tenant.getSessionRepository().createSessionFromExisting(activeSession, logger, true, timeoutBudget);
- tenant.getSessionRepository().addLocalSession(newSession);
+ SessionRepository sessionRepository = tenant.getSessionRepository();
+ LocalSession newSession = sessionRepository.createSessionFromExisting(activeSession, logger, true, timeoutBudget);
+ sessionRepository.addLocalSession(newSession);
return Optional.of(Deployment.unprepared(newSession, this, hostProvisioner, tenant, timeout, clock,
false /* don't validate as this is already deployed */, bootstrap));
@@ -493,11 +494,10 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
private Application getApplication(ApplicationId applicationId, Optional<Version> version) {
try {
- Tenant tenant = tenantRepository.getTenant(applicationId.tenant());
+ Tenant tenant = getTenant(applicationId);
if (tenant == null) throw new NotFoundException("Tenant '" + applicationId.tenant() + "' not found");
long sessionId = getSessionIdForApplication(tenant, applicationId);
- RemoteSession session = tenant.getSessionRepository().getRemoteSession(sessionId);
- if (session == null) throw new NotFoundException("Remote session " + sessionId + " not found");
+ RemoteSession session = getRemoteSession(tenant, sessionId);
return session.ensureApplicationLoaded().getForVersionOrLatest(version, clock.instant());
} catch (NotFoundException e) {
log.log(Level.WARNING, "Failed getting application for '" + applicationId + "': " + e.getMessage());
@@ -625,15 +625,15 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
return applicationRepo.requireActiveSessionOf(applicationId);
}
- public void validateThatRemoteSessionIsNotActive(Tenant tenant, long sessionId) {
- RemoteSession session = getRemoteSession(tenant, sessionId);
+ public void validateThatSessionIsNotActive(Tenant tenant, long sessionId) {
+ Session session = getRemoteSession(tenant, sessionId);
if (Session.Status.ACTIVATE.equals(session.getStatus())) {
throw new IllegalStateException("Session is active: " + sessionId);
}
}
- public void validateThatRemoteSessionIsPrepared(Tenant tenant, long sessionId) {
- RemoteSession session = getRemoteSession(tenant, sessionId);
+ public void validateThatSessionIsPrepared(Tenant tenant, long sessionId) {
+ Session session = getRemoteSession(tenant, sessionId);
if ( ! Session.Status.PREPARE.equals(session.getStatus()))
throw new IllegalStateException("Session not prepared: " + sessionId);
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java
index bade20f45ad..c0789a9c828 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java
@@ -49,8 +49,8 @@ public class SessionPrepareHandler extends SessionHandler {
protected HttpResponse handleGET(HttpRequest request) {
Tenant tenant = getExistingTenant(request);
long sessionId = getSessionIdV2(request);
- applicationRepository.validateThatRemoteSessionIsNotActive(tenant, sessionId);
- applicationRepository.validateThatRemoteSessionIsPrepared(tenant, sessionId);
+ applicationRepository.validateThatSessionIsNotActive(tenant, sessionId);
+ applicationRepository.validateThatSessionIsPrepared(tenant, sessionId);
return new SessionPrepareResponse(applicationRepository.createDeployLog(), tenant.getName(), request, sessionId);
}
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 fd3bc84ed8a..8c3ab795f02 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
@@ -70,7 +70,7 @@ public class SessionRepository {
private static final Logger log = Logger.getLogger(SessionRepository.class.getName());
private static final FilenameFilter sessionApplicationsFilter = (dir, name) -> name.matches("\\d+");
- private static final long nonExistingActiveSession = 0;
+ private static final long nonExistingActiveSessionId = 0;
private final SessionCache<LocalSession> localSessionCache = new SessionCache<>();
private final SessionCache<RemoteSession> remoteSessionCache = new SessionCache<>();
@@ -451,7 +451,7 @@ public class SessionRepository {
user = "unknown";
}
DeployData deployData = new DeployData(user, userDir.getAbsolutePath(), applicationId, deployTimestamp,
- internalRedeploy, sessionId, currentlyActiveSessionId.orElse(nonExistingActiveSession));
+ internalRedeploy, sessionId, currentlyActiveSessionId.orElse(nonExistingActiveSessionId));
return FilesApplicationPackage.fromFileWithDeployData(configApplicationDir, deployData);
}