This is an automated email from the ASF dual-hosted git repository. jdyer pushed a commit to branch feature/SOLR-17771 in repository https://gitbox.apache.org/repos/asf/solr.git
commit b5c6c996bdefdf1e40703e991bcd8200f62770a3 Author: jdyer1 <[email protected]> AuthorDate: Mon Oct 13 14:29:17 2025 -0500 Make CloudHttp2SolrClient generic; update references to remove compiler warnings --- .../src/java/org/apache/solr/cli/CLIUtils.java | 6 +- .../src/java/org/apache/solr/cli/ExportTool.java | 2 +- .../java/org/apache/solr/cli/HealthcheckTool.java | 3 +- .../java/org/apache/solr/cli/RunExampleTool.java | 3 +- .../java/org/apache/solr/cloud/ZkController.java | 5 +- .../solr/client/solrj/io/SolrClientCache.java | 4 +- .../client/solrj/impl/SolrClientCloudManager.java | 4 +- .../solrj/impl/SolrClientNodeStateProvider.java | 8 +-- .../client/solrj/impl/CloudHttp2SolrClient.java | 75 +++++++++++----------- .../impl/CloudHttp2SolrClientBuilderTest.java | 73 +++++++++++++++------ .../CloudHttp2SolrClientMultiConstructorTest.java | 4 +- .../solrj/impl/CloudHttp2SolrClientRetryTest.java | 2 +- .../solrj/impl/CloudHttp2SolrClientTest.java | 6 +- .../solrj/impl/CloudSolrClientBuilderTest.java | 12 ++-- .../impl/CloudSolrClientMultiConstructorTest.java | 4 +- .../client/solrj/impl/HttpClusterStateSSLTest.java | 4 +- .../impl/SendUpdatesToLeadersOverrideTest.java | 6 +- .../src/java/org/apache/solr/SolrTestCaseJ4.java | 2 +- 18 files changed, 130 insertions(+), 93 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cli/CLIUtils.java b/solr/core/src/java/org/apache/solr/cli/CLIUtils.java index c04e02fc160..fccbd4a84b3 100644 --- a/solr/core/src/java/org/apache/solr/cli/CLIUtils.java +++ b/solr/core/src/java/org/apache/solr/cli/CLIUtils.java @@ -261,13 +261,13 @@ public final class CLIUtils { .build(); } - public static CloudHttp2SolrClient getCloudHttp2SolrClient(String zkHost) { + public static CloudHttp2SolrClient<Http2SolrClient> getCloudHttp2SolrClient(String zkHost) { return getCloudHttp2SolrClient(zkHost, null); } - public static CloudHttp2SolrClient getCloudHttp2SolrClient( + public static CloudHttp2SolrClient<Http2SolrClient> getCloudHttp2SolrClient( String zkHost, Http2SolrClient.Builder builder) { - return new CloudHttp2SolrClient.Builder(Collections.singletonList(zkHost), Optional.empty()) + return new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(Collections.singletonList(zkHost), Optional.empty()) .withHttpClientBuilder(builder) .build(); } diff --git a/solr/core/src/java/org/apache/solr/cli/ExportTool.java b/solr/core/src/java/org/apache/solr/cli/ExportTool.java index af2cf6ba590..e2392563563 100644 --- a/solr/core/src/java/org/apache/solr/cli/ExportTool.java +++ b/solr/core/src/java/org/apache/solr/cli/ExportTool.java @@ -256,7 +256,7 @@ public class ExportTool extends ToolBase { new Http2SolrClient.Builder().withOptionalBasicAuthCredentials(credentials); solrClient = - new CloudHttp2SolrClient.Builder(Collections.singletonList(baseurl)) + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(Collections.singletonList(baseurl)) .withHttpClientBuilder(builder) .build(); NamedList<Object> response = diff --git a/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java b/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java index bf795a51596..c17f85c571d 100644 --- a/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java +++ b/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java @@ -34,6 +34,7 @@ import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient; import org.apache.solr.client.solrj.impl.CloudSolrClient; +import org.apache.solr.client.solrj.impl.Http2SolrClient; import org.apache.solr.client.solrj.request.GenericSolrRequest; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.common.cloud.ClusterState; @@ -88,7 +89,7 @@ public class HealthcheckTool extends ToolBase { CLIO.err("Healthcheck tool only works in Solr Cloud mode."); runtime.exit(1); } - try (CloudHttp2SolrClient cloudSolrClient = CLIUtils.getCloudHttp2SolrClient(zkHost)) { + try (CloudHttp2SolrClient<Http2SolrClient> cloudSolrClient = CLIUtils.getCloudHttp2SolrClient(zkHost)) { echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ..."); cloudSolrClient.connect(); runCloudTool(cloudSolrClient, cli); diff --git a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java index fd530bb2854..4e15d459f99 100644 --- a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java +++ b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java @@ -46,6 +46,7 @@ import org.apache.commons.io.file.PathUtils; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient; import org.apache.solr.client.solrj.impl.CloudSolrClient; +import org.apache.solr.client.solrj.impl.Http2SolrClient; import org.apache.solr.common.SolrException; import org.apache.solr.common.util.EnvUtils; import org.noggit.CharArr; @@ -630,7 +631,7 @@ public class RunExampleTool extends ToolBase { /** wait until the number of live nodes == numNodes. */ protected void waitToSeeLiveNodes(String zkHost, int numNodes) { try (CloudSolrClient cloudClient = - new CloudHttp2SolrClient.Builder(Collections.singletonList(zkHost), Optional.empty()).build()) { + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(Collections.singletonList(zkHost), Optional.empty()).build()) { cloudClient.connect(); Set<String> liveNodes = cloudClient.getClusterState().getLiveNodes(); int numLiveNodes = (liveNodes != null) ? liveNodes.size() : 0; 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 bc41a64136e..f6be7f9a18a 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -62,6 +62,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.CloudSolrClient; +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; @@ -206,7 +207,7 @@ public class ZkController implements Closeable { public final ZkStateReader zkStateReader; private SolrCloudManager cloudManager; - private CloudHttp2SolrClient cloudSolrClient; + private CloudHttp2SolrClient<Http2SolrClient> cloudSolrClient; private final ExecutorService zkConnectionListenerCallbackExecutor = ExecutorUtil.newMDCAwareSingleThreadExecutor( @@ -962,7 +963,7 @@ public class ZkController implements Closeable { return cloudManager; } cloudSolrClient = - new CloudHttp2SolrClient.Builder(new ZkClientClusterStateProvider(zkStateReader)) + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(new ZkClientClusterStateProvider(zkStateReader)) .withHttpClient(cc.getDefaultHttpSolrClient()) .build(); cloudManager = new SolrClientCloudManager(cloudSolrClient, cc.getObjectCache()); diff --git a/solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java b/solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java index ec94c7d5aa9..6138a6be7fa 100644 --- a/solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java +++ b/solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java @@ -96,13 +96,13 @@ public class SolrClientCache implements Closeable { return client; } - private static CloudHttp2SolrClient newCloudHttp2SolrClient( + private static CloudHttp2SolrClient<Http2SolrClient> newCloudHttp2SolrClient( String zkHost, Http2SolrClient http2SolrClient, boolean canUseACLs, String basicAuthCredentials) { final List<String> hosts = List.of(zkHost); - var builder = new CloudHttp2SolrClient.Builder(hosts, Optional.empty()); + var builder = new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(hosts, Optional.empty()); builder.canUseZkACLs(canUseACLs); // using internal builder to ensure the internal client gets closed builder = 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 30afd6bed57..0efd116869a 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 @@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory; public class SolrClientCloudManager implements SolrCloudManager { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final CloudHttp2SolrClient cloudSolrClient; + private final CloudHttp2SolrClient<Http2SolrClient> cloudSolrClient; private final ZkDistribStateManager stateManager; private final ZkStateReader zkStateReader; private final SolrZkClient zkClient; @@ -41,7 +41,7 @@ public class SolrClientCloudManager implements SolrCloudManager { private final boolean closeObjectCache; private volatile boolean isClosed; - public SolrClientCloudManager(CloudHttp2SolrClient client, ObjectCache objectCache) { + public SolrClientCloudManager(CloudHttp2SolrClient<Http2SolrClient> 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 e3b3e9cbcf5..51ab3540e00 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 @@ -52,14 +52,14 @@ import org.slf4j.LoggerFactory; public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final CloudHttp2SolrClient solrClient; + private final CloudHttp2SolrClient<Http2SolrClient> 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(CloudHttp2SolrClient solrClient) { + public SolrClientNodeStateProvider(CloudHttp2SolrClient<Http2SolrClient> solrClient) { this.solrClient = solrClient; try { readReplicaDetails(); @@ -222,7 +222,7 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter static class RemoteCallCtx { ZkClientClusterStateProvider zkClientClusterStateProvider; - CloudHttp2SolrClient cloudSolrClient; + CloudHttp2SolrClient <Http2SolrClient>cloudSolrClient; public final Map<String, Object> tags = new HashMap<>(); private final String node; public Map<String, Object> session; @@ -234,7 +234,7 @@ public class SolrClientNodeStateProvider implements NodeStateProvider, MapWriter return true; } - public RemoteCallCtx(String node, CloudHttp2SolrClient cloudSolrClient) { + public RemoteCallCtx(String node, CloudHttp2SolrClient<Http2SolrClient> cloudSolrClient) { this.node = node; this.cloudSolrClient = cloudSolrClient; this.zkClientClusterStateProvider = diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java index 028d8b675c5..e4fbe3f7941 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java @@ -37,11 +37,11 @@ import org.apache.solr.common.SolrException; * @since solr 8.0 */ @SuppressWarnings("serial") -public class CloudHttp2SolrClient extends CloudSolrClient { +public class CloudHttp2SolrClient<C extends HttpSolrClientBase> extends CloudSolrClient { private final ClusterStateProvider stateProvider; - private final LBHttp2SolrClient<Http2SolrClient> lbClient; - private final Http2SolrClient myClient; + private final LBHttp2SolrClient<C> lbClient; + private final C myClient; private final boolean clientIsInternal; /** @@ -52,7 +52,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * * @param builder a {@link Http2SolrClient.Builder} with the options used to create the client. */ - protected CloudHttp2SolrClient(Builder builder) { + protected CloudHttp2SolrClient(Builder<?,?> builder) { super(builder.shardLeadersOnly, builder.parallelUpdates, builder.directUpdatesToLeadersOnly); this.clientIsInternal = builder.httpClient == null; this.myClient = createOrGetHttpClientFromBuilder(builder); @@ -73,20 +73,20 @@ public class CloudHttp2SolrClient extends CloudSolrClient { // locks. this.locks = objectList(builder.parallelCacheRefreshesLocks); - this.lbClient = new LBHttp2SolrClient.Builder<Http2SolrClient>(myClient).build(); + this.lbClient = new LBHttp2SolrClient.Builder<>(myClient).build(); } - - private Http2SolrClient createOrGetHttpClientFromBuilder(Builder builder) { + @SuppressWarnings("unchecked") + private C createOrGetHttpClientFromBuilder(Builder<?,?> builder) { if (builder.httpClient != null) { - return builder.httpClient; + return (C) builder.httpClient; } else if (builder.internalClientBuilder != null) { - return builder.internalClientBuilder.build(); + return (C) builder.internalClientBuilder.build(); } else { - return new Http2SolrClient.Builder().build(); + return (C) new Http2SolrClient.Builder().build(); } } - private ClusterStateProvider createClusterStateProvider(Builder builder) { + private ClusterStateProvider createClusterStateProvider(Builder<?,?> builder) { if (builder.stateProvider != null) { return builder.stateProvider; } else if (builder.zkHosts.isEmpty()) { @@ -96,7 +96,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { } } - private ClusterStateProvider createZkClusterStateProvider(Builder builder) { + private ClusterStateProvider createZkClusterStateProvider(Builder<?,?> builder) { try { ClusterStateProvider stateProvider = ClusterStateProvider.newZkClusterStateProvider( @@ -113,7 +113,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { } private ClusterStateProvider createHttp2ClusterStateProvider( - List<String> solrUrls, Http2SolrClient httpClient) { + List<String> solrUrls, C httpClient) { try { return new Http2ClusterStateProvider<>(solrUrls, httpClient); } catch (Exception e) { @@ -148,7 +148,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { } @Override - public LBHttp2SolrClient<Http2SolrClient> getLbClient() { + public LBHttp2SolrClient<C> getLbClient() { return lbClient; } @@ -157,7 +157,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { return stateProvider; } - public Http2SolrClient getHttpClient() { + public C getHttpClient() { return myClient; } @@ -167,16 +167,16 @@ public class CloudHttp2SolrClient extends CloudSolrClient { } /** Constructs {@link CloudHttp2SolrClient} instances from provided configuration. */ - public static class Builder { + public static class Builder<B extends HttpSolrClientBuilderBase<?,?>, C extends HttpSolrClientBase> { protected Collection<String> zkHosts = new ArrayList<>(); protected List<String> solrUrls = new ArrayList<>(); protected String zkChroot; - protected Http2SolrClient httpClient; + protected C httpClient; protected boolean shardLeadersOnly = true; protected boolean directUpdatesToLeadersOnly = false; protected boolean parallelUpdates = true; protected ClusterStateProvider stateProvider; - protected Http2SolrClient.Builder internalClientBuilder; + protected B internalClientBuilder; private RequestWriter requestWriter; private ResponseParser responseParser; private long retryExpiryTimeNano = @@ -206,6 +206,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * final SolrClient client = new CloudHttp2SolrClient.Builder(solrBaseUrls).build(); * </pre> */ + @SuppressWarnings({"rawtypes"}) public Builder(List<String> solrUrls) { this.solrUrls = solrUrls; } @@ -245,7 +246,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { } /** Whether to use the default ZK ACLs when building a ZK Client. */ - public Builder canUseZkACLs(boolean canUseZkACLs) { + public Builder<B, C> canUseZkACLs(boolean canUseZkACLs) { this.canUseZkACLs = canUseZkACLs; return this; } @@ -257,7 +258,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * @see #sendUpdatesToAnyReplica * @see CloudSolrClient#isUpdatesToLeaders */ - public Builder sendUpdatesOnlyToShardLeaders() { + public Builder<B, C> sendUpdatesOnlyToShardLeaders() { shardLeadersOnly = true; return this; } @@ -269,7 +270,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * @see #sendUpdatesOnlyToShardLeaders * @see CloudSolrClient#isUpdatesToLeaders */ - public Builder sendUpdatesToAnyReplica() { + public Builder<B, C> sendUpdatesToAnyReplica() { shardLeadersOnly = false; return this; } @@ -284,7 +285,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * @see #sendDirectUpdatesToAnyShardReplica * @see CloudSolrClient#isDirectUpdatesToLeadersOnly */ - public Builder sendDirectUpdatesToShardLeadersOnly() { + public Builder<B, C> sendDirectUpdatesToShardLeadersOnly() { directUpdatesToLeadersOnly = true; return this; } @@ -299,19 +300,19 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * @see #sendDirectUpdatesToShardLeadersOnly * @see CloudSolrClient#isDirectUpdatesToLeadersOnly */ - public Builder sendDirectUpdatesToAnyShardReplica() { + public Builder<B, C> sendDirectUpdatesToAnyShardReplica() { directUpdatesToLeadersOnly = false; return this; } /** Provides a {@link RequestWriter} for created clients to use when handing requests. */ - public Builder withRequestWriter(RequestWriter requestWriter) { + public Builder<B, C> withRequestWriter(RequestWriter requestWriter) { this.requestWriter = requestWriter; return this; } /** Provides a {@link ResponseParser} for created clients to use when handling requests. */ - public Builder withResponseParser(ResponseParser responseParser) { + public Builder<B, C> withResponseParser(ResponseParser responseParser) { this.responseParser = responseParser; return this; } @@ -326,7 +327,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * * <p>If not set, this defaults to 'true' and sends sub-requests in parallel. */ - public Builder withParallelUpdates(boolean parallelUpdates) { + public Builder<B, C> withParallelUpdates(boolean parallelUpdates) { this.parallelUpdates = parallelUpdates; return this; } @@ -337,7 +338,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * * <p>Defaults to 3. */ - public Builder withParallelCacheRefreshes(int parallelCacheRefreshesLocks) { + public Builder<B, C> withParallelCacheRefreshes(int parallelCacheRefreshesLocks) { this.parallelCacheRefreshesLocks = parallelCacheRefreshesLocks; return this; } @@ -345,13 +346,13 @@ public class CloudHttp2SolrClient extends CloudSolrClient { /** * This is the time to wait to re-fetch the state after getting the same state version from ZK */ - public Builder withRetryExpiryTime(long expiryTime, TimeUnit unit) { + public Builder<B, C> withRetryExpiryTime(long expiryTime, TimeUnit unit) { this.retryExpiryTimeNano = TimeUnit.NANOSECONDS.convert(expiryTime, unit); return this; } /** Sets the default collection for request. */ - public Builder withDefaultCollection(String defaultCollection) { + public Builder<B, C> withDefaultCollection(String defaultCollection) { this.defaultCollection = defaultCollection; return this; } @@ -361,7 +362,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * * @param timeToLive ttl value */ - public Builder withCollectionCacheTtl(long timeToLive, TimeUnit unit) { + public Builder<B, C> withCollectionCacheTtl(long timeToLive, TimeUnit unit) { assert timeToLive > 0; this.timeToLiveSeconds = TimeUnit.SECONDS.convert(timeToLive, unit); return this; @@ -374,7 +375,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * * @return this */ - public Builder withHttpClient(Http2SolrClient httpSolrClient) { + public Builder<B, C> withHttpClient(C httpSolrClient) { if (this.internalClientBuilder != null) { throw new IllegalStateException( "The builder can't accept an httpClient AND an internalClientBuilder, only one of those can be provided"); @@ -391,7 +392,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * @param internalClientBuilder the builder to use for creating the internal http client. * @return this */ - public Builder withHttpClientBuilder(Http2SolrClient.Builder internalClientBuilder) { + public Builder<B, C> withHttpClientBuilder(B internalClientBuilder) { if (this.httpClient != null) { throw new IllegalStateException( "The builder can't accept an httpClient AND an internalClientBuilder, only one of those can be provided"); @@ -401,7 +402,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { } @Deprecated(since = "9.10") - public Builder withInternalClientBuilder(Http2SolrClient.Builder internalClientBuilder) { + public Builder<B, C> withInternalClientBuilder(B internalClientBuilder) { return withHttpClientBuilder(internalClientBuilder); } @@ -411,7 +412,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * @param zkConnectTimeout timeout value * @param unit time unit */ - public Builder withZkConnectTimeout(int zkConnectTimeout, TimeUnit unit) { + public Builder<B, C> withZkConnectTimeout(int zkConnectTimeout, TimeUnit unit) { this.zkConnectTimeout = Math.toIntExact(unit.toMillis(zkConnectTimeout)); return this; } @@ -422,13 +423,13 @@ public class CloudHttp2SolrClient extends CloudSolrClient { * @param zkClientTimeout timeout value * @param unit time unit */ - public Builder withZkClientTimeout(int zkClientTimeout, TimeUnit unit) { + public Builder<B, C> withZkClientTimeout(int zkClientTimeout, TimeUnit unit) { this.zkClientTimeout = Math.toIntExact(unit.toMillis(zkClientTimeout)); return this; } /** Create a {@link CloudHttp2SolrClient} based on the provided configuration. */ - public CloudHttp2SolrClient build() { + public CloudHttp2SolrClient<C> build() { int providedOptions = 0; if (!zkHosts.isEmpty()) providedOptions++; if (!solrUrls.isEmpty()) providedOptions++; @@ -442,7 +443,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { "One of zkHosts, solrUrls, or stateProvider must be specified."); } - return new CloudHttp2SolrClient(this); + return new CloudHttp2SolrClient<>(this); } } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java index ac07fb12028..72dbf83cfc7 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java @@ -54,7 +54,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { @Test public void testSingleZkHostSpecified() throws IOException { try (CloudSolrClient createdClient = - new CloudHttp2SolrClient.Builder( + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) .build()) { try (ZkClientClusterStateProvider zkClientClusterStateProvider = @@ -72,7 +72,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { zkHostList.add(ANY_ZK_HOST); zkHostList.add(ANY_OTHER_ZK_HOST); try (CloudSolrClient createdClient = - new CloudHttp2SolrClient.Builder(zkHostList, Optional.of(ANY_CHROOT)).build()) { + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(zkHostList, Optional.of(ANY_CHROOT)).build()) { try (ZkClientClusterStateProvider zkClientClusterStateProvider = ZkClientClusterStateProvider.from(createdClient)) { final String clientZkHost = zkClientClusterStateProvider.getZkHost(); @@ -89,7 +89,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { zkHosts.add(ANY_ZK_HOST); zkHosts.add(ANY_OTHER_ZK_HOST); try (CloudSolrClient createdClient = - new CloudHttp2SolrClient.Builder(zkHosts, Optional.of(ANY_CHROOT)).build()) { + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(zkHosts, Optional.of(ANY_CHROOT)).build()) { try (ZkClientClusterStateProvider zkClientClusterStateProvider = ZkClientClusterStateProvider.from(createdClient)) { final String clientZkHost = zkClientClusterStateProvider.getZkHost(); @@ -103,7 +103,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { @Test public void testByDefaultConfiguresClientToSendUpdatesOnlyToShardLeaders() throws IOException { try (CloudSolrClient createdClient = - new CloudHttp2SolrClient.Builder( + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) .build()) { assertTrue(createdClient.isUpdatesToLeaders()); @@ -113,7 +113,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { @Test public void testIsDirectUpdatesToLeadersOnlyDefault() throws IOException { try (CloudSolrClient createdClient = - new CloudHttp2SolrClient.Builder( + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) .build()) { assertFalse(createdClient.isDirectUpdatesToLeadersOnly()); @@ -125,7 +125,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { expectThrows( IllegalStateException.class, () -> - new CloudHttp2SolrClient.Builder( + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) .withHttpClient(mock(Http2SolrClient.class)) .withHttpClientBuilder(mock(Http2SolrClient.Builder.class)) @@ -133,7 +133,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { expectThrows( IllegalStateException.class, () -> - new CloudHttp2SolrClient.Builder( + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) .withHttpClientBuilder(mock(Http2SolrClient.Builder.class)) .withHttpClient(mock(Http2SolrClient.class)) @@ -141,16 +141,16 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { } @Test - public void testProvideInternalBuilder() throws IOException { + public void testProvideInternalJettyClientBuilder() throws IOException { Http2SolrClient http2Client = mock(Http2SolrClient.class); Http2SolrClient.Builder http2ClientBuilder = mock(Http2SolrClient.Builder.class); when(http2ClientBuilder.build()).thenReturn(http2Client); - CloudHttp2SolrClient.Builder clientBuilder = - new CloudHttp2SolrClient.Builder( + CloudHttp2SolrClient.Builder<HttpSolrClientBuilderBase<?, ?>, HttpSolrClientBase> clientBuilder = + new CloudHttp2SolrClient.Builder<>( Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) .withHttpClientBuilder(http2ClientBuilder); verify(http2ClientBuilder, never()).build(); - try (CloudHttp2SolrClient client = clientBuilder.build()) { + try (CloudHttp2SolrClient<?> client = clientBuilder.build()) { assertEquals(http2Client, client.getHttpClient()); verify(http2ClientBuilder, times(1)).build(); verify(http2Client, never()).close(); @@ -160,13 +160,46 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { } @Test - public void testProvideExternalClient() throws IOException { + public void testProvideInternalJdkClientBuilder() throws IOException { + var http2Client = mock(HttpJdkSolrClient.class); + HttpJdkSolrClient.Builder http2ClientBuilder = mock(HttpJdkSolrClient.Builder.class); + when(http2ClientBuilder.build()).thenReturn(http2Client); + CloudHttp2SolrClient.Builder<HttpJdkSolrClient.Builder, HttpJdkSolrClient> clientBuilder = + new CloudHttp2SolrClient.Builder<HttpJdkSolrClient.Builder, HttpJdkSolrClient>( + Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) + .withHttpClientBuilder(http2ClientBuilder); + verify(http2ClientBuilder, never()).build(); + try (CloudHttp2SolrClient<HttpJdkSolrClient> client = clientBuilder.build()) { + assertEquals(http2Client, client.getHttpClient()); + verify(http2ClientBuilder, times(1)).build(); + verify(http2Client, never()).close(); + } + // it's internal, should be closed when closing CloudSolrClient + verify(http2Client, times(1)).close(); + } + + @Test + public void testProvideExternalJettyClient() throws IOException { Http2SolrClient http2Client = mock(Http2SolrClient.class); - CloudHttp2SolrClient.Builder clientBuilder = - new CloudHttp2SolrClient.Builder( + CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient> clientBuilder = + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) .withHttpClient(http2Client); - try (CloudHttp2SolrClient client = clientBuilder.build()) { + try (CloudHttp2SolrClient<Http2SolrClient> client = clientBuilder.build()) { + assertEquals(http2Client, client.getHttpClient()); + } + // it's external, should be NOT closed when closing CloudSolrClient + verify(http2Client, never()).close(); + } + + @Test + public void testProvideExternalJdkClient() throws IOException { + HttpJdkSolrClient http2Client = mock(HttpJdkSolrClient.class); + CloudHttp2SolrClient.Builder<HttpJdkSolrClient.Builder, HttpJdkSolrClient> clientBuilder = + new CloudHttp2SolrClient.Builder<HttpJdkSolrClient.Builder, HttpJdkSolrClient>( + Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) + .withHttpClient(http2Client); + try (CloudHttp2SolrClient<HttpJdkSolrClient> client = clientBuilder.build()) { assertEquals(http2Client, client.getHttpClient()); } // it's external, should be NOT closed when closing CloudSolrClient @@ -175,8 +208,8 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { @Test public void testDefaultCollectionPassedFromBuilderToClient() throws IOException { - try (CloudHttp2SolrClient createdClient = - new CloudHttp2SolrClient.Builder( + try (CloudHttp2SolrClient<Http2SolrClient> createdClient = + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) .withDefaultCollection("aCollection") .build()) { @@ -213,7 +246,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { Http2SolrClient httpClient, Http2SolrClient.Builder internalClientBuilder) throws IOException { - CloudHttp2SolrClient.Builder clientBuilder = new CloudHttp2SolrClient.Builder(solrUrls); + CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient> clientBuilder = new CloudHttp2SolrClient.Builder<>(solrUrls); if (httpClient != null) { clientBuilder.withHttpClient(httpClient); @@ -221,7 +254,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { clientBuilder.withHttpClientBuilder(internalClientBuilder); } - try (CloudHttp2SolrClient client = clientBuilder.build()) { + try (CloudHttp2SolrClient<Http2SolrClient> client = clientBuilder.build()) { assertEquals( client.getHttpClient(), ((Http2ClusterStateProvider) client.getClusterStateProvider()).getHttpClient()); @@ -230,7 +263,7 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { public void testCustomStateProvider() throws IOException { ZkClientClusterStateProvider stateProvider = mock(ZkClientClusterStateProvider.class); - try (CloudSolrClient cloudSolrClient = new CloudHttp2SolrClient.Builder(stateProvider).build()) { + try (CloudSolrClient cloudSolrClient = new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(stateProvider).build()) { assertEquals(stateProvider, cloudSolrClient.getClusterStateProvider()); } verify(stateProvider, times(1)).close(); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientMultiConstructorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientMultiConstructorTest.java index c4210bab7b4..ccf57adc49b 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientMultiConstructorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientMultiConstructorTest.java @@ -69,7 +69,7 @@ public class CloudHttp2SolrClientMultiConstructorTest extends SolrTestCase { } try (CloudSolrClient client = - new CloudHttp2SolrClient.Builder(new ArrayList<>(hosts), Optional.ofNullable(clientChroot)) + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(new ArrayList<>(hosts), Optional.ofNullable(clientChroot)) .build()) { try (ZkClientClusterStateProvider zkClientClusterStateProvider = ZkClientClusterStateProvider.from(client)) { @@ -82,6 +82,6 @@ public class CloudHttp2SolrClientMultiConstructorTest extends SolrTestCase { public void testBadChroot() { final List<String> zkHosts = new ArrayList<>(); zkHosts.add("host1:2181"); - new CloudHttp2SolrClient.Builder(zkHosts, Optional.of("foo")).build(); + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(zkHosts, Optional.of("foo")).build(); } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java index 39f10b2c324..a399cd85764 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java @@ -53,7 +53,7 @@ public class CloudHttp2SolrClientRetryTest extends SolrCloudTestCase { public void testRetry() throws Exception { String collectionName = "testRetry"; try (CloudSolrClient solrClient = - new CloudHttp2SolrClient.Builder( + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty()) .build()) { CollectionAdminRequest.createCollection(collectionName, 1, 1).process(solrClient); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java index fb721a06ea2..70def143d70 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java @@ -112,9 +112,9 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase { final List<String> solrUrls = new ArrayList<>(); solrUrls.add(cluster.getJettySolrRunner(0).getBaseUrl().toString()); - httpBasedCloudSolrClient = new CloudHttp2SolrClient.Builder(solrUrls).build(); + httpBasedCloudSolrClient = new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(solrUrls).build(); zkBasedCloudSolrClient = - new CloudHttp2SolrClient.Builder( + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty()) .build(); } @@ -312,7 +312,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase { private CloudSolrClient createHttpCSPBasedCloudSolrClient() { final List<String> solrUrls = new ArrayList<>(); solrUrls.add(cluster.getJettySolrRunner(0).getBaseUrl().toString()); - return new CloudHttp2SolrClient.Builder(solrUrls).build(); + return new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(solrUrls).build(); } @Test diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java index 4089faa454e..2c101b86811 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java @@ -34,7 +34,7 @@ public class CloudSolrClientBuilderTest extends SolrTestCase { @Test public void testSingleZkHostSpecified() throws IOException { try (CloudSolrClient createdClient = - new CloudHttp2SolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).build(); ) { + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).build(); ) { try (ZkClientClusterStateProvider zkClientClusterStateProvider = ZkClientClusterStateProvider.from(createdClient)) { final String clientZkHost = zkClientClusterStateProvider.getZkHost(); @@ -48,7 +48,7 @@ public class CloudSolrClientBuilderTest extends SolrTestCase { final List<String> zkHostList = new ArrayList<>(); zkHostList.add(ANY_ZK_HOST); zkHostList.add(ANY_OTHER_ZK_HOST); - try (CloudSolrClient createdClient = new CloudHttp2SolrClient.Builder(zkHostList, Optional.of(ANY_CHROOT)).build()) { + try (CloudSolrClient createdClient = new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(zkHostList, Optional.of(ANY_CHROOT)).build()) { try (ZkClientClusterStateProvider zkClientClusterStateProvider = ZkClientClusterStateProvider.from(createdClient)) { final String clientZkHost = zkClientClusterStateProvider.getZkHost(); @@ -63,7 +63,7 @@ public class CloudSolrClientBuilderTest extends SolrTestCase { final ArrayList<String> zkHosts = new ArrayList<>(); zkHosts.add(ANY_ZK_HOST); zkHosts.add(ANY_OTHER_ZK_HOST); - try (CloudSolrClient createdClient = new CloudHttp2SolrClient.Builder(zkHosts, Optional.of(ANY_CHROOT)).build()) { + try (CloudSolrClient createdClient = new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(zkHosts, Optional.of(ANY_CHROOT)).build()) { try (ZkClientClusterStateProvider zkClientClusterStateProvider = ZkClientClusterStateProvider.from(createdClient)) { final String clientZkHost = zkClientClusterStateProvider.getZkHost(); @@ -76,7 +76,7 @@ public class CloudSolrClientBuilderTest extends SolrTestCase { @Test public void testByDefaultConfiguresClientToSendUpdatesOnlyToShardLeaders() throws IOException { try (CloudSolrClient createdClient = - new CloudHttp2SolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).build()) { + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).build()) { assertTrue(createdClient.isUpdatesToLeaders()); } } @@ -84,7 +84,7 @@ public class CloudSolrClientBuilderTest extends SolrTestCase { @Test public void testIsDirectUpdatesToLeadersOnlyDefault() throws IOException { try (CloudSolrClient createdClient = - new CloudHttp2SolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).build()) { + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)).build()) { assertFalse(createdClient.isDirectUpdatesToLeadersOnly()); } } @@ -104,7 +104,7 @@ public class CloudSolrClientBuilderTest extends SolrTestCase { @Test public void testDefaultCollectionPassedFromBuilderToClient() throws IOException { try (CloudSolrClient createdClient = - new CloudHttp2SolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) .withDefaultCollection("aCollection") .build()) { assertEquals("aCollection", createdClient.getDefaultCollection()); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java index dc540e49693..ee769ec1e76 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java @@ -69,7 +69,7 @@ public class CloudSolrClientMultiConstructorTest extends SolrTestCase { } try (CloudSolrClient client = - (new CloudHttp2SolrClient.Builder(new ArrayList<>(hosts), Optional.ofNullable(clientChroot)) + (new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(new ArrayList<>(hosts), Optional.ofNullable(clientChroot)) .build())) { try (ZkClientClusterStateProvider zkClientClusterStateProvider = ZkClientClusterStateProvider.from(client)) { @@ -113,6 +113,6 @@ public class CloudSolrClientMultiConstructorTest extends SolrTestCase { public void testBadChroot() { final List<String> zkHosts = new ArrayList<>(); zkHosts.add("host1:2181"); - new CloudHttp2SolrClient.Builder(zkHosts, Optional.of("foo")).build(); + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(zkHosts, Optional.of("foo")).build(); } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClusterStateSSLTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClusterStateSSLTest.java index d160a5d43da..d23987059ec 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClusterStateSSLTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpClusterStateSSLTest.java @@ -83,7 +83,7 @@ public class HttpClusterStateSSLTest extends SolrCloudTestCase { // verify the http derived cluster state (on the client side) agrees with what the server stored try (CloudSolrClient httpBasedCloudSolrClient = - new CloudHttp2SolrClient.Builder(Collections.singletonList(url0.toExternalForm())).build()) { + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(Collections.singletonList(url0.toExternalForm())).build()) { ClusterStateProvider csp = httpBasedCloudSolrClient.getClusterStateProvider(); assertTrue(csp instanceof Http2ClusterStateProvider); verifyUrlSchemeInClusterState(csp.getCollection(collectionId), expectedReplicas); @@ -91,7 +91,7 @@ public class HttpClusterStateSSLTest extends SolrCloudTestCase { // http2 try (CloudSolrClient http2BasedClient = - new CloudHttp2SolrClient.Builder(Collections.singletonList(url0.toExternalForm())) + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>(Collections.singletonList(url0.toExternalForm())) .build()) { ClusterStateProvider csp = http2BasedClient.getClusterStateProvider(); assertTrue(csp instanceof Http2ClusterStateProvider); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java index 89c674b01ee..cd8a6c2b71d 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java @@ -214,7 +214,7 @@ public class SendUpdatesToLeadersOverrideTest extends SolrCloudTestCase { assertTrue(client.isUpdatesToLeaders()); } try (CloudSolrClient client = - new CloudHttp2SolrClient.Builder( + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty()) .build()) { assertTrue(client.isUpdatesToLeaders()); @@ -245,7 +245,7 @@ public class SendUpdatesToLeadersOverrideTest extends SolrCloudTestCase { public void testHttp2ClientThatDefaultsToLeaders() throws Exception { try (CloudSolrClient client = - new CloudHttp2SolrClient.Builder( + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty()) .sendUpdatesOnlyToShardLeaders() .build()) { @@ -256,7 +256,7 @@ public class SendUpdatesToLeadersOverrideTest extends SolrCloudTestCase { public void testHttp2ClientThatDoesNotDefaultToLeaders() throws Exception { try (CloudSolrClient client = - new CloudHttp2SolrClient.Builder( + new CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient>( Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty()) .sendUpdatesToAnyReplica() .build()) { diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java index f2b08870f52..16d0dca8721 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -2527,7 +2527,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { * A variant of {@link org.apache.solr.client.solrj.impl.CloudHttp2SolrClient.Builder} that will * randomize some internal settings. */ - public static class RandomizingCloudHttp2SolrClientBuilder extends CloudHttp2SolrClient.Builder { + public static class RandomizingCloudHttp2SolrClientBuilder extends CloudHttp2SolrClient.Builder<Http2SolrClient.Builder, Http2SolrClient> { public RandomizingCloudHttp2SolrClientBuilder(List<String> zkHosts, Optional<String> zkChroot) { super(zkHosts, zkChroot);
