Search in sources :

Example 46 with ApplicationId

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

the class JobQueueSerializer method fromJson.

public Deque<ApplicationId> fromJson(byte[] data) {
    Inspector inspector = SlimeUtils.jsonToSlime(data).get();
    Deque<ApplicationId> queue = new ArrayDeque<>();
    inspector.traverse((ArrayTraverser) (index, value) -> queue.addLast(ApplicationId.fromSerializedForm(value.asString())));
    return queue;
}
Also used : HashSet(java.util.HashSet) Cursor(com.yahoo.slime.Cursor) List(java.util.List) Inspector(com.yahoo.slime.Inspector) ApplicationId(com.yahoo.config.provision.ApplicationId) SlimeUtils(com.yahoo.vespa.config.SlimeUtils) ArrayTraverser(com.yahoo.slime.ArrayTraverser) Slime(com.yahoo.slime.Slime) Set(java.util.Set) IOException(java.io.IOException) ArrayDeque(java.util.ArrayDeque) Deque(java.util.Deque) Inspector(com.yahoo.slime.Inspector) ApplicationId(com.yahoo.config.provision.ApplicationId) ArrayDeque(java.util.ArrayDeque)

Example 47 with ApplicationId

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

the class JobQueueSerializer method toJson.

public byte[] toJson(Iterable<ApplicationId> queue) {
    try {
        Slime slime = new Slime();
        Cursor array = slime.setArray();
        queue.forEach((id -> array.addString(id.serializedForm())));
        return SlimeUtils.toJsonBytes(slime);
    } catch (IOException e) {
        throw new RuntimeException("Serialization of a job queue failed", e);
    }
}
Also used : HashSet(java.util.HashSet) Cursor(com.yahoo.slime.Cursor) List(java.util.List) Inspector(com.yahoo.slime.Inspector) ApplicationId(com.yahoo.config.provision.ApplicationId) SlimeUtils(com.yahoo.vespa.config.SlimeUtils) ArrayTraverser(com.yahoo.slime.ArrayTraverser) Slime(com.yahoo.slime.Slime) Set(java.util.Set) IOException(java.io.IOException) ArrayDeque(java.util.ArrayDeque) Deque(java.util.Deque) IOException(java.io.IOException) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Example 48 with ApplicationId

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

the class ApplicationController method deleteApplication.

/**
 * Deletes the the given application. All known instances of the applications will be deleted,
 * including PR instances.
 *
 * @throws IllegalArgumentException if the application has deployments or the caller is not authorized
 * @throws NotExistsException if no instances of the application exist
 */
public void deleteApplication(ApplicationId applicationId, Optional<NToken> token) {
    // Find all instances of the application
    List<ApplicationId> instances = controller.applications().asList(applicationId.tenant()).stream().map(Application::id).filter(id -> id.application().equals(applicationId.application()) && id.tenant().equals(applicationId.tenant())).collect(Collectors.toList());
    if (instances.isEmpty()) {
        throw new NotExistsException("Could not delete application '" + applicationId + "': Application not found");
    }
    // TODO: Make this one transaction when database is moved to ZooKeeper
    instances.forEach(id -> lockOrThrow(id, application -> {
        if (!application.deployments().isEmpty())
            throw new IllegalArgumentException("Could not delete '" + application + "': It has active deployments");
        Tenant tenant = controller.tenants().tenant(new TenantId(id.tenant().value())).get();
        if (tenant.isAthensTenant() && !token.isPresent())
            throw new IllegalArgumentException("Could not delete '" + application + "': No NToken provided");
        // Only delete in Athenz once
        if (id.instance().isDefault() && tenant.isAthensTenant()) {
            zmsClientFactory.createZmsClientWithAuthorizedServiceToken(token.get()).deleteApplication(tenant.getAthensDomain().get(), new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId(id.application().value()));
        }
        db.deleteApplication(id);
        log.info("Deleted " + application);
    }));
}
Also used : ArtifactRepository(com.yahoo.vespa.hosted.controller.api.integration.deployment.ArtifactRepository) ZmsClient(com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsClient) EndpointStatus(com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus) DeploymentTrigger(com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger) URISyntaxException(java.net.URISyntaxException) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) ValidationId(com.yahoo.config.application.api.ValidationId) JobReport(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobReport) TenantName(com.yahoo.config.provision.TenantName) Tenant(com.yahoo.vespa.hosted.controller.api.Tenant) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) DeploymentExpirer(com.yahoo.vespa.hosted.controller.maintenance.DeploymentExpirer) RevisionId(com.yahoo.vespa.hosted.controller.api.identifiers.RevisionId) Duration(java.time.Duration) Map(java.util.Map) DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) URI(java.net.URI) Rotation(com.yahoo.vespa.hosted.controller.rotation.Rotation) Exceptions(com.yahoo.yolean.Exceptions) RotationRepository(com.yahoo.vespa.hosted.controller.rotation.RotationRepository) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) Set(java.util.Set) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) List(java.util.List) Optional(java.util.Optional) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) RotationsConfig(com.yahoo.vespa.hosted.rotation.config.RotationsConfig) Log(com.yahoo.vespa.hosted.controller.api.integration.configserver.Log) AthenzClientFactory(com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactory) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) RecordId(com.yahoo.vespa.hosted.controller.api.integration.dns.RecordId) ConfigServerClient(com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerClient) HashMap(java.util.HashMap) NToken(com.yahoo.vespa.athenz.api.NToken) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) HashSet(java.util.HashSet) ConfigChangeActions(com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions) ImmutableList(com.google.common.collect.ImmutableList) TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) RecordData(com.yahoo.vespa.hosted.controller.api.integration.dns.RecordData) RoutingEndpoint(com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingEndpoint) RoutingGenerator(com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator) ActivateResult(com.yahoo.vespa.hosted.controller.api.ActivateResult) NoInstanceException(com.yahoo.vespa.hosted.controller.api.integration.configserver.NoInstanceException) Lock(com.yahoo.vespa.curator.Lock) Hostname(com.yahoo.vespa.hosted.controller.api.identifiers.Hostname) Environment(com.yahoo.config.provision.Environment) ControllerDb(com.yahoo.vespa.hosted.controller.persistence.ControllerDb) CuratorDb(com.yahoo.vespa.hosted.controller.persistence.CuratorDb) IOException(java.io.IOException) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Consumer(java.util.function.Consumer) Pair(com.yahoo.collections.Pair) DeploymentSpec(com.yahoo.config.application.api.DeploymentSpec) RecordName(com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName) Clock(java.time.Clock) NameService(com.yahoo.vespa.hosted.controller.api.integration.dns.NameService) PrepareResponse(com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse) Collections(java.util.Collections) Record(com.yahoo.vespa.hosted.controller.api.integration.dns.Record) RotationLock(com.yahoo.vespa.hosted.controller.rotation.RotationLock) TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Tenant(com.yahoo.vespa.hosted.controller.api.Tenant) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 49 with ApplicationId

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

the class AclProvisioningTest method trusted_nodes_for_docker_hosts_nodes_in_zone_application.

@Test
public void trusted_nodes_for_docker_hosts_nodes_in_zone_application() {
    // use same id for both allocate calls below
    ApplicationId applicationId = tester.makeApplicationId();
    List<Node> configServers = setConfigServers("cfg1:1234,cfg2:1234,cfg3:1234");
    // Populate repo
    tester.makeReadyNodes(2, "default", NodeType.host);
    // Allocate 2 Docker hosts
    List<Node> activeDockerHostNodes = allocateNodes(NodeType.host, applicationId);
    assertEquals(2, activeDockerHostNodes.size());
    // Check trusted nodes for all nodes
    activeDockerHostNodes.forEach(node -> {
        System.out.println("Checking node " + node);
        List<NodeAcl> nodeAcls = tester.nodeRepository().getNodeAcls(node, false);
        assertAcls(Arrays.asList(activeDockerHostNodes, configServers), dockerBridgeNetwork, nodeAcls);
    });
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) NodeAcl(com.yahoo.vespa.hosted.provision.node.NodeAcl) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 50 with ApplicationId

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

the class AclProvisioningTest method trusted_nodes_for_proxy.

@Test
public void trusted_nodes_for_proxy() {
    List<Node> configServers = setConfigServers("cfg1:1234,cfg2:1234,cfg3:1234");
    // Populate repo
    tester.makeReadyNodes(10, "default");
    tester.makeReadyNodes(3, "default", NodeType.proxy);
    // Deploy zone application
    ApplicationId zoneApplication = tester.makeApplicationId();
    allocateNodes(Capacity.fromRequiredNodeType(NodeType.proxy), zoneApplication);
    // Get trusted nodes for first proxy node
    List<Node> proxyNodes = tester.nodeRepository().getNodes(zoneApplication);
    Node node = proxyNodes.get(0);
    List<NodeAcl> nodeAcls = tester.nodeRepository().getNodeAcls(node, false);
    // Trusted nodes is all config servers and all proxy nodes
    assertAcls(Arrays.asList(proxyNodes, configServers), nodeAcls);
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) NodeAcl(com.yahoo.vespa.hosted.provision.node.NodeAcl) ApplicationId(com.yahoo.config.provision.ApplicationId) 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