Search in sources :

Example 96 with ApplicationId

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);
}
Also used : ApplicationMetaData(com.yahoo.config.application.api.ApplicationMetaData) Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TenantName(com.yahoo.config.provision.TenantName) TimeoutBudget(com.yahoo.vespa.config.server.TimeoutBudget) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 97 with ApplicationId

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);
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TenantName(com.yahoo.config.provision.TenantName) InternalServerException(com.yahoo.vespa.config.server.http.InternalServerException) BadRequestException(com.yahoo.vespa.config.server.http.BadRequestException) TenantApplications(com.yahoo.vespa.config.server.application.TenantApplications) ApplicationId(com.yahoo.config.provision.ApplicationId) BadRequestException(com.yahoo.vespa.config.server.http.BadRequestException) InternalServerException(com.yahoo.vespa.config.server.http.InternalServerException)

Example 98 with ApplicationId

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());
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) RequestHandler(com.yahoo.vespa.config.server.RequestHandler) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 99 with ApplicationId

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());
}
Also used : ApplicationId(com.yahoo.config.provision.ApplicationId) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) Test(org.junit.Test)

Example 100 with ApplicationId

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);
}
Also used : ApplicationId(com.yahoo.config.provision.ApplicationId) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) Test(org.junit.Test)

Aggregations

ApplicationId (com.yahoo.config.provision.ApplicationId)173 Test (org.junit.Test)102 Zone (com.yahoo.config.provision.Zone)52 Node (com.yahoo.vespa.hosted.provision.Node)30 ClusterSpec (com.yahoo.config.provision.ClusterSpec)22 TenantName (com.yahoo.config.provision.TenantName)20 Flavor (com.yahoo.config.provision.Flavor)19 List (java.util.List)16 HashSet (java.util.HashSet)15 HostSpec (com.yahoo.config.provision.HostSpec)12 Duration (java.time.Duration)12 HashMap (java.util.HashMap)12 Map (java.util.Map)12 Set (java.util.Set)12 Collectors (java.util.stream.Collectors)12 Version (com.yahoo.component.Version)11 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)11 Slime (com.yahoo.slime.Slime)11 ArrayList (java.util.ArrayList)11 Optional (java.util.Optional)11