mirror of https://github.com/apache/lucene.git
SOLR-5380: Using cloudSolrServer.setDefaultCollection(collectionId) does not work as intended for an alias spanning more than 1 collection.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1535076 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c95712ee4
commit
9c47892d4e
|
@ -122,6 +122,10 @@ Bug Fixes
|
||||||
* SOLR-5363: Solr doesn't start up properly with Log4J2 (Petar Tahchiev via Alan
|
* SOLR-5363: Solr doesn't start up properly with Log4J2 (Petar Tahchiev via Alan
|
||||||
Woodward)
|
Woodward)
|
||||||
|
|
||||||
|
* SOLR-5380: Using cloudSolrServer.setDefaultCollection(collectionId) does not
|
||||||
|
work as intended for an alias spanning more than 1 collection.
|
||||||
|
(Thomas Egense, Shawn Heisey, Mark Miller)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,12 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {
|
||||||
query = new SolrQuery("*:*");
|
query = new SolrQuery("*:*");
|
||||||
query.set("collection", "testalias");
|
query.set("collection", "testalias");
|
||||||
res = cloudSolrServer.query(query);
|
res = cloudSolrServer.query(query);
|
||||||
|
assertEquals(5, res.getResults().getNumFound());
|
||||||
|
|
||||||
|
// Try with setDefaultCollection
|
||||||
|
query = new SolrQuery("*:*");
|
||||||
|
cloudSolrServer.setDefaultCollection("testalias");
|
||||||
|
res = cloudSolrServer.query(query);
|
||||||
cloudSolrServer.shutdown();
|
cloudSolrServer.shutdown();
|
||||||
assertEquals(5, res.getResults().getNumFound());
|
assertEquals(5, res.getResults().getNumFound());
|
||||||
|
|
||||||
|
|
|
@ -546,17 +546,7 @@ public class CloudSolrServer extends SolrServer {
|
||||||
throw new SolrException(ErrorCode.BAD_REQUEST,
|
throw new SolrException(ErrorCode.BAD_REQUEST,
|
||||||
"Could not find collection: " + collection);
|
"Could not find collection: " + collection);
|
||||||
}
|
}
|
||||||
collection = collectionsList.iterator().next();
|
|
||||||
|
|
||||||
StringBuilder collectionString = new StringBuilder();
|
|
||||||
Iterator<String> it = collectionsList.iterator();
|
|
||||||
for (int i = 0; i < collectionsList.size(); i++) {
|
|
||||||
String col = it.next();
|
|
||||||
collectionString.append(col);
|
|
||||||
if (i < collectionsList.size() - 1) {
|
|
||||||
collectionString.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: not a big deal because of the caching, but we could avoid looking
|
// TODO: not a big deal because of the caching, but we could avoid looking
|
||||||
// at every shard
|
// at every shard
|
||||||
// when getting leaders if we tweaked some things
|
// when getting leaders if we tweaked some things
|
||||||
|
@ -592,10 +582,24 @@ public class CloudSolrServer extends SolrServer {
|
||||||
|| !coreNodeProps.getState().equals(ZkStateReader.ACTIVE)) continue;
|
|| !coreNodeProps.getState().equals(ZkStateReader.ACTIVE)) continue;
|
||||||
if (nodes.put(node, nodeProps) == null) {
|
if (nodes.put(node, nodeProps) == null) {
|
||||||
if (!sendToLeaders || (sendToLeaders && coreNodeProps.isLeader())) {
|
if (!sendToLeaders || (sendToLeaders && coreNodeProps.isLeader())) {
|
||||||
String url = coreNodeProps.getCoreUrl();
|
String url;
|
||||||
|
if (reqParams.get("collection") == null) {
|
||||||
|
url = ZkCoreNodeProps.getCoreUrl(
|
||||||
|
nodeProps.getStr(ZkStateReader.BASE_URL_PROP),
|
||||||
|
defaultCollection);
|
||||||
|
} else {
|
||||||
|
url = coreNodeProps.getCoreUrl();
|
||||||
|
}
|
||||||
urlList2.add(url);
|
urlList2.add(url);
|
||||||
} else if (sendToLeaders) {
|
} else if (sendToLeaders) {
|
||||||
String url = coreNodeProps.getCoreUrl();
|
String url;
|
||||||
|
if (reqParams.get("collection") == null) {
|
||||||
|
url = ZkCoreNodeProps.getCoreUrl(
|
||||||
|
nodeProps.getStr(ZkStateReader.BASE_URL_PROP),
|
||||||
|
defaultCollection);
|
||||||
|
} else {
|
||||||
|
url = coreNodeProps.getCoreUrl();
|
||||||
|
}
|
||||||
replicas.add(url);
|
replicas.add(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue