public void createCollection(String collectionName, String configName, int numShards) throws IOException {
int TIMEOUT = 30;
CloudSolrClient solrClient = new CloudSolrClient.Builder().withZkHost(getZkConnectString()).build();
solrClient.setDefaultCollection(collectionName);
CollectionAdminRequest.Create request = CollectionAdminRequest.createCollection(
collectionName, configName, numShards, 1);
request.setMaxShardsPerNode(numShards);
RequestStatusState state;
try {
state = request.processAndWait(solrClient, TIMEOUT);
} catch (SolrServerException | InterruptedException e) {
throw new RuntimeException(e);
}
if (state != RequestStatusState.COMPLETED && state != RequestStatusState.RUNNING) {
throw new IllegalStateException("Unexpected state: " + state);
}
waitForRecoveriesToFinish(
collectionName, solrClient.getZkStateReader(), true, true, TIMEOUT);
}