Commit ce9fa1d7 authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Improve submitJob() in case a job is already deployed

parent 70997421
Pipeline #13653 passed with stage
in 1 minute and 9 seconds
......@@ -1074,7 +1074,12 @@ public class PAGateway {
scriptTasks.add(createInfraTask(task, deployment, suffix, token));
task.setDeploymentFirstSubmittedTaskName(scriptTasks.get(scriptTasks.size()-1).getName().substring(0, scriptTasks.get(scriptTasks.size()-1).getName().lastIndexOf("_")));
// If the infrastructure comes with the deployment of the EMS, we set it up.
Optional.ofNullable(deployment.getEmsDeployment()).ifPresent(emsDeploymentRequest -> scriptTasks.add(createEmsDeploymentTask(emsDeploymentRequest,suffix,token)));
Optional.ofNullable(deployment.getEmsDeployment()).ifPresent(emsDeploymentRequest -> {
String emsTaskSuffix = "_" + task.getName() + suffix;
ScriptTask emsScriptTask = createEmsDeploymentTask(emsDeploymentRequest,emsTaskSuffix,token);
emsScriptTask.addDependence(scriptTasks.get(scriptTasks.size()-1));
scriptTasks.add(emsScriptTask);
});
LOGGER.info("Token added: " + token);
deployment.setIsDeployed(true);
deployment.setNodeAccessToken(token);
......@@ -1286,7 +1291,10 @@ public class PAGateway {
// Creating application deployment tasks
createAndAddAppDeploymentTasks(task, suffix, token, scriptTasks, job);
});
task.setDeploymentFirstSubmittedTaskName(scriptTasks.get(0).getName().substring(0, scriptTasks.get(0).getName().lastIndexOf("_")));
if(!scriptTasks.isEmpty()) {
task.setDeploymentFirstSubmittedTaskName(
scriptTasks.get(0).getName().substring(0, scriptTasks.get(0).getName().lastIndexOf("_")));
}
}
scriptTasks.forEach(scriptTask -> task.addSubmittedTaskName(scriptTask.getName()));
......@@ -1393,12 +1401,17 @@ public class PAGateway {
paJob.setProjectName("Morphemic");
long submittedJobId = schedulerGateway.submit(paJob).longValue();
jobToSubmit.setSubmittedJobId(submittedJobId);
long submittedJobId = -1L;
if (!paJob.getTasks().isEmpty()) {
submittedJobId = schedulerGateway.submit(paJob).longValue();
jobToSubmit.setSubmittedJobId(submittedJobId);
LOGGER.info("Job submitted successfully. ID = " + submittedJobId);
} else {
LOGGER.warn("The job " + jobId + " is already deployed. Nothing to be submitted here.");
}
EntityManagerHelper.persist(jobToSubmit);
EntityManagerHelper.commit();
LOGGER.info("Job submitted successfully. ID = " + submittedJobId);
return(submittedJobId);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment