Search in sources :

Example 21 with TenantName

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

the class ApplicationApiHandler method getExistingTenant.

private Tenant getExistingTenant(HttpRequest request) {
    TenantName tenantName = Utils.getTenantNameFromSessionRequest(request);
    Utils.checkThatTenantExists(tenants, tenantName);
    return tenants.getTenant(tenantName);
}
Also used : TenantName(com.yahoo.config.provision.TenantName)

Example 22 with TenantName

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

the class ApplicationApiHandler 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.prepareAndActivate(tenant, sessionId, 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) PrepareParams(com.yahoo.vespa.config.server.session.PrepareParams)

Example 23 with TenantName

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

the class RemoteSessionRepoTest method testBadApplicationRepoOnActivate.

// If reading a session throws an exception it should be handled and not prevent other applications
// from loading. In this test we just show that we end up with one session in remote session
// repo even if it had bad data (by making getSessionIdForApplication() in FailingTenantApplications
// throw an exception).
@Test
public void testBadApplicationRepoOnActivate() throws Exception {
    long sessionId = 3L;
    TenantApplications applicationRepo = new FailingTenantApplications();
    TenantName mytenant = TenantName.from("mytenant");
    Tenant tenant = TenantBuilder.create(new TestComponentRegistry.Builder().curator(curator).build(), mytenant).withApplicationRepo(applicationRepo).build();
    curator.create(Tenants.getSessionsPath(mytenant));
    remoteSessionRepo = tenant.getRemoteSessionRepo();
    assertThat(remoteSessionRepo.listSessions().size(), is(0));
    createSession(sessionId, true, mytenant);
    assertThat(remoteSessionRepo.listSessions().size(), is(1));
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TenantName(com.yahoo.config.provision.TenantName) TestComponentRegistry(com.yahoo.vespa.config.server.TestComponentRegistry) TenantApplications(com.yahoo.vespa.config.server.application.TenantApplications) Test(org.junit.Test)

Example 24 with TenantName

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

the class TenantHandlerTest method testTenantCreateWithAllPossibleCharactersInName.

@Test
public void testTenantCreateWithAllPossibleCharactersInName() throws Exception {
    TenantName tenantName = TenantName.from("aB-9999_foo");
    assertNull(tenants.getTenant(tenantName));
    TenantCreateResponse response = putSync(HttpRequest.createTestRequest("http://deploy.example.yahoo.com:80/application/v2/tenant/" + tenantName, Method.PUT));
    assertResponseEquals(response, "{\"message\":\"Tenant " + tenantName + " created.\"}");
}
Also used : TenantName(com.yahoo.config.provision.TenantName) Test(org.junit.Test)

Example 25 with TenantName

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

the class RoutingProducerTest method createTestModel.

private Map<TenantName, Map<ApplicationId, ApplicationInfo>> createTestModel(DeployState.Builder deployStateBuilder) throws IOException, SAXException {
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> tMap = new LinkedHashMap<>();
    TenantName foo = TenantName.from("foo");
    TenantName bar = TenantName.from("bar");
    TenantName routing = TenantName.from(Tenants.HOSTED_VESPA_TENANT.value());
    tMap.put(foo, createTestApplications(foo, deployStateBuilder));
    tMap.put(bar, createTestApplications(bar, deployStateBuilder));
    tMap.put(routing, createTestApplications(routing, deployStateBuilder));
    return tMap;
}
Also used : TenantName(com.yahoo.config.provision.TenantName) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

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