lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r1662777 - in /lucene/dev/branches/lucene_solr_4_10: ./ solr/ solr/core/ solr/core/src/test-files/solr/ solr/core/src/test/org/apache/solr/handler/component/ solr/test-framework/ solr/test-framework/src/java/org/apache/solr/cloud/ solr/test...
Date Fri, 27 Feb 2015 18:32:17 GMT
Author: shalin
Date: Fri Feb 27 18:32:16 2015
New Revision: 1662777

URL: http://svn.apache.org/r1662777
Log:
SOLR-7147: Introduce new TrackingShardHandlerFactory for monitoring what requests are sent
to shards during tests

Added:
    lucene/dev/branches/lucene_solr_4_10/solr/core/src/test-files/solr/solr-trackingshardhandler.xml
      - copied, changed from r1662210, lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/solr-trackingshardhandler.xml
    lucene/dev/branches/lucene_solr_4_10/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java
      - copied, changed from r1662210, lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java
    lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/handler/
      - copied from r1662210, lucene/dev/branches/branch_5x/solr/test-framework/src/java/org/apache/solr/handler/
Modified:
    lucene/dev/branches/lucene_solr_4_10/   (props changed)
    lucene/dev/branches/lucene_solr_4_10/solr/   (props changed)
    lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_4_10/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_4_10/solr/test-framework/   (props changed)
    lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
    lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java

Modified: lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt?rev=1662777&r1=1662776&r2=1662777&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt Fri Feb 27 18:32:16 2015
@@ -89,6 +89,12 @@ Bug Fixes
   
 * SOLR-7067: bin/solr won't run under bash 4.2+. (Steve Rowe)
 
+Other Changes
+----------------------
+
+* SOLR-7147: Introduce new TrackingShardHandlerFactory for monitoring what requests
+  are sent to shards during tests. (hossman, shalin)
+
 ==================  4.10.3 ==================
 
 Bug Fixes

Copied: lucene/dev/branches/lucene_solr_4_10/solr/core/src/test-files/solr/solr-trackingshardhandler.xml
(from r1662210, lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/solr-trackingshardhandler.xml)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/core/src/test-files/solr/solr-trackingshardhandler.xml?p2=lucene/dev/branches/lucene_solr_4_10/solr/core/src/test-files/solr/solr-trackingshardhandler.xml&p1=lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/solr-trackingshardhandler.xml&r1=1662210&r2=1662777&rev=1662777&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test-files/solr/solr-trackingshardhandler.xml
(original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/core/src/test-files/solr/solr-trackingshardhandler.xml
Fri Feb 27 18:32:16 2015
@@ -22,8 +22,6 @@
 <solr>
 
   <str name="shareSchema">${shareSchema:false}</str>
-  <str name="configSetBaseDir">${configSetBaseDir:configsets}</str>
-  <str name="coreRootDirectory">${coreRootDirectory:.}</str>
 
   <solrcloud>
     <str name="host">127.0.0.1</str>

Copied: lucene/dev/branches/lucene_solr_4_10/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java
(from r1662210, lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java?p2=lucene/dev/branches/lucene_solr_4_10/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java&p1=lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java&r1=1662210&r2=1662777&rev=1662777&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java
(original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java
Fri Feb 27 18:32:16 2015
@@ -21,16 +21,14 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.solr.BaseDistributedSearchTestCase;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.impl.CloudSolrServer;
 import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.servlet.SolrDispatchFilter;
-import org.junit.Test;
 
 /**
  * Test for {@link org.apache.solr.handler.component.TrackingShardHandlerFactory}
@@ -41,6 +39,8 @@ public class TestTrackingShardHandlerFac
 
   public TestTrackingShardHandlerFactory() {
     schemaString = "schema15.xml"; // we need a string id
+    fixShardCount = true;
+    shardCount = 2;
   }
 
   @Override
@@ -48,9 +48,8 @@ public class TestTrackingShardHandlerFac
     return "solr-trackingshardhandler.xml";
   }
 
-  @Test
-  @BaseDistributedSearchTestCase.ShardsFixed(num = 2)
-  public void testRequestTracking() throws Exception {
+  @Override
+  public void doTest() throws Exception {
     String collectionName = "testTwoPhase";
 
     List<JettySolrRunner> runners = new ArrayList<>(jettys);
@@ -75,7 +74,7 @@ public class TestTrackingShardHandlerFac
     assertNotNull(coreAdminRequests);
     assertEquals("Unexpected number of core admin requests were found", 2, coreAdminRequests.size());
 
-    CloudSolrClient client = cloudClient;
+    CloudSolrServer client = cloudClient;
 
     client.setDefaultCollection(collectionName);
         /*

Modified: lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java?rev=1662777&r1=1662776&r2=1662777&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
(original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
Fri Feb 27 18:32:16 2015
@@ -137,7 +137,7 @@ public abstract class AbstractDistribZkT
     waitForRecoveriesToFinish(collection, zkStateReader, verbose, failOnTimeout, 330);
   }
   
-  protected void waitForRecoveriesToFinish(String collection,
+  public static void waitForRecoveriesToFinish(String collection,
       ZkStateReader zkStateReader, boolean verbose, boolean failOnTimeout, int timeoutSeconds)
       throws Exception {
     log.info("Wait for recoveries to finish - collection: " + collection + " failOnTimeout:"
+ failOnTimeout + " timeout (sec):" + timeoutSeconds);
@@ -174,7 +174,7 @@ public abstract class AbstractDistribZkT
           if (verbose) System.out.println("Gave up waiting for recovery to finish..");
           if (failOnTimeout) {
             Diagnostics.logThreadDumps("Gave up waiting for recovery to finish.  THREAD DUMP:");
-            printLayout();
+            zkStateReader.getZkClient().printLayoutToStdOut();
             fail("There are still nodes recoverying - waited for " + timeoutSeconds + " seconds");
             // won't get here
             return;

Modified: lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java?rev=1662777&r1=1662210&r2=1662777&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java
(original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/test-framework/src/java/org/apache/solr/handler/component/TrackingShardHandlerFactory.java
Fri Feb 27 18:32:16 2015
@@ -18,11 +18,12 @@ package org.apache.solr.handler.componen
  */
 
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Queue;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.cloud.MiniSolrCloudCluster;
@@ -32,6 +33,7 @@ import org.apache.solr.common.cloud.Slic
 import org.apache.solr.common.cloud.ZkCoreNodeProps;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.StrUtils;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.servlet.SolrDispatchFilter;
 
@@ -186,7 +188,7 @@ public class TrackingShardHandlerFactory
    * @see org.apache.solr.handler.component.TrackingShardHandlerFactory#setTrackingQueue(java.util.List,
java.util.Queue)
    */
   public static class RequestTrackingQueue extends LinkedList<ShardRequestAndParams>
{
-    private final Map<String, List<ShardRequestAndParams>> requests = new HashMap<>();
+    private final Map<String, List<ShardRequestAndParams>> requests = new ConcurrentHashMap<>();
 
     @Override
     public boolean offer(ShardRequestAndParams shardRequestAndParams) {
@@ -244,15 +246,17 @@ public class TrackingShardHandlerFactory
       Slice slice = collection.getSlice(shardId);
       assert slice != null;
 
-      List<TrackingShardHandlerFactory.ShardRequestAndParams> results = new ArrayList<>();
-      for (Map.Entry<String, Replica> entry : slice.getReplicasMap().entrySet()) {
-        String coreUrl = new ZkCoreNodeProps(entry.getValue()).getCoreUrl();
-        List<TrackingShardHandlerFactory.ShardRequestAndParams> list = requests.get(coreUrl);
-        if (list != null) {
-          results.addAll(list);
+      for (Map.Entry<String, List<ShardRequestAndParams>> entry : requests.entrySet())
{
+        // multiple shard addresses may be present separated by '|'
+        List<String> list = StrUtils.splitSmart(entry.getKey(), '|');
+        for (Map.Entry<String, Replica> replica : slice.getReplicasMap().entrySet())
{
+          String coreUrl = new ZkCoreNodeProps(replica.getValue()).getCoreUrl();
+          if (list.contains(coreUrl)) {
+            return new ArrayList<>(entry.getValue());
+          }
         }
       }
-      return results;
+      return Collections.emptyList();
     }
 
     /**
@@ -278,7 +282,7 @@ public class TrackingShardHandlerFactory
      * Retrieves all requests recorded by this collection as a Map of shard address (string
url)
      * to a list of {@link org.apache.solr.handler.component.TrackingShardHandlerFactory.ShardRequestAndParams}
      *
-     * @return a {@link java.util.Map} of url strings to {@link org.apache.solr.handler.component.TrackingShardHandlerFactory.ShardRequestAndParams}
objects
+     * @return a {@link java.util.concurrent.ConcurrentHashMap} of url strings to {@link
org.apache.solr.handler.component.TrackingShardHandlerFactory.ShardRequestAndParams} objects
      * or empty map if none have been recorded
      */
     public Map<String, List<ShardRequestAndParams>> getAllRequests() {



Mime
View raw message