下面列出了com.google.protobuf.TextFormat.ParseException#org.apache.solr.client.solrj.response.CollectionAdminResponse 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@SuppressWarnings("unchecked")
@Override
public List<String> handle(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig) throws Exception {
try {
CollectionAdminRequest.List colListReq = new CollectionAdminRequest.List();
CollectionAdminResponse response = colListReq.process(solrClient);
if (response.getStatus() != 0) {
logger.error("Error getting collection list from solr. response=" + response);
return null;
}
return (List<String>) response.getResponse().get("collections");
} catch (SolrException e) {
logger.error("getCollections() operation failed", e);
return new ArrayList<>();
}
}
private void createAlias() {
try {
CollectionAdminRequest.CreateTimeRoutedAlias rq = CollectionAdminRequest
.createTimeRoutedAlias(
aliasName,
start,
"+12HOUR",
"routedFoo_dt",
CollectionAdminRequest.createCollection("_ignored_", "_default", 1, 1)
);
final CollectionAdminResponse response = rq.process(solrClient);
if (response.getStatus() != 0) {
addFailure(new RuntimeException("failed to create collection " + aliasName));
}
} catch (Exception e) {
addFailure(e);
}
}
@SuppressWarnings({"unchecked"})
private Collection<CollectionSnapshotMetaData> listCollectionSnapshots(SolrClient adminClient, String collectionName) throws Exception {
CollectionAdminRequest.ListSnapshots listSnapshots = new CollectionAdminRequest.ListSnapshots(collectionName);
CollectionAdminResponse resp = listSnapshots.process(adminClient);
assertTrue( resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO) instanceof NamedList );
@SuppressWarnings({"rawtypes"})
NamedList apiResult = (NamedList) resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO);
Collection<CollectionSnapshotMetaData> result = new ArrayList<>();
for (int i = 0; i < apiResult.size(); i++) {
result.add(new CollectionSnapshotMetaData((NamedList<Object>)apiResult.getVal(i)));
}
return result;
}
@SuppressWarnings("rawtypes")
public void listSnapshots(String collectionName) {
CollectionAdminRequest.ListSnapshots listSnaps = new CollectionAdminRequest.ListSnapshots(collectionName);
CollectionAdminResponse resp;
try {
resp = listSnaps.process(solrClient);
Preconditions.checkState(resp.getStatus() == 0, "The LISTSNAPSHOTS request failed. The status code is " + resp.getStatus());
NamedList apiResult = (NamedList) resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO);
for (int i = 0; i < apiResult.size(); i++) {
CLIO.out(apiResult.getName(i));
}
} catch (Exception e) {
log.error("Failed to list snapshots for collection {}", collectionName, e);
CLIO.out("Failed to list snapshots for collection " + collectionName
+" due to following error : "+e.getLocalizedMessage());
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
private Collection<CollectionSnapshotMetaData> listCollectionSnapshots(String collectionName)
throws SolrServerException, IOException {
CollectionAdminRequest.ListSnapshots listSnapshots = new CollectionAdminRequest.ListSnapshots(collectionName);
CollectionAdminResponse resp = listSnapshots.process(solrClient);
Preconditions.checkState(resp.getStatus() == 0);
NamedList apiResult = (NamedList) resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO);
Collection<CollectionSnapshotMetaData> result = new ArrayList<>();
for (int i = 0; i < apiResult.size(); i++) {
result.add(new CollectionSnapshotMetaData((NamedList<Object>)apiResult.getVal(i)));
}
return result;
}
private void create1ShardCollection(String name, String config, MiniSolrCloudCluster solrCluster) throws Exception {
CollectionAdminResponse response;
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create(name,config,1,1,0,0) {
@Override
public SolrParams getParams() {
ModifiableSolrParams msp = new ModifiableSolrParams(super.getParams());
msp.set(USER_PARAM, "user");
return msp;
}
};
create.setMaxShardsPerNode(1);
response = create.process(solrCluster.getSolrClient());
miniCluster.waitForActiveCollection(name, 1, 1);
if (response.getStatus() != 0 || response.getErrorMessages() != null) {
fail("Could not create collection. Response" + response.toString());
}
}
private static void createCollectionIfNotExists(CloudSolrClient client, Configuration config, String collection)
throws IOException, SolrServerException, KeeperException, InterruptedException {
if (!checkIfCollectionExists(client, collection)) {
Integer numShards = config.get(NUM_SHARDS);
Integer maxShardsPerNode = config.get(MAX_SHARDS_PER_NODE);
Integer replicationFactor = config.get(REPLICATION_FACTOR);
CollectionAdminRequest.Create createRequest = new CollectionAdminRequest.Create();
createRequest.setConfigName(collection);
createRequest.setCollectionName(collection);
createRequest.setNumShards(numShards);
createRequest.setMaxShardsPerNode(maxShardsPerNode);
createRequest.setReplicationFactor(replicationFactor);
CollectionAdminResponse createResponse = createRequest.process(client);
if (createResponse.isSuccess()) {
logger.trace("Collection {} successfully created.", collection);
} else {
throw new SolrServerException(Joiner.on("\n").join(createResponse.getErrorMessages()));
}
}
waitForRecoveriesToFinish(client, collection);
}
public void testDiagnosticsWithPayload() throws Exception {
CloudSolrClient solrClient = cluster.getSolrClient();
String COLLNAME = "testDiagnosticsWithPayload.COLL";
CollectionAdminResponse adminResponse = CollectionAdminRequest.createCollection(COLLNAME, CONFIGSET_NAME, 1, 2)
.setMaxShardsPerNode(4)
.process(solrClient);
cluster.waitForActiveCollection(COLLNAME, 1, 2);
DocCollection collection = solrClient.getClusterStateProvider().getCollection(COLLNAME);
Replica aReplica = collection.getReplicas().get(0);
String configPayload = "{\n" +
" 'cluster-policy': [{'replica': 0, 'node': '_NODE'}]\n" +
"}";
configPayload = configPayload.replaceAll("_NODE", aReplica.getNodeName());
@SuppressWarnings({"rawtypes"})
SolrRequest req = AutoScalingRequest.create(SolrRequest.METHOD.POST, "/diagnostics", configPayload);
NamedList<Object> response = solrClient.request(req);
assertEquals(response._getStr("diagnostics/violations[0]/node",null),response._getStr("diagnostics/violations[0]/node",null));
CollectionAdminRequest.deleteCollection(COLLNAME)
.process(cluster.getSolrClient());
}
private void doSplitShardWithRule(SolrIndexSplitter.SplitMethod splitMethod) throws Exception {
waitForThingsToLevelOut(15, TimeUnit.SECONDS);
log.info("Starting testSplitShardWithRule");
String collectionName = "shardSplitWithRule_" + splitMethod.toLower();
CollectionAdminRequest.Create createRequest = CollectionAdminRequest.createCollection(collectionName, "conf1", 1, 2)
.setRule("shard:*,replica:<2,node:*");
CollectionAdminResponse response = createRequest.process(cloudClient);
assertEquals(0, response.getStatus());
try {
cloudClient.waitForState(collectionName, 30, TimeUnit.SECONDS, SolrCloudTestCase.activeClusterShape(1, 2));
} catch (TimeoutException e) {
new RuntimeException("Timeout waiting for 1shards and 2 replicas.", e);
}
CollectionAdminRequest.SplitShard splitShardRequest = CollectionAdminRequest.splitShard(collectionName)
.setShardName("shard1").setSplitMethod(splitMethod.toLower());
response = splitShardRequest.process(cloudClient);
assertEquals(String.valueOf(response.getErrorMessages()), 0, response.getStatus());
}
@Test
public void testClusterProp() throws InterruptedException, IOException, SolrServerException {
// sanity check our expected default
final ClusterProperties props = new ClusterProperties(zkClient());
assertEquals("Expecting prop to default to unset, test needs upated",
props.getClusterProperty(ZkStateReader.AUTO_ADD_REPLICAS, null), null);
CollectionAdminResponse response = CollectionAdminRequest.setClusterProperty(ZkStateReader.AUTO_ADD_REPLICAS, "true")
.process(cluster.getSolrClient());
assertEquals(0, response.getStatus());
assertEquals("Cluster property was not set", props.getClusterProperty(ZkStateReader.AUTO_ADD_REPLICAS, null), "true");
// Unset ClusterProp that we set.
CollectionAdminRequest.setClusterProperty(ZkStateReader.AUTO_ADD_REPLICAS, null).process(cluster.getSolrClient());
assertEquals("Cluster property was not unset", props.getClusterProperty(ZkStateReader.AUTO_ADD_REPLICAS, null), null);
response = CollectionAdminRequest.setClusterProperty(ZkStateReader.AUTO_ADD_REPLICAS, "false")
.process(cluster.getSolrClient());
assertEquals(0, response.getStatus());
assertEquals("Cluster property was not set", props.getClusterProperty(ZkStateReader.AUTO_ADD_REPLICAS, null), "false");
}
@Test
public void testAddAndDeleteReplicaProp() throws InterruptedException, IOException, SolrServerException {
final String collection = "replicaProperties";
CollectionAdminRequest.createCollection(collection, "conf", 2, 2)
.process(cluster.getSolrClient());
cluster.waitForActiveCollection(collection, 2, 4);
final Replica replica = getCollectionState(collection).getLeader("shard1");
CollectionAdminResponse response
= CollectionAdminRequest.addReplicaProperty(collection, "shard1", replica.getName(), "preferredleader", "true")
.process(cluster.getSolrClient());
assertEquals(0, response.getStatus());
waitForState("Expecting property 'preferredleader' to appear on replica " + replica.getName(), collection,
(n, c) -> "true".equals(c.getReplica(replica.getName()).getProperty("preferredleader")));
response = CollectionAdminRequest.deleteReplicaProperty(collection, "shard1", replica.getName(), "property.preferredleader")
.process(cluster.getSolrClient());
assertEquals(0, response.getStatus());
waitForState("Expecting property 'preferredleader' to be removed from replica " + replica.getName(), collection,
(n, c) -> c.getReplica(replica.getName()).getProperty("preferredleader") == null);
}
protected CollectionAdminResponse createCollection(String collectionName, String confSetName, int numShards,
int replicationFactor, SolrClient client) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionAction.CREATE.toString());
params.set("collection.configName", confSetName);
params.set("name", collectionName);
params.set("numShards", numShards);
params.set("replicationFactor", replicationFactor);
@SuppressWarnings({"rawtypes"})
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
CollectionAdminResponse res = new CollectionAdminResponse();
res.setResponse(client.request(request));
return res;
}
@BeforeClass
public static void setupCluster() throws Exception {
numNodes = random().nextInt(4) + 4;
numShards = random().nextInt(3) + 3;
numReplicas = random().nextInt(2) + 2;
useAdminToSetProps = random().nextBoolean();
configureCluster(numNodes)
.addConfig(COLLECTION_NAME, configset("cloud-minimal"))
.configure();
CollectionAdminResponse resp = CollectionAdminRequest.createCollection(COLLECTION_NAME, COLLECTION_NAME,
numShards, numReplicas, 0, 0)
.setMaxShardsPerNode((numShards * numReplicas) / numNodes + 1)
.process(cluster.getSolrClient());
assertEquals("Admin request failed; ", 0, resp.getStatus());
cluster.waitForActiveCollection(COLLECTION_NAME, numShards, numShards * numReplicas);
}
private int createAlias(final CloudSolrClient solrClient, String aliasNameIn, Collection<String> collectionListIn)
throws SolrServerException, IOException {
List<String> collectionToAdd = new ArrayList<>();
try {
collectionToAdd = new ListCollectionHandler().handle(solrClient, null);
} catch (Exception e) {
logger.error("Invalid state during getting collections for creating alias");
}
collectionToAdd.retainAll(collectionListIn);
String collectionsCSV = null;
if (!collectionToAdd.isEmpty()) {
collectionsCSV = StringUtils.join(collectionToAdd, ',');
CollectionAdminRequest.CreateAlias aliasCreateRequest = CollectionAdminRequest.createAlias(aliasNameIn, collectionsCSV);
CollectionAdminResponse createResponse = aliasCreateRequest.process(solrClient);
if (createResponse.getStatus() != 0) {
logger.error("Error creating alias. alias=" + aliasNameIn + ", collectionList=" + collectionsCSV
+ ", response=" + createResponse);
return 0;
}
}
if (collectionToAdd.size() == collectionListIn.size()) {
logger.info("Created alias for all collections. alias=" + aliasNameIn + ", collectionsCSV=" + collectionsCSV);
} else {
logger.info("Created alias for " + collectionToAdd.size() + " out of " + collectionListIn.size() + " collections. " +
"alias=" + aliasNameIn + ", collectionsCSV=" + collectionsCSV);
}
return collectionToAdd.size();
}
public void testSuggestionsWithPayload() throws Exception {
CloudSolrClient solrClient = cluster.getSolrClient();
String COLLNAME = "testSuggestionsWithPayload.COLL";
CollectionAdminResponse adminResponse = CollectionAdminRequest.createCollection(COLLNAME, CONFIGSET_NAME, 1, 2)
.setMaxShardsPerNode(4)
.process(solrClient);
cluster.waitForActiveCollection(COLLNAME, 1, 2);
DocCollection collection = solrClient.getClusterStateProvider().getCollection(COLLNAME);
Replica aReplica = collection.getReplicas().get(0);
String configPayload = "{\n" +
" 'cluster-policy': [{'replica': 0, 'node': '_NODE'}]\n" +
"}";
configPayload = configPayload.replaceAll("_NODE", aReplica.getNodeName());
@SuppressWarnings({"rawtypes"})
SolrRequest req = AutoScalingRequest.create(SolrRequest.METHOD.POST, "/suggestions", configPayload);
NamedList<Object> response = solrClient.request(req);
assertFalse(((Collection) response.get("suggestions")).isEmpty());
String replicaName = response._getStr("suggestions[0]/operation/command/move-replica/replica", null);
boolean[] passed = new boolean[]{false};
collection.forEachReplica((s, replica) -> {
if (replica.getName().equals(replicaName) && replica.getNodeName().equals(aReplica.getNodeName())) {
passed[0] = true;
}
});
assertTrue(passed[0]);
req = AutoScalingRequest.create(SolrRequest.METHOD.POST, "/suggestions", configPayload, new MapSolrParams(Collections.singletonMap("type", repair.name())));
response = solrClient.request(req);
assertTrue(((Collection) response.get("suggestions")).isEmpty());
CollectionAdminRequest.deleteCollection(COLLNAME)
.process(cluster.getSolrClient());
}
@Before
@Override
public void setUp() throws Exception {
super.setUp();
collectionName = "CollectionPropsTest" + System.nanoTime();
CollectionAdminRequest.Create request = CollectionAdminRequest.createCollection(collectionName, "conf", 2, 2);
CollectionAdminResponse response = request.process(cluster.getSolrClient());
assertTrue("Unable to create collection: " + response.toString(), response.isSuccess());
}
@BeforeClass
public static void setUpCluster() throws Exception {
configureCluster(NUM_LIVE_NODES)
.addConfig("conf", new File(ExternalPaths.TECHPRODUCTS_CONFIGSET).toPath())
.configure();
CollectionAdminResponse response = CollectionAdminRequest.createCollection("techproducts", "conf", 1, 1)
.process(cluster.getSolrClient());
cluster.waitForActiveCollection("techproducts", 1, 1);
}
protected CollectionAdminResponse createCollection(Map<String,List<Integer>> collectionInfos,
String collectionName, String configSetName, int numShards, int replicationFactor, int maxShardsPerNode, SolrClient client, String createNodeSetStr) throws SolrServerException, IOException, InterruptedException, TimeoutException {
int numNrtReplicas = useTlogReplicas()?0:replicationFactor;
int numTlogReplicas = useTlogReplicas()?replicationFactor:0;
return createCollection(collectionInfos, collectionName,
Utils.makeMap(
OverseerCollectionMessageHandler.NUM_SLICES, numShards,
ZkStateReader.NRT_REPLICAS, numNrtReplicas,
ZkStateReader.TLOG_REPLICAS, numTlogReplicas,
ZkStateReader.PULL_REPLICAS, getPullReplicaCount(),
OverseerCollectionMessageHandler.CREATE_NODE_SET, createNodeSetStr,
ZkStateReader.MAX_SHARDS_PER_NODE, maxShardsPerNode),
client, configSetName);
}
protected CollectionAdminResponse createCollection(Map<String, List<Integer>> collectionInfos,
String collectionName, int numShards, int replicationFactor, int maxShardsPerNode, SolrClient client, String createNodeSetStr, String configName) throws SolrServerException, IOException, InterruptedException, TimeoutException {
int numNrtReplicas = useTlogReplicas()?0:replicationFactor;
int numTlogReplicas = useTlogReplicas()?replicationFactor:0;
return createCollection(collectionInfos, collectionName,
Utils.makeMap(
OverseerCollectionMessageHandler.NUM_SLICES, numShards,
ZkStateReader.NRT_REPLICAS, numNrtReplicas,
ZkStateReader.TLOG_REPLICAS, numTlogReplicas,
ZkStateReader.PULL_REPLICAS, getPullReplicaCount(),
OverseerCollectionMessageHandler.CREATE_NODE_SET, createNodeSetStr,
ZkStateReader.MAX_SHARDS_PER_NODE, maxShardsPerNode),
client, configName);
}
protected void createCollectionRetry(String testCollectionName, String configSetName, int numShards, int replicationFactor, int maxShardsPerNode)
throws SolrServerException, IOException, InterruptedException, TimeoutException {
CollectionAdminResponse resp = createCollection(testCollectionName, configSetName, numShards, replicationFactor, maxShardsPerNode);
if (resp.getResponse().get("failure") != null) {
CollectionAdminRequest.Delete req = CollectionAdminRequest.deleteCollection(testCollectionName);
req.process(cloudClient);
resp = createCollection(testCollectionName, configSetName, numShards, replicationFactor, maxShardsPerNode);
if (resp.getResponse().get("failure") != null) {
fail("Could not create " + testCollectionName);
}
}
}
static RequestStatusState getRequestState(String requestId, SolrClient client) throws IOException, SolrServerException {
CollectionAdminResponse response = getStatusResponse(requestId, client);
@SuppressWarnings({"rawtypes"})
NamedList innerResponse = (NamedList) response.getResponse().get("status");
return RequestStatusState.fromKey((String) innerResponse.get("state"));
}
private void createCollection(String name, String config, int numShards, int numReplicas, int maxShardsPerNode)
throws Exception {
CollectionAdminResponse response;
CollectionAdminRequest.Create create =
CollectionAdminRequest.createCollection(name, config, numShards, numReplicas);
create.setMaxShardsPerNode(maxShardsPerNode);
response = create.process(solrCluster.getSolrClient());
if (response.getStatus() != 0 || response.getErrorMessages() != null) {
fail("Could not create collection. Response" + response.toString());
}
ZkStateReader zkStateReader = solrCluster.getSolrClient().getZkStateReader();
solrCluster.waitForActiveCollection(name, numShards, numShards * numReplicas);
}
private CollectionAdminResponse createCollection(Map<String, List<Integer>> collectionInfos,
String collectionName, int numShards, int replicationFactor,
int maxShardsPerNode, SolrClient client, String createNodeSetStr)
throws SolrServerException, IOException {
return createCollection(collectionInfos, collectionName,
Utils.makeMap(
NUM_SLICES, numShards,
REPLICATION_FACTOR, replicationFactor,
CREATE_NODE_SET, createNodeSetStr,
MAX_SHARDS_PER_NODE, maxShardsPerNode),
client, "conf1");
}
private static boolean runningSolrIsCloud(String url) throws Exception {
try (final HttpSolrClient client = new HttpSolrClient.Builder(url).build()) {
final SolrRequest<CollectionAdminResponse> request = new CollectionAdminRequest.ClusterStatus();
final CollectionAdminResponse response = request.process(client);
return response != null;
} catch (Exception e) {
if (exceptionIsAuthRelated(e)) {
throw e;
}
return false;
}
}
public void createSnapshot(String collectionName, String snapshotName) {
CollectionAdminRequest.CreateSnapshot createSnap = new CollectionAdminRequest.CreateSnapshot(collectionName, snapshotName);
CollectionAdminResponse resp;
try {
resp = createSnap.process(solrClient);
Preconditions.checkState(resp.getStatus() == 0, "The CREATESNAPSHOT request failed. The status code is " + resp.getStatus());
CLIO.out("Successfully created snapshot with name " + snapshotName + " for collection " + collectionName);
} catch (Exception e) {
log.error("Failed to create a snapshot with name {} for collection {}", snapshotName, collectionName, e);
CLIO.out("Failed to create a snapshot with name " + snapshotName + " for collection " + collectionName
+" due to following error : "+e.getLocalizedMessage());
}
}
public void deleteSnapshot(String collectionName, String snapshotName) {
CollectionAdminRequest.DeleteSnapshot deleteSnap = new CollectionAdminRequest.DeleteSnapshot(collectionName, snapshotName);
CollectionAdminResponse resp;
try {
resp = deleteSnap.process(solrClient);
Preconditions.checkState(resp.getStatus() == 0, "The DELETESNAPSHOT request failed. The status code is " + resp.getStatus());
CLIO.out("Successfully deleted snapshot with name " + snapshotName + " for collection " + collectionName);
} catch (Exception e) {
log.error("Failed to delete a snapshot with name {} for collection {}", snapshotName, collectionName, e);
CLIO.out("Failed to delete a snapshot with name " + snapshotName + " for collection " + collectionName
+" due to following error : "+e.getLocalizedMessage());
}
}
public void backupCollectionMetaData(String collectionName, String snapshotName, String backupLoc) throws SolrServerException, IOException {
// Backup the collection meta-data
CollectionAdminRequest.Backup backup = new CollectionAdminRequest.Backup(collectionName, snapshotName);
backup.setIndexBackupStrategy(CollectionAdminParams.NO_INDEX_BACKUP_STRATEGY);
backup.setLocation(backupLoc);
CollectionAdminResponse resp = backup.process(solrClient);
Preconditions.checkState(resp.getStatus() == 0, "The request failed. The status code is " + resp.getStatus());
}
@Test
public void doBlobHandlerTest() throws Exception {
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
CollectionAdminResponse response1;
CollectionAdminRequest.Create createCollectionRequest = CollectionAdminRequest.createCollection(".system",1,2);
response1 = createCollectionRequest.process(client);
assertEquals(0, response1.getStatus());
assertTrue(response1.isSuccess());
DocCollection sysColl = cloudClient.getZkStateReader().getClusterState().getCollection(".system");
Replica replica = sysColl.getActiveSlicesMap().values().iterator().next().getLeader();
String baseUrl = replica.getStr(ZkStateReader.BASE_URL_PROP);
String url = baseUrl + "/.system/config/requestHandler";
MapWriter map = TestSolrConfigHandlerConcurrent.getAsMap(url, cloudClient);
assertNotNull(map);
assertEquals("solr.BlobHandler", map._get(asList(
"config",
"requestHandler",
"/blob",
"class"),null));
map = TestSolrConfigHandlerConcurrent.getAsMap(baseUrl + "/.system/schema/fields/blob", cloudClient);
assertNotNull(map);
assertEquals("blob", map._get(asList(
"field",
"name"),null));
assertEquals("bytes", map._get( asList(
"field",
"type"),null));
checkBlobPost(baseUrl, cloudClient);
checkBlobPostMd5(baseUrl, cloudClient);
}
}
public static void createSystemCollection(SolrClient client) throws SolrServerException, IOException {
CollectionAdminResponse response1;
CollectionAdminRequest.Create createCollectionRequest = CollectionAdminRequest.createCollection(".system",1,2);
response1 = createCollectionRequest.process(client);
assertEquals(0, response1.getStatus());
assertTrue(response1.isSuccess());
}
void createCollectionWithRetry(String testCollectionName, String config, int numShards, int replicationFactor, int maxShardsPerNode) throws IOException, SolrServerException, InterruptedException, TimeoutException {
CollectionAdminResponse resp = createCollection(testCollectionName, "conf1", numShards, replicationFactor, maxShardsPerNode);
if (resp.getResponse().get("failure") != null) {
Thread.sleep(5000); // let system settle down. This should be very rare.
CollectionAdminRequest.deleteCollection(testCollectionName).process(cloudClient);
resp = createCollection(testCollectionName, "conf1", numShards, replicationFactor, maxShardsPerNode);
if (resp.getResponse().get("failure") != null) {
fail("Could not create " + testCollectionName);
}
}
}