From 550d5586eef1a489a56338dd6bd8a3261b7a2c65 Mon Sep 17 00:00:00 2001 From: Ali_fahs Date: Wed, 8 Dec 2021 11:21:58 +0100 Subject: [PATCH 01/10] Improving the node source deletion --- .../org/activeeon/morphemic/PAGateway.java | 40 +---------------- .../deployment/PAResourceManagerGateway.java | 39 ++++++++++++++++ .../morphemic/service/ByonUtils.java | 45 +++++++++++++++++++ 3 files changed, 86 insertions(+), 38 deletions(-) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java index 9eec3019..eb74d305 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java @@ -831,7 +831,7 @@ public class PAGateway { ByonNode byonNode = EntityManagerHelper.find(ByonNode.class, byonId); if (byonNode == null) { LOGGER.error("The passed BYON ID is not Found in the database"); - return false; + throw new IllegalArgumentException("The passed BYON ID \"" + byonId + "\" is not Found in the database"); } LOGGER.info("Deleting the corresponding PACloud from the database ..."); @@ -848,7 +848,7 @@ public class PAGateway { LOGGER.warn("The PACloud related to the byonNode {} is not found.", byonNode.getName()); } - if(!undeployByonNs(byonNode, false, true)) { + if(!ByonUtils.undeployByonNs(byonNode, false, true)) { LOGGER.warn("The BYON node source undeploy finished with errors!"); } @@ -862,42 +862,6 @@ public class PAGateway { * */ } - /** - * 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 - */ - } - /** * Kill all active jobs in ProActive Scheduler */ diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java index a48a835e..fcdfa4c4 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java @@ -13,6 +13,7 @@ import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.conn.util.InetAddressUtils; import org.ow2.proactive.resourcemanager.common.NSState; import org.ow2.proactive.resourcemanager.common.event.RMNodeEvent; +import org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent; import org.ow2.proactive.resourcemanager.common.event.dto.RMStateFull; import org.ow2.proactive.resourcemanager.exception.RMException; import org.ow2.proactive.resourcemanager.exception.RMNodeException; @@ -462,4 +463,42 @@ public class PAResourceManagerGateway { }); EntityManagerHelper.commit(); } + /** + * get all the node sources in ProActive resource manager + * @param status defines the status of node sources to be returned, can take ["deployed", "undeployed", "all"] + * @return listNodeSources a sorted string list of names of the deployed node sources + * @throws NotConnectedException In case the user is not connected + * @throws PermissionRestException In case the user does not have valid permissions + */ + public List getNodeSources(String status) throws NotConnectedException, PermissionRestException { + LOGGER.info("Getting the node sources names from the resource manager"); + List listDeployedNodeSources = new ArrayList<>(); + List listUndeployedNodeSources = new ArrayList<>(); + RMStateFull rmState = getFullMonitoring(); + List listNodeSourceEvents = rmState.getNodeSource(); + listNodeSourceEvents.forEach(nodeSourceEvent -> { + if (nodeSourceEvent.getNodeSourceStatus().equals("deployed")) { + listDeployedNodeSources.add(nodeSourceEvent.getNodeSourceName()); + } + else { + listUndeployedNodeSources.add(nodeSourceEvent.getNodeSourceName()); + } + } ); + LOGGER.info("Returning " + status +" node sources names from the resource manager"); + if(status.equals("deployed")) { + Collections.sort(listDeployedNodeSources,String.CASE_INSENSITIVE_ORDER); + return listDeployedNodeSources; + } + if(status.equals("undeployed")){ + Collections.sort(listUndeployedNodeSources,String.CASE_INSENSITIVE_ORDER); + return listUndeployedNodeSources; + } + if(status.equals("all")) { + listDeployedNodeSources.addAll(listUndeployedNodeSources); + Collections.sort(listDeployedNodeSources, String.CASE_INSENSITIVE_ORDER); + return listDeployedNodeSources; + } + LOGGER.error("The passed status \"" + status + "\"is incorrect"); + throw new IllegalArgumentException("The passed status \"" + status + "\" is incorrect"); + } } diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java index 4ced1c52..5c448d69 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java @@ -4,7 +4,10 @@ import lombok.extern.slf4j.Slf4j; import org.activeeon.morphemic.infrastructure.deployment.PAResourceManagerGateway; import org.activeeon.morphemic.model.*; import org.apache.commons.lang3.RandomStringUtils; +import org.ow2.proactive.scheduler.common.exception.NotConnectedException; +import org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException; +import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Optional; @@ -149,4 +152,46 @@ public class ByonUtils { LOGGER.info("The hostname is retrieved successfully: " + nodeHostnames.get(0)); return nodeHostnames.get(0); } + + /** + * 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 + */ + public static 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"); + if(resourceManagerGateway.getNodeSources("all").contains(nodeSourceName)) { + resourceManagerGateway.removeNodeSource(nodeSourceName, preempt); + } + else{ + LOGGER.warn("The node source \""+ nodeSourceName+"\" does not exist in the RM"); + } + } 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"); + if(resourceManagerGateway.getNodeSources("deployed").contains(nodeSourceName)) { + resourceManagerGateway.undeployNodeSource(nodeSourceName, preempt); + } + else{ + LOGGER.warn("The node source \""+ nodeSourceName+"\" is not deployed in the RM"); + } + } catch (NotConnectedException | PermissionRestException e) { + LOGGER.error(Arrays.toString(e.getStackTrace())); + return false; + } + } + LOGGER.info("BYON node source was removed with no errors"); + return true; + } } -- GitLab From ec1bae616ad086a5a2fa49f1b1cf801cb8940c56 Mon Sep 17 00:00:00 2001 From: mklkun Date: Wed, 8 Dec 2021 11:58:24 +0100 Subject: [PATCH 02/10] Improve getNodeSources method --- .../deployment/PAResourceManagerGateway.java | 38 ++++--------------- .../morphemic/service/ByonUtils.java | 4 +- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java index fcdfa4c4..372ec038 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java @@ -30,6 +30,7 @@ import javax.security.auth.login.LoginException; import java.security.KeyException; import java.util.*; import java.util.concurrent.*; +import java.util.stream.Collectors; @Slf4j public class PAResourceManagerGateway { @@ -464,41 +465,16 @@ public class PAResourceManagerGateway { EntityManagerHelper.commit(); } /** - * get all the node sources in ProActive resource manager + * Get a list of node source names in a given status from the ProActive Resource Manager * @param status defines the status of node sources to be returned, can take ["deployed", "undeployed", "all"] - * @return listNodeSources a sorted string list of names of the deployed node sources + * @return listNodeSourceNames a string list of names of the deployed node sources * @throws NotConnectedException In case the user is not connected * @throws PermissionRestException In case the user does not have valid permissions */ - public List getNodeSources(String status) throws NotConnectedException, PermissionRestException { + public List getNodeSourceNames(String status) throws NotConnectedException, PermissionRestException { LOGGER.info("Getting the node sources names from the resource manager"); - List listDeployedNodeSources = new ArrayList<>(); - List listUndeployedNodeSources = new ArrayList<>(); - RMStateFull rmState = getFullMonitoring(); - List listNodeSourceEvents = rmState.getNodeSource(); - listNodeSourceEvents.forEach(nodeSourceEvent -> { - if (nodeSourceEvent.getNodeSourceStatus().equals("deployed")) { - listDeployedNodeSources.add(nodeSourceEvent.getNodeSourceName()); - } - else { - listUndeployedNodeSources.add(nodeSourceEvent.getNodeSourceName()); - } - } ); - LOGGER.info("Returning " + status +" node sources names from the resource manager"); - if(status.equals("deployed")) { - Collections.sort(listDeployedNodeSources,String.CASE_INSENSITIVE_ORDER); - return listDeployedNodeSources; - } - if(status.equals("undeployed")){ - Collections.sort(listUndeployedNodeSources,String.CASE_INSENSITIVE_ORDER); - return listUndeployedNodeSources; - } - if(status.equals("all")) { - listDeployedNodeSources.addAll(listUndeployedNodeSources); - Collections.sort(listDeployedNodeSources, String.CASE_INSENSITIVE_ORDER); - return listDeployedNodeSources; - } - LOGGER.error("The passed status \"" + status + "\"is incorrect"); - throw new IllegalArgumentException("The passed status \"" + status + "\" is incorrect"); + return getFullMonitoring().getNodeSource().stream() + .filter(nodeSourceEvent -> nodeSourceEvent.getNodeSourceStatus().equals(status) || status.equals("all")) + .map(RMNodeSourceEvent::getNodeSourceName).collect(Collectors.toList()); } } diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java index 5c448d69..af51173b 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java @@ -166,7 +166,7 @@ public class ByonUtils { if (remove) { try { LOGGER.info("Removing BYON node source " + nodeSourceName + " from the ProActive server"); - if(resourceManagerGateway.getNodeSources("all").contains(nodeSourceName)) { + if(resourceManagerGateway.getNodeSourceNames("all").contains(nodeSourceName)) { resourceManagerGateway.removeNodeSource(nodeSourceName, preempt); } else{ @@ -180,7 +180,7 @@ public class ByonUtils { else { try { LOGGER.info("Undeploying BYON node source " + nodeSourceName + " from the ProActive server"); - if(resourceManagerGateway.getNodeSources("deployed").contains(nodeSourceName)) { + if(resourceManagerGateway.getNodeSourceNames("deployed").contains(nodeSourceName)) { resourceManagerGateway.undeployNodeSource(nodeSourceName, preempt); } else{ -- GitLab From ec23691b8aef00c294eba544602269dba39a5cc4 Mon Sep 17 00:00:00 2001 From: Ali_fahs Date: Wed, 8 Dec 2021 14:56:31 +0100 Subject: [PATCH 03/10] Add status check to the getNodeSourceNames method --- .../infrastructure/deployment/PAResourceManagerGateway.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java index 372ec038..1faaba39 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java @@ -473,6 +473,10 @@ public class PAResourceManagerGateway { */ public List getNodeSourceNames(String status) throws NotConnectedException, PermissionRestException { LOGGER.info("Getting the node sources names from the resource manager"); + if (!Arrays.asList("deployed","undeployed","all").contains(status)){ + LOGGER.error("The passed status \"" + status + "\" is incorrect"); + throw new IllegalArgumentException("The passed status \"" + status + "\" is incorrect"); + } return getFullMonitoring().getNodeSource().stream() .filter(nodeSourceEvent -> nodeSourceEvent.getNodeSourceStatus().equals(status) || status.equals("all")) .map(RMNodeSourceEvent::getNodeSourceName).collect(Collectors.toList()); -- GitLab From 20b9cc9ccc3c7e56593b46d08ddbab31bfefcf5d Mon Sep 17 00:00:00 2001 From: Ali_fahs Date: Thu, 9 Dec 2021 03:27:59 +0100 Subject: [PATCH 04/10] Delete the Byon node location, image, and hardware --- .../java/org/activeeon/morphemic/PAGateway.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java index eb74d305..4dff183a 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java @@ -829,6 +829,7 @@ public class PAGateway { public Boolean deleteByonNode(String byonId) { EntityManagerHelper.begin(); ByonNode byonNode = EntityManagerHelper.find(ByonNode.class, byonId); + if (byonNode == null) { LOGGER.error("The passed BYON ID is not Found in the database"); throw new IllegalArgumentException("The passed BYON ID \"" + byonId + "\" is not Found in the database"); @@ -852,9 +853,19 @@ public class PAGateway { LOGGER.warn("The BYON node source undeploy finished with errors!"); } - LOGGER.info("Deleting the BYON node " + byonNode.getId() +" from the database..."); + Location byonLocation = byonNode.getNodeCandidate().getLocation(); + Hardware byonHardware = byonNode.getNodeCandidate().getHardware(); + Image byonImage = byonNode.getNodeCandidate().getImage(); + + LOGGER.info("Removing the BYON node " + byonNode.getId() +" from the database..."); byonNode.setNodeCandidate(null); EntityManagerHelper.remove(byonNode); + LOGGER.info("Removing the BYON Location " + byonLocation.getId() +" from the database..."); + EntityManagerHelper.remove(byonLocation); + LOGGER.info("Removing the BYON Hardware " + byonHardware.getId() +" from the database..."); + EntityManagerHelper.remove(byonHardware); + LOGGER.info("Removing the BYON Image " + byonImage.getId() +" from the database..."); + EntityManagerHelper.remove(byonImage); EntityManagerHelper.commit(); return true; /*TODO: -- GitLab From 975c4a5c8cc91c31206458fe27c7de0dfab57660 Mon Sep 17 00:00:00 2001 From: ali_fahs Date: Mon, 13 Dec 2021 00:32:47 +0100 Subject: [PATCH 05/10] deleting the node from db using ByonUtils class --- .../java/org/activeeon/morphemic/PAGateway.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java index 4dff183a..e5fa6791 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java @@ -852,21 +852,7 @@ public class PAGateway { if(!ByonUtils.undeployByonNs(byonNode, false, true)) { LOGGER.warn("The BYON node source undeploy finished with errors!"); } - - Location byonLocation = byonNode.getNodeCandidate().getLocation(); - Hardware byonHardware = byonNode.getNodeCandidate().getHardware(); - Image byonImage = byonNode.getNodeCandidate().getImage(); - - LOGGER.info("Removing the BYON node " + byonNode.getId() +" from the database..."); - byonNode.setNodeCandidate(null); - EntityManagerHelper.remove(byonNode); - LOGGER.info("Removing the BYON Location " + byonLocation.getId() +" from the database..."); - EntityManagerHelper.remove(byonLocation); - LOGGER.info("Removing the BYON Hardware " + byonHardware.getId() +" from the database..."); - EntityManagerHelper.remove(byonHardware); - LOGGER.info("Removing the BYON Image " + byonImage.getId() +" from the database..."); - EntityManagerHelper.remove(byonImage); - EntityManagerHelper.commit(); + ByonUtils.deleteByonNode(byonNode); return true; /*TODO: * change the hardcoding for preempt and remove variables -- GitLab From a12d128d24cfb673cb8624d7726229c386fcbaf0 Mon Sep 17 00:00:00 2001 From: ali_fahs Date: Mon, 13 Dec 2021 00:32:47 +0100 Subject: [PATCH 06/10] deleting the node from db using ByonUtils class --- .../org/activeeon/morphemic/PAGateway.java | 16 +------------ .../morphemic/service/ByonUtils.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java index 4dff183a..e5fa6791 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java @@ -852,21 +852,7 @@ public class PAGateway { if(!ByonUtils.undeployByonNs(byonNode, false, true)) { LOGGER.warn("The BYON node source undeploy finished with errors!"); } - - Location byonLocation = byonNode.getNodeCandidate().getLocation(); - Hardware byonHardware = byonNode.getNodeCandidate().getHardware(); - Image byonImage = byonNode.getNodeCandidate().getImage(); - - LOGGER.info("Removing the BYON node " + byonNode.getId() +" from the database..."); - byonNode.setNodeCandidate(null); - EntityManagerHelper.remove(byonNode); - LOGGER.info("Removing the BYON Location " + byonLocation.getId() +" from the database..."); - EntityManagerHelper.remove(byonLocation); - LOGGER.info("Removing the BYON Hardware " + byonHardware.getId() +" from the database..."); - EntityManagerHelper.remove(byonHardware); - LOGGER.info("Removing the BYON Image " + byonImage.getId() +" from the database..."); - EntityManagerHelper.remove(byonImage); - EntityManagerHelper.commit(); + ByonUtils.deleteByonNode(byonNode); return true; /*TODO: * change the hardcoding for preempt and remove variables diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java index af51173b..53566dde 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java @@ -194,4 +194,28 @@ public class ByonUtils { LOGGER.info("BYON node source was removed with no errors"); return true; } + + /** + * Deleting the BYON node and its Node candidate from the data base + * @param byonNode an object of class ByonNode to be removed. + */ + public static void deleteByonNode(ByonNode byonNode) { + EntityManagerHelper.begin(); + LOGGER.info("Removing the BYON node " + byonNode.getId() +" from the database..."); + + Location byonLocation = byonNode.getNodeCandidate().getLocation(); + Hardware byonHardware = byonNode.getNodeCandidate().getHardware(); + Image byonImage = byonNode.getNodeCandidate().getImage(); + + LOGGER.info("Removing the BYON Location " + byonLocation.getId() +" from the database..."); + EntityManagerHelper.remove(byonLocation); + LOGGER.info("Removing the BYON Hardware " + byonHardware.getId() +" from the database..."); + EntityManagerHelper.remove(byonHardware); + LOGGER.info("Removing the BYON Image " + byonImage.getId() +" from the database..."); + EntityManagerHelper.remove(byonImage); + + byonNode.setNodeCandidate(null); + EntityManagerHelper.remove(byonNode); + EntityManagerHelper.commit(); + } } -- GitLab From 464e996a31d07b9ec54661c3421800588ffc40e4 Mon Sep 17 00:00:00 2001 From: ali_fahs Date: Wed, 15 Dec 2021 03:44:14 +0100 Subject: [PATCH 07/10] Adding the ability to retreive the node state from RM --- .../infrastructure/deployment/PAResourceManagerGateway.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java index 1faaba39..2c1d3d0d 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java @@ -168,6 +168,9 @@ public class PAResourceManagerGateway { if (option.equals("hostname")) { nodeInfo = rmNodeEvent.getHostName(); } + if (option.equals("state")) { + nodeInfo = rmNodeEvent.getNodeState().toString(); + } if (nodeInfo.equals("none")) { LOGGER.error("A wrong option was passed and the nodeInfo was now changed"); throw new IllegalArgumentException("The option passed \"" + option+ "\" is not found!"); -- GitLab From 5d3895c10453eebcc15852264ec8082ee652278b Mon Sep 17 00:00:00 2001 From: ali_fahs Date: Wed, 15 Dec 2021 03:46:49 +0100 Subject: [PATCH 08/10] changing the Operation of getByonHostName --- .../morphemic/service/ByonUtils.java | 118 +++++++++++++----- 1 file changed, 84 insertions(+), 34 deletions(-) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java index 53566dde..9554fc7c 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java @@ -19,9 +19,9 @@ public class ByonUtils { private ByonUtils() {} - static final int MAX_CONNECTION_RETRIES = 5; + static final int MAX_CONNECTION_RETRIES = 10; - static final int INTERVAL = 5000; + static final int INTERVAL = 20000; public static void init(String paURL) { resourceManagerGateway = new PAResourceManagerGateway(paURL); @@ -109,48 +109,98 @@ public class ByonUtils { */ public static String getBYONHostname(String nsName) { LOGGER.info("Getting the byon node host name for: " + nsName); + List nodeSourcesNames= new LinkedList<>(); + List nodeHostNames = new LinkedList<>(); + List nodeStates = new LinkedList<>(); + int retries =0; + while (retries host name is empty, retrying to get node information"); + } + else + { + return nodeHostNames.get(0); + } + } + } + } + try { + Thread.sleep(INTERVAL); + } + catch (InterruptedException e){ + LOGGER.error("The sleep thread was interrupted"); + } + } + LOGGER.error("The node host name is not retrieved after " + retries+ " retries" ); + throw new IllegalStateException("Node hostname is empty"); + + /* TODO + * change the get getNodeStates and getNodeHostNames to getNodeEvents + * to limit the number of connections to the RM + * nodeStates.get(0) may lead to IndexOutOfRangeException => to be changed + */ + } + + private static List getNodeHostNames(String nsName){ List nodeHostnames = new LinkedList<>(); - int retries=0; try { nodeHostnames = resourceManagerGateway.getAsyncDeployedNodesInformation(nsName, "hostname"); } catch(Exception e) { LOGGER.error(" resourceManagerGateway threw an exception: " + e); } - if (nodeHostnames == null) { - LOGGER.error("The node Source "+ nsName + " Does not have any nodes"); - throw new IllegalStateException("Node source is empty no hostname can be retrieved"); - } - else { - if (nodeHostnames.size() != 1) { - if (nodeHostnames.size() == 0) { - LOGGER.error("The node Source " + nsName + " Does not have any nodes"); - throw new IllegalStateException("Node source is empty no hostname can be retrieved"); - } else { - LOGGER.error("The node Source " + nsName + " has more than one node"); - throw new IllegalStateException("Node source has multiple nodes"); - } - } + return nodeHostnames; + } + + private static List getNodeStates(String nsName){ + List nodeStates = new LinkedList<>(); + try { + nodeStates = resourceManagerGateway.getAsyncDeployedNodesInformation(nsName, "state"); } - while (nodeHostnames.get(0).equals("")) - { - LOGGER.warn("The node host name is empty, retrying to get node information"); - try { - Thread.sleep(INTERVAL); - nodeHostnames = resourceManagerGateway.getAsyncDeployedNodesInformation(nsName, "hostname"); - } - catch(Exception e) { - LOGGER.error(" resourceManagerGateway threw an exception: " + e); - } - if (retries > MAX_CONNECTION_RETRIES) { - LOGGER.error("The node host name is empty after " + retries+ " retries" ); - throw new IllegalStateException("Node hostname is empty"); - } - retries++; + catch(Exception e) { + LOGGER.error(" resourceManagerGateway threw an exception: " + e); } + return nodeStates; + } - LOGGER.info("The hostname is retrieved successfully: " + nodeHostnames.get(0)); - return nodeHostnames.get(0); + private static List getNodeSourcesNames() { + List nodeSourcesNames = new LinkedList<>(); + //Check if the node source exist + try { + nodeSourcesNames = resourceManagerGateway.getNodeSourceNames("deployed"); + } catch (NotConnectedException | PermissionRestException e) { + LOGGER.error(Arrays.toString(e.getStackTrace())); + } + return nodeSourcesNames; } /** -- GitLab From 5bc8d68121c7f56a777f7810746d6ee2c76f92a5 Mon Sep 17 00:00:00 2001 From: ali_fahs Date: Wed, 15 Dec 2021 03:52:24 +0100 Subject: [PATCH 09/10] change the sshinfra timeout --- .../src/main/resources/Define_NS_BYON.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scheduling-abstraction-layer/src/main/resources/Define_NS_BYON.xml b/scheduling-abstraction-layer/src/main/resources/Define_NS_BYON.xml index bd0753f7..f8a3805c 100644 --- a/scheduling-abstraction-layer/src/main/resources/Define_NS_BYON.xml +++ b/scheduling-abstraction-layer/src/main/resources/Define_NS_BYON.xml @@ -66,7 +66,7 @@ println " OK!" //Getting NS configuration settings def infrastructureType = "org.ow2.proactive.resourcemanager.nodesource.infrastructure.SSHInfrastructureV2" -def infrastructureParameters = ["60000", //Node Time out +def infrastructureParameters = ["300000", //Node Time out "5", //Max deployment failure "5000", //wait between Deployment sshPort,//port, //SSH port -- GitLab From 15e0495b9fbf7f8cd7cff518484bda5c20cbd210 Mon Sep 17 00:00:00 2001 From: ali_fahs Date: Wed, 15 Dec 2021 13:10:17 +0100 Subject: [PATCH 10/10] move the RM get function to the RM gateway --- .../deployment/PAResourceManagerGateway.java | 47 +++++++++++++++++++ .../morphemic/service/ByonUtils.java | 39 ++------------- 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java index 2c1d3d0d..cc22fa9b 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java @@ -484,4 +484,51 @@ public class PAResourceManagerGateway { .filter(nodeSourceEvent -> nodeSourceEvent.getNodeSourceStatus().equals(status) || status.equals("all")) .map(RMNodeSourceEvent::getNodeSourceName).collect(Collectors.toList()); } + + + /** + * Get a list of deployed nodes hostnames from the ProActive Resource Manager + * @param nsName a String of the node source name + * @return nodeHostNames a string list of names of the deployed nodes hostnames + */ + public List getNodeHostNames(String nsName){ + List nodeHostNames = new LinkedList<>(); + try { + nodeHostNames = getAsyncDeployedNodesInformation(nsName, "hostname"); + } + catch(Exception e) { + LOGGER.error(" resourceManagerGateway threw an exception: " + e); + } + return nodeHostNames; + } + + /** + * Get a list of deployed nodes states from the ProActive Resource Manager + * @param nsName a String of the node source name + * @return nodeStates a string list of names of the deployed node states + */ + public List getNodeStates(String nsName){ + List nodeStates = new LinkedList<>(); + try { + nodeStates = getAsyncDeployedNodesInformation(nsName, "state"); + } + catch(Exception e) { + LOGGER.error(" resourceManagerGateway threw an exception: " + e); + } + return nodeStates; + } + + /** + * Get a list of deployed nodes sources from the ProActive Resource Manager + * @return nodeSourcesNames a string list of names of the deployed node sources + */ + public List getDeployedNodeSourcesNames() { + List nodeSourcesNames = new LinkedList<>(); + try { + nodeSourcesNames = getNodeSourceNames("deployed"); + } catch (NotConnectedException | PermissionRestException e) { + LOGGER.error(Arrays.toString(e.getStackTrace())); + } + return nodeSourcesNames; + } } diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java index 9554fc7c..fc79d300 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/service/ByonUtils.java @@ -116,14 +116,14 @@ public class ByonUtils { while (retries host name is empty, retrying to get node information"); } else @@ -170,39 +170,6 @@ public class ByonUtils { */ } - private static List getNodeHostNames(String nsName){ - List nodeHostnames = new LinkedList<>(); - try { - nodeHostnames = resourceManagerGateway.getAsyncDeployedNodesInformation(nsName, "hostname"); - } - catch(Exception e) { - LOGGER.error(" resourceManagerGateway threw an exception: " + e); - } - return nodeHostnames; - } - - private static List getNodeStates(String nsName){ - List nodeStates = new LinkedList<>(); - try { - nodeStates = resourceManagerGateway.getAsyncDeployedNodesInformation(nsName, "state"); - } - catch(Exception e) { - LOGGER.error(" resourceManagerGateway threw an exception: " + e); - } - return nodeStates; - } - - private static List getNodeSourcesNames() { - List nodeSourcesNames = new LinkedList<>(); - //Check if the node source exist - try { - nodeSourcesNames = resourceManagerGateway.getNodeSourceNames("deployed"); - } catch (NotConnectedException | PermissionRestException e) { - LOGGER.error(Arrays.toString(e.getStackTrace())); - } - return nodeSourcesNames; - } - /** * Undeploy or remove the node source of a BYON node * @param byonNode an object of class ByonNode to be undeployed or removed. -- GitLab