Apache Lucene open-source search software
SOLR-3089: RequestBuilder now exposes isDistrib() method
Ishan Chattopadhyaya1f3d971a757e
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 99415a2d7c6..6bcb5e04f20 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -274,6 +274,9 @@ Other Changes* SOLR-11902: Clarify in bin/solr help text whether commands can be run remotely (Jason Gerlowski)+* SOLR-3089: RequestBuilder now exposes isDistrib() method. Using this, plugins can know whether a request is+ distributed. (Rok Rejc, Frank Wesemann, Abhishek Kumar Singh, Mikhail Khludnev via Ishan Chattopadhyaya)+================== 7.2.1 ==================Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.diff --git a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java b/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.javaindex df0623e11fc..1f9e2d51183 100644--- a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java+++ b/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java@@ -139,6 +139,13 @@ public class ResponseBuilderpublic List<ShardRequest> finished; // requests that have received responses from all shardspublic String shortCircuitedURL;+ /**+ * This function will return true if this was a distributed search request.+ */+ public boolean isDistributed() {+ return this.isDistrib;+ }+public int getShardNum(String shard) {for (int i = 0; i < shards.length; i++) {if (shards[i] == shard || shards[i].equals(shard)) return i;diff --git a/solr/core/src/test/org/apache/solr/handler/ResponseBuilderTest.java b/solr/core/src/test/org/apache/solr/handler/ResponseBuilderTest.javanew file mode 100644index 00000000000..2ac6727d83b--- /dev/null+++ b/solr/core/src/test/org/apache/solr/handler/ResponseBuilderTest.java@@ -0,0 +1,46 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++package org.apache.solr.handler;++import java.util.ArrayList;++import org.apache.solr.SolrTestCaseJ4;+import org.apache.solr.handler.component.ResponseBuilder;+import org.apache.solr.request.SolrQueryRequest;+import org.apache.solr.response.SolrQueryResponse;+import org.junit.BeforeClass;++public class ResponseBuilderTest extends SolrTestCaseJ4 {++ @BeforeClass+ public static void beforeClass() throws Exception {+ initCore("solrconfig.xml", "schema.xml");+ }++ //This test is being added to verify responseBuilder.isDistributed() exists and is visible.+ public void testIsDistrib(){++ SolrQueryRequest req = req("q", "title:test");+ SolrQueryResponse rsp = new SolrQueryResponse();++ ResponseBuilder responseBuilder = new ResponseBuilder(req, rsp, new ArrayList<>(0));+ assertFalse(responseBuilder.isDistributed());++ }++}