diff options
author | Jon Bratseth <jonbratseth@yahoo.com> | 2018-01-31 09:15:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-31 09:15:55 +0100 |
commit | db2401b216a90a945221aa40f8dcdcc6fdcce6d9 (patch) | |
tree | f05b159a976f100fe4299488f7eb521b59ef2fba /configserver | |
parent | 7923c31a91388782f6f6b169358a6cecdf63d2fc (diff) | |
parent | c0b12b093c13e4256e4b949a11f9e6a10963fa2d (diff) |
Merge pull request #4817 from vespa-engine/hmusum/use-high-level-constructs
Use application repo to avoid dealing with low-level code
Diffstat (limited to 'configserver')
3 files changed, 10 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 7d47cc0b101..633207f1fcb 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 @@ -49,6 +49,7 @@ import java.io.File; import java.net.URI; import java.time.Clock; import java.time.Duration; +import java.time.Instant; import java.util.List; import java.util.Optional; import java.util.concurrent.ExecutorService; @@ -339,14 +340,14 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye return currentActiveApplicationSet; } - public PrepareResult prepare(Tenant tenant, long sessionId, PrepareParams prepareParams) { + public PrepareResult prepare(Tenant tenant, long sessionId, PrepareParams prepareParams, Instant now) { validateThatLocalSessionIsNotActive(tenant, sessionId); LocalSession session = getLocalSession(tenant, sessionId); ApplicationId applicationId = prepareParams.getApplicationId(); Optional<ApplicationSet> currentActiveApplicationSet = getCurrentActiveApplicationSet(tenant, applicationId); Slime deployLog = createDeployLog(); DeployLogger logger = new DeployHandlerLogger(deployLog.get().setArray("log"), prepareParams.isVerbose(), applicationId); - ConfigChangeActions actions = session.prepare(logger, prepareParams, currentActiveApplicationSet, tenant.getPath(), clock.instant()); + ConfigChangeActions actions = session.prepare(logger, prepareParams, currentActiveApplicationSet, tenant.getPath(), now); logConfigChangeActions(actions, logger); log.log(LogLevel.INFO, Tenants.logPre(applicationId) + "Session " + sessionId + " prepared successfully. "); return new PrepareResult(sessionId, actions, deployLog); 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 c0782d11ad9..1eca5bc7acc 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 @@ -14,6 +14,7 @@ import com.yahoo.vespa.config.server.http.SessionHandler; import com.yahoo.vespa.config.server.http.Utils; import java.time.Duration; +import java.time.Instant; /** * A handler that prepares a session given by an id in the request. v2 of application API @@ -41,7 +42,7 @@ public class SessionPrepareHandler extends SessionHandler { TenantName tenantName = tenant.getName(); long sessionId = getSessionIdV2(request); PrepareParams prepareParams = PrepareParams.fromHttpRequest(request, tenantName, zookeeperBarrierTimeout); - PrepareResult result = applicationRepository.prepare(tenant, sessionId, prepareParams); + PrepareResult result = applicationRepository.prepare(tenant, sessionId, prepareParams, Instant.now()); return new SessionPrepareResponse(result, tenantName, request); } 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 63f0f5f26b7..ac23861bd86 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 @@ -33,7 +33,6 @@ 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.SilentDeployLogger; import com.yahoo.vespa.config.server.tenant.Tenant; import com.yahoo.vespa.config.server.tenant.Tenants; import com.yahoo.vespa.curator.Curator; @@ -134,20 +133,16 @@ public class DeployTester { * Do the initial "deploy" with the existing API-less code as the deploy API doesn't support first deploys yet. */ public ApplicationId deployApp(String appName, String vespaVersion, Instant now) { - Tenant tenant = tenant(); - LocalSession session = tenant.getSessionFactory().createSession(testApp, appName, new TimeoutBudget(clock, Duration.ofSeconds(60))); + TimeoutBudget timeoutBudget = new TimeoutBudget(clock, Duration.ofSeconds(60)); ApplicationId id = ApplicationId.from(tenant.getName(), ApplicationName.from(appName), InstanceName.defaultName()); PrepareParams.Builder paramsBuilder = new PrepareParams.Builder().applicationId(id); if (vespaVersion != null) paramsBuilder.vespaVersion(vespaVersion); - session.prepare(new SilentDeployLogger(), - paramsBuilder.build(), - Optional.empty(), - tenant.getPath(), - now); - session.createActivateTransaction().commit(); - tenant.getLocalSessionRepo().addSession(session); + + long sessionId = applicationRepository.createSession(tenant, timeoutBudget, testApp, appName); + applicationRepository.prepare(tenant, sessionId, paramsBuilder.build(), now); + applicationRepository.activate(tenant, sessionId, timeoutBudget, false, false); this.id = id; return id; } |