diff options
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java | 10 | ||||
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java | 12 |
2 files changed, 13 insertions, 9 deletions
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 466138c817f..6e571fec72b 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 @@ -30,6 +30,8 @@ import java.time.Duration; import java.util.Optional; import java.util.logging.Logger; +import static com.yahoo.vespa.curator.Curator.CompletionWaiter; + /** * The process of deploying an application. * Deployments are created by an {@link ApplicationRepository}. @@ -140,9 +142,11 @@ public class Deployment implements com.yahoo.config.provision.Deployment { if ( ! timeoutBudget.hasTimeLeft()) throw new RuntimeException("Timeout exceeded when trying to activate '" + applicationId + "'"); RemoteSession previousActiveSession; + CompletionWaiter waiter; try (Lock lock = tenant.getApplicationRepo().lock(applicationId)) { - NestedTransaction transaction = new NestedTransaction(); previousActiveSession = applicationRepository.getActiveSession(applicationId); + waiter = session.createActiveWaiter(); + NestedTransaction transaction = new NestedTransaction(); transaction.add(deactivateCurrentActivateNew(previousActiveSession, session, ignoreSessionStaleFailure)); hostProvisioner.ifPresent(provisioner -> provisioner.activate(transaction, applicationId, session.getAllocatedHosts().getHosts())); transaction.commit(); @@ -154,11 +158,11 @@ public class Deployment implements com.yahoo.config.provision.Deployment { throw new InternalServerException("Error activating application", e); } - session.waitUntilActivated(timeoutBudget); + waiter.awaitCompletion(timeoutBudget.timeLeft()); log.log(Level.INFO, session.logPre() + "Session " + session.getSessionId() + " activated successfully using " + hostProvisioner.map(provisioner -> provisioner.getClass().getSimpleName()).orElse("no host provisioner") + ". Config generation " + session.getMetaData().getGeneration() + - (previousActiveSession != null ? ". Based on previous active session " + previousActiveSession.getSessionId() : "") + + (previousActiveSession != null ? ". Based on session " + previousActiveSession.getSessionId() : "") + ". File references: " + applicationRepository.getFileReferences(applicationId)); } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java index 73e7b36c381..96324ea4320 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java @@ -7,9 +7,10 @@ import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.provision.TenantName; import com.yahoo.path.Path; import com.yahoo.transaction.Transaction; -import com.yahoo.vespa.config.server.TimeoutBudget; import com.yahoo.vespa.config.server.application.TenantApplications; +import static com.yahoo.vespa.curator.Curator.CompletionWaiter; + /** * A LocalSession is a session that has been created locally on this configserver. A local session can be edited and * prepared. Deleting a local session will ensure that the local filesystem state and global zookeeper state is @@ -56,8 +57,11 @@ public class LocalSession extends Session { sessionZooKeeperClient.writeStatus(newStatus); } + public CompletionWaiter createActiveWaiter() { + return sessionZooKeeperClient.createActiveWaiter(); + } + public Transaction createActivateTransaction() { - sessionZooKeeperClient.createActiveWaiter(); Transaction transaction = createSetStatusTransaction(Status.ACTIVATE); transaction.add(applicationRepo.createPutTransaction(sessionZooKeeperClient.readApplicationId(), getSessionId()).operations()); return transaction; @@ -71,10 +75,6 @@ public class LocalSession extends Session { return applicationPackage.getMetaData().getPreviousActiveGeneration(); } - public void waitUntilActivated(TimeoutBudget timeoutBudget) { - sessionZooKeeperClient.getActiveWaiter().awaitCompletion(timeoutBudget.timeLeft()); - } - public enum Mode { READ, WRITE } |