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
9eda6b26
Commit
9eda6b26
authored
Jul 29, 2021
by
Ali Fahs
Browse files
adding the undeploy and remove NS function
parent
cd014c46
Pipeline
#15139
passed with stage
in 1 minute and 7 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java
View file @
9eda6b26
...
@@ -690,6 +690,9 @@ public class PAGateway {
...
@@ -690,6 +690,9 @@ public class PAGateway {
ByonNode
byonNode
=
EntityManagerHelper
.
find
(
ByonNode
.
class
,
byonNodeId
);
ByonNode
byonNode
=
EntityManagerHelper
.
find
(
ByonNode
.
class
,
byonNodeId
);
Task
task
=
EntityManagerHelper
.
find
(
Task
.
class
,
componentId
);
Task
task
=
EntityManagerHelper
.
find
(
Task
.
class
,
componentId
);
assert
byonNode
!=
null
:
"The BYON ID passed in the mapping does not exist in the database"
;
assert
task
!=
null
:
"The componentId passed in the mapping does not exist in the database"
;
Deployment
newDeployment
=
new
Deployment
();
Deployment
newDeployment
=
new
Deployment
();
newDeployment
.
setNodeName
(
byonNode
.
getName
());
newDeployment
.
setNodeName
(
byonNode
.
getName
());
newDeployment
.
setDeploymentType
(
NodeType
.
BYON
);
newDeployment
.
setDeploymentType
(
NodeType
.
BYON
);
...
@@ -697,8 +700,9 @@ public class PAGateway {
...
@@ -697,8 +700,9 @@ public class PAGateway {
List
<
ByonNode
>
byonNodeList
=
new
LinkedList
<>();
List
<
ByonNode
>
byonNodeList
=
new
LinkedList
<>();
byonNodeList
.
add
(
byonNode
);
byonNodeList
.
add
(
byonNode
);
defineByonNodeSource
(
byonNodeList
,
"BYON_NS_"
+
jobId
);
LOGGER
.
info
(
"BYON node Added: "
+
byonNode
.
getName
()
+
" Ip: "
+
byonNode
.
getIpAddresses
().
get
(
0
).
getValue
()
);
LOGGER
.
info
(
"BYON node source defined."
);
defineByonNodeSource
(
byonNodeList
,
"BYON_NS_"
+
byonNode
.
getId
());
LOGGER
.
info
(
"BYON node source BYON_NS_"
+
byonNode
.
getId
()
+
" is defined"
);
newDeployment
.
setTask
(
task
);
newDeployment
.
setTask
(
task
);
newDeployment
.
setNumber
(
task
.
getNextDeploymentID
());
newDeployment
.
setNumber
(
task
.
getNextDeploymentID
());
...
@@ -712,13 +716,10 @@ public class PAGateway {
...
@@ -712,13 +716,10 @@ public class PAGateway {
EntityManagerHelper
.
commit
();
EntityManagerHelper
.
commit
();
LOGGER
.
info
(
"BYON nodes added properly."
);
LOGGER
.
info
(
"BYON nodes added properly."
);
return
0
;
return
0
;
/*TODO:
* Create node sources per JobID
* */
}
}
/**
/**
* Undeploy clouds
* Undeploy clouds
* @param cloudIDs List of cloud IDs to remove
* @param cloudIDs List of cloud IDs to remove
...
@@ -817,19 +818,59 @@ public class PAGateway {
...
@@ -817,19 +818,59 @@ public class PAGateway {
EntityManagerHelper
.
begin
();
EntityManagerHelper
.
begin
();
ByonNode
byonNode
=
EntityManagerHelper
.
find
(
ByonNode
.
class
,
byonId
);
ByonNode
byonNode
=
EntityManagerHelper
.
find
(
ByonNode
.
class
,
byonId
);
if
(
byonNode
==
null
)
{
if
(
byonNode
==
null
)
{
LOGGER
.
error
(
"The passed BYON ID is not Found in the database"
);
return
false
;
return
false
;
}
}
else
{
else
{
System
.
out
.
println
(
"Deleting the node: "
+
byonNode
.
getId
());
if
(!
undeployByonNs
(
byonNode
,
false
,
true
))
{
LOGGER
.
warn
(
"The BYON node source undeploy finished with errors"
);
}
LOGGER
.
info
(
"Deleting the BYON node "
+
byonNode
.
getId
()
+
" from the database"
);
EntityManagerHelper
.
remove
(
byonNode
);
EntityManagerHelper
.
remove
(
byonNode
);
EntityManagerHelper
.
commit
();
EntityManagerHelper
.
commit
();
return
true
;
}
}
return
true
;
/*TODO:
/*TODO:
*
add logging info when deleting
*
change the hardcoding for preempt and remove variables
* */
* */
}
}
/**
* Undeploy or remove the node source of a BYON node
* @param byonNode an object of class ByonNode to be undeployed or removed.
* @param preempt If true undeploy or remove node source immediately without waiting for nodes to be freed
* @param remove If true completely remove the node source, if false only undeply the node source
* @return true if the resourceManagerGateway return no errors, false otherwise
*/
private
Boolean
undeployByonNs
(
ByonNode
byonNode
,
Boolean
preempt
,
Boolean
remove
)
{
assert
byonNode
!=
null
:
"A null value was passed for byonNode, A node source must have a BYON ID"
;
String
nodeSourceName
=
"BYON_NS_"
+
byonNode
.
getId
();
if
(
remove
)
{
try
{
LOGGER
.
info
(
"Removing BYON node source "
+
nodeSourceName
+
" from the ProActive server"
);
resourceManagerGateway
.
removeNodeSource
(
nodeSourceName
,
preempt
);
}
catch
(
NotConnectedException
|
PermissionRestException
e
)
{
LOGGER
.
error
(
Arrays
.
toString
(
e
.
getStackTrace
()));
return
false
;
}
}
else
{
try
{
LOGGER
.
info
(
"Undeploying BYON node source "
+
nodeSourceName
+
" from the ProActive server"
);
resourceManagerGateway
.
undeployNodeSource
(
nodeSourceName
,
preempt
);
}
catch
(
NotConnectedException
|
PermissionRestException
e
)
{
LOGGER
.
error
(
Arrays
.
toString
(
e
.
getStackTrace
()));
return
false
;
}
}
LOGGER
.
info
(
"BYON node source was removed with no errors"
);
return
true
;
/*TODO:
* Check if the nodes source is present before calling the resourceManagerGateway
*/
}
/**
/**
* Stop jobs
* Stop jobs
* @param jobIDs List of job IDs to stop
* @param jobIDs List of job IDs to stop
...
...
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