From 3525a56010de3bfbbe870cf0c1e3d8a6a5924652 Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Sat, 13 Sep 2014 08:51:39 +0000 Subject: [PATCH] SOLR-6514 git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1624717 13f79535-47bb-0310-9956-ffa450edef68 --- .../client/solrj/impl/CloudSolrServer.java | 31 ++++--------------- .../client/solrj/impl/LBHttpSolrServer.java | 5 ++- 2 files changed, 10 insertions(+), 26 deletions(-) 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.java index 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 queryStringParams = lbServer.getQueryParams(); - if (queryStringParams == null) { - queryStringParams = new HashSet(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 aliasList = StrUtils.splitSmart(alias, ",", true); + List 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.java index 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 queryParams; + private Set queryParams = new HashSet<>(); static { solrQuery.setRows(0); @@ -244,6 +244,9 @@ public class LBHttpSolrServer extends SolrServer { public void setQueryParams(Set queryParams) { this.queryParams = queryParams; } + public void addQueryParams(String queryOnlyParam) { + this.queryParams.add(queryOnlyParam) ; + } public static String normalize(String server) { if (server.endsWith("/"))