SOLR-6448: SolrJ support for all Collection API calls

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1648446 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Anshum Gupta 2014-12-29 23:37:04 +00:00
parent 3a857ad958
commit 74e318cabd
10 changed files with 763 additions and 205 deletions

View File

@ -574,6 +574,8 @@ Other Changes
* SOLR-6896: Speed up tests by dropping SolrJettyRunner thread max idle time * SOLR-6896: Speed up tests by dropping SolrJettyRunner thread max idle time
(Alan Woodward) (Alan Woodward)
* SOLR-6448: Add SolrJ support for all current Collection API calls. (Anshum Gupta)
================== 4.10.3 ================== ================== 4.10.3 ==================
Bug Fixes Bug Fixes

View File

@ -268,7 +268,7 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {
server.request(request); server.request(request);
} else { } else {
CreateAlias request = new CreateAlias(); CreateAlias request = new CreateAlias();
request.setCollectionName(alias); request.setAliasName(alias);
request.setAliasedCollections(collections); request.setAliasedCollections(collections);
request.process(server); request.process(server);
} }
@ -288,7 +288,7 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {
server.request(request); server.request(request);
} else { } else {
DeleteAlias request = new DeleteAlias(); DeleteAlias request = new DeleteAlias();
request.setCollectionName(alias); request.setAliasName(alias);
request.process(server); request.process(server);
} }
server.shutdown(); server.shutdown();

View File

@ -25,7 +25,6 @@ import java.io.IOException;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -203,7 +202,6 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
deletePartiallyCreatedCollection(); deletePartiallyCreatedCollection();
deleteCollectionRemovesStaleZkCollectionsNode(); deleteCollectionRemovesStaleZkCollectionsNode();
clusterPropTest(); clusterPropTest();
addReplicaTest();
// last // last
deleteCollectionWithDownNodes(); deleteCollectionWithDownNodes();
@ -212,8 +210,6 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
} }
} }
private void deleteCollectionRemovesStaleZkCollectionsNode() throws Exception { private void deleteCollectionRemovesStaleZkCollectionsNode() throws Exception {
// we can use this client because we just want base url // we can use this client because we just want base url
@ -1126,60 +1122,6 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
} }
private void addReplicaTest() throws Exception {
String collectionName = "addReplicaColl";
CloudSolrServer client = createCloudClient(null);
try {
createCollection(collectionName, client, 2, 2);
String newReplicaName = Assign.assignNode(collectionName, client.getZkStateReader().getClusterState());
ArrayList<String> nodeList = new ArrayList<>(client.getZkStateReader().getClusterState().getLiveNodes());
Collections.shuffle(nodeList, random());
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica();
addReplica.setCollectionName(collectionName);
addReplica.setShardName("shard1");
addReplica.setNode(nodeList.get(0));
client.request(addReplica);
long timeout = System.currentTimeMillis() + 3000;
Replica newReplica = null;
for (; System.currentTimeMillis() < timeout; ) {
Slice slice = client.getZkStateReader().getClusterState().getSlice(collectionName, "shard1");
newReplica = slice.getReplica(newReplicaName);
}
assertNotNull(newReplica);
log.info("newReplica {},\n{} ", newReplica, client.getZkStateReader().getBaseUrlForNodeName(nodeList.get(0)));
assertEquals("Replica should be created on the right node",
client.getZkStateReader().getBaseUrlForNodeName(nodeList.get(0)), newReplica.getStr(ZkStateReader.BASE_URL_PROP));
newReplicaName = Assign.assignNode(collectionName, client.getZkStateReader().getClusterState());
addReplica = new CollectionAdminRequest.AddReplica();
addReplica.setCollectionName(collectionName);
addReplica.setShardName("shard2");
client.request(addReplica);
timeout = System.currentTimeMillis() + 3000;
newReplica = null;
for (; System.currentTimeMillis() < timeout; ) {
Slice slice = client.getZkStateReader().getClusterState().getSlice(collectionName, "shard2");
newReplica = slice.getReplica(newReplicaName);
}
assertNotNull(newReplica);
} finally {
client.shutdown();
}
}
@Override @Override
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException { protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
@ -1236,9 +1178,9 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
request.setPath("/admin/collections"); request.setPath("/admin/collections");
client.request(request); client.request(request);
long tomeOut = System.currentTimeMillis() + 3000; long timeOut = System.currentTimeMillis() + 3000;
boolean changed = false; boolean changed = false;
while(System.currentTimeMillis() <tomeOut){ while(System.currentTimeMillis() <timeOut){
Thread.sleep(10); Thread.sleep(10);
changed = Objects.equals(val,client.getZkStateReader().getClusterProps().get(name)); changed = Objects.equals(val,client.getZkStateReader().getClusterProps().get(name));
if(changed) break; if(changed) break;

View File

@ -17,6 +17,7 @@ package org.apache.solr.cloud;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.commons.codec.binary.StringUtils;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil; import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
@ -32,13 +33,20 @@ import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CoreAdminParams; import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.NamedList;
import org.apache.zookeeper.KeeperException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Properties; import java.util.Properties;
import static org.apache.solr.cloud.ReplicaPropertiesBase.verifyUniqueAcrossCollection;
@LuceneTestCase.Slow @LuceneTestCase.Slow
public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase { public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
@ -50,6 +58,13 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
testCreateAndDeleteAlias(); testCreateAndDeleteAlias();
testSplitShard(); testSplitShard();
testCreateCollectionWithPropertyParam(); testCreateCollectionWithPropertyParam();
testAddAndDeleteReplica();
testClusterProp();
testAddAndRemoveRole();
testOverseerStatus();
testList();
testAddAndDeleteReplicaProp();
testBalanceShardUnique();
} }
public void tearDown() throws Exception { public void tearDown() throws Exception {
@ -65,7 +80,6 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
super.tearDown(); super.tearDown();
} }
protected void testCreateAndDeleteCollection() throws Exception { protected void testCreateAndDeleteCollection() throws Exception {
String collectionName = "solrj_test"; String collectionName = "solrj_test";
CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create(); CollectionAdminRequest.Create createCollectionRequest = new CollectionAdminRequest.Create();
@ -170,14 +184,14 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
protected void testCreateAndDeleteAlias() throws IOException, SolrServerException { protected void testCreateAndDeleteAlias() throws IOException, SolrServerException {
CollectionAdminRequest.CreateAlias createAliasRequest = new CollectionAdminRequest CollectionAdminRequest.CreateAlias createAliasRequest = new CollectionAdminRequest
.CreateAlias(); .CreateAlias();
createAliasRequest.setCollectionName("solrj_alias"); createAliasRequest.setAliasName("solrj_alias");
createAliasRequest.setAliasedCollections("collection1"); createAliasRequest.setAliasedCollections(DEFAULT_COLLECTION);
CollectionAdminResponse response = createAliasRequest.process(cloudClient); CollectionAdminResponse response = createAliasRequest.process(cloudClient);
assertEquals(0, response.getStatus()); assertEquals(0, response.getStatus());
CollectionAdminRequest.DeleteAlias deleteAliasRequest = new CollectionAdminRequest.DeleteAlias(); CollectionAdminRequest.DeleteAlias deleteAliasRequest = new CollectionAdminRequest.DeleteAlias();
deleteAliasRequest.setCollectionName("solrj_alias"); deleteAliasRequest.setAliasName("solrj_alias");
deleteAliasRequest.process(cloudClient); deleteAliasRequest.process(cloudClient);
assertEquals(0, response.getStatus()); assertEquals(0, response.getStatus());
@ -274,4 +288,213 @@ public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
deleteCollectionRequest.setCollectionName(collectionName); deleteCollectionRequest.setCollectionName(collectionName);
deleteCollectionRequest.process(cloudClient); deleteCollectionRequest.process(cloudClient);
} }
private void testAddAndDeleteReplica() throws Exception {
String collectionName = "solrj_replicatests";
createCollection(collectionName, cloudClient, 1, 2);
cloudClient.setDefaultCollection(collectionName);
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));
CollectionAdminResponse response = addReplica.process(cloudClient);
assertEquals(0, response.getStatus());
assertTrue(response.isSuccess());
long timeout = System.currentTimeMillis() + 3000;
Replica newReplica = null;
while (System.currentTimeMillis() < timeout && newReplica == null) {
Slice slice = cloudClient.getZkStateReader().getClusterState().getSlice(collectionName, "shard1");
newReplica = slice.getReplica(newReplicaName);
}
assertNotNull(newReplica);
assertEquals("Replica should be created on the right node",
cloudClient.getZkStateReader().getBaseUrlForNodeName(nodeList.get(0)),
newReplica.getStr(ZkStateReader.BASE_URL_PROP)
);
// Test DELETEREPLICA
CollectionAdminRequest.DeleteReplica deleteReplicaRequest = new CollectionAdminRequest.DeleteReplica();
deleteReplicaRequest.setCollectionName(collectionName);
deleteReplicaRequest.setShardName("shard1");
deleteReplicaRequest.setReplica(newReplicaName);
response = deleteReplicaRequest.process(cloudClient);
assertEquals(0, response.getStatus());
timeout = System.currentTimeMillis() + 3000;
while (System.currentTimeMillis() < timeout && newReplica != null) {
Slice slice = cloudClient.getZkStateReader().getClusterState().getSlice(collectionName, "shard1");
newReplica = slice.getReplica(newReplicaName);
}
assertNull(newReplica);
}
private void testClusterProp() throws InterruptedException, IOException, SolrServerException {
CollectionAdminRequest.ClusterProp clusterPropRequest = new CollectionAdminRequest.ClusterProp();
clusterPropRequest.setPropertyName(ZkStateReader.LEGACY_CLOUD);
clusterPropRequest.setPropertyValue("false");
CollectionAdminResponse response = clusterPropRequest.process(cloudClient);
assertEquals(0, response.getStatus());
long timeOut = System.currentTimeMillis() + 3000;
boolean changed = false;
while(System.currentTimeMillis() < timeOut){
Thread.sleep(10);
changed = Objects.equals("false",
cloudClient.getZkStateReader().getClusterProps().get(ZkStateReader.LEGACY_CLOUD));
if(changed) break;
}
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.process(cloudClient);
timeOut = System.currentTimeMillis() + 3000;
changed = false;
while(System.currentTimeMillis() < timeOut){
Thread.sleep(10);
changed = (cloudClient.getZkStateReader().getClusterProps().get(ZkStateReader.LEGACY_CLOUD) == null);
if(changed)
break;
}
assertTrue("The Cluster property wasn't unset", changed);
}
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");
addRoleRequest.process(cloudClient);
CollectionAdminRequest.ClusterStatus clusterStatusRequest = new CollectionAdminRequest.ClusterStatus();
clusterStatusRequest.setCollectionName(DEFAULT_COLLECTION);
CollectionAdminResponse response = clusterStatusRequest.process(cloudClient);
NamedList<Object> rsp = response.getResponse();
NamedList<Object> cluster = (NamedList<Object>) rsp.get("cluster");
assertNotNull("Cluster state should not be null", cluster);
Map<String, Object> roles = (Map<String, Object>) cluster.get("roles");
assertNotNull("Role information should not be null", roles);
List<String> overseer = (List<String>) roles.get("overseer");
assertNotNull(overseer);
assertEquals(1, overseer.size());
assertTrue(overseer.contains(replica.getNodeName()));
// Remove role
CollectionAdminRequest.RemoveRole removeRoleRequest = new CollectionAdminRequest.RemoveRole();
removeRoleRequest.setNode(replica.getNodeName());
removeRoleRequest.setRole("overseer");
removeRoleRequest.process(cloudClient);
clusterStatusRequest = new CollectionAdminRequest.ClusterStatus();
clusterStatusRequest.setCollectionName(DEFAULT_COLLECTION);
response = clusterStatusRequest.process(cloudClient);
rsp = response.getResponse();
cluster = (NamedList<Object>) rsp.get("cluster");
assertNotNull("Cluster state should not be null", cluster);
roles = (Map<String, Object>) cluster.get("roles");
assertNotNull("Role information should not be null", roles);
overseer = (List<String>) roles.get("overseer");
assertFalse(overseer.contains(replica.getNodeName()));
}
private void testOverseerStatus() throws IOException, SolrServerException {
CollectionAdminRequest.OverseerStatus overseerStatusRequest = new CollectionAdminRequest.OverseerStatus();
CollectionAdminResponse response = overseerStatusRequest.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);
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);
assertEquals(0, response.getStatus());
long timeout = System.currentTimeMillis() + 20000;
String propertyValue = null;
String replicaName = replica.getName();
while (System.currentTimeMillis() < timeout) {
ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
replica = clusterState.getReplica(DEFAULT_COLLECTION, replicaName);
propertyValue = replica.getStr("property.preferredleader");
if(StringUtils.equals("true", propertyValue))
break;
Thread.sleep(50);
}
assertEquals("Replica property was not updated, Latest value: " +
cloudClient.getZkStateReader().getClusterState().getReplica(DEFAULT_COLLECTION, replicaName),
"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);
assertEquals(0, response.getStatus());
timeout = System.currentTimeMillis() + 20000;
boolean updated = false;
while (System.currentTimeMillis() < timeout) {
ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
replica = clusterState.getReplica(DEFAULT_COLLECTION, replicaName);
updated = replica.getStr("property.preferredleader") == null;
if(updated)
break;
Thread.sleep(50);
}
assertTrue("Replica property was not removed", updated);
}
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);
assertEquals(0, response.getStatus());
verifyUniqueAcrossCollection(cloudClient, DEFAULT_COLLECTION, "property.preferredleader");
}
} }

View File

@ -172,7 +172,7 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
// try to clean up // try to clean up
try { try {
CollectionAdminRequest req = new CollectionAdminRequest.Delete(); CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName); req.setCollectionName(testCollectionName);
req.process(cloudClient); req.process(cloudClient);
} catch (Exception e) { } catch (Exception e) {
@ -253,7 +253,7 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
// try to clean up // try to clean up
try { try {
CollectionAdminRequest req = new CollectionAdminRequest.Delete(); CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName); req.setCollectionName(testCollectionName);
req.process(cloudClient); req.process(cloudClient);
} catch (Exception e) { } catch (Exception e) {
@ -309,7 +309,7 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
// try to clean up // try to clean up
try { try {
CollectionAdminRequest req = new CollectionAdminRequest.Delete(); CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName); req.setCollectionName(testCollectionName);
req.process(cloudClient); req.process(cloudClient);
} catch (Exception e) { } catch (Exception e) {
@ -405,7 +405,7 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
// try to clean up // try to clean up
try { try {
CollectionAdminRequest req = new CollectionAdminRequest.Delete(); CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName); req.setCollectionName(testCollectionName);
req.process(cloudClient); req.process(cloudClient);
} catch (Exception e) { } catch (Exception e) {

View File

@ -170,7 +170,7 @@ public class LeaderFailoverAfterPartitionTest extends HttpPartitionTest {
// try to clean up // try to clean up
try { try {
CollectionAdminRequest req = new CollectionAdminRequest.Delete(); CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName); req.setCollectionName(testCollectionName);
req.process(cloudClient); req.process(cloudClient);
} catch (Exception e) { } catch (Exception e) {

View File

@ -105,7 +105,7 @@ public class LeaderInitiatedRecoveryOnCommitTest extends BasicDistributedZkTest
// try to clean up // try to clean up
try { try {
CollectionAdminRequest req = new CollectionAdminRequest.Delete(); CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName); req.setCollectionName(testCollectionName);
req.process(cloudClient); req.process(cloudClient);
} catch (Exception e) { } catch (Exception e) {
@ -147,7 +147,7 @@ public class LeaderInitiatedRecoveryOnCommitTest extends BasicDistributedZkTest
// try to clean up // try to clean up
try { try {
CollectionAdminRequest req = new CollectionAdminRequest.Delete(); CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
req.setCollectionName(testCollectionName); req.setCollectionName(testCollectionName);
req.process(cloudClient); req.process(cloudClient);
} catch (Exception e) { } catch (Exception e) {

View File

@ -22,6 +22,7 @@ import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrServer; import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
@ -119,14 +120,13 @@ public class MigrateRouteKeyTest extends BasicDistributedZkTest {
} }
protected void invokeMigrateApi(String sourceCollection, String splitKey, String targetCollection) throws SolrServerException, IOException { protected void invokeMigrateApi(String sourceCollection, String splitKey, String targetCollection) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams(); cloudClient.setDefaultCollection(sourceCollection);
params.set("action", CollectionParams.CollectionAction.MIGRATE.toString()); CollectionAdminRequest.Migrate migrateRequest = new CollectionAdminRequest.Migrate();
params.set("collection", sourceCollection); migrateRequest.setCollectionName(sourceCollection);
params.set("target.collection", targetCollection); migrateRequest.setTargetCollection(targetCollection);
params.set("split.key", splitKey); migrateRequest.setSplitKey(splitKey);
params.set("forward.timeout", 45); migrateRequest.setForwardTimeout(45);
migrateRequest.process(cloudClient);
invoke(params);
} }
protected void invoke(ModifiableSolrParams params) throws SolrServerException, IOException { protected void invoke(ModifiableSolrParams params) throws SolrServerException, IOException {

View File

@ -40,7 +40,7 @@ import org.apache.zookeeper.KeeperException;
// and shards, but for now this will do. // and shards, but for now this will do.
public abstract class ReplicaPropertiesBase extends AbstractFullDistribZkTestBase { public abstract class ReplicaPropertiesBase extends AbstractFullDistribZkTestBase {
NamedList<Object> doPropertyAction(CloudSolrServer client, String... paramsIn) throws IOException, SolrServerException { public static NamedList<Object> doPropertyAction(CloudSolrServer client, String... paramsIn) throws IOException, SolrServerException {
assertTrue("paramsIn must be an even multiple of 2, it is: " + paramsIn.length, (paramsIn.length % 2) == 0); assertTrue("paramsIn must be an even multiple of 2, it is: " + paramsIn.length, (paramsIn.length % 2) == 0);
ModifiableSolrParams params = new ModifiableSolrParams(); ModifiableSolrParams params = new ModifiableSolrParams();
for (int idx = 0; idx < paramsIn.length; idx += 2) { for (int idx = 0; idx < paramsIn.length; idx += 2) {
@ -51,7 +51,7 @@ public abstract class ReplicaPropertiesBase extends AbstractFullDistribZkTestBas
return client.request(request); return client.request(request);
} }
void verifyPropertyNotPresent(CloudSolrServer client, String collectionName, String replicaName, public static void verifyPropertyNotPresent(CloudSolrServer client, String collectionName, String replicaName,
String property) String property)
throws KeeperException, InterruptedException { throws KeeperException, InterruptedException {
ClusterState clusterState = null; ClusterState clusterState = null;
@ -76,7 +76,7 @@ public abstract class ReplicaPropertiesBase extends AbstractFullDistribZkTestBas
// collection // collection
// shard // shard
// replica // replica
void verifyPropertyVal(CloudSolrServer client, String collectionName, public static void verifyPropertyVal(CloudSolrServer client, String collectionName,
String replicaName, String property, String val) String replicaName, String property, String val)
throws InterruptedException, KeeperException { throws InterruptedException, KeeperException {
Replica replica = null; Replica replica = null;
@ -102,16 +102,16 @@ public abstract class ReplicaPropertiesBase extends AbstractFullDistribZkTestBas
// Verify that // Verify that
// 1> the property is only set once in all the replicas in a slice. // 1> the property is only set once in all the replicas in a slice.
// 2> the property is balanced evenly across all the nodes hosting collection // 2> the property is balanced evenly across all the nodes hosting collection
void verifyUniqueAcrossCollection(CloudSolrServer client, String collectionName, public static void verifyUniqueAcrossCollection(CloudSolrServer client, String collectionName,
String property) throws KeeperException, InterruptedException { String property) throws KeeperException, InterruptedException {
verifyUnique(client, collectionName, property, true); verifyUnique(client, collectionName, property, true);
} }
void verifyUniquePropertyWithinCollection(CloudSolrServer client, String collectionName, public static void verifyUniquePropertyWithinCollection(CloudSolrServer client, String collectionName,
String property) throws KeeperException, InterruptedException { String property) throws KeeperException, InterruptedException {
verifyUnique(client, collectionName, property, false); verifyUnique(client, collectionName, property, false);
} }
void verifyUnique(CloudSolrServer client, String collectionName, String property, boolean balanced) public static void verifyUnique(CloudSolrServer client, String collectionName, String property, boolean balanced)
throws KeeperException, InterruptedException { throws KeeperException, InterruptedException {
DocCollection col = null; DocCollection col = null;

View File

@ -43,14 +43,52 @@ import java.util.concurrent.TimeUnit;
* *
* @since solr 4.5 * @since solr 4.5
*/ */
public class CollectionAdminRequest extends SolrRequest public class CollectionAdminRequest extends SolrRequest {
{
protected String collection = null;
protected CollectionAction action = null; protected CollectionAction action = null;
protected String asyncId = null;
private static String PROPERTY_PREFIX = "property."; private static String PROPERTY_PREFIX = "property.";
public void setAction( CollectionAction action )
{
this.action = action;
}
public CollectionAdminRequest()
{
super( METHOD.GET, "/admin/collections" );
}
public CollectionAdminRequest( String path )
{
super( METHOD.GET, path );
}
@Override
public SolrParams getParams() {
if( action == null ) {
throw new RuntimeException( "no action specified!" );
}
ModifiableSolrParams params = new ModifiableSolrParams();
params.set( CoreAdminParams.ACTION, action.toString() );
return params;
}
@Override
public Collection<ContentStream> getContentStreams() throws IOException {
return null;
}
@Override
public CollectionAdminResponse process(SolrServer server) throws SolrServerException, IOException
{
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
CollectionAdminResponse res = new CollectionAdminResponse();
res.setResponse( server.request( this ) );
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
return res;
}
protected void addProperties(ModifiableSolrParams params, Properties props) { protected void addProperties(ModifiableSolrParams params, Properties props) {
Iterator<Map.Entry<Object, Object>> iter = props.entrySet().iterator(); Iterator<Map.Entry<Object, Object>> iter = props.entrySet().iterator();
while(iter.hasNext()) { while(iter.hasNext()) {
@ -61,7 +99,29 @@ public class CollectionAdminRequest extends SolrRequest
} }
} }
protected static class CollectionShardAdminRequest extends CollectionAdminRequest { //---------------------------------------------------------------------------------------
//
//---------------------------------------------------------------------------------------
protected static class CollectionSpecificAdminRequest extends CollectionAdminRequest {
protected String collection = null;
public final void setCollectionName( String collectionName )
{
this.collection = collectionName;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
params.set( CoreAdminParams.NAME, collection );
return params;
}
}
protected static class CollectionShardAdminRequest extends CollectionSpecificAdminRequest {
protected String shardName = null; protected String shardName = null;
public void setShardName(String shard) { this.shardName = shard; } public void setShardName(String shard) { this.shardName = shard; }
@ -69,10 +129,8 @@ public class CollectionAdminRequest extends SolrRequest
public ModifiableSolrParams getCommonParams() { public ModifiableSolrParams getCommonParams() {
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams(); ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
params.remove( "name" );
params.set( "collection", collection ); params.set( "collection", collection );
params.set( "shard", shardName); params.set( "shard", shardName);
params.set( "async", asyncId);
return params; return params;
} }
@ -81,9 +139,41 @@ public class CollectionAdminRequest extends SolrRequest
return getCommonParams(); return getCommonParams();
} }
} }
protected static class CollectionAdminRoleRequest extends CollectionAdminRequest {
private String node;
private String role;
//a create collection request public void setNode(String node) {
public static class Create extends CollectionAdminRequest { this.node = node;
}
public String getNode() {
return this.node;
}
public void setRole(String role) {
this.role = role;
}
public String getRole() {
return this.role;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
params.set("role", this.role);
params.set("node", this.node);
return params;
}
}
/** Specific Collection API call implementations **/
// CREATE request
public static class Create extends CollectionSpecificAdminRequest {
protected String configName = null; protected String configName = null;
protected String createNodeSet = null; protected String createNodeSet = null;
protected String routerName; protected String routerName;
@ -96,6 +186,7 @@ public class CollectionAdminRequest extends SolrRequest
private Properties properties; private Properties properties;
protected Boolean autoAddReplicas; protected Boolean autoAddReplicas;
protected Integer stateFormat; protected Integer stateFormat;
protected String asyncId;
public Create() { public Create() {
@ -112,6 +203,9 @@ public class CollectionAdminRequest extends SolrRequest
public void setAutoAddReplicas(boolean autoAddReplicas) { this.autoAddReplicas = autoAddReplicas; } public void setAutoAddReplicas(boolean autoAddReplicas) { this.autoAddReplicas = autoAddReplicas; }
public void setReplicationFactor(Integer repl) { this.replicationFactor = repl; } public void setReplicationFactor(Integer repl) { this.replicationFactor = repl; }
public void setStateFormat(Integer stateFormat) { this.stateFormat = stateFormat; } public void setStateFormat(Integer stateFormat) { this.stateFormat = stateFormat; }
public void setAsyncId(String asyncId) {
this.asyncId = asyncId;
}
public String getConfigName() { return configName; } public String getConfigName() { return configName; }
public String getCreateNodeSet() { return createNodeSet; } public String getCreateNodeSet() { return createNodeSet; }
@ -122,6 +216,9 @@ public class CollectionAdminRequest extends SolrRequest
public Integer getReplicationFactor() { return replicationFactor; } public Integer getReplicationFactor() { return replicationFactor; }
public Boolean getAutoAddReplicas() { return autoAddReplicas; } public Boolean getAutoAddReplicas() { return autoAddReplicas; }
public Integer getStateFormat() { return stateFormat; } public Integer getStateFormat() { return stateFormat; }
public String getAsyncId() {
return asyncId;
}
public Properties getProperties() { public Properties getProperties() {
return properties; return properties;
@ -135,37 +232,26 @@ public class CollectionAdminRequest extends SolrRequest
public SolrParams getParams() { public SolrParams getParams() {
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams(); ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
if (configName != null) { params.set( "collection.configName", configName);
params.set( "collection.configName", configName); params.set( "createNodeSet", createNodeSet);
}
if (createNodeSet != null) {
params.set( "createNodeSet", createNodeSet);
}
if (numShards != null) { if (numShards != null) {
params.set( ZkStateReader.NUM_SHARDS_PROP, numShards); params.set( ZkStateReader.NUM_SHARDS_PROP, numShards);
} }
if (maxShardsPerNode != null) { if (maxShardsPerNode != null) {
params.set( "maxShardsPerNode", maxShardsPerNode); params.set( "maxShardsPerNode", maxShardsPerNode);
} }
if (routerName != null) { params.set( "router.name", routerName);
params.set( "router.name", routerName); params.set("shards", shards);
}
if (shards != null) {
params.set("shards", shards);
}
if (routerField != null) { if (routerField != null) {
params.set("router.field", routerField); params.set("router.field", routerField);
} }
if (replicationFactor != null) { if (replicationFactor != null) {
params.set( "replicationFactor", replicationFactor); params.set( "replicationFactor", replicationFactor);
} }
if (asyncId != null) { params.set("async", asyncId);
params.set("async", asyncId);
}
if (autoAddReplicas != null) { if (autoAddReplicas != null) {
params.set(ZkStateReader.AUTO_ADD_REPLICAS, autoAddReplicas); params.set(ZkStateReader.AUTO_ADD_REPLICAS, autoAddReplicas);
} }
if(properties != null) { if(properties != null) {
addProperties(params, properties); addProperties(params, properties);
} }
@ -174,23 +260,24 @@ public class CollectionAdminRequest extends SolrRequest
} }
return params; return params;
} }
} }
//a reload collection request // RELOAD request
public static class Reload extends CollectionAdminRequest { public static class Reload extends CollectionSpecificAdminRequest {
public Reload() { public Reload() {
action = CollectionAction.RELOAD; action = CollectionAction.RELOAD;
} }
} }
//a delete collection request // DELETE request
public static class Delete extends CollectionAdminRequest { public static class Delete extends CollectionSpecificAdminRequest {
public Delete() { public Delete() {
action = CollectionAction.DELETE; action = CollectionAction.DELETE;
} }
} }
//a create shard collection request // CREATESHARD request
public static class CreateShard extends CollectionShardAdminRequest { public static class CreateShard extends CollectionShardAdminRequest {
protected String nodeSet; protected String nodeSet;
private Properties properties; private Properties properties;
@ -226,13 +313,18 @@ public class CollectionAdminRequest extends SolrRequest
} }
} }
//a split shard collection request // SPLITSHARD request
public static class SplitShard extends CollectionShardAdminRequest { public static class SplitShard extends CollectionShardAdminRequest {
protected String ranges; protected String ranges;
protected String splitKey; protected String splitKey;
protected String asyncId;
private Properties properties; private Properties properties;
public SplitShard() {
action = CollectionAction.SPLITSHARD;
}
public void setRanges(String ranges) { this.ranges = ranges; } public void setRanges(String ranges) { this.ranges = ranges; }
public String getRanges() { return ranges; } public String getRanges() { return ranges; }
@ -252,10 +344,14 @@ public class CollectionAdminRequest extends SolrRequest
this.properties = properties; this.properties = properties;
} }
public SplitShard() { public void setAsyncId(String asyncId) {
action = CollectionAction.SPLITSHARD; this.asyncId = asyncId;
} }
public String getAsyncId() {
return asyncId;
}
@Override @Override
public SolrParams getParams() { public SolrParams getParams() {
ModifiableSolrParams params = getCommonParams(); ModifiableSolrParams params = getCommonParams();
@ -267,18 +363,20 @@ public class CollectionAdminRequest extends SolrRequest
if(properties != null) { if(properties != null) {
addProperties(params, properties); addProperties(params, properties);
} }
params.set("async", asyncId);
return params; return params;
} }
} }
//a delete shard collection request // DELETESHARD request
public static class DeleteShard extends CollectionShardAdminRequest { public static class DeleteShard extends CollectionShardAdminRequest {
public DeleteShard() { public DeleteShard() {
action = CollectionAction.DELETESHARD; action = CollectionAction.DELETESHARD;
} }
} }
//a request status collection request // REQUESTSTATUS request
public static class RequestStatus extends CollectionAdminRequest { public static class RequestStatus extends CollectionAdminRequest {
protected String requestId = null; protected String requestId = null;
@ -289,12 +387,6 @@ public class CollectionAdminRequest extends SolrRequest
public void setRequestId(String requestId) {this.requestId = requestId; } public void setRequestId(String requestId) {this.requestId = requestId; }
public String getRequestId() { return this.requestId; } public String getRequestId() { return this.requestId; }
@Override
public void setAsyncId(String asyncId) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "You can not set async id for " +
"a REQUESTSTATUS call. Try setRequestId()." );
}
@Override @Override
public SolrParams getParams() { public SolrParams getParams() {
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams(); ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
@ -302,40 +394,69 @@ public class CollectionAdminRequest extends SolrRequest
return params; return params;
} }
} }
//a collection alias create request // CREATEALIAS request
public static class CreateAlias extends CollectionAdminRequest { public static class CreateAlias extends CollectionAdminRequest {
protected String aliasedCollections = null; protected String aliasName;
protected String aliasedCollections;
public void setAliasedCollections(String alias) { this.aliasedCollections = alias; }
public String getAliasedCollections() { return this.aliasedCollections; }
@Override
public SolrParams getParams() {
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
params.set( "collections", aliasedCollections );
return params;
}
public CreateAlias() { public CreateAlias() {
action = CollectionAction.CREATEALIAS; action = CollectionAction.CREATEALIAS;
} }
}
//a collection alias delete request public void setAliasName(String aliasName) {
public static class DeleteAlias extends CollectionAdminRequest { this.aliasName = aliasName;
public DeleteAlias() { }
action = CollectionAction.DELETEALIAS;
public String getAliasName() {
return aliasName;
}
public void setAliasedCollections(String alias) { this.aliasedCollections = alias; }
public String getAliasedCollections() { return this.aliasedCollections; }
@Deprecated
public void setCollectionName(String aliasName) {
this.aliasName = aliasName;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
params.set("name", aliasName);
params.set( "collections", aliasedCollections );
return params;
} }
} }
// DELETEALIAS request
public static class DeleteAlias extends CollectionAdminRequest {
protected String aliasName;
public DeleteAlias() {
action = CollectionAction.DELETEALIAS;
}
public void setAliasName(String aliasName) {
this.aliasName = aliasName;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
params.set("name", aliasName);
return params;
}
}
// ADDREPLICA request
public static class AddReplica extends CollectionShardAdminRequest { public static class AddReplica extends CollectionShardAdminRequest {
private String node; private String node;
private String routeKey; private String routeKey;
private String instanceDir; private String instanceDir;
private String dataDir; private String dataDir;
private Properties properties; private Properties properties;
private String asyncId;
public AddReplica() { public AddReplica() {
action = CollectionAction.ADDREPLICA; action = CollectionAction.ADDREPLICA;
@ -391,6 +512,7 @@ public class CollectionAdminRequest extends SolrRequest
} }
params.add(ShardParams._ROUTE_, routeKey); params.add(ShardParams._ROUTE_, routeKey);
} }
params.set("async", asyncId);
if (node != null) { if (node != null) {
params.add("node", node); params.add("node", node);
} }
@ -405,69 +527,338 @@ public class CollectionAdminRequest extends SolrRequest
} }
return params; return params;
} }
}
public CollectionAdminRequest() public void setAsyncId(String asyncId) {
{ this.asyncId = asyncId;
super( METHOD.GET, "/admin/collections" ); }
}
public String getAsyncId() {
public CollectionAdminRequest( String path ) return asyncId;
{
super( METHOD.GET, path );
}
public final void setCollectionName( String collectionName )
{
this.collection = collectionName;
}
//---------------------------------------------------------------------------------------
//
//---------------------------------------------------------------------------------------
public void setAction( CollectionAction action )
{
this.action = action;
}
public void setAsyncId(String asyncId) {
this.asyncId = asyncId;
}
//---------------------------------------------------------------------------------------
//
//---------------------------------------------------------------------------------------
@Override
public SolrParams getParams()
{
if( action == null ) {
throw new RuntimeException( "no action specified!" );
} }
ModifiableSolrParams params = new ModifiableSolrParams();
params.set( CoreAdminParams.ACTION, action.toString() );
params.set( CoreAdminParams.NAME, collection );
return params;
} }
//--------------------------------------------------------------------------------------- // DELETEREPLICA request
// public static class DeleteReplica extends CollectionShardAdminRequest {
//--------------------------------------------------------------------------------------- private String replica;
private Boolean onlyIfDown;
public DeleteReplica() {
action = CollectionAction.DELETEREPLICA;
}
@Override public void setReplica(String replica) {
public Collection<ContentStream> getContentStreams() throws IOException { this.replica = replica;
return null; }
public String getReplica() {
return this.replica;
}
public void setOnlyIfDown(boolean onlyIfDown) {
this.onlyIfDown = onlyIfDown;
}
public Boolean getOnlyIfDown() {
return this.onlyIfDown;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
params.set(ZkStateReader.REPLICA_PROP, this.replica);
if(onlyIfDown != null) {
params.set("onlyIfDown", this.onlyIfDown);
}
return params;
}
}
// CLUSTERPROP request
public static class ClusterProp extends CollectionAdminRequest {
private String propertyName;
private String propertyValue;
public ClusterProp() {
this.action = CollectionAction.CLUSTERPROP;
}
public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}
public String getPropertyName() {
return this.propertyName;
}
public void setPropertyValue(String propertyValue) {
this.propertyValue = propertyValue;
}
public String getPropertyValue() {
return this.propertyValue;
}
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
params.add("name", propertyName);
params.add("val", propertyValue);
return params;
}
}
// MIGRATE request
public static class Migrate extends CollectionSpecificAdminRequest {
private String targetCollection;
private String splitKey;
private Integer forwardTimeout;
private Properties properties;
private String asyncId;
public Migrate() {
action = CollectionAction.MIGRATE;
}
public void setTargetCollection(String targetCollection) {
this.targetCollection = targetCollection;
}
public String getTargetCollection() {
return this.targetCollection;
}
public void setSplitKey(String splitKey) {
this.splitKey = splitKey;
}
public String getSplitKey() {
return this.splitKey;
}
public void setForwardTimeout(int forwardTimeout) {
this.forwardTimeout = forwardTimeout;
}
public Integer getForwardTimeout() {
return this.forwardTimeout;
}
public void setProperties(Properties properties) {
this.properties = properties;
}
public Properties getProperties() {
return this.properties;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
params.set( "collection", collection );
params.set("target.collection", targetCollection);
params.set("split.key", splitKey);
if(forwardTimeout != null) {
params.set("forward.timeout", forwardTimeout);
}
params.set("async", asyncId);
if(properties != null) {
addProperties(params, properties);
}
return params;
}
public void setAsyncId(String asyncId) {
this.asyncId = asyncId;
}
public String getAsyncId() {
return asyncId;
}
}
// ADDROLE request
public static class AddRole extends CollectionAdminRoleRequest {
public AddRole() {
action = CollectionAction.ADDROLE;
}
} }
@Override // REMOVEROLE request
public CollectionAdminResponse process(SolrServer server) throws SolrServerException, IOException public static class RemoveRole extends CollectionAdminRoleRequest {
{ public RemoveRole() {
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS); action = CollectionAction.REMOVEROLE;
CollectionAdminResponse res = new CollectionAdminResponse(); }
res.setResponse( server.request( this ) ); }
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime); // OVERSEERSTATUS request
return res; public static class OverseerStatus extends CollectionAdminRequest {
public OverseerStatus () {
action = CollectionAction.OVERSEERSTATUS;
}
}
// CLUSTERSTATUS request
public static class ClusterStatus extends CollectionShardAdminRequest {
public ClusterStatus () {
action = CollectionAction.CLUSTERSTATUS;
}
}
// LIST request
public static class List extends CollectionAdminRequest {
public List () {
action = CollectionAction.LIST;
}
}
// ADDREPLICAPROP request
public static class AddReplicaProp extends CollectionShardAdminRequest {
private String replica;
private String propertyName;
private String propertyValue;
private Boolean shardUnique;
public AddReplicaProp() {
action = CollectionAction.ADDREPLICAPROP;
}
public String getReplica() {
return replica;
}
public void setReplica(String replica) {
this.replica = replica;
}
public String getPropertyName() {
return propertyName;
}
public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}
public String getPropertyValue() {
return propertyValue;
}
public void setPropertyValue(String propertyValue) {
this.propertyValue = propertyValue;
}
public Boolean getShardUnique() {
return shardUnique;
}
public void setShardUnique(Boolean shardUnique) {
this.shardUnique = shardUnique;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
params.set("replica", replica);
params.set("property", propertyName);
params.set("property.value", propertyValue);
if(shardUnique != null)
params.set("shardUnique", shardUnique);
return params;
}
}
// DELETEREPLICAPROP request
public static class DeleteReplicaProp extends CollectionShardAdminRequest {
private String replica;
private String propertyName;
public DeleteReplicaProp() {
this.action = CollectionAction.DELETEREPLICAPROP;
}
public String getReplica() {
return replica;
}
public void setReplica(String replica) {
this.replica = replica;
}
public String getPropertyName() {
return propertyName;
}
public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
params.set("replica", replica);
params.set("property", propertyName);
return params;
}
}
// BALANCESHARDUNIQUE request
public static class BalanceShardUnique extends CollectionAdminRequest {
private String collection;
private String propertyName;
private Boolean onlyActiveNodes;
private Boolean shardUnique;
public String getPropertyName() {
return propertyName;
}
public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}
public Boolean getOnlyActiveNodes() {
return onlyActiveNodes;
}
public void setOnlyActiveNodes(Boolean onlyActiveNodes) {
this.onlyActiveNodes = onlyActiveNodes;
}
public Boolean getShardUnique() {
return shardUnique;
}
public void setShardUnique(Boolean shardUnique) {
this.shardUnique = shardUnique;
}
public void setCollection(String collection) {
this.collection = collection;
}
public String getCollection() {
return collection;
}
@Override
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
params.set("collection", collection);
params.set("property", propertyName);
if(onlyActiveNodes != null)
params.set("onlyactivenodes", onlyActiveNodes);
if(shardUnique != null)
params.set("shardUnique", shardUnique);
return params;
}
} }
} }