public String toShortString() { return tenant().value() + "." + application().value() + ( instance().isDefault() ? "" : "." + instance().value() ); }
@Override public boolean equals(Object o) { if (this == o) return true; if ( ! (o instanceof RunId)) return false; RunId id = (RunId) o; if (number != id.number) return false; if ( ! application.equals(id.application)) return false; return type == id.type; }
/** Creates a new TesterId for a tester of the given application. */ public static TesterId of(ApplicationId id) { return new TesterId(ApplicationId.from(id.tenant().value(), id.application().value(), id.instance().value() + suffix)); }
/** * Returns the id of the deployed application, or the default value if not explicitly set (self-hosted). */ private static ApplicationName getDeployedApplicationId(DeployState deployState, AbstractConfigProducer ancestor) { return getContainerCluster(ancestor) .map(cluster -> deployState.getProperties().applicationId().application()) .orElse(ApplicationId.defaultId().application()); }
private static String toApp(ApplicationId applicationId) { return applicationId.application().value() + "." + applicationId.instance().value(); }
@Override public Map<ApplicationInstanceReference, ApplicationInstance> getAllApplicationInstances() { // Convert apps information to the response payload to return Map<ApplicationInstanceReference, ApplicationInstance> status = new HashMap<>(); for (Map.Entry<ApplicationId, MockDeployer.ApplicationContext> app : apps.entrySet()) { Set<ServiceInstance> serviceInstances = new HashSet<>(); for (Node node : nodeRepository.getNodes(app.getValue().id(), Node.State.active)) { serviceInstances.add(new ServiceInstance(new ConfigId("configid"), new HostName(node.hostname()), getHostStatus(node.hostname()))); } Set<ServiceCluster> serviceClusters = new HashSet<>(); serviceClusters.add(new ServiceCluster(new ClusterId(app.getValue().clusterContexts().get(0).cluster().id().value()), new ServiceType("serviceType"), serviceInstances)); TenantId tenantId = new TenantId(app.getKey().tenant().value()); ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId(app.getKey().application().value()); status.put(new ApplicationInstanceReference(tenantId, applicationInstanceId), new ApplicationInstance(tenantId, applicationInstanceId, serviceClusters)); } return status; }
public ApplicationId build() { if (application == null) { throw new IllegalArgumentException("must set application name in builder"); } return ApplicationId.from(tenant, application, instance); }
boolean wantToRetireNode = false; ClusterMembership membership = offered.allocation().get().membership(); if ( ! offered.allocation().get().owner().equals(application)) continue; // wrong application if ( ! membership.cluster().equalsIgnoringGroupAndVespaVersion(cluster)) continue; // wrong cluster id/type if ((! offeredPriority.isSurplusNode || saturated()) && ! membership.cluster().group().equals(cluster.group())) continue; // wrong group and we can't or have no reason to change it if ( offered.status().wantToRetire()) wantToRetireNode = true; if ( requestedNodes.isExclusive() && ! hostsOnly(application.tenant(), offered.parentHostname())) wantToRetireNode = true; continue; if ( ! exclusiveTo(application.tenant(), offered.parentHostname())) { ++rejectedDueToExclusivity; continue; if ( requestedNodes.isExclusive() && ! hostsOnly(application.tenant(), offered.parentHostname())) { ++rejectedDueToExclusivity; continue;
public Map<TenantName, Set<ApplicationInfo>> getModelsPerTenant() { Map<TenantName, Set<ApplicationInfo>> newModels = new LinkedHashMap<>(); this.models.forEach((key, value) -> { if (!newModels.containsKey(key.tenant())) { newModels.put(key.tenant(), new LinkedHashSet<>()); } newModels.get(key.tenant()).add(value); }); return newModels; }
"state", node.state().name(), "host", node.hostname(), "tenantName", applicationId.tenant().value(), "applicationId", applicationId.serializedForm().replace(':', '.'), "app", toApp(applicationId), "clustertype", allocation.get().membership().cluster().type().name(),
nodeRepository().getNode(node.hostname()) .filter(upToDateNode -> node.state() == Node.State.active) .filter(upToDateNode -> node.allocation().get().owner().equals(upToDateNode.allocation().get().owner()))) .flatMap(node -> node.map(Stream::of).orElseGet(Stream::empty)) .collect(Collectors.toSet()); deployment.activate(); } catch (Exception e) { log.log(LogLevel.INFO, "Failed to redeploy " + app.serializedForm() + ", will be redeployed later by application maintainer", e);
@Override public String toString() { return toShortString(); }
private ApplicationId toApplicationId(String applicationIdString) { try { return ApplicationId.fromSerializedForm(applicationIdString); } catch (IllegalArgumentException e) { throw new BadRequestException(e); } }
NodeSpec requestedNodes; if ( requestedCapacity.type() == NodeType.tenant) { int nodeCount = application.instance().isTester() ? 1 : capacityPolicies.decideSize(requestedCapacity, cluster.type());
private static String serializedForm(ApplicationId application, ClusterSpec.Id cluster) { return application.serializedForm() + ":" + cluster.value(); }
public static ApplicationId toApplicationId(String applicationIdString) { String[] parts = applicationIdString.split("\\."); if (parts.length != 3) throw new IllegalArgumentException("Application id must be on the form tenant.application.instance, got '" + applicationIdString + "'"); return ApplicationId.from(TenantName.from(parts[0]), ApplicationName.from(parts[1]), InstanceName.from(parts[2])); }
private boolean hostsOnly(TenantName tenant, Optional<String> parentHostname) { if ( ! parentHostname.isPresent()) return true; // yes, as host is exclusive for (Node nodeOnHost : nodeRepository.list().childrenOf(parentHostname.get())) { if ( ! nodeOnHost.allocation().isPresent()) continue; if ( ! nodeOnHost.allocation().get().owner().tenant().equals(tenant)) return false; } return true; }
/** * Deploy in the maintenance thread to avoid scheduling multiple deployments of the same application if it takes * longer to deploy than the (short) maintenance interval of this */ @Override protected void deploy(ApplicationId application) { deployWithLock(application); log.info("Redeployed application " + application.toShortString() + " as a manual change was made to its nodes"); }
/** Create an instance from a serialized value on the form tenant:application:instance:cluster-id */ public static LoadBalancerId fromSerializedForm(String value) { int lastSeparator = value.lastIndexOf(":"); ApplicationId application = ApplicationId.fromSerializedForm(value.substring(0, lastSeparator)); ClusterSpec.Id cluster = ClusterSpec.Id.from(value.substring(lastSeparator + 1)); return new LoadBalancerId(application, cluster); }
@GET @Produces(MediaType.APPLICATION_JSON) public ApplicationReferenceList getAllInstances() { List<ApplicationId> applications = new ArrayList<>(healthMonitorApi.getMonitoredApplicationIds()); applications.sort(Comparator.comparing(ApplicationId::serializedForm)); ApplicationReferenceList list = new ApplicationReferenceList(); list.applicationList = applications.stream().map(applicationId -> { UrlReference reference = new UrlReference(); reference.url = uriInfo.getBaseUriBuilder() .path(HealthResource.class) .path(applicationId.serializedForm()) .build() .toString(); return reference; }).collect(Collectors.toList()); return list; }