mirror of https://github.com/apache/lucene.git
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:
parent
8f6343fb83
commit
5b0ae51d63
|
@ -199,6 +199,10 @@ Bug Fixes
|
||||||
webcontainers / proxies. (Jakob Furrer, hossman, Shawn Heisey, Uwe Schindler,
|
webcontainers / proxies. (Jakob Furrer, hossman, Shawn Heisey, Uwe Schindler,
|
||||||
Mark Miller)
|
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
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -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.embedded.JettySolrRunner;
|
||||||
import org.apache.solr.client.solrj.impl.CloudSolrServer;
|
import org.apache.solr.client.solrj.impl.CloudSolrServer;
|
||||||
import org.apache.solr.client.solrj.impl.HttpSolrServer;
|
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.QueryRequest;
|
||||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
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.client.solrj.response.QueryResponse;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
@ -241,23 +243,38 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {
|
||||||
assertTrue(sawException);
|
assertTrue(sawException);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAlias(String alias, String collections) throws SolrServerException, IOException {
|
private void createAlias(String alias, String collections)
|
||||||
|
throws SolrServerException, IOException {
|
||||||
|
if (random().nextBoolean()) {
|
||||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||||
params.set("collections", collections);
|
params.set("collections", collections);
|
||||||
params.set("name", alias);
|
params.set("name", alias);
|
||||||
params.set("action", CollectionAction.CREATEALIAS.toString());
|
params.set("action", CollectionAction.CREATEALIAS.toString());
|
||||||
QueryRequest request = new QueryRequest(params);
|
QueryRequest request = new QueryRequest(params);
|
||||||
request.setPath("/admin/collections");
|
request.setPath("/admin/collections");
|
||||||
NamedList<Object> result = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))).request(request);
|
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 {
|
private void deleteAlias(String alias) throws SolrServerException,
|
||||||
|
IOException {
|
||||||
|
if (random().nextBoolean()) {
|
||||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||||
params.set("name", alias);
|
params.set("name", alias);
|
||||||
params.set("action", CollectionAction.DELETEALIAS.toString());
|
params.set("action", CollectionAction.DELETEALIAS.toString());
|
||||||
QueryRequest request = new QueryRequest(params);
|
QueryRequest request = new QueryRequest(params);
|
||||||
request.setPath("/admin/collections");
|
request.setPath("/admin/collections");
|
||||||
NamedList<Object> result = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))).request(request);
|
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,
|
protected void indexDoc(List<CloudJettyRunner> skipServers, Object... fields) throws IOException,
|
||||||
|
|
|
@ -197,7 +197,7 @@ public class CollectionAdminRequest extends SolrRequest
|
||||||
@Override
|
@Override
|
||||||
public SolrParams getParams() {
|
public SolrParams getParams() {
|
||||||
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
|
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
|
||||||
params.set( "collections", collection );
|
params.set( "collections", aliasedCollections );
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue