You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/09/21 09:52:17 UTC
lucene-solr:jira/http2: Cleanup LBHttp2SolrClient
Repository: lucene-solr
Updated Branches:
refs/heads/jira/http2 a833e356c -> 661774131
Cleanup LBHttp2SolrClient
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/66177413
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/66177413
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/66177413
Branch: refs/heads/jira/http2
Commit: 66177413107530c43a4eaed5e12a577a363a15fc
Parents: a833e35
Author: Cao Manh Dat <da...@apache.org>
Authored: Fri Sep 21 16:52:09 2018 +0700
Committer: Cao Manh Dat <da...@apache.org>
Committed: Fri Sep 21 16:52:09 2018 +0700
----------------------------------------------------------------------
.../client/solrj/impl/LBHttp2SolrClient.java | 42 ++++++++------------
1 file changed, 16 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/66177413/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java
----------------------------------------------------------------------
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 b1860f1..d34dfdb 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
@@ -89,7 +89,7 @@ import static org.apache.solr.common.params.CommonParams.ADMIN_PATHS;
* 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
+ * @since solr 8.0
*/
public class LBHttp2SolrClient extends SolrClient {
private static Set<Integer> RETRY_CODES = new HashSet<>(4);
@@ -105,7 +105,7 @@ public class LBHttp2SolrClient extends SolrClient {
private final Map<String, ServerWrapper> aliveServers = new LinkedHashMap<>();
// access to aliveServers should be synchronized on itself
- protected final Map<String, ServerWrapper> zombieServers = new ConcurrentHashMap<>();
+ private 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];
@@ -121,9 +121,6 @@ public class LBHttp2SolrClient extends SolrClient {
private volatile RequestWriter requestWriter;
private Set<String> queryParams = new HashSet<>();
- private Integer connectionTimeout;
-
- private Integer soTimeout;
static {
solrQuery.setRows(0);
@@ -150,7 +147,7 @@ public class LBHttp2SolrClient extends SolrClient {
int failedPings = 0;
- public ServerWrapper(String baseUrl) {
+ ServerWrapper(String baseUrl) {
this.baseUrl = baseUrl;
}
@@ -258,7 +255,7 @@ public class LBHttp2SolrClient extends SolrClient {
try {
MDC.put("LBHttp2SolrClient.url", serverStr);
- if (numServersToTry != null && numServersTried > numServersToTry.intValue()) {
+ if (numServersToTry != null && numServersTried > numServersToTry) {
break;
}
@@ -279,7 +276,7 @@ public class LBHttp2SolrClient extends SolrClient {
break;
}
- if (numServersToTry != null && numServersTried > numServersToTry.intValue()) {
+ if (numServersToTry != null && numServersTried > numServersToTry) {
break;
}
@@ -301,10 +298,10 @@ public class LBHttp2SolrClient extends SolrClient {
if (timeAllowedExceeded) {
solrServerExceptionMessage = "Time allowed to handle this request exceeded";
} else {
- if (numServersToTry != null && numServersTried > numServersToTry.intValue()) {
+ if (numServersToTry != null && numServersTried > numServersToTry) {
solrServerExceptionMessage = "No live SolrServers available to handle this request:"
+ " numServersTried="+numServersTried
- + " numServersToTry="+numServersToTry.intValue();
+ + " numServersToTry="+ numServersToTry;
} else {
solrServerExceptionMessage = "No live SolrServers available to handle this request";
}
@@ -317,7 +314,7 @@ public class LBHttp2SolrClient extends SolrClient {
}
- protected Exception addZombie(String serverStr, Exception e) {
+ private Exception addZombie(String serverStr, Exception e) {
ServerWrapper wrapper;
@@ -328,8 +325,8 @@ public class LBHttp2SolrClient extends SolrClient {
return e;
}
- protected Exception doRequest(String serverStr, Req req, Rsp rsp, boolean isNonRetryable,
- boolean isZombie) throws SolrServerException, IOException {
+ private Exception doRequest(String serverStr, Req req, Rsp rsp, boolean isNonRetryable,
+ boolean isZombie) throws SolrServerException, IOException {
Exception ex = null;
try {
rsp.server = serverStr;
@@ -382,7 +379,7 @@ public class LBHttp2SolrClient extends SolrClient {
private void updateAliveList() {
synchronized (aliveServers) {
- aliveServerList = aliveServers.values().toArray(new ServerWrapper[aliveServers.size()]);
+ aliveServerList = aliveServers.values().toArray(new ServerWrapper[0]);
}
}
@@ -455,7 +452,7 @@ public class LBHttp2SolrClient extends SolrClient {
Exception ex = null;
ServerWrapper[] serverList = aliveServerList;
- final int maxTries = (numServersToTry == null ? serverList.length : numServersToTry.intValue());
+ final int maxTries = (numServersToTry == null ? serverList.length : numServersToTry);
int numServersTried = 0;
Map<String,ServerWrapper> justFailed = null;
@@ -497,7 +494,7 @@ public class LBHttp2SolrClient extends SolrClient {
break;
}
- if (wrapper.standard==false || justFailed!=null && justFailed.containsKey(wrapper.baseUrl)) continue;
+ if (!wrapper.standard || justFailed!=null && justFailed.containsKey(wrapper.baseUrl)) continue;
try {
++numServersTried;
request.setBasePath(wrapper.baseUrl);
@@ -526,10 +523,10 @@ public class LBHttp2SolrClient extends SolrClient {
if (timeAllowedExceeded) {
solrServerExceptionMessage = "Time allowed to handle this request exceeded";
} else {
- if (numServersToTry != null && numServersTried > numServersToTry.intValue()) {
+ if (numServersToTry != null && numServersTried > numServersToTry) {
solrServerExceptionMessage = "No live SolrServers available to handle this request:"
+ " numServersTried="+numServersTried
- + " numServersToTry="+numServersToTry.intValue();
+ + " numServersToTry="+ numServersToTry;
} else {
solrServerExceptionMessage = "No live SolrServers available to handle this request";
}
@@ -635,7 +632,7 @@ public class LBHttp2SolrClient extends SolrClient {
private static Runnable getAliveCheckRunner(final WeakReference<LBHttp2SolrClient> lbRef) {
return () -> {
LBHttp2SolrClient lb = lbRef.get();
- if (lb != null && lb.zombieServers != null) {
+ if (lb != null) {
for (ServerWrapper zombieServer : lb.zombieServers.values()) {
lb.checkAZombieServer(zombieServer);
}
@@ -643,13 +640,6 @@ public class LBHttp2SolrClient extends SolrClient {
};
}
- /**
- * Return the HttpClient this instance uses.
- */
- private Http2SolrClient getHttpClient() {
- return httpClient;
- }
-
public ResponseParser getParser() {
return parser;
}