VespaModelUtil { public static ClusterId getContentClusterName(ApplicationInstance application, HostName hostName) { Set<ClusterId> contentClusterIdsOnHost = application.serviceClusters().stream() .filter(VespaModelUtil::isContent) .filter(cluster -> clusterHasInstanceOnHost(cluster, hostName)) .map(ServiceCluster::clusterId) .collect(Collectors.toSet()); if (contentClusterIdsOnHost.size() != 1) { throw new IllegalArgumentException("Expected exactly one content cluster within application " + application.applicationInstanceId() + " and host " + hostName + ", but found " + contentClusterIdsOnHost.size() + ": " + contentClusterIdsOnHost + ", application: " + application); } return contentClusterIdsOnHost.iterator().next(); }  static boolean isClusterController(ServiceCluster cluster); static boolean isStorage(ServiceCluster cluster); static boolean isContent(ServiceCluster cluster); static List<HostName> getClusterControllerInstancesInOrder(ApplicationInstance application,
                                                                          ClusterId contentClusterId); static Set<ServiceCluster> getClusterControllerServiceClusters(ApplicationInstance application); static HostName getControllerHostName(ApplicationInstance application, ClusterId contentClusterId); static ClusterId getContentClusterName(ApplicationInstance application, HostName hostName); static int getStorageNodeIndex(ApplicationInstance application, HostName hostName); static Optional<ServiceInstance> getStorageNodeAtHost(ApplicationInstance application, 
                                                                        HostName hostName); static int getClusterControllerIndex(ConfigId configId); static int getStorageNodeIndex(ConfigId configId); static final ApplicationId TENANT_HOST_APPLICATION_ID; static final ClusterId ADMIN_CLUSTER_ID; static final ServiceType SLOBROK_SERVICE_TYPE; static final ServiceType CLUSTER_CONTROLLER_SERVICE_TYPE; static final ServiceType DISTRIBUTOR_SERVICE_TYPE; static final ServiceType SEARCHNODE_SERVICE_TYPE; static final ServiceType STORAGENODE_SERVICE_TYPE; static final ServiceType METRICS_PROXY_SERVICE_TYPE; }
@Test public void testGetContentClusterName() { ClusterId contentClusterName = VespaModelUtil.getContentClusterName(application, distributor0.hostName()); assertEquals(CONTENT_CLUSTER_ID, contentClusterName); }
@Test public void testGetContentClusterNameForSecondaryContentCluster() { ClusterId contentClusterName = VespaModelUtil.getContentClusterName(application, secondaryDistributor0.hostName()); assertEquals(contentClusterName, SECONDARY_CONTENT_CLUSTER_ID); }