OrchestratorImpl implements Orchestrator { @Override public Host getHost(HostName hostName) throws HostNameNotFoundException { ApplicationInstance applicationInstance = serviceMonitor .getApplicationNarrowedTo(hostName) .orElseThrow(() -> new HostNameNotFoundException(hostName)); List<ServiceInstance> serviceInstances = applicationInstance .serviceClusters().stream() .flatMap(cluster -> cluster.serviceInstances().stream()) .filter(serviceInstance -> hostName.equals(serviceInstance.hostName())) .collect(Collectors.toList()); HostInfo hostInfo = statusService.getHostInfo(applicationInstance.reference(), hostName); return new Host(hostName, hostInfo, applicationInstance.reference(), serviceInstances); } @Inject  OrchestratorImpl(ClusterControllerClientFactory clusterControllerClientFactory,
                            StatusService statusService,
                            OrchestratorConfig orchestratorConfig,
                            ServiceMonitor serviceMonitor,
                            ConfigserverConfig configServerConfig,
                            FlagSource flagSource);  OrchestratorImpl(Policy policy,
                            ClusterControllerClientFactory clusterControllerClientFactory,
                            StatusService statusService,
                            ServiceMonitor serviceMonitor,
                            int serviceMonitorConvergenceLatencySeconds,
                            Clock clock,
                            ApplicationApiFactory applicationApiFactory,
                            FlagSource flagSource); @Override Host getHost(HostName hostName); @Override HostStatus getNodeStatus(HostName hostName); @Override HostInfo getHostInfo(ApplicationInstanceReference reference, HostName hostname); @Override Function<HostName, Optional<HostInfo>> getHostResolver(); @Override void setNodeStatus(HostName hostName, HostStatus status); @Override void resume(HostName hostName); @Override void suspend(HostName hostName); @Override void acquirePermissionToRemove(HostName hostName); @Override ApplicationInstanceStatus getApplicationInstanceStatus(ApplicationId appId); @Override Set<ApplicationId> getAllSuspendedApplications(); @Override void resume(ApplicationId appId); @Override void suspend(ApplicationId appId); @Override void suspendAll(HostName parentHostname, List<HostName> hostNames);  }
@Test public void testGetHost() throws Exception { ClusterControllerClientFactory clusterControllerClientFactory = new ClusterControllerClientFactoryMock(); StatusService statusService = new ZkStatusService( new MockCurator(), mock(Metric.class), new TestTimer(), new DummyAntiServiceMonitor()); HostName hostName = new HostName("host.yahoo.com"); TenantId tenantId = new TenantId("tenant"); ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId("applicationInstanceId"); ApplicationInstanceReference reference = new ApplicationInstanceReference( tenantId, applicationInstanceId); ApplicationInstance applicationInstance = new ApplicationInstance( tenantId, applicationInstanceId, Set.of(new ServiceCluster( new ClusterId("clusterId"), new ServiceType("serviceType"), Set.of(new ServiceInstance( new ConfigId("configId1"), hostName, ServiceStatus.UP), new ServiceInstance( new ConfigId("configId2"), hostName, ServiceStatus.NOT_CHECKED))))); ServiceMonitor serviceMonitor = () -> new ServiceModel(Map.of(reference, applicationInstance)); orchestrator = new OrchestratorImpl(new HostedVespaPolicy(new HostedVespaClusterPolicy(), clusterControllerClientFactory, applicationApiFactory), clusterControllerClientFactory, statusService, serviceMonitor, 0, new ManualClock(), applicationApiFactory, flagSource); orchestrator.setNodeStatus(hostName, HostStatus.ALLOWED_TO_BE_DOWN); Host host = orchestrator.getHost(hostName); assertEquals(reference, host.getApplicationInstanceReference()); assertEquals(hostName, host.getHostName()); assertEquals(HostStatus.ALLOWED_TO_BE_DOWN, host.getHostInfo().status()); assertTrue(host.getHostInfo().suspendedSince().isPresent()); assertEquals(2, host.getServiceInstances().size()); }