Commit 9d063cdf authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Merge branch 'morphemic-rc1.5' into 'fix-OS-acquiring'

# Conflicts:
#   scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java
parents 5ec84b7d 5c14bcb3
Pipeline #17442 passed with stage
in 2 minutes and 2 seconds
......@@ -56,6 +56,7 @@ build:amq-message-java-library:
only:
- master
- morphemic-rc1.5
- fix-byon-acquire
script:
- $AMQ_MESSAGE_JAVA_LIBRARY_CLI clean install
artifacts:
......@@ -144,6 +145,7 @@ deploy:scheduling-abstraction-layer:
- master
- morphemic-rc1.5
- proactive-dev
- fix-byon-acquire
dependencies:
- build:scheduling-abstraction-layer
script:
......
......@@ -104,6 +104,9 @@ class Gluonts(morphemic.handler.ModelHandler,messaging.listener.MorphemicListene
#self.model = morphemic.model.Model(self)
def run(self):
#logging.debug("setting up")
#sleep(180)
#logging.debug("starting the connection to ActiveMQ")
self.connector.connect()
self.connector.set_listener(self.id, self)
self.connector.topic("start_forecasting.gluonmachines", self.id)
......@@ -129,7 +132,7 @@ class Gluonts(morphemic.handler.ModelHandler,messaging.listener.MorphemicListene
def on_metrics_to_predict(self, body):
dataset_preprocessor = CSVData(APP_NAME,start_collection='2h')
dataset_preprocessor = CSVData(APP_NAME)
dataset_preprocessor.prepare_csv()
logging.debug("DATASET DOWNLOADED")
......
......@@ -105,7 +105,9 @@ class Prophet(morphemic.handler.ModelHandler,messaging.listener.MorphemicListene
self.connector = messaging.morphemic.Connection(ACTIVEMQ_USER,ACTIVEMQ_PASSWORD, host=ACTIVEMQ_HOSTNAME, port=ACTIVEMQ_PORT)
def run(self):
logging.debug("setting up")
#logging.debug("setting up")
#sleep(180)
#logging.debug("starting the connection to ActiveMQ")
self.connector.connect()
self.connector.set_listener(self.id, self)
self.connector.topic("start_forecasting.prophet", self.id)
......@@ -132,7 +134,7 @@ class Prophet(morphemic.handler.ModelHandler,messaging.listener.MorphemicListene
def on_metrics_to_predict(self, body):
#getting data from datasetmaker
dataset_preprocessor = CSVData(APP_NAME,start_collection='2h')
dataset_preprocessor = CSVData(APP_NAME)
dataset_preprocessor.prepare_csv()
logging.debug("DATASET DOWNLOADED")
......@@ -170,10 +172,7 @@ class Prophet(morphemic.handler.ModelHandler,messaging.listener.MorphemicListene
def start(self):
logging.debug("Staring Prophet Forecaster")
try:
self.run()
except exception.ConnectFailedException:
logging.error("Failed to connect to ActiveMQ. Please check your connection settings.")
self.run()
self._run = True
def on_disconnected(self):
......
......@@ -48,7 +48,7 @@ public class PAResourceManagerGateway {
* @return List of deployed nodes names
* @throws InterruptedException In case the process is interrupted
*/
public List<String> getAsyncDeployedNodesInformation(String nodeSource) throws InterruptedException {
public List<String> getAsyncDeployedNodesInformation(String nodeSource, String option) throws InterruptedException {
ExecutorService executorService = Executors.newSingleThreadExecutor();
Callable<List<String>> callable = () -> {
......@@ -60,14 +60,19 @@ public class PAResourceManagerGateway {
while (!gotResponse && retries <= MAX_CONNECTION_RETRIES) {
try {
Thread.sleep(INTERVAL);
deployedNodes = getDeployedNodesInformation(nodeSource);
deployedNodes = getDeployedNodesInformation(nodeSource, option);
if (!deployedNodes.isEmpty()) {
gotResponse = true;
} else {
retries++;
}
} catch (Exception e) {
retries++;
if(e.getClass().getSimpleName().equals("IllegalArgumentException")) {
throw e;
}
else {
retries++;
}
}
}
if (gotResponse) {
......@@ -86,6 +91,11 @@ public class PAResourceManagerGateway {
}
executorService.shutdown();
return deployedNodes;
/* TODO
* This method throws an error if a node source is deployed with no nodes attached.
* The better approach should be returning an empty list instead of connectTimeoutException.
*/
}
......@@ -135,24 +145,43 @@ public class PAResourceManagerGateway {
/**
* Get deployed nodes names
* @param nodeSource The name of the node source
* @param option needed (either "hostname" or "name")
* @return List of deployed nodes names
* @throws NotConnectedException In case the user is not connected
* @throws PermissionRestException In case the user does not have valid permissions
* @throws IllegalArgumentException if the option passed was not supported
*/
private List<String> getDeployedNodesInformation(String nodeSource) throws NotConnectedException, PermissionRestException {
private List<String> getDeployedNodesInformation(String nodeSource, String option) throws IllegalArgumentException, NotConnectedException, PermissionRestException {
reconnectIfDisconnected();
List<String> deployedNodes = new ArrayList<>();
RMStateFull rmState = getFullMonitoring();
String nodeInfo= "none";
LOGGER.debug("Searching for deployed nodes information ...");
for (RMNodeEvent rmNodeEvent : rmState.getNodesEvents()) {
if (rmNodeEvent.getNodeSource().equals(nodeSource)) {
String nodeUrl = rmNodeEvent.getNodeUrl();
deployedNodes.add(nodeUrl.substring(nodeUrl.lastIndexOf('/') + 1));
if (option.equals("name")) {
nodeInfo = rmNodeEvent.getNodeUrl();
}
if (option.equals("hostname")) {
nodeInfo = rmNodeEvent.getHostName();
}
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!");
}
else {
deployedNodes.add(nodeInfo.substring(nodeInfo.lastIndexOf('/') + 1));
}
}
}
LOGGER.info(deployedNodes.size() + " nodes found!");
return deployedNodes;
/* TODO
* This method can be improved to including all RMNodeEvent variables.
* For now, all what we need are the name and Hostname, but later it can include other variables.
*/
}
private RMStateFull getFullMonitoring() throws NotConnectedException, PermissionRestException {
......
......@@ -248,6 +248,11 @@ public class NodeCandidateUtils {
LOGGER.info("Getting images from Proactive ...");
JSONArray images = connectorIaasGateway.getImages(paCloud.getDummyInfrastructureName());
if (images == null) {
LOGGER.warn(String.format("No available images were found for the cloud [%s]. Please check your configuration.",
paCloud.getCloudID()));
return;
}
LOGGER.info("Returned images: " + images.toString());
List<JSONObject> consolidatedImages = images.toList().parallelStream()
.map(NodeCandidateUtils::convertObjectToJson)
......
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