lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r1580979 - in /lucene/dev/branches/lucene_solr_4_7: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/handler/component/ solr/core/src/test/org/apache/solr/cloud/ solr/test-framework/ solr/test-framework/src/java/org/apache/solr/cloud/
Date Mon, 24 Mar 2014 18:39:01 GMT
Author: shalin
Date: Mon Mar 24 18:39:00 2014
New Revision: 1580979

URL: http://svn.apache.org/r1580979
Log:
SOLR-5550: shards.info is not returned by a short circuited distributed query

Added:
    lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java
      - copied unchanged from r1578083, lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java
Modified:
    lucene/dev/branches/lucene_solr_4_7/   (props changed)
    lucene/dev/branches/lucene_solr_4_7/solr/   (props changed)
    lucene/dev/branches/lucene_solr_4_7/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_4_7/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
    lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
    lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
    lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
    lucene/dev/branches/lucene_solr_4_7/solr/test-framework/   (props changed)
    lucene/dev/branches/lucene_solr_4_7/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java

Modified: lucene/dev/branches/lucene_solr_4_7/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_7/solr/CHANGES.txt?rev=1580979&r1=1580978&r2=1580979&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_7/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_7/solr/CHANGES.txt Mon Mar 24 18:39:00 2014
@@ -72,6 +72,9 @@ Bug Fixes
 * SOLR-5423: CSV output doesn't include function field
   (Arun Kumar, hossman, Steve Rowe)
 
+* SOLR-5550: shards.info is not returned by a short circuited distributed query.
+  (Timothy Potter, shalin)
+
 ==================  4.7.0 ==================
 
 Versions of Major Components

Modified: lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java?rev=1580979&r1=1580978&r2=1580979&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
(original)
+++ lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
Mon Mar 24 18:39:00 2014
@@ -339,6 +339,7 @@ public class HttpShardHandler extends Sh
 
           if (shortCircuit) {
             rb.isDistrib = false;
+            rb.shortCircuitedURL = ZkCoreNodeProps.getCoreUrl(zkController.getBaseUrl(),
coreDescriptor.getName());
             return;
           }
           // We shouldn't need to do anything to handle "shard.rows" since it was previously
meant to be an optimization?

Modified: lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java?rev=1580979&r1=1580978&r2=1580979&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
(original)
+++ lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
Mon Mar 24 18:39:00 2014
@@ -128,7 +128,7 @@ public class ResponseBuilder
   public int shards_start = -1;
   public List<ShardRequest> outgoing;  // requests to be sent
   public List<ShardRequest> finished;  // requests that have received responses from
all shards
-
+  public String shortCircuitedURL;
 
   public int getShardNum(String shard) {
     for (int i = 0; i < shards.length; i++) {

Modified: lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java?rev=1580979&r1=1580978&r2=1580979&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
(original)
+++ lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
Mon Mar 24 18:39:00 2014
@@ -17,12 +17,20 @@
 
 package org.apache.solr.handler.component;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.ShardParams;
-import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.core.CloseHook;
 import org.apache.solr.core.PluginInfo;
 import org.apache.solr.core.SolrCore;
@@ -36,11 +44,6 @@ import org.apache.solr.util.plugin.SolrC
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-
 /**
  *
  * Refer SOLR-281
@@ -230,7 +233,6 @@ public class SearchHandler extends Reque
           rb.addDebugInfo("timing", timer.asNamedList() );
         }
       }
-
     } else {
       // a distributed request
 
@@ -330,6 +332,37 @@ public class SearchHandler extends Reque
         // we are done when the next stage is MAX_VALUE
       } while (nextStage != Integer.MAX_VALUE);
     }
+    
+    // SOLR-5550: still provide shards.info if requested even for a short circuited distrib
request
+    if(!rb.isDistrib && req.getParams().getBool(ShardParams.SHARDS_INFO, false) &&
rb.shortCircuitedURL != null) {  
+      NamedList<Object> shardInfo = new SimpleOrderedMap<Object>();
+      SimpleOrderedMap<Object> nl = new SimpleOrderedMap<Object>();        
+      if (rsp.getException() != null) {
+        Throwable cause = rsp.getException();
+        if (cause instanceof SolrServerException) {
+          cause = ((SolrServerException)cause).getRootCause();
+        } else {
+          if (cause.getCause() != null) {
+            cause = cause.getCause();
+          }          
+        }
+        nl.add("error", cause.toString() );
+        StringWriter trace = new StringWriter();
+        cause.printStackTrace(new PrintWriter(trace));
+        nl.add("trace", trace.toString() );
+      }
+      else {
+        nl.add("numFound", rb.getResults().docList.matches());
+        nl.add("maxScore", rb.getResults().docList.maxScore());
+      }
+      nl.add("shardAddress", rb.shortCircuitedURL);
+      nl.add("time", rsp.getEndTime()-req.getStartTime()); // elapsed time of this request
so far
+      
+      int pos = rb.shortCircuitedURL.indexOf("://");        
+      String shardInfoName = pos != -1 ? rb.shortCircuitedURL.substring(pos+3) : rb.shortCircuitedURL;
+      shardInfo.add(shardInfoName, nl);   
+      rsp.getValues().add(ShardParams.SHARDS_INFO,shardInfo);            
+    }
   }
 
   //////////////////////// SolrInfoMBeans methods //////////////////////

Modified: lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java?rev=1580979&r1=1580978&r2=1580979&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
(original)
+++ lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
Mon Mar 24 18:39:00 2014
@@ -339,31 +339,8 @@ public class ShardRoutingTest extends Ab
     // todo - target diff servers and use cloud clients as well as non-cloud clients
   }
 
-  // TODO: refactor some of this stuff up into a base class for use by other tests
-  void doQuery(String expectedDocs, String... queryParams) throws Exception {
-    Set<String> expectedIds = new HashSet<String>( StrUtils.splitSmart(expectedDocs,
",", true) );
-
-    QueryResponse rsp = cloudClient.query(params(queryParams));
-    Set<String> obtainedIds = new HashSet<String>();
-    for (SolrDocument doc : rsp.getResults()) {
-      obtainedIds.add((String) doc.get("id"));
-    }
-
-    assertEquals(expectedIds, obtainedIds);
-  }
-
   void doRTG(String ids) throws Exception {
-    cloudClient.query(params("qt","/get", "ids",ids));
-
-    Set<String> expectedIds = new HashSet<String>( StrUtils.splitSmart(ids, ",",
true) );
-
-    QueryResponse rsp = cloudClient.query(params("qt","/get", "ids",ids));
-    Set<String> obtainedIds = new HashSet<String>();
-    for (SolrDocument doc : rsp.getResults()) {
-      obtainedIds.add((String) doc.get("id"));
-    }
-
-    assertEquals(expectedIds, obtainedIds);
+    doQuery(ids, "qt", "/get", "ids", ids);
   }
 
   // TODO: refactor some of this stuff into the SolrJ client... it should be easier to use

Modified: lucene/dev/branches/lucene_solr_4_7/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_7/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1580979&r1=1580978&r2=1580979&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_7/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
(original)
+++ lucene/dev/branches/lucene_solr_4_7/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
Mon Mar 24 18:39:00 2014
@@ -1623,7 +1623,19 @@ public abstract class AbstractFullDistri
       Thread.sleep(2000);
     } while (retry);
   }
-  
+
+  void doQuery(String expectedDocs, String... queryParams) throws Exception {
+    Set<String> expectedIds = new HashSet<String>( StrUtils.splitSmart(expectedDocs,
",", true) );
+
+    QueryResponse rsp = cloudClient.query(params(queryParams));
+    Set<String> obtainedIds = new HashSet<String>();
+    for (SolrDocument doc : rsp.getResults()) {
+      obtainedIds.add((String) doc.get("id"));
+    }
+
+    assertEquals(expectedIds, obtainedIds);
+  }
+
   @Override
   @After
   public void tearDown() throws Exception {



Mime
View raw message