log.info("stdout=" + stdOutputString);
// GFacUtils.updateJobStatus(details, JobState.COMPLETE);
} catch (Exception e) {
throw new GFacProviderException(e.getMessage(), e);
} finally {
if (cluster != null) {
try {
cluster.disconnect();
} catch (SSHApiException e) {
throw new GFacProviderException(e.getMessage(), e);
}
}
}
} else {
try {
jobExecutionContext.getNotifier().publish(new StartExecutionEvent());
HostDescriptionType host = jobExecutionContext.getApplicationContext().
getHostDescription().getType();
HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) jobExecutionContext.getApplicationContext().
getApplicationDeploymentDescription().getType();
JobDetails jobDetails = new JobDetails();
String taskID = jobExecutionContext.getTaskData().getTaskID();
try {
Cluster cluster = null;
if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) != null) {
cluster = ((SSHSecurityContext) jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)).getPbsCluster();
}
if (cluster == null) {
throw new GFacProviderException("Security context is not set properly");
} else {
log.info("Successfully retrieved the Security Context");
}
// This installed path is a mandetory field, because this could change based on the computing resource
JobDescriptor jobDescriptor = GFACSSHUtils.createJobDescriptor(jobExecutionContext, app, cluster);
log.info(jobDescriptor.toXML());
jobDetails.setJobDescription(jobDescriptor.toXML());
String jobID = cluster.submitBatchJob(jobDescriptor);
jobExecutionContext.setJobDetails(jobDetails);
if (jobID == null) {
jobDetails.setJobID("none");
GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.FAILED);
} else {
jobDetails.setJobID(jobID);
GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.SUBMITTED);
}
delegateToMonitorHandlers(jobExecutionContext);
} catch (SSHApiException e) {
String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
log.error(error);
jobDetails.setJobID("none");
GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.FAILED);
GFacUtils.saveErrorDetails(jobExecutionContext, error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
throw new GFacProviderException(error, e);
} catch (Exception e) {
String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
log.error(error);
jobDetails.setJobID("none");
GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.FAILED);
GFacUtils.saveErrorDetails(jobExecutionContext, error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
throw new GFacProviderException(error, e);
}
} catch (GFacException e) {
throw new GFacProviderException(e.getMessage(), e);
}
}
}