You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2011/12/17 21:16:17 UTC

svn commit: r1215565 - /lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java

Author: markrmiller
Date: Sat Dec 17 20:16:17 2011
New Revision: 1215565

URL: http://svn.apache.org/viewvc?rev=1215565&view=rev
Log:
only use a subset of props in the shard leader props

Modified:
    lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java

Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1215565&r1=1215564&r2=1215565&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java Sat Dec 17 20:16:17 2011
@@ -499,9 +499,12 @@ public final class ZkController {
             + shardUrl + "shardId:" + shardId);
     }
 
-    ZkNodeProps zkProps = new ZkNodeProps(props);
+    // we only put a subset of props into the leader node
+    ZkNodeProps leaderProps = new ZkNodeProps(ZkStateReader.NODE_NAME_PROP,
+        props.get(ZkStateReader.NODE_NAME_PROP), ZkStateReader.URL_PROP,
+        props.get(ZkStateReader.URL_PROP));
 
-    ElectionContext context = new ShardLeaderElectionContext(shardId, collection, shardZkNodeName, ZkStateReader.toJSON(zkProps));
+    ElectionContext context = new ShardLeaderElectionContext(shardId, collection, shardZkNodeName, ZkStateReader.toJSON(leaderProps));
     
     leaderElector.setup(context);
     leaderElector.joinElection(context);
@@ -509,37 +512,41 @@ public final class ZkController {
     // should be fine if we do this rather than read from cloud state since it's rare?
     String leaderUrl = zkStateReader.getLeaderUrl(collection, cloudDesc.getShardId());
     
-    final boolean iamleader;
     SolrCore core = null;
     try {
       boolean doRecovery = true;
       if (leaderUrl.equals(shardUrl)) {
-        iamleader = true;
         doRecovery = false;
 
-        // recover from local transaction log and wait for it to complete before going active
-        // TODO: should this be moved to another thread?  To recoveryStrat?
-        // TODO: should this actually be done earlier, before (or as part of) leader election perhaps?
-        // TODO: ensure that a replica that is trying to recover waits until I'm active (or don't make me the
-        //       leader until my local replay is done.  But this replay is only needed on the leader - replicas
-        //       will do recovery anyway
+        // recover from local transaction log and wait for it to complete before
+        // going active
+        // TODO: should this be moved to another thread? To recoveryStrat?
+        // TODO: should this actually be done earlier, before (or as part of)
+        // leader election perhaps?
+        // TODO: ensure that a replica that is trying to recover waits until I'm
+        // active (or don't make me the
+        // leader until my local replay is done. But this replay is only needed
+        // on the leader - replicas
+        // will do recovery anyway
         CoreContainer cc = desc.getCoreContainer();
-        if (cc != null) {  // TODO: CoreContainer only null in tests?
-        core = cc.getCore(desc.getName());
-        if (!core.isReloaded()) {
-          Future<UpdateLog.RecoveryInfo> recoveryFuture = core.getUpdateHandler().getUpdateLog().recoverFromLog();
-          if (recoveryFuture != null) {
-            recoveryFuture.get();  // NOTE: this could potentially block for minutes or more!
-            // TODO: public as recovering in the mean time?
+        if (cc != null) { // TODO: CoreContainer only null in tests?
+          core = cc.getCore(desc.getName());
+          if (!core.isReloaded()) {
+            Future<UpdateLog.RecoveryInfo> recoveryFuture = core
+                .getUpdateHandler().getUpdateLog().recoverFromLog();
+            if (recoveryFuture != null) {
+              recoveryFuture.get(); // NOTE: this could potentially block for
+                                    // minutes or more!
+              // TODO: public as recovering in the mean time?
+            }
           }
         }
-        }
         
         // publish new props
         publishAsActive(shardUrl, cloudDesc, shardZkNodeName, shardId);
       } else {
-        iamleader = false;
         CoreContainer cc = desc.getCoreContainer();
+        // CoreContainer can be null for some tests...
         if (cc != null) {
           core = cc.getCore(desc.getName());