You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/10/01 07:36:26 UTC

[lucene-solr] 06/06: @880 More test work.

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit e769d65a4f29fdba307e25689ae1338a040255af
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Thu Oct 1 02:35:37 2020 -0500

    @880 More test work.
---
 .../cloud/api/collections/DeleteCollectionCmd.java |   17 +-
 .../handler/component/HttpShardHandlerFactory.java |   36 +-
 .../java/org/apache/solr/schema/IndexSchema.java   |    8 +-
 .../solr/cloud/TestQueryingOnDownCollection.java   |   34 +-
 .../TestCollectionsAPIViaSolrCloudCluster.java     |    3 +-
 .../org/apache/solr/schema/BadIndexSchemaTest.java |    1 -
 .../org/apache/solr/search/QueryEqualityTest.java  |    2 +
 .../client/solrj/impl/AsyncLBHttpSolrClient.java   | 1067 --------------------
 .../solr/client/solrj/impl/LBHttp2SolrClient.java  |   22 +-
 .../solr/client/solrj/impl/LBSolrClient.java       |   10 +-
 .../solr/common/util/SolrQueuedThreadPool.java     |    2 +-
 .../src/java/org/apache/solr/SolrTestCase.java     |    8 +-
 12 files changed, 71 insertions(+), 1139 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteCollectionCmd.java
index 59136c3..c851aae 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteCollectionCmd.java
@@ -44,6 +44,7 @@ import static org.apache.solr.common.params.CollectionAdminParams.COLOCATED_WITH
 import static org.apache.solr.common.params.CollectionAdminParams.FOLLOW_ALIASES;
 import static org.apache.solr.common.params.CollectionAdminParams.WITH_COLLECTION;
 import static org.apache.solr.common.params.CollectionParams.CollectionAction.DELETE;
+import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
 import static org.apache.solr.common.params.CommonParams.NAME;
 import java.lang.invoke.MethodHandles;
 import java.util.ArrayList;
@@ -126,15 +127,19 @@ public class DeleteCollectionCmd implements OverseerCollectionMessageHandler.Cmd
       params.set(CoreAdminParams.DELETE_METRICS_HISTORY, deleteHistory);
 
 
-      // nocommit
-      //String asyncId = message.getStr(ASYNC);
+
+      String asyncId = message.getStr(ASYNC);
+
+      if (asyncId != null) {
+        skipFinalStateWork = true;
+      }
 
       Set<String> okayExceptions = new HashSet<>(1);
       okayExceptions.add(NonExistentCoreException.class.getName());
       ZkNodeProps internalMsg = message.plus(NAME, collection);
 
       @SuppressWarnings({"unchecked"})
-      List<Replica> failedReplicas = ocmh.collectionCmd(internalMsg, params, results, null, null, okayExceptions);
+      List<Replica> failedReplicas = ocmh.collectionCmd(internalMsg, params, results, null, asyncId, okayExceptions);
 
       if (failedReplicas == null) {
         skipFinalStateWork = true;
@@ -142,6 +147,12 @@ public class DeleteCollectionCmd implements OverseerCollectionMessageHandler.Cmd
         throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Could not find collection");
       }
 
+      if (failedReplicas.size() > 0) {
+        skipFinalStateWork = true;
+
+        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Could not fully delete collection");
+      }
+
     } finally {
       if (!skipFinalStateWork) {
         log.info("Send DELETE operation to Overseer collection={}", collection);
diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
index 23f5f26..cec2ebe 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
@@ -16,46 +16,21 @@
  */
 package org.apache.solr.handler.component;
 
-import java.lang.invoke.MethodHandles;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.SynchronousQueue;
-import java.util.stream.Collectors;
-
 import com.google.common.annotations.VisibleForTesting;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.AsyncLBHttpSolrClient;
 import org.apache.solr.client.solrj.impl.Http2SolrClient;
-import org.apache.solr.client.solrj.impl.HttpClientUtil;
 import org.apache.solr.client.solrj.impl.LBHttp2SolrClient;
-import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
 import org.apache.solr.client.solrj.impl.LBSolrClient;
 import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.client.solrj.routing.AffinityReplicaListTransformerFactory;
 import org.apache.solr.client.solrj.routing.ReplicaListTransformer;
 import org.apache.solr.client.solrj.routing.ReplicaListTransformerFactory;
 import org.apache.solr.client.solrj.routing.RequestReplicaListTransformerGenerator;
-import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.cloud.ZkController;
-import org.apache.solr.common.ParWork;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.cloud.ClusterState;
 import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.ShardParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.IOUtils;
@@ -76,6 +51,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.solr.util.stats.InstrumentedHttpRequestExecutor.KNOWN_METRIC_NAME_STRATEGIES;
+import java.lang.invoke.MethodHandles;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.stream.Collectors;
 
 
 public class HttpShardHandlerFactory extends ShardHandlerFactory implements org.apache.solr.util.plugin.PluginInfoInitialized, SolrMetricProducer {
diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
index 645bde1..62d2110 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -659,15 +659,15 @@ public class IndexSchema {
 
       //                      /schema/defaultSearchField/text()
 
-      node = (TinyElementImpl) defaultSearchFieldExp.evaluate(document, XPathConstants.NODE);
-      if (node != null) {
+      TinyTextualElement.TinyTextualElementText node2 = (TinyTextualElement.TinyTextualElementText) defaultSearchFieldExp.evaluate(document, XPathConstants.NODE);
+      if (node2 != null) {
         throw new SolrException(ErrorCode.SERVER_ERROR, "Setting defaultSearchField in schema not supported since Solr 7");
       }
 
       //                      /schema/solrQueryParser/@defaultOperator
 
-      node = (TinyElementImpl) solrQueryParserDefaultOpExp.evaluate(document, XPathConstants.NODE);
-      if (node != null) {
+      node2 = (TinyTextualElement.TinyTextualElementText) solrQueryParserDefaultOpExp.evaluate(document, XPathConstants.NODE);
+      if (node2 != null) {
         throw new SolrException(ErrorCode.SERVER_ERROR, "Setting default operator in schema (solrQueryParser/@defaultOperator) not supported");
       }
 
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestQueryingOnDownCollection.java b/solr/core/src/test/org/apache/solr/cloud/TestQueryingOnDownCollection.java
index 461f1fe..348a608 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestQueryingOnDownCollection.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestQueryingOnDownCollection.java
@@ -83,33 +83,25 @@ public class TestQueryingOnDownCollection extends SolrCloudTestCase {
     // assert all nodes as active
     assertEquals(3, cluster.getSolrClient().getClusterStateProvider().getLiveNodes().size());
 
-    SolrClient client = cluster.getJettySolrRunner(0).newClient();
+    try (SolrClient client = cluster.getJettySolrRunner(0).newClient()) {
 
-    SolrRequest req = new QueryRequest(new SolrQuery("*:*").setRows(0)).setBasicAuthCredentials(USERNAME, PASSWORD);
+      SolrRequest req = new QueryRequest(new SolrQuery("*:*").setRows(0)).setBasicAuthCredentials(USERNAME, PASSWORD);
 
-    // Without the SOLR-13793 fix, this causes requests to "down collection" to pile up (until the nodes run out 
-    // of serviceable threads and they crash, even for other collections hosted on the nodes).
-    SolrException error = expectThrows(SolrException.class,
-        "Request should fail after trying all replica nodes once",
-        () -> client.request(req, COLLECTION_NAME)
-    );
+      // Without the SOLR-13793 fix, this causes requests to "down collection" to pile up (until the nodes run out
+      // of serviceable threads and they crash, even for other collections hosted on the nodes).
+      SolrException error = expectThrows(SolrException.class, "Request should fail after trying all replica nodes once", () -> client.request(req, COLLECTION_NAME));
 
-    client.close();
-
-    assertEquals(404, error.code());
+      assertEquals(404, error.code());
+    }
 
     // run same set of tests on v2 client which uses V2HttpCall
-    Http2SolrClient v2Client = new Http2SolrClient.Builder(cluster.getJettySolrRunner(0).getBaseUrl().toString())
-        .build();
-
-    error = expectThrows(SolrException.class,
-        "Request should fail after trying all replica nodes once",
-        () -> v2Client.request(req, COLLECTION_NAME)
-    );
+    try (Http2SolrClient v2Client = new Http2SolrClient.Builder(cluster.getJettySolrRunner(0).getBaseUrl())
+        .build()) {
+      SolrRequest req = new QueryRequest(new SolrQuery("*:*").setRows(0)).setBasicAuthCredentials(USERNAME, PASSWORD);
+      SolrException error = expectThrows(SolrException.class, "Request should fail after trying all replica nodes once", () -> v2Client.request(req, COLLECTION_NAME));
 
-    v2Client.close();
-
-    assertEquals(404, error.code());
+      assertEquals(404, error.code());
+    }
   }
 
   private void downAllReplicas() throws Exception {
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java
index f9c3de6..0123e97 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java
@@ -112,11 +112,12 @@ public class TestCollectionsAPIViaSolrCloudCluster extends SolrCloudTestCase {
       CollectionAdminRequest.deleteCollection("foobar432").process(cluster.getSolrClient());
       fail("expected exception");
     } catch (Exception e) {
-      assertTrue(e.getMessage().contains("Could not find collection"));
+      assertTrue(e.getMessage(), e.getMessage().contains("Could not find collection"));
     }
   }
 
   @Test
+  @Nightly // slow
   public void testCollectionCreateSearchDelete() throws Exception {
 
     final CloudHttp2SolrClient client = cluster.getSolrClient();
diff --git a/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java b/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
index d530479..3569cce 100644
--- a/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
@@ -19,7 +19,6 @@ package org.apache.solr.schema;
 import org.apache.solr.core.AbstractBadConfigTestBase;
 import org.junit.Ignore;
 
-@Ignore // nocommit debug
 public class BadIndexSchemaTest extends AbstractBadConfigTestBase {
 
   private void doTest(final String schema, final String errString) 
diff --git a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
index 00108d7..5f8f683 100644
--- a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
+++ b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
@@ -24,6 +24,7 @@ import java.util.Set;
 import junit.framework.AssertionFailedError;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryUtils;
+import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrRequestInfo;
@@ -44,6 +45,7 @@ import org.junit.BeforeClass;
  * @see QParserPlugin#standardPlugins
  * @see QueryUtils
  **/
+@LuceneTestCase.Nightly // 10 seconds+ to run all these, don't need to do that every time for non Nightly
 public class QueryEqualityTest extends SolrTestCaseJ4 {
 
   @BeforeClass
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/AsyncLBHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/AsyncLBHttpSolrClient.java
deleted file mode 100644
index 430d4a5..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/AsyncLBHttpSolrClient.java
+++ /dev/null
@@ -1,1067 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.impl;
-
-import java.io.IOException;
-import java.lang.invoke.MethodHandles;
-import java.lang.ref.WeakReference;
-import java.net.ConnectException;
-import java.net.MalformedURLException;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.solr.client.solrj.ResponseParser;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.request.IsUpdateRequest;
-import org.apache.solr.client.solrj.request.QueryRequest;
-import org.apache.solr.client.solrj.request.RequestWriter;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.ParWork;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.QoSParams;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SolrNamedThreadFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-
-import static org.apache.solr.common.params.CommonParams.ADMIN_PATHS;
-
-/**
- * LBHttpSolrClient or "LoadBalanced HttpSolrClient" is a load balancing wrapper around
- * {@link HttpSolrClient}. This is useful when you
- * have multiple Solr servers and the requests need to be Load Balanced among them.
- *
- * Do <b>NOT</b> use this class for indexing in master/slave scenarios since documents must be sent to the
- * correct master; no inter-node routing is done.
- *
- * In SolrCloud (leader/replica) scenarios, it is usually better to use
- * {@link CloudSolrClient}, but this class may be used
- * for updates because the server will forward them to the appropriate leader.
- *
- * <p>
- * It offers automatic failover when a server goes down and it detects when the server comes back up.
- * <p>
- * Load balancing is done using a simple round-robin on the list of servers.
- * <p>
- * If a request to a server fails by an IOException due to a connection timeout or read timeout then the host is taken
- * off the list of live servers and moved to a 'dead server list' and the request is resent to the next live server.
- * This process is continued till it tries all the live servers. If at least one server is alive, the request succeeds,
- * and if not it fails.
- * <blockquote><pre>
- * SolrClient lbHttpSolrClient = new LBHttpSolrClient("http://host1:8080/solr/", "http://host2:8080/solr", "http://host2:8080/solr");
- * //or if you wish to pass the HttpClient do as follows
- * httpClient httpClient = new HttpClient();
- * SolrClient lbHttpSolrClient = new LBHttpSolrClient(httpClient, "http://host1:8080/solr/", "http://host2:8080/solr", "http://host2:8080/solr");
- * </pre></blockquote>
- * This detects if a dead server comes alive automatically. The check is done in fixed intervals in a dedicated thread.
- * This interval can be set using {@link #setAliveCheckInterval} , the default is set to one minute.
- * <p>
- * <b>When to use this?</b><br> This can be used as a software load balancer when you do not wish to setup an external
- * load balancer. Alternatives to this code are to use
- * a dedicated hardware load balancer or using Apache httpd with mod_proxy_balancer as a load balancer. See <a
- * href="http://en.wikipedia.org/wiki/Load_balancing_(computing)">Load balancing on Wikipedia</a>
- *
- * @since solr 1.4
- */
-public class AsyncLBHttpSolrClient extends SolrClient {
-
-  private static final Logger log = LoggerFactory
-      .getLogger(MethodHandles.lookup().lookupClass());
-
-  private static Set<Integer> RETRY_CODES = new HashSet<>(4);
-
-  static {
-    RETRY_CODES.add(404);
-    RETRY_CODES.add(403);
-    RETRY_CODES.add(503);
-    RETRY_CODES.add(500);
-  }
-
-  // keys to the maps are currently of the form "http://localhost:8983/solr"
-  // which should be equivalent to HttpSolrServer.getBaseURL()
-  private final Map<String, ServerWrapper> aliveServers = new LinkedHashMap<>();
-  // access to aliveServers should be synchronized on itself
-  
-  protected final Map<String, ServerWrapper> zombieServers = new ConcurrentHashMap<>();
-
-  // changes to aliveServers are reflected in this array, no need to synchronize
-  private volatile ServerWrapper[] aliveServerList = new ServerWrapper[0];
-  
-  //private Set<SolrClient> clients = new ConcurrentHashMap<>().newKeySet();
-
-  private ScheduledExecutorService aliveCheckExecutor;
-
-  private final Http2SolrClient httpClient;
-  private final boolean clientIsInternal;
-  //private Http2SolrClient.Builder httpSolrClientBuilder;
-  private final AtomicInteger counter = new AtomicInteger(-1);
-
-  //private static final SolrQuery solrQuery = new SolrQuery("*:*");
-  private volatile ResponseParser parser;
-  private volatile RequestWriter requestWriter;
-
-  private Set<String> queryParams = new HashSet<>();
-  private Integer connectionTimeout;
-
-  private Integer soTimeout;
-
-  private Builder builder;
-
-  private Http2SolrClient solrClient;
-
-  static {
-
-  }
-
-  protected static class ServerWrapper {
-
-    private final Http2SolrClient solrClient;
-
-    // "standard" servers are used by default.  They normally live in the alive list
-    // and move to the zombie list when unavailable.  When they become available again,
-    // they move back to the alive list.
-    boolean standard = true;
-
-    int failedPings = 0;
-
-    private String baseUrl;
-
-    public ServerWrapper(Http2SolrClient solrClient, String baseUrl) {
-      this.solrClient = solrClient;
-      this.baseUrl = baseUrl;
-    }
-
-    @Override
-    public String toString() {
-      return baseUrl;
-    }
-
-    public String getKey() {
-      return baseUrl;
-    }
-
-    @Override
-    public int hashCode() {
-      return this.getKey().hashCode();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-      if (this == obj) return true;
-      if (!(obj instanceof ServerWrapper)) return false;
-      return this.getKey().equals(((ServerWrapper)obj).getKey());
-    }
-
-    public NamedList<Object> request(SolrRequest request, String collection) throws SolrServerException, IOException {
-      request.setBasePath(baseUrl);
-      return solrClient.request(request, collection);
-    }
-  }
-
-  public static class Req {
-    protected SolrRequest request;
-    protected List<String> servers;
-    protected int numDeadServersToTry;
-    private final Integer numServersToTry;
-
-    public Req(SolrRequest request, List<String> servers) {
-      this(request, servers, null);
-    }
-
-    public Req(SolrRequest request, List<String> servers, Integer numServersToTry) {
-      this.request = request;
-      this.servers = servers;
-      this.numDeadServersToTry = servers.size();
-      this.numServersToTry = numServersToTry;
-    }
-
-    public SolrRequest getRequest() {
-      return request;
-    }
-    public List<String> getServers() {
-      return servers;
-    }
-
-    /** @return the number of dead servers to try if there are no live servers left */
-    public int getNumDeadServersToTry() {
-      return numDeadServersToTry;
-    }
-
-    /** @param numDeadServersToTry The number of dead servers to try if there are no live servers left.
-     * Defaults to the number of servers in this request. */
-    public void setNumDeadServersToTry(int numDeadServersToTry) {
-      this.numDeadServersToTry = numDeadServersToTry;
-    }
-
-    public Integer getNumServersToTry() {
-      return numServersToTry;
-    }
-  }
-
-  public static class Rsp {
-    protected String server;
-    protected NamedList<Object> rsp;
-    public NamedList<Object> areq;
-
-    /** The response from the server */
-    public NamedList<Object> getResponse() {
-      return rsp;
-    }
-
-    /** The server that returned the response */
-    public String getServer() {
-      return server;
-    }
-  }
-
-  /**
-   * The provided httpClient should use a multi-threaded connection manager
-   *
-   * @deprecated use {@link AsyncLBHttpSolrClient#AsyncLBHttpSolrClient(Builder, Http2SolrClient)} instead, as it is a more extension/subclassing-friendly alternative
-   */
-  @Deprecated
-  protected AsyncLBHttpSolrClient(Http2SolrClient.Builder httpSolrClientBuilder,
-      Http2SolrClient httpClient, Http2SolrClient solrClient, String... solrServerUrl) {
-    this(httpClient, null, solrClient, solrServerUrl);
-  }
-
-  /**
-   * The provided httpClient should use a multi-threaded connection manager
-   *
-   * @deprecated use {@link AsyncLBHttpSolrClient#AsyncLBHttpSolrClient(Builder, Http2SolrClient)} instead, as it is a more extension/subclassing-friendly alternative
-   */
-  @Deprecated
-  protected AsyncLBHttpSolrClient(Http2SolrClient httpClient, ResponseParser parser, Http2SolrClient solrClient, String... solrServerUrl) {
-    this(new AsyncLBHttpSolrClient.Builder()
-        .withBaseSolrUrls(solrServerUrl)
-        .withResponseParser(parser)
-        .withHttp2SolrClient(httpClient), solrClient);
-  }
-
-  protected AsyncLBHttpSolrClient(Builder builder, Http2SolrClient solrClient) {
-    assert solrClient != null;
-    this.solrClient = solrClient;
-    this.clientIsInternal = builder.httpClient == null;
-    //this.httpSolrClientBuilder = builder.httpSolrClientBuilder;
-    this.httpClient = builder.httpClient == null ? new Http2SolrClient.Builder("").build() : builder.solrClient;
-    this.connectionTimeout = builder.connectionTimeoutMillis;
-    this.soTimeout = builder.socketTimeoutMillis;    
-    this.parser = builder.responseParser;
-
-    if (! builder.baseSolrUrls.isEmpty()) {
-      for (String s : builder.baseSolrUrls) {
-        ServerWrapper wrapper = new ServerWrapper(makeSolrClient(s), s);
-        aliveServers.put(wrapper.getKey(), wrapper);
-      }
-    }
-    updateAliveList();
-    this.builder = builder;
-  }
-
-//  private HttpClient constructClient(String[] solrServerUrl) {
-//    ModifiableSolrParams params = new ModifiableSolrParams();
-//    if (solrServerUrl != null && solrServerUrl.length > 1) {
-//      // we prefer retrying another server
-//      params.set(HttpClientUtil.PROP_USE_RETRY, false);
-//    } else {
-//      params.set(HttpClientUtil.PROP_USE_RETRY, true);
-//    }
-//    return HttpClientUtil.createClient(params);
-//  }
-
-  public Set<String> getQueryParams() {
-    return queryParams;
-  }
-
-  /**
-   * Expert Method.
-   * @param queryParams set of param keys to only send via the query string
-   */
-  public void setQueryParams(Set<String> queryParams) {
-    this.queryParams = queryParams;
-  }
-  public void addQueryParams(String queryOnlyParam) {
-    this.queryParams.add(queryOnlyParam) ;
-  }
-
-  public static String normalize(String server) {
-    if (server.endsWith("/"))
-      server = server.substring(0, server.length() - 1);
-    return server;
-  }
-
-  protected Http2SolrClient makeSolrClient(String server) {
-//    HttpSolrClient client;
-//    if (httpSolrClientBuilder != null) {
-//      synchronized (this) {
-//        httpSolrClientBuilder
-//            .withBaseSolrUrl(server)
-//            .withHttpClient(httpClient);
-//        if (connectionTimeout != null) {
-//          httpSolrClientBuilder.withConnectionTimeout(connectionTimeout);
-//        }
-//        if (soTimeout != null) {
-//          httpSolrClientBuilder.withSocketTimeout(soTimeout);
-//        }
-//        client = httpSolrClientBuilder.build();
-//      }
-//    } else {
-//      final HttpSolrClient.Builder clientBuilder = new HttpSolrClient.Builder(server)
-//          .withHttpClient(httpClient)
-//          .withResponseParser(parser);
-//      if (connectionTimeout != null) {
-//        clientBuilder.withConnectionTimeout(connectionTimeout);
-//      }
-//      if (soTimeout != null) {
-//        clientBuilder.withSocketTimeout(soTimeout);
-//      }
-//      client = clientBuilder.build();
-//    }
-//    if (requestWriter != null) {
-//      client.setRequestWriter(requestWriter);
-//    }
-//    if (queryParams != null) {
-//      client.setQueryParams(queryParams);
-//    }
-    
-    return solrClient; 
-    
-  //  return solrClient;
-  }
-  
-  static class SolrClientWrapper {
-    private Http2SolrClient solrClient;
-
-    SolrClientWrapper(Http2SolrClient solrClient) {
-      this.solrClient = solrClient;
-    }
-  }
-
-  /**
-   * Tries to query a live server from the list provided in Req. Servers in the dead pool are skipped.
-   * If a request fails due to an IOException, the server is moved to the dead pool for a certain period of
-   * time, or until a test request on that server succeeds.
-   *
-   * Servers are queried in the exact order given (except servers currently in the dead pool are skipped).
-   * If no live servers from the provided list remain to be tried, a number of previously skipped dead servers will be tried.
-   * Req.getNumDeadServersToTry() controls how many dead servers will be tried.
-   *
-   * If no live servers are found a SolrServerException is thrown.
-   *
-   * @param req contains both the request as well as the list of servers to query
-   *
-   * @return the result of the request
-   *
-   * @throws IOException If there is a low-level I/O error.
-   */
-  public Rsp request(Req req) throws SolrServerException, IOException {
-    Rsp rsp = new Rsp();
-    Exception ex = null;
-    boolean isNonRetryable = req.request instanceof IsUpdateRequest || ADMIN_PATHS.contains(req.request.getPath());
-    List<ServerWrapper> skipped = null;
-
-    final Integer numServersToTry = req.getNumServersToTry();
-    int numServersTried = 0;
-
-    boolean timeAllowedExceeded = false;
-    long timeAllowedNano = getTimeAllowedInNanos(req.getRequest());
-    long timeOutTime = System.nanoTime() + timeAllowedNano;
-    for (String serverStr : req.getServers()) {
-      if (timeAllowedExceeded = isTimeExceeded(timeAllowedNano, timeOutTime)) {
-        break;
-      }
-      
-      serverStr = normalize(serverStr);
-      // if the server is currently a zombie, just skip to the next one
-      ServerWrapper wrapper = zombieServers.get(serverStr);
-      if (wrapper != null) {
-        // System.out.println("ZOMBIE SERVER QUERIED: " + serverStr);
-        final int numDeadServersToTry = req.getNumDeadServersToTry();
-        if (numDeadServersToTry > 0) {
-          if (skipped == null) {
-            skipped = new ArrayList<>(numDeadServersToTry);
-            skipped.add(wrapper);
-          }
-          else if (skipped.size() < numDeadServersToTry) {
-            skipped.add(wrapper);
-          }
-        }
-        continue;
-      }
-      try {
-        MDC.put("LBHttpSolrClient.url", serverStr);
-
-        if (numServersToTry != null && numServersTried > numServersToTry.intValue()) {
-          break;
-        }
-
-        Http2SolrClient client = makeSolrClient(serverStr);
-        req.request.setBasePath(serverStr);
-
-        ++numServersTried;
-        ex = doRequest(client, req, rsp, isNonRetryable, false, null);
-        if (ex == null) {
-          return rsp; // SUCCESS
-        }
-      } finally {
-        MDC.remove("LBHttpSolrClient.url");
-      }
-    }
-
-    // try the servers we previously skipped
-    if (skipped != null) {
-      for (ServerWrapper wrapper : skipped) {
-        if (timeAllowedExceeded = isTimeExceeded(timeAllowedNano, timeOutTime)) {
-          break;
-        }
-
-        if (numServersToTry != null && numServersTried > numServersToTry.intValue()) {
-          break;
-        }
-
-        try {
-          MDC.put("LBHttpSolrClient.url", wrapper.baseUrl);
-          ++numServersTried;
-          req.request.setBasePath(wrapper.baseUrl);
-          ex = doRequest(wrapper.solrClient, req, rsp, isNonRetryable, true, wrapper.getKey());
-          if (ex == null) {
-            return rsp; // SUCCESS
-          }
-        } finally {
-          MDC.remove("LBHttpSolrClient.url");
-        }
-      }
-    }
-
-
-    final String solrServerExceptionMessage;
-    if (timeAllowedExceeded) {
-      solrServerExceptionMessage = "Time allowed to handle this request exceeded";
-    } else {
-      if (numServersToTry != null && numServersTried > numServersToTry.intValue()) {
-        solrServerExceptionMessage = "No live SolrServers available to handle this request:"
-            + " numServersTried="+numServersTried
-            + " numServersToTry="+numServersToTry.intValue();
-      } else {
-        solrServerExceptionMessage = "No live SolrServers available to handle this request";
-      }
-    }
-    if (ex == null) {
-      throw new SolrServerException(solrServerExceptionMessage);
-    } else {
-      throw new SolrServerException(solrServerExceptionMessage+":" + zombieServers.keySet(), ex);
-    }
-
-  }
-
-  protected Exception addZombie(Http2SolrClient server, String url, Exception e) {
-    log.warn("adding zombie server {} due to exception", url, e);
-    ServerWrapper wrapper;
-
-    wrapper = new ServerWrapper(server, url);
-    wrapper.standard = false;
-    zombieServers.put(wrapper.getKey(), wrapper);
-    startAliveCheckExecutor();
-    return e;
-  }  
-
-  protected Exception doRequest(Http2SolrClient client, Req req, Rsp rsp, boolean isNonRetryable,
-      boolean isZombie, String zombieKey) throws SolrServerException, IOException {
-    Exception ex = null;
-    try {
-      assert client != null;
-      assert req != null;
-      assert rsp != null;
-      rsp.server = req.request.getBasePath();
-     // rsp.rsp =
-      rsp.areq = client.request(req.getRequest());
-
-    } catch(SolrException e) {
-      // we retry on 404 or 403 or 503 or 500
-      // unless it's an update - then we only retry on connect exception
-      if (!isNonRetryable && RETRY_CODES.contains(e.code())) {
-        ex = (!isZombie) ? addZombie(client, rsp.server, e) : e;
-      } else {
-        // Server is alive but the request was likely malformed or invalid
-        if (isZombie) {
-          zombieServers.remove(zombieKey);
-        }
-        throw e;
-      }
-    } catch (SocketException e) {
-      if (!isNonRetryable || e instanceof ConnectException) {
-        ex = (!isZombie) ? addZombie(client, rsp.server, e) : e;
-      } else {
-        throw e;
-      }
-    } catch (SocketTimeoutException e) {
-      if (!isNonRetryable) {
-        ex = (!isZombie) ? addZombie(client, rsp.server, e) : e;
-      } else {
-        throw e;
-      }
-    } catch (SolrServerException e) {
-      Throwable rootCause = e.getRootCause();
-      if (!isNonRetryable && rootCause instanceof IOException) {
-        ex = (!isZombie) ? addZombie(client, rsp.server, e) : e;
-      } else if (isNonRetryable && rootCause instanceof ConnectException) {
-        ex = (!isZombie) ? addZombie(client, rsp.server, e) : e;
-      } else {
-        throw e;
-      }
-    } catch (Exception e) {
-      ParWork.propagateInterrupt(e);
-      throw new SolrServerException(e);
-    }
-
-    return ex;
-  }
-
-  private void updateAliveList() {
-    synchronized (aliveServers) {
-      aliveServerList = aliveServers.values().toArray(new ServerWrapper[aliveServers.size()]);
-    }
-  }
-
-  private ServerWrapper removeFromAlive(String key) {
-    synchronized (aliveServers) {
-      ServerWrapper wrapper = aliveServers.remove(key);
-      if (wrapper != null)
-        updateAliveList();
-      return wrapper;
-    }
-  }
-
-  private void addToAlive(ServerWrapper wrapper) {
-    synchronized (aliveServers) {
-      ServerWrapper prev = aliveServers.put(wrapper.getKey(), wrapper);
-      // TODO: warn if there was a previous entry?
-      updateAliveList();
-    }
-  }
-
-  public void addSolrServer(String server) throws MalformedURLException {
-    Http2SolrClient client = makeSolrClient(server);
-    addToAlive(new ServerWrapper(client, server));
-  }
-
-  public String removeSolrServer(String server) {
-    try {
-      server = new URL(server).toExternalForm();
-    } catch (MalformedURLException e) {
-      throw new RuntimeException(e);
-    }
-    if (server.endsWith("/")) {
-      server = server.substring(0, server.length() - 1);
-    }
-
-    // there is a small race condition here - if the server is in the process of being moved between
-    // lists, we could fail to remove it.
-    removeFromAlive(server);
-    zombieServers.remove(server);
-    return null;
-  }
-
-  /**
-   * @deprecated since 7.0  Use {@link Builder} methods instead. 
-   */
-  @Deprecated
-  public void setConnectionTimeout(int timeout) {
-    this.connectionTimeout = timeout;
-    synchronized (aliveServers) {
-      Iterator<ServerWrapper> wrappersIt = aliveServers.values().iterator();
-      while (wrappersIt.hasNext()) {
-       // wrappersIt.next().client.setConnectionTimeout(timeout);
-      }
-    }
-    Iterator<ServerWrapper> wrappersIt = zombieServers.values().iterator();
-    while (wrappersIt.hasNext()) {
-      //wrappersIt.next().client.setConnectionTimeout(timeout);
-    }
-  }
-
-  /**
-   * set soTimeout (read timeout) on the underlying HttpConnectionManager. This is desirable for queries, but probably
-   * not for indexing.
-   *
-   * @deprecated since 7.0  Use {@link Builder} methods instead. 
-   */
-  @Deprecated
-  public void setSoTimeout(int timeout) {
-    this.soTimeout = timeout;
-    synchronized (aliveServers) {
-      Iterator<ServerWrapper> wrappersIt = aliveServers.values().iterator();
-      while (wrappersIt.hasNext()) {
-        //wrappersIt.next().client.setSoTimeout(timeout);
-      }
-    }
-    Iterator<ServerWrapper> wrappersIt = zombieServers.values().iterator();
-    while (wrappersIt.hasNext()) {
-      //wrappersIt.next().client.setSoTimeout(timeout);
-    }
-  }
-
-  @Override
-  public void close() {
-    if (aliveCheckExecutor != null) {
-      aliveCheckExecutor.shutdownNow();
-    }
-    if(clientIsInternal) {
-      IOUtils.closeQuietly(httpClient);
-    }
-    
-//    for (SolrClient client : clients) {
-//      try {
-//        client.close();
-//      } catch (IOException e) {
-//        throw new RuntimeException(e);
-//      }
-//    }
-//    if (zombieServers != null) {
-//      synchronized (zombieServers) {
-//
-//        for (S zombieServer : zombieServers.values()) {
-//          try {
-//            zombieServer.client.close();
-//          } catch (IOException e) {
-//            throw new RuntimeException(e);
-//          }
-//        }
-//      }
-//    }
-//    if (aliveServers != null) {
-//      synchronized (aliveServers) {
-//
-//        for (ServerWrapper aliveServer : aliveServers.values()) {
-//          try {
-//            aliveServer.client.close();
-//          } catch (IOException e) {
-//            throw new RuntimeException(e);
-//          }
-//        }
-//      }
-//    }
-  }
-
-  /**
-   * Tries to query a live server. A SolrServerException is thrown if all servers are dead.
-   * If the request failed due to IOException then the live server is moved to dead pool and the request is
-   * retried on another live server.  After live servers are exhausted, any servers previously marked as dead
-   * will be tried before failing the request.
-   *
-   * @param request the SolrRequest.
-   *
-   * @return response
-   *
-   * @throws IOException If there is a low-level I/O error.
-   */
-  @Override
-  public NamedList<Object> request(final SolrRequest request, String collection)
-          throws SolrServerException, IOException {
-    return request(request, collection, null);
-  }
-
-  public NamedList<Object> request(final SolrRequest request, String collection,
-      final Integer numServersToTry) throws SolrServerException, IOException {
-    Exception ex = null;
-    ServerWrapper[] serverList = aliveServerList;
-    
-    final int maxTries = (numServersToTry == null ? serverList.length : numServersToTry.intValue());
-    int numServersTried = 0;
-    Map<String,ServerWrapper> justFailed = null;
-
-    boolean timeAllowedExceeded = false;
-    long timeAllowedNano = getTimeAllowedInNanos(request);
-    long timeOutTime = System.nanoTime() + timeAllowedNano;
-    for (int attempts=0; attempts<maxTries; attempts++) {
-      if (timeAllowedExceeded = isTimeExceeded(timeAllowedNano, timeOutTime)) {
-        break;
-      }
-      
-      int count = counter.incrementAndGet() & Integer.MAX_VALUE;
-      ServerWrapper wrapper = serverList[count % serverList.length];
-
-      try {
-        ++numServersTried;
-        return wrapper.request(request, collection);
-      } catch (SolrException e) {
-        // Server is alive but the request was malformed or invalid
-        throw e;
-      } catch (SolrServerException e) {
-        if (e.getRootCause() instanceof IOException) {
-          ex = e;
-          moveAliveToDead(wrapper);
-          if (justFailed == null) justFailed = new HashMap<>();
-          justFailed.put(wrapper.getKey(), wrapper);
-        } else {
-          throw e;
-        }
-      } catch (Exception e) {
-        ParWork.propagateInterrupt(e);
-        throw new SolrServerException(e);
-      }
-    }
-
-    // try other standard servers that we didn't try just now
-    for (ServerWrapper wrapper : zombieServers.values()) {
-      if (timeAllowedExceeded = isTimeExceeded(timeAllowedNano, timeOutTime)) {
-        break;
-      }
-      
-      if (wrapper.standard==false || justFailed!=null && justFailed.containsKey(wrapper.getKey())) continue;
-      try {
-        ++numServersTried;
-        NamedList<Object> rsp = wrapper.request(request, collection);
-        // remove from zombie list *before* adding to alive to avoid a race that could lose a server
-        zombieServers.remove(wrapper.getKey());
-        addToAlive(wrapper);
-        return rsp;
-      } catch (SolrException e) {
-        // Server is alive but the request was malformed or invalid
-        throw e;
-      } catch (SolrServerException e) {
-        if (e.getRootCause() instanceof IOException) {
-          ex = e;
-          // still dead
-        } else {
-          throw e;
-        }
-      } catch (Exception e) {
-        ParWork.propagateInterrupt(e);
-        throw new SolrServerException(e);
-      }
-    }
-
-
-    final String solrServerExceptionMessage;
-    if (timeAllowedExceeded) {
-      solrServerExceptionMessage = "Time allowed to handle this request exceeded";
-    } else {
-      if (numServersToTry != null && numServersTried > numServersToTry.intValue()) {
-        solrServerExceptionMessage = "No live SolrServers available to handle this request:"
-            + " numServersTried="+numServersTried
-            + " numServersToTry="+numServersToTry.intValue();
-      } else {
-        solrServerExceptionMessage = "No live SolrServers available to handle this request";
-      }
-    }
-    if (ex == null) {
-      throw new SolrServerException(solrServerExceptionMessage);
-    } else {
-      throw new SolrServerException(solrServerExceptionMessage, ex);
-    }
-  }
-  
-  /**
-   * @return time allowed in nanos, returns -1 if no time_allowed is specified.
-   */
-  private long getTimeAllowedInNanos(final SolrRequest req) {
-    SolrParams reqParams = req.getParams();
-    return reqParams == null ? -1 : 
-      TimeUnit.NANOSECONDS.convert(reqParams.getInt(CommonParams.TIME_ALLOWED, -1), TimeUnit.MILLISECONDS);
-  }
-  
-  private boolean isTimeExceeded(long timeAllowedNano, long timeOutTime) {
-    return timeAllowedNano > 0 && System.nanoTime() > timeOutTime;
-  }
-  
-  /**
-   * Takes up one dead server and check for aliveness. The check is done in a roundrobin. Each server is checked for
-   * aliveness once in 'x' millis where x is decided by the setAliveCheckinterval() or it is defaulted to 1 minute
-   *
-   * @param zombieServer a server in the dead pool
-   */
-  private void checkAZombieServer(ServerWrapper zombieServer) {
-    try {
-      SolrQuery solrQuery = new SolrQuery("*:*");
-      solrQuery.setRows(0);
-      /**
-       * Default sort (if we don't supply a sort) is by score and since
-       * we request 0 rows any sorting and scoring is not necessary.
-       * SolrQuery.DOCID schema-independently specifies a non-scoring sort.
-       * <code>_docid_ asc</code> sort is efficient,
-       * <code>_docid_ desc</code> sort is not, so choose ascending DOCID sort.
-       */
-      solrQuery.setSort(SolrQuery.DOCID, SolrQuery.ORDER.asc);
-      // not a top-level request, we are interested only in the server being sent to i.e. it need not distribute our request to further servers    
-      solrQuery.setDistrib(false);
-      QueryRequest request = new QueryRequest(solrQuery);
-      QueryResponse resp = request.process(zombieServer.solrClient);
-      //QueryResponse resp = zombieServer.solrClient.query(solrQuery);
-      if (resp.getStatus() == 0) {
-        // server has come back up.
-        // make sure to remove from zombies before adding to alive to avoid a race condition
-        // where another thread could mark it down, move it back to zombie, and then we delete
-        // from zombie and lose it forever.
-        ServerWrapper wrapper = zombieServers.remove(zombieServer.getKey());
-        if (wrapper != null) {
-          wrapper.failedPings = 0;
-          if (wrapper.standard) {
-            addToAlive(wrapper);
-          }
-        } else {
-          // something else already moved the server from zombie to alive
-        }
-      }
-    } catch (Exception e) {
-      ParWork.propagateInterrupt(e);
-      //Expected. The server is still down.
-      zombieServer.failedPings++;
-
-      // If the server doesn't belong in the standard set belonging to this load balancer
-      // then simply drop it after a certain number of failed pings.
-      if (!zombieServer.standard && zombieServer.failedPings >= NONSTANDARD_PING_LIMIT) {
-        zombieServers.remove(zombieServer.getKey());
-      }
-    }
-  }
-
-  private void moveAliveToDead(ServerWrapper wrapper) {
-    wrapper = removeFromAlive(wrapper.getKey());
-    if (wrapper == null)
-      return;  // another thread already detected the failure and removed it
-    zombieServers.put(wrapper.getKey(), wrapper);
-    startAliveCheckExecutor();
-  }
-
-  private int interval = CHECK_INTERVAL;
-
-  /**
-   * LBHttpSolrServer keeps pinging the dead servers at fixed interval to find if it is alive. Use this to set that
-   * interval
-   *
-   * @param interval time in milliseconds
-   */
-  public void setAliveCheckInterval(int interval) {
-    if (interval <= 0) {
-      throw new IllegalArgumentException("Alive check interval must be " +
-              "positive, specified value = " + interval);
-    }
-    this.interval = interval;
-  }
-
-  private void startAliveCheckExecutor() {
-    // double-checked locking, but it's OK because we don't *do* anything with aliveCheckExecutor
-    // if it's not null.
-    if (aliveCheckExecutor == null) {
-      synchronized (this) {
-        if (aliveCheckExecutor == null) {
-          aliveCheckExecutor = Executors.newSingleThreadScheduledExecutor(
-              new SolrNamedThreadFactory("aliveCheckExecutor"));
-          aliveCheckExecutor.scheduleAtFixedRate(
-                  getAliveCheckRunner(new WeakReference<>(this)),
-                  this.interval, this.interval, TimeUnit.MILLISECONDS);
-        }
-      }
-    }
-  }
-
-  private static Runnable getAliveCheckRunner(final WeakReference<AsyncLBHttpSolrClient> lbRef) {
-    return () -> {
-      AsyncLBHttpSolrClient lb = lbRef.get();
-      if (lb != null && lb.zombieServers != null) {
-        for (ServerWrapper zombieServer : lb.zombieServers.values()) {
-          lb.checkAZombieServer(zombieServer);
-        }
-      }
-    };
-  }
-
-  /**
-   * Return the HttpClient this instance uses.
-   */
-  public Http2SolrClient getHttpClient() {
-    return httpClient;
-  }
-
-  public ResponseParser getParser() {
-    return parser;
-  }
-
-  /**
-   * Changes the {@link ResponseParser} that will be used for the internal
-   * SolrServer objects.
-   *
-   * @param parser Default Response Parser chosen to parse the response if the parser
-   *               were not specified as part of the request.
-   * @see org.apache.solr.client.solrj.SolrRequest#getResponseParser()
-   */
-  public void setParser(ResponseParser parser) {
-    this.parser = parser;
-  }
-
-  /**
-   * Changes the {@link RequestWriter} that will be used for the internal
-   * SolrServer objects.
-   *
-   * @param requestWriter Default RequestWriter, used to encode requests sent to the server.
-   */
-  public void setRequestWriter(RequestWriter requestWriter) {
-    this.requestWriter = requestWriter;
-  }
-  
-  public RequestWriter getRequestWriter() {
-    return requestWriter;
-  }
-  
-  @Override
-  protected void finalize() throws Throwable {
-    try {
-      if(this.aliveCheckExecutor!=null)
-        this.aliveCheckExecutor.shutdownNow();
-    } finally {
-      super.finalize();
-    }
-  }
-
-  // defaults
-  private static final int CHECK_INTERVAL = 60 * 1000; //1 minute between checks
-  private static final int NONSTANDARD_PING_LIMIT = 5;  // number of times we'll ping dead servers not in the server list
-
-  /**
-   * Constructs {@link AsyncLBHttpSolrClient} instances from provided configuration.
-   */
-  public static class Builder extends SolrClientBuilder<Builder> {
-    protected final List<String> baseSolrUrls;
-    protected Http2SolrClient.Builder httpSolrClientBuilder;
-    protected Map<String,String> headers = new HashMap<>();
-    private Http2SolrClient solrClient;
-
-    public Builder() {
-      this.baseSolrUrls = new ArrayList<>();
-      this.responseParser = new BinaryResponseParser();
-    }
-
-    public Http2SolrClient.Builder getHttpSolrClientBuilder() {
-      return httpSolrClientBuilder;
-    }
-   
-    /**
-     * Provide a Solr endpoint to be used when configuring {@link AsyncLBHttpSolrClient} instances.
-     * 
-     * Method may be called multiple times.  All provided values will be used.
-     * 
-     * Two different paths can be specified as a part of the URL:
-     * 
-     * 1) A path pointing directly at a particular core
-     * <pre>
-     *   SolrClient client = builder.withBaseSolrUrl("http://my-solr-server:8983/solr/core1").build();
-     *   QueryResponse resp = client.query(new SolrQuery("*:*"));
-     * </pre>
-     * Note that when a core is provided in the base URL, queries and other requests can be made without mentioning the
-     * core explicitly.  However, the client can only send requests to that core.
-     * 
-     * 2) The path of the root Solr path ("/solr")
-     * <pre>
-     *   SolrClient client = builder.withBaseSolrUrl("http://my-solr-server:8983/solr").build();
-     *   QueryResponse resp = client.query("core1", new SolrQuery("*:*"));
-     * </pre>
-     * In this case the client is more flexible and can be used to send requests to any cores.  This flexibility though
-     * requires that the core is specified on all requests.
-     */
-    public Builder withBaseSolrUrl(String baseSolrUrl) {
-      this.baseSolrUrls.add(baseSolrUrl);
-      return this;
-    }
- 
-    /**
-     * Provide Solr endpoints to be used when configuring {@link AsyncLBHttpSolrClient} instances.
-     * 
-     * Method may be called multiple times.  All provided values will be used.
-     * 
-     * Two different paths can be specified as a part of each URL:
-     * 
-     * 1) A path pointing directly at a particular core
-     * <pre>
-     *   SolrClient client = builder.withBaseSolrUrls("http://my-solr-server:8983/solr/core1").build();
-     *   QueryResponse resp = client.query(new SolrQuery("*:*"));
-     * </pre>
-     * Note that when a core is provided in the base URL, queries and other requests can be made without mentioning the
-     * core explicitly.  However, the client can only send requests to that core.
-     * 
-     * 2) The path of the root Solr path ("/solr")
-     * <pre>
-     *   SolrClient client = builder.withBaseSolrUrls("http://my-solr-server:8983/solr").build();
-     *   QueryResponse resp = client.query("core1", new SolrQuery("*:*"));
-     * </pre>
-     * In this case the client is more flexible and can be used to send requests to any cores.  This flexibility though
-     * requires that the core is specified on all requests.
-     */
-    public Builder withBaseSolrUrls(String... solrUrls) {
-      for (String baseSolrUrl : solrUrls) {
-        this.baseSolrUrls.add(baseSolrUrl);
-      }
-      return this;
-    }
-
-    /**
-     * Provides a {@link HttpSolrClient.Builder} to be used for building the internally used clients.
-     */
-    public Builder withHttpSolrClientBuilder(Http2SolrClient.Builder builder) {
-      this.httpSolrClientBuilder = builder;
-      return this;
-    }
-    
-    public Builder withHttp2SolrClient(Http2SolrClient solrClient) {
-      this.solrClient = solrClient;
-      return this;
-    }
-    
-    public Builder withHeader(String header, String value) {
-      this.headers.put(header, value);
-      return this;
-    }
-    
-    public Builder markInternalRequest() {
-      this.headers.put(QoSParams.REQUEST_SOURCE, QoSParams.INTERNAL);
-      return this;
-    }
-
-    /**
-     * Create a {@link HttpSolrClient} based on provided configuration.
-     */
-    public AsyncLBHttpSolrClient build() {
-      return new AsyncLBHttpSolrClient(this, solrClient);
-    }
-
-    @Override
-    public Builder getThis() {
-      return this;
-    }
-  }
-}
\ No newline at end of file
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java
index 92bd99b..4b60c9b 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java
@@ -123,13 +123,13 @@ public class LBHttp2SolrClient extends LBSolrClient {
           }
           try {
             MDC.put("LBSolrClient.url", url);
-            synchronized (cancelled) {
-              if (cancelled.get()) {
-                return;
-              }
-              Cancellable cancellable = doRequest(url, req, rsp, isNonRetryable, it.isServingZombieServer(), this);
-              currentCancellable.set(cancellable);
+
+            if (cancelled.get()) {
+              return;
             }
+            Cancellable cancellable = doRequest(url, req, rsp, isNonRetryable, it.isServingZombieServer(), this);
+            currentCancellable.set(cancellable);
+
           } finally {
             MDC.remove("LBSolrClient.url");
           }
@@ -145,12 +145,12 @@ public class LBHttp2SolrClient extends LBSolrClient {
       asyncListener.onFailure(e);
     }
     return () -> {
-      synchronized (cancelled) {
-        cancelled.set(true);
-        if (currentCancellable.get() != null) {
-          currentCancellable.get().cancel();
-        }
+
+      cancelled.set(true);
+      if (currentCancellable.get() != null) {
+        currentCancellable.get().cancel();
       }
+
     };
   }
 
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
index c3fed48..cbdf0b9 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
@@ -37,6 +37,7 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -83,7 +84,7 @@ public abstract class LBSolrClient extends SolrClient {
   private volatile ServerWrapper[] aliveServerList = EMPTY_SERVER_WRAPPER;
 
 
-  private volatile ScheduledExecutorService aliveCheckExecutor;
+  private volatile ScheduledThreadPoolExecutor aliveCheckExecutor;
 
   private int interval = Integer.getInteger("solr.lbclient.live_check_interval", CHECK_INTERVAL);
   private final AtomicInteger counter = new AtomicInteger(-1);
@@ -471,8 +472,10 @@ public abstract class LBSolrClient extends SolrClient {
     if (aliveCheckExecutor == null) {
       synchronized (this) {
         if (aliveCheckExecutor == null) {
-          aliveCheckExecutor = Executors.newSingleThreadScheduledExecutor(
+          aliveCheckExecutor = new ScheduledThreadPoolExecutor(1,
               new SolrNamedThreadFactory("aliveCheckExecutor"));
+          aliveCheckExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
+          aliveCheckExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
           aliveCheckExecutor.scheduleAtFixedRate(
               getAliveCheckRunner(new WeakReference<>(this)),
               this.interval, this.interval, TimeUnit.MILLISECONDS);
@@ -746,6 +749,9 @@ public abstract class LBSolrClient extends SolrClient {
   @Override
   public void close() {
     this.closed = true;
+    if (aliveCheckExecutor != null) {
+      aliveCheckExecutor.shutdownNow();
+    }
     ExecutorUtil.shutdownAndAwaitTermination(aliveCheckExecutor);
     assert ObjectReleaseTracker.release(this);
   }
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
index 49e2520..07ec778 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
@@ -100,7 +100,7 @@ public class SolrQueuedThreadPool extends ContainerLifeCycle implements ThreadFa
 
     public SolrQueuedThreadPool(String name) {
         this(name, Integer.MAX_VALUE, Integer.getInteger("solr.minContainerThreads", 250),
-            30000, 0, // no reserved executor threads - we can process requests after shutdown or some race - we try to limit without threadpool limits no anyway
+            Integer.getInteger("solr.containerThreadsIdleTimeout", 30000), 0, // no reserved executor threads - we can process requests after shutdown or some race - we try to limit without threadpool limits no anyway
                 null, -1, null,
                 new  SolrNamedThreadFactory(name));
         this.name = name;
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
index 6bc9218..8ca5222 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
@@ -276,7 +276,7 @@ public class SolrTestCase extends LuceneTestCase {
 
       System.setProperty("solr.defaultCollectionActiveWait", "10");
 
-      System.setProperty("solr.http2solrclient.maxpool.size", "12");
+      System.setProperty("solr.http2solrclient.maxpool.size", "16");
       System.setProperty("solr.http2solrclient.pool.keepalive", "1500");
 
       System.setProperty("solr.disablePublicKeyHandler", "false");
@@ -288,8 +288,10 @@ public class SolrTestCase extends LuceneTestCase {
       // unlimited - System.setProperty("solr.maxContainerThreads", "300");
       System.setProperty("solr.lowContainerThreadsThreshold", "-1");
       System.setProperty("solr.minContainerThreads", "8");
-      System.setProperty("solr.rootSharedThreadPoolCoreSize", "16");
+      System.setProperty("solr.rootSharedThreadPoolCoreSize", "10");
       System.setProperty("solr.minHttp2ClientThreads", "6");
+      System.setProperty("solr.containerThreadsIdleTimeout", "1000");
+
 
 
       ScheduledTriggers.DEFAULT_COOLDOWN_PERIOD_SECONDS = 1;
@@ -297,7 +299,7 @@ public class SolrTestCase extends LuceneTestCase {
       ScheduledTriggers.DEFAULT_TRIGGER_CORE_POOL_SIZE = 2;
 
       System.setProperty("solr.tests.maxBufferedDocs", "1000000");
-      System.setProperty("solr.tests.ramPerThreadHardLimitMB", "30");
+      System.setProperty("solr.tests.ramPerThreadHardLimitMB", "90");
 
       System.setProperty("solr.tests.ramBufferSizeMB", "100");