ApplicationApiImpl implements ApplicationApi { @Override public List<StorageNode> getUpStorageNodesInGroupInClusterOrder() { return clusterInOrder.stream() .map(ClusterApi::upStorageNodeInGroup) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); } ApplicationApiImpl(NodeGroup nodeGroup,
                              ApplicationLock lock,
                              ClusterControllerClientFactory clusterControllerClientFactory,
                              int numberOfConfigServers, Clock clock); @Override ApplicationId applicationId(); @Override List<ClusterApi> getClusters(); @Override List<StorageNode> getSuspendedStorageNodesInGroupInReverseClusterOrder(); @Override NodeGroup getNodeGroup(); @Override List<StorageNode> getStorageNodesInGroupInClusterOrder(); @Override List<StorageNode> getUpStorageNodesInGroupInClusterOrder(); @Override ApplicationInstanceStatus getApplicationStatus(); @Override void setHostState(OrchestratorContext context, HostName hostName, HostStatus status); @Override List<HostName> getNodesInGroupWith(Predicate<HostStatus> statusPredicate);  }
@Test public void testGetUpStorageNodesInGroupInClusterOrder() { HostName hostName1 = new HostName("host1"); HostName hostName2 = new HostName("host2"); HostName hostName3 = new HostName("host3"); HostName hostName4 = new HostName("host4"); HostName hostName5 = new HostName("host5"); HostName hostName6 = new HostName("host6"); HostName hostName7 = new HostName("host7"); ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList( modelUtils.createServiceCluster( "cluster-3", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList( modelUtils.createServiceInstance("config-id-30", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-31", hostName2, ServiceStatus.UP) ) ), modelUtils.createServiceCluster( "cluster-1", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList( modelUtils.createServiceInstance("config-id-10", hostName3, ServiceStatus.DOWN), modelUtils.createServiceInstance("config-id-11", hostName4, ServiceStatus.UP) ) ), modelUtils.createServiceCluster( "cluster-4", new ServiceType("service-type-4"), Arrays.asList( modelUtils.createServiceInstance("config-id-40", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-41", hostName2, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-42", hostName3, ServiceStatus.UP), modelUtils.createServiceInstance("config-id-43", hostName5, ServiceStatus.UP) ) ), modelUtils.createServiceCluster( "cluster-2", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList( modelUtils.createServiceInstance("config-id-20", hostName6, ServiceStatus.DOWN), modelUtils.createServiceInstance("config-id-21", hostName7, ServiceStatus.UP) ) ) )); verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1), hostName1); verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName2), hostName2); verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName3)); verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName4), hostName4); verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName5)); verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName3), hostName1); verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl(applicationInstance, hostName1, hostName4), hostName4, hostName1); verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl( applicationInstance, hostName1, hostName4, hostName5), hostName4, hostName1); verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl( applicationInstance, hostName1, hostName4, hostName5, hostName6), hostName4, hostName1); verifyUpStorageNodesInOrder(modelUtils.createApplicationApiImpl( applicationInstance, hostName1, hostName4, hostName5, hostName7), hostName4, hostName7, hostName1); }