@Override public String call() throws Exception { final Deployment deployment = defaultClient().hostStatus(host).get().getJobs().get(jobId); if (deployment != null && !isNullOrEmpty(deployment.getDeploymentGroupName())) { return deployment.getDeploymentGroupName(); } else { return null; } } });
@Override public Boolean call() throws Exception { final HostStatus hostStatus = getOrNull(client.hostStatus(host)); final TaskStatus taskStatus = hostStatus.getStatuses().get(jobId); final Deployment deployment = hostStatus.getJobs().get(jobId); return taskStatus == null && deployment == null ? true : null; } });
@Override public String call() throws Exception { final Deployment deployment = defaultClient().hostStatus(host).get().getJobs().get(jobId); if (deployment != null && !isNullOrEmpty(deployment.getDeploymentGroupName())) { return deployment.getDeploymentGroupName(); } else { return null; } } });
@Override public String call() throws Exception { final Deployment deployment = defaultClient().hostStatus(host).get().getJobs().get(jobId); if (deployment != null && !isNullOrEmpty(deployment.getDeploymentGroupName())) { return deployment.getDeploymentGroupName(); } else { return null; } } });
.flatMap(hostStatus -> hostStatus.getJobs().keySet().stream()) .distinct() .collect(Collectors.toMap(Function.identity(), model::getJob));
@Test public void testRollingUpdateCoordination() throws Exception { // stop the default master master.stopAsync().awaitTerminated(); // start a bunch of masters and agents final Map<String, MasterMain> masters = startDefaultMasters(3); final Map<String, AgentMain> agents = Maps.newLinkedHashMap(); for (int i = 0; i < 20; i++) { final String name = TEST_HOST + i; agents.put(name, startDefaultAgent(name, "--labels", TEST_LABEL)); } // create a deployment group and start rolling out cli("create-deployment-group", "--json", TEST_GROUP, TEST_LABEL); final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, IDLE_COMMAND); cli("rolling-update", "--async", "--par", String.valueOf(agents.size()), testJobNameAndVersion, TEST_GROUP); // wait until the task is running on the final agent awaitTaskState(jobId, getLast(agents.keySet()), TaskStatus.State.RUNNING); // ensure that all masters were involved final Set<String> deployingMasters = Sets.newHashSet(); final Map<String, HostStatus> hostStatuses = defaultClient().hostStatuses( Lists.newArrayList(agents.keySet())).get(); for (final HostStatus status : hostStatuses.values()) { for (final Deployment deployment : status.getJobs().values()) { deployingMasters.add(deployment.getDeployerMaster()); } } assertEquals(masters.size(), deployingMasters.size()); }
for (final Map.Entry<JobId, Deployment> entry : hostStatus.getJobs().entrySet()) { if (name.equals(entry.getValue().getDeploymentGroupName())) { deployedJobId = entry.getKey();
@Test public void testMaster() throws Exception { final JobId jobId = createAndAwaitJobRunning(); // shut down the agent so it cannot remove the tombstone we make agent.stopAsync().awaitTerminated(); // make sure things look correct before assertFalse(zkMasterModel.getJobs().isEmpty()); assertEquals(START, zkMasterModel.getDeployment(TEST_HOST, jobId).getGoal()); // undeploy job client.undeploy(jobId, TEST_HOST).get(); // These used to be filtered away assertNull(zkMasterModel.getDeployment(TEST_HOST, jobId)); assertTrue(zkMasterModel.getHostStatus(TEST_HOST).getJobs().isEmpty()); }
defaultClient().hostStatus(hosts.get(0)).get().getJobs().get(jobId); assertEquals(TEST_GROUP, deployment.getDeploymentGroupName()); awaitDeploymentGroupStatus(defaultClient(), TEST_GROUP,
defaultClient().hostStatus(hosts.get(0)).get().getJobs().get(jobId); assertEquals(TEST_GROUP, deployment.getDeploymentGroupName()); awaitDeploymentGroupStatus(defaultClient(), TEST_GROUP, DeploymentGroupStatus.State.DONE);
defaultClient().hostStatus(host).get().getJobs().get(manualJobId); assertNotNull(manualDeployment); assertEquals(Goal.START, manualDeployment.getGoal());
for (final Map.Entry<JobId, Deployment> entry : hostStatus.getJobs().entrySet()) { if (name.equals(entry.getValue().getDeploymentGroupName())) { deployedJobId = entry.getKey();
final HostStatus hostStatus = getHostStatus(host); final List<JobId> jobs = hostStatus != null ? ImmutableList.copyOf(hostStatus.getJobs().keySet()) : Collections.<JobId>emptyList(); throw new HostStillInUseException(host, jobs);