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