Commit 441b49a6 authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Improve stopJob endpoint in SAL

parent 8dd96394
...@@ -931,22 +931,26 @@ public class PAGateway { ...@@ -931,22 +931,26 @@ public class PAGateway {
.map(Deployment::getNodeName) .map(Deployment::getNodeName)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<Deployment> taskIaasDeployments = task.getDeployments().stream()
.filter(deployment -> NodeType.IAAS.equals(deployment.getDeploymentType()))
.collect(Collectors.toList());
task.getDeployments().forEach(deployment -> { List<Deployment> taskByonDeployments = task.getDeployments().stream()
switch (deployment.getDeploymentType()) { .filter(deployment -> NodeType.BYON.equals(deployment.getDeploymentType()))
case IAAS: .collect(Collectors.toList());
taskIaasDeployments.forEach(deployment -> {
deployment.getTask().removeDeployment(deployment); deployment.getTask().removeDeployment(deployment);
EntityManagerHelper.persist(deployment.getTask()); EntityManagerHelper.persist(deployment.getTask());
deployment.getPaCloud().removeDeployment(deployment); deployment.getPaCloud().removeDeployment(deployment);
EntityManagerHelper.persist(deployment.getPaCloud()); EntityManagerHelper.persist(deployment.getPaCloud());
EntityManagerHelper.remove(deployment); EntityManagerHelper.remove(deployment);
break; });
case BYON:
taskByonDeployments.forEach(deployment -> {
deployment.getTask().removeDeployment(deployment); deployment.getTask().removeDeployment(deployment);
EntityManagerHelper.persist(deployment.getTask()); EntityManagerHelper.persist(deployment.getTask());
EntityManagerHelper.remove(deployment); EntityManagerHelper.remove(deployment);
break;
}
}); });
removeNodes(iaasNodesToBeRemoved,true); removeNodes(iaasNodesToBeRemoved,true);
...@@ -960,6 +964,12 @@ public class PAGateway { ...@@ -960,6 +964,12 @@ public class PAGateway {
//////////////////////////////////////////////// ////////////////////////////////////////////////
}); });
job.setSubmittedJobType(SubmittedJobType.STOP);
//TODO: This should be updated if a stopping workflow will be submitted in future.
// Please think of the impact of this on PaGateway.getJobState()
// job.setSubmittedJobId(0L);
EntityManagerHelper.persist(job);
EntityManagerHelper.commit(); EntityManagerHelper.commit();
// This is kept for future improvement. // This is kept for future improvement.
...@@ -1846,8 +1856,11 @@ public class PAGateway { ...@@ -1846,8 +1856,11 @@ public class PAGateway {
Job submittedJob = optJob.get(); Job submittedJob = optJob.get();
LOGGER.info("Job " + jobId + " mapped to the submitted ProActive job: " + submittedJob.getSubmittedJobId() + LOGGER.info("Job " + jobId + " mapped to the submitted ProActive job: " + submittedJob.getSubmittedJobId() +
" of type: " + submittedJob.getSubmittedJobType().toString()); " of type: " + submittedJob.getSubmittedJobType().toString());
JobState jobState = schedulerGateway.getJobState(String.valueOf(submittedJob.getSubmittedJobId())); JobState jobState = null;
if (submittedJob.getSubmittedJobId() != 0L) {
jobState = schedulerGateway.getJobState(String.valueOf(submittedJob.getSubmittedJobId()));
LOGGER.info("Returned state: " + jobState.getStatus().toString() + " for job: " + jobId); LOGGER.info("Returned state: " + jobState.getStatus().toString() + " for job: " + jobId);
}
return Pair.of(submittedJob.getSubmittedJobType(), jobState); return Pair.of(submittedJob.getSubmittedJobType(), jobState);
} }
......
Supports Markdown
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