diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index dd9b7851fc9..176fd06f38a 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -55,6 +55,11 @@ Upgrading from Solr 4.x the "suggestions" subsection, and now are directly under "spellcheck". See SOLR-3029 for more information. +* The CollectionsAPI SolrJ calls createCollection(), reloadCollection(), + deleteCollection(), requestStatus(), createShard(), splitShard(), deleteShard(), + createAlias() and deleteAlias() which were deprecated in 4.11 have been removed. + The new usage involves a builder style construction of the call. + Detailed Change List ---------------------- @@ -97,6 +102,9 @@ Other Changes removes "experimental" warning from two places: replication handler details command and DataImportHandler responses. (ehatcher) +* SOLR-6073: Remove helper methods from CollectionsRequest (SolrJ) for CollectionsAPI + calls and move to a builder design for the same. (Anshum Gupta) + ================== 4.11.0 ================= Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release @@ -110,6 +118,13 @@ Apache UIMA 2.3.1 Apache ZooKeeper 3.4.6 Noggit 0.6 +Upgrading from Solr 4.10 +---------------------- +* The CollectionsAPI SolrJ calls createCollection(), reloadCollection(), + deleteCollection(), requestStatus(), createShard(), splitShard(), deleteShard(), + createAlias() and deleteAlias() have been deprecated. The new usage involves a + builder style construction of the call. + Detailed Change List ---------------------- @@ -157,7 +172,8 @@ Other Changes * SOLR-6445: Upgrade Noggit to verion 0.6 to support more flexible JSON input (Noble Paul , Yonik Seeley) - +* SOLR-6073: Remove helper methods from CollectionsRequest (SolrJ) for CollectionsAPI + calls and move to a builder design for the same. (Anshum Gupta) ================== 4.10.0 ================= Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release diff --git a/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java b/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java index 8081be07882..66eb6b6990f 100644 --- a/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java @@ -29,6 +29,8 @@ 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.CollectionAdminRequest.CreateAlias; +import org.apache.solr.client.solrj.request.CollectionAdminRequest.DeleteAlias; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.client.solrj.response.QueryResponse; @@ -265,7 +267,10 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase { request.setPath("/admin/collections"); server.request(request); } else { - CollectionAdminRequest.CreateAlias.createAlias(alias, collections, server); + CreateAlias request = new CreateAlias(); + request.setCollectionName(alias); + request.setAliasedCollections(collections); + request.process(server); } server.shutdown(); } @@ -282,7 +287,9 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase { request.setPath("/admin/collections"); server.request(request); } else { - CollectionAdminRequest.deleteAlias(alias,server); + DeleteAlias request = new DeleteAlias(); + request.setCollectionName(alias); + request.process(server); } server.shutdown(); } diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java index 54c7371d4df..537edc13d5c 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java @@ -22,6 +22,9 @@ import org.apache.solr.client.solrj.SolrServer; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.request.CollectionAdminRequest; +import org.apache.solr.client.solrj.request.CollectionAdminRequest.Create; +import org.apache.solr.client.solrj.request.CollectionAdminRequest.RequestStatus; +import org.apache.solr.client.solrj.request.CollectionAdminRequest.SplitShard; import org.apache.solr.client.solrj.response.CollectionAdminResponse; import org.apache.solr.common.util.NamedList; import org.apache.solr.update.DirectUpdateHandler2; @@ -67,14 +70,25 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT private void testSolrJAPICalls() throws Exception { SolrServer server = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))); - CollectionAdminRequest.createCollection("testasynccollectioncreation", 1, "conf1", server, "1001"); - String state = null; - state = getRequestStateAfterCompletion("1001", MAX_TIMEOUT_SECONDS, server); + Create createCollectionRequest = new Create(); + createCollectionRequest.setCollectionName("testasynccollectioncreation"); + createCollectionRequest.setNumShards(1); + createCollectionRequest.setConfigName("conf1"); + createCollectionRequest.setAsyncId("1001"); + createCollectionRequest.process(server); + + String state = getRequestStateAfterCompletion("1001", MAX_TIMEOUT_SECONDS, server); assertEquals("CreateCollection task did not complete!", "completed", state); - CollectionAdminRequest.createCollection("testasynccollectioncreation", 1, "conf1", server, "1002"); + + createCollectionRequest = new Create(); + createCollectionRequest.setCollectionName("testasynccollectioncreation"); + createCollectionRequest.setNumShards(1); + createCollectionRequest.setConfigName("conf1"); + createCollectionRequest.setAsyncId("1002"); + createCollectionRequest.process(server); state = getRequestStateAfterCompletion("1002", MAX_TIMEOUT_SECONDS, server); @@ -88,7 +102,12 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT state = getRequestStateAfterCompletion("1003", MAX_TIMEOUT_SECONDS, server); assertEquals("Add replica did not complete", "completed", state); - CollectionAdminRequest.splitShard("testasynccollectioncreation", "shard1", server, "1004"); + + SplitShard splitShardRequest = new SplitShard(); + splitShardRequest.setCollectionName("testasynccollectioncreation"); + splitShardRequest.setShardName("shard1"); + splitShardRequest.setAsyncId("1004"); + splitShardRequest.process(server); state = getRequestStateAfterCompletion("1004", MAX_TIMEOUT_SECONDS * 2, server); @@ -111,7 +130,9 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT } private String getRequestState(String requestId, SolrServer server) throws IOException, SolrServerException { - CollectionAdminResponse response = CollectionAdminRequest.requestStatus(requestId, server); + RequestStatus request = new RequestStatus(); + request.setRequestId(requestId); + CollectionAdminResponse response = request.process(server); NamedList innerResponse = (NamedList) response.getResponse().get("status"); return (String) innerResponse.get("state"); } diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java index 9152f612df8..d7d6a20ac65 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java @@ -255,10 +255,14 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa Map> coresStatus; Map> nodesStatus; - response = CollectionAdminRequest.createCollection("solrj_collection", - 2, 2, null, - null, "conf1", "myOwnField", - server); + CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create(); + createCollectionRequest.setCollectionName("solrj_collection"); + createCollectionRequest.setNumShards(2); + createCollectionRequest.setReplicationFactor(2); + createCollectionRequest.setConfigName("conf1"); + createCollectionRequest.setRouterField("myOwnField"); + response = createCollectionRequest.process(server); + assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); coresStatus = response.getCollectionCoresStatus(); @@ -269,59 +273,104 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa assertTrue(status.get("QTime") > 0); } - response = CollectionAdminRequest.createCollection("solrj_implicit", - "shardA,shardB", "conf1", server); + // TODO: This test tries to validates defaulting to implicit router. + createCollectionRequest = new CollectionAdminRequest.Create(); + createCollectionRequest.setCollectionName("solrj_implicit"); + createCollectionRequest.setShards("shardA,shardB"); + createCollectionRequest.setConfigName("conf1"); + createCollectionRequest.setRouterName("implicit"); + response = createCollectionRequest.process(server); + assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); coresStatus = response.getCollectionCoresStatus(); assertEquals(2, coresStatus.size()); - response = CollectionAdminRequest.createShard("solrj_implicit", "shardC", server); + CollectionAdminRequest.CreateShard createShardRequest = new CollectionAdminRequest + .CreateShard(); + createShardRequest.setCollectionName("solrj_implicit"); + createShardRequest.setShardName("shardC"); + response = createShardRequest.process(server); + assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); coresStatus = response.getCollectionCoresStatus(); assertEquals(1, coresStatus.size()); assertEquals(0, (int) coresStatus.get("solrj_implicit_shardC_replica1").get("status")); - response = CollectionAdminRequest.deleteShard("solrj_implicit", "shardC", server); + CollectionAdminRequest.DeleteShard deleteShardRequest = new CollectionAdminRequest + .DeleteShard(); + deleteShardRequest.setCollectionName("solrj_implicit"); + deleteShardRequest.setShardName("shardC"); + response = deleteShardRequest.process(server); + assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); nodesStatus = response.getCollectionNodesStatus(); assertEquals(1, nodesStatus.size()); - response = CollectionAdminRequest.deleteCollection("solrj_implicit", server); + CollectionAdminRequest.Delete deleteCollectionRequest = new CollectionAdminRequest.Delete(); + deleteCollectionRequest.setCollectionName("solrj_implicit"); + response = deleteCollectionRequest.process(server); + assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); nodesStatus = response.getCollectionNodesStatus(); assertEquals(2, nodesStatus.size()); - response = CollectionAdminRequest.createCollection("conf1", 4, "conf1", server); + createCollectionRequest = new CollectionAdminRequest.Create(); + createCollectionRequest.setCollectionName("conf1"); + createCollectionRequest.setNumShards(4); + createCollectionRequest.setConfigName("conf1"); + response = createCollectionRequest.process(server); + assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); - response = CollectionAdminRequest.reloadCollection("conf1", server); + CollectionAdminRequest.Reload reloadCollectionRequest = new CollectionAdminRequest.Reload(); + reloadCollectionRequest.setCollectionName("conf1"); + response = reloadCollectionRequest.process(server); + assertEquals(0, response.getStatus()); - response = CollectionAdminRequest.createAlias("solrj_alias", "conf1,solrj_collection", server); + CollectionAdminRequest.CreateAlias createAliasRequest = new CollectionAdminRequest + .CreateAlias(); + createAliasRequest.setCollectionName("solrj_alias"); + createAliasRequest.setAliasedCollections("conf1,solrj_collection"); + response = createAliasRequest.process(server); + assertEquals(0, response.getStatus()); - response = CollectionAdminRequest.deleteAlias("solrj_alias", server); + CollectionAdminRequest.DeleteAlias deleteAliasRequest = new CollectionAdminRequest.DeleteAlias(); + deleteAliasRequest.setCollectionName("solrj_alias"); + deleteAliasRequest.process(server); + assertEquals(0, response.getStatus()); - response = CollectionAdminRequest.splitShard("conf1", "shard1", server); + CollectionAdminRequest.SplitShard splitShardRequest = new CollectionAdminRequest.SplitShard(); + splitShardRequest.setCollectionName("conf1"); + splitShardRequest.setShardName("shard1"); + response = splitShardRequest.process(server); + assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); coresStatus = response.getCollectionCoresStatus(); assertEquals(0, (int) coresStatus.get("conf1_shard1_0_replica1").get("status")); assertEquals(0, (int) coresStatus.get("conf1_shard1_0_replica1").get("status")); - response = CollectionAdminRequest.deleteCollection("conf1", server); + deleteCollectionRequest = new CollectionAdminRequest.Delete(); + deleteCollectionRequest.setCollectionName("conf1"); + response = deleteCollectionRequest.process(server); + assertEquals(0, response.getStatus()); nodesStatus = response.getCollectionNodesStatus(); assertTrue(response.isSuccess()); assertEquals(4, nodesStatus.size()); - response = CollectionAdminRequest.deleteCollection("solrj_collection", server); + deleteCollectionRequest = new CollectionAdminRequest.Delete(); + deleteCollectionRequest.setCollectionName("solrj_collection"); + deleteCollectionRequest.process(server); + assertEquals(0, response.getStatus()); nodesStatus = response.getCollectionNodesStatus(); assertTrue(response.isSuccess()); @@ -470,7 +519,6 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa request = new QueryRequest(params); request.setPath("/admin/collections"); gotExp = false; - resp = null; try { resp = createNewSolrServer("", baseUrl).request(request); } catch (SolrException e) { diff --git a/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java b/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java index c85bd9bdd38..86867895c31 100644 --- a/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java @@ -21,7 +21,9 @@ import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServer; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.HttpSolrServer; -import org.apache.solr.client.solrj.request.CollectionAdminRequest; +import org.apache.solr.client.solrj.request.CollectionAdminRequest.Create; +import org.apache.solr.client.solrj.request.CollectionAdminRequest.RequestStatus; +import org.apache.solr.client.solrj.request.CollectionAdminRequest.SplitShard; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.response.CollectionAdminResponse; import org.apache.solr.common.params.CollectionParams; @@ -77,7 +79,12 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase { SolrServer server = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))); for(int i = 1 ; i <= NUM_COLLECTIONS ; i++) { - CollectionAdminRequest.createCollection("ocptest" + i, 4, "conf1", server, i + ""); + Create createCollectionRequest = new Create(); + createCollectionRequest.setCollectionName("ocptest" + i); + createCollectionRequest.setNumShards(4); + createCollectionRequest.setConfigName("conf1"); + createCollectionRequest.setAsyncId(String.valueOf(i)); + createCollectionRequest.process(server); } boolean pass = false; @@ -107,10 +114,24 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase { private void testTaskExclusivity() throws IOException, SolrServerException { SolrServer server = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))); - CollectionAdminRequest.createCollection("ocptest_shardsplit", 4, "conf1", server, "1000"); + Create createCollectionRequest = new Create(); + createCollectionRequest.setCollectionName("ocptest_shardsplit"); + createCollectionRequest.setNumShards(4); + createCollectionRequest.setConfigName("conf1"); + createCollectionRequest.setAsyncId("1000"); + createCollectionRequest.process(server); - CollectionAdminRequest.splitShard("ocptest_shardsplit", SHARD1, server, "1001"); - CollectionAdminRequest.splitShard("ocptest_shardsplit", SHARD2, server, "1002"); + SplitShard splitShardRequest = new SplitShard(); + splitShardRequest.setCollectionName("ocptest_shardsplit"); + splitShardRequest.setShardName(SHARD1); + splitShardRequest.setAsyncId("1001"); + splitShardRequest.process(server); + + splitShardRequest = new SplitShard(); + splitShardRequest.setCollectionName("ocptest_shardsplit"); + splitShardRequest.setShardName(SHARD2); + splitShardRequest.setAsyncId("1002"); + splitShardRequest.process(server); int iterations = 0; while(true) { @@ -147,13 +168,32 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase { private void testDeduplicationOfSubmittedTasks() throws IOException, SolrServerException { SolrServer server = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))); - CollectionAdminRequest.createCollection("ocptest_shardsplit2", 4, "conf1", server, "3000"); + Create createCollectionRequest = new Create(); + createCollectionRequest.setCollectionName("ocptest_shardsplit2"); + createCollectionRequest.setNumShards(4); + createCollectionRequest.setConfigName("conf1"); + createCollectionRequest.setAsyncId("3000"); + createCollectionRequest.process(server); - CollectionAdminRequest.splitShard("ocptest_shardsplit2", SHARD1, server, "3001"); - CollectionAdminRequest.splitShard("ocptest_shardsplit2", SHARD2, server, "3002"); + SplitShard splitShardRequest = new SplitShard(); + splitShardRequest.setCollectionName("ocptest_shardsplit2"); + splitShardRequest.setShardName(SHARD1); + splitShardRequest.setAsyncId("3001"); + splitShardRequest.process(server); + + splitShardRequest = new SplitShard(); + splitShardRequest.setCollectionName("ocptest_shardsplit2"); + splitShardRequest.setShardName(SHARD2); + splitShardRequest.setAsyncId("3002"); + splitShardRequest.process(server); // Now submit another task with the same id. At this time, hopefully the previous 3002 should still be in the queue. - CollectionAdminResponse response = CollectionAdminRequest.splitShard("ocptest_shardsplit2", SHARD1, server, "3002"); + splitShardRequest = new SplitShard(); + splitShardRequest.setCollectionName("ocptest_shardsplit2"); + splitShardRequest.setShardName(SHARD1); + splitShardRequest.setAsyncId("3002"); + CollectionAdminResponse response = splitShardRequest.process(server); + NamedList r = response.getResponse(); assertEquals("Duplicate request was supposed to exist but wasn't found. De-duplication of submitted task failed.", "Task with the same requestid already exists.", r.get("error")); @@ -185,7 +225,11 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase { try { SolrServer server = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))); - CollectionAdminRequest.splitShard("collection1", SHARD1, server, "2000"); + SplitShard splitShardRequest = new SplitShard(); + splitShardRequest.setCollectionName("collection1"); + splitShardRequest.setShardName(SHARD1); + splitShardRequest.setAsyncId("2000"); + splitShardRequest.process(server); String state = getRequestState("2000", server); while (state.equals("submitted")) { @@ -246,7 +290,10 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase { } private String getRequestState(String requestId, SolrServer server) throws IOException, SolrServerException { - CollectionAdminResponse response = CollectionAdminRequest.requestStatus(requestId, server); + RequestStatus requestStatusRequest = new RequestStatus(); + requestStatusRequest.setRequestId(requestId); + CollectionAdminResponse response = requestStatusRequest.process(server); + NamedList innerResponse = (NamedList) response.getResponse().get("status"); return (String) innerResponse.get("state"); } diff --git a/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java b/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java index 09aa0b59920..7e156594bb7 100644 --- a/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java @@ -32,6 +32,7 @@ import org.apache.lucene.util.LuceneTestCase.Slow; import org.apache.lucene.util.LuceneTestCase.Nightly; import org.apache.solr.SolrTestCaseJ4.SuppressSSL; import org.apache.solr.client.solrj.request.CollectionAdminRequest; +import org.apache.solr.client.solrj.request.CollectionAdminRequest.Create; import org.apache.solr.client.solrj.response.CollectionAdminResponse; import org.apache.solr.cloud.hdfs.HdfsTestUtil; import org.apache.solr.common.cloud.ClusterStateUtil; @@ -113,15 +114,31 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBa // serially private void testBasics() throws Exception { String collection1 = "solrj_collection"; - CollectionAdminResponse response = CollectionAdminRequest.createCollection(collection1, 2, - 2, 2, null, "conf1", "myOwnField", true, cloudClient); + Create createCollectionRequest = new Create(); + createCollectionRequest.setCollectionName(collection1); + createCollectionRequest.setNumShards(2); + createCollectionRequest.setReplicationFactor(2); + createCollectionRequest.setMaxShardsPerNode(2); + createCollectionRequest.setConfigName("conf1"); + createCollectionRequest.setRouterField("myOwnField"); + createCollectionRequest.setAutoAddReplicas(true); + CollectionAdminResponse response = createCollectionRequest.process(cloudClient); + assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); waitForRecoveriesToFinish(collection1, false); String collection2 = "solrj_collection2"; - CollectionAdminResponse response2 = CollectionAdminRequest.createCollection(collection2, 2, - 2, 2, null, "conf1", "myOwnField", false, cloudClient); + createCollectionRequest = new Create(); + createCollectionRequest.setCollectionName(collection2); + createCollectionRequest.setNumShards(2); + createCollectionRequest.setReplicationFactor(2); + createCollectionRequest.setMaxShardsPerNode(2); + createCollectionRequest.setConfigName("conf1"); + createCollectionRequest.setRouterField("myOwnField"); + createCollectionRequest.setAutoAddReplicas(false); + CollectionAdminResponse response2 = createCollectionRequest.process(getCommonCloudSolrServer()); + assertEquals(0, response2.getStatus()); assertTrue(response2.isSuccess()); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java index bacca061074..7f638175723 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java @@ -212,6 +212,12 @@ public class CollectionAdminRequest extends SolrRequest public void setRequestId(String requestId) {this.requestId = requestId; } public String getRequestId() { return this.requestId; } + @Override + public void setAsyncId(String asyncId) { + throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "You can not set async id for " + + "a REQUESTSTATUS call. Try setRequestId()." ); + } + @Override public SolrParams getParams() { ModifiableSolrParams params = (ModifiableSolrParams) super.getParams(); @@ -375,235 +381,4 @@ public class CollectionAdminRequest extends SolrRequest res.setElapsedTime(endTime - startTime); return res; } - - //--------------------------------------------------------------------------------------- - // - //--------------------------------------------------------------------------------------- - - // creates collection using a compositeId router - public static CollectionAdminResponse createCollection( String name, - Integer shards, Integer repl, Integer maxShards, - String nodeSet, - String conf, - String routerField, - SolrServer server) throws SolrServerException, IOException - { - return createCollection(name, shards, repl, maxShards, nodeSet, conf, routerField, server, null); - } - - // creates collection using a compositeId router - public static CollectionAdminResponse createCollection( String name, - Integer shards, Integer repl, Integer maxShards, - String nodeSet, - String conf, - String routerField, - Boolean autoAddReplicas, - SolrServer server) throws SolrServerException, IOException - { - Create req = new Create(); - req.setCollectionName(name); - req.setRouterName("compositeId"); - req.setNumShards(shards); - req.setReplicationFactor(repl); - req.setMaxShardsPerNode(maxShards); - req.setCreateNodeSet(nodeSet); - req.setConfigName(conf); - req.setRouterField(routerField); - req.setAutoAddReplicas(autoAddReplicas); - return req.process( server ); - } - - // creates collection using a compositeId router - public static CollectionAdminResponse createCollection( String name, - Integer shards, Integer repl, Integer maxShards, - String nodeSet, - String conf, - String routerField, - SolrServer server, - String asyncId) throws SolrServerException, IOException - { - Create req = new Create(); - req.setCollectionName(name); - req.setRouterName("compositeId"); - req.setNumShards(shards); - req.setReplicationFactor(repl); - req.setMaxShardsPerNode(maxShards); - req.setCreateNodeSet(nodeSet); - req.setConfigName(conf); - req.setRouterField(routerField); - req.setAsyncId(asyncId); - return req.process( server ); - } - - public static CollectionAdminResponse createCollection(String name, Integer shards, - String conf, - SolrServer server) throws SolrServerException, IOException { - return createCollection(name, shards, conf, server, null); - } - - public static CollectionAdminResponse createCollection( String name, - Integer shards, String conf, - SolrServer server, - String asyncId) throws SolrServerException, IOException - { - Create req = new Create(); - req.setCollectionName(name); - req.setRouterName("compositeId"); - req.setNumShards(shards); - req.setConfigName(conf); - req.setAsyncId(asyncId); - return req.process( server ); - } - - public static CollectionAdminResponse createCollection(String name, - String shards, Integer repl, Integer maxShards, - String nodeSet, - String conf, - String routerField, - SolrServer server) throws SolrServerException, IOException { - return createCollection(name, shards, repl, maxShards, nodeSet, conf, routerField, server, null); - } - - // creates a collection using an implicit router - public static CollectionAdminResponse createCollection( String name, - String shards, Integer repl, Integer maxShards, - String nodeSet, - String conf, - String routerField, - SolrServer server, - String asyncId) throws SolrServerException, IOException - { - Create req = new Create(); - req.setCollectionName(name); - req.setRouterName("implicit"); - req.setShards(shards); - req.setReplicationFactor(repl); - req.setMaxShardsPerNode(maxShards); - req.setCreateNodeSet(nodeSet); - req.setConfigName(conf); - req.setRouterField(routerField); - req.setAsyncId(asyncId); - return req.process( server ); - } - - public static CollectionAdminResponse createCollection( String name, - String shards, String conf, - SolrServer server) throws SolrServerException, IOException - { - return createCollection(name, shards, conf, server, null); - } - - public static CollectionAdminResponse createCollection( String name, - String shards, String conf, - SolrServer server, String asyncId ) throws SolrServerException, IOException - { - Create req = new Create(); - req.setCollectionName(name); - req.setRouterName("implicit"); - req.setShards(shards); - req.setConfigName(conf); - req.setAsyncId(asyncId); - return req.process( server ); - } - - public static CollectionAdminResponse reloadCollection( String name, SolrServer server) - throws SolrServerException, IOException { - return reloadCollection(name, server, null); - } - - public static CollectionAdminResponse reloadCollection( String name, SolrServer server, String asyncId ) - throws SolrServerException, IOException - { - CollectionAdminRequest req = new Reload(); - req.setCollectionName(name); - req.setAsyncId(asyncId); - return req.process( server ); - } - - public static CollectionAdminResponse deleteCollection( String name, SolrServer server) - throws SolrServerException, IOException - { - return deleteCollection(name, server, null); - } - - public static CollectionAdminResponse deleteCollection( String name, SolrServer server, - String asyncId) - throws SolrServerException, IOException - { - CollectionAdminRequest req = new Delete(); - req.setCollectionName(name); - req.setAsyncId(asyncId); - return req.process( server ); - } - - public static CollectionAdminResponse requestStatus(String requestId, SolrServer server) - throws SolrServerException, IOException { - RequestStatus req = new RequestStatus(); - - req.setRequestId(requestId); - return req.process(server); - } - - public static CollectionAdminResponse createShard( String name, String shard, String nodeSet, SolrServer server ) throws SolrServerException, IOException - { - CreateShard req = new CreateShard(); - req.setCollectionName(name); - req.setShardName(shard); - req.setNodeSet(nodeSet); - return req.process( server ); - } - public static CollectionAdminResponse createShard( String name, String shard, SolrServer server ) throws SolrServerException, IOException - { - return createShard(name, shard, null, server); - } - - public static CollectionAdminResponse splitShard( String name, String shard, String ranges, SolrServer server ) throws SolrServerException, IOException - { - return splitShard(name, shard, ranges, server, null); - } - - public static CollectionAdminResponse splitShard( String name, String shard, String ranges, SolrServer server, - String asyncId) throws SolrServerException, IOException - { - SplitShard req = new SplitShard(); - req.setCollectionName(name); - req.setShardName(shard); - req.setRanges(ranges); - req.setAsyncId(asyncId); - return req.process( server ); - } - - public static CollectionAdminResponse splitShard(String name, String shard, SolrServer server) - throws SolrServerException, IOException { - return splitShard(name, shard, null, server, null); - } - - public static CollectionAdminResponse splitShard( String name, String shard, SolrServer server, - String asyncId ) throws SolrServerException, IOException - { - return splitShard(name, shard, null, server, asyncId); - } - - public static CollectionAdminResponse deleteShard( String name, String shard, SolrServer server ) throws SolrServerException, IOException - { - CollectionShardAdminRequest req = new DeleteShard(); - req.setCollectionName(name); - req.setShardName(shard); - return req.process( server ); - } - - public static CollectionAdminResponse createAlias( String name, String collections, SolrServer server ) throws SolrServerException, IOException - { - CreateAlias req = new CreateAlias(); - req.setCollectionName(name); - req.setAliasedCollections(collections); - return req.process( server ); - } - - public static CollectionAdminResponse deleteAlias( String name, SolrServer server ) throws SolrServerException, IOException - { - CollectionAdminRequest req = new DeleteAlias(); - req.setCollectionName(name); - return req.process( server ); - } }