/** * @param configId Config ID is of the form "storage/storage/3", where 3 is the storage node index. * @return The storage node index. * @throws java.lang.IllegalArgumentException If configId does not have the required form. */ public static int getStorageNodeIndex(ConfigId configId) { Matcher matcher = STORAGE_NODE_INDEX_PATTERN.matcher(configId.s()); if (!matcher.matches()) { throw new IllegalArgumentException("Unable to extract node index from config ID " + configId); } return Integer.valueOf(matcher.group(1)); }
/** * @param configId Must be of the form admin/cluster-controllers/2 or NAME/standalone/NAME-controllers/2, * where NAME is the name of the content cluster. NAME-controllers is also the cluster ID of * the cluster controller cluster. * @return the Cluster Controller index given its config ID. * @throws java.lang.IllegalArgumentException if the config ID is not of the proper format. */ 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)); }
@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); } }