default String status(Job job) throws Exception { return job.getStatus().getName(); }
private void checkJobCanBeDeleted(Job job) throws CatalogException { switch (job.getStatus().getName()) { case Job.JobStatus.DELETED: throw new CatalogException("Job already deleted."); case Job.JobStatus.PREPARED: case Job.JobStatus.RUNNING: case Job.JobStatus.QUEUED: throw new CatalogException("The status of the job is " + job.getStatus().getName() + ". Please, stop the job before deleting it."); case Job.JobStatus.DONE: case Job.JobStatus.ERROR: case Job.JobStatus.READY: default: break; } }
@Override public String status(Job job) throws Exception { String status = SgeManager.status(Objects.toString(job.getResourceManagerAttributes().get(Job.JOB_SCHEDULER_NAME))); switch (status) { case SgeManager.ERROR: case SgeManager.EXECUTION_ERROR: return Job.JobStatus.ERROR; case SgeManager.FINISHED: return Job.JobStatus.READY; case SgeManager.QUEUED: return Job.JobStatus.QUEUED; case SgeManager.RUNNING: case SgeManager.TRANSFERRED: return Job.JobStatus.RUNNING; case SgeManager.UNKNOWN: default: return job.getStatus().getName(); } } }
@Override protected String getStatus(Job job) { String status; try { status = SgeManager.status(Objects.toString(job.getResourceManagerAttributes().get(Job.JOB_SCHEDULER_NAME))); } catch (Exception e) { logger.error("Could not obtain the status of the job {} from SGE. Error: {}", job.getUid(), e.getMessage()); return Job.JobStatus.UNKNOWN; } switch (status) { case SgeManager.ERROR: case SgeManager.EXECUTION_ERROR: return Job.JobStatus.ERROR; case SgeManager.FINISHED: return Job.JobStatus.READY; case SgeManager.QUEUED: return Job.JobStatus.QUEUED; case SgeManager.RUNNING: case SgeManager.TRANSFERRED: return Job.JobStatus.RUNNING; case SgeManager.UNKNOWN: default: return job.getStatus().getName(); } }
/** * Do not execute Job using its command line, won't find the opencga-storage.sh * Call directly to the OpenCGAStorageMain */ private Job runStorageJob(Job storageJob, String sessionId) throws IOException, CatalogException { // storageJob.setCommandLine(storageJob.getCommandLine() + " --job-id " + storageJob.getId()); Job job = opencga.runStorageJob(storageJob, sessionId); assertEquals(Job.JobStatus.READY, job.getStatus().getName()); return job; }
@Test public void deleteJobTest() throws CatalogException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Job job = catalogJobDBAdaptor.insert(new Job("name", user3.getId(), "", "", "", new File().setUid(4), Collections.emptyList(), 1), studyId, null).first(); long jobId = job.getUid(); assertEquals(Job.JobStatus.PREPARED, job.getStatus().getName()); catalogJobDBAdaptor.delete(jobId); thrown.expect(CatalogDBException.class); thrown.expectMessage("not exist"); catalogJobDBAdaptor.get(jobId, QueryOptions.empty()); }
job.setStatus(ParamUtils.defaultObject(job.getStatus(), new Job.JobStatus(Job.JobStatus.PREPARED))); job.setInput(ParamUtils.defaultObject(job.getInput(), Collections.emptyList())); job.setOutput(ParamUtils.defaultObject(job.getOutput(), Collections.emptyList()));