lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r1684674 - in /lucene/dev/branches/lucene_solr_5_2: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/servlet/ solr/core/src/test/org/apache/solr/cloud/
Date Wed, 10 Jun 2015 13:49:06 GMT
Author: shalin
Date: Wed Jun 10 13:49:05 2015
New Revision: 1684674

URL: http://svn.apache.org/r1684674
Log:
SOLR-7493: Requests aren't distributed evenly if the collection isn't present locally. Merging
r1683950 from branch_5x

Added:
    lucene/dev/branches/lucene_solr_5_2/solr/core/src/test/org/apache/solr/cloud/TestRandomRequestDistribution.java
      - copied unchanged from r1683950, lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/TestRandomRequestDistribution.java
Modified:
    lucene/dev/branches/lucene_solr_5_2/   (props changed)
    lucene/dev/branches/lucene_solr_5_2/solr/   (props changed)
    lucene/dev/branches/lucene_solr_5_2/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_5_2/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_5_2/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
    lucene/dev/branches/lucene_solr_5_2/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java

Modified: lucene/dev/branches/lucene_solr_5_2/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_2/solr/CHANGES.txt?rev=1684674&r1=1684673&r2=1684674&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_2/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_5_2/solr/CHANGES.txt Wed Jun 10 13:49:05 2015
@@ -46,6 +46,9 @@ Bug Fixes
 
 * SOLR-7655: The DefaultSolrHighlighter since 5.0 was determining if payloads were present
in a way
   that was slow, especially when lots of fields were highlighted.  It's now fast.  (David
Smiley)
+
+* SOLR-7493: Requests aren't distributed evenly if the collection isn't present locally.
+  (Jeff Wartes, shalin)
   
 Other Changes
 ----------------------

Modified: lucene/dev/branches/lucene_solr_5_2/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_2/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java?rev=1684674&r1=1684673&r2=1684674&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_2/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
(original)
+++ lucene/dev/branches/lucene_solr_5_2/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
Wed Jun 10 13:49:05 2015
@@ -35,6 +35,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Random;
 import java.util.Set;
 
 import org.apache.commons.io.IOUtils;
@@ -109,7 +110,7 @@ import static org.apache.solr.servlet.So
 import static org.apache.solr.servlet.SolrDispatchFilter.Action.PROCESS;
 import static org.apache.solr.servlet.SolrDispatchFilter.Action.REMOTEQUERY;
 import static org.apache.solr.servlet.SolrDispatchFilter.Action.RETRY;
-import static org.apache.solr.servlet.SolrDispatchFilter.Action.RETURN; 
+import static org.apache.solr.servlet.SolrDispatchFilter.Action.RETURN;
 
 /**
  * This class represents a call made to Solr
@@ -117,6 +118,18 @@ import static org.apache.solr.servlet.So
 public class HttpSolrCall {
   protected static Logger log = LoggerFactory.getLogger(HttpSolrCall.class);
 
+  static final Random random;
+  static {
+    // We try to make things reproducible in the context of our tests by initializing the
random instance
+    // based on the current seed
+    String seed = System.getProperty("tests.seed");
+    if (seed == null) {
+      random = new Random();
+    } else {
+      random = new Random(seed.hashCode());
+    }
+  }
+
   protected final SolrDispatchFilter solrDispatchFilter;
   protected final CoreContainer cores;
   protected final HttpServletRequest req;
@@ -843,9 +856,16 @@ public class HttpSolrCall {
                             boolean byCoreName, boolean activeReplicas) {
     String coreUrl;
     Set<String> liveNodes = clusterState.getLiveNodes();
-    for (Slice slice : slices) {
-      Map<String, Replica> sliceShards = slice.getReplicasMap();
-      for (Replica replica : sliceShards.values()) {
+    List<Slice> randomizedSlices = new ArrayList<>(slices.size());
+    randomizedSlices.addAll(slices);
+    Collections.shuffle(randomizedSlices, random);
+
+    for (Slice slice : randomizedSlices) {
+      List<Replica> randomizedReplicas = new ArrayList<>();
+      randomizedReplicas.addAll(slice.getReplicas());
+      Collections.shuffle(randomizedReplicas, random);
+
+      for (Replica replica : randomizedReplicas) {
         if (!activeReplicas || (liveNodes.contains(replica.getNodeName())
             && replica.getState() == Replica.State.ACTIVE)) {
 

Modified: lucene/dev/branches/lucene_solr_5_2/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_2/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java?rev=1684674&r1=1684673&r2=1684674&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_2/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
(original)
+++ lucene/dev/branches/lucene_solr_5_2/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
Wed Jun 10 13:49:05 2015
@@ -93,7 +93,7 @@ public class SolrDispatchFilter extends
     String exclude = config.getInitParameter("excludePatterns");
     if(exclude != null) {
       String[] excludeArray = exclude.split(",");
-      excludePatterns = new ArrayList();
+      excludePatterns = new ArrayList<>();
       for (String element : excludeArray) {
         excludePatterns.add(Pattern.compile(element));
       }



Mime
View raw message