lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ans...@apache.org
Subject svn commit: r1622126 - in /lucene/dev/branches/branch_4x/solr: ./ core/src/test/org/apache/solr/cloud/ solrj/src/java/org/apache/solr/client/solrj/request/
Date Tue, 02 Sep 2014 21:04:52 GMT
Author: anshum
Date: Tue Sep  2 21:04:51 2014
New Revision: 1622126

URL: http://svn.apache.org/r1622126
Log:
SOLR-6073: Deprecate helper methods for CollectionsAPI SolrJ calls. Move towards using builder
design for the calls.

Modified:
    lucene/dev/branches/branch_4x/solr/CHANGES.txt
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java
    lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java

Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1622126&r1=1622125&r2=1622126&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Tue Sep  2 21:04:51 2014
@@ -30,6 +30,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
 ----------------------
 
@@ -43,6 +50,9 @@ New Features
 * SOLR-6365: specify appends, defaults, invariants outside of the request handler.
   (Noble Paul, Erik Hatcher, shalin)
 
+* SOLR-6073: Remove helper methods from CollectionsRequest (SolrJ) for CollectionsAPI
+  calls and move to a builder design for the same. (Anshum Gupta)
+
 Bug Fixes
 ----------------------
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java?rev=1622126&r1=1622125&r2=1622126&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
Tue Sep  2 21:04:51 2014
@@ -29,6 +29,8 @@ import org.apache.solr.client.solrj.embe
 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 extend
       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 extend
       request.setPath("/admin/collections");
       server.request(request);
     } else {
-      CollectionAdminRequest.deleteAlias(alias,server);
+      DeleteAlias request = new DeleteAlias();
+      request.setCollectionName(alias);
+      request.process(server);
     }
     server.shutdown();
   }

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java?rev=1622126&r1=1622125&r2=1622126&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIAsyncDistributedZkTest.java
Tue Sep  2 21:04:51 2014
@@ -22,6 +22,9 @@ import org.apache.solr.client.solrj.Solr
 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 CollectionsAPIAsyncDistribu
 
   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 CollectionsAPIAsyncDistribu
     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 CollectionsAPIAsyncDistribu
   }
 
   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");
   }

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1622126&r1=1622125&r2=1622126&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
Tue Sep  2 21:04:51 2014
@@ -255,10 +255,14 @@ public class CollectionsAPIDistributedZk
     Map<String, NamedList<Integer>> coresStatus;
     Map<String, NamedList<Integer>> 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 CollectionsAPIDistributedZk
       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 CollectionsAPIDistributedZk
     request = new QueryRequest(params);
     request.setPath("/admin/collections");
     gotExp = false;
-    resp = null;
     try {
       resp = createNewSolrServer("", baseUrl).request(request);
     } catch (SolrException e) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java?rev=1622126&r1=1622125&r2=1622126&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java
Tue Sep  2 21:04:51 2014
@@ -21,7 +21,9 @@ import org.apache.solr.client.solrj.Solr
 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 extend
     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 extend
 
   private void testTaskExclusivity() throws IOException, SolrServerException {
     SolrServer server = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0)));
-    CollectionAdminRequest.createCollection("ocptest_shardsplit", 4, "conf1", server, "1000");
-
-    CollectionAdminRequest.splitShard("ocptest_shardsplit", SHARD1, server, "1001");
-    CollectionAdminRequest.splitShard("ocptest_shardsplit", SHARD2, server, "1002");
+    Create createCollectionRequest = new Create();
+    createCollectionRequest.setCollectionName("ocptest_shardsplit");
+    createCollectionRequest.setNumShards(4);
+    createCollectionRequest.setConfigName("conf1");
+    createCollectionRequest.setAsyncId("1000");
+    createCollectionRequest.process(server);
+
+    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 extend
 
   private void testDeduplicationOfSubmittedTasks() throws IOException, SolrServerException
{
     SolrServer server = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0)));
-    CollectionAdminRequest.createCollection("ocptest_shardsplit2", 4, "conf1", server, "3000");
-
-    CollectionAdminRequest.splitShard("ocptest_shardsplit2", SHARD1, server, "3001");
-    CollectionAdminRequest.splitShard("ocptest_shardsplit2", SHARD2, server, "3002");
+    Create createCollectionRequest = new Create();
+    createCollectionRequest.setCollectionName("ocptest_shardsplit2");
+    createCollectionRequest.setNumShards(4);
+    createCollectionRequest.setConfigName("conf1");
+    createCollectionRequest.setAsyncId("3000");
+    createCollectionRequest.process(server);
+
+    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 extend
     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 extend
   }
 
   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");
   }

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java?rev=1622126&r1=1622125&r2=1622126&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java
Tue Sep  2 21:04:51 2014
@@ -32,6 +32,7 @@ import org.apache.lucene.util.LuceneTest
 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 SharedFSAutoReplicaFailover
   // 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());
     

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java?rev=1622126&r1=1622125&r2=1622126&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
Tue Sep  2 21:04:51 2014
@@ -213,6 +213,12 @@ public class CollectionAdminRequest exte
     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();
       params.set("requestid", requestId);
@@ -381,6 +387,7 @@ public class CollectionAdminRequest exte
   //---------------------------------------------------------------------------------------
 
   // creates collection using a compositeId router
+  @Deprecated
   public static CollectionAdminResponse createCollection( String name,
                                                           Integer shards, Integer repl, Integer
maxShards,
                                                           String nodeSet,
@@ -390,8 +397,9 @@ public class CollectionAdminRequest exte
   {
     return createCollection(name, shards, repl, maxShards, nodeSet, conf, routerField, server,
null);
   }
-  
+
   // creates collection using a compositeId router
+  @Deprecated
   public static CollectionAdminResponse createCollection( String name,
                                                           Integer shards, Integer repl, Integer
maxShards,
                                                           String nodeSet,
@@ -414,6 +422,7 @@ public class CollectionAdminRequest exte
   }
 
   // creates collection using a compositeId router
+  @Deprecated
   public static CollectionAdminResponse createCollection( String name,
                                                           Integer shards, Integer repl, Integer
maxShards,
                                                           String nodeSet,
@@ -435,12 +444,14 @@ public class CollectionAdminRequest exte
     return req.process( server );
   }
 
+  @Deprecated
   public static CollectionAdminResponse createCollection(String name, Integer shards,
                                                         String conf,
                                                         SolrServer server) throws SolrServerException,
IOException {
     return createCollection(name, shards, conf, server, null);
   }
 
+  @Deprecated
   public static CollectionAdminResponse createCollection( String name,
                                                           Integer shards, String conf,
                                                           SolrServer server,
@@ -455,6 +466,7 @@ public class CollectionAdminRequest exte
     return req.process( server );
   }
 
+  @Deprecated
   public static CollectionAdminResponse createCollection(String name,
                                                          String shards, Integer repl, Integer
maxShards,
                                                          String nodeSet,
@@ -465,6 +477,7 @@ public class CollectionAdminRequest exte
   }
 
   // creates a collection using an implicit router
+  @Deprecated
   public static CollectionAdminResponse createCollection( String name,
                                                           String shards, Integer repl, Integer
maxShards,
                                                           String nodeSet,
@@ -486,6 +499,7 @@ public class CollectionAdminRequest exte
     return req.process( server );
   }
 
+  @Deprecated
   public static CollectionAdminResponse createCollection( String name,
                                                           String shards, String conf,
                                                           SolrServer server) throws SolrServerException,
IOException
@@ -493,6 +507,7 @@ public class CollectionAdminRequest exte
     return createCollection(name, shards, conf, server, null);
   }
 
+  @Deprecated
   public static CollectionAdminResponse createCollection( String name,
                                                           String shards, String conf,
                                                           SolrServer server, String asyncId
) throws SolrServerException, IOException
@@ -506,11 +521,13 @@ public class CollectionAdminRequest exte
     return req.process( server );
   }
 
+  @Deprecated
   public static CollectionAdminResponse reloadCollection( String name, SolrServer server)
       throws SolrServerException, IOException {
     return reloadCollection(name, server, null);
   }
 
+  @Deprecated
   public static CollectionAdminResponse reloadCollection( String name, SolrServer server,
String asyncId )
       throws SolrServerException, IOException
   {
@@ -520,12 +537,14 @@ public class CollectionAdminRequest exte
     return req.process( server );
   }
 
+  @Deprecated
   public static CollectionAdminResponse deleteCollection( String name, SolrServer server)
       throws SolrServerException, IOException
   {
     return deleteCollection(name, server, null);
   }
 
+  @Deprecated
   public static CollectionAdminResponse deleteCollection( String name, SolrServer server,
                                                           String asyncId)
       throws SolrServerException, IOException
@@ -536,6 +555,7 @@ public class CollectionAdminRequest exte
     return req.process( server );
   }
 
+  @Deprecated
   public static CollectionAdminResponse requestStatus(String requestId, SolrServer server)
       throws SolrServerException, IOException {
     RequestStatus req = new RequestStatus();
@@ -544,6 +564,7 @@ public class CollectionAdminRequest exte
     return req.process(server);
   }
 
+  @Deprecated
   public static CollectionAdminResponse createShard( String name, String shard, String nodeSet,
SolrServer server ) throws SolrServerException, IOException
   {
     CreateShard req = new CreateShard();
@@ -552,16 +573,20 @@ public class CollectionAdminRequest exte
     req.setNodeSet(nodeSet);
     return req.process( server );
   }
+
+  @Deprecated
   public static CollectionAdminResponse createShard( String name, String shard, SolrServer
server ) throws SolrServerException, IOException
   {
     return createShard(name, shard, null, server);
   }
 
+  @Deprecated
   public static CollectionAdminResponse splitShard( String name, String shard, String ranges,
SolrServer server ) throws SolrServerException, IOException
   {
     return splitShard(name, shard, ranges, server, null);
   }
 
+  @Deprecated
   public static CollectionAdminResponse splitShard( String name, String shard, String ranges,
SolrServer server,
                                                     String asyncId) throws SolrServerException,
IOException
   {
@@ -573,17 +598,20 @@ public class CollectionAdminRequest exte
     return req.process( server );
   }
 
+  @Deprecated
   public static CollectionAdminResponse splitShard(String name, String shard, SolrServer
server)
       throws SolrServerException, IOException {
     return splitShard(name, shard, null, server, null);
   }
 
+  @Deprecated
   public static CollectionAdminResponse splitShard( String name, String shard, SolrServer
server,
                                                     String asyncId ) throws SolrServerException,
IOException
   {
     return splitShard(name, shard, null, server, asyncId);
   }
 
+  @Deprecated
   public static CollectionAdminResponse deleteShard( String name, String shard, SolrServer
server ) throws SolrServerException, IOException
   {
     CollectionShardAdminRequest req = new DeleteShard();
@@ -592,6 +620,7 @@ public class CollectionAdminRequest exte
     return req.process( server );
   }
 
+  @Deprecated
   public static CollectionAdminResponse createAlias( String name, String collections, SolrServer
server ) throws SolrServerException, IOException
   {
     CreateAlias req = new CreateAlias();
@@ -600,6 +629,7 @@ public class CollectionAdminRequest exte
     return req.process( server );
   }
 
+  @Deprecated
   public static CollectionAdminResponse deleteAlias( String name, SolrServer server ) throws
SolrServerException, IOException
   {
     CollectionAdminRequest req = new DeleteAlias();



Mime
View raw message