/** * @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()); }
@Override public String toString() { return "NodeGroup{" + "application=" + application.reference() + ", hostNames=" + hostNames + '}'; }
@Override public HostName hostName() { return storageService.hostName(); }
private static boolean applicationInstanceUsesHost(ApplicationInstance applicationInstance, HostName hostName) { return applicationInstance.serviceClusters().stream() .anyMatch(serviceCluster -> serviceCluster.serviceInstances().stream() .anyMatch(serviceInstance -> serviceInstance.hostName().equals(hostName))); }
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; }
public static Stream<ServiceInstance> serviceInstancesOnHost(ServiceCluster serviceCluster, HostName hostName) { return serviceCluster.serviceInstances().stream() .filter(instance -> instance.hostName().equals(hostName)); }
private static Set<ServiceCluster> getServiceClustersInGroup(NodeGroup nodeGroup) { ApplicationInstance applicationInstance = nodeGroup.getApplication(); Set<ServiceCluster> serviceClustersInGroup = new HashSet<>(); for (ServiceCluster cluster : applicationInstance.serviceClusters()) { for (ServiceInstance instance : cluster.serviceInstances()) { if (nodeGroup.contains(instance.hostName())) { serviceClustersInGroup.add(cluster); break; } } } return serviceClustersInGroup; }
private static String applicationInstancePath(ApplicationInstanceReference applicationInstanceReference) { return HOST_STATUS_BASE_PATH + '/' + applicationInstanceReference.tenantId() + ":" + applicationInstanceReference.applicationInstanceId(); }
@Override public int compareTo(StorageNode otherStorageNode) { if (!(otherStorageNode instanceof StorageNodeImpl)) { throw new IllegalArgumentException("Unable to compare our class to any StorageNode object"); } StorageNodeImpl that = (StorageNodeImpl) otherStorageNode; // We're guaranteed there's only one storage service per node. return this.storageService.hostName().compareTo(that.storageService.hostName()); } }
@Override public ServiceType serviceType() { return serviceCluster.serviceType(); }
@Override public ClusterId clusterId() { return serviceCluster.clusterId(); }
public ServiceInstance(ConfigId configId, HostName hostName, ServiceStatus serviceStatus) { this(configId, hostName, new ServiceStatusInfo(serviceStatus)); }
@Override public Host getHost(HostName hostName) throws HostNameNotFoundException { ApplicationInstance applicationInstance = getApplicationInstance(hostName); List<ServiceInstance> serviceInstances = applicationInstance .serviceClusters().stream() .flatMap(cluster -> cluster.serviceInstances().stream()) .filter(serviceInstance -> hostName.equals(serviceInstance.hostName())) .collect(Collectors.toList()); HostStatus hostStatus = getNodeStatus(applicationInstance.reference(), hostName); return new Host(hostName, hostStatus, applicationInstance.reference(), serviceInstances); }
/** * 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 String toString() { return "StorageNodeImpl{" + "applicationInstance=" + applicationInstance.reference() + ", clusterId=" + clusterId + ", storageService=" + storageService + '}'; }
public static boolean isClusterController(ServiceCluster cluster) { return CLUSTER_CONTROLLER_SERVICE_TYPE.equals(cluster.serviceType()); }
public ApplicationInstanceReference getApplicationReference() { return application.reference(); }