Search in sources :

Example 1 with TenantName

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

the class ApplicationApiHandler method handlePOST.

@Override
protected HttpResponse handlePOST(HttpRequest request) {
    Tenant tenant = getExistingTenant(request);
    TenantName tenantName = tenant.getName();
    TimeoutBudget timeoutBudget = SessionHandler.getTimeoutBudget(request, zookeeperBarrierTimeout);
    PrepareParams prepareParams = PrepareParams.fromHttpRequest(request, tenantName, zookeeperBarrierTimeout);
    Slime deployLog = createDeployLog();
    DeployLogger logger = SessionCreateHandler.createLogger(request, deployLog, tenantName);
    String name = SessionCreateHandler.getNameProperty(request, logger);
    SessionCreateHandler.validateDataAndHeader(request);
    PrepareResult result = applicationRepository.createSessionAndPrepareAndActivate(tenant, request.getData(), request.getHeader(contentTypeHeader), timeoutBudget, name, prepareParams, shouldIgnoreLockFailure(request), shouldIgnoreSessionStaleFailure(request), Instant.now());
    return new SessionPrepareAndActivateResponse(result, tenantName, request, prepareParams.getApplicationId(), zone);
}
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) PrepareParams(com.yahoo.vespa.config.server.session.PrepareParams)

Example 2 with TenantName

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

the class RpcServer method resolveTenant.

/**
 * Returns the tenant for this request, empty if there is no tenant for this request
 * (which on hosted Vespa means that the requesting host is not currently active for any tenant)
 */
public Optional<TenantName> resolveTenant(JRTServerConfigRequest request, Trace trace) {
    if ("*".equals(request.getConfigKey().getConfigId()))
        return Optional.of(ApplicationId.global().tenant());
    String hostname = request.getClientHostName();
    TenantName tenant = hostRegistry.getKeyForHost(hostname);
    if (tenant == null) {
        if (GetConfigProcessor.logDebug(trace)) {
            String message = "Did not find tenant for host '" + hostname + "', using " + TenantName.defaultName();
            log.log(LogLevel.DEBUG, message);
            log.log(LogLevel.DEBUG, "hosts in host registry: " + hostRegistry.getAllHosts());
            trace.trace(6, message);
        }
        return Optional.empty();
    }
    return Optional.of(tenant);
}
Also used : TenantName(com.yahoo.config.provision.TenantName)

Example 3 with TenantName

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

the class TenantHandler method getAndValidateTenantFromRequest.

/**
 * Gets the tenant name from the request, throws if it exists already and validates its name
 *
 * @param request an {@link com.yahoo.container.jdisc.HttpRequest}
 * @return tenant name
 */
private TenantName getAndValidateTenantFromRequest(HttpRequest request) {
    final TenantName tenantName = getTenantNameFromRequest(request);
    checkThatTenantDoesNotExist(tenantName);
    validateTenantName(tenantName);
    return tenantName;
}
Also used : TenantName(com.yahoo.config.provision.TenantName)

Example 4 with TenantName

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

the class SuperModelConfigProvider method getConfig.

public <CONFIGTYPE extends ConfigInstance> CONFIGTYPE getConfig(Class<CONFIGTYPE> configClass, ApplicationId applicationId, String configId) {
    TenantName tenant = applicationId.tenant();
    if (!superModel.getAllModels().containsKey(tenant)) {
        throw new IllegalArgumentException("Tenant " + tenant + " not found");
    }
    Map<ApplicationId, ApplicationInfo> applications = superModel.getAllModels().get(tenant);
    if (!applications.containsKey(applicationId)) {
        throw new IllegalArgumentException("Application id " + applicationId + " not found");
    }
    ApplicationInfo application = applications.get(applicationId);
    ConfigKey<CONFIGTYPE> key = new ConfigKey<>(configClass, configId);
    ConfigPayload payload = application.getModel().getConfig(key, null);
    return payload.toInstance(configClass, configId);
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) TenantName(com.yahoo.config.provision.TenantName) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 5 with TenantName

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

the class ApplicationHandler method createFromRequestSimpleAppId.

// The URL pattern with only tenant and application given
private static ApplicationId createFromRequestSimpleAppId(BindingMatch<?> bm) {
    TenantName tenant = TenantName.from(bm.group(2));
    ApplicationName application = ApplicationName.from(bm.group(3));
    return new ApplicationId.Builder().tenant(tenant).applicationName(application).build();
}
Also used : ApplicationName(com.yahoo.config.provision.ApplicationName) TenantName(com.yahoo.config.provision.TenantName) 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