Search in sources :

Example 6 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class SessionPrepareHandler method handlePUT.

@Override
protected HttpResponse handlePUT(HttpRequest request) {
    Tenant tenant = getExistingTenant(request);
    TenantName tenantName = tenant.getName();
    long sessionId = getSessionIdV2(request);
    PrepareParams prepareParams = PrepareParams.fromHttpRequest(request, tenantName, zookeeperBarrierTimeout);
    PrepareResult result = applicationRepository.prepare(tenant, sessionId, prepareParams, Instant.now());
    return new SessionPrepareResponse(result, tenantName, request);
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TenantName(com.yahoo.config.provision.TenantName) PrepareParams(com.yahoo.vespa.config.server.session.PrepareParams)

Example 7 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class SessionPrepareHandler method getExistingTenant.

private Tenant getExistingTenant(HttpRequest request) {
    TenantName tenantName = Utils.getTenantNameFromSessionRequest(request);
    Utils.checkThatTenantExists(tenants, tenantName);
    return tenants.getTenant(tenantName);
}
Also used : TenantName(com.yahoo.config.provision.TenantName)

Example 8 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class Tenants method createSystemTenants.

/**
 * Writes the tenants that should always be present into ZooKeeper. Will not fail if the node
 * already exists, as this is OK and might happen when several config servers start at the
 * same time and try to call this method.
 */
private synchronized void createSystemTenants(ConfigserverConfig configserverConfig) {
    List<TenantName> systemTenants = new ArrayList<>();
    systemTenants.add(DEFAULT_TENANT);
    if (configserverConfig.hostedVespa())
        systemTenants.add(HOSTED_VESPA_TENANT);
    for (final TenantName tenantName : systemTenants) {
        try {
            writeTenantPath(tenantName);
        } catch (RuntimeException e) {
            // Do nothing if we get NodeExistsException
            if (e.getCause().getClass() != KeeperException.NodeExistsException.class) {
                throw e;
            }
        }
    }
}
Also used : TenantName(com.yahoo.config.provision.TenantName) ArrayList(java.util.ArrayList)

Example 9 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class Tenants method checkForAddedTenants.

private void checkForAddedTenants(Set<TenantName> newTenants) {
    // TODO: Creating an executor here for every invocation does not seem optimal
    ExecutorService executor = Executors.newFixedThreadPool(globalComponentRegistry.getConfigserverConfig().numParallelTenantLoaders());
    for (TenantName tenantName : newTenants) {
        // Note: the http handler will check if the tenant exists, and throw accordingly
        executor.execute(() -> createTenant(tenantName));
    }
    executor.shutdown();
    try {
        // Timeout should never happen
        executor.awaitTermination(365, TimeUnit.DAYS);
    } catch (InterruptedException e) {
        throw new RuntimeException("Executor for creating tenants did not terminate within timeout");
    }
}
Also used : TenantName(com.yahoo.config.provision.TenantName) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService)

Example 10 with TenantName

use of com.yahoo.config.provision.TenantName in project vespa by vespa-engine.

the class SessionCreateHandler method handlePOST.

@Override
protected HttpResponse handlePOST(HttpRequest request) {
    Slime deployLog = createDeployLog();
    final TenantName tenantName = Utils.getTenantNameFromSessionRequest(request);
    Utils.checkThatTenantExists(tenants, tenantName);
    Tenant tenant = tenants.getTenant(tenantName);
    TimeoutBudget timeoutBudget = SessionHandler.getTimeoutBudget(request, zookeeperBarrierTimeout);
    DeployLogger logger = createLogger(request, deployLog, tenantName);
    long sessionId;
    if (request.hasProperty("from")) {
        ApplicationId applicationId = getFromApplicationId(request);
        sessionId = applicationRepository.createSessionFromExisting(tenant, logger, timeoutBudget, applicationId);
    } else {
        validateDataAndHeader(request);
        String name = getNameProperty(request, logger);
        sessionId = applicationRepository.createSession(tenant, timeoutBudget, request.getData(), request.getHeader(ApplicationApiHandler.contentTypeHeader), name);
    }
    return createResponse(request, tenantName, deployLog, sessionId);
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TenantName(com.yahoo.config.provision.TenantName) TimeoutBudget(com.yahoo.vespa.config.server.TimeoutBudget) DeployLogger(com.yahoo.config.application.api.DeployLogger) Slime(com.yahoo.slime.Slime) ApplicationId(com.yahoo.config.provision.ApplicationId)

Aggregations

TenantName (com.yahoo.config.provision.TenantName)48 Test (org.junit.Test)15 ApplicationId (com.yahoo.config.provision.ApplicationId)12 Map (java.util.Map)12 LinkedHashMap (java.util.LinkedHashMap)11 Tenant (com.yahoo.vespa.config.server.tenant.Tenant)9 LbServicesConfig (com.yahoo.cloud.config.LbServicesConfig)4 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)4 ApplicationName (com.yahoo.config.provision.ApplicationName)4 SuperModel (com.yahoo.config.model.api.SuperModel)3 Slime (com.yahoo.slime.Slime)3 TimeoutBudget (com.yahoo.vespa.config.server.TimeoutBudget)3 PrepareParams (com.yahoo.vespa.config.server.session.PrepareParams)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 DeployLogger (com.yahoo.config.application.api.DeployLogger)2 DeployState (com.yahoo.config.model.deploy.DeployState)2 Version (com.yahoo.config.provision.Version)2 Zone (com.yahoo.config.provision.Zone)2 ConfigKey (com.yahoo.vespa.config.ConfigKey)2