You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2018/02/10 14:18:31 UTC

lucene-solr:master: SOLR-3089: RequestBuilder now exposes isDistrib() method

Repository: lucene-solr
Updated Branches:
  refs/heads/master 1fe34f1e8 -> 1f3d971a7


SOLR-3089: RequestBuilder now exposes isDistrib() method


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1f3d971a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1f3d971a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1f3d971a

Branch: refs/heads/master
Commit: 1f3d971a757edd694adbc492f2de08263921eb01
Parents: 1fe34f1
Author: Ishan Chattopadhyaya <is...@apache.org>
Authored: Sat Feb 10 19:48:11 2018 +0530
Committer: Ishan Chattopadhyaya <is...@apache.org>
Committed: Sat Feb 10 19:48:11 2018 +0530

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  3 ++
 .../solr/handler/component/ResponseBuilder.java |  7 +++
 .../solr/handler/ResponseBuilderTest.java       | 46 ++++++++++++++++++++
 3 files changed, 56 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1f3d971a/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 99415a2..6bcb5e0 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.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1f3d971a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
----------------------------------------------------------------------
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.java
index df0623e..1f9e2d5 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 ResponseBuilder
   public List<ShardRequest> finished;  // requests that have received responses from all shards
   public 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;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1f3d971a/solr/core/src/test/org/apache/solr/handler/ResponseBuilderTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/ResponseBuilderTest.java b/solr/core/src/test/org/apache/solr/handler/ResponseBuilderTest.java
new file mode 100644
index 0000000..2ac6727
--- /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());
+
+  }
+
+}