Skip to content

Commit

Permalink
Better variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
jdyer1 committed Dec 17, 2024
1 parent e035a0c commit 99282aa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions solr/core/src/java/org/apache/solr/cloud/ZkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,24 @@ final class HttpSolrClientProvider implements AutoCloseable {

private final Http2SolrClient httpSolrClient;

private final Http2SolrClient.Builder httpClientBuilder;
private final Http2SolrClient.Builder httpSolrClientBuilder;

private final InstrumentedHttpListenerFactory trackHttpSolrMetrics;

HttpSolrClientProvider(UpdateShardHandlerConfig cfg, SolrMetricsContext parentContext) {
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(
Expand All @@ -76,7 +77,7 @@ Http2SolrClient getSolrClient() {
}

void setSecurityBuilder(HttpClientBuilderPlugin builder) {
builder.setup(httpClientBuilder, httpSolrClient);
builder.setup(httpSolrClientBuilder, httpSolrClient);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public void testLBHttp2SolrClientWithTheseParamNamesInTheUrl() {
Set<String> 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<Http2SolrClient.Builder>(httpClientBuilder, endpoint)
new LBHttp2SolrClient.Builder<Http2SolrClient.Builder>(httpSolrClientBuilder, endpoint)
.build()) {

assertArrayEquals(
Expand All @@ -76,11 +76,11 @@ public void testSynchronous() throws Exception {
LBSolrClient.Endpoint ep2 = new LBSolrClient.Endpoint("http://endpoint.two");
List<LBSolrClient.Endpoint> endpointList = List.of(ep1, ep2);

var httpClientBuilder =
var httpSolrClientBuilder =
new MockHttpSolrClientBuilder().withConnectionTimeout(10, TimeUnit.SECONDS);

try (LBHttp2SolrClient<MockHttpSolrClientBuilder> 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++) {
Expand All @@ -104,11 +104,11 @@ public void testSynchronousWithFalures() throws Exception {
LBSolrClient.Endpoint ep2 = new LBSolrClient.Endpoint("http://endpoint.two");
List<LBSolrClient.Endpoint> endpointList = List.of(ep1, ep2);

var httpClientBuilder =
var httpSolrClientBuilder =
new MockHttpSolrClientBuilder().withConnectionTimeout(10, TimeUnit.SECONDS);

try (LBHttp2SolrClient<MockHttpSolrClientBuilder> testClient =
new LBHttp2SolrClient.Builder<>(httpClientBuilder, ep1, ep2).build()) {
new LBHttp2SolrClient.Builder<>(httpSolrClientBuilder, ep1, ep2).build()) {

setEndpointToFail(testClient, ep1);
setEndpointToSucceed(testClient, ep2);
Expand Down Expand Up @@ -154,11 +154,11 @@ public void testAsyncWithFailures() {
LBSolrClient.Endpoint ep2 = new LBSolrClient.Endpoint("http://endpoint.two");
List<LBSolrClient.Endpoint> endpointList = List.of(ep1, ep2);

var httpClientBuilder =
var httpSolrClientBuilder =
new MockHttpSolrClientBuilder().withConnectionTimeout(10, TimeUnit.SECONDS);

try (LBHttp2SolrClient<MockHttpSolrClientBuilder> 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.
Expand Down Expand Up @@ -226,11 +226,11 @@ public void testAsync() {
LBSolrClient.Endpoint ep2 = new LBSolrClient.Endpoint("http://endpoint.two");
List<LBSolrClient.Endpoint> endpointList = List.of(ep1, ep2);

var httpClientBuilder =
var httpSolrClientBuilder =
new MockHttpSolrClientBuilder().withConnectionTimeout(10, TimeUnit.SECONDS);

try (LBHttp2SolrClient<MockHttpSolrClientBuilder> 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<CompletableFuture<LBSolrClient.Rsp>> responses = new ArrayList<>();
Expand Down

0 comments on commit 99282aa

Please sign in to comment.