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