Search in sources :

Example 1 with ActivationConflictException

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());
}
Also used : ActivationConflictException(com.yahoo.vespa.config.server.ActivationConflictException) InternalServerException(com.yahoo.vespa.config.server.http.InternalServerException) NestedTransaction(com.yahoo.transaction.NestedTransaction) TimeoutBudget(com.yahoo.vespa.config.server.TimeoutBudget) InternalServerException(com.yahoo.vespa.config.server.http.InternalServerException) ActivationConflictException(com.yahoo.vespa.config.server.ActivationConflictException) ActivateLock(com.yahoo.vespa.config.server.tenant.ActivateLock)

Aggregations

NestedTransaction (com.yahoo.transaction.NestedTransaction)1 ActivationConflictException (com.yahoo.vespa.config.server.ActivationConflictException)1 TimeoutBudget (com.yahoo.vespa.config.server.TimeoutBudget)1 InternalServerException (com.yahoo.vespa.config.server.http.InternalServerException)1 ActivateLock (com.yahoo.vespa.config.server.tenant.ActivateLock)1