From 99282aa62e69bd9bb11c9c1b2fa8de754f8427d3 Mon Sep 17 00:00:00 2001 From: jdyer1 Date: Tue, 17 Dec 2024 17:25:55 -0600 Subject: [PATCH] Better variable names --- .../org/apache/solr/cloud/ZkController.java | 4 ++-- .../solr/core/HttpSolrClientProvider.java | 11 +++++----- .../solrj/impl/CloudHttp2SolrClient.java | 6 +++--- .../solrj/impl/LBHttp2SolrClientTest.java | 20 +++++++++---------- 4 files changed, 21 insertions(+), 20 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 3dc5453ca2e..1f40b1d45da 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -868,14 +868,14 @@ public SolrCloudManager getSolrCloudManager() { if (cloudManager != null) { return cloudManager; } - var httpClientBuilder = + var httpSolrClientBuilder = new Http2SolrClient.Builder() .withHttpClient(cc.getDefaultHttpSolrClient()) .withIdleTimeout(30000, TimeUnit.MILLISECONDS) .withConnectionTimeout(15000, TimeUnit.MILLISECONDS); cloudSolrClient = new CloudHttp2SolrClient.Builder(new ZkClientClusterStateProvider(zkStateReader)) - .withInternalClientBuilder(httpClientBuilder) + .withInternalClientBuilder(httpSolrClientBuilder) .build(); cloudManager = new SolrClientCloudManager(cloudSolrClient, cc.getObjectCache()); cloudManager.getClusterStateProvider().connect(); diff --git a/solr/core/src/java/org/apache/solr/core/HttpSolrClientProvider.java b/solr/core/src/java/org/apache/solr/core/HttpSolrClientProvider.java index 347607ea9f9..e9631b26d1f 100644 --- a/solr/core/src/java/org/apache/solr/core/HttpSolrClientProvider.java +++ b/solr/core/src/java/org/apache/solr/core/HttpSolrClientProvider.java @@ -36,7 +36,7 @@ final class HttpSolrClientProvider implements AutoCloseable { private final Http2SolrClient httpSolrClient; - private final Http2SolrClient.Builder httpClientBuilder; + private final Http2SolrClient.Builder httpSolrClientBuilder; private final InstrumentedHttpListenerFactory trackHttpSolrMetrics; @@ -44,15 +44,16 @@ final class HttpSolrClientProvider implements AutoCloseable { trackHttpSolrMetrics = new InstrumentedHttpListenerFactory(getNameStrategy(cfg)); initializeMetrics(parentContext); - this.httpClientBuilder = new Http2SolrClient.Builder().addListenerFactory(trackHttpSolrMetrics); + this.httpSolrClientBuilder = + new Http2SolrClient.Builder().addListenerFactory(trackHttpSolrMetrics); if (cfg != null) { - httpClientBuilder + httpSolrClientBuilder .withConnectionTimeout(cfg.getDistributedConnectionTimeout(), TimeUnit.MILLISECONDS) .withIdleTimeout(cfg.getDistributedSocketTimeout(), TimeUnit.MILLISECONDS) .withMaxConnectionsPerHost(cfg.getMaxUpdateConnectionsPerHost()); } - httpSolrClient = httpClientBuilder.build(); + httpSolrClient = httpSolrClientBuilder.build(); } private InstrumentedHttpListenerFactory.NameStrategy getNameStrategy( @@ -76,7 +77,7 @@ Http2SolrClient getSolrClient() { } void setSecurityBuilder(HttpClientBuilderPlugin builder) { - builder.setup(httpClientBuilder, httpSolrClient); + builder.setup(httpSolrClientBuilder, httpSolrClient); } @Override 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 ef80a292b9a..18aa318f8ba 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 @@ -53,8 +53,8 @@ public class CloudHttp2SolrClient extends CloudSolrClient { */ protected CloudHttp2SolrClient(Builder builder) { super(builder.shardLeadersOnly, builder.parallelUpdates, builder.directUpdatesToLeadersOnly); - var httpClientBuilder = createOrGetHttpClientBuilder(builder); - this.myClient = httpClientBuilder.build(); + var httpSolrClientBuilder = createOrGetHttpClientBuilder(builder); + this.myClient = httpSolrClientBuilder.build(); this.stateProvider = createClusterStateProvider(builder); this.retryExpiryTimeNano = builder.retryExpiryTimeNano; this.defaultCollection = builder.defaultCollection; @@ -72,7 +72,7 @@ protected CloudHttp2SolrClient(Builder builder) { // locks. this.locks = objectList(builder.parallelCacheRefreshesLocks); - this.lbClient = new LBHttp2SolrClient.Builder<>(httpClientBuilder).build(); + this.lbClient = new LBHttp2SolrClient.Builder<>(httpSolrClientBuilder).build(); } private Http2SolrClient.Builder createOrGetHttpClientBuilder(Builder builder) { diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientTest.java index ca3ce7ce4bf..30cee0804b5 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientTest.java @@ -52,11 +52,11 @@ public void testLBHttp2SolrClientWithTheseParamNamesInTheUrl() { Set urlParamNames = new HashSet<>(2); urlParamNames.add("param1"); - var httpClientBuilder = + var httpSolrClientBuilder = new Http2SolrClient.Builder(url).withTheseParamNamesInTheUrl(urlParamNames); var endpoint = new LBSolrClient.Endpoint(url); try (var testClient = - new LBHttp2SolrClient.Builder(httpClientBuilder, endpoint) + new LBHttp2SolrClient.Builder(httpSolrClientBuilder, endpoint) .build()) { assertArrayEquals( @@ -76,11 +76,11 @@ public void testSynchronous() throws Exception { LBSolrClient.Endpoint ep2 = new LBSolrClient.Endpoint("http://endpoint.two"); List endpointList = List.of(ep1, ep2); - var httpClientBuilder = + var httpSolrClientBuilder = new MockHttpSolrClientBuilder().withConnectionTimeout(10, TimeUnit.SECONDS); try (LBHttp2SolrClient testClient = - new LBHttp2SolrClient.Builder<>(httpClientBuilder, ep1, ep2).build()) { + new LBHttp2SolrClient.Builder<>(httpSolrClientBuilder, ep1, ep2).build()) { String lastEndpoint = null; for (int i = 0; i < 10; i++) { @@ -104,11 +104,11 @@ public void testSynchronousWithFalures() throws Exception { LBSolrClient.Endpoint ep2 = new LBSolrClient.Endpoint("http://endpoint.two"); List endpointList = List.of(ep1, ep2); - var httpClientBuilder = + var httpSolrClientBuilder = new MockHttpSolrClientBuilder().withConnectionTimeout(10, TimeUnit.SECONDS); try (LBHttp2SolrClient testClient = - new LBHttp2SolrClient.Builder<>(httpClientBuilder, ep1, ep2).build()) { + new LBHttp2SolrClient.Builder<>(httpSolrClientBuilder, ep1, ep2).build()) { setEndpointToFail(testClient, ep1); setEndpointToSucceed(testClient, ep2); @@ -154,11 +154,11 @@ public void testAsyncWithFailures() { LBSolrClient.Endpoint ep2 = new LBSolrClient.Endpoint("http://endpoint.two"); List endpointList = List.of(ep1, ep2); - var httpClientBuilder = + var httpSolrClientBuilder = new MockHttpSolrClientBuilder().withConnectionTimeout(10, TimeUnit.SECONDS); try (LBHttp2SolrClient testClient = - new LBHttp2SolrClient.Builder<>(httpClientBuilder, ep1, ep2).build()) { + new LBHttp2SolrClient.Builder<>(httpSolrClientBuilder, ep1, ep2).build()) { for (int j = 0; j < 2; j++) { // first time Endpoint One will return error code 500. @@ -226,11 +226,11 @@ public void testAsync() { LBSolrClient.Endpoint ep2 = new LBSolrClient.Endpoint("http://endpoint.two"); List endpointList = List.of(ep1, ep2); - var httpClientBuilder = + var httpSolrClientBuilder = new MockHttpSolrClientBuilder().withConnectionTimeout(10, TimeUnit.SECONDS); try (LBHttp2SolrClient testClient = - new LBHttp2SolrClient.Builder<>(httpClientBuilder, ep1, ep2).build()) { + new LBHttp2SolrClient.Builder<>(httpSolrClientBuilder, ep1, ep2).build()) { int limit = 10; // For simplicity use an even limit List> responses = new ArrayList<>();