use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class SessionActiveHandler method handlePUT.
@Override
protected HttpResponse handlePUT(HttpRequest request) {
final TenantName tenantName = Utils.getTenantNameFromSessionRequest(request);
Utils.checkThatTenantExists(tenants, tenantName);
Tenant tenant = tenants.getTenant(tenantName);
TimeoutBudget timeoutBudget = getTimeoutBudget(request, DEFAULT_ACTIVATE_TIMEOUT);
final Long sessionId = getSessionIdV2(request);
ApplicationId applicationId = applicationRepository.activate(tenant, sessionId, timeoutBudget, shouldIgnoreLockFailure(request), shouldIgnoreSessionStaleFailure(request));
ApplicationMetaData metaData = applicationRepository.getMetadataFromSession(tenant, sessionId);
return new SessionActiveResponse(metaData.getSlime(), request, applicationId, sessionId, zone);
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class TenantHandler method handleDELETE.
@Override
protected HttpResponse handleDELETE(HttpRequest request) {
final TenantName tenantName = getTenantNameFromRequest(request);
Utils.checkThatTenantExists(tenants, tenantName);
// TODO: Move logic to ApplicationRepository
Tenant tenant = tenants.getTenant(tenantName);
TenantApplications applicationRepo = tenant.getApplicationRepo();
final List<ApplicationId> activeApplications = applicationRepo.listApplications();
if (activeApplications.isEmpty()) {
try {
tenants.deleteTenant(tenantName);
} catch (IllegalArgumentException e) {
throw e;
} catch (Exception e) {
throw new InternalServerException(Exceptions.toMessageString(e));
}
} else {
throw new BadRequestException("Cannot delete tenant '" + tenantName + "', as it has active applications: " + activeApplications);
}
return new TenantDeleteResponse(tenantName);
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class HttpListNamedConfigsHandler method handleGET.
@Override
public HttpResponse handleGET(HttpRequest req) {
HttpListConfigsRequest listReq = HttpListConfigsRequest.createFromNamedListRequest(req);
RequestHandler requestHandler = HttpConfigRequests.getRequestHandler(tenants, listReq);
ApplicationId appId = listReq.getApplicationId();
HttpConfigRequest.validateRequestKey(listReq.getKey(), requestHandler, appId);
Set<ConfigKey<?>> configs = requestHandler.listNamedConfigs(appId, Optional.empty(), listReq.getKey(), listReq.isRecursive());
String urlBase = HttpListConfigsHandler.getUrlBase(req, listReq, appId, zone);
Set<ConfigKey<?>> allConfigs = requestHandler.allConfigsProduced(appId, Optional.empty());
return new HttpListConfigsHandler.ListConfigsResponse(configs, allConfigs, urlBase, listReq.isRecursive());
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class ApplicationHandlerTest method testConverge.
@Test
public void testConverge() throws Exception {
long sessionId = 1;
ApplicationId application = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(mytenantName).build();
addMockApplication(tenants.getTenant(mytenantName), application, sessionId, Clock.systemUTC());
converge(application, Zone.defaultZone());
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class ApplicationHandlerTest method testRestart.
@Test
public void testRestart() throws Exception {
long sessionId = 1;
ApplicationId application = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(mytenantName).build();
addMockApplication(tenants.getTenant(mytenantName), application, sessionId, Clock.systemUTC());
assertFalse(provisioner.restarted);
restart(application, Zone.defaultZone());
assertTrue(provisioner.restarted);
assertEquals(application, provisioner.lastApplicationId);
}
Aggregations