\r
private static final Logger log = Logger.getLogger(ClusterSession.class);\r
\r
- private static final PropertyHelper ph = PropertyHelperManager\r
- .getPropertyHelper();\r
+ private static final PropertyHelper ph = PropertyHelperManager.getPropertyHelper();\r
\r
public static final String JOBID = "JOBID";\r
// TaskId (getTaskDirectory()) -> ConfiguredExecutable<?> map\r
// private static BufferedWriter tasks;\r
\r
private ClusterSession() {\r
- log.debug("Initializing session "\r
- + Util.datef.format(Calendar.getInstance().getTime()));\r
+ log.debug("Initializing session " + Util.datef.format(Calendar.getInstance().getTime()));\r
SessionFactory factory = SessionFactory.getFactory();\r
session = factory.getSession();\r
sContact = session.getContact();\r
if (open) {\r
session.exit();\r
open = false;\r
- log.debug("Closing the session at: "\r
- + Util.datef.format(Calendar.getInstance().getTime()));\r
+ log.debug("Closing the session at: " + Util.datef.format(Calendar.getInstance().getTime()));\r
}\r
} catch (DrmaaException dre) {\r
// Cannot recover at this point, just log\r
return waitForJob(taskId, Session.TIMEOUT_WAIT_FOREVER);\r
}\r
\r
- public static ClusterJobId getClusterJobId(String taskId)\r
- throws IOException {\r
+ public static ClusterJobId getClusterJobId(String taskId) throws IOException {\r
Job job = Job.getByTaskId(taskId, jobs);\r
if (job != null) {\r
return job.getJobId();\r
String workDir = compbio.engine.Configurator.getWorkDirectory(taskId);\r
assert !Util.isEmpty(workDir);\r
File file = new File(workDir, JOBID);\r
- log.debug("Looking up cluster jobid by the task id " + taskId\r
- + " File path is " + file.getAbsolutePath());\r
+ log.debug("Looking up cluster jobid by the task id " + taskId + " File path is " + file.getAbsolutePath());\r
assert file.exists();\r
return new ClusterJobId(FileUtil.readFileToString(file));\r
}\r
\r
- public JobInfo waitForJob(String jobId, long waitingTime)\r
- throws DrmaaException, IOException {\r
+ public JobInfo waitForJob(String jobId, long waitingTime) throws DrmaaException, IOException {\r
ClusterJobId cjobId = getClusterJobId(jobId);\r
JobInfo status = session.wait(cjobId.getJobId(), waitingTime);\r
// Once the job has been waited for it will be finished\r
}\r
}\r
\r
- public ConfiguredExecutable<?> getResults(String taskId)\r
- throws DrmaaException, ResultNotAvailableException {\r
+ public ConfiguredExecutable<?> getResults(String taskId) throws DrmaaException, ResultNotAvailableException {\r
\r
EngineUtil.isValidJobId(taskId);\r
try {\r
JobInfo status = waitForJob(taskId);\r
} catch (InvalidJobException e) {\r
// Its OK to continue, the job may have already completed normally\r
- log.warn("Could not find the cluster job with id " + taskId\r
- + " perhaps it has completed", e.getCause());\r
+ log.warn("Could not find the cluster job with id " + taskId + " perhaps it has completed", e.getCause());\r
} catch (IOException e) {\r
- log.error("Could not read JOBID file for the job " + taskId\r
- + " Message " + e.getLocalizedMessage(), e.getCause());\r
+ log.error("Could not read JOBID file for the job " + taskId + " Message " + e.getLocalizedMessage(),\r
+ e.getCause());\r
}\r
// Once the job has been waited for it will be finished\r
// Next time it will not be found in the session, so removed from the\r
exec = EngineUtil.loadExecutable(taskId);\r
}\r
if (exec != null) {\r
- EngineUtil.writeMarker(exec.getWorkDirectory(),\r
- JobStatus.COLLECTED);\r
+ EngineUtil.writeMarker(exec.getWorkDirectory(), JobStatus.COLLECTED);\r
}\r
return exec;\r
}\r
\r
- public static StatisticManager getStatistics(JobInfo status)\r
- throws DrmaaException {\r
+ public static StatisticManager getStatistics(JobInfo status) throws DrmaaException {\r
return new StatisticManager(status);\r
}\r
\r
* if the job is no longer in the queue or running. basically it\r
* will throw this exception for all finished or cancelled jobs\r
*/\r
- public int getJobStatus(ClusterJobId jobId) throws DrmaaException,\r
- InvalidJobException {\r
+ public int getJobStatus(ClusterJobId jobId) throws DrmaaException, InvalidJobException {\r
return session.getJobProgramStatus(jobId.getJobId());\r
}\r
\r
public static String getJobStatus(final int status) throws DrmaaException {\r
String statusString = null;\r
switch (status) {\r
- case Session.UNDETERMINED :\r
- statusString = "Job status cannot be determined\n";\r
- break;\r
- case Session.QUEUED_ACTIVE :\r
- statusString = "Job is queued and active\n";\r
- break;\r
- case Session.SYSTEM_ON_HOLD :\r
- statusString = "Job is queued and in system hold\n";\r
- break;\r
- case Session.USER_ON_HOLD :\r
- statusString = "Job is queued and in user hold\n";\r
- break;\r
- case Session.USER_SYSTEM_ON_HOLD :\r
- statusString = "Job is queued and in user and system hold\n";\r
- break;\r
- case Session.RUNNING :\r
- statusString = "Job is running\n";\r
- break;\r
- case Session.SYSTEM_SUSPENDED :\r
- statusString = "Job is system suspended\n";\r
- break;\r
- case Session.USER_SUSPENDED :\r
- statusString = "Job is user suspended\n";\r
- break;\r
- case Session.USER_SYSTEM_SUSPENDED :\r
- statusString = "Job is user and system suspended\n";\r
- break;\r
- case Session.DONE :\r
- statusString = "Job finished normally\n";\r
- break;\r
- case Session.FAILED :\r
- statusString = "Job finished, but failed\n";\r
- break;\r
+ case Session.UNDETERMINED:\r
+ statusString = "Job status cannot be determined\n";\r
+ break;\r
+ case Session.QUEUED_ACTIVE:\r
+ statusString = "Job is queued and active\n";\r
+ break;\r
+ case Session.SYSTEM_ON_HOLD:\r
+ statusString = "Job is queued and in system hold\n";\r
+ break;\r
+ case Session.USER_ON_HOLD:\r
+ statusString = "Job is queued and in user hold\n";\r
+ break;\r
+ case Session.USER_SYSTEM_ON_HOLD:\r
+ statusString = "Job is queued and in user and system hold\n";\r
+ break;\r
+ case Session.RUNNING:\r
+ statusString = "Job is running\n";\r
+ break;\r
+ case Session.SYSTEM_SUSPENDED:\r
+ statusString = "Job is system suspended\n";\r
+ break;\r
+ case Session.USER_SUSPENDED:\r
+ statusString = "Job is user suspended\n";\r
+ break;\r
+ case Session.USER_SYSTEM_SUSPENDED:\r
+ statusString = "Job is user and system suspended\n";\r
+ break;\r
+ case Session.DONE:\r
+ statusString = "Job finished normally\n";\r
+ break;\r
+ case Session.FAILED:\r
+ statusString = "Job finished, but failed\n";\r
+ break;\r
}\r
return statusString;\r
}\r