OrchestratorImpl implements Orchestrator { @Override public void suspendAll(HostName parentHostname, List<HostName> hostNames) throws BatchHostStateChangeDeniedException, BatchHostNameNotFoundException, BatchInternalErrorException { try (OrchestratorContext context = OrchestratorContext.createContextForMultiAppOp(clock)) { List<NodeGroup> nodeGroupsOrderedByApplication; try { nodeGroupsOrderedByApplication = nodeGroupsOrderedForSuspend(hostNames); } catch (HostNameNotFoundException e) { throw new BatchHostNameNotFoundException(parentHostname, hostNames, e); } suspendAllNodeGroups(context, parentHostname, nodeGroupsOrderedByApplication, true); suspendAllNodeGroups(context, parentHostname, nodeGroupsOrderedByApplication, false); } } @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 suspendAllWorks() throws Exception { OrchestratorImpl orchestrator = spy(this.orchestrator); orchestrator.suspendAll( new HostName("parentHostname"), Arrays.asList( DummyServiceMonitor.TEST1_HOST_NAME, DummyServiceMonitor.TEST3_HOST_NAME, DummyServiceMonitor.TEST6_HOST_NAME)); InOrder order = inOrder(orchestrator); verifySuspendGroup(order, orchestrator, DummyServiceMonitor.TEST3_NODE_GROUP, true); verifySuspendGroup(order, orchestrator, DummyServiceMonitor.TEST6_NODE_GROUP, true); verifySuspendGroup(order, orchestrator, DummyServiceMonitor.TEST1_NODE_GROUP, true); verifySuspendGroup(order, orchestrator, DummyServiceMonitor.TEST3_NODE_GROUP, false); verifySuspendGroup(order, orchestrator, DummyServiceMonitor.TEST6_NODE_GROUP, false); verifySuspendGroup(order, orchestrator, DummyServiceMonitor.TEST1_NODE_GROUP, false); order.verifyNoMoreInteractions(); }