lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1364022 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/src/java/org/apache/solr/cloud/ZkController.java
Date Fri, 20 Jul 2012 23:30:07 GMT
Author: markrmiller
Date: Fri Jul 20 23:30:06 2012
New Revision: 1364022

URL: http://svn.apache.org/viewvc?rev=1364022&view=rev
Log:
SOLR-3655: Ensure we register as down and leader sees that before creating startup ephem node

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    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/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1364022&r1=1364021&r2=1364022&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
Fri Jul 20 23:30:06 2012
@@ -177,29 +177,15 @@ public final class ZkController {
               overseerElector.joinElection(context);
               zkStateReader.createClusterStateWatchersAndUpdate();
               
-              List<CoreDescriptor> descriptors = registerOnReconnect
-                  .getCurrentDescriptors();
-              if (descriptors != null) {
-                // before registering as live, make sure everyone is in a
-                // down state
-                for (CoreDescriptor descriptor : descriptors) {
-                  final String coreZkNodeName = getNodeName() + "_"
-                      + descriptor.getName();
-                  try {
-                    publish(descriptor, ZkStateReader.DOWN);
-                    waitForLeaderToSeeDownState(descriptor, coreZkNodeName);
-                  } catch (Exception e) {
-                    SolrException.log(log, "", e);
-                  }
-                }
-              }
+              registerAllCoresAsDown(registerOnReconnect);
               
 
               // we have to register as live first to pick up docs in the buffer
               createEphemeralLiveNode();
               
+              List<CoreDescriptor> descriptors = registerOnReconnect.getCurrentDescriptors();
               // re register all descriptors
-              if (descriptors != null) {
+              if (descriptors  != null) {
                 for (CoreDescriptor descriptor : descriptors) {
                   // TODO: we need to think carefully about what happens when it was
                   // a leader that was expired - as well as what to do about leaders/overseers
@@ -228,7 +214,28 @@ public final class ZkController {
     cmdExecutor = new ZkCmdExecutor();
     leaderElector = new LeaderElector(zkClient);
     zkStateReader = new ZkStateReader(zkClient);
-    init();
+    
+    init(registerOnReconnect);
+  }
+
+  private void registerAllCoresAsDown(
+      final CurrentCoreDescriptorProvider registerOnReconnect) {
+    List<CoreDescriptor> descriptors = registerOnReconnect
+        .getCurrentDescriptors();
+    if (descriptors != null) {
+      // before registering as live, make sure everyone is in a
+      // down state
+      for (CoreDescriptor descriptor : descriptors) {
+        final String coreZkNodeName = getNodeName() + "_"
+            + descriptor.getName();
+        try {
+          publish(descriptor, ZkStateReader.DOWN);
+          waitForLeaderToSeeDownState(descriptor, coreZkNodeName);
+        } catch (Exception e) {
+          SolrException.log(log, "", e);
+        }
+      }
+    }
   }
 
   /**
@@ -338,8 +345,9 @@ public final class ZkController {
     return zkServerAddress;
   }
 
-  private void init() {
-
+  private void init(CurrentCoreDescriptorProvider registerOnReconnect) {
+    registerAllCoresAsDown(registerOnReconnect);
+    
     try {
       // makes nodes zkNode
       cmdExecutor.ensureExists(ZkStateReader.LIVE_NODES_ZKNODE, zkClient);



Mime
View raw message