Commit 99582d13 authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Adding logging verbose to debug node candidates calculation

parent 97062ef8
......@@ -38,7 +38,7 @@ public class PAConnectorIaasGateway {
public JSONArray getNodeCandidates(String nodeSourceName, String region, String imageReq) {
Validate.notNull(nodeSourceName, "nodeSourceName must not be null");
Validate.notNull(region, "region must not be null");
LOGGER.debug("Retrieving node candidates for cloud " + nodeSourceName + " region " +
LOGGER.info("Retrieving node candidates for cloud " + nodeSourceName + " region " +
region + " and imageReq " + imageReq);
JSONArray nodeCandidates = null;
......@@ -50,7 +50,7 @@ public class PAConnectorIaasGateway {
HttpURLConnection connection = (HttpURLConnection) requestUri.toURL().openConnection();
connection.setRequestMethod(HttpMethod.POST.toString());
LOGGER.debug("requestUri = " + requestUri.toString());
LOGGER.info("requestUri = " + requestUri.toString());
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
LOGGER.warn("Failed : HTTP error code : " + connection.getResponseCode());
......@@ -61,7 +61,7 @@ public class PAConnectorIaasGateway {
(connection.getInputStream())));
nodeCandidates = new JSONArray(new JSONTokener(br));
LOGGER.debug("Node candidates retrieved for successfully: " + nodeCandidates.toString());
LOGGER.info("Node candidates retrieved for successfully: " + nodeCandidates.toString());
connection.disconnect();
......@@ -71,7 +71,7 @@ public class PAConnectorIaasGateway {
@SneakyThrows
public JSONArray getImages(String nodeSourceName) {
Validate.notNull(nodeSourceName, "nodeSourceName must not be null");
LOGGER.debug("Retrieving images for cloud " + nodeSourceName);
LOGGER.info("Retrieving images for cloud " + nodeSourceName);
JSONArray images = null;
URIBuilder uriBuilder = new URIBuilder(new URL(paURL).toURI());
......@@ -80,7 +80,7 @@ public class PAConnectorIaasGateway {
HttpURLConnection connection = (HttpURLConnection) requestUri.toURL().openConnection();
connection.setRequestMethod(HttpMethod.GET.toString());
LOGGER.debug("requestUri = " + requestUri.toString());
LOGGER.info("requestUri = " + requestUri.toString());
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
LOGGER.warn("Failed : HTTP error code : " + connection.getResponseCode());
......@@ -91,7 +91,7 @@ public class PAConnectorIaasGateway {
(connection.getInputStream())));
images = new JSONArray(new JSONTokener(br));
LOGGER.debug("Images retrieved for cloud " + nodeSourceName + ". Images: " + images.toString());
LOGGER.info("Images retrieved for cloud " + nodeSourceName + ". Images: " + images.toString());
connection.disconnect();
......
......@@ -131,6 +131,7 @@ public class NodeCandidateUtils {
}
private Location createLocation(JSONObject nodeCandidateJSON, PACloud paCloud) {
LOGGER.info("Creating location ...");
String locationId = paCloud.getCloudID() + "/" + nodeCandidateJSON.optString("region");
Location location = em.find(Location.class, locationId);
if (location == null) {
......@@ -142,7 +143,7 @@ public class NodeCandidateUtils {
location.setIsAssignable(true);
location.setGeoLocation(createGeoLocation(paCloud.getCloudProviderName(), location.getName()));
}
LOGGER.info("Location created: " + location.toString());
return location;
}
......@@ -205,6 +206,7 @@ public class NodeCandidateUtils {
}
public NodeCandidate createNodeCandidate(JSONObject nodeCandidateJSON, JSONObject imageJSON, PACloud paCloud) {
LOGGER.info("Creating node candidate ...");
NodeCandidate nodeCandidate = new NodeCandidate();
nodeCandidate.setNodeCandidateType(NodeCandidate.NodeCandidateTypeEnum.IAAS);
nodeCandidate.setPrice(nodeCandidateJSON.optDouble("price"));
......@@ -217,7 +219,7 @@ public class NodeCandidateUtils {
nodeCandidate.setPricePerInvocation((double) 0);
nodeCandidate.setMemoryPrice((double) 0);
nodeCandidate.setEnvironment(new Environment());
LOGGER.info("Node candidate created: " + nodeCandidate.toString());
return nodeCandidate;
}
......@@ -226,10 +228,15 @@ public class NodeCandidateUtils {
newCloudIds.forEach(newCloudId -> {
PACloud paCloud = em.find(PACloud.class, newCloudId);
LOGGER.info("Getting blacklisted regions...");
List<String> blacklistedRegions = Arrays.asList(paCloud.getBlacklist().split(","));
LOGGER.info("Blacklisted regions: " + blacklistedRegions.toString());
LOGGER.info("Getting images from Proactive ...");
JSONArray images = connectorIaasGateway.getImages(paCloud.getDummyInfrastructureName());
LOGGER.info("Returned images: " + images.toString());
List<JSONObject> consolidatedImages = images.toList().parallelStream().map(o -> (JSONObject) o).filter(record -> !blacklistedRegions.contains(record.get("location"))).collect(Collectors.toList());
LOGGER.info("Consolidated images: " + consolidatedImages.toString());
//TODO: (Optimization) An images per region map structure <region,[image1,image2]> could be the best here.
// It can reduce the getNodeCandidates calls to PA.
......
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