Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Melodic
morphemic-preprocessor
Commits
8dd96394
Commit
8dd96394
authored
Aug 20, 2021
by
Mohamed Khalil Labidi
Browse files
Merge branch 'stop-job' into 'proactive-dev'
Add stopJob and stopJobs endpoint to SAL See merge request
!138
parents
774673a3
4f9ad381
Changes
1
Hide whitespace changes
Inline
Side-by-side
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java
View file @
8dd96394
...
...
@@ -901,7 +901,70 @@ public class PAGateway {
* @param jobIDs List of job IDs to stop
*/
public
void
stopJobs
(
List
<
String
>
jobIDs
)
{
//TODO
jobIDs
.
forEach
(
this
::
stopJob
);
}
/**
* Stop the deployed job
* @param jobId A deployed job identifier
* @return The submitted stopping job id
*/
public
long
stopJob
(
String
jobId
)
{
LOGGER
.
info
(
"Stopping job "
+
jobId
);
Optional
<
Job
>
optJob
=
Optional
.
ofNullable
(
EntityManagerHelper
.
find
(
Job
.
class
,
jobId
));
if
(!
optJob
.
isPresent
())
{
LOGGER
.
error
(
String
.
format
(
"Job [%s] not found"
,
jobId
));
return
0L
;
}
Job
job
=
optJob
.
get
();
EntityManagerHelper
.
begin
();
job
.
getTasks
().
forEach
(
task
->
{
List
<
String
>
iaasNodesToBeRemoved
=
task
.
getDeployments
().
stream
()
.
filter
(
deployment
->
NodeType
.
IAAS
.
equals
(
deployment
.
getDeploymentType
()))
.
filter
(
Deployment:
:
getIsDeployed
)
.
map
(
Deployment:
:
getNodeName
)
.
collect
(
Collectors
.
toList
());
List
<
String
>
byonNodesToBeRemoved
=
task
.
getDeployments
().
stream
()
.
filter
(
deployment
->
NodeType
.
BYON
.
equals
(
deployment
.
getDeploymentType
()))
.
filter
(
Deployment:
:
getIsDeployed
)
.
map
(
Deployment:
:
getNodeName
)
.
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
;
}
});
removeNodes
(
iaasNodesToBeRemoved
,
true
);
////////////////////////////////////////////////
// Is that correct ???
// Should we just delete the token set on the node ???
removeNodes
(
byonNodesToBeRemoved
,
true
);
// To verify the behavior needed in upperware.
// If we don't remove BYON nodes we should stop the component in it with a script.
////////////////////////////////////////////////
});
EntityManagerHelper
.
commit
();
// This is kept for future improvement.
// It is in case we want to return the submitted stopping job's ID
return
0L
;
}
private
void
updateNodeCandidatesAsync
(
List
<
String
>
newCloudIds
)
{
...
...
@@ -1768,16 +1831,6 @@ public class PAGateway {
return
(
submittedJobId
);
}
/**
* Stop the deployed job
* @param jobId A deployed job identifier
* @return The submitted stopping job id
*/
public
long
stopJob
(
String
jobId
)
{
//TODO: Submit stopping scripts for all apps
return
0L
;
}
/**
* Get a ProActive job state
* @param jobId A job ID
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment