Search in sources :

Example 86 with ApplicationId

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]"));
    }
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) BadRequestException(com.yahoo.vespa.config.server.http.BadRequestException) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 87 with ApplicationId

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;
}
Also used : ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ApplicationId(com.yahoo.config.provision.ApplicationId) LinkedHashMap(java.util.LinkedHashMap)

Example 88 with ApplicationId

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;
}
Also used : ProviderUniqueId(com.yahoo.vespa.hosted.athenz.instanceproviderservice.identitydocument.ProviderUniqueId) SignedIdentityDocument(com.yahoo.vespa.hosted.athenz.instanceproviderservice.identitydocument.SignedIdentityDocument) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 89 with ApplicationId

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

Example 90 with ApplicationId

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

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