Apache Solr open-source search software
SOLR-6514
Noble Paul3525a56010de
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.javaindex f83611def4f..05cbe50fdb8 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java@@ -182,7 +182,7 @@ public class CloudSolrServer extends SolrServer {this.lbServer.setParser(new BinaryResponseParser());this.updatesToLeaders = true;shutdownLBHttpSolrServer = true;- setupStateVerParamOnQueryString(lbServer);+ lbServer.addQueryParams(STATE_VERSION);}@@ -201,7 +201,7 @@ public class CloudSolrServer extends SolrServer {this.lbServer.setParser(new BinaryResponseParser());this.updatesToLeaders = updatesToLeaders;shutdownLBHttpSolrServer = true;- setupStateVerParamOnQueryString(lbServer);+ lbServer.addQueryParams(STATE_VERSION);}/**Sets the cache ttl for DocCollection Objects cached . This is only applicable for collections which are persisted outside of clusterstate.json@@ -237,24 +237,10 @@ public class CloudSolrServer extends SolrServer {this.lbServer = lbServer;this.updatesToLeaders = updatesToLeaders;shutdownLBHttpSolrServer = false;- setupStateVerParamOnQueryString(lbServer);+ lbServer.addQueryParams(STATE_VERSION);}- /**- * Used internally to setup the _stateVer_ param to be sent in the query string of requests- * coming from this instance.- */- protected void setupStateVerParamOnQueryString(LBHttpSolrServer lbServer) {- // setup the stateVer param to be passed in the query string of every request- Set<String> queryStringParams = lbServer.getQueryParams();- if (queryStringParams == null) {- queryStringParams = new HashSet<String>(2);- lbServer.setQueryParams(queryStringParams);- }- queryStringParams.add(STATE_VERSION);- }-public ResponseParser getParser() {return lbServer.getParser();}@@ -701,6 +687,7 @@ public class CloudSolrServer extends SolrServer {boolean stateWasStale = false;if (retryCount < MAX_STALE_RETRIES &&+ requestedCollections != null &&!requestedCollections.isEmpty() &&SolrException.ErrorCode.getErrorCode(errorCode) == SolrException.ErrorCode.INVALID_STATE){@@ -883,9 +870,6 @@ public class CloudSolrServer extends SolrServer {}- // System.out.println("########################## MAKING REQUEST TO " +- // theUrlList);-LBHttpSolrServer.Req req = new LBHttpSolrServer.Req(request, theUrlList);LBHttpSolrServer.Rsp rsp = lbServer.request(req);return rsp.getResponse();@@ -902,16 +886,13 @@ public class CloudSolrServer extends SolrServer {Aliases aliases = zkStateReader.getAliases();String alias = aliases.getCollectionAlias(collectionName);if (alias != null) {- List<String> aliasList = StrUtils.splitSmart(alias, ",", true);+ List<String> aliasList = StrUtils.splitSmart(alias, ",", true);collectionsList.addAll(aliasList);continue;}- DocCollection docCollection = getDocCollection(clusterState, collection);- if (docCollection == null) {throw new SolrException(ErrorCode.BAD_REQUEST, "Collection not found: " + collectionName);}- }collectionsList.add(collectionName);}@@ -957,7 +938,7 @@ public class CloudSolrServer extends SolrServer {DocCollection col = clusterState.getCollectionOrNull(collection);if(col == null ) return null;- collectionStateCache.put(collection, new ExpiringCachedDocCollection(col));+ if(col.getStateFormat() >1) collectionStateCache.put(collection, new ExpiringCachedDocCollection(col));return col;}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.javaindex 39cc9d87979..52316dc946d 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java@@ -106,7 +106,7 @@ public class LBHttpSolrServer extends SolrServer {private volatile ResponseParser parser;private volatile RequestWriter requestWriter;- private Set<String> queryParams;+ private Set<String> queryParams = new HashSet<>();static {solrQuery.setRows(0);@@ -244,6 +244,9 @@ public class LBHttpSolrServer extends SolrServer {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("/"))