use of org.apache.airavata.gfac.core.task.JobSubmissionTask in project airavata by apache.
the class Factory method loadConfiguration.
public static void loadConfiguration() throws GFacException {
GFacYamlConfigruation config = new GFacYamlConfigruation();
try {
for (JobSubmitterTaskConfig jobSubmitterTaskConfig : config.getJobSbumitters()) {
String taskClass = jobSubmitterTaskConfig.getTaskClass();
Class<?> aClass = Class.forName(taskClass);
Constructor<?> constructor = aClass.getConstructor();
JobSubmissionTask task = (JobSubmissionTask) constructor.newInstance();
task.init(jobSubmitterTaskConfig.getProperties());
jobSubmissionTask.put(jobSubmitterTaskConfig.getSubmissionProtocol(), task);
}
for (DataTransferTaskConfig dataTransferTaskConfig : config.getFileTransferTasks()) {
String taskClass = dataTransferTaskConfig.getTaskClass();
Class<?> aClass = Class.forName(taskClass);
Constructor<?> constructor = aClass.getConstructor();
Task task = (Task) constructor.newInstance();
task.init(dataTransferTaskConfig.getProperties());
dataMovementTask.put(dataTransferTaskConfig.getTransferProtocol(), task);
}
for (ResourceConfig resourceConfig : config.getResourceConfiguration()) {
resources.put(resourceConfig.getJobManagerType(), resourceConfig);
}
} catch (Exception e) {
throw new GFacException("Gfac config issue", e);
}
sessionCache = CacheBuilder.newBuilder().expireAfterAccess(ServerSettings.getSessionCacheAccessTimeout(), TimeUnit.MINUTES).removalListener((RemovalListener<String, Session>) removalNotification -> {
if (removalNotification.getValue().isConnected()) {
log.info("Disconnecting ssh session with key: " + removalNotification.getKey());
removalNotification.getValue().disconnect();
}
log.info("Removed ssh session with key: " + removalNotification.getKey());
}).build();
}
use of org.apache.airavata.gfac.core.task.JobSubmissionTask in project airavata by apache.
the class GFacEngineImpl method cancelProcess.
@Override
public void cancelProcess(ProcessContext processContext) throws GFacException {
if (processContext != null) {
switch(processContext.getProcessState()) {
case MONITORING:
case EXECUTING:
// get job submission task and invoke cancel
JobSubmissionTask jobSubmissionTask = Factory.getJobSubmissionTask(processContext.getJobSubmissionProtocol());
TaskContext taskCtx = getJobSubmissionTaskContext(processContext);
executeCancel(taskCtx, jobSubmissionTask);
break;
case COMPLETED:
case FAILED:
case CANCELED:
case CANCELLING:
log.warn("Process cancel trigger for already {} process", processContext.getProcessState().name());
break;
default:
break;
}
}
}
use of org.apache.airavata.gfac.core.task.JobSubmissionTask in project airavata by apache.
the class GFacEngineImpl method executeJobSubmission.
private boolean executeJobSubmission(TaskContext taskContext, boolean recovery) throws GFacException {
TaskStatus taskStatus = new TaskStatus(TaskState.EXECUTING);
taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
taskContext.setTaskStatus(taskStatus);
GFacUtils.saveAndPublishTaskStatus(taskContext);
try {
JobSubmissionTaskModel jobSubmissionTaskModel = ((JobSubmissionTaskModel) taskContext.getSubTaskModel());
JobSubmissionTask jobSubmissionTask = Factory.getJobSubmissionTask(jobSubmissionTaskModel.getJobSubmissionProtocol());
ProcessContext processContext = taskContext.getParentProcessContext();
taskStatus = executeTask(taskContext, jobSubmissionTask, recovery);
taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
taskContext.setTaskStatus(taskStatus);
GFacUtils.saveAndPublishTaskStatus(taskContext);
checkFailures(taskContext, taskStatus, jobSubmissionTask);
return false;
} catch (TException e) {
throw new GFacException(e);
}
}
Aggregations