use of org.gridlab.gat.resources.Job.JobState in project compss by bsc-wdc.
the class GATJob method processMetricEvent.
// MetricListener interface implementation
@Override
public void processMetricEvent(MetricEvent value) {
Job job = (Job) value.getSource();
JobState newJobState = (JobState) value.getValue();
JobDescription jd = (JobDescription) job.getJobDescription();
SoftwareDescription sd = jd.getSoftwareDescription();
Integer jobId = (Integer) sd.getAttributes().get("jobId");
logger.debug("Processing job ID = " + jobId);
/*
* Check if either the job has finished or there has been a submission error. We don't care about other state
* transitions
*/
if (newJobState == JobState.STOPPED) {
if (Tracer.isActivated()) {
Integer slot = (Integer) sd.getAttributes().get("slot");
String host = getResourceNode().getHost();
Tracer.freeSlot(host, slot);
}
/*
* We must check whether the chosen adaptor is globus In that case, since globus doesn't provide the exit
* status of a job, we must examine the standard error file
*/
try {
if (usingGlobus) {
File errFile = sd.getStderr();
// Error file should always be in the same host as the IT
File localFile = GAT.createFile(context, errFile.toGATURI());
if (localFile.length() > 0) {
GATjob = null;
RUNNING_JOBS.remove(this);
ErrorManager.warn("Error when creating file.");
listener.jobFailed(this, JobEndStatus.EXECUTION_FAILED);
} else {
if (!debug) {
localFile.delete();
}
RUNNING_JOBS.remove(this);
listener.jobCompleted(this);
}
} else {
if (job.getExitStatus() == 0) {
RUNNING_JOBS.remove(this);
listener.jobCompleted(this);
} else {
GATjob = null;
RUNNING_JOBS.remove(this);
listener.jobFailed(this, JobEndStatus.EXECUTION_FAILED);
}
}
} catch (Exception e) {
ErrorManager.fatal(CALLBACK_PROCESSING_ERR + ": " + this, e);
}
} else if (newJobState == JobState.SUBMISSION_ERROR) {
if (Tracer.isActivated()) {
Integer slot = (Integer) sd.getAttributes().get("slot");
String host = getResourceNode().getHost();
Tracer.freeSlot(host, slot);
}
try {
if (usingGlobus && job.getInfo().get("resManError").equals("NO_ERROR")) {
RUNNING_JOBS.remove(this);
listener.jobCompleted(this);
} else {
GATjob = null;
RUNNING_JOBS.remove(this);
listener.jobFailed(this, JobEndStatus.SUBMISSION_FAILED);
}
} catch (GATInvocationException e) {
ErrorManager.fatal(CALLBACK_PROCESSING_ERR + ": " + this, e);
}
}
}
Aggregations