use of com.spotify.helios.common.protocol.JobDeleteResponse in project helios by spotify.
the class JobRemoveCommand method runWithJobId.
@Override
protected int runWithJobId(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final JobId jobId, final BufferedReader stdin) throws IOException, ExecutionException, InterruptedException {
final boolean yes = options.getBoolean(yesArg.getDest());
final boolean force = options.getBoolean(forceArg.getDest());
if (force) {
log.warn("If you are using '--force' to skip the interactive prompt, " + "note that we have deprecated it. Please use '--yes'.");
}
if (!yes && !force) {
out.printf("This will remove the job %s%n", jobId);
final boolean confirmed = Utils.userConfirmed(out, stdin);
if (!confirmed) {
return 1;
}
}
if (!json) {
out.printf("Removing job %s%n", jobId);
}
int code = 0;
final String token = options.getString(tokenArg.getDest());
final JobDeleteResponse response = client.deleteJob(jobId, token).get();
if (!json) {
out.printf("%s: ", jobId);
}
if (response.getStatus() == JobDeleteResponse.Status.OK) {
if (json) {
out.print(response.toJsonString());
} else {
out.printf("done%n");
}
} else {
if (json) {
out.print(response.toJsonString());
} else {
out.printf("failed: %s%n", response);
}
code = 1;
}
return code;
}
use of com.spotify.helios.common.protocol.JobDeleteResponse in project helios by spotify.
the class DeregisterTest method testDeregisterJobDeployedWithoutStatus.
// Verify that we can deregister a host there are jobs deployed to it, for which there's no
// corresponding status information. For example, if a job was deployed to the host after is went
// down.
@Test
public void testDeregisterJobDeployedWithoutStatus() throws Exception {
startDefaultMaster();
final String host = testHost();
final HeliosClient client = defaultClient();
final DefaultZooKeeperClient zkClient = new DefaultZooKeeperClient(zk().curatorWithSuperAuth());
final String idPath = Paths.configHostId(host);
ZooKeeperRegistrarUtil.registerHost(zkClient, idPath, host, UUID.randomUUID().toString());
// Create a job
final Job job = Job.newBuilder().setName(testJobName).setVersion(testJobVersion).setImage(BUSYBOX).setCommand(IDLE_COMMAND).setPorts(ImmutableMap.of("foo", PortMapping.of(4711), "bar", PortMapping.of(4712, ports.localPort("bar")))).build();
final JobId jobId = job.getId();
final CreateJobResponse created = client.createJob(job).get();
assertEquals(CreateJobResponse.Status.OK, created.getStatus());
// Deploy the job on the agent
final Deployment deployment = Deployment.of(jobId, START);
final JobDeployResponse deployed = client.deploy(deployment, host).get();
assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
// Deregister agent
final HostDeregisterResponse deregisterResponse = client.deregisterHost(host).get();
assertEquals(HostDeregisterResponse.Status.OK, deregisterResponse.getStatus());
// Verify that it's possible to remove the job
final JobDeleteResponse deleteResponse = client.deleteJob(jobId).get();
assertEquals(JobDeleteResponse.Status.OK, deleteResponse.getStatus());
}
use of com.spotify.helios.common.protocol.JobDeleteResponse in project helios by spotify.
the class JobRemoveTest method testRemoveJobWithoutHistory.
@Test
public void testRemoveJobWithoutHistory() throws Exception {
final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, IDLE_COMMAND);
final JobDeleteResponse response = defaultClient().deleteJob(jobId).get(WAIT_TIMEOUT_SECONDS, SECONDS);
assertEquals(JobDeleteResponse.Status.OK, response.getStatus());
}
Aggregations