lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject lucene-solr:feature/autoscaling: SOLR-10397: Handle interrupted event for Overseer.autoscalingTriggerCreator
Date Sat, 29 Jul 2017 03:43:48 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/feature/autoscaling 6893699f0 -> 7ef991d64


SOLR-10397: Handle interrupted event for Overseer.autoscalingTriggerCreator


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/7ef991d6
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/7ef991d6
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/7ef991d6

Branch: refs/heads/feature/autoscaling
Commit: 7ef991d642e82a8ba5afbe924a120bc96d8887d1
Parents: 6893699
Author: Cao Manh Dat <datcm@apache.org>
Authored: Sat Jul 29 10:43:37 2017 +0700
Committer: Cao Manh Dat <datcm@apache.org>
Committed: Sat Jul 29 10:43:37 2017 +0700

----------------------------------------------------------------------
 .../java/org/apache/solr/cloud/Overseer.java    | 32 +++++++++++++++-----
 1 file changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7ef991d6/solr/core/src/java/org/apache/solr/cloud/Overseer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/Overseer.java b/solr/core/src/java/org/apache/solr/cloud/Overseer.java
index 9176324..ecfc3f9 100644
--- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java
+++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java
@@ -480,6 +480,8 @@ public class Overseer implements Closeable {
 
   private OverseerThread triggerThread;
 
+  private Thread autoscalingTriggerCreator;
+
   private final ZkStateReader reader;
 
   private final ShardHandler shardHandler;
@@ -531,7 +533,7 @@ public class Overseer implements Closeable {
     ccThread.setDaemon(true);
 
     //TODO nocommit, autoscaling framework should start autoAddReplicas trigger automatically
(implicitly)
-    Thread autoscalingTriggerCreator = new Thread(createAutoscalingTriggerIfNotExist(), "AutoscalingTriggerCreator");
+    autoscalingTriggerCreator = new Thread(createAutoscalingTriggerIfNotExist(), "AutoscalingTriggerCreator");
     autoscalingTriggerCreator.setDaemon(true);
     autoscalingTriggerCreator.start();
 
@@ -584,14 +586,18 @@ public class Overseer implements Closeable {
           throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
               "Failed when creating .auto_add_replicas trigger");
         }
-        while (getZkController().getCoreContainer()
-            .getRequestHandler(AutoScalingHandler.HANDLER_PATH) == null) {
-          try {
-            Thread.sleep(500);
-          } catch (InterruptedException e) {
-            // expected
+        try {
+          while (getZkController().getCoreContainer().getRequestHandler(AutoScalingHandler.HANDLER_PATH)
== null) {
+            try {
+              Thread.sleep(500);
+            } catch (InterruptedException e) {
+              break;
+            }
           }
-        }
+          if (getZkController().getCoreContainer().isShutDown()) {
+            return;
+          }
+        } catch (Exception e) {}
 
         String dsl = AutoScaling.AUTO_ADD_REPLICAS_TRIGGER_DSL.replace("{{waitFor}}",
             String.valueOf(config.getAutoReplicaFailoverWaitAfterExpiration()/1000));
@@ -626,6 +632,9 @@ public class Overseer implements Closeable {
       IOUtils.closeQuietly(triggerThread);
       triggerThread.interrupt();
     }
+    if (autoscalingTriggerCreator != null) {
+      autoscalingTriggerCreator.interrupt();
+    }
     
     if (updaterThread != null) {
       try {
@@ -642,10 +651,17 @@ public class Overseer implements Closeable {
         triggerThread.join();
       } catch (InterruptedException e)  {}
     }
+    if (autoscalingTriggerCreator != null) {
+      try {
+        log.info("Waiting for autoscaling trigger creator join");
+        autoscalingTriggerCreator.join();
+      } catch (InterruptedException e) {}
+    }
     
     updaterThread = null;
     ccThread = null;
     triggerThread = null;
+    autoscalingTriggerCreator = null;
   }
 
   /**


Mime
View raw message