myriad-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smare...@apache.org
Subject incubator-myriad git commit: MYRIAD-137: Decline cached offers when a zero-profile NM shutsdown.
Date Fri, 16 Oct 2015 22:55:33 GMT
Repository: incubator-myriad
Updated Branches:
  refs/heads/master 9cc6f318b -> d2eaa4d16


MYRIAD-137: Decline cached offers when a zero-profile NM shutsdown.


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

Branch: refs/heads/master
Commit: d2eaa4d163b79bd233614fe88e0a341d2fcdb126
Parents: 9cc6f31
Author: Santosh Marella <smarella@maprtech.com>
Authored: Wed Sep 30 16:42:47 2015 -0700
Committer: Santosh Marella <marella@gmail.com>
Committed: Fri Oct 16 15:51:19 2015 -0700

----------------------------------------------------------------------
 .../ebay/myriad/scheduler/TaskTerminator.java   | 14 +++++++++----
 .../handlers/StatusUpdateEventHandler.java      | 22 ++++++++++++++------
 .../scheduler/fgs/OfferLifecycleManager.java    | 14 +++++++++++++
 3 files changed, 40 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/d2eaa4d1/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/TaskTerminator.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/TaskTerminator.java
b/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/TaskTerminator.java
index f677ded..9840099 100644
--- a/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/TaskTerminator.java
+++ b/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/TaskTerminator.java
@@ -18,6 +18,7 @@
  */
 package com.ebay.myriad.scheduler;
 
+import com.ebay.myriad.scheduler.fgs.OfferLifecycleManager;
 import com.ebay.myriad.state.SchedulerState;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Sets;
@@ -33,15 +34,19 @@ import org.slf4j.LoggerFactory;
  * {@link TaskTerminator} is responsible for killing tasks.
  */
 public class TaskTerminator implements Runnable {
-    private static final Logger LOGGER = LoggerFactory.getLogger(MyriadDriverManager.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(TaskTerminator.class);
 
-    private SchedulerState schedulerState;
-    private MyriadDriverManager driverManager;
+    private final SchedulerState schedulerState;
+    private final MyriadDriverManager driverManager;
+    private final OfferLifecycleManager offerLifeCycleManager;
 
     @Inject
-    public TaskTerminator(SchedulerState schedulerState, MyriadDriverManager driverManager)
{
+    public TaskTerminator(SchedulerState schedulerState,
+                          MyriadDriverManager driverManager,
+                          OfferLifecycleManager offerLifecycleManager) {
         this.schedulerState = schedulerState;
         this.driverManager = driverManager;
+        this.offerLifeCycleManager = offerLifecycleManager;
     }
 
     @Override
@@ -66,6 +71,7 @@ public class TaskTerminator implements Runnable {
               this.schedulerState.removeTask(taskIdToKill);
             } else {
               Status status = this.driverManager.kill(taskIdToKill);
+              offerLifeCycleManager.declineOutstandingOffers(schedulerState.getTask(taskIdToKill).getHostname());
               this.schedulerState.removeTask(taskIdToKill);
               Preconditions.checkState(status == Status.DRIVER_RUNNING);
             }

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/d2eaa4d1/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/event/handlers/StatusUpdateEventHandler.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/event/handlers/StatusUpdateEventHandler.java
b/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/event/handlers/StatusUpdateEventHandler.java
index 522ebe2..bd46747 100644
--- a/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/event/handlers/StatusUpdateEventHandler.java
+++ b/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/event/handlers/StatusUpdateEventHandler.java
@@ -19,16 +19,16 @@
 package com.ebay.myriad.scheduler.event.handlers;
 
 import com.ebay.myriad.scheduler.event.StatusUpdateEvent;
+import com.ebay.myriad.scheduler.fgs.OfferLifecycleManager;
 import com.ebay.myriad.state.SchedulerState;
 import com.lmax.disruptor.EventHandler;
+import javax.inject.Inject;
 import org.apache.mesos.Protos.TaskID;
 import org.apache.mesos.Protos.TaskState;
 import org.apache.mesos.Protos.TaskStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.inject.Inject;
-
 /**
  * handles and logs mesos status update events
  */
@@ -36,8 +36,14 @@ public class StatusUpdateEventHandler implements EventHandler<StatusUpdateEvent>
 
     private static final Logger LOGGER = LoggerFactory.getLogger(StatusUpdateEventHandler.class);
 
+    private final SchedulerState schedulerState;
+    private final OfferLifecycleManager offerLifecycleManager;
+
     @Inject
-    private SchedulerState schedulerState;
+    public StatusUpdateEventHandler(SchedulerState schedulerState, OfferLifecycleManager
offerLifecycleManager) {
+      this.schedulerState = schedulerState;
+      this.offerLifecycleManager = offerLifecycleManager;
+    }
 
     @Override
     public void onEvent(StatusUpdateEvent event,
@@ -47,10 +53,10 @@ public class StatusUpdateEventHandler implements EventHandler<StatusUpdateEvent>
         this.schedulerState.updateTask(status);
         TaskID taskId = status.getTaskId();
         if (!schedulerState.hasTask(taskId)) {
-            LOGGER.warn("Task: {} not found, status: {}", taskId, status.getState());
+            LOGGER.warn("Task: {} not found, status: {}", taskId.getValue(), status.getState());
             return;
         }
-        LOGGER.info("Status Update for task: {} | state: {}", taskId, status.getState());
+        LOGGER.info("Status Update for task: {} | state: {}", taskId.getValue(), status.getState());
         TaskState state = status.getState();
 
         switch (state) {
@@ -64,16 +70,20 @@ public class StatusUpdateEventHandler implements EventHandler<StatusUpdateEvent>
                 schedulerState.makeTaskActive(taskId);
                 break;
             case TASK_FINISHED:
+                offerLifecycleManager.declineOutstandingOffers(schedulerState.getTask(taskId).getHostname());
                 schedulerState.removeTask(taskId);
                 break;
             case TASK_FAILED:
                 // Add to pending tasks
-                schedulerState.makeTaskPending(taskId);
+              offerLifecycleManager.declineOutstandingOffers(schedulerState.getTask(taskId).getHostname());
+              schedulerState.makeTaskPending(taskId);
                 break;
             case TASK_KILLED:
+              offerLifecycleManager.declineOutstandingOffers(schedulerState.getTask(taskId).getHostname());
                 schedulerState.removeTask(taskId);
                 break;
             case TASK_LOST:
+              offerLifecycleManager.declineOutstandingOffers(schedulerState.getTask(taskId).getHostname());
                 schedulerState.makeTaskPending(taskId);
                 break;
             default:

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/d2eaa4d1/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/fgs/OfferLifecycleManager.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/fgs/OfferLifecycleManager.java
b/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/fgs/OfferLifecycleManager.java
index eb6e783..cf89be4 100644
--- a/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/fgs/OfferLifecycleManager.java
+++ b/myriad-scheduler/src/main/java/com/ebay/myriad/scheduler/fgs/OfferLifecycleManager.java
@@ -26,6 +26,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import javax.inject.Inject;
 
 import org.apache.mesos.Protos;
+import org.apache.mesos.Protos.Offer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -101,4 +102,17 @@ public class OfferLifecycleManager {
   public ConsumedOffer drainConsumedOffer(String hostname) {
     return consumedOfferMap.remove(hostname);
   }
+
+  public void declineOutstandingOffers(String hostname) {
+    int numOutStandingOffers = 0;
+    OfferFeed offerFeed = getOfferFeed(hostname);
+    Offer offer;
+    while (offerFeed != null && (offer = offerFeed.poll()) != null) {
+      declineOffer(offer);
+      numOutStandingOffers++;
+    }
+    if (numOutStandingOffers > 0) {
+      LOGGER.info("Declined {} outstanding offers for host {}", numOutStandingOffers, hostname);
+    }
+  }
 }


Mime
View raw message