@JsonValue @Override public String toString() { return clusterId.s() + ":" + serviceType.s(); }
/** * @return true iff the service cluster is a content service cluster. */ public static boolean isContent(ServiceCluster cluster) { return DISTRIBUTOR_SERVICE_TYPE.equals(cluster.serviceType()) || SEARCHNODE_SERVICE_TYPE.equals(cluster.serviceType()) || STORAGENODE_SERVICE_TYPE.equals(cluster.serviceType()); }
@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); }
@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; }
@GET @Path("/{applicationId}") @Produces(MediaType.APPLICATION_JSON) public ApplicationServices getInstance(@PathParam("applicationId") String applicationIdString) { ApplicationId applicationId = ApplicationId.fromSerializedForm(applicationIdString); Map<ServiceId, ServiceStatusInfo> services = healthMonitorApi.getServices(applicationId); List<ServiceResource> serviceResources = services.entrySet().stream().map(entry -> { ServiceResource serviceResource = new ServiceResource(); serviceResource.clusterId = entry.getKey().getClusterId(); serviceResource.serviceType = entry.getKey().getServiceType(); serviceResource.configId = entry.getKey().getConfigId(); serviceResource.serviceStatusInfo = entry.getValue(); return serviceResource; }) .sorted(Comparator.comparing(resource -> resource.serviceType.s())) .collect(Collectors.toList()); ApplicationServices applicationServices = new ApplicationServices(); applicationServices.services = serviceResources; return applicationServices; }
/** * Note that a search node service cluster (service type searchnode aka proton) is * always accompanied by a storage node service cluster, but not vice versa. * * @return true iff the service cluster consists of storage nodes (proton or vds). */ public static boolean isStorage(ServiceCluster cluster) { return STORAGENODE_SERVICE_TYPE.equals(cluster.serviceType()); }
@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); } }
public static boolean isClusterController(ServiceCluster cluster) { return CLUSTER_CONTROLLER_SERVICE_TYPE.equals(cluster.serviceType()); }
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; }
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; } }