use of com.yahoo.vespa.config.server.ActivationConflictException in project vespa by vespa-engine.
the class Deployment method activate.
/**
* Activates this. If it is not already prepared, this will call prepare first.
*/
@Override
public void activate() {
if (!prepared)
prepare();
TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout);
long sessionId = session.getSessionId();
validateSessionStatus(session);
ActivateLock activateLock = tenant.getActivateLock();
boolean activateLockAcquired = false;
try {
log.log(LogLevel.DEBUG, "Trying to acquire lock " + activateLock + " for session " + sessionId);
activateLockAcquired = activateLock.acquire(timeoutBudget, ignoreLockFailure);
if (!activateLockAcquired) {
throw new ActivationConflictException("Did not get activate lock for session " + sessionId + " within " + timeout);
}
log.log(LogLevel.DEBUG, "Lock acquired " + activateLock + " for session " + sessionId);
NestedTransaction transaction = new NestedTransaction();
transaction.add(deactivateCurrentActivateNew(applicationRepository.getActiveSession(session.getApplicationId()), session, ignoreSessionStaleFailure));
if (hostProvisioner.isPresent()) {
hostProvisioner.get().activate(transaction, session.getApplicationId(), session.getAllocatedHosts().getHosts());
}
transaction.commit();
session.waitUntilActivated(timeoutBudget);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new InternalServerException("Error activating application", e);
} finally {
if (activateLockAcquired) {
log.log(LogLevel.DEBUG, "Trying to release lock " + activateLock + " for session " + sessionId);
activateLock.release();
log.log(LogLevel.DEBUG, "Lock released " + activateLock + " for session " + sessionId);
}
}
log.log(LogLevel.INFO, session.logPre() + "Session " + sessionId + " activated successfully using " + (hostProvisioner.isPresent() ? hostProvisioner.get() : "no host provisioner") + ". Config generation " + session.getMetaData().getGeneration());
}
Aggregations