SOLR-5547: Creating a collection alias using SolrJ's CollectionAdminRequest sets the alias name and the collections to alias to the same value.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1550548 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-12-12 21:57:39 +00:00
parent 8f6343fb83
commit 5b0ae51d63
3 changed files with 37 additions and 16 deletions

View File

@ -198,6 +198,10 @@ Bug Fixes
* SOLR-5532: SolrJ Content-Type validation is too strict for some
webcontainers / proxies. (Jakob Furrer, hossman, Shawn Heisey, Uwe Schindler,
Mark Miller)
* SOLR-5547: Creating a collection alias using SolrJ's CollectionAdminRequest
sets the alias name and the collections to alias to the same value.
(Aaron Schram, Mark Miller)
Optimizations
----------------------

View File

@ -27,8 +27,10 @@ import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
@ -241,23 +243,38 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {
assertTrue(sawException);
}
private void createAlias(String alias, String collections) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("collections", collections);
params.set("name", alias);
params.set("action", CollectionAction.CREATEALIAS.toString());
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
NamedList<Object> result = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))).request(request);
private void createAlias(String alias, String collections)
throws SolrServerException, IOException {
if (random().nextBoolean()) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("collections", collections);
params.set("name", alias);
params.set("action", CollectionAction.CREATEALIAS.toString());
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
NamedList<Object> result = createNewSolrServer("",
getBaseUrl((HttpSolrServer) clients.get(0))).request(request);
} else {
CollectionAdminResponse resp = CollectionAdminRequest.CreateAlias
.createAlias(alias, collections, createNewSolrServer("",
getBaseUrl((HttpSolrServer) clients.get(0))));
}
}
private void deleteAlias(String alias) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("name", alias);
params.set("action", CollectionAction.DELETEALIAS.toString());
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
NamedList<Object> result = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))).request(request);
private void deleteAlias(String alias) throws SolrServerException,
IOException {
if (random().nextBoolean()) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("name", alias);
params.set("action", CollectionAction.DELETEALIAS.toString());
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
NamedList<Object> result = createNewSolrServer("",
getBaseUrl((HttpSolrServer) clients.get(0))).request(request);
} else {
CollectionAdminResponse resp = CollectionAdminRequest.deleteAlias(alias,
createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))));
}
}
protected void indexDoc(List<CloudJettyRunner> skipServers, Object... fields) throws IOException,

View File

@ -197,7 +197,7 @@ public class CollectionAdminRequest extends SolrRequest
@Override
public SolrParams getParams() {
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
params.set( "collections", collection );
params.set( "collections", aliasedCollections );
return params;
}