lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject svn commit: r1566248 - in /lucene/dev/branches/branch_4x/solr: ./ core/ core/src/java/org/apache/solr/cloud/
Date Sun, 09 Feb 2014 07:46:20 GMT
Author: noble
Date: Sun Feb  9 07:46:19 2014
New Revision: 1566248

URL: http://svn.apache.org/r1566248
Log:
SOLR-5476 avoiding race condition 

Modified:
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/Overseer.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ZkController.java

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java?rev=1566248&r1=1566247&r2=1566248&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
Sun Feb  9 07:46:19 2014
@@ -71,7 +71,7 @@ public abstract class ElectionContext {
     }
   }
 
-  abstract void runLeaderProcess(boolean weAreReplacement) throws KeeperException, InterruptedException,
IOException;
+  abstract void runLeaderProcess(boolean weAreReplacement, int pauseTime) throws KeeperException,
InterruptedException, IOException;
 
   public void checkIfIamLeaderFired() {}
 
@@ -106,7 +106,7 @@ class ShardLeaderElectionContextBase ext
   }
 
   @Override
-  void runLeaderProcess(boolean weAreReplacement) throws KeeperException,
+  void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStart) throws KeeperException,
       InterruptedException, IOException {
     
     zkClient.makePath(leaderPath, ZkStateReader.toJSON(leaderProps),
@@ -154,7 +154,7 @@ final class ShardLeaderElectionContext e
    * weAreReplacement: has someone else been the leader already?
    */
   @Override
-  void runLeaderProcess(boolean weAreReplacement) throws KeeperException,
+  void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStart) throws KeeperException,
       InterruptedException, IOException {
     log.info("Running the leader process for shard " + shardId);
     
@@ -270,7 +270,7 @@ final class ShardLeaderElectionContext e
     }
     boolean success = false;
     try {
-      super.runLeaderProcess(weAreReplacement);
+      super.runLeaderProcess(weAreReplacement, 0);
       success = true;
     } catch (Exception e) {
       SolrException.log(log, "There was a problem trying to register as the leader", e);
@@ -449,7 +449,7 @@ final class OverseerElectionContext exte
   }
 
   @Override
-  void runLeaderProcess(boolean weAreReplacement) throws KeeperException,
+  void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStart) throws KeeperException,
       InterruptedException {
     log.info("I am going to be the leader {}", id);
     final String id = leaderSeqPath
@@ -458,6 +458,13 @@ final class OverseerElectionContext exte
 
     zkClient.makePath(leaderPath, ZkStateReader.toJSON(myProps),
         CreateMode.EPHEMERAL, true);
+    if(pauseBeforeStart >0){
+      try {
+        Thread.sleep(pauseBeforeStart);
+      } catch (InterruptedException e) {
+        log.warn("Wait interrupted ", e);
+      }
+    }
     
     overseer.start(id);
   }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java?rev=1566248&r1=1566247&r2=1566248&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
Sun Feb  9 07:46:19 2014
@@ -161,7 +161,7 @@ public  class LeaderElector {
   // TODO: get this core param out of here
   protected void runIamLeaderProcess(final ElectionContext context, boolean weAreReplacement)
throws KeeperException,
       InterruptedException, IOException {
-    context.runLeaderProcess(weAreReplacement);
+    context.runLeaderProcess(weAreReplacement,0);
   }
   
   /**

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/Overseer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/Overseer.java?rev=1566248&r1=1566247&r2=1566248&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/Overseer.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/Overseer.java Sun
Feb  9 07:46:19 2014
@@ -59,10 +59,10 @@ public class Overseer {
   public static final String ADD_ROUTING_RULE = "addroutingrule";
   public static final String REMOVE_ROUTING_RULE = "removeroutingrule";
 
-  private static final int STATE_UPDATE_DELAY = 1500;  // delay between cloud state updates
+  public static final int STATE_UPDATE_DELAY = 1500;  // delay between cloud state updates
 
   private static Logger log = LoggerFactory.getLogger(Overseer.class);
-  
+
   static enum LeaderStatus { DONT_KNOW, NO, YES };
 
   private long lastUpdatedTime = 0;
@@ -89,7 +89,7 @@ public class Overseer {
     
     @Override
     public void run() {
-        
+
       LeaderStatus isLeader = amILeader();
       while (isLeader == LeaderStatus.DONT_KNOW) {
         log.debug("am_i_leader unclear {}", isLeader);

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1566248&r1=1566247&r2=1566248&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ZkController.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ZkController.java
Sun Feb  9 07:46:19 2014
@@ -295,9 +295,8 @@ public final class ZkController {
   public void forceOverSeer(){
     try {
       zkClient.delete("/overseer_elect/leader",-1, true);
-      log.info("Forcing me to be leader  {} ",getBaseUrl());
-      overseerElector.getContext().runLeaderProcess(true);
-      rejoinOverseerElection();
+      log.info("Forcing me to be leader  {} ", getBaseUrl());
+      overseerElector.getContext().runLeaderProcess(true, Overseer.STATE_UPDATE_DELAY+100);
     } catch (Exception e) {
       throw new SolrException(ErrorCode.SERVER_ERROR, " Error becoming overseer ",e);
 



Mime
View raw message