public Job(String jobId, String jobName, JobListener listener) { this.jobName = jobName; this.listener = listener; dateCreated = new Date(); id = jobId; setStatus(Status.READY); }
public Job(String jobName, JobListener listener) { this.jobName = jobName; this.listener = listener; dateCreated = new Date(); id = JOB_DATE_FORMAT.format(dateCreated) + "_" + jobName; setStatus(Status.READY); }
@Override public void submit(Job job) { job.setStatus(Job.Status.PENDING); queue.add(job); jobs.put(job.getId(), job); }
runningJob.setStatus(Job.Status.ABORT); runningJob.aborted = false; return; runningJob.setStatus(Job.Status.RUNNING); runningJob.setStatus(Job.Status.ABORT); LOGGER.debug("Job Aborted, " + runningJob.getId() + ", " + runningJob.getErrorMessage()); LOGGER.debug("Job Error, " + runningJob.getId() + ", " + runningJob.getReturn()); runningJob.setStatus(Job.Status.ERROR); } else if (jobResult != null && jobResult instanceof InterpreterResult && ((InterpreterResult) jobResult).code() == InterpreterResult.Code.ERROR) { LOGGER.debug("Job Error, " + runningJob.getId() + ", " + runningJob.getReturn()); runningJob.setStatus(Job.Status.ERROR); } else { LOGGER.debug("Job Finished, " + runningJob.getId() + ", Result: " + runningJob.getReturn()); runningJob.setStatus(Job.Status.FINISHED);
@Override public void cancel(String sessionId, String className, RemoteInterpreterContext interpreterContext) throws TException { logger.info("cancel {} {}", className, interpreterContext.getParagraphId()); Interpreter intp = getInterpreter(sessionId, className); String jobId = interpreterContext.getParagraphId(); Job job = intp.getScheduler().getJob(jobId); if (job != null && job.getStatus() == Status.PENDING) { job.setStatus(Status.ABORT); } else { try { intp.cancel(convert(interpreterContext, null)); } catch (InterpreterException e) { throw new TException("Fail to cancel", e); } } }