@Override public ClusterId clusterId() { return serviceCluster.clusterId(); }
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()); }
/** * @return The set of all Cluster Controller service instances for the application. */ public static List<HostName> getClusterControllerInstancesInOrder(ApplicationInstance application, ClusterId contentClusterId) { Set<ServiceCluster> controllerClusters = getClusterControllerServiceClusters(application); Collection<ServiceCluster> controllerClustersForContentCluster = filter(controllerClusters, contentClusterId); Set<ServiceInstance> clusterControllerInstances; if (controllerClustersForContentCluster.size() == 1) { clusterControllerInstances = first(controllerClustersForContentCluster).serviceInstances(); } else if (controllerClusters.size() == 1) { ServiceCluster cluster = first(controllerClusters); log.warning("No cluster controller cluster for content cluster " + contentClusterId + ", using the only cluster controller cluster available: " + cluster.clusterId()); clusterControllerInstances = cluster.serviceInstances(); } else { throw new RuntimeException("Failed getting cluster controller for content cluster " + contentClusterId + ". Available clusters = " + controllerClusters + ", matching clusters = " + controllerClustersForContentCluster); } return clusterControllerInstances.stream() .sorted(CLUSTER_CONTROLLER_INDEX_COMPARATOR) .map(serviceInstance -> serviceInstance.hostName()) .collect(Collectors.toList()); }
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; }
@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); } }