Skip to content

Commit

Permalink
Added forced close of scheduler when connection seems lost
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaassen committed Mar 26, 2020
1 parent b2b727b commit 5a38f2e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ private void updateRunningJobs(Scheduler scheduler) {
jobLogger.error("Exception while retrieving status of job (scheduler connection lost?)", status.getException());
logger.error("Exception while retrieving status of job " + job.getName() + "(" + job.getId() + ") -- scheduler connection lost?",
status.getException());

// Force the scheduler to close when we seem to lose the connection
logger.error("Forcing the scheduler to close");
xenonService.closeScheduler();
} else if (status.getState().equals("UNKNOWN")) {
// We seem to have lost the job completely? -- try to recover the output
jobLogger.error("Could not find job ", status.getException());
Expand Down Expand Up @@ -196,6 +200,9 @@ private void updateWaitingJobs(Scheduler scheduler) {
jobLogger.error("Exception while retrieving status of job (scheduler connection lost?)", status.getException());
logger.error("Exception while retrieving status of job " + job.getName() + "(" + job.getId() + ") -- scheduler connection lost?",
status.getException());

logger.error("Forcing the scheduler to close");
xenonService.closeScheduler();
} else if (status.getState().equals("UNKNOWN")) {
// We seem to have lost the job completely? -- try to recover the output
jobLogger.error("Could not find job ", status.getException());
Expand Down Expand Up @@ -249,6 +256,7 @@ private void cancelRunningJobs(Scheduler scheduler) {
status = scheduler.cancelJob(job.getXenonId());
jobService.setXenonState(job.getId(), status.getState());
} else {
// FIXME: we may leak jobs here if the connection to the machine is lost!
if (status.hasException() && !(status.getException() instanceof JobCanceledException)) {
jobService.setXenonExitcode(job.getId(), status.getExitCode());
jobService.setErrorAndState(job.getId(), status.getException(), JobState.RUNNING_CR, JobState.PERMANENT_FAILURE);
Expand Down Expand Up @@ -300,6 +308,7 @@ private void cancelWaitingJobs(Scheduler scheduler) {
logger.debug("Cancelled job: " + job.getId() + " new status: " + status);
}

// FIXME: we may leak jobs here if the connection to the machine is lost?
jobService.setJobState(job.getId(), JobState.WAITING_CR, JobState.CANCELLED);
}
} catch (NoSuchJobException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,17 @@ public Scheduler getScheduler() throws XenonException {
return scheduler;
}

public Scheduler forceNewScheduler() throws XenonException {
public void closeScheduler() throws XenonException {
if (scheduler != null) {
if (scheduler.isOpen()) {
scheduler.close();
}
scheduler = null;
}
}

public Scheduler forceNewScheduler() throws XenonException {
closeScheduler();
return getScheduler();
}

Expand Down

0 comments on commit 5a38f2e

Please sign in to comment.