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

Merge branch 'improve-stop' into 'proactive-dev'

Improve stopJob endpoint in SAL

See merge request !139
parents 8dd96394 441b49a6
......@@ -931,22 +931,26 @@ public class PAGateway {
.map(Deployment::getNodeName)
.collect(Collectors.toList());
List<Deployment> taskIaasDeployments = task.getDeployments().stream()
.filter(deployment -> NodeType.IAAS.equals(deployment.getDeploymentType()))
.collect(Collectors.toList());
task.getDeployments().forEach(deployment -> {
switch (deployment.getDeploymentType()) {
case IAAS:
deployment.getTask().removeDeployment(deployment);
EntityManagerHelper.persist(deployment.getTask());
deployment.getPaCloud().removeDeployment(deployment);
EntityManagerHelper.persist(deployment.getPaCloud());
EntityManagerHelper.remove(deployment);
break;
case BYON:
deployment.getTask().removeDeployment(deployment);
EntityManagerHelper.persist(deployment.getTask());
EntityManagerHelper.remove(deployment);
break;
}
List<Deployment> taskByonDeployments = task.getDeployments().stream()
.filter(deployment -> NodeType.BYON.equals(deployment.getDeploymentType()))
.collect(Collectors.toList());
taskIaasDeployments.forEach(deployment -> {
deployment.getTask().removeDeployment(deployment);
EntityManagerHelper.persist(deployment.getTask());
deployment.getPaCloud().removeDeployment(deployment);
EntityManagerHelper.persist(deployment.getPaCloud());
EntityManagerHelper.remove(deployment);
});
taskByonDeployments.forEach(deployment -> {
deployment.getTask().removeDeployment(deployment);
EntityManagerHelper.persist(deployment.getTask());
EntityManagerHelper.remove(deployment);
});
removeNodes(iaasNodesToBeRemoved,true);
......@@ -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();
// This is kept for future improvement.
......@@ -1846,8 +1856,11 @@ public class PAGateway {
Job submittedJob = optJob.get();
LOGGER.info("Job " + jobId + " mapped to the submitted ProActive job: " + submittedJob.getSubmittedJobId() +
" of type: " + submittedJob.getSubmittedJobType().toString());
JobState jobState = schedulerGateway.getJobState(String.valueOf(submittedJob.getSubmittedJobId()));
LOGGER.info("Returned state: " + jobState.getStatus().toString() + " for job: " + jobId);
JobState jobState = null;
if (submittedJob.getSubmittedJobId() != 0L) {
jobState = schedulerGateway.getJobState(String.valueOf(submittedJob.getSubmittedJobId()));
LOGGER.info("Returned state: " + jobState.getStatus().toString() + " for job: " + jobId);
}
return Pair.of(submittedJob.getSubmittedJobType(), jobState);
}
......
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