VespaModelUtil { public static int getClusterControllerIndex(ConfigId configId) { Matcher matcher = CONTROLLER_INDEX_PATTERN.matcher(configId.s()); if (!matcher.matches()) { throw new IllegalArgumentException("Unable to extract cluster controller index from config ID " + configId); } return Integer.valueOf(matcher.group(1)); }  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 testGetClusterControllerIndex() { ConfigId configId = new ConfigId("admin/cluster-controllers/2"); assertEquals(2, VespaModelUtil.getClusterControllerIndex(configId)); }
@Test public void testGetClusterControllerIndexWithStandaloneClusterController() { ConfigId configId = new ConfigId("fantasy_sports/standalone/fantasy_sports-controllers/1"); assertEquals(1, VespaModelUtil.getClusterControllerIndex(configId)); }
@Test(expected = IllegalArgumentException.class) public void testBadClusterControllerConfigId() { ConfigId configId = new ConfigId("fantasy_sports/storage/9"); VespaModelUtil.getClusterControllerIndex(configId); fail(); }