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
0a547056
Commit
0a547056
authored
Apr 14, 2022
by
Mohamed Khalil Labidi
Browse files
Adding loggers to debug filtering node candidates
parent
11e1e871
Changes
5
Hide whitespace changes
Inline
Side-by-side
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java
View file @
0a547056
...
...
@@ -345,11 +345,14 @@ public class PAGateway {
List
<
NodeCandidate
>
allNodeCandidates
=
EntityManagerHelper
.
createQuery
(
"SELECT nc FROM NodeCandidate nc"
,
NodeCandidate
.
class
).
getResultList
();
allNodeCandidates
.
forEach
(
nodeCandidate
->
{
LOGGER
.
info
(
"Checking node candidate with type: {}"
,
nodeCandidate
.
getHardware
().
getName
());
if
(
nodeCandidate
.
isByonNodeCandidate
()
||
JCloudsInstancesUtils
.
isHandledHardwareInstanceType
(
nodeCandidate
.
getCloud
().
getApi
().
getProviderName
(),
nodeCandidate
.
getHardware
().
getName
())
||
WhiteListedInstanceTypesUtils
.
isHandledHardwareInstanceType
(
nodeCandidate
.
getHardware
().
getName
()))
{
LOGGER
.
info
(
" Checking filters for node candidate with type: {} ..."
,
nodeCandidate
.
getHardware
().
getName
());
if
(
NodeCandidateUtils
.
verifyAllFilters
(
requirements
,
nodeCandidate
))
{
LOGGER
.
info
(
" Requirements answered. Success!"
);
filteredNodeCandidates
.
add
(
nodeCandidate
);
}
}
...
...
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/model/NodeCandidate.java
View file @
0a547056
...
...
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import
com.fasterxml.jackson.annotation.JsonValue
;
import
lombok.AllArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.activeeon.morphemic.service.EntityManagerHelper
;
import
org.hibernate.annotations.GenericGenerator
;
...
...
@@ -19,6 +20,7 @@ import java.util.Optional;
/**
* A node creatable by the system
*/
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
@Entity
...
...
@@ -301,7 +303,13 @@ public class NodeCandidate implements Serializable {
* @return true if yes, false if not
*/
public
boolean
isByonNodeCandidate
()
{
return
nodeCandidateType
.
value
.
equals
(
"BYON"
);
if
(
nodeCandidateType
.
value
.
equals
(
"BYON"
))
{
LOGGER
.
info
(
" Is BYON: YES"
);
return
true
;
}
else
{
LOGGER
.
info
(
" Is BYON: NO"
);
return
false
;
}
}
/**
...
...
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/nc/NodeCandidateUtils.java
View file @
0a547056
...
...
@@ -50,18 +50,23 @@ public class NodeCandidateUtils {
public
static
boolean
verifyAllFilters
(
List
<
Requirement
>
requirements
,
NodeCandidate
nodeCandidate
)
{
if
(
requirements
==
null
||
requirements
.
isEmpty
())
{
LOGGER
.
info
(
" Satisfy all requirements!!!"
);
return
true
;
}
if
(
requirements
.
get
(
0
)
instanceof
NodeTypeRequirement
)
{
if
(
satisfyNodeTypeRequirement
((
NodeTypeRequirement
)
requirements
.
get
(
0
),
nodeCandidate
))
{
LOGGER
.
info
(
" satisfyNodeTypeRequirement: YES"
);
return
verifyAllFilters
(
requirements
.
subList
(
1
,
requirements
.
size
()),
nodeCandidate
);
}
LOGGER
.
info
(
" satisfyNodeTypeRequirement: NO"
);
return
false
;
}
if
(
requirements
.
get
(
0
)
instanceof
AttributeRequirement
)
{
if
(
satisfyAttributeRequirement
((
AttributeRequirement
)
requirements
.
get
(
0
),
nodeCandidate
))
{
LOGGER
.
info
(
" satisfyAttributeRequirement: YES"
);
return
verifyAllFilters
(
requirements
.
subList
(
1
,
requirements
.
size
()),
nodeCandidate
);
}
LOGGER
.
info
(
" satisfyAttributeRequirement: YES"
);
return
false
;
}
LOGGER
.
warn
(
"Unknown requirement type. It could not be applied: "
+
requirements
.
get
(
0
).
toString
());
...
...
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/nc/WhiteListedInstanceTypesUtils.java
View file @
0a547056
package
org.activeeon.morphemic.nc
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
public
class
WhiteListedInstanceTypesUtils
{
/**
...
...
@@ -8,6 +11,12 @@ public class WhiteListedInstanceTypesUtils {
* @return True if the instance type family is while listed, false otherwise
*/
public
static
boolean
isHandledHardwareInstanceType
(
String
instanceType
)
{
return
AwsWhiteListedInstanceTypes
.
isAwsWhiteListedHardwareInstanceType
(
instanceType
);
if
(
AwsWhiteListedInstanceTypes
.
isAwsWhiteListedHardwareInstanceType
(
instanceType
))
{
LOGGER
.
info
(
" Is aws white list family: YES"
);
return
true
;
}
else
{
LOGGER
.
info
(
" Is aws white list family: NO"
);
return
false
;
}
}
}
scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/JCloudsInstancesUtils.java
View file @
0a547056
...
...
@@ -35,8 +35,15 @@ public class JCloudsInstancesUtils {
*/
public
static
boolean
isHandledHardwareInstanceType
(
String
providerName
,
String
instanceType
)
{
if
(
"aws-ec2"
.
equals
(
providerName
))
return
handledAWSInstanceTypes
.
contains
(
instanceType
);
if
(
handledAWSInstanceTypes
.
contains
(
instanceType
))
{
LOGGER
.
info
(
" Is aws handled by JClouds: YES"
);
return
true
;
}
else
{
LOGGER
.
info
(
" Is aws handled by JClouds: NO"
);
return
false
;
}
// TODO: To check if for other cloud providers all instance types are handled by JClouds
LOGGER
.
info
(
" Is handled by JClouds: YES"
);
return
true
;
}
}
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