drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [07/10] drill git commit: DRILL-2520: Foreman is being removed from the running query table prematurely WorkManager: - reinstate retireForeman() on WorkerBee - don't use SelfCleaningRunnable to remove Foreman from running query list
Date Thu, 26 Mar 2015 06:26:46 GMT
DRILL-2520: Foreman is being removed from the running query table prematurely
WorkManager:
- reinstate retireForeman() on WorkerBee
- don't use SelfCleaningRunnable to remove Foreman from running query list

Foreman:
- use retireForeman() to remove self from running query list during cleanup


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/6fec51cb
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/6fec51cb
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/6fec51cb

Branch: refs/heads/0.8.0
Commit: 6fec51cbb310bd1669b69f943c220cda7dc88899
Parents: 1c072fe
Author: Chris Westin <cwestin@yahoo.com>
Authored: Mon Mar 23 13:31:56 2015 -0700
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Wed Mar 25 21:11:22 2015 -0700

----------------------------------------------------------------------
 .../org/apache/drill/exec/work/WorkManager.java | 31 ++++++++++++++++----
 .../apache/drill/exec/work/foreman/Foreman.java |  3 ++
 2 files changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/6fec51cb/exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java
index a08630a..231e49a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java
@@ -52,6 +52,7 @@ import org.apache.drill.exec.work.user.UserWorker;
 
 import com.codahale.metrics.Gauge;
 import com.codahale.metrics.MetricRegistry;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
@@ -173,12 +174,30 @@ public class WorkManager implements AutoCloseable {
   public class WorkerBee {
     public void addNewForeman(final Foreman foreman) {
       queries.put(foreman.getQueryId(), foreman);
-      executor.execute(new SelfCleaningRunnable(foreman) {
-        @Override
-        protected void cleanup() {
-          queries.remove(foreman.getQueryId(), foreman);
-        }
-      });
+
+      // We're relying on the Foreman to clean itself up with retireForeman().
+      executor.execute(foreman);
+    }
+
+    /**
+     * Remove the given Foreman from the running query list.
+     *
+     * <p>The running query list is a bit of a misnomer, because it doesn't
+     * necessarily mean that {@link org.apache.drill.exec.work.foreman.Foreman#run()}
+     * is executing. That only lasts for the duration of query setup, after which
+     * the Foreman instance survives as a state machine that reacts to events
+     * from the local root fragment as well as RPC responses from remote Drillbits.</p>
+     *
+     * @param foreman the Foreman to retire
+     */
+    public void retireForeman(final Foreman foreman) {
+      Preconditions.checkNotNull(foreman);
+
+      final QueryId queryId = foreman.getQueryId();
+      final boolean wasRemoved = queries.remove(queryId, foreman);
+      if (!wasRemoved) {
+        throw new IllegalStateException("Couldn't find retiring Foreman for query " + queryId);
+      }
     }
 
     public Foreman getForemanForQueryId(final QueryId queryId) {

http://git-wip-us.apache.org/repos/asf/drill/blob/6fec51cb/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
index 44112c3..32fd650 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
@@ -633,6 +633,9 @@ public class Foreman implements Runnable {
         logger.warn("Exception sending result to client", resultException);
       }
 
+      // Remove the Foreman from the running query list.
+      bee.retireForeman(Foreman.this);
+
       try {
         releaseLease();
       } finally {


Mime
View raw message