Skip to content

SOLR-17043: Remove SolrClient path pattern matching #3238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
08fa4e8
Change getRequestType and update CloudSolrClient
Feb 25, 2025
4ba37c4
Deprecate IsUpdateRequest
Feb 28, 2025
8ded9cf
Remove references to ADMIN_PATHS
Feb 28, 2025
9a06708
Add getBaseRequestType for more complex use cases
Feb 28, 2025
48cb77b
spotlessApply
Mar 3, 2025
0a47d38
Use getBaseRequestType for everything
Mar 3, 2025
3188648
getBaseRequestType should be protected, not public
Mar 4, 2025
7d891a6
Fix request routing for misclassified requests
Mar 4, 2025
654beb6
doc wording
Mar 4, 2025
e262274
gradlew check
Mar 4, 2025
37ecfe8
Fix Javadoc warning
Mar 4, 2025
5ff4c37
Make getRequestType final
Mar 10, 2025
1204f32
Replace getBaseRequestType with a defaultType field
Mar 14, 2025
46330f4
typo
Mar 14, 2025
7d7b9ee
Make requestType an explicit constructor param
Mar 17, 2025
605ff05
Move sendToLeaders to UpdateReqeust
Mar 20, 2025
73d92e9
Restore request types of V2Request and FieldAnalysisRequest
Mar 25, 2025
ae4f8db
Remove extra logic in SolrRequest, fix CloudSolrClient issue, and sta…
Apr 7, 2025
16c52b4
spotlessApply
Apr 7, 2025
63463f8
Fix 11/23 failing test
Apr 7, 2025
baacbc1
Fix remaining tests
Apr 8, 2025
5237b0b
Fix TestRebalanceLeaders
Apr 8, 2025
57ac132
typo
Apr 8, 2025
fe7afc4
Remove IsUpdateRequest from AbstractUpdateRequest
Apr 8, 2025
a8af543
Fix CollectionRequiringSolrRequest
Apr 10, 2025
9a714cb
Remove unnecessary deps
Apr 10, 2025
a0082c5
Make sure logic matches in LBSolrClient
Apr 10, 2025
4822570
Minor review feedback cleanup
gerlowskija Apr 16, 2025
481afeb
Fix 'check'
gerlowskija Apr 17, 2025
7dd4bdc
Merge branch 'main' into feat/SOLR-17043
gerlowskija Apr 17, 2025
e4d0141
Add CHANGES.txt entry
gerlowskija Apr 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Improvements

* SOLR-17705: SolrJ's SolrRequest now allows any type for its response; needn't be SolrResponse. (David Smiley)

* SOLR-17043: "LB" and "Cloud" clients no longer use brittle URL pattern-matching when routing requests. (Jude Muriithi via David Smiley, Jason Gerlowski)

Optimizations
---------------------
* SOLR-17568: The CLI bin/solr export tool now contacts the appropriate nodes directly for data instead of proxying through one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,8 @@ public static void checkDiskSpace(
.add("key", indexSizeMetricName)
.add("key", freeDiskSpaceMetricName);
SolrResponse rsp =
new GenericSolrRequest(SolrRequest.METHOD.GET, "/admin/metrics", params)
new GenericSolrRequest(
SolrRequest.METHOD.GET, "/admin/metrics", SolrRequest.SolrRequestType.ADMIN, params)
.process(cloudManager.getSolrClient());

Number size = (Number) rsp.getResponse().findRecursive("metrics", indexSizeMetricName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import org.apache.solr.api.AnnotatedApi;
import org.apache.solr.api.Api;
import org.apache.solr.api.ApiBag;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.io.stream.expr.Expressible;
Expand Down Expand Up @@ -966,7 +965,7 @@ private static class PerReplicaCallable extends CollectionRequiringSolrRequest<S
int maxWait;

PerReplicaCallable(Replica replica, String prop, int expectedZkVersion, int maxWait) {
super(METHOD.GET, "/config/" + ZNODEVER);
super(METHOD.GET, "/config/" + ZNODEVER, SolrRequestType.ADMIN);
this.replica = replica;
this.expectedZkVersion = expectedZkVersion;
this.prop = prop;
Expand Down Expand Up @@ -1030,11 +1029,6 @@ public Boolean call() throws Exception {
protected SolrResponse createResponse(NamedList<Object> namedList) {
return null;
}

@Override
public String getRequestType() {
return SolrRequest.SolrRequestType.ADMIN.toString();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import java.util.concurrent.TimeUnit;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.Version;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionRequiringSolrRequest;
Expand Down Expand Up @@ -356,7 +355,7 @@ private static class GetZkSchemaVersionCallable

GetZkSchemaVersionCallable(
String baseUrl, String coreName, int expectedZkVersion, ZkController zkController) {
super(METHOD.GET, "/schema/zkversion");
super(METHOD.GET, "/schema/zkversion", SolrRequestType.ADMIN);
this.zkController = zkController;
this.baseUrl = baseUrl;
this.coreName = coreName;
Expand Down Expand Up @@ -412,11 +411,6 @@ public Integer call() throws Exception {
protected SolrResponse createResponse(NamedList<Object> namedList) {
return null;
}

@Override
public String getRequestType() {
return SolrRequest.SolrRequestType.ADMIN.toString();
}
}

public static class FieldExistsException extends SolrException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testPathIsAddedToContext() throws IOException, SolrServerException {
private static class SystemInfoRequest extends SolrRequest<QueryResponse> {

public SystemInfoRequest() {
super(METHOD.GET, "/admin/info/system");
super(METHOD.GET, "/admin/info/system", SolrRequest.SolrRequestType.ADMIN);
}

@Override
Expand All @@ -59,10 +59,5 @@ public SolrParams getParams() {
protected QueryResponse createResponse(final NamedList<Object> namedList) {
return new QueryResponse();
}

@Override
public String getRequestType() {
return SolrRequest.SolrRequestType.ADMIN.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.api.AnnotatedApi;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.SolrRequest.SolrRequestType;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudLegacySolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest;
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Create;
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Delete;
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Upload;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.GenericSolrRequest;
import org.apache.solr.client.solrj.request.schema.SchemaRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.client.solrj.response.ConfigSetAdminResponse;
Expand Down Expand Up @@ -1487,8 +1489,8 @@ protected CollectionAdminResponse createCollection(
params.set("name", collectionName);
params.set("numShards", numShards);
params.set("replicationFactor", replicationFactor);
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
var request =
new GenericSolrRequest(METHOD.GET, "/admin/collections", SolrRequestType.ADMIN, params);

CollectionAdminResponse res = new CollectionAdminResponse();
res.setResponse(client.request(request));
Expand Down
29 changes: 17 additions & 12 deletions solr/core/src/test/org/apache/solr/cloud/TestRebalanceLeaders.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@
import java.util.TreeSet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.SolrRequest.SolrRequestType;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.GenericSolrRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.SimpleSolrResponse;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.TimeSource;
import org.apache.solr.embedded.JettySolrRunner;
import org.apache.solr.util.TimeOut;
Expand Down Expand Up @@ -408,13 +411,14 @@ private void rebalanceLeaderUsingStandardRequest() throws IOException, SolrServe
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.REBALANCELEADERS.toString());
params.set("collection", COLLECTION_NAME);
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
QueryResponse resp = request.process(cluster.getSolrClient());
var request =
new GenericSolrRequest(METHOD.GET, "/admin/collections", SolrRequestType.ADMIN, params);
SimpleSolrResponse resp = request.process(cluster.getSolrClient());
assertTrue(
"All leaders should have been verified",
resp.getResponse().get("Summary").toString().contains("Success"));
assertEquals("Call to rebalanceLeaders failed ", 0, resp.getStatus());
NamedList<?> header = (NamedList) resp.getResponse().get("responseHeader");
assertEquals("Call to rebalanceLeaders failed ", 0, header.get("status"));
}

private void rebalancePropUsingSolrJAPI(String prop) throws IOException, SolrServerException {
Expand Down Expand Up @@ -445,10 +449,11 @@ private void rebalancePropUsingStandardRequest(String prop)
if (prop.toLowerCase(Locale.ROOT).contains("preferredleader") == false) {
params.set("shardUnique", true);
}
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
QueryResponse resp = request.process(cluster.getSolrClient());
assertEquals("Call to rebalanceLeaders failed ", 0, resp.getStatus());
var request =
new GenericSolrRequest(METHOD.GET, "/admin/collections", SolrRequestType.ADMIN, params);
var resp = request.process(cluster.getSolrClient());
NamedList<?> header = (NamedList) resp.getResponse().get("responseHeader");
assertEquals("Call to rebalanceLeaders failed ", 0, header.get("status"));
}

// This important. I've (Erick Erickson) run across a situation where the "standard request"
Expand Down Expand Up @@ -479,8 +484,8 @@ void setPropWithStandardRequest(Slice slice, Replica rep, String prop)
params.set("shardUnique", "true");
}

QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
var request =
new GenericSolrRequest(METHOD.GET, "/admin/collections", SolrRequestType.ADMIN, params);
cluster.getSolrClient().request(request);
String propLC = prop.toLowerCase(Locale.ROOT);
waitForState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.SolrRequest.SolrRequestType;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.GenericSolrRequest;
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.DocCollection;
Expand All @@ -47,8 +49,8 @@ public static NamedList<Object> doPropertyAction(CloudSolrClient client, String.
for (int idx = 0; idx < paramsIn.length; idx += 2) {
params.set(paramsIn[idx], paramsIn[idx + 1]);
}
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
var request =
new GenericSolrRequest(METHOD.GET, "/admin/collections", SolrRequestType.ADMIN, params);
return client.request(request);
}

Expand Down
Loading
Loading