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);
}
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);
}
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;
}
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);
}
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();
}
Aggregations