myriad-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smare...@apache.org
Subject [1/3] incubator-myriad git commit: MYRIAD-154 Restarting RM starts a "default" medium-profile NM on each…
Date Tue, 20 Oct 2015 18:34:41 GMT
Repository: incubator-myriad
Updated Branches:
  refs/heads/master d29ee338e -> f67075c46


MYRIAD-154 Restarting RM starts a "default" medium-profile NM on each…

… restart.

We check if there is atleast one NM in pending, staging or active state. if yes,
do not launch additional NMs.

Tested, NM was launched the first time as there were no NMs in pending, staging or active
state.
Restarted RM multiple times. No new NM was launched.

This closes: #11
Review: https://github.com/apache/incubator-myriad/pull/11


Project: http://git-wip-us.apache.org/repos/asf/incubator-myriad/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-myriad/commit/5cab3b1d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-myriad/tree/5cab3b1d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-myriad/diff/5cab3b1d

Branch: refs/heads/master
Commit: 5cab3b1d1e9e287d013563b0226ff2a2b3bdbf54
Parents: d29ee33
Author: Swapnil Daingade <sdaingade@maprtech.com>
Authored: Tue Oct 20 11:29:33 2015 -0700
Committer: Santosh Marella <marella@gmail.com>
Committed: Tue Oct 20 11:29:33 2015 -0700

----------------------------------------------------------------------
 .../src/main/java/com/ebay/myriad/Main.java     | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/5cab3b1d/myriad-scheduler/src/main/java/com/ebay/myriad/Main.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/java/com/ebay/myriad/Main.java b/myriad-scheduler/src/main/java/com/ebay/myriad/Main.java
index f73e1f0..a0ad9cb 100644
--- a/myriad-scheduler/src/main/java/com/ebay/myriad/Main.java
+++ b/myriad-scheduler/src/main/java/com/ebay/myriad/Main.java
@@ -41,6 +41,8 @@ import com.ebay.myriad.scheduler.TaskFactory;
 import com.ebay.myriad.scheduler.TaskTerminator;
 import com.ebay.myriad.scheduler.TaskUtils;
 import com.ebay.myriad.scheduler.yarn.interceptor.InterceptorRegistry;
+import com.ebay.myriad.state.NodeTask;
+import com.ebay.myriad.state.SchedulerState;
 import com.ebay.myriad.webapp.MyriadWebServer;
 import com.ebay.myriad.webapp.WebAppGuiceModule;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -56,9 +58,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
+import java.util.HashSet;
 
 /**
  * Main entry point for myriad scheduler
@@ -211,7 +215,32 @@ public class Main {
       Map<String, Integer> nmInstances = injector.getInstance(MyriadConfiguration.class).getNmInstances();
       MyriadOperations myriadOperations = injector.getInstance(MyriadOperations.class);
       ServiceProfileManager profileManager = injector.getInstance(ServiceProfileManager.class);
+      SchedulerState schedulerState = injector.getInstance(SchedulerState.class);
+
+      Set<NodeTask> launchedNMTasks = new HashSet<>();
+      launchedNMTasks.addAll(
+        schedulerState.getPendingTasksByType(NodeManagerConfiguration.NM_TASK_PREFIX));
+      if (!launchedNMTasks.isEmpty()) {
+        LOGGER.info("{} NM(s) in pending state. Not launching additional NMs", launchedNMTasks.size());
+        return;
+      }
+
+      launchedNMTasks.addAll(
+        schedulerState.getStagingTasksByType(NodeManagerConfiguration.NM_TASK_PREFIX));
+      if (!launchedNMTasks.isEmpty()) {
+        LOGGER.info("{} NM(s) in staging state. Not launching additional NMs", launchedNMTasks.size());
+        return;
+      }
+
+      launchedNMTasks.addAll(
+        schedulerState.getActiveTasksByType(NodeManagerConfiguration.NM_TASK_PREFIX));
+      if (!launchedNMTasks.isEmpty()) {
+        LOGGER.info("{} NM(s) in active state. Not launching additional NMs", launchedNMTasks.size());
+        return;
+      }
+
       for (Map.Entry<String, Integer> entry : nmInstances.entrySet()) {
+        LOGGER.info("Launching {} NM(s) with profile {}", entry.getValue(), entry.getKey());
         myriadOperations.flexUpCluster(profileManager.get(entry.getKey()), entry.getValue(),
null);
       }
     }


Mime
View raw message