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/11/26 02:16:24 UTC

svn commit: r1206388 - /lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java

Author: markrmiller
Date: Sat Nov 26 01:16:13 2011
New Revision: 1206388

URL: http://svn.apache.org/viewvc?rev=1206388&view=rev
Log:
remove nocommit - do not try and forward update cmds to nodes that are down

Modified:
    lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java

Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java?rev=1206388&r1=1206387&r2=1206388&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java Sat Nov 26 01:16:13 2011
@@ -31,6 +31,7 @@ import org.apache.lucene.util.CharsRef;
 import org.apache.solr.cloud.HashPartitioner;
 import org.apache.solr.cloud.HashPartitioner.Range;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.SolrInputField;
 import org.apache.solr.common.cloud.CloudState;
 import org.apache.solr.common.cloud.Slice;
@@ -429,20 +430,26 @@ public class DistributedUpdateProcessor 
       String shardId, String shardZkNodeName) {
     CloudState cloudState = req.getCore().getCoreDescriptor()
         .getCoreContainer().getZkController().getCloudState();
+   
     Slice replicas = cloudState.getSlices(collection).get(shardId);
     
-    // nocommit: ignore shards on nodes that are down
     Map<String,ZkNodeProps> shardMap = replicas.getShards();
 
     StringBuilder replicasUrl = new StringBuilder();
     for (Entry<String,ZkNodeProps> entry : shardMap.entrySet()) {
-      if (replicasUrl.length() > 0) {
-        replicasUrl.append("|");
+      if (cloudState.liveNodesContain(entry.getValue().get(
+          ZkStateReader.NODE_NAME_PROP))) {
+        
+        if (replicasUrl.length() > 0) {
+          replicasUrl.append("|");
+        }
+        String replicaUrl = entry.getValue().get(ZkStateReader.URL_PROP);
+        replicasUrl.append(replicaUrl);
       }
-      String replicaUrl = entry.getValue().get("url");
-      replicasUrl.append(replicaUrl);
     }
-
+    if (replicasUrl.length() == 0) {
+      throw new ZooKeeperException(ErrorCode.SERVICE_UNAVAILABLE, "No servers hosting shard " + shardId + " found");
+    }
     return replicasUrl.toString();
   }