SOLR-6514

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1624717 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2014-09-13 08:51:39 +00:00
parent de14ec4126
commit 3525a56010
2 changed files with 10 additions and 26 deletions

View File

@ -182,7 +182,7 @@ public class CloudSolrServer extends SolrServer {
this.lbServer.setParser(new BinaryResponseParser()); this.lbServer.setParser(new BinaryResponseParser());
this.updatesToLeaders = true; this.updatesToLeaders = true;
shutdownLBHttpSolrServer = true; shutdownLBHttpSolrServer = true;
setupStateVerParamOnQueryString(lbServer); lbServer.addQueryParams(STATE_VERSION);
} }
@ -201,7 +201,7 @@ public class CloudSolrServer extends SolrServer {
this.lbServer.setParser(new BinaryResponseParser()); this.lbServer.setParser(new BinaryResponseParser());
this.updatesToLeaders = updatesToLeaders; this.updatesToLeaders = updatesToLeaders;
shutdownLBHttpSolrServer = true; 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 /**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.lbServer = lbServer;
this.updatesToLeaders = updatesToLeaders; this.updatesToLeaders = updatesToLeaders;
shutdownLBHttpSolrServer = false; 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() { public ResponseParser getParser() {
return lbServer.getParser(); return lbServer.getParser();
} }
@ -701,6 +687,7 @@ public class CloudSolrServer extends SolrServer {
boolean stateWasStale = false; boolean stateWasStale = false;
if (retryCount < MAX_STALE_RETRIES && if (retryCount < MAX_STALE_RETRIES &&
requestedCollections != null &&
!requestedCollections.isEmpty() && !requestedCollections.isEmpty() &&
SolrException.ErrorCode.getErrorCode(errorCode) == SolrException.ErrorCode.INVALID_STATE) 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.Req req = new LBHttpSolrServer.Req(request, theUrlList);
LBHttpSolrServer.Rsp rsp = lbServer.request(req); LBHttpSolrServer.Rsp rsp = lbServer.request(req);
return rsp.getResponse(); return rsp.getResponse();
@ -902,16 +886,13 @@ public class CloudSolrServer extends SolrServer {
Aliases aliases = zkStateReader.getAliases(); Aliases aliases = zkStateReader.getAliases();
String alias = aliases.getCollectionAlias(collectionName); String alias = aliases.getCollectionAlias(collectionName);
if (alias != null) { if (alias != null) {
List<String> aliasList = StrUtils.splitSmart(alias, ",", true); List<String> aliasList = StrUtils.splitSmart(alias, ",", true);
collectionsList.addAll(aliasList); collectionsList.addAll(aliasList);
continue; continue;
} }
DocCollection docCollection = getDocCollection(clusterState, collection);
if (docCollection == null) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Collection not found: " + collectionName); throw new SolrException(ErrorCode.BAD_REQUEST, "Collection not found: " + collectionName);
} }
}
collectionsList.add(collectionName); collectionsList.add(collectionName);
} }
@ -957,7 +938,7 @@ public class CloudSolrServer extends SolrServer {
DocCollection col = clusterState.getCollectionOrNull(collection); DocCollection col = clusterState.getCollectionOrNull(collection);
if(col == null ) return null; if(col == null ) return null;
collectionStateCache.put(collection, new ExpiringCachedDocCollection(col)); if(col.getStateFormat() >1) collectionStateCache.put(collection, new ExpiringCachedDocCollection(col));
return col; return col;
} }

View File

@ -106,7 +106,7 @@ public class LBHttpSolrServer extends SolrServer {
private volatile ResponseParser parser; private volatile ResponseParser parser;
private volatile RequestWriter requestWriter; private volatile RequestWriter requestWriter;
private Set<String> queryParams; private Set<String> queryParams = new HashSet<>();
static { static {
solrQuery.setRows(0); solrQuery.setRows(0);
@ -244,6 +244,9 @@ public class LBHttpSolrServer extends SolrServer {
public void setQueryParams(Set<String> queryParams) { public void setQueryParams(Set<String> queryParams) {
this.queryParams = queryParams; this.queryParams = queryParams;
} }
public void addQueryParams(String queryOnlyParam) {
this.queryParams.add(queryOnlyParam) ;
}
public static String normalize(String server) { public static String normalize(String server) {
if (server.endsWith("/")) if (server.endsWith("/"))