aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/main/java/com/yahoo/vespa/config
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2024-06-07 14:30:15 +0200
committerHarald Musum <musum@yahooinc.com>2024-06-07 14:30:15 +0200
commitab28f6754299957fdae78469e13fc33915c6b7e8 (patch)
treea8f144ab6122b6efaafd9e1cec4e1efe1073d02d /configserver/src/main/java/com/yahoo/vespa/config
parent0a5fde8f0e91cb774ce65fe525f54bf7fd905260 (diff)
Minor simplifications found while reading code, no functional changes
Diffstat (limited to 'configserver/src/main/java/com/yahoo/vespa/config')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java31
1 files changed, 9 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 8ffbeede37e..01015a30bf4 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
@@ -899,15 +899,6 @@ 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 Optional<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 Optional<Session> getActiveRemoteSession(ApplicationId applicationId) {
Tenant tenant = getTenant(applicationId);
if (tenant == null) throw new IllegalArgumentException("Could not find any tenant for '" + applicationId + "'");
return getActiveSession(tenant, applicationId);
@@ -915,15 +906,12 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
public long getSessionIdForApplication(ApplicationId applicationId) {
Tenant tenant = getTenant(applicationId);
- if (tenant == null) throw new NotFoundException("Tenant '" + applicationId.tenant() + "' not found");
- return getSessionIdForApplication(tenant, applicationId);
- }
-
- private long getSessionIdForApplication(Tenant tenant, ApplicationId applicationId) {
- TenantApplications applicationRepo = tenant.getApplicationRepo();
- if (! applicationRepo.exists(applicationId))
+ if (tenant == null)
+ throw new NotFoundException("Tenant '" + applicationId.tenant() + "' not found");
+ if (! tenant.getApplicationRepo().exists(applicationId))
throw new NotFoundException("Unknown application id '" + applicationId + "'");
- return applicationRepo.requireActiveSessionOf(applicationId);
+
+ return requireActiveSession(tenant, applicationId).getSessionId();
}
public void validateThatSessionIsNotActive(Tenant tenant, long sessionId) {
@@ -944,7 +932,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
DeployLogger deployLogger) {
Tenant tenant = getTenant(applicationId);
SessionRepository sessionRepository = tenant.getSessionRepository();
- Session fromSession = getExistingSession(tenant, applicationId);
+ Session fromSession = requireActiveSession(tenant, applicationId);
return sessionRepository.createSessionFromExisting(fromSession, internalRedeploy, timeoutBudget, deployLogger).getSessionId();
}
@@ -1130,10 +1118,9 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
}
}
- // 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 Session requireActiveSession(Tenant tenant, ApplicationId applicationId) {
+ return getActiveSession(tenant, applicationId)
+ .orElseThrow(() -> new IllegalArgumentException("Application '" + applicationId + "' has no active session."));
}
public Optional<Session> getActiveSession(Tenant tenant, ApplicationId applicationId) {