Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.apache.solr.client.solrj.cloud.DistribStateManager;
import org.apache.solr.client.solrj.cloud.SolrCloudManager;
import org.apache.solr.client.solrj.cloud.VersionedData;
import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient;
import org.apache.solr.client.solrj.impl.NodeValueFetcher;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.MetricsRequest;
Expand Down Expand Up @@ -879,7 +878,7 @@ public static void checkDiskSpace(
var req = new MetricsRequest(params);
req.setResponseParser(new InputStreamResponseParser("prometheus"));

var cloudClient = (CloudHttp2SolrClient) cloudManager.getSolrClient();
var cloudClient = cloudManager.getSolrClient();
var httpClient = cloudClient.getHttpClient();

NamedList<Object> resp =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.jetty.CloudJettySolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.SolrQuery;
Expand Down Expand Up @@ -157,7 +156,7 @@ private void doSplitStaticIndexReplication(SolrIndexSplitter.SplitMethod splitMe
builder
.withDefaultCollection(collectionName)
.sendUpdatesOnlyToShardLeaders()
.withHttpClient(((CloudJettySolrClient) cloudClient).getHttpClient())
.withHttpClient(cloudClient.getHttpClient())
.build()) {
StoppableIndexingThread thread =
new StoppableIndexingThread(controlClient, client, "i1", true);
Expand Down
4 changes: 2 additions & 2 deletions solr/solr-ref-guide/modules/deployment-guide/pages/solrj.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ processing time of the largest update request.

=== Cloud Request Routing

The SolrJ `CloudSolrClient` implementations (`CloudSolrClient` and `CloudHttp2SolrClient`) respect the xref:solrcloud-distributed-requests.adoc#shards-preference-parameter[shards.preference parameter].
Therefore requests sent to single-sharded collections, using either of the above clients, will route requests the same way that distributed requests are routed to individual shards.
SolrJ `CloudSolrClient` respects the xref:solrcloud-distributed-requests.adoc#shards-preference-parameter[shards.preference parameter].
Therefore requests sent to single-sharded collections will route requests the same way that distributed requests are routed to individual shards.
If no `shards.preference` parameter is provided, the clients will default to sorting replicas randomly.

For update requests, while the replicas are sorted in the order defined by the request, leader replicas will always be sorted first.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,15 @@
public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

private final CloudHttp2SolrClient solrClient;
private final CloudSolrClient solrClient;
protected final Map<String, Map<String, Map<String, List<Replica>>>>
nodeVsCollectionVsShardVsReplicaInfo = new HashMap<>();

@SuppressWarnings({"rawtypes"})
private Map<String, Map> nodeVsTags = new HashMap<>();

public SolrClientNodeStateProvider(CloudSolrClient solrClient) {
if (!(solrClient instanceof CloudHttp2SolrClient)) {
throw new IllegalArgumentException(
"The passed-in CloudSolrClient must be a " + CloudHttp2SolrClient.class);
}
this.solrClient = (CloudHttp2SolrClient) solrClient;
this.solrClient = solrClient;
try {
readReplicaDetails();
} catch (IOException e) {
Expand Down Expand Up @@ -242,7 +238,7 @@ public String toString() {
static class RemoteCallCtx {

ZkClientClusterStateProvider zkClientClusterStateProvider;
CloudHttp2SolrClient cloudSolrClient;
CloudSolrClient cloudSolrClient;
public final Map<String, Object> tags = new HashMap<>();
private final String node;
public Map<String, Object> session;
Expand All @@ -254,7 +250,7 @@ public boolean isNodeAlive(String node) {
return true;
}

public RemoteCallCtx(String node, CloudHttp2SolrClient cloudSolrClient) {
public RemoteCallCtx(String node, CloudSolrClient cloudSolrClient) {
this.node = node;
this.cloudSolrClient = cloudSolrClient;
this.zkClientClusterStateProvider =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public ClusterStateProvider getClusterStateProvider() {
return stateProvider;
}

@Override
public HttpSolrClient getHttpClient() {
return myClient;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,9 @@ public void close() {
}
}

/** The HttpSolrClient that underlies this one. It has no baseUrl or default collection. */
public abstract HttpSolrClient getHttpClient();

public ResponseParser getParser() {
return getLbClient().getParser();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,11 @@ public ClusterStateProvider getClusterStateProvider() {
return provider;
}

@Override
public HttpSolrClient getHttpClient() {
throw new UnsupportedOperationException();
}

@FunctionalInterface
interface Invocation {
NamedList<Object> invoke(SolrRequest<?> request, List<String> inputCollections)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.lucene.tests.util.TestUtil;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.jetty.CloudJettySolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.CollectionAdminRequest.ClusterProp;
import org.apache.solr.client.solrj.request.QueryRequest;
Expand Down Expand Up @@ -467,12 +466,13 @@ private void testBackupAndRestore(String collectionName) throws Exception {
public static Map<String, Integer> getShardToDocCountMap(
CloudSolrClient client, DocCollection docCollection) throws SolrServerException, IOException {
Map<String, Integer> shardToDocCount = new TreeMap<>();
var jettySolrClient = ((CloudJettySolrClient) client).getHttpClient();
for (Slice slice : docCollection.getActiveSlices()) {
long docsInShard =
new QueryRequest("/select", params("q", "*:*", "distrib", "false"))
.processWithBaseUrl(
jettySolrClient, slice.getLeader().getBaseUrl(), slice.getLeader().getCoreName())
client.getHttpClient(),
slice.getLeader().getBaseUrl(),
slice.getLeader().getCoreName())
.getResults()
.getNumFound();
shardToDocCount.put(slice.getName(), (int) docsInShard);
Expand Down
Loading