Commit 0a547056 authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Adding loggers to debug filtering node candidates

parent 11e1e871
......@@ -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);
}
}
......
......@@ -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;
}
}
/**
......
......@@ -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());
......
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;
}
}
}
......@@ -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;
}
}
Supports Markdown
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