You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2014/03/16 15:19:17 UTC
svn commit: r1578083 - in /lucene/dev/branches/branch_4x: ./ 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/
Author: shalin
Date: Sun Mar 16 14:19:17 2014
New Revision: 1578083
URL: http://svn.apache.org/r1578083
Log:
SOLR-5550: shards.info is not returned by a short circuited distributed query
Added:
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java
- copied unchanged from r1578078, lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestShortCircuitedRequests.java
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
lucene/dev/branches/branch_4x/solr/test-framework/ (props changed)
lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1578083&r1=1578082&r2=1578083&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Sun Mar 16 14:19:17 2014
@@ -126,6 +126,9 @@ Bug Fixes
* SOLR-5866: UpdateShardHandler needs to use the system default scheme registry to
properly handle https via javax.net.ssl.* properties. (Steve Davids via shalin)
+* SOLR-5550: shards.info is not returned by a short circuited distributed query.
+ (Timothy Potter, shalin)
+
Optimizations
----------------------
* SOLR-1880: Distributed Search skips GET_FIELDS stage if EXECUTE_QUERY
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java?rev=1578083&r1=1578082&r2=1578083&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java Sun Mar 16 14:19:17 2014
@@ -340,6 +340,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/branch_4x/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java?rev=1578083&r1=1578082&r2=1578083&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java Sun Mar 16 14:19:17 2014
@@ -129,7 +129,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/branch_4x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java?rev=1578083&r1=1578082&r2=1578083&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java Sun Mar 16 14:19:17 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
@@ -231,7 +234,6 @@ public class SearchHandler extends Reque
rb.addDebugInfo("timing", timer.asNamedList() );
}
}
-
} else {
// a distributed request
@@ -331,6 +333,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/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java?rev=1578083&r1=1578082&r2=1578083&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java Sun Mar 16 14:19:17 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<>( StrUtils.splitSmart(expectedDocs, ",", true) );
-
- QueryResponse rsp = cloudClient.query(params(queryParams));
- Set<String> obtainedIds = new HashSet<>();
- 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<>( StrUtils.splitSmart(ids, ",", true) );
-
- QueryResponse rsp = cloudClient.query(params("qt","/get", "ids",ids));
- Set<String> obtainedIds = new HashSet<>();
- 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/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1578083&r1=1578082&r2=1578083&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Sun Mar 16 14:19:17 2014
@@ -1516,7 +1516,19 @@ public abstract class AbstractFullDistri
Thread.sleep(2000);
} while (retry);
}
-
+
+ void doQuery(String expectedDocs, String... queryParams) throws Exception {
+ Set<String> expectedIds = new HashSet<>( StrUtils.splitSmart(expectedDocs, ",", true) );
+
+ QueryResponse rsp = cloudClient.query(params(queryParams));
+ Set<String> obtainedIds = new HashSet<>();
+ for (SolrDocument doc : rsp.getResults()) {
+ obtainedIds.add((String) doc.get("id"));
+ }
+
+ assertEquals(expectedIds, obtainedIds);
+ }
+
@Override
@After
public void tearDown() throws Exception {