Skip to content

Commit 704f2fe

Browse files
committed
Revert "SOLR-17541: LBSolrClient implementations should agree on 'getClient()' semantics (#2899)"
This reverts commit d3e57aa.
1 parent d3e57aa commit 704f2fe

19 files changed

+348
-344
lines changed

solr/CHANGES.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ Improvements
3434

3535
* SOLR-17516: `LBHttp2SolrClient` is now generic, adding support for `HttpJdkSolrClient`. (James Dyer)
3636

37-
* SOLR-17541: `LBHttp2SolrClient` now maintains a separate internal/delegate client per Solr Base URL. Both `LBHttp2SolrClient` and `CloudHttp2SolrClient`
38-
always create and manage these internal clients. The ability for callers to provide a pre-built client is removed. Callers may specify the internal client
39-
details by providing an instance of either `Http2SolrClient.Builder` or `HttpJdkSolrClient.Builder`. (James Dyer)
40-
4137
Optimizations
4238
---------------------
4339
* SOLR-17568: The CLI bin/solr export tool now contacts the appropriate nodes directly for data instead of proxying through one.
@@ -106,11 +102,6 @@ Deprecation Removals
106102

107103
* SOLR-17540: Removed the Hadoop Auth module, and thus Kerberos authentication and other exotic options. (Eric Pugh)
108104

109-
* SOLR-17541: Removed `CloudHttp2SolrClient.Builder#withHttpClient` in favor of `CloudHttp2SolrClient.Builder#withInternalClientBuilder`.
110-
The constructor on `LBHttp2SolrClient.Builder` that took an instance of `HttpSolrClientBase` is updated to instead take an instance of
111-
`HttpSolrClientBuilderBase`. Renamed `LBHttp2SolrClient.Builder#withListenerFactory` to `LBHttp2SolrClient.Builder#withListenerFactories`
112-
(James Dyer)
113-
114105
Dependency Upgrades
115106
---------------------
116107
(No changes)
@@ -159,10 +150,7 @@ New Features
159150

160151
Improvements
161152
---------------------
162-
* SOLR-17541: Deprecate `CloudHttp2SolrClient.Builder#withHttpClient` in favor of
163-
`CloudHttp2SolrClient.Builder#withInternalClientBuilder`.
164-
Deprecate `LBHttp2SolrClient.Builder#withListenerFactory` in favor of
165-
`LBHttp2SolrClient.Builder#withListenerFactories` (James Dyer)
153+
(No changes)
166154

167155
Optimizations
168156
---------------------

solr/core/src/java/org/apache/solr/cloud/ZkController.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ public String toString() {
197197
public final ZkStateReader zkStateReader;
198198
private SolrCloudManager cloudManager;
199199

200+
// only for internal usage
201+
private Http2SolrClient http2SolrClient;
202+
200203
private CloudHttp2SolrClient cloudSolrClient;
201204

202205
private final String zkServerAddress; // example: 127.0.0.1:54062/solr
@@ -751,6 +754,7 @@ public void close() {
751754
sysPropsCacher.close();
752755
customThreadPool.execute(() -> IOUtils.closeQuietly(cloudManager));
753756
customThreadPool.execute(() -> IOUtils.closeQuietly(cloudSolrClient));
757+
customThreadPool.execute(() -> IOUtils.closeQuietly(http2SolrClient));
754758

755759
try {
756760
try {
@@ -846,14 +850,15 @@ public SolrCloudManager getSolrCloudManager() {
846850
if (cloudManager != null) {
847851
return cloudManager;
848852
}
849-
var httpSolrClientBuilder =
853+
http2SolrClient =
850854
new Http2SolrClient.Builder()
851855
.withHttpClient(cc.getDefaultHttpSolrClient())
852856
.withIdleTimeout(30000, TimeUnit.MILLISECONDS)
853-
.withConnectionTimeout(15000, TimeUnit.MILLISECONDS);
857+
.withConnectionTimeout(15000, TimeUnit.MILLISECONDS)
858+
.build();
854859
cloudSolrClient =
855860
new CloudHttp2SolrClient.Builder(new ZkClientClusterStateProvider(zkStateReader))
856-
.withInternalClientBuilder(httpSolrClientBuilder)
861+
.withHttpClient(http2SolrClient)
857862
.build();
858863
cloudManager = new SolrClientCloudManager(cloudSolrClient, cc.getObjectCache());
859864
cloudManager.getClusterStateProvider().connect();

solr/core/src/java/org/apache/solr/core/HttpSolrClientProvider.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.solr.core;
1818

19+
import java.util.List;
1920
import java.util.concurrent.TimeUnit;
2021
import org.apache.solr.client.solrj.impl.Http2SolrClient;
2122
import org.apache.solr.common.util.IOUtils;
@@ -36,24 +37,22 @@ final class HttpSolrClientProvider implements AutoCloseable {
3637

3738
private final Http2SolrClient httpSolrClient;
3839

39-
private final Http2SolrClient.Builder httpSolrClientBuilder;
40-
4140
private final InstrumentedHttpListenerFactory trackHttpSolrMetrics;
4241

4342
HttpSolrClientProvider(UpdateShardHandlerConfig cfg, SolrMetricsContext parentContext) {
4443
trackHttpSolrMetrics = new InstrumentedHttpListenerFactory(getNameStrategy(cfg));
4544
initializeMetrics(parentContext);
4645

47-
this.httpSolrClientBuilder =
48-
new Http2SolrClient.Builder().addListenerFactory(trackHttpSolrMetrics);
46+
Http2SolrClient.Builder httpClientBuilder =
47+
new Http2SolrClient.Builder().withListenerFactory(List.of(trackHttpSolrMetrics));
4948

5049
if (cfg != null) {
51-
httpSolrClientBuilder
50+
httpClientBuilder
5251
.withConnectionTimeout(cfg.getDistributedConnectionTimeout(), TimeUnit.MILLISECONDS)
5352
.withIdleTimeout(cfg.getDistributedSocketTimeout(), TimeUnit.MILLISECONDS)
5453
.withMaxConnectionsPerHost(cfg.getMaxUpdateConnectionsPerHost());
5554
}
56-
httpSolrClient = httpSolrClientBuilder.build();
55+
httpSolrClient = httpClientBuilder.build();
5756
}
5857

5958
private InstrumentedHttpListenerFactory.NameStrategy getNameStrategy(
@@ -77,7 +76,7 @@ Http2SolrClient getSolrClient() {
7776
}
7877

7978
void setSecurityBuilder(HttpClientBuilderPlugin builder) {
80-
builder.setup(httpSolrClientBuilder, httpSolrClient);
79+
builder.setup(httpSolrClient);
8180
}
8281

8382
@Override

solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public class HttpShardHandler extends ShardHandler {
114114
protected AtomicInteger pending;
115115

116116
private final Map<String, List<String>> shardToURLs;
117-
protected LBHttp2SolrClient<Http2SolrClient.Builder> lbClient;
117+
protected LBHttp2SolrClient<Http2SolrClient> lbClient;
118118

119119
public HttpShardHandler(HttpShardHandlerFactory httpShardHandlerFactory) {
120120
this.httpShardHandlerFactory = httpShardHandlerFactory;

solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ public class HttpShardHandlerFactory extends ShardHandlerFactory
8383
protected ExecutorService commExecutor;
8484

8585
protected volatile Http2SolrClient defaultClient;
86-
protected Http2SolrClient.Builder httpSolrClientBuilder;
8786
protected InstrumentedHttpListenerFactory httpListenerFactory;
88-
protected LBHttp2SolrClient<Http2SolrClient.Builder> loadbalancer;
87+
protected LBHttp2SolrClient<Http2SolrClient> loadbalancer;
8988

9089
int corePoolSize = 0;
9190
int maximumPoolSize = Integer.MAX_VALUE;
@@ -306,16 +305,16 @@ public void init(PluginInfo info) {
306305
sb);
307306
int soTimeout =
308307
getParameter(args, HttpClientUtil.PROP_SO_TIMEOUT, HttpClientUtil.DEFAULT_SO_TIMEOUT, sb);
309-
this.httpSolrClientBuilder =
308+
309+
this.defaultClient =
310310
new Http2SolrClient.Builder()
311311
.withConnectionTimeout(connectionTimeout, TimeUnit.MILLISECONDS)
312312
.withIdleTimeout(soTimeout, TimeUnit.MILLISECONDS)
313313
.withExecutor(commExecutor)
314314
.withMaxConnectionsPerHost(maxConnectionsPerHost)
315-
.addListenerFactory(this.httpListenerFactory);
316-
this.defaultClient = httpSolrClientBuilder.build();
317-
318-
this.loadbalancer = new LBHttp2SolrClient.Builder<>(httpSolrClientBuilder).build();
315+
.build();
316+
this.defaultClient.addListenerFactory(this.httpListenerFactory);
317+
this.loadbalancer = new LBHttp2SolrClient.Builder<Http2SolrClient>(defaultClient).build();
319318

320319
initReplicaListTransformers(getParameter(args, "replicaRouting", null, sb));
321320

@@ -325,7 +324,7 @@ public void init(PluginInfo info) {
325324
@Override
326325
public void setSecurityBuilder(HttpClientBuilderPlugin clientBuilderPlugin) {
327326
if (clientBuilderPlugin != null) {
328-
clientBuilderPlugin.setup(httpSolrClientBuilder, defaultClient);
327+
clientBuilderPlugin.setup(defaultClient);
329328
}
330329
}
331330

solr/core/src/java/org/apache/solr/security/HttpClientBuilderPlugin.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,4 @@ public interface HttpClientBuilderPlugin {
3434
public SolrHttpClientBuilder getHttpClientBuilder(SolrHttpClientBuilder builder);
3535

3636
public default void setup(Http2SolrClient client) {}
37-
38-
/** TODO: Ideally, we only pass the builder here. */
39-
public default void setup(Http2SolrClient.Builder builder, Http2SolrClient client) {
40-
setup(client);
41-
}
4237
}

solr/core/src/java/org/apache/solr/security/PKIAuthenticationPlugin.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,6 @@ PublicKey fetchPublicKeyFromRemote(String nodename) {
376376

377377
@Override
378378
public void setup(Http2SolrClient client) {
379-
setup(null, client);
380-
}
381-
382-
@Override
383-
public void setup(Http2SolrClient.Builder builder, Http2SolrClient client) {
384379
final HttpListenerFactory.RequestResponseListener listener =
385380
new HttpListenerFactory.RequestResponseListener() {
386381
private static final String CACHED_REQUEST_USER_KEY = "cachedRequestUser";
@@ -436,12 +431,7 @@ private Optional<String> getUserFromJettyRequest(Request request) {
436431
(String) request.getAttributes().get(CACHED_REQUEST_USER_KEY));
437432
}
438433
};
439-
if (client != null) {
440-
client.addListenerFactory(() -> listener);
441-
}
442-
if (builder != null) {
443-
builder.addListenerFactory(() -> listener);
444-
}
434+
client.addListenerFactory(() -> listener);
445435
}
446436

447437
@Override

solr/core/src/test/org/apache/solr/cli/PostToolTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public void testBasicRun() throws Exception {
7676

7777
withBasicAuth(CollectionAdminRequest.createCollection(collection, "conf1", 1, 1, 0, 0))
7878
.processAndWait(cluster.getSolrClient(), 10);
79-
waitForState("creating", collection, activeClusterShape(1, 1));
8079

8180
File jsonDoc = File.createTempFile("temp", ".json");
8281

solr/core/src/test/org/apache/solr/cloud/OverseerTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,16 +1945,17 @@ public Void answer(InvocationOnMock invocation) {
19451945
}
19461946

19471947
private SolrCloudManager getCloudDataProvider(ZkStateReader zkStateReader) {
1948-
var httpSolrClientBuilder =
1948+
var httpSolrClient =
19491949
new Http2SolrClient.Builder()
19501950
.withIdleTimeout(30000, TimeUnit.MILLISECONDS)
1951-
.withConnectionTimeout(15000, TimeUnit.MILLISECONDS);
1951+
.withConnectionTimeout(15000, TimeUnit.MILLISECONDS)
1952+
.build();
19521953
var cloudSolrClient =
19531954
new CloudHttp2SolrClient.Builder(new ZkClientClusterStateProvider(zkStateReader))
1954-
.withInternalClientBuilder(httpSolrClientBuilder)
1955+
.withHttpClient(httpSolrClient)
19551956
.build();
19561957
solrClients.add(cloudSolrClient);
1957-
solrClients.add(httpSolrClientBuilder.build());
1958+
solrClients.add(httpSolrClient);
19581959
SolrClientCloudManager sccm = new SolrClientCloudManager(cloudSolrClient, null);
19591960
sccm.getClusterStateProvider().connect();
19601961
return sccm;

solr/solrj/src/java/org/apache/solr/client/solrj/SolrClientFunction.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818

1919
import java.io.IOException;
2020

21-
/**
22-
* A lambda intended for invoking SolrClient operations
23-
*
24-
* @lucene.experimental
25-
*/
21+
/** A lambda intended for invoking SolrClient operations */
2622
@FunctionalInterface
2723
public interface SolrClientFunction<C extends SolrClient, R> {
2824
R apply(C c) throws IOException, SolrServerException;

0 commit comments

Comments
 (0)