Search in sources :

Example 11 with Lock

use of com.yahoo.vespa.curator.Lock in project vespa by vespa-engine.

the class TenantController method updateTenant.

public void updateTenant(Tenant updatedTenant, Optional<NToken> token) {
    try (Lock lock = lock(updatedTenant.getId())) {
        if (!tenant(updatedTenant.getId()).isPresent())
            throw new IllegalArgumentException("Could not update " + updatedTenant + ": Tenant does not exist");
        if (updatedTenant.isAthensTenant() && !token.isPresent())
            throw new IllegalArgumentException("Could not update " + updatedTenant + ": No NToken provided");
        updateAthenzDomain(updatedTenant, token);
        db.updateTenant(updatedTenant);
        log.info("Updated " + updatedTenant);
    } catch (PersistenceException e) {
        throw new RuntimeException(e);
    }
}
Also used : PersistenceException(com.yahoo.vespa.hosted.controller.persistence.PersistenceException) Lock(com.yahoo.vespa.curator.Lock)

Example 12 with Lock

use of com.yahoo.vespa.curator.Lock in project vespa by vespa-engine.

the class JobControl method setActive.

/**
 * Set a job active or inactive
 */
public void setActive(String jobSimpleClassName, boolean active) {
    try (Lock lock = db.lockInactiveJobs()) {
        Set<String> inactiveJobs = db.readInactiveJobs();
        if (active)
            inactiveJobs.remove(jobSimpleClassName);
        else
            inactiveJobs.add(jobSimpleClassName);
        db.writeInactiveJobs(inactiveJobs);
    }
}
Also used : Lock(com.yahoo.vespa.curator.Lock)

Aggregations

Lock (com.yahoo.vespa.curator.Lock)12 Tenant (com.yahoo.vespa.hosted.controller.api.Tenant)4 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 ZmsClient (com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsClient)2 ImmutableList (com.google.common.collect.ImmutableList)1 Pair (com.yahoo.collections.Pair)1 Version (com.yahoo.component.Version)1 DeploymentSpec (com.yahoo.config.application.api.DeploymentSpec)1 ValidationId (com.yahoo.config.application.api.ValidationId)1 Environment (com.yahoo.config.provision.Environment)1 TenantName (com.yahoo.config.provision.TenantName)1 NToken (com.yahoo.vespa.athenz.api.NToken)1 ActivateResult (com.yahoo.vespa.hosted.controller.api.ActivateResult)1 DeployOptions (com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions)1 EndpointStatus (com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus)1 ConfigChangeActions (com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions)1 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)1 Hostname (com.yahoo.vespa.hosted.controller.api.identifiers.Hostname)1 RevisionId (com.yahoo.vespa.hosted.controller.api.identifiers.RevisionId)1