private static Collection<ServiceCluster> filter(Set<ServiceCluster> controllerClusters, ClusterId contentClusterId) { ClusterId clusterControllerClusterId = new ClusterId(contentClusterId.s() + "-controllers"); return controllerClusters.stream(). filter(cluster -> cluster.clusterId().equals(clusterControllerClusterId)). collect(Collectors.toList()); }
@JsonValue @Override public String toString() { return clusterId.s() + ":" + serviceType.s(); }
@GET @Path("/{instanceId}/serviceStatusInfo") @Produces(MediaType.APPLICATION_JSON) public ServiceStatusInfo getServiceStatus( @PathParam("instanceId") String instanceId, @QueryParam("clusterId") String clusterIdString, @QueryParam("serviceType") String serviceTypeString, @QueryParam("configId") String configIdString) { ApplicationInstanceReference reference = parseInstanceId(instanceId); ApplicationId applicationId = OrchestratorUtil.toApplicationId(reference); if (clusterIdString == null) { throwBadRequest("Missing clusterId query parameter"); } if (serviceTypeString == null) { throwBadRequest("Missing serviceType query parameter"); } if (configIdString == null) { throwBadRequest("Missing configId query parameter"); } ClusterId clusterId = new ClusterId(clusterIdString); ServiceType serviceType = new ServiceType(serviceTypeString); ConfigId configId = new ConfigId(configIdString); return rootManager.getStatus(applicationId, clusterId, serviceType, configId); }
public static int getSuspendPercentageAllowed(ServiceCluster serviceCluster) { if (VespaModelUtil.ADMIN_CLUSTER_ID.equals(serviceCluster.clusterId())) { if (VespaModelUtil.SLOBROK_SERVICE_TYPE.equals(serviceCluster.serviceType())) { return SUSPENSION_ALLOW_MINIMAL; } return SUSPENSION_ALLOW_ALL; } if (VespaModelUtil.isStorage(serviceCluster)) { return SUSPENSION_ALLOW_MINIMAL; } return SUSPENSION_ALLOW_TEN_PERCENT; }
ClusterControllerClient client = clusterControllerClientFactory.createClient( clusterControllers, clusterId.s()); try { ClusterControllerStateResponse response = client.setApplicationState(context, state); throw new ApplicationStateChangeDeniedException( "Timed out while waiting for cluster controllers " + clusterControllers + " with cluster ID " + clusterId.s() + ": " + e.getMessage());
@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; }
ConcurrentSuspensionLimitForCluster getConcurrentSuspensionLimit(ClusterApi clusterApi) { if (clusterApi.isStorageCluster()) { return ConcurrentSuspensionLimitForCluster.ONE_NODE; } if (VespaModelUtil.ADMIN_CLUSTER_ID.equals(clusterApi.clusterId())) { if (VespaModelUtil.SLOBROK_SERVICE_TYPE.equals(clusterApi.serviceType())) { return ConcurrentSuspensionLimitForCluster.ONE_NODE; } return ConcurrentSuspensionLimitForCluster.ALL_NODES; } if (clusterApi.getApplication().applicationId().equals(VespaModelUtil.ZONE_APPLICATION_ID) && clusterApi.clusterId().equals(VespaModelUtil.NODE_ADMIN_CLUSTER_ID)) { return ConcurrentSuspensionLimitForCluster.TWENTY_PERCENT; } return ConcurrentSuspensionLimitForCluster.TEN_PERCENT; } }
@Override public GetHostResponse getHost(String hostNameString) { HostName hostName = new HostName(hostNameString); try { Host host = orchestrator.getHost(hostName); URI applicationUri = uriInfo.getBaseUriBuilder() .path(InstanceResource.class) .path(host.getApplicationInstanceReference().asString()) .build(); List<HostService> hostServices = host.getServiceInstances().stream() .map(serviceInstance -> new HostService( serviceInstance.getServiceCluster().clusterId().s(), serviceInstance.getServiceCluster().serviceType().s(), serviceInstance.configId().s(), serviceInstance.serviceStatus().name())) .collect(Collectors.toList()); return new GetHostResponse( host.getHostName().s(), host.getHostStatus().name(), applicationUri.toString(), hostServices); } catch (UncheckedTimeoutException e) { log.log(LogLevel.INFO, "Failed to get host " + hostName + ": " + e.getMessage()); throw webExceptionFromTimeout("getHost", hostName, e); } catch (HostNameNotFoundException e) { log.log(LogLevel.INFO, "Host not found: " + hostName); throw new NotFoundException(e); } }
throws HostStateChangeDeniedException { String clusterId = this.clusterId.s();