You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2017/07/26 11:52:37 UTC
[1/3] lucene-solr:branch_7_0: SOLR-11130: V2Request is SolrJ should
return the correct collection name
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7_0 32b2b6d10 -> 0fc791af3
SOLR-11130: V2Request is SolrJ should return the correct collection name
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/3a8bcad5
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/3a8bcad5
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/3a8bcad5
Branch: refs/heads/branch_7_0
Commit: 3a8bcad5c6e83b48888c66d65e1226cb2ef860c4
Parents: 32b2b6d
Author: Noble Paul <no...@apache.org>
Authored: Wed Jul 26 21:10:21 2017 +0930
Committer: Noble Paul <no...@apache.org>
Committed: Wed Jul 26 21:21:28 2017 +0930
----------------------------------------------------------------------
.../org/apache/solr/client/solrj/SolrRequest.java | 5 +++++
.../solr/client/solrj/impl/CloudSolrClient.java | 8 ++++----
.../solr/client/solrj/request/V2Request.java | 18 ++++++++++++++++--
.../solr/client/solrj/request/TestV2Request.java | 9 +++++++++
4 files changed, 34 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a8bcad5/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
index fe5c4fc..37bc5e3 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
@@ -16,6 +16,7 @@
*/
package org.apache.solr.client.solrj;
+import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
@@ -195,4 +196,8 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
return process(client, null);
}
+ public String getCollection() {
+ return getParams() == null ? null : getParams().get("collection");
+ }
+
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a8bcad5/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index eeb96af..7da9d6e 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -786,10 +786,10 @@ public class CloudSolrClient extends SolrClient {
@Override
public NamedList<Object> request(SolrRequest request, String collection) throws SolrServerException, IOException {
- SolrParams reqParams = request.getParams();
-
- if (collection == null)
- collection = (reqParams != null) ? reqParams.get("collection", getDefaultCollection()) : getDefaultCollection();
+ if (collection == null) {
+ collection = request.getCollection();
+ if (collection == null) collection = defaultCollection;
+ }
return requestWithRetryOnStaleState(request, 0, collection);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a8bcad5/solr/solrj/src/java/org/apache/solr/client/solrj/request/V2Request.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/V2Request.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/V2Request.java
index 39220d1..6694487 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/V2Request.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/V2Request.java
@@ -24,6 +24,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.solr.client.solrj.SolrClient;
@@ -38,14 +39,22 @@ import org.apache.solr.common.util.Utils;
public class V2Request extends SolrRequest<V2Response> {
//only for debugging purposes
public static final ThreadLocal<AtomicLong> v2Calls = new ThreadLocal<>();
- static final Pattern COLL_REQ_PATTERN = Pattern.compile("/(c|collections)/[^/]+/(?!shards)");
+ static final Pattern COLL_REQ_PATTERN = Pattern.compile("/(c|collections)/([^/])+/(?!shards)");
private InputStream payload;
private SolrParams solrParams;
public final boolean useBinary;
+ private String collection;
+ private boolean isPerCollectionRequest = false;
private V2Request(METHOD m, String resource, boolean useBinary) {
super(m, resource);
+ Matcher matcher = COLL_REQ_PATTERN.matcher(getPath());
+ if (matcher.find()) {
+ this.collection = matcher.group(2);
+ isPerCollectionRequest = true;
+ }
this.useBinary = useBinary;
+
}
@Override
@@ -73,7 +82,12 @@ public class V2Request extends SolrRequest<V2Response> {
}
public boolean isPerCollectionRequest() {
- return COLL_REQ_PATTERN.matcher(getPath()).find();
+ return isPerCollectionRequest;
+ }
+
+ @Override
+ public String getCollection() {
+ return collection;
}
@Override
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a8bcad5/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java
index 61f771e..566405f 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java
@@ -49,6 +49,7 @@ public class TestV2Request extends SolrCloudTestCase {
assertFalse(new V2Request.Builder("/collections/a/shards").build().isPerCollectionRequest());
assertFalse(new V2Request.Builder("/collections/a/shards/").build().isPerCollectionRequest());
assertTrue(new V2Request.Builder("/collections/a/update").build().isPerCollectionRequest());
+ assertEquals("a", new V2Request.Builder("/collections/a/update").build().getCollection());
assertTrue(new V2Request.Builder("/c/a/update").build().isPerCollectionRequest());
assertTrue(new V2Request.Builder("/c/a/schema").build().isPerCollectionRequest());
assertFalse(new V2Request.Builder("/c/a").build().isPerCollectionRequest());
@@ -80,10 +81,18 @@ public class TestV2Request extends SolrCloudTestCase {
"}").build());
assertSuccess(client, new V2Request.Builder("/c").build());
assertSuccess(client, new V2Request.Builder("/c/_introspect").build());
+
+
+ assertSuccess(client, new V2Request.Builder("/c/test/config")
+ .withMethod(SolrRequest.METHOD.POST)
+ .withPayload("{'create-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' , 'startup' : 'lazy'}}")
+ .build());
+
assertSuccess(client, new V2Request.Builder("/c/test").withMethod(SolrRequest.METHOD.DELETE).build());
NamedList<Object> res = client.request(new V2Request.Builder("/c").build());
List collections = (List) res.get("collections");
assertEquals(0, collections.size());
+
}
}
[3/3] lucene-solr:branch_7_0: SOLR-11130: change was added in wrong
version
Posted by no...@apache.org.
SOLR-11130: change was added in wrong version
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/0fc791af
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/0fc791af
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/0fc791af
Branch: refs/heads/branch_7_0
Commit: 0fc791af379721bc9e30782011e378b3c6455aae
Parents: e79d1f2
Author: Noble Paul <no...@apache.org>
Authored: Wed Jul 26 21:19:23 2017 +0930
Committer: Noble Paul <no...@apache.org>
Committed: Wed Jul 26 21:21:41 2017 +0930
----------------------------------------------------------------------
solr/CHANGES.txt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0fc791af/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f4ba6a0..6bac127 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -291,6 +291,9 @@ Bug Fixes
* SOLR-11136: Fix solrj XMLResponseParser when nested docs transformer is used with indented XML (hossman)
+* SOLR-11130: V2Request in SolrJ should return the correct collection name so that the request is forwarded to the
+ correct node (noble)
+
Optimizations
----------------------
@@ -2233,8 +2236,6 @@ Bug Fixes
* SOLR-9391: LBHttpSolrClient.request now correctly returns Rsp.server when
previously skipped servers were successfully tried. (Christine Poerschke)
-* SOLR-11130: V2Request in SolrJ should return the correct collection name so that the request is forwarded to the
- correct node (noble)
Optimizations
----------------------
[2/3] lucene-solr:branch_7_0: SOLR-11130: V2Request in SolrJ should
return the correct collection name so that the request is forwarded to the
correct node
Posted by no...@apache.org.
SOLR-11130: V2Request in SolrJ should return the correct collection name so that the request is forwarded to the correct node
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e79d1f24
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e79d1f24
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e79d1f24
Branch: refs/heads/branch_7_0
Commit: e79d1f2470e3698a95a54354be1b6d54cf322dba
Parents: 3a8bcad
Author: Noble Paul <no...@apache.org>
Authored: Wed Jul 26 21:13:53 2017 +0930
Committer: Noble Paul <no...@apache.org>
Committed: Wed Jul 26 21:21:35 2017 +0930
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e79d1f24/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e3b6aef..f4ba6a0 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -2233,6 +2233,9 @@ Bug Fixes
* SOLR-9391: LBHttpSolrClient.request now correctly returns Rsp.server when
previously skipped servers were successfully tried. (Christine Poerschke)
+* SOLR-11130: V2Request in SolrJ should return the correct collection name so that the request is forwarded to the
+ correct node (noble)
+
Optimizations
----------------------