/** * @return The node index of the storage node running on the host. * @throws java.lang.IllegalArgumentException if there is not exactly one storage node running on the host, * or if the index of that storage node could not be found. */ public static int getStorageNodeIndex(ApplicationInstance application, HostName hostName) { Optional<ServiceInstance> storageNode = getStorageNodeAtHost(application, hostName); if (!storageNode.isPresent()) { throw new IllegalArgumentException("Failed to find a storage node for application " + application.applicationInstanceId() + " at host " + hostName); } return getStorageNodeIndex(storageNode.get().configId()); }
if (storageNodes.contains(hostName)) { throw new IllegalStateException("Found more than 1 storage service instance on " + hostName + ": last service instance is " + serviceInstance.configId() + " in storage cluster " + clusterInfo());
@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); } }
clusterId); ConfigId configId = storageService.configId(); int nodeIndex = VespaModelUtil.getStorageNodeIndex(configId);