protected void undeployJob(final JobId jobId, final String host) throws Exception { final String undeployOutput = cli("undeploy", jobId.toString(), host); assertThat(undeployOutput, containsString(host + ": done")); final String output = cli("status", "--host", host, "--json"); final Map<JobId, JobStatus> statuses = Json.readUnchecked(output, new TypeReference<Map<JobId, JobStatus>>() {}); final JobStatus status = statuses.get(jobId); assertTrue(status == null || status.getDeployments().get(host) == null); }
/** Returns the current job status as a {@link JobStatus} object. */ @Override public JobStatus getJobStatus(final JobId jobId) { final ZooKeeperClient client = provider.get("getJobStatus"); final Job job = getJob(client, jobId); if (job == null) { return null; } final List<String> hosts; try { hosts = listJobHosts(client, jobId); } catch (JobDoesNotExistException e) { return null; } final ImmutableMap.Builder<String, Deployment> deployments = ImmutableMap.builder(); final ImmutableMap.Builder<String, TaskStatus> taskStatuses = ImmutableMap.builder(); for (final String host : hosts) { final TaskStatus taskStatus = getTaskStatus(client, host, jobId); if (taskStatus != null) { taskStatuses.put(host, taskStatus); } final Deployment deployment = getDeployment(host, jobId); if (deployment != null) { deployments.put(host, deployment); } } final Map<String, Deployment> deploymentsMap = deployments.build(); return JobStatus.newBuilder() .setJob(job) .setDeployments(deploymentsMap) .setTaskStatuses(taskStatuses.build()) .build(); }