SOLR-7595: Allow method chaining for all CollectionAdminRequests in Solrj

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1681808 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2015-05-26 18:33:33 +00:00
parent e461ab66f1
commit a94d110aa4
18 changed files with 587 additions and 432 deletions

View File

@ -68,7 +68,9 @@ Versions of Major Components
Upgrading from Solr 5.2
-----------------------
(no changes)
* SolrJ's CollectionAdminRequest class is now marked as abstract. Use one of its concrete
sub-classes instead.
Detailed Change List
----------------------
@ -92,7 +94,8 @@ Optimizations
Other Changes
----------------------
(no changes)
* SOLR-7595: Allow method chaining for all CollectionAdminRequests in Solrj. (shalin)
================== 5.2.0 ==================

View File

@ -123,9 +123,8 @@ public class CollectionReloadTest extends AbstractFullDistribZkTestBase {
// try to clean up
try {
CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName);
req.process(cloudClient);
new CollectionAdminRequest.Delete()
.setCollectionName(testCollectionName).process(cloudClient);
} catch (Exception e) {
// don't fail the test
log.warn("Could not delete collection {} after test completed", testCollectionName);

View File

@ -17,6 +17,8 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
import java.io.IOException;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
@ -30,8 +32,6 @@ import org.apache.solr.common.util.NamedList;
import org.apache.solr.update.DirectUpdateHandler2;
import org.junit.Test;
import java.io.IOException;
/**
* Tests the Cloud Collections API.
*/
@ -58,11 +58,11 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT
@ShardsFixed(num = 1)
public void testSolrJAPICalls() throws Exception {
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
Create createCollectionRequest = new Create();
createCollectionRequest.setCollectionName("testasynccollectioncreation");
createCollectionRequest.setNumShards(1);
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setAsyncId("1001");
Create createCollectionRequest = new Create()
.setCollectionName("testasynccollectioncreation")
.setNumShards(1)
.setConfigName("conf1")
.setAsyncId("1001");
createCollectionRequest.process(client);
String state = getRequestStateAfterCompletion("1001", MAX_TIMEOUT_SECONDS, client);
@ -70,30 +70,30 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT
assertEquals("CreateCollection task did not complete!", "completed", state);
createCollectionRequest = new Create();
createCollectionRequest.setCollectionName("testasynccollectioncreation");
createCollectionRequest.setNumShards(1);
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setAsyncId("1002");
createCollectionRequest = new Create()
.setCollectionName("testasynccollectioncreation")
.setNumShards(1)
.setConfigName("conf1")
.setAsyncId("1002");
createCollectionRequest.process(client);
state = getRequestStateAfterCompletion("1002", MAX_TIMEOUT_SECONDS, client);
assertEquals("Recreating a collection with the same name didn't fail, should have.", "failed", state);
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica();
addReplica.setCollectionName("testasynccollectioncreation");
addReplica.setShardName("shard1");
addReplica.setAsyncId("1003");
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica()
.setCollectionName("testasynccollectioncreation")
.setShardName("shard1")
.setAsyncId("1003");
client.request(addReplica);
state = getRequestStateAfterCompletion("1003", MAX_TIMEOUT_SECONDS, client);
assertEquals("Add replica did not complete", "completed", state);
SplitShard splitShardRequest = new SplitShard();
splitShardRequest.setCollectionName("testasynccollectioncreation");
splitShardRequest.setShardName("shard1");
splitShardRequest.setAsyncId("1004");
SplitShard splitShardRequest = new SplitShard()
.setCollectionName("testasynccollectioncreation")
.setShardName("shard1")
.setAsyncId("1004");
splitShardRequest.process(client);
state = getRequestStateAfterCompletion("1004", MAX_TIMEOUT_SECONDS * 2, client);

View File

@ -879,8 +879,8 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
"conf1");
// remove collection
CollectionAdminRequest.Delete delete = new CollectionAdminRequest.Delete();
delete.setCollectionName(collectionName);
CollectionAdminRequest.Delete delete = new CollectionAdminRequest.Delete()
.setCollectionName(collectionName);
client.request(delete);
} catch (SolrServerException | IOException e) {
e.printStackTrace();

View File

@ -70,12 +70,13 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
protected void testCreateAndDeleteCollection() throws Exception {
String collectionName = "solrj_test";
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();
createCollectionRequest.setCollectionName(collectionName);
createCollectionRequest.setNumShards(2);
createCollectionRequest.setReplicationFactor(2);
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setRouterField("myOwnField");
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create()
.setCollectionName(collectionName)
.setNumShards(2)
.setReplicationFactor(2)
.setConfigName("conf1")
.setRouterField("myOwnField")
.setStateFormat(1);
CollectionAdminResponse response = createCollectionRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -89,8 +90,8 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
}
cloudClient.setDefaultCollection(collectionName);
CollectionAdminRequest.Delete deleteCollectionRequest = new CollectionAdminRequest.Delete();
deleteCollectionRequest.setCollectionName(collectionName);
CollectionAdminRequest.Delete deleteCollectionRequest = new CollectionAdminRequest.Delete()
.setCollectionName(collectionName);
response = deleteCollectionRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -102,11 +103,11 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
// Test Creating a collection with new stateformat.
collectionName = "solrj_newstateformat";
createCollectionRequest = new CollectionAdminRequest.Create();
createCollectionRequest.setCollectionName(collectionName);
createCollectionRequest.setNumShards(2);
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setStateFormat(2);
createCollectionRequest = new CollectionAdminRequest.Create()
.setCollectionName(collectionName)
.setNumShards(2)
.setConfigName("conf1")
.setStateFormat(2);
response = createCollectionRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -122,12 +123,11 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
protected void testCreateAndDeleteShard() throws IOException, SolrServerException {
// Create an implicit collection
String collectionName = "solrj_implicit";
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();
createCollectionRequest.setCollectionName(collectionName);
createCollectionRequest.setShards("shardA,shardB");
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setRouterName("implicit");
CollectionAdminResponse response = createCollectionRequest.process(cloudClient);
CollectionAdminResponse response = new CollectionAdminRequest.Create()
.setCollectionName(collectionName)
.setShards("shardA,shardB")
.setConfigName("conf1")
.setRouterName("implicit").process(cloudClient);
assertEquals(0, response.getStatus());
assertTrue(response.isSuccess());
@ -136,11 +136,10 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
cloudClient.setDefaultCollection(collectionName);
// Add a shard to the implicit collection
CollectionAdminRequest.CreateShard createShardRequest = new CollectionAdminRequest
.CreateShard();
createShardRequest.setCollectionName(collectionName);
createShardRequest.setShardName("shardC");
response = createShardRequest.process(cloudClient);
response = new CollectionAdminRequest
.CreateShard()
.setCollectionName(collectionName)
.setShardName("shardC").process(cloudClient);
assertEquals(0, response.getStatus());
assertTrue(response.isSuccess());
@ -149,9 +148,9 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
assertEquals(0, (int) coresStatus.get(collectionName + "_shardC_replica1").get("status"));
CollectionAdminRequest.DeleteShard deleteShardRequest = new CollectionAdminRequest
.DeleteShard();
deleteShardRequest.setCollectionName(collectionName);
deleteShardRequest.setShardName("shardC");
.DeleteShard()
.setCollectionName(collectionName)
.setShardName("shardC");
response = deleteShardRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -162,8 +161,8 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
protected void testReloadCollection() throws IOException, SolrServerException {
cloudClient.setDefaultCollection(DEFAULT_COLLECTION);
CollectionAdminRequest.Reload reloadCollectionRequest = new CollectionAdminRequest.Reload();
reloadCollectionRequest.setCollectionName("collection1");
CollectionAdminRequest.Reload reloadCollectionRequest = new CollectionAdminRequest.Reload()
.setCollectionName("collection1");
CollectionAdminResponse response = reloadCollectionRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -171,15 +170,15 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
protected void testCreateAndDeleteAlias() throws IOException, SolrServerException {
CollectionAdminRequest.CreateAlias createAliasRequest = new CollectionAdminRequest
.CreateAlias();
createAliasRequest.setAliasName("solrj_alias");
createAliasRequest.setAliasedCollections(DEFAULT_COLLECTION);
.CreateAlias()
.setAliasName("solrj_alias")
.setAliasedCollections(DEFAULT_COLLECTION);
CollectionAdminResponse response = createAliasRequest.process(cloudClient);
assertEquals(0, response.getStatus());
CollectionAdminRequest.DeleteAlias deleteAliasRequest = new CollectionAdminRequest.DeleteAlias();
deleteAliasRequest.setAliasName("solrj_alias");
CollectionAdminRequest.DeleteAlias deleteAliasRequest = new CollectionAdminRequest.DeleteAlias()
.setAliasName("solrj_alias");
deleteAliasRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -189,15 +188,15 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
String collectionName = "solrj_test_splitshard";
cloudClient.setDefaultCollection(collectionName);
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setNumShards(2);
createCollectionRequest.setCollectionName(collectionName);
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create()
.setConfigName("conf1")
.setNumShards(2)
.setCollectionName(collectionName);
createCollectionRequest.process(cloudClient);
CollectionAdminRequest.SplitShard splitShardRequest = new CollectionAdminRequest.SplitShard();
splitShardRequest.setCollectionName(collectionName);
splitShardRequest.setShardName("shard1");
CollectionAdminRequest.SplitShard splitShardRequest = new CollectionAdminRequest.SplitShard()
.setCollectionName(collectionName)
.setShardName("shard1");
CollectionAdminResponse response = splitShardRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -210,9 +209,9 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
waitForThingsToLevelOut(10);
// Test splitting using split.key
splitShardRequest = new CollectionAdminRequest.SplitShard();
splitShardRequest.setCollectionName(collectionName);
splitShardRequest.setSplitKey("b!");
splitShardRequest = new CollectionAdminRequest.SplitShard()
.setCollectionName(collectionName)
.setSplitKey("b!");
response = splitShardRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -240,11 +239,11 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
properties.put(CoreAdminParams.DATA_DIR, dataDir.getAbsolutePath());
properties.put(CoreAdminParams.ULOG_DIR, ulogDir.getAbsolutePath());
CollectionAdminRequest.Create createReq = new CollectionAdminRequest.Create();
createReq.setCollectionName(collectionName);
createReq.setNumShards(1);
createReq.setConfigName("conf1");
createReq.setProperties(properties);
CollectionAdminRequest.Create createReq = new CollectionAdminRequest.Create()
.setCollectionName(collectionName)
.setNumShards(1)
.setConfigName("conf1")
.setProperties(properties);
CollectionAdminResponse response = createReq.process(cloudClient);
assertEquals(0, response.getStatus());
@ -282,10 +281,10 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
String newReplicaName = Assign.assignNode(collectionName, cloudClient.getZkStateReader().getClusterState());
ArrayList<String> nodeList = new ArrayList<>(cloudClient.getZkStateReader().getClusterState().getLiveNodes());
Collections.shuffle(nodeList, random());
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica();
addReplica.setCollectionName(collectionName);
addReplica.setShardName("shard1");
addReplica.setNode(nodeList.get(0));
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica()
.setCollectionName(collectionName)
.setShardName("shard1")
.setNode(nodeList.get(0));
CollectionAdminResponse response = addReplica.process(cloudClient);
assertEquals(0, response.getStatus());
@ -307,10 +306,10 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
);
// Test DELETEREPLICA
CollectionAdminRequest.DeleteReplica deleteReplicaRequest = new CollectionAdminRequest.DeleteReplica();
deleteReplicaRequest.setCollectionName(collectionName);
deleteReplicaRequest.setShardName("shard1");
deleteReplicaRequest.setReplica(newReplicaName);
CollectionAdminRequest.DeleteReplica deleteReplicaRequest = new CollectionAdminRequest.DeleteReplica()
.setCollectionName(collectionName)
.setShardName("shard1")
.setReplica(newReplicaName);
response = deleteReplicaRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -326,9 +325,9 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
}
private void testClusterProp() throws InterruptedException, IOException, SolrServerException {
CollectionAdminRequest.ClusterProp clusterPropRequest = new CollectionAdminRequest.ClusterProp();
clusterPropRequest.setPropertyName(ZkStateReader.LEGACY_CLOUD);
clusterPropRequest.setPropertyValue("false");
CollectionAdminRequest.ClusterProp clusterPropRequest = new CollectionAdminRequest.ClusterProp()
.setPropertyName(ZkStateReader.LEGACY_CLOUD)
.setPropertyValue("false");
CollectionAdminResponse response = clusterPropRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -345,9 +344,9 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
assertTrue("The Cluster property wasn't set", changed);
// Unset ClusterProp that we set.
clusterPropRequest = new CollectionAdminRequest.ClusterProp();
clusterPropRequest.setPropertyName(ZkStateReader.LEGACY_CLOUD);
clusterPropRequest.setPropertyValue(null);
clusterPropRequest = new CollectionAdminRequest.ClusterProp()
.setPropertyName(ZkStateReader.LEGACY_CLOUD)
.setPropertyValue(null);
clusterPropRequest.process(cloudClient);
timeOut = System.currentTimeMillis() + 3000;
@ -364,13 +363,13 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
private void testAddAndRemoveRole() throws InterruptedException, IOException, SolrServerException {
cloudClient.setDefaultCollection(DEFAULT_COLLECTION);
Replica replica = cloudClient.getZkStateReader().getLeaderRetry(DEFAULT_COLLECTION, SHARD1);
CollectionAdminRequest.AddRole addRoleRequest = new CollectionAdminRequest.AddRole();
addRoleRequest.setNode(replica.getNodeName());
addRoleRequest.setRole("overseer");
CollectionAdminRequest.AddRole addRoleRequest = new CollectionAdminRequest.AddRole()
.setNode(replica.getNodeName())
.setRole("overseer");
addRoleRequest.process(cloudClient);
CollectionAdminRequest.ClusterStatus clusterStatusRequest = new CollectionAdminRequest.ClusterStatus();
clusterStatusRequest.setCollectionName(DEFAULT_COLLECTION);
CollectionAdminRequest.ClusterStatus clusterStatusRequest = new CollectionAdminRequest.ClusterStatus()
.setCollectionName(DEFAULT_COLLECTION);
CollectionAdminResponse response = clusterStatusRequest.process(cloudClient);
NamedList<Object> rsp = response.getResponse();
@ -384,10 +383,10 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
assertTrue(overseer.contains(replica.getNodeName()));
// Remove role
CollectionAdminRequest.RemoveRole removeRoleRequest = new CollectionAdminRequest.RemoveRole();
removeRoleRequest.setNode(replica.getNodeName());
removeRoleRequest.setRole("overseer");
removeRoleRequest.process(cloudClient);
new CollectionAdminRequest.RemoveRole()
.setNode(replica.getNodeName())
.setRole("overseer")
.process(cloudClient);
clusterStatusRequest = new CollectionAdminRequest.ClusterStatus();
clusterStatusRequest.setCollectionName(DEFAULT_COLLECTION);
@ -403,28 +402,25 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
}
private void testOverseerStatus() throws IOException, SolrServerException {
CollectionAdminRequest.OverseerStatus overseerStatusRequest = new CollectionAdminRequest.OverseerStatus();
CollectionAdminResponse response = overseerStatusRequest.process(cloudClient);
CollectionAdminResponse response = new CollectionAdminRequest.OverseerStatus().process(cloudClient);
assertEquals(0, response.getStatus());
assertNotNull("overseer_operations shouldn't be null", response.getResponse().get("overseer_operations"));
}
private void testList() throws IOException, SolrServerException {
CollectionAdminRequest.List listRequest = new CollectionAdminRequest.List();
CollectionAdminResponse response = listRequest.process(cloudClient);
CollectionAdminResponse response = new CollectionAdminRequest.List().process(cloudClient);
assertEquals(0, response.getStatus());
assertNotNull("collection list should not be null", response.getResponse().get("collections"));
}
private void testAddAndDeleteReplicaProp() throws InterruptedException, IOException, SolrServerException {
Replica replica = cloudClient.getZkStateReader().getLeaderRetry(DEFAULT_COLLECTION, SHARD1);
CollectionAdminRequest.AddReplicaProp addReplicaPropRequest = new CollectionAdminRequest.AddReplicaProp();
addReplicaPropRequest.setCollectionName(DEFAULT_COLLECTION);
addReplicaPropRequest.setShardName(SHARD1);
addReplicaPropRequest.setReplica(replica.getName());
addReplicaPropRequest.setPropertyName("preferredleader");
addReplicaPropRequest.setPropertyValue("true");
CollectionAdminResponse response = addReplicaPropRequest.process(cloudClient);
CollectionAdminResponse response = new CollectionAdminRequest.AddReplicaProp()
.setCollectionName(DEFAULT_COLLECTION)
.setShardName(SHARD1)
.setReplica(replica.getName())
.setPropertyName("preferredleader")
.setPropertyValue("true").process(cloudClient);
assertEquals(0, response.getStatus());
long timeout = System.currentTimeMillis() + 20000;
@ -445,12 +441,11 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
"true",
propertyValue);
CollectionAdminRequest.DeleteReplicaProp deleteReplicaPropRequest = new CollectionAdminRequest.DeleteReplicaProp();
deleteReplicaPropRequest.setCollectionName(DEFAULT_COLLECTION);
deleteReplicaPropRequest.setShardName(SHARD1);
deleteReplicaPropRequest.setReplica(replicaName);
deleteReplicaPropRequest.setPropertyName("property.preferredleader");
response = deleteReplicaPropRequest.process(cloudClient);
response = new CollectionAdminRequest.DeleteReplicaProp()
.setCollectionName(DEFAULT_COLLECTION)
.setShardName(SHARD1)
.setReplica(replicaName)
.setPropertyName("property.preferredleader").process(cloudClient);
assertEquals(0, response.getStatus());
timeout = System.currentTimeMillis() + 20000;
@ -471,12 +466,9 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
private void testBalanceShardUnique() throws IOException,
SolrServerException, KeeperException, InterruptedException {
CollectionAdminRequest.BalanceShardUnique balanceShardUniqueRequest =
new CollectionAdminRequest.BalanceShardUnique();
cloudClient.setDefaultCollection(DEFAULT_COLLECTION);
balanceShardUniqueRequest.setCollection(DEFAULT_COLLECTION);
balanceShardUniqueRequest.setPropertyName("preferredLeader");
CollectionAdminResponse response = balanceShardUniqueRequest.process(cloudClient);
CollectionAdminResponse response = new CollectionAdminRequest.BalanceShardUnique()
.setCollection(DEFAULT_COLLECTION)
.setPropertyName("preferredLeader").process(cloudClient);
assertEquals(0, response.getStatus());
verifyUniqueAcrossCollection(cloudClient, DEFAULT_COLLECTION, "property.preferredleader");

View File

@ -168,13 +168,11 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
private void createCollection() {
try {
final CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();
createCollectionRequest.setCollectionName(collectionName);
createCollectionRequest.setNumShards(1);
createCollectionRequest.setReplicationFactor(1);
createCollectionRequest.setConfigName(configName);
final CollectionAdminResponse response = createCollectionRequest.process(solrClient);
final CollectionAdminResponse response = new CollectionAdminRequest.Create()
.setCollectionName(collectionName)
.setNumShards(1)
.setReplicationFactor(1)
.setConfigName(configName).process(solrClient);
if (response.getStatus() != 0) {
addFailure(new RuntimeException("failed to create collection " + collectionName));
}
@ -186,8 +184,8 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
private void deleteCollection() {
try {
final CollectionAdminRequest.Delete deleteCollectionRequest = new CollectionAdminRequest.Delete();
deleteCollectionRequest.setCollectionName(collectionName);
final CollectionAdminRequest.Delete deleteCollectionRequest = new CollectionAdminRequest.Delete()
.setCollectionName(collectionName);
final CollectionAdminResponse response = deleteCollectionRequest.process(solrClient);
if (response.getStatus() != 0) {

View File

@ -152,8 +152,8 @@ public class DistribJoinFromCollectionTest extends AbstractFullDistribZkTestBase
// try to clean up
for (String c : new String[]{ toColl, fromColl }) {
try {
CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(c);
CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete()
.setCollectionName(c);
req.process(cloudClient);
} catch (Exception e) {
// don't fail the test

View File

@ -250,8 +250,8 @@ public class DistributedVersionInfoTest extends AbstractFullDistribZkTestBase {
// try to clean up
try {
CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName);
CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete()
.setCollectionName(testCollectionName);
req.process(cloudClient);
} catch (Exception e) {
// don't fail the test

View File

@ -157,13 +157,13 @@ public class FullSolrCloudDistribCmdsTest extends AbstractFullDistribZkTestBase
CollectionAdminResponse response;
Map<String, NamedList<Integer>> coresStatus;
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();
createCollectionRequest.setCollectionName("implicit_collection_without_routerfield");
createCollectionRequest.setRouterName("implicit");
createCollectionRequest.setNumShards(2);
createCollectionRequest.setShards("shard1,shard2");
createCollectionRequest.setReplicationFactor(2);
createCollectionRequest.setConfigName("conf1");
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create()
.setCollectionName("implicit_collection_without_routerfield")
.setRouterName("implicit")
.setNumShards(2)
.setShards("shard1,shard2")
.setReplicationFactor(2)
.setConfigName("conf1");
response = createCollectionRequest.process(server);
assertEquals(0, response.getStatus());
@ -285,15 +285,15 @@ public class FullSolrCloudDistribCmdsTest extends AbstractFullDistribZkTestBase
CollectionAdminResponse response;
Map<String, NamedList<Integer>> coresStatus;
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();
createCollectionRequest.setCollectionName("compositeid_collection_with_routerfield");
createCollectionRequest.setRouterName("compositeId");
createCollectionRequest.setRouterField("routefield_s");
createCollectionRequest.setNumShards(2);
createCollectionRequest.setShards("shard1,shard2");
createCollectionRequest.setReplicationFactor(2);
createCollectionRequest.setConfigName("conf1");
response = createCollectionRequest.process(server);
response = new CollectionAdminRequest.Create()
.setCollectionName("compositeid_collection_with_routerfield")
.setRouterName("compositeId")
.setRouterField("routefield_s")
.setNumShards(2)
.setShards("shard1,shard2")
.setReplicationFactor(2)
.setConfigName("conf1")
.process(server);
assertEquals(0, response.getStatus());
assertTrue(response.isSuccess());

View File

@ -162,9 +162,8 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
// try to clean up
try {
CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName);
req.process(cloudClient);
new CollectionAdminRequest.Delete()
.setCollectionName(testCollectionName).process(cloudClient);
} catch (Exception e) {
// don't fail the test
log.warn("Could not delete collection {} after test completed", testCollectionName);
@ -243,9 +242,8 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
// try to clean up
try {
CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName);
req.process(cloudClient);
new CollectionAdminRequest.Delete()
.setCollectionName(testCollectionName).process(cloudClient);
} catch (Exception e) {
// don't fail the test
log.warn("Could not delete collection {} after test completed", testCollectionName);

View File

@ -76,12 +76,12 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase {
private void testParallelCollectionAPICalls() throws IOException, SolrServerException {
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
for(int i = 1 ; i <= NUM_COLLECTIONS ; i++) {
Create createCollectionRequest = new Create();
createCollectionRequest.setCollectionName("ocptest" + i);
createCollectionRequest.setNumShards(4);
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setAsyncId(String.valueOf(i));
createCollectionRequest.process(client);
new Create()
.setCollectionName("ocptest" + i)
.setNumShards(4)
.setConfigName("conf1")
.setAsyncId(String.valueOf(i))
.process(client);
}
boolean pass = false;
@ -112,23 +112,23 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase {
private void testTaskExclusivity() throws IOException, SolrServerException {
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
Create createCollectionRequest = new Create();
createCollectionRequest.setCollectionName("ocptest_shardsplit");
createCollectionRequest.setNumShards(4);
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setAsyncId("1000");
Create createCollectionRequest = new Create()
.setCollectionName("ocptest_shardsplit")
.setNumShards(4)
.setConfigName("conf1")
.setAsyncId("1000");
createCollectionRequest.process(client);
SplitShard splitShardRequest = new SplitShard();
splitShardRequest.setCollectionName("ocptest_shardsplit");
splitShardRequest.setShardName(SHARD1);
splitShardRequest.setAsyncId("1001");
SplitShard splitShardRequest = new SplitShard()
.setCollectionName("ocptest_shardsplit")
.setShardName(SHARD1)
.setAsyncId("1001");
splitShardRequest.process(client);
splitShardRequest = new SplitShard();
splitShardRequest.setCollectionName("ocptest_shardsplit");
splitShardRequest.setShardName(SHARD2);
splitShardRequest.setAsyncId("1002");
splitShardRequest = new SplitShard()
.setCollectionName("ocptest_shardsplit")
.setShardName(SHARD2)
.setAsyncId("1002");
splitShardRequest.process(client);
int iterations = 0;
@ -167,30 +167,30 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase {
private void testDeduplicationOfSubmittedTasks() throws IOException, SolrServerException {
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
Create createCollectionRequest = new Create();
createCollectionRequest.setCollectionName("ocptest_shardsplit2");
createCollectionRequest.setNumShards(4);
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setAsyncId("3000");
createCollectionRequest.process(client);
new Create()
.setCollectionName("ocptest_shardsplit2")
.setNumShards(4)
.setConfigName("conf1")
.setAsyncId("3000")
.process(client);
SplitShard splitShardRequest = new SplitShard();
splitShardRequest.setCollectionName("ocptest_shardsplit2");
splitShardRequest.setShardName(SHARD1);
splitShardRequest.setAsyncId("3001");
SplitShard splitShardRequest = new SplitShard()
.setCollectionName("ocptest_shardsplit2")
.setShardName(SHARD1)
.setAsyncId("3001");
splitShardRequest.process(client);
splitShardRequest = new SplitShard();
splitShardRequest.setCollectionName("ocptest_shardsplit2");
splitShardRequest.setShardName(SHARD2);
splitShardRequest.setAsyncId("3002");
splitShardRequest = new SplitShard()
.setCollectionName("ocptest_shardsplit2")
.setShardName(SHARD2)
.setAsyncId("3002");
splitShardRequest.process(client);
// Now submit another task with the same id. At this time, hopefully the previous 3002 should still be in the queue.
splitShardRequest = new SplitShard();
splitShardRequest.setCollectionName("ocptest_shardsplit2");
splitShardRequest.setShardName(SHARD1);
splitShardRequest.setAsyncId("3002");
splitShardRequest = new SplitShard()
.setCollectionName("ocptest_shardsplit2")
.setShardName(SHARD1)
.setAsyncId("3002");
CollectionAdminResponse response = splitShardRequest.process(client);
NamedList r = response.getResponse();
@ -223,10 +223,10 @@ public class MultiThreadedOCPTest extends AbstractFullDistribZkTestBase {
indexThread.start();
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
SplitShard splitShardRequest = new SplitShard();
splitShardRequest.setCollectionName("collection1");
splitShardRequest.setShardName(SHARD1);
splitShardRequest.setAsyncId("2000");
SplitShard splitShardRequest = new SplitShard()
.setCollectionName("collection1")
.setShardName(SHARD1)
.setAsyncId("2000");
splitShardRequest.process(client);
String state = getRequestState("2000", client);

View File

@ -120,14 +120,14 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBa
// serially
private void testBasics() throws Exception {
String collection1 = "solrj_collection";
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);
Create createCollectionRequest = new Create()
.setCollectionName(collection1)
.setNumShards(2)
.setReplicationFactor(2)
.setMaxShardsPerNode(2)
.setConfigName("conf1")
.setRouterField("myOwnField")
.setAutoAddReplicas(true);
CollectionAdminResponse response = createCollectionRequest.process(cloudClient);
assertEquals(0, response.getStatus());
@ -135,14 +135,14 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBa
waitForRecoveriesToFinish(collection1, false);
String collection2 = "solrj_collection2";
createCollectionRequest = new Create();
createCollectionRequest.setCollectionName(collection2);
createCollectionRequest.setNumShards(2);
createCollectionRequest.setReplicationFactor(2);
createCollectionRequest.setMaxShardsPerNode(2);
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setRouterField("myOwnField");
createCollectionRequest.setAutoAddReplicas(false);
createCollectionRequest = new Create()
.setCollectionName(collection2)
.setNumShards(2)
.setReplicationFactor(2)
.setMaxShardsPerNode(2)
.setConfigName("conf1")
.setRouterField("myOwnField")
.setAutoAddReplicas(false);
CollectionAdminResponse response2 = createCollectionRequest.process(getCommonCloudSolrClient());
assertEquals(0, response2.getStatus());
@ -151,14 +151,14 @@ public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBa
waitForRecoveriesToFinish(collection2, false);
String collection3 = "solrj_collection3";
createCollectionRequest = new Create();
createCollectionRequest.setCollectionName(collection3);
createCollectionRequest.setNumShards(5);
createCollectionRequest.setReplicationFactor(1);
createCollectionRequest.setMaxShardsPerNode(1);
createCollectionRequest.setConfigName("conf1");
createCollectionRequest.setRouterField("myOwnField");
createCollectionRequest.setAutoAddReplicas(true);
createCollectionRequest = new Create()
.setCollectionName(collection3)
.setNumShards(5)
.setReplicationFactor(1)
.setMaxShardsPerNode(1)
.setConfigName("conf1")
.setRouterField("myOwnField")
.setAutoAddReplicas(true);
CollectionAdminResponse response3 = createCollectionRequest.process(getCommonCloudSolrClient());
assertEquals(0, response3.getStatus());

View File

@ -41,17 +41,15 @@ public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestB
break;
}
}
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
String collectionName = "SimpleCollectionCreateDeleteTest";
create.setCollectionName(collectionName);
create.setNumShards(1);
create.setReplicationFactor(1);
create.setCreateNodeSet(overseerNode);
ModifiableSolrParams params = new ModifiableSolrParams(create.getParams());
params.set("stateFormat", "2");
QueryRequest req = new QueryRequest(params);
req.setPath("/admin/collections");
NamedList<Object> request = cloudClient.request(req);
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create()
.setCollectionName(collectionName)
.setNumShards(1)
.setReplicationFactor(1)
.setCreateNodeSet(overseerNode)
.setStateFormat(2);
NamedList<Object> request = create.process(cloudClient).getResponse();
if (request.get("success") != null) {
assertTrue(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, false));
@ -63,16 +61,13 @@ public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestB
assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, false));
// create collection again on a node other than the overseer leader
create = new CollectionAdminRequest.Create();
create.setCollectionName(collectionName);
create.setNumShards(1);
create.setReplicationFactor(1);
create.setCreateNodeSet(notOverseerNode);
params = new ModifiableSolrParams(create.getParams());
params.set("stateFormat", "2");
req = new QueryRequest(params);
req.setPath("/admin/collections");
request = cloudClient.request(req);
create = new CollectionAdminRequest.Create()
.setCollectionName(collectionName)
.setNumShards(1)
.setReplicationFactor(1)
.setCreateNodeSet(notOverseerNode)
.setStateFormat(2);
request = create.process(cloudClient).getResponse();
assertTrue("Collection creation should not have failed", request.get("success") != null);
}
}

View File

@ -175,12 +175,12 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
String cname = "clusterStatusZNodeVersion";
try (CloudSolrClient client = createCloudClient(null)) {
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
create.setCollectionName(cname);
create.setMaxShardsPerNode(1);
create.setNumShards(1);
create.setReplicationFactor(1);
create.setConfigName("conf1");
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create()
.setCollectionName(cname)
.setMaxShardsPerNode(1)
.setNumShards(1)
.setReplicationFactor(1)
.setConfigName("conf1");
create.process(client);
waitForRecoveriesToFinish(cname, true);
@ -203,9 +203,9 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
Integer znodeVersion = (Integer) collection.get("znodeVersion");
assertNotNull(znodeVersion);
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica();
addReplica.setCollectionName(cname);
addReplica.setShardName("shard1");
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica()
.setCollectionName(cname)
.setShardName("shard1");
addReplica.process(client);
waitForRecoveriesToFinish(cname, true);

View File

@ -49,13 +49,13 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
String rulesColl = "rulesColl";
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
CollectionAdminResponse rsp;
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
create.setCollectionName(rulesColl);
create.setShards("shard1");
create.setRouterName(ImplicitDocRouter.NAME);
create.setReplicationFactor(2);
create.setRule("cores:<4", "node:*,replica:<2", "freedisk:>1");
create.setSnitch("class:ImplicitSnitch");
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create()
.setCollectionName(rulesColl)
.setShards("shard1")
.setRouterName(ImplicitDocRouter.NAME)
.setReplicationFactor(2)
.setRule("cores:<4", "node:*,replica:<2", "freedisk:>1")
.setSnitch("class:ImplicitSnitch");
rsp = create.process(client);
assertEquals(0, rsp.getStatus());
assertTrue(rsp.isSuccess());
@ -74,16 +74,16 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
CollectionAdminResponse rsp;
CollectionAdminRequest.CreateShard createShard = new CollectionAdminRequest.CreateShard();
createShard.setCollectionName(rulesColl);
createShard.setShardName("shard2");
CollectionAdminRequest.CreateShard createShard = new CollectionAdminRequest.CreateShard()
.setCollectionName(rulesColl)
.setShardName("shard2");
rsp = createShard.process(client);
assertEquals(0, rsp.getStatus());
assertTrue(rsp.isSuccess());
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica();
addReplica.setCollectionName(rulesColl);
addReplica.setShardName("shard2");
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica()
.setCollectionName(rulesColl)
.setShardName("shard2");
rsp = createShard.process(client);
assertEquals(0, rsp.getStatus());
assertTrue(rsp.isSuccess());
@ -97,12 +97,12 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
String rulesColl = "modifyColl";
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
CollectionAdminResponse rsp;
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
create.setCollectionName(rulesColl);
create.setNumShards(1);
create.setReplicationFactor(2);
create.setRule("cores:<4", "node:*,replica:1", "freedisk:>1");
create.setSnitch("class:ImplicitSnitch");
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create()
.setCollectionName(rulesColl)
.setNumShards(1)
.setReplicationFactor(2)
.setRule("cores:<4", "node:*,replica:1", "freedisk:>1")
.setSnitch("class:ImplicitSnitch");
rsp = create.process(client);
assertEquals(0, rsp.getStatus());
assertTrue(rsp.isSuccess());

View File

@ -62,10 +62,10 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
CollectionAdminResponse response1;
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();
createCollectionRequest.setCollectionName(".system");
createCollectionRequest.setNumShards(1);
createCollectionRequest.setReplicationFactor(2);
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create()
.setCollectionName(".system")
.setNumShards(1)
.setReplicationFactor(2);
response1 = createCollectionRequest.process(client);
assertEquals(0, response1.getStatus());
assertTrue(response1.isSuccess());
@ -105,10 +105,10 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
public static void createSystemCollection(SolrClient client) throws SolrServerException, IOException {
CollectionAdminResponse response1;
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();
createCollectionRequest.setCollectionName(".system");
createCollectionRequest.setNumShards(1);
createCollectionRequest.setReplicationFactor(2);
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create()
.setCollectionName(".system")
.setNumShards(1)
.setReplicationFactor(2);
response1 = createCollectionRequest.process(client);
assertEquals(0, response1.getStatus());
assertTrue(response1.isSuccess());

View File

@ -41,14 +41,15 @@ import java.util.Properties;
*
* @since solr 4.5
*/
public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse> {
public abstract class CollectionAdminRequest <Q extends CollectionAdminRequest<Q>> extends SolrRequest<CollectionAdminResponse> {
protected CollectionAction action = null;
private static String PROPERTY_PREFIX = "property.";
protected void setAction(CollectionAction action) {
protected CollectionAdminRequest setAction(CollectionAction action) {
this.action = action;
return this;
}
public CollectionAdminRequest() {
@ -59,6 +60,8 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
super(METHOD.GET, path);
}
protected abstract Q getThis();
@Override
public SolrParams getParams() {
if (action == null) {
@ -93,13 +96,18 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
//
//---------------------------------------------------------------------------------------
protected static class CollectionSpecificAdminRequest extends CollectionAdminRequest {
protected abstract static class CollectionSpecificAdminRequest <T extends CollectionAdminRequest<T>> extends CollectionAdminRequest<T> {
protected String collection = null;
public final void setCollectionName(String collectionName) {
public final T setCollectionName(String collectionName) {
this.collection = collectionName;
return getThis();
}
public final String getCollectionName() {
return collection;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
@ -109,21 +117,23 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
}
protected static class CollectionShardAdminRequest extends CollectionAdminRequest {
protected abstract static class CollectionShardAdminRequest <T extends CollectionAdminRequest<T>> extends CollectionAdminRequest<T> {
protected String shardName = null;
protected String collection = null;
public void setCollectionName(String collectionName) {
public T setCollectionName(String collectionName) {
this.collection = collectionName;
return getThis();
}
public String getCollectionName() {
return collection;
}
public void setShardName(String shard) {
public T setShardName(String shard) {
this.shardName = shard;
return getThis();
}
public String getShardName() {
@ -143,20 +153,22 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
}
}
protected static class CollectionAdminRoleRequest extends CollectionAdminRequest {
private String node;
private String role;
protected abstract static class CollectionAdminRoleRequest <T extends CollectionAdminRequest<T>> extends CollectionAdminRequest<T> {
protected String node;
protected String role;
public void setNode(String node) {
public T setNode(String node) {
this.node = node;
return getThis();
}
public String getNode() {
return this.node;
}
public void setRole(String role) {
public T setRole(String role) {
this.role = role;
return getThis();
}
public String getRole() {
@ -176,7 +188,7 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
/** Specific Collection API call implementations **/
// CREATE request
public static class Create extends CollectionSpecificAdminRequest {
public static class Create extends CollectionSpecificAdminRequest<Create> {
protected String configName = null;
protected String createNodeSet = null;
protected String routerName;
@ -195,21 +207,22 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
action = CollectionAction.CREATE;
}
public void setConfigName(String config) { this.configName = config; }
public void setCreateNodeSet(String nodeSet) { this.createNodeSet = nodeSet; }
public void setRouterName(String routerName) { this.routerName = routerName; }
public void setShards(String shards) { this.shards = shards; }
public void setRouterField(String routerField) { this.routerField = routerField; }
public void setNumShards(Integer numShards) {this.numShards = numShards;}
public void setMaxShardsPerNode(Integer numShards) { this.maxShardsPerNode = numShards; }
public void setAutoAddReplicas(boolean autoAddReplicas) { this.autoAddReplicas = autoAddReplicas; }
public void setReplicationFactor(Integer repl) { this.replicationFactor = repl; }
public void setStateFormat(Integer stateFormat) { this.stateFormat = stateFormat; }
public void setAsyncId(String asyncId) {
public Create setConfigName(String config) { this.configName = config; return this; }
public Create setCreateNodeSet(String nodeSet) { this.createNodeSet = nodeSet; return this; }
public Create setRouterName(String routerName) { this.routerName = routerName; return this; }
public Create setShards(String shards) { this.shards = shards; return this; }
public Create setRouterField(String routerField) { this.routerField = routerField; return this; }
public Create setNumShards(Integer numShards) {this.numShards = numShards; return this; }
public Create setMaxShardsPerNode(Integer numShards) { this.maxShardsPerNode = numShards; return this; }
public Create setAutoAddReplicas(boolean autoAddReplicas) { this.autoAddReplicas = autoAddReplicas; return this; }
public Create setReplicationFactor(Integer repl) { this.replicationFactor = repl; return this; }
public Create setStateFormat(Integer stateFormat) { this.stateFormat = stateFormat; return this; }
public Create setAsyncId(String asyncId) {
this.asyncId = asyncId;
return this;
}
public void setRule(String... s){ this.rule = s; }
public void setSnitch(String... s){ this.snitch = s; }
public Create setRule(String... s){ this.rule = s; return this; }
public Create setSnitch(String... s){ this.snitch = s; return this; }
public String getConfigName() { return configName; }
public String getCreateNodeSet() { return createNodeSet; }
@ -228,8 +241,9 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return properties;
}
public void setProperties(Properties properties) {
public Create setProperties(Properties properties) {
this.properties = properties;
return this;
}
@Override
@ -266,30 +280,47 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
if(snitch != null) params.set("snitch", snitch);
return params;
}
@Override
protected Create getThis() {
return this;
}
}
// RELOAD request
public static class Reload extends CollectionSpecificAdminRequest {
public static class Reload extends CollectionSpecificAdminRequest<Reload> {
public Reload() {
action = CollectionAction.RELOAD;
}
@Override
protected Reload getThis() {
return this;
}
}
// DELETE request
public static class Delete extends CollectionSpecificAdminRequest {
public static class Delete extends CollectionSpecificAdminRequest<Delete> {
protected String collection = null;
public Delete() {
action = CollectionAction.DELETE;
}
@Override
protected Delete getThis() {
return this;
}
}
// CREATESHARD request
public static class CreateShard extends CollectionShardAdminRequest {
public static class CreateShard extends CollectionShardAdminRequest<CreateShard> {
protected String nodeSet;
private Properties properties;
public void setNodeSet(String nodeSet) {
public CreateShard setNodeSet(String nodeSet) {
this.nodeSet = nodeSet;
return this;
}
public String getNodeSet() {
@ -300,8 +331,9 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return properties;
}
public void setProperties(Properties properties) {
public CreateShard setProperties(Properties properties) {
this.properties = properties;
return this;
}
public CreateShard() {
@ -319,10 +351,15 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
}
return params;
}
@Override
protected CreateShard getThis() {
return this;
}
}
// SPLITSHARD request
public static class SplitShard extends CollectionShardAdminRequest {
public static class SplitShard extends CollectionShardAdminRequest<SplitShard> {
protected String ranges;
protected String splitKey;
protected String asyncId;
@ -333,11 +370,12 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
action = CollectionAction.SPLITSHARD;
}
public void setRanges(String ranges) { this.ranges = ranges; }
public SplitShard setRanges(String ranges) { this.ranges = ranges; return this; }
public String getRanges() { return ranges; }
public void setSplitKey(String splitKey) {
public SplitShard setSplitKey(String splitKey) {
this.splitKey = splitKey;
return this;
}
public String getSplitKey() {
@ -348,12 +386,14 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return properties;
}
public void setProperties(Properties properties) {
public SplitShard setProperties(Properties properties) {
this.properties = properties;
return this;
}
public void setAsyncId(String asyncId) {
public SplitShard setAsyncId(String asyncId) {
this.asyncId = asyncId;
return this;
}
public String getAsyncId() {
@ -375,25 +415,36 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
params.set("async", asyncId);
return params;
}
@Override
protected SplitShard getThis() {
return this;
}
}
// DELETESHARD request
public static class DeleteShard extends CollectionShardAdminRequest {
public static class DeleteShard extends CollectionShardAdminRequest<DeleteShard> {
public DeleteShard() {
action = CollectionAction.DELETESHARD;
}
@Override
protected DeleteShard getThis() {
return this;
}
}
// REQUESTSTATUS request
public static class RequestStatus extends CollectionAdminRequest {
public static class RequestStatus extends CollectionAdminRequest<RequestStatus> {
protected String requestId = null;
public RequestStatus() {
action = CollectionAction.REQUESTSTATUS;
}
public void setRequestId(String requestId) {
public RequestStatus setRequestId(String requestId) {
this.requestId = requestId;
return this;
}
public String getRequestId() {
@ -406,10 +457,15 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
params.set(CoreAdminParams.REQUESTID, requestId);
return params;
}
@Override
protected RequestStatus getThis() {
return this;
}
}
// CREATEALIAS request
public static class CreateAlias extends CollectionAdminRequest {
public static class CreateAlias extends CollectionAdminRequest<CreateAlias> {
protected String aliasName;
protected String aliasedCollections;
@ -417,22 +473,28 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
action = CollectionAction.CREATEALIAS;
}
public void setAliasName(String aliasName) {
public CreateAlias setAliasName(String aliasName) {
this.aliasName = aliasName;
return this;
}
public String getAliasName() {
return aliasName;
}
public void setAliasedCollections(String alias) {
public CreateAlias setAliasedCollections(String alias) {
this.aliasedCollections = alias;
return this;
}
public String getAliasedCollections() {
return this.aliasedCollections;
}
/**
* @param aliasName the alias name
* @deprecated use {@link #setAliasName(String)} instead
*/
@Deprecated
public void setCollectionName(String aliasName) {
this.aliasName = aliasName;
@ -445,18 +507,24 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
params.set("collections", aliasedCollections);
return params;
}
@Override
protected CreateAlias getThis() {
return this;
}
}
// DELETEALIAS request
public static class DeleteAlias extends CollectionAdminRequest {
public static class DeleteAlias extends CollectionAdminRequest<DeleteAlias> {
protected String aliasName;
public DeleteAlias() {
action = CollectionAction.DELETEALIAS;
}
public void setAliasName(String aliasName) {
public DeleteAlias setAliasName(String aliasName) {
this.aliasName = aliasName;
return this;
}
@Override
@ -465,10 +533,15 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
params.set(CoreAdminParams.NAME, aliasName);
return params;
}
@Override
protected DeleteAlias getThis() {
return this;
}
}
// ADDREPLICA request
public static class AddReplica extends CollectionShardAdminRequest {
public static class AddReplica extends CollectionShardAdminRequest<AddReplica> {
private String node;
private String routeKey;
private String instanceDir;
@ -484,40 +557,45 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return properties;
}
public void setProperties(Properties properties) {
public AddReplica setProperties(Properties properties) {
this.properties = properties;
return this;
}
public String getNode() {
return node;
}
public void setNode(String node) {
public AddReplica setNode(String node) {
this.node = node;
return this;
}
public String getRouteKey() {
return routeKey;
}
public void setRouteKey(String routeKey) {
public AddReplica setRouteKey(String routeKey) {
this.routeKey = routeKey;
return this;
}
public String getInstanceDir() {
return instanceDir;
}
public void setInstanceDir(String instanceDir) {
public AddReplica setInstanceDir(String instanceDir) {
this.instanceDir = instanceDir;
return this;
}
public String getDataDir() {
return dataDir;
}
public void setDataDir(String dataDir) {
public AddReplica setDataDir(String dataDir) {
this.dataDir = dataDir;
return this;
}
@Override
@ -548,17 +626,23 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return params;
}
public void setAsyncId(String asyncId) {
public AddReplica setAsyncId(String asyncId) {
this.asyncId = asyncId;
return this;
}
public String getAsyncId() {
return asyncId;
}
@Override
protected AddReplica getThis() {
return this;
}
}
// DELETEREPLICA request
public static class DeleteReplica extends CollectionShardAdminRequest {
public static class DeleteReplica extends CollectionShardAdminRequest<DeleteReplica> {
private String replica;
private Boolean onlyIfDown;
@ -566,16 +650,18 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
action = CollectionAction.DELETEREPLICA;
}
public void setReplica(String replica) {
public DeleteReplica setReplica(String replica) {
this.replica = replica;
return this;
}
public String getReplica() {
return this.replica;
}
public void setOnlyIfDown(boolean onlyIfDown) {
public DeleteReplica setOnlyIfDown(boolean onlyIfDown) {
this.onlyIfDown = onlyIfDown;
return this;
}
public Boolean getOnlyIfDown() {
@ -592,10 +678,15 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
}
return params;
}
@Override
protected DeleteReplica getThis() {
return this;
}
}
// CLUSTERPROP request
public static class ClusterProp extends CollectionAdminRequest {
public static class ClusterProp extends CollectionAdminRequest<ClusterProp> {
private String propertyName;
private String propertyValue;
@ -603,16 +694,18 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
this.action = CollectionAction.CLUSTERPROP;
}
public void setPropertyName(String propertyName) {
public ClusterProp setPropertyName(String propertyName) {
this.propertyName = propertyName;
return this;
}
public String getPropertyName() {
return this.propertyName;
}
public void setPropertyValue(String propertyValue) {
public ClusterProp setPropertyValue(String propertyValue) {
this.propertyValue = propertyValue;
return this;
}
public String getPropertyValue() {
@ -627,11 +720,15 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return params;
}
@Override
protected ClusterProp getThis() {
return this;
}
}
// MIGRATE request
public static class Migrate extends CollectionAdminRequest {
public static class Migrate extends CollectionAdminRequest<Migrate> {
private String collection;
private String targetCollection;
private String splitKey;
@ -643,40 +740,45 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
action = CollectionAction.MIGRATE;
}
public void setCollectionName(String collection) {
public Migrate setCollectionName(String collection) {
this.collection = collection;
return this;
}
public String getCollectionName() {
return collection;
}
public void setTargetCollection(String targetCollection) {
public Migrate setTargetCollection(String targetCollection) {
this.targetCollection = targetCollection;
return this;
}
public String getTargetCollection() {
return this.targetCollection;
}
public void setSplitKey(String splitKey) {
public Migrate setSplitKey(String splitKey) {
this.splitKey = splitKey;
return this;
}
public String getSplitKey() {
return this.splitKey;
}
public void setForwardTimeout(int forwardTimeout) {
public Migrate setForwardTimeout(int forwardTimeout) {
this.forwardTimeout = forwardTimeout;
return this;
}
public Integer getForwardTimeout() {
return this.forwardTimeout;
}
public void setProperties(Properties properties) {
public Migrate setProperties(Properties properties) {
this.properties = properties;
return this;
}
public Properties getProperties() {
@ -701,62 +803,95 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return params;
}
public void setAsyncId(String asyncId) {
public Migrate setAsyncId(String asyncId) {
this.asyncId = asyncId;
return this;
}
public String getAsyncId() {
return asyncId;
}
@Override
protected Migrate getThis() {
return this;
}
}
// ADDROLE request
public static class AddRole extends CollectionAdminRoleRequest {
public static class AddRole extends CollectionAdminRoleRequest<AddRole> {
public AddRole() {
action = CollectionAction.ADDROLE;
}
@Override
protected AddRole getThis() {
return this;
}
}
// REMOVEROLE request
public static class RemoveRole extends CollectionAdminRoleRequest {
public static class RemoveRole extends CollectionAdminRoleRequest<RemoveRole> {
public RemoveRole() {
action = CollectionAction.REMOVEROLE;
}
@Override
protected RemoveRole getThis() {
return this;
}
}
// OVERSEERSTATUS request
public static class OverseerStatus extends CollectionAdminRequest {
public static class OverseerStatus extends CollectionAdminRequest<OverseerStatus> {
public OverseerStatus () {
action = CollectionAction.OVERSEERSTATUS;
}
@Override
protected OverseerStatus getThis() {
return this;
}
}
// CLUSTERSTATUS request
public static class ClusterStatus extends CollectionAdminRequest {
public static class ClusterStatus extends CollectionAdminRequest<ClusterStatus> {
protected String shardName = null;
protected String collection = null;
protected String routeKey = null;
public ClusterStatus () {
action = CollectionAction.CLUSTERSTATUS;
}
public void setCollectionName(String collectionName) {
public ClusterStatus setCollectionName(String collectionName) {
this.collection = collectionName;
return this;
}
public String getCollectionName() {
return collection;
}
public void setShardName(String shard) {
public ClusterStatus setShardName(String shard) {
this.shardName = shard;
return this;
}
public String getShardName() {
return this.shardName;
}
public String getRouteKey() {
return routeKey;
}
public ClusterStatus setRouteKey(String routeKey) {
this.routeKey = routeKey;
return this;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
@ -766,20 +901,32 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
if (shardName != null) {
params.set(CoreAdminParams.SHARD, shardName);
}
if (routeKey != null) {
params.set(ShardParams._ROUTE_, routeKey);
}
return params;
}
@Override
protected ClusterStatus getThis() {
return this;
}
}
// LIST request
public static class List extends CollectionAdminRequest {
public static class List extends CollectionAdminRequest<List> {
public List () {
action = CollectionAction.LIST;
}
@Override
protected List getThis() {
return this;
}
}
// ADDREPLICAPROP request
public static class AddReplicaProp extends CollectionShardAdminRequest {
public static class AddReplicaProp extends CollectionShardAdminRequest<AddReplicaProp> {
private String replica;
private String propertyName;
private String propertyValue;
@ -793,32 +940,36 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return replica;
}
public void setReplica(String replica) {
public AddReplicaProp setReplica(String replica) {
this.replica = replica;
return this;
}
public String getPropertyName() {
return propertyName;
}
public void setPropertyName(String propertyName) {
public AddReplicaProp setPropertyName(String propertyName) {
this.propertyName = propertyName;
return this;
}
public String getPropertyValue() {
return propertyValue;
}
public void setPropertyValue(String propertyValue) {
public AddReplicaProp setPropertyValue(String propertyValue) {
this.propertyValue = propertyValue;
return this;
}
public Boolean getShardUnique() {
return shardUnique;
}
public void setShardUnique(Boolean shardUnique) {
public AddReplicaProp setShardUnique(Boolean shardUnique) {
this.shardUnique = shardUnique;
return this;
}
@Override
@ -834,11 +985,15 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return params;
}
@Override
protected AddReplicaProp getThis() {
return this;
}
}
// DELETEREPLICAPROP request
public static class DeleteReplicaProp extends CollectionShardAdminRequest {
public static class DeleteReplicaProp extends CollectionShardAdminRequest<DeleteReplicaProp> {
private String replica;
private String propertyName;
@ -850,16 +1005,18 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return replica;
}
public void setReplica(String replica) {
public DeleteReplicaProp setReplica(String replica) {
this.replica = replica;
return this;
}
public String getPropertyName() {
return propertyName;
}
public void setPropertyName(String propertyName) {
public DeleteReplicaProp setPropertyName(String propertyName) {
this.propertyName = propertyName;
return this;
}
@Override
@ -869,10 +1026,15 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
params.set("property", propertyName);
return params;
}
@Override
protected DeleteReplicaProp getThis() {
return this;
}
}
// BALANCESHARDUNIQUE request
public static class BalanceShardUnique extends CollectionAdminRequest {
public static class BalanceShardUnique extends CollectionAdminRequest<BalanceShardUnique> {
private String collection;
private String propertyName;
private Boolean onlyActiveNodes;
@ -886,28 +1048,32 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return propertyName;
}
public void setPropertyName(String propertyName) {
public BalanceShardUnique setPropertyName(String propertyName) {
this.propertyName = propertyName;
return this;
}
public Boolean getOnlyActiveNodes() {
return onlyActiveNodes;
}
public void setOnlyActiveNodes(Boolean onlyActiveNodes) {
public BalanceShardUnique setOnlyActiveNodes(Boolean onlyActiveNodes) {
this.onlyActiveNodes = onlyActiveNodes;
return this;
}
public Boolean getShardUnique() {
return shardUnique;
}
public void setShardUnique(Boolean shardUnique) {
public BalanceShardUnique setShardUnique(Boolean shardUnique) {
this.shardUnique = shardUnique;
return this;
}
public void setCollection(String collection) {
public BalanceShardUnique setCollection(String collection) {
this.collection = collection;
return this;
}
public String getCollection() {
@ -926,5 +1092,9 @@ public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse>
return params;
}
@Override
protected BalanceShardUnique getThis() {
return this;
}
}
}

View File

@ -36,54 +36,54 @@ import com.google.common.collect.Sets;
public class CollectionAdminRequestRequiredParamsTest extends LuceneTestCase {
public void testBalanceShardUnique() {
final CollectionAdminRequest.BalanceShardUnique request = new CollectionAdminRequest.BalanceShardUnique();
request.setCollection("foo");
request.setPropertyName("prop");
final CollectionAdminRequest.BalanceShardUnique request = new CollectionAdminRequest.BalanceShardUnique()
.setCollection("foo")
.setPropertyName("prop");
assertContainsParams(request.getParams(), ACTION, COLLECTION, "property");
}
public void testClusterProp() {
final CollectionAdminRequest.ClusterProp request = new CollectionAdminRequest.ClusterProp();
request.setPropertyName("foo");
request.setPropertyValue("bar");
final CollectionAdminRequest.ClusterProp request = new CollectionAdminRequest.ClusterProp()
.setPropertyName("foo")
.setPropertyValue("bar");
assertContainsParams(request.getParams(), ACTION, NAME, "val");
}
public void testAddRole() {
final CollectionAdminRequest.AddRole request = new CollectionAdminRequest.AddRole();
request.setNode("node");
request.setRole("role");
final CollectionAdminRequest.AddRole request = new CollectionAdminRequest.AddRole()
.setNode("node")
.setRole("role");
assertContainsParams(request.getParams(), ACTION, "node", "role");
}
public void testRemoveRole() {
final CollectionAdminRequest.RemoveRole request = new CollectionAdminRequest.RemoveRole();
request.setNode("node");
request.setRole("role");
final CollectionAdminRequest.RemoveRole request = new CollectionAdminRequest.RemoveRole()
.setNode("node")
.setRole("role");
assertContainsParams(request.getParams(), ACTION, "node", "role");
}
public void testAddReplica() {
// with shard parameter
CollectionAdminRequest.AddReplica request = new CollectionAdminRequest.AddReplica();
request.setShardName("shard");
request.setCollectionName("collection");
CollectionAdminRequest.AddReplica request = new CollectionAdminRequest.AddReplica()
.setShardName("shard")
.setCollectionName("collection");
assertContainsParams(request.getParams(), ACTION, COLLECTION, SHARD);
// with route parameter
request = new CollectionAdminRequest.AddReplica();
request.setRouteKey("route");
request.setCollectionName("collection");
request = new CollectionAdminRequest.AddReplica()
.setRouteKey("route")
.setCollectionName("collection");
assertContainsParams(request.getParams(), ACTION, COLLECTION, ShardParams._ROUTE_);
}
public void testAddReplicaProp() {
final CollectionAdminRequest.AddReplicaProp request = new CollectionAdminRequest.AddReplicaProp();
request.setShardName("shard");
request.setCollectionName("collection");
request.setReplica("replica");
request.setPropertyName("prop");
request.setPropertyValue("value");
final CollectionAdminRequest.AddReplicaProp request = new CollectionAdminRequest.AddReplicaProp()
.setShardName("shard")
.setCollectionName("collection")
.setReplica("replica")
.setPropertyName("prop")
.setPropertyValue("value");
assertContainsParams(request.getParams(), ACTION, COLLECTION, SHARD, REPLICA, "property", "property.value");
}
@ -93,71 +93,71 @@ public class CollectionAdminRequestRequiredParamsTest extends LuceneTestCase {
}
public void testCreateShard() {
final CollectionAdminRequest.CreateShard request = new CollectionAdminRequest.CreateShard();
request.setCollectionName("collection");
request.setShardName("shard");
final CollectionAdminRequest.CreateShard request = new CollectionAdminRequest.CreateShard()
.setCollectionName("collection")
.setShardName("shard");
assertContainsParams(request.getParams(), ACTION, COLLECTION, SHARD);
}
public void testDeleteReplica() {
final CollectionAdminRequest.DeleteReplica request = new CollectionAdminRequest.DeleteReplica();
request.setCollectionName("collection");
request.setShardName("shard");
request.setReplica("replica");
final CollectionAdminRequest.DeleteReplica request = new CollectionAdminRequest.DeleteReplica()
.setCollectionName("collection")
.setShardName("shard")
.setReplica("replica");
assertContainsParams(request.getParams(), ACTION, COLLECTION, SHARD, REPLICA);
}
public void testDeleteReplicaProp() {
final CollectionAdminRequest.DeleteReplicaProp request = new CollectionAdminRequest.DeleteReplicaProp();
request.setCollectionName("collection");
request.setShardName("shard");
request.setReplica("replica");
request.setPropertyName("foo");
final CollectionAdminRequest.DeleteReplicaProp request = new CollectionAdminRequest.DeleteReplicaProp()
.setCollectionName("collection")
.setShardName("shard")
.setReplica("replica")
.setPropertyName("foo");
assertContainsParams(request.getParams(), ACTION, COLLECTION, SHARD, REPLICA, "property");
}
public void testDeleteShard() {
final CollectionAdminRequest.DeleteShard request = new CollectionAdminRequest.DeleteShard();
request.setCollectionName("collection");
request.setShardName("shard");
final CollectionAdminRequest.DeleteShard request = new CollectionAdminRequest.DeleteShard()
.setCollectionName("collection")
.setShardName("shard");
assertContainsParams(request.getParams(), ACTION, COLLECTION, SHARD);
}
public void testSplitShard() {
final CollectionAdminRequest.SplitShard request = new CollectionAdminRequest.SplitShard();
request.setCollectionName("collection");
request.setShardName("shard");
final CollectionAdminRequest.SplitShard request = new CollectionAdminRequest.SplitShard()
.setCollectionName("collection")
.setShardName("shard");
assertContainsParams(request.getParams(), ACTION, COLLECTION, SHARD);
}
public void testCreateCollection() {
final CollectionAdminRequest.Create request = new CollectionAdminRequest.Create();
request.setCollectionName("collection");
final CollectionAdminRequest.Create request = new CollectionAdminRequest.Create()
.setCollectionName("collection");
assertContainsParams(request.getParams(), ACTION, NAME);
}
public void testReloadCollection() {
final CollectionAdminRequest.Reload request = new CollectionAdminRequest.Reload();
request.setCollectionName("collection");
final CollectionAdminRequest.Reload request = new CollectionAdminRequest.Reload()
.setCollectionName("collection");
assertContainsParams(request.getParams(), ACTION, NAME);
}
public void testDeleteCollection() {
final CollectionAdminRequest.Delete request = new CollectionAdminRequest.Delete();
request.setCollectionName("collection");
final CollectionAdminRequest.Delete request = new CollectionAdminRequest.Delete()
.setCollectionName("collection");
assertContainsParams(request.getParams(), ACTION, NAME);
}
public void testCreateAlias() {
final CollectionAdminRequest.CreateAlias request = new CollectionAdminRequest.CreateAlias();
request.setAliasName("name");
request.setAliasedCollections("collections");
final CollectionAdminRequest.CreateAlias request = new CollectionAdminRequest.CreateAlias()
.setAliasName("name")
.setAliasedCollections("collections");
assertContainsParams(request.getParams(), ACTION, NAME, "collections");
}
public void testDeleteAlias() {
final CollectionAdminRequest.DeleteAlias request = new CollectionAdminRequest.DeleteAlias();
request.setAliasName("name");
final CollectionAdminRequest.DeleteAlias request = new CollectionAdminRequest.DeleteAlias()
.setAliasName("name");
assertContainsParams(request.getParams(), ACTION, NAME);
}
@ -167,10 +167,10 @@ public class CollectionAdminRequestRequiredParamsTest extends LuceneTestCase {
}
public void testMigrate() {
final CollectionAdminRequest.Migrate request = new CollectionAdminRequest.Migrate();
request.setCollectionName("collection");
request.setTargetCollection("target");
request.setSplitKey("splitKey");
final CollectionAdminRequest.Migrate request = new CollectionAdminRequest.Migrate()
.setCollectionName("collection")
.setTargetCollection("target")
.setSplitKey("splitKey");
assertContainsParams(request.getParams(), ACTION, COLLECTION, "target.collection", "split.key");
}
@ -180,8 +180,8 @@ public class CollectionAdminRequestRequiredParamsTest extends LuceneTestCase {
}
public void testRequestStatus() {
final CollectionAdminRequest.RequestStatus request = new CollectionAdminRequest.RequestStatus();
request.setRequestId("request");
final CollectionAdminRequest.RequestStatus request = new CollectionAdminRequest.RequestStatus()
.setRequestId("request");
assertContainsParams(request.getParams(), ACTION, REQUESTID);
}