Skip to content
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

Replace CloudLegacySolrClient with CloudHttp2SolrClient in SolrClientCloudManager #2751

Merged
merged 12 commits into from
Oct 24, 2024
16 changes: 13 additions & 3 deletions solr/core/src/java/org/apache/solr/cloud/ZkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.cloud.SolrCloudManager;
import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient;
import org.apache.solr.client.solrj.impl.Http2SolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient.Builder;
import org.apache.solr.client.solrj.impl.SolrClientCloudManager;
import org.apache.solr.client.solrj.impl.SolrZkClientTimeout;
Expand Down Expand Up @@ -199,6 +200,9 @@ public String toString() {
public final ZkStateReader zkStateReader;
private SolrCloudManager cloudManager;

// only for internal usage-only
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved
private Http2SolrClient http2SolrClient;

private CloudHttp2SolrClient cloudSolrClient;

private final String zkServerAddress; // example: 127.0.0.1:54062/solr
Expand Down Expand Up @@ -769,6 +773,7 @@ public void close() {

sysPropsCacher.close();
customThreadPool.execute(() -> IOUtils.closeQuietly(cloudSolrClient));
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved
customThreadPool.execute(() -> IOUtils.closeQuietly(http2SolrClient));
customThreadPool.execute(() -> IOUtils.closeQuietly(cloudManager));
dsmiley marked this conversation as resolved.
Show resolved Hide resolved

try {
Expand Down Expand Up @@ -865,10 +870,15 @@ public SolrCloudManager getSolrCloudManager() {
if (cloudManager != null) {
return cloudManager;
}
cloudSolrClient =
new CloudHttp2SolrClient.Builder(
Collections.singletonList(getZkServerAddress()), Optional.empty())
http2SolrClient =
new Http2SolrClient.Builder()
.withHttpClient(cc.getDefaultHttpSolrClient())
.withIdleTimeout(30000, TimeUnit.MILLISECONDS)
.withConnectionTimeout(15000, TimeUnit.MILLISECONDS)
.build();
cloudSolrClient =
new CloudHttp2SolrClient.Builder(List.of(getZkServerAddress()), Optional.empty())
.withHttpClient(http2SolrClient)
.build();
cloudManager = new SolrClientCloudManager(cc.getObjectCache(), cloudSolrClient);
cloudManager.getClusterStateProvider().connect();
Expand Down
Loading