use of com.spotify.helios.master.JobNotDeployedException in project helios by spotify.
the class ExpiredJobReaper method runOneIteration.
@Override
public void runOneIteration() {
for (final Entry<JobId, Job> entry : masterModel.getJobs().entrySet()) {
final JobId jobId = entry.getKey();
final Job job = entry.getValue();
if (job.getExpires() == null) {
//noinspection UnnecessaryContinue
continue;
} else if (job.getExpires().getTime() <= clock.now().getMillis()) {
final JobStatus status = masterModel.getJobStatus(jobId);
final List<String> hosts = ImmutableList.copyOf(status.getDeployments().keySet());
for (final String host : hosts) {
try {
masterModel.undeployJob(host, jobId, job.getToken());
} catch (HostNotFoundException e) {
log.error("couldn't undeploy job {} from host {} when it hit deadline", jobId, host, e);
} catch (JobNotDeployedException e) {
log.debug("job {} was already undeployed when it hit deadline", jobId, e);
} catch (TokenVerificationException e) {
log.error("couldn't undeploy job {} from host {} because token verification failed", jobId, host, e);
}
}
try {
masterModel.removeJob(jobId, job.getToken());
} catch (JobDoesNotExistException e) {
log.debug("job {} was already removed when it hit deadline", jobId, e);
} catch (JobStillDeployedException e) {
log.debug("job {} still deployed on some host(s) after expiry reap", jobId, e);
} catch (TokenVerificationException e) {
log.error("couldn't remove job {} because token verification failed", jobId, e);
}
}
}
}
use of com.spotify.helios.master.JobNotDeployedException in project helios by spotify.
the class ZooKeeperMasterModelIntegrationTest method testUpdateDeploy.
@Test
public void testUpdateDeploy() throws Exception {
try {
stopJob(model, JOB);
fail("should have thrown JobNotDeployedException");
} catch (JobNotDeployedException e) {
assertTrue(true);
} catch (Exception e) {
fail("Should have thrown an JobNotDeployedException, got " + e.getClass());
}
model.addJob(JOB);
try {
stopJob(model, JOB);
fail("should have thrown exception");
} catch (HostNotFoundException e) {
assertTrue(true);
} catch (Exception e) {
fail("Should have thrown an HostNotFoundException");
}
model.registerHost(HOST, "foo");
final List<String> hosts = model.listHosts();
assertThat(hosts, hasItem(HOST));
try {
stopJob(model, JOB);
fail("should have thrown exception");
} catch (JobNotDeployedException e) {
assertTrue(true);
} catch (Exception e) {
fail("Should have thrown an JobNotDeployedException");
}
model.deployJob(HOST, Deployment.newBuilder().setGoal(Goal.START).setJobId(JOB.getId()).build());
final Map<JobId, Job> jobsOnHost = model.getJobs();
assertEquals(1, jobsOnHost.size());
final Job descriptor = jobsOnHost.get(JOB.getId());
assertEquals(JOB, descriptor);
// should succeed this time!
stopJob(model, JOB);
final Deployment jobCfg = model.getDeployment(HOST, JOB.getId());
assertEquals(Goal.STOP, jobCfg.getGoal());
}
Aggregations