use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class TenantHandlerTest method testDeleteTenantWithActiveApplications.
@Test
public void testDeleteTenantWithActiveApplications() throws Exception {
putSync(HttpRequest.createTestRequest("http://deploy.example.yahoo.com:80/application/v2/tenant/" + a, Method.PUT));
Tenant tenant = tenants.getTenant(a);
assertEquals(a, tenant.getName());
int sessionId = 1;
ApplicationId app = ApplicationId.from(a, ApplicationName.from("foo"), InstanceName.defaultName());
ApplicationHandlerTest.addMockApplication(tenant, app, sessionId, Clock.systemUTC());
try {
handler.handleDELETE(HttpRequest.createTestRequest("http://deploy.example.yahoo.com:80/application/v2/tenant/" + a, Method.DELETE));
fail();
} catch (BadRequestException e) {
assertThat(e.getMessage(), is("Cannot delete tenant 'a', as it has active applications: [a.foo]"));
}
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class RoutingProducerTest method createTestApplications.
private Map<ApplicationId, ApplicationInfo> createTestApplications(TenantName tenant, DeployState.Builder deploystateBuilder) throws IOException, SAXException {
Map<ApplicationId, ApplicationInfo> aMap = new LinkedHashMap<>();
ApplicationId fooApp = new ApplicationId.Builder().tenant(tenant).applicationName("foo").build();
ApplicationId barApp = new ApplicationId.Builder().tenant(tenant).applicationName("bar").build();
ApplicationId routingApp = new ApplicationId.Builder().tenant(tenant).applicationName(RoutingProducer.ROUTING_APPLICATION.value()).build();
aMap.put(fooApp, createApplication(fooApp, deploystateBuilder));
aMap.put(barApp, createApplication(barApp, deploystateBuilder));
aMap.put(routingApp, createApplication(routingApp, deploystateBuilder));
return aMap;
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class InstanceValidator method isValidInstance.
public boolean isValidInstance(InstanceConfirmation instanceConfirmation) {
SignedIdentityDocument signedIdentityDocument = instanceConfirmation.signedIdentityDocument;
ProviderUniqueId providerUniqueId = signedIdentityDocument.identityDocument.providerUniqueId;
ApplicationId applicationId = ApplicationId.from(providerUniqueId.tenant, providerUniqueId.application, providerUniqueId.instance);
if (!isSameIdentityAsInServicesXml(applicationId, instanceConfirmation.domain, instanceConfirmation.service)) {
return false;
}
log.log(LogLevel.INFO, () -> String.format("Validating instance %s.", providerUniqueId));
if (isInstanceSignatureValid(instanceConfirmation)) {
log.log(LogLevel.INFO, () -> String.format("Instance %s is valid.", providerUniqueId));
return true;
}
log.log(LogLevel.ERROR, () -> String.format("Instance %s has invalid signature.", providerUniqueId));
return false;
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class DeployStateTest method testProperties.
@Test
public void testProperties() {
DeployState.Builder builder = new DeployState.Builder();
DeployState state = builder.build(true);
assertThat(state.getProperties().applicationId(), is(ApplicationId.defaultId()));
ApplicationId customId = new ApplicationId.Builder().tenant("bar").applicationName("foo").instanceName("quux").build();
DeployProperties properties = new DeployProperties.Builder().applicationId(customId).build();
builder.properties(properties);
state = builder.build(true);
assertThat(state.getProperties().applicationId(), is(customId));
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class HostHandler method handleGET.
@Override
public HttpResponse handleGET(HttpRequest request) {
String hostname = getBindingMatch(request).group(2);
log.log(LogLevel.DEBUG, "hostname=" + hostname);
HostRegistry<TenantName> tenantHostRegistry = hostRegistries.getTenantHostRegistry();
log.log(LogLevel.DEBUG, "hosts in tenant host registry '" + tenantHostRegistry + "' " + tenantHostRegistry.getAllHosts());
TenantName tenant = tenantHostRegistry.getKeyForHost(hostname);
if (tenant == null)
return createError(hostname);
log.log(LogLevel.DEBUG, "tenant=" + tenant);
HostRegistry<ApplicationId> applicationIdHostRegistry = hostRegistries.getApplicationHostRegistry(tenant);
ApplicationId applicationId;
if (applicationIdHostRegistry == null)
return createError(hostname);
applicationId = applicationIdHostRegistry.getKeyForHost(hostname);
log.log(LogLevel.DEBUG, "applicationId=" + applicationId);
if (applicationId == null) {
return createError(hostname);
} else {
log.log(LogLevel.DEBUG, "hosts in application host registry '" + applicationIdHostRegistry + "' " + applicationIdHostRegistry.getAllHosts());
return new HostResponse(Response.Status.OK, applicationId, zone);
}
}
Aggregations