Skip to content
GitLab
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
83a99f29
Commit
83a99f29
authored
Jul 15, 2021
by
Mohamed Khalil Labidi
Browse files
Merge branch 'instance-id' into 'proactive-dev'
Add instance ID info support in Deployment class See merge request
!118
parents
a193cb7b
17010dcc
Changes
3
Hide whitespace changes
Inline
Side-by-side
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java
View file @
83a99f29
...
...
@@ -668,6 +668,7 @@ public class PAGateway {
*/
public
List
<
Deployment
>
getAllNodes
()
{
resourceManagerGateway
.
synchronizeDeploymentsIPAddresses
(
schedulerGateway
);
resourceManagerGateway
.
synchronizeDeploymentsInstanceIDs
();
return
EntityManagerHelper
.
createQuery
(
"SELECT d FROM Deployment d"
,
Deployment
.
class
).
getResultList
();
}
...
...
@@ -1000,6 +1001,7 @@ public class PAGateway {
false
,
null
,
null
,
null
,
null
);
})
...
...
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java
View file @
83a99f29
...
...
@@ -343,12 +343,12 @@ public class PAResourceManagerGateway {
deployments
.
parallelStream
().
forEach
(
deployment
->
{
if
(
deployment
.
getIsDeployed
())
{
try
{
List
<
String
>
nodeURLs
=
searchNodes
(
Collections
.
singletonList
(
deployment
.
getNodeName
()),
true
);
if
(!
nodeURLs
.
isEmpty
())
{
if
(
deployment
.
getIpAddress
()
!=
null
)
{
LOGGER
.
info
(
"Deployment "
+
deployment
.
getNodeName
()
+
"already synchronized. IP: "
+
deployment
.
getIpAddress
()
);
}
else
{
if
(
deployment
.
getIpAddress
()
!=
null
)
{
LOGGER
.
info
(
"Deployment "
+
deployment
.
getNodeName
()
+
"already synchronized. IP: "
+
deployment
.
getIpAddress
()
);
}
else
{
List
<
String
>
nodeURLs
=
searchNodes
(
Collections
.
singletonList
(
deployment
.
getNodeName
()),
true
);
if
(!
nodeURLs
.
isEmpty
())
{
TaskFlowJob
paIPJob
=
createIPAddrGetterWorkflow
(
deployment
);
if
(!
paIPJob
.
getTasks
().
isEmpty
())
{
long
submittedJobId
=
schedulerGateway
.
submit
(
paIPJob
).
longValue
();
...
...
@@ -366,9 +366,9 @@ public class PAResourceManagerGateway {
deployment
.
setIpAddress
(
ipAddress
);
EntityManagerHelper
.
persist
(
deployment
);
}
}
else
{
LOGGER
.
warn
(
"The node "
+
deployment
.
getNodeName
()
+
" is not reachable in RM."
);
}
}
else
{
LOGGER
.
warn
(
"The node "
+
deployment
.
getNodeName
()
+
" is not reachable in RM."
);
}
}
catch
(
NotConnectedException
nce
)
{
LOGGER
.
error
(
"ERROR: Not able to search for a node due to a NotConnectedException: "
+
Arrays
.
toString
(
nce
.
getStackTrace
()));
...
...
@@ -398,4 +398,34 @@ public class PAResourceManagerGateway {
LOGGER
.
info
(
"Job created: "
+
paJob
.
toString
());
return
paJob
;
}
public
void
synchronizeDeploymentsInstanceIDs
()
{
List
<
Deployment
>
deployments
=
EntityManagerHelper
.
createQuery
(
"SELECT d FROM Deployment d"
,
Deployment
.
class
).
getResultList
();
EntityManagerHelper
.
begin
();
deployments
.
parallelStream
().
forEach
(
deployment
->
{
if
(
deployment
.
getIsDeployed
())
{
try
{
if
(
deployment
.
getInstanceId
()
!=
null
)
{
LOGGER
.
info
(
"Deployment "
+
deployment
.
getNodeName
()
+
" already synchronized. Instance ID: "
+
deployment
.
getInstanceId
());
}
else
{
List
<
String
>
nodeURLs
=
searchNodes
(
Collections
.
singletonList
(
deployment
.
getNodeName
()),
true
);
if
(!
nodeURLs
.
isEmpty
())
{
String
instanceId
=
nodeURLs
.
get
(
0
).
substring
(
nodeURLs
.
get
(
0
).
lastIndexOf
(
"__"
)
+
2
);
deployment
.
setInstanceId
(
instanceId
);
EntityManagerHelper
.
persist
(
deployment
);
LOGGER
.
info
(
"Deployment "
+
deployment
.
getNodeName
()
+
"instance ID set to: "
+
instanceId
);
}
else
{
LOGGER
.
warn
(
"The node "
+
deployment
.
getNodeName
()
+
" is not reachable in RM."
);
}
}
}
catch
(
NotConnectedException
nce
)
{
LOGGER
.
error
(
"ERROR: Not able to search for a node due to a NotConnectedException: "
+
Arrays
.
toString
(
nce
.
getStackTrace
()));
}
catch
(
RestException
re
)
{
LOGGER
.
error
(
"ERROR: Not able to search for a node due to a RestException: "
+
Arrays
.
toString
(
re
.
getStackTrace
()));
}
}
});
EntityManagerHelper
.
commit
();
}
}
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/model/Deployment.java
View file @
83a99f29
...
...
@@ -47,6 +47,9 @@ public class Deployment implements Serializable {
@Column
(
name
=
"NUMBER"
)
private
Long
number
;
@Column
(
name
=
"INSTANCE_ID"
)
private
String
instanceId
;
@Embedded
private
IpAddress
ipAddress
=
null
;
...
...
@@ -58,6 +61,7 @@ public class Deployment implements Serializable {
", imageProviderId='"
+
imageProviderId
+
'\''
+
", hardwareProviderId='"
+
hardwareProviderId
+
'\''
+
", isDeployed='"
+
isDeployed
.
toString
()
+
'\''
+
", instanceId='"
+
instanceId
+
'\''
+
", ipAddress='"
+
ipAddress
+
'\''
+
", nodeAccessToken='"
+
nodeAccessToken
+
'\''
+
", number='"
+
number
+
'\''
+
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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