diff --git a/src/java/org/apache/solr/handler/component/DebugComponent.java b/src/java/org/apache/solr/handler/component/DebugComponent.java index 2d478b37698..99ef332e1c2 100644 --- a/src/java/org/apache/solr/handler/component/DebugComponent.java +++ b/src/java/org/apache/solr/handler/component/DebugComponent.java @@ -113,7 +113,7 @@ public class DebugComponent extends SearchComponent for (ShardRequest sreq : rb.finished) { if ((sreq.purpose & ShardRequest.PURPOSE_GET_DEBUG) == 0) continue; for (ShardResponse srsp : sreq.responses) { - NamedList sdebug = (NamedList)srsp.rsp.getResponse().get("debug"); + NamedList sdebug = (NamedList)srsp.getSolrResponse().getResponse().get("debug"); info = (NamedList)merge(sdebug, info, excludeSet); NamedList sexplain = (NamedList)sdebug.get("explain"); diff --git a/src/java/org/apache/solr/handler/component/FacetComponent.java b/src/java/org/apache/solr/handler/component/FacetComponent.java index df28b36759c..b35f6856cd3 100644 --- a/src/java/org/apache/solr/handler/component/FacetComponent.java +++ b/src/java/org/apache/solr/handler/component/FacetComponent.java @@ -198,8 +198,8 @@ public class FacetComponent extends SearchComponent FacetInfo fi = rb._facetInfo; for (ShardResponse srsp: sreq.responses) { - int shardNum = rb.getShardNum(srsp.shard); - NamedList facet_counts = (NamedList)srsp.rsp.getResponse().get("facet_counts"); + int shardNum = rb.getShardNum(srsp.getShard()); + NamedList facet_counts = (NamedList)srsp.getSolrResponse().getResponse().get("facet_counts"); // handle facet queries NamedList facet_queries = (NamedList)facet_counts.get("facet_queries"); @@ -287,7 +287,7 @@ public class FacetComponent extends SearchComponent for (ShardResponse srsp: sreq.responses) { // int shardNum = rb.getShardNum(srsp.shard); - NamedList facet_counts = (NamedList)srsp.rsp.getResponse().get("facet_counts"); + NamedList facet_counts = (NamedList)srsp.getSolrResponse().getResponse().get("facet_counts"); NamedList facet_queries = (NamedList)facet_counts.get("facet_queries"); // These are single term queries used to fill in missing counts diff --git a/src/java/org/apache/solr/handler/component/HighlightComponent.java b/src/java/org/apache/solr/handler/component/HighlightComponent.java index d5d7a371fea..7aa65705690 100644 --- a/src/java/org/apache/solr/handler/component/HighlightComponent.java +++ b/src/java/org/apache/solr/handler/component/HighlightComponent.java @@ -114,7 +114,7 @@ public class HighlightComponent extends SearchComponent for (ShardRequest sreq : rb.finished) { if ((sreq.purpose & ShardRequest.PURPOSE_GET_HIGHLIGHTS) == 0) continue; for (ShardResponse srsp : sreq.responses) { - NamedList hl = (NamedList)srsp.rsp.getResponse().get("highlighting"); + NamedList hl = (NamedList)srsp.getSolrResponse().getResponse().get("highlighting"); for (int i=0; i future = completionService.take(); pending.remove(future); ShardResponse rsp = future.get(); - rsp.req.responses.add(rsp); - if (rsp.req.responses.size() == rsp.req.actualShards.length) { + rsp.getShardRequest().responses.add(rsp); + if (rsp.getShardRequest().responses.size() == rsp.getShardRequest().actualShards.length) { return rsp; } } catch (InterruptedException e) { @@ -419,13 +419,13 @@ class HttpCommComponent { Future future = completionService.take(); pending.remove(future); ShardResponse rsp = future.get(); - if (rsp.exception != null) return rsp; // if exception, return immediately + if (rsp.getException() != null) return rsp; // if exception, return immediately // add response to the response list... we do this after the take() and // not after the completion of "call" so we know when the last response // for a request was received. Otherwise we might return the same // request more than once. - rsp.req.responses.add(rsp); - if (rsp.req.responses.size() == rsp.req.actualShards.length) { + rsp.getShardRequest().responses.add(rsp); + if (rsp.getShardRequest().responses.size() == rsp.getShardRequest().actualShards.length) { return rsp; } } catch (InterruptedException e) { diff --git a/src/java/org/apache/solr/handler/component/ShardRequest.java b/src/java/org/apache/solr/handler/component/ShardRequest.java index 47b43b8fa7f..2a9f50cab33 100755 --- a/src/java/org/apache/solr/handler/component/ShardRequest.java +++ b/src/java/org/apache/solr/handler/component/ShardRequest.java @@ -16,14 +16,11 @@ */ package org.apache.solr.handler.component; -import org.apache.solr.client.solrj.SolrResponse; -import org.apache.solr.common.params.ModifiableSolrParams; -import org.apache.solr.common.SolrException; -import org.apache.solr.common.util.NamedList; - import java.util.ArrayList; import java.util.List; +import org.apache.solr.common.params.ModifiableSolrParams; + // todo... when finalized make accessors public class ShardRequest { @@ -66,21 +63,3 @@ public class ShardRequest { + "}"; } } - - -class ShardResponse { - public ShardRequest req; - public String shard; - public String shardAddress; // the specific shard that this response was received from - public int rspCode; - public Throwable exception; - public SolrResponse rsp; - - public String toString() { - return "ShardResponse:{shard="+shard+",shardAddress="+shardAddress - +"\n\trequest=" + req - +"\n\tresponse=" + rsp - + (exception==null ? "" : "\n\texception="+ SolrException.toStr(exception)) - +"\n}"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/solr/handler/component/ShardResponse.java b/src/java/org/apache/solr/handler/component/ShardResponse.java new file mode 100755 index 00000000000..15321d05563 --- /dev/null +++ b/src/java/org/apache/solr/handler/component/ShardResponse.java @@ -0,0 +1,66 @@ +package org.apache.solr.handler.component; + +import org.apache.solr.client.solrj.SolrResponse; +import org.apache.solr.common.SolrException; + +public final class ShardResponse { + private ShardRequest req; + private String shard; + private String shardAddress; // the specific shard that this response was received from + private int rspCode; + private Throwable exception; + private SolrResponse rsp; + + public String toString() { + return "ShardResponse:{shard="+shard+",shardAddress="+shardAddress + +"\n\trequest=" + req + +"\n\tresponse=" + rsp + + (exception==null ? "" : "\n\texception="+ SolrException.toStr(exception)) + +"\n}"; + } + + public Throwable getException() + { + return exception; + } + + public ShardRequest getShardRequest() + { + return req; + } + + public SolrResponse getSolrResponse() + { + return rsp; + } + + public String getShard() + { + return shard; + } + + void setShardRequest(ShardRequest rsp) + { + this.req = rsp; + } + + void setSolrResponse(SolrResponse rsp) + { + this.rsp = rsp; + } + + void setShard(String shard) + { + this.shard = shard; + } + + void setException(Throwable exception) + { + this.exception = exception; + } + + void setResponseCode(int rspCode) + { + this.rspCode = rspCode; + } +}