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