From 57e11d5ca9699456f334570bbe08266b5b3c0b3a Mon Sep 17 00:00:00 2001 From: Sanjay Dutt Date: Tue, 8 Oct 2024 17:06:01 +0530 Subject: [PATCH 1/8] Replaced CloudLegacySolrClient with CloudHttp2SolrClient for SolrClientCloudManager --- .../org/apache/solr/cloud/ZkController.java | 19 ++-- .../org/apache/solr/cloud/OverseerTest.java | 21 ++-- .../apache/solr/cloud/ZkControllerTest.java | 9 ++ .../solrj/cloud/DelegatingCloudManager.java | 13 --- .../client/solrj/cloud/SolrCloudManager.java | 10 -- .../solrj/impl/SolrClientCloudManager.java | 95 ++----------------- .../impl/SolrClientNodeStateProvider.java | 34 +++---- .../solrj/impl/NodeValueFetcherTest.java | 50 +++++----- 8 files changed, 84 insertions(+), 167 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index a1ebe69374c..dad69dc365f 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -54,11 +54,10 @@ import java.util.stream.Collectors; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.cloud.SolrCloudManager; -import org.apache.solr.client.solrj.impl.CloudLegacySolrClient; +import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient; 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; -import org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; import org.apache.solr.client.solrj.request.CoreAdminRequest.WaitForState; import org.apache.solr.cloud.overseer.ClusterStateMutator; import org.apache.solr.cloud.overseer.OverseerAction; @@ -199,7 +198,8 @@ public String toString() { private final SolrZkClient zkClient; public final ZkStateReader zkStateReader; private SolrCloudManager cloudManager; - private CloudLegacySolrClient cloudSolrClient; + + private CloudHttp2SolrClient solrCloudClient; private final String zkServerAddress; // example: 127.0.0.1:54062/solr @@ -768,7 +768,7 @@ public void close() { } finally { sysPropsCacher.close(); - customThreadPool.execute(() -> IOUtils.closeQuietly(cloudSolrClient)); + customThreadPool.execute(() -> IOUtils.closeQuietly(solrCloudClient)); customThreadPool.execute(() -> IOUtils.closeQuietly(cloudManager)); try { @@ -865,13 +865,12 @@ public SolrCloudManager getSolrCloudManager() { if (cloudManager != null) { return cloudManager; } - cloudSolrClient = - new CloudLegacySolrClient.Builder(new ZkClientClusterStateProvider(zkStateReader)) - .withHttpClient(cc.getUpdateShardHandler().getDefaultHttpClient()) - .withConnectionTimeout(15000, TimeUnit.MILLISECONDS) - .withSocketTimeout(30000, TimeUnit.MILLISECONDS) + solrCloudClient = + new CloudHttp2SolrClient.Builder( + Collections.singletonList(getZkServerAddress()), Optional.empty()) + .withHttpClient(cc.getDefaultHttpSolrClient()) .build(); - cloudManager = new SolrClientCloudManager(cloudSolrClient, cc.getObjectCache()); + cloudManager = new SolrClientCloudManager(cc.getObjectCache(), solrCloudClient); cloudManager.getClusterStateProvider().connect(); } return cloudManager; diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java index 8d3b94071d8..949779376cf 100644 --- a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java @@ -52,8 +52,8 @@ import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.cloud.DistributedQueue; import org.apache.solr.client.solrj.cloud.SolrCloudManager; -import org.apache.solr.client.solrj.impl.CloudLegacySolrClient; -import org.apache.solr.client.solrj.impl.CloudSolrClient; +import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient; +import org.apache.solr.client.solrj.impl.Http2SolrClient; import org.apache.solr.client.solrj.impl.SolrClientCloudManager; import org.apache.solr.cloud.overseer.NodeMutator; import org.apache.solr.cloud.overseer.OverseerAction; @@ -127,7 +127,7 @@ public class OverseerTest extends SolrTestCaseJ4 { Collections.synchronizedList(new ArrayList<>()); private final List updateShardHandlers = Collections.synchronizedList(new ArrayList<>()); - private final List solrClients = Collections.synchronizedList(new ArrayList<>()); + private final List solrClients = Collections.synchronizedList(new ArrayList<>()); private static final String COLLECTION = SolrTestCaseJ4.DEFAULT_TEST_COLLECTION_NAME; public static class MockZKController { @@ -1948,13 +1948,18 @@ public Void answer(InvocationOnMock invocation) { } private SolrCloudManager getCloudDataProvider(String zkAddress) { - var client = - new CloudLegacySolrClient.Builder(Collections.singletonList(zkAddress), Optional.empty()) - .withSocketTimeout(30000, TimeUnit.MILLISECONDS) + var httpSolrClient = + new Http2SolrClient.Builder() + .withIdleTimeout(30000, TimeUnit.MILLISECONDS) .withConnectionTimeout(15000, TimeUnit.MILLISECONDS) .build(); - solrClients.add(client); - SolrClientCloudManager sccm = new SolrClientCloudManager(client); + var cloudSolrClient = + new CloudHttp2SolrClient.Builder(Collections.singletonList(zkAddress), Optional.empty()) + .withHttpClient(httpSolrClient) + .build(); + solrClients.add(cloudSolrClient); + solrClients.add(httpSolrClient); + SolrClientCloudManager sccm = new SolrClientCloudManager(null, cloudSolrClient); sccm.getClusterStateProvider().connect(); return sccm; } diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java index d7f5d041ef4..6bda0dd6b53 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java @@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.apache.solr.SolrTestCaseJ4; +import org.apache.solr.client.solrj.impl.Http2SolrClient; import org.apache.solr.common.MapWriter; import org.apache.solr.common.cloud.ClusterProperties; import org.apache.solr.common.cloud.ClusterState; @@ -514,6 +515,7 @@ public void tearDown() throws Exception { private static class MockCoreContainer extends CoreContainer { UpdateShardHandler updateShardHandler = new UpdateShardHandler(UpdateShardHandlerConfig.DEFAULT); + Http2SolrClient solrClient; public MockCoreContainer() { super(SolrXmlConfig.fromString(TEST_PATH(), "")); @@ -522,6 +524,7 @@ public MockCoreContainer() { this.shardHandlerFactory = httpShardHandlerFactory; this.coreAdminHandler = new CoreAdminHandler(); this.metricManager = mock(SolrMetricManager.class); + this.solrClient = new Http2SolrClient.Builder().build(); } @Override @@ -535,9 +538,15 @@ public UpdateShardHandler getUpdateShardHandler() { @Override public void shutdown() { updateShardHandler.close(); + solrClient.close(); super.shutdown(); } + @Override + public Http2SolrClient getDefaultHttpSolrClient() { + return solrClient; + } + @Override public SolrMetricManager getMetricManager() { return metricManager; diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/cloud/DelegatingCloudManager.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/cloud/DelegatingCloudManager.java index cc8c265692f..c259ac3a29c 100644 --- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/cloud/DelegatingCloudManager.java +++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/cloud/DelegatingCloudManager.java @@ -17,7 +17,6 @@ package org.apache.solr.client.solrj.cloud; import java.io.IOException; -import java.util.Map; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrResponse; import org.apache.solr.client.solrj.impl.ClusterStateProvider; @@ -69,18 +68,6 @@ public T request(SolrRequest req) throws IOException return delegate.request(req); } - @Override - public byte[] httpRequest( - String url, - SolrRequest.METHOD method, - Map headers, - String payload, - int timeout, - boolean followRedirects) - throws IOException { - return delegate.httpRequest(url, method, headers, payload, timeout, followRedirects); - } - @Override public void close() throws IOException { delegate.close(); diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/cloud/SolrCloudManager.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/cloud/SolrCloudManager.java index f169bbc3443..d244addd952 100644 --- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/cloud/SolrCloudManager.java +++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/cloud/SolrCloudManager.java @@ -18,7 +18,6 @@ package org.apache.solr.client.solrj.cloud; import java.io.IOException; -import java.util.Map; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrResponse; import org.apache.solr.client.solrj.impl.ClusterStateProvider; @@ -53,13 +52,4 @@ default ClusterState getClusterState() throws IOException { // Solr-like methods T request(SolrRequest req) throws IOException; - - byte[] httpRequest( - String url, - SolrRequest.METHOD method, - Map headers, - String payload, - int timeout, - boolean followRedirects) - throws IOException; } diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java index 626a917e7ed..28fdea27801 100644 --- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java +++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java @@ -19,20 +19,6 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; -import java.nio.charset.StandardCharsets; -import java.util.Map; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.entity.StringEntity; -import org.apache.http.util.EntityUtils; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrResponse; import org.apache.solr.client.solrj.SolrServerException; @@ -51,21 +37,17 @@ public class SolrClientCloudManager implements SolrCloudManager { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - protected final CloudLegacySolrClient solrClient; + // protected final CloudLegacySolrClient solrClient; private final ZkDistribStateManager stateManager; private final ZkStateReader zkStateReader; private final SolrZkClient zkClient; private final ObjectCache objectCache; private final boolean closeObjectCache; private volatile boolean isClosed; + private final CloudHttp2SolrClient cloudSolrClient; - public SolrClientCloudManager(CloudLegacySolrClient solrClient) { - this(solrClient, null); - } - - public SolrClientCloudManager(CloudLegacySolrClient solrClient, ObjectCache objectCache) { - this.solrClient = solrClient; - this.zkStateReader = ZkStateReader.from(solrClient); + public SolrClientCloudManager(ObjectCache objectCache, CloudHttp2SolrClient client) { + this.zkStateReader = ZkStateReader.from(client); this.zkClient = zkStateReader.getZkClient(); this.stateManager = new ZkDistribStateManager(zkClient); this.isClosed = false; @@ -76,6 +58,7 @@ public SolrClientCloudManager(CloudLegacySolrClient solrClient, ObjectCache obje this.objectCache = objectCache; this.closeObjectCache = false; } + this.cloudSolrClient = client; } @Override @@ -103,12 +86,12 @@ public TimeSource getTimeSource() { @Override public ClusterStateProvider getClusterStateProvider() { - return solrClient.getClusterStateProvider(); + return cloudSolrClient.getClusterStateProvider(); } @Override public NodeStateProvider getNodeStateProvider() { - return new SolrClientNodeStateProvider(solrClient); + return new SolrClientNodeStateProvider(cloudSolrClient); } @Override @@ -119,7 +102,7 @@ public DistribStateManager getDistribStateManager() { @Override public T request(SolrRequest req) throws IOException { try { - return req.process(solrClient); + return req.process(cloudSolrClient); } catch (SolrServerException e) { throw new IOException(e); } @@ -127,68 +110,6 @@ public T request(SolrRequest req) throws IOException private static final byte[] EMPTY = new byte[0]; - @Override - public byte[] httpRequest( - String url, - SolrRequest.METHOD method, - Map headers, - String payload, - int timeout, - boolean followRedirects) - throws IOException { - HttpClient client = solrClient.getHttpClient(); - final HttpRequestBase req; - HttpEntity entity = null; - if (payload != null) { - entity = new StringEntity(payload, StandardCharsets.UTF_8); - } - switch (method) { - case GET: - req = new HttpGet(url); - break; - case POST: - req = new HttpPost(url); - if (entity != null) { - ((HttpPost) req).setEntity(entity); - } - break; - case PUT: - req = new HttpPut(url); - if (entity != null) { - ((HttpPut) req).setEntity(entity); - } - break; - case DELETE: - req = new HttpDelete(url); - break; - default: - throw new IOException("Unsupported method " + method); - } - if (headers != null) { - headers.forEach((k, v) -> req.addHeader(k, v)); - } - RequestConfig.Builder requestConfigBuilder = HttpClientUtil.createDefaultRequestConfigBuilder(); - if (timeout > 0) { - requestConfigBuilder.setSocketTimeout(timeout); - requestConfigBuilder.setConnectTimeout(timeout); - } - requestConfigBuilder.setRedirectsEnabled(followRedirects); - req.setConfig(requestConfigBuilder.build()); - HttpClientContext httpClientRequestContext = HttpClientUtil.createNewHttpClientRequestContext(); - HttpResponse rsp = client.execute(req, httpClientRequestContext); - int statusCode = rsp.getStatusLine().getStatusCode(); - if (statusCode != 200) { - throw new IOException( - "Error sending request to " + url + ", HTTP response: " + rsp.toString()); - } - HttpEntity responseEntity = rsp.getEntity(); - if (responseEntity != null && responseEntity.getContent() != null) { - return EntityUtils.toByteArray(responseEntity); - } else { - return EMPTY; - } - } - public SolrZkClient getZkClient() { return zkClient; } diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java index 7e70378c582..11c426d0615 100644 --- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java +++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java @@ -54,15 +54,15 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final CloudLegacySolrClient solrClient; + private final CloudHttp2SolrClient cloudSolrClient; protected final Map>>> nodeVsCollectionVsShardVsReplicaInfo = new HashMap<>(); @SuppressWarnings({"rawtypes"}) private Map nodeVsTags = new HashMap<>(); - public SolrClientNodeStateProvider(CloudLegacySolrClient solrClient) { - this.solrClient = solrClient; + public SolrClientNodeStateProvider(CloudHttp2SolrClient cloudSolrClient) { + this.cloudSolrClient = cloudSolrClient; try { readReplicaDetails(); } catch (IOException e) { @@ -71,7 +71,7 @@ public SolrClientNodeStateProvider(CloudLegacySolrClient solrClient) { } protected ClusterStateProvider getClusterStateProvider() { - return solrClient.getClusterStateProvider(); + return cloudSolrClient.getClusterStateProvider(); } protected void readReplicaDetails() throws IOException { @@ -114,7 +114,7 @@ public Map getNodeValues(String node, Collection tags) { protected Map fetchTagValues(String node, Collection tags) { NodeValueFetcher nodeValueFetcher = new NodeValueFetcher(); - RemoteCallCtx ctx = new RemoteCallCtx(node, solrClient); + RemoteCallCtx ctx = new RemoteCallCtx(node, cloudSolrClient); nodeValueFetcher.getTags(new HashSet<>(tags), ctx); return ctx.tags; } @@ -180,7 +180,7 @@ protected Map fetchReplicaMetrics( Map> collect = metricsKeyVsTagReplica.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> Set.of(e.getKey()))); - RemoteCallCtx ctx = new RemoteCallCtx(null, solrClient); + RemoteCallCtx ctx = new RemoteCallCtx(null, cloudSolrClient); fetchReplicaMetrics(node, ctx, collect); return ctx.tags; } @@ -226,10 +226,10 @@ public String toString() { static class RemoteCallCtx { ZkClientClusterStateProvider zkClientClusterStateProvider; - CloudLegacySolrClient solrClient; public final Map tags = new HashMap<>(); private final String node; public Map session; + CloudHttp2SolrClient cloudSolrClient; public boolean isNodeAlive(String node) { if (zkClientClusterStateProvider != null) { @@ -238,11 +238,11 @@ public boolean isNodeAlive(String node) { return true; } - public RemoteCallCtx(String node, CloudLegacySolrClient solrClient) { + public RemoteCallCtx(String node, CloudHttp2SolrClient cloudSolrClient) { this.node = node; - this.solrClient = solrClient; + this.cloudSolrClient = cloudSolrClient; this.zkClientClusterStateProvider = - (ZkClientClusterStateProvider) solrClient.getClusterStateProvider(); + (ZkClientClusterStateProvider) cloudSolrClient.getClusterStateProvider(); } /** @@ -290,15 +290,15 @@ public SimpleSolrResponse invoke(String solrNode, String path, SolrParams params String url = zkClientClusterStateProvider.getZkStateReader().getBaseUrlForNodeName(solrNode); GenericSolrRequest request = new GenericSolrRequest(SolrRequest.METHOD.POST, path, params); - try (var client = - new HttpSolrClient.Builder() - .withHttpClient(solrClient.getHttpClient()) - .withBaseSolrUrl(url) - .withResponseParser(new BinaryResponseParser()) - .build()) { - NamedList rsp = client.request(request); + request.setResponseParser(new BinaryResponseParser()); + + try { + NamedList rsp = + cloudSolrClient.getHttpClient().requestWithBaseUrl(url, request::process).getResponse(); request.response.setResponse(rsp); return request.response; + } catch (SolrServerException | IOException e) { + throw new RuntimeException(e); } } diff --git a/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java b/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java index 5f521dbb20c..d1d2dfc10a8 100644 --- a/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java +++ b/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java @@ -16,6 +16,8 @@ */ package org.apache.solr.client.solrj.impl; +import java.util.Collections; +import java.util.Optional; import java.util.Set; import org.apache.solr.client.solrj.impl.SolrClientNodeStateProvider.RemoteCallCtx; import org.apache.solr.client.solrj.request.CollectionAdminRequest; @@ -62,28 +64,32 @@ public void cleanup() throws Exception { } @Test - public void testGetTags() { - - CloudLegacySolrClient solrClient = (CloudLegacySolrClient) cluster.getSolrClient(); - int totalCores = 0; - - // Sum all the cores of the collection by fetching tags of all nodes. - // We should get same number than when we created the collection - for (JettySolrRunner runner : cluster.getJettySolrRunners()) { - String node = runner.getNodeName(); - RemoteCallCtx ctx = new RemoteCallCtx(node, solrClient); - NodeValueFetcher fetcher = new NodeValueFetcher(); - - Set requestedTags = Set.of("cores"); - fetcher.getTags(requestedTags, ctx); - - // make sure we only get the tag we asked - assertEquals(1, ctx.tags.size()); - - int coresOnNode = (Integer) ctx.tags.get("cores"); - totalCores += coresOnNode; + public void testGetTags() throws Exception { + try (CloudHttp2SolrClient cloudHttp2SolrClient = + new CloudHttp2SolrClient.Builder( + Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty()) + .build()) { + CloudLegacySolrClient solrClient = (CloudLegacySolrClient) cluster.getSolrClient(); + int totalCores = 0; + + // Sum all the cores of the collection by fetching tags of all nodes. + // We should get same number than when we created the collection + for (JettySolrRunner runner : cluster.getJettySolrRunners()) { + String node = runner.getNodeName(); + RemoteCallCtx ctx = new RemoteCallCtx(node, cloudHttp2SolrClient); + NodeValueFetcher fetcher = new NodeValueFetcher(); + + Set requestedTags = Set.of("cores"); + fetcher.getTags(requestedTags, ctx); + + // make sure we only get the tag we asked + assertEquals(1, ctx.tags.size()); + + int coresOnNode = (Integer) ctx.tags.get("cores"); + totalCores += coresOnNode; + } + + assertEquals(numShards * numReplicas, totalCores); } - - assertEquals(numShards * numReplicas, totalCores); } } From a2dc271afe1e30dac3d828bea135fd0f4ad19596 Mon Sep 17 00:00:00 2001 From: Sanjay Dutt Date: Tue, 8 Oct 2024 17:40:04 +0530 Subject: [PATCH 2/8] removed unusedDeclaredArtifacts httpclient, httpcore from solrj-zookeeper --- solr/solrj-zookeeper/build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/solr/solrj-zookeeper/build.gradle b/solr/solrj-zookeeper/build.gradle index a8dccd8b7bc..2e03d9fed3c 100644 --- a/solr/solrj-zookeeper/build.gradle +++ b/solr/solrj-zookeeper/build.gradle @@ -34,8 +34,6 @@ dependencies { // declare dependencies we use even though already declared by solrj-core implementation 'org.slf4j:slf4j-api' - implementation 'org.apache.httpcomponents:httpclient' - implementation 'org.apache.httpcomponents:httpcore' api('org.apache.zookeeper:zookeeper', { exclude group: "org.apache.yetus", module: "audience-annotations" From fd0fcbe670c8554e9fedfc3bd23ddbe52bb5e5c3 Mon Sep 17 00:00:00 2001 From: Sanjay Dutt Date: Fri, 11 Oct 2024 17:36:20 +0530 Subject: [PATCH 3/8] Switching to CloudSolrClient ref --- .../org/apache/solr/cloud/ZkController.java | 8 ++++---- .../solrj/impl/SolrClientCloudManager.java | 7 +++---- .../impl/SolrClientNodeStateProvider.java | 19 +++++++++++-------- .../solrj/impl/NodeValueFetcherTest.java | 6 +++--- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index dad69dc365f..03d7a6a724f 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -199,7 +199,7 @@ public String toString() { public final ZkStateReader zkStateReader; private SolrCloudManager cloudManager; - private CloudHttp2SolrClient solrCloudClient; + private CloudHttp2SolrClient cloudSolrClient; private final String zkServerAddress; // example: 127.0.0.1:54062/solr @@ -768,7 +768,7 @@ public void close() { } finally { sysPropsCacher.close(); - customThreadPool.execute(() -> IOUtils.closeQuietly(solrCloudClient)); + customThreadPool.execute(() -> IOUtils.closeQuietly(cloudSolrClient)); customThreadPool.execute(() -> IOUtils.closeQuietly(cloudManager)); try { @@ -865,12 +865,12 @@ public SolrCloudManager getSolrCloudManager() { if (cloudManager != null) { return cloudManager; } - solrCloudClient = + cloudSolrClient = new CloudHttp2SolrClient.Builder( Collections.singletonList(getZkServerAddress()), Optional.empty()) .withHttpClient(cc.getDefaultHttpSolrClient()) .build(); - cloudManager = new SolrClientCloudManager(cc.getObjectCache(), solrCloudClient); + cloudManager = new SolrClientCloudManager(cc.getObjectCache(), cloudSolrClient); cloudManager.getClusterStateProvider().connect(); } return cloudManager; diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java index 28fdea27801..18faddf3e24 100644 --- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java +++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java @@ -37,16 +37,16 @@ public class SolrClientCloudManager implements SolrCloudManager { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - // protected final CloudLegacySolrClient solrClient; + private final CloudHttp2SolrClient cloudSolrClient; private final ZkDistribStateManager stateManager; private final ZkStateReader zkStateReader; private final SolrZkClient zkClient; private final ObjectCache objectCache; private final boolean closeObjectCache; private volatile boolean isClosed; - private final CloudHttp2SolrClient cloudSolrClient; public SolrClientCloudManager(ObjectCache objectCache, CloudHttp2SolrClient client) { + this.cloudSolrClient = client; this.zkStateReader = ZkStateReader.from(client); this.zkClient = zkStateReader.getZkClient(); this.stateManager = new ZkDistribStateManager(zkClient); @@ -58,7 +58,6 @@ public SolrClientCloudManager(ObjectCache objectCache, CloudHttp2SolrClient clie this.objectCache = objectCache; this.closeObjectCache = false; } - this.cloudSolrClient = client; } @Override @@ -91,7 +90,7 @@ public ClusterStateProvider getClusterStateProvider() { @Override public NodeStateProvider getNodeStateProvider() { - return new SolrClientNodeStateProvider(cloudSolrClient); + return new SolrClientNodeStateProvider(cloudSolrClient, cloudSolrClient.getHttpClient()); } @Override diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java index 11c426d0615..4bcaccd543d 100644 --- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java +++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java @@ -54,15 +54,17 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final CloudHttp2SolrClient cloudSolrClient; + private final CloudSolrClient cloudSolrClient; + private final Http2SolrClient solrClient; protected final Map>>> nodeVsCollectionVsShardVsReplicaInfo = new HashMap<>(); @SuppressWarnings({"rawtypes"}) private Map nodeVsTags = new HashMap<>(); - public SolrClientNodeStateProvider(CloudHttp2SolrClient cloudSolrClient) { + public SolrClientNodeStateProvider(CloudSolrClient cloudSolrClient, Http2SolrClient solrClient) { this.cloudSolrClient = cloudSolrClient; + this.solrClient = solrClient; try { readReplicaDetails(); } catch (IOException e) { @@ -114,7 +116,7 @@ public Map getNodeValues(String node, Collection tags) { protected Map fetchTagValues(String node, Collection tags) { NodeValueFetcher nodeValueFetcher = new NodeValueFetcher(); - RemoteCallCtx ctx = new RemoteCallCtx(node, cloudSolrClient); + RemoteCallCtx ctx = new RemoteCallCtx(node, cloudSolrClient, solrClient); nodeValueFetcher.getTags(new HashSet<>(tags), ctx); return ctx.tags; } @@ -180,7 +182,7 @@ protected Map fetchReplicaMetrics( Map> collect = metricsKeyVsTagReplica.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> Set.of(e.getKey()))); - RemoteCallCtx ctx = new RemoteCallCtx(null, cloudSolrClient); + RemoteCallCtx ctx = new RemoteCallCtx(null, cloudSolrClient, solrClient); fetchReplicaMetrics(node, ctx, collect); return ctx.tags; } @@ -226,10 +228,11 @@ public String toString() { static class RemoteCallCtx { ZkClientClusterStateProvider zkClientClusterStateProvider; + CloudSolrClient cloudSolrClient; + Http2SolrClient solrClient; public final Map tags = new HashMap<>(); private final String node; public Map session; - CloudHttp2SolrClient cloudSolrClient; public boolean isNodeAlive(String node) { if (zkClientClusterStateProvider != null) { @@ -238,9 +241,10 @@ public boolean isNodeAlive(String node) { return true; } - public RemoteCallCtx(String node, CloudHttp2SolrClient cloudSolrClient) { + public RemoteCallCtx(String node, CloudSolrClient cloudSolrClient, Http2SolrClient solrClient) { this.node = node; this.cloudSolrClient = cloudSolrClient; + this.solrClient = solrClient; this.zkClientClusterStateProvider = (ZkClientClusterStateProvider) cloudSolrClient.getClusterStateProvider(); } @@ -293,8 +297,7 @@ public SimpleSolrResponse invoke(String solrNode, String path, SolrParams params request.setResponseParser(new BinaryResponseParser()); try { - NamedList rsp = - cloudSolrClient.getHttpClient().requestWithBaseUrl(url, request::process).getResponse(); + NamedList rsp = solrClient.requestWithBaseUrl(url, request::process).getResponse(); request.response.setResponse(rsp); return request.response; } catch (SolrServerException | IOException e) { diff --git a/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java b/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java index d1d2dfc10a8..2e4466ba10b 100644 --- a/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java +++ b/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java @@ -65,18 +65,18 @@ public void cleanup() throws Exception { @Test public void testGetTags() throws Exception { - try (CloudHttp2SolrClient cloudHttp2SolrClient = + try (var cloudHttp2SolrClient = new CloudHttp2SolrClient.Builder( Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty()) .build()) { - CloudLegacySolrClient solrClient = (CloudLegacySolrClient) cluster.getSolrClient(); int totalCores = 0; // Sum all the cores of the collection by fetching tags of all nodes. // We should get same number than when we created the collection for (JettySolrRunner runner : cluster.getJettySolrRunners()) { String node = runner.getNodeName(); - RemoteCallCtx ctx = new RemoteCallCtx(node, cloudHttp2SolrClient); + RemoteCallCtx ctx = + new RemoteCallCtx(node, cloudHttp2SolrClient, cloudHttp2SolrClient.getHttpClient()); NodeValueFetcher fetcher = new NodeValueFetcher(); Set requestedTags = Set.of("cores"); From 140d5e0722ec0b01c2520f8251179118b0b25e00 Mon Sep 17 00:00:00 2001 From: Sanjay Dutt Date: Thu, 17 Oct 2024 13:58:49 +0530 Subject: [PATCH 4/8] Switch to CloudHttp2SolrClient to easily access Http2SolrClient --- .../solrj/impl/SolrClientCloudManager.java | 2 +- .../solrj/impl/SolrClientNodeStateProvider.java | 17 +++++++---------- .../client/solrj/impl/NodeValueFetcherTest.java | 3 +-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java index 18faddf3e24..910607ed930 100644 --- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java +++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java @@ -90,7 +90,7 @@ public ClusterStateProvider getClusterStateProvider() { @Override public NodeStateProvider getNodeStateProvider() { - return new SolrClientNodeStateProvider(cloudSolrClient, cloudSolrClient.getHttpClient()); + return new SolrClientNodeStateProvider(cloudSolrClient); } @Override diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java index 4bcaccd543d..9ec923ba89a 100644 --- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java +++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java @@ -54,17 +54,15 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final CloudSolrClient cloudSolrClient; - private final Http2SolrClient solrClient; + private final CloudHttp2SolrClient cloudSolrClient; protected final Map>>> nodeVsCollectionVsShardVsReplicaInfo = new HashMap<>(); @SuppressWarnings({"rawtypes"}) private Map nodeVsTags = new HashMap<>(); - public SolrClientNodeStateProvider(CloudSolrClient cloudSolrClient, Http2SolrClient solrClient) { + public SolrClientNodeStateProvider(CloudHttp2SolrClient cloudSolrClient) { this.cloudSolrClient = cloudSolrClient; - this.solrClient = solrClient; try { readReplicaDetails(); } catch (IOException e) { @@ -116,7 +114,7 @@ public Map getNodeValues(String node, Collection tags) { protected Map fetchTagValues(String node, Collection tags) { NodeValueFetcher nodeValueFetcher = new NodeValueFetcher(); - RemoteCallCtx ctx = new RemoteCallCtx(node, cloudSolrClient, solrClient); + RemoteCallCtx ctx = new RemoteCallCtx(node, cloudSolrClient); nodeValueFetcher.getTags(new HashSet<>(tags), ctx); return ctx.tags; } @@ -182,7 +180,7 @@ protected Map fetchReplicaMetrics( Map> collect = metricsKeyVsTagReplica.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> Set.of(e.getKey()))); - RemoteCallCtx ctx = new RemoteCallCtx(null, cloudSolrClient, solrClient); + RemoteCallCtx ctx = new RemoteCallCtx(null, cloudSolrClient); fetchReplicaMetrics(node, ctx, collect); return ctx.tags; } @@ -228,8 +226,7 @@ public String toString() { static class RemoteCallCtx { ZkClientClusterStateProvider zkClientClusterStateProvider; - CloudSolrClient cloudSolrClient; - Http2SolrClient solrClient; + CloudHttp2SolrClient cloudSolrClient; public final Map tags = new HashMap<>(); private final String node; public Map session; @@ -241,10 +238,9 @@ public boolean isNodeAlive(String node) { return true; } - public RemoteCallCtx(String node, CloudSolrClient cloudSolrClient, Http2SolrClient solrClient) { + public RemoteCallCtx(String node, CloudHttp2SolrClient cloudSolrClient) { this.node = node; this.cloudSolrClient = cloudSolrClient; - this.solrClient = solrClient; this.zkClientClusterStateProvider = (ZkClientClusterStateProvider) cloudSolrClient.getClusterStateProvider(); } @@ -297,6 +293,7 @@ public SimpleSolrResponse invoke(String solrNode, String path, SolrParams params request.setResponseParser(new BinaryResponseParser()); try { + var solrClient = cloudSolrClient.getHttpClient(); NamedList rsp = solrClient.requestWithBaseUrl(url, request::process).getResponse(); request.response.setResponse(rsp); return request.response; diff --git a/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java b/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java index 2e4466ba10b..29edd771b43 100644 --- a/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java +++ b/solr/solrj-zookeeper/src/test/org/apache/solr/client/solrj/impl/NodeValueFetcherTest.java @@ -75,8 +75,7 @@ public void testGetTags() throws Exception { // We should get same number than when we created the collection for (JettySolrRunner runner : cluster.getJettySolrRunners()) { String node = runner.getNodeName(); - RemoteCallCtx ctx = - new RemoteCallCtx(node, cloudHttp2SolrClient, cloudHttp2SolrClient.getHttpClient()); + RemoteCallCtx ctx = new RemoteCallCtx(node, cloudHttp2SolrClient); NodeValueFetcher fetcher = new NodeValueFetcher(); Set requestedTags = Set.of("cores"); From 8fc61293e17d3534a6a9bdb3d3a6fe2dff7b4299 Mon Sep 17 00:00:00 2001 From: Sanjay Dutt Date: Mon, 21 Oct 2024 19:14:27 +0530 Subject: [PATCH 5/8] Provided http2SolrClient with custom timeouts --- .../java/org/apache/solr/cloud/ZkController.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index 03d7a6a724f..4b78990887e 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -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; @@ -199,6 +200,9 @@ public String toString() { public final ZkStateReader zkStateReader; private SolrCloudManager cloudManager; + // only for internal usage-only + private Http2SolrClient http2SolrClient; + private CloudHttp2SolrClient cloudSolrClient; private final String zkServerAddress; // example: 127.0.0.1:54062/solr @@ -769,6 +773,7 @@ public void close() { sysPropsCacher.close(); customThreadPool.execute(() -> IOUtils.closeQuietly(cloudSolrClient)); + customThreadPool.execute(() -> IOUtils.closeQuietly(http2SolrClient)); customThreadPool.execute(() -> IOUtils.closeQuietly(cloudManager)); try { @@ -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(); From 2d33669e396ed4c6967aa828147bc5813c7db5e9 Mon Sep 17 00:00:00 2001 From: Sanjay Dutt Date: Thu, 24 Oct 2024 10:39:17 +0530 Subject: [PATCH 6/8] Addresses gh comments --- .../org/apache/solr/cloud/ZkController.java | 6 +++--- .../org/apache/solr/cloud/OverseerTest.java | 2 +- .../solrj/impl/SolrClientCloudManager.java | 2 +- .../impl/SolrClientNodeStateProvider.java | 18 +++++++++--------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index 4b78990887e..33732ea0a94 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -200,7 +200,7 @@ public String toString() { public final ZkStateReader zkStateReader; private SolrCloudManager cloudManager; - // only for internal usage-only + // only for internal usage private Http2SolrClient http2SolrClient; private CloudHttp2SolrClient cloudSolrClient; @@ -772,9 +772,9 @@ public void close() { } finally { sysPropsCacher.close(); + customThreadPool.execute(() -> IOUtils.closeQuietly(cloudManager)); customThreadPool.execute(() -> IOUtils.closeQuietly(cloudSolrClient)); customThreadPool.execute(() -> IOUtils.closeQuietly(http2SolrClient)); - customThreadPool.execute(() -> IOUtils.closeQuietly(cloudManager)); try { try { @@ -880,7 +880,7 @@ public SolrCloudManager getSolrCloudManager() { new CloudHttp2SolrClient.Builder(List.of(getZkServerAddress()), Optional.empty()) .withHttpClient(http2SolrClient) .build(); - cloudManager = new SolrClientCloudManager(cc.getObjectCache(), cloudSolrClient); + cloudManager = new SolrClientCloudManager(cloudSolrClient, cc.getObjectCache()); cloudManager.getClusterStateProvider().connect(); } return cloudManager; diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java index 949779376cf..6c5af8facd9 100644 --- a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java @@ -1959,7 +1959,7 @@ private SolrCloudManager getCloudDataProvider(String zkAddress) { .build(); solrClients.add(cloudSolrClient); solrClients.add(httpSolrClient); - SolrClientCloudManager sccm = new SolrClientCloudManager(null, cloudSolrClient); + SolrClientCloudManager sccm = new SolrClientCloudManager(cloudSolrClient, null); sccm.getClusterStateProvider().connect(); return sccm; } diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java index 910607ed930..3dca5176aa1 100644 --- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java +++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientCloudManager.java @@ -45,7 +45,7 @@ public class SolrClientCloudManager implements SolrCloudManager { private final boolean closeObjectCache; private volatile boolean isClosed; - public SolrClientCloudManager(ObjectCache objectCache, CloudHttp2SolrClient client) { + public SolrClientCloudManager(CloudHttp2SolrClient client, ObjectCache objectCache) { this.cloudSolrClient = client; this.zkStateReader = ZkStateReader.from(client); this.zkClient = zkStateReader.getZkClient(); diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java index 9ec923ba89a..984e1b7a18f 100644 --- a/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java +++ b/solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/SolrClientNodeStateProvider.java @@ -54,15 +54,15 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final CloudHttp2SolrClient cloudSolrClient; + private final CloudHttp2SolrClient solrClient; protected final Map>>> nodeVsCollectionVsShardVsReplicaInfo = new HashMap<>(); @SuppressWarnings({"rawtypes"}) private Map nodeVsTags = new HashMap<>(); - public SolrClientNodeStateProvider(CloudHttp2SolrClient cloudSolrClient) { - this.cloudSolrClient = cloudSolrClient; + public SolrClientNodeStateProvider(CloudHttp2SolrClient solrClient) { + this.solrClient = solrClient; try { readReplicaDetails(); } catch (IOException e) { @@ -71,7 +71,7 @@ public SolrClientNodeStateProvider(CloudHttp2SolrClient cloudSolrClient) { } protected ClusterStateProvider getClusterStateProvider() { - return cloudSolrClient.getClusterStateProvider(); + return solrClient.getClusterStateProvider(); } protected void readReplicaDetails() throws IOException { @@ -114,7 +114,7 @@ public Map getNodeValues(String node, Collection tags) { protected Map fetchTagValues(String node, Collection tags) { NodeValueFetcher nodeValueFetcher = new NodeValueFetcher(); - RemoteCallCtx ctx = new RemoteCallCtx(node, cloudSolrClient); + RemoteCallCtx ctx = new RemoteCallCtx(node, solrClient); nodeValueFetcher.getTags(new HashSet<>(tags), ctx); return ctx.tags; } @@ -180,7 +180,7 @@ protected Map fetchReplicaMetrics( Map> collect = metricsKeyVsTagReplica.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> Set.of(e.getKey()))); - RemoteCallCtx ctx = new RemoteCallCtx(null, cloudSolrClient); + RemoteCallCtx ctx = new RemoteCallCtx(null, solrClient); fetchReplicaMetrics(node, ctx, collect); return ctx.tags; } @@ -293,12 +293,12 @@ public SimpleSolrResponse invoke(String solrNode, String path, SolrParams params request.setResponseParser(new BinaryResponseParser()); try { - var solrClient = cloudSolrClient.getHttpClient(); - NamedList rsp = solrClient.requestWithBaseUrl(url, request::process).getResponse(); + NamedList rsp = + cloudSolrClient.getHttpClient().requestWithBaseUrl(url, request::process).getResponse(); request.response.setResponse(rsp); return request.response; } catch (SolrServerException | IOException e) { - throw new RuntimeException(e); + throw new SolrException(ErrorCode.SERVER_ERROR, "Fetching replica metrics failed", e); } } From 284b9eeedd0f9663b1412bc884f5499241db35fe Mon Sep 17 00:00:00 2001 From: Sanjay Dutt Date: Thu, 24 Oct 2024 19:19:43 +0530 Subject: [PATCH 7/8] changes.txt --- solr/CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 36923970e5e..1b8cc8ac33f 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -203,6 +203,9 @@ led to the suppression of exceptions. (Andrey Bozhko) * SOLR-11318: Introduce unit testing for AssertTool. (Eric Pugh, Jason Gerlowski) +* SOLR-16503: Replaced CloudLegacySolrClient with CloudHttp2SolrClient in SolrClientCloudManager and updated all +internal classes accordingly. (Sanjay Dutt, David Smiley) + ================== 9.7.0 ================== New Features --------------------- From 1040917636a5359c04c186628473589eb8e7fddb Mon Sep 17 00:00:00 2001 From: Sanjay Dutt Date: Thu, 24 Oct 2024 20:13:53 +0530 Subject: [PATCH 8/8] changes.txt --- solr/CHANGES.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 1b8cc8ac33f..9e8f5e7615a 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -170,6 +170,8 @@ Optimizations * SOLR-17441: Improve system metrics collection by skipping unreadable MXBean properties, making /admin/info/system calls faster (Haythem Khiri) +* SOLR-16503: Switched from HTTP1 to HTTP2 in SolrClientCloudManager by replacing CloudLegacySolrClient with CloudHttp2SolrClient. (Sanjay Dutt, David Smiley) + Bug Fixes --------------------- * SOLR-12429: Uploading a configset with a symbolic link produces a IOException. Now a error message to user generated instead. (Eric Pugh) @@ -203,9 +205,6 @@ led to the suppression of exceptions. (Andrey Bozhko) * SOLR-11318: Introduce unit testing for AssertTool. (Eric Pugh, Jason Gerlowski) -* SOLR-16503: Replaced CloudLegacySolrClient with CloudHttp2SolrClient in SolrClientCloudManager and updated all -internal classes accordingly. (Sanjay Dutt, David Smiley) - ================== 9.7.0 ================== New Features ---------------------