Java Code Examples for org.apache.solr.client.solrj.SolrRequest#setPath()

The following examples show how to use org.apache.solr.client.solrj.SolrRequest#setPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCollectionAPI.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void clusterStatusNoCollection() throws Exception {

    try (CloudSolrClient client = createCloudClient(null)) {
      ModifiableSolrParams params = new ModifiableSolrParams();
      params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
      @SuppressWarnings({"rawtypes"})
      SolrRequest request = new QueryRequest(params);
      request.setPath("/admin/collections");

      NamedList<Object> rsp = client.request(request);
      @SuppressWarnings({"unchecked"})
      NamedList<Object> cluster = (NamedList<Object>) rsp.get("cluster");
      assertNotNull("Cluster state should not be null", cluster);
      @SuppressWarnings({"unchecked"})
      NamedList<Object> collections = (NamedList<Object>) cluster.get("collections");
      assertNotNull("Collections should not be null in cluster state", collections);
      assertNotNull(collections.get(COLLECTION_NAME1));
      assertEquals(4, collections.size());

      @SuppressWarnings({"unchecked"})
      List<String> liveNodes = (List<String>) cluster.get("live_nodes");
      assertNotNull("Live nodes should not be null", liveNodes);
      assertFalse(liveNodes.isEmpty());
    }

  }
 
Example 2
Source File: SSLMigrationTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void setUrlScheme(String value) throws Exception {
  @SuppressWarnings("rawtypes")
  Map m = makeMap("action", CollectionAction.CLUSTERPROP.toString()
      .toLowerCase(Locale.ROOT), "name", "urlScheme", "val", value);
  @SuppressWarnings("unchecked")
  SolrParams params = new MapSolrParams(m);
  @SuppressWarnings({"rawtypes"})
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");
  
  List<String> urls = new ArrayList<String>();
  for(Replica replica : getReplicas()) {
    urls.add(replica.getStr(ZkStateReader.BASE_URL_PROP));
  }
  //Create new SolrServer to configure new HttpClient w/ SSL config
  try (SolrClient client = getLBHttpSolrClient(urls.toArray(new String[]{}))) {
    client.request(request);
  }
}
 
Example 3
Source File: TestCollectionAPI.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void testAliasCreationNameValidation() throws Exception{
  try (CloudSolrClient client = createCloudClient(null)) {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("action", CollectionParams.CollectionAction.CREATEALIAS.toString());
    params.set("name", "invalid@name#with$weird%characters");
    params.set("collections", COLLECTION_NAME);
    @SuppressWarnings({"rawtypes"})
    SolrRequest request = new QueryRequest(params);
    request.setPath("/admin/collections");

    try {
      client.request(request);
      fail();
    } catch (BaseHttpSolrClient.RemoteSolrException e) {
      final String errorMessage = e.getMessage();
      assertTrue(errorMessage.contains("Invalid alias"));
      assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
      assertTrue(errorMessage.contains("alias names must consist entirely of"));
    }
  }
}
 
Example 4
Source File: TestCollectionAPI.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void testCollectionCreationShardNameValidation() throws Exception {
  try (CloudSolrClient client = createCloudClient(null)) {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("action", CollectionParams.CollectionAction.CREATE.toString());
    params.set("name", "valid_collection_name");
    params.set("router.name", "implicit");
    params.set("numShards", "1");
    params.set("shards", "invalid@name#with$weird%characters");
    @SuppressWarnings({"rawtypes"})
    SolrRequest request = new QueryRequest(params);
    request.setPath("/admin/collections");

    try {
      client.request(request);
      fail();
    } catch (BaseHttpSolrClient.RemoteSolrException e) {
      final String errorMessage = e.getMessage();
      assertTrue(errorMessage.contains("Invalid shard"));
      assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
      assertTrue(errorMessage.contains("shard names must consist entirely of"));
    }
  }
}
 
Example 5
Source File: TestCollectionAPI.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void testCollectionCreationCollectionNameValidation() throws Exception {
  try (CloudSolrClient client = createCloudClient(null)) {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("action", CollectionParams.CollectionAction.CREATE.toString());
    params.set("name", "invalid@name#with$weird%characters");
    @SuppressWarnings({"rawtypes"})
    SolrRequest request = new QueryRequest(params);
    request.setPath("/admin/collections");

    try {
      client.request(request);
      fail();
    } catch (BaseHttpSolrClient.RemoteSolrException e) {
      final String errorMessage = e.getMessage();
      assertTrue(errorMessage.contains("Invalid collection"));
      assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
      assertTrue(errorMessage.contains("collection names must consist entirely of"));
    }
  }
}
 
Example 6
Source File: TestRebalanceLeaders.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
void setPropWithStandardRequest(Slice slice, Replica rep, String prop) throws IOException, SolrServerException {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("action", CollectionParams.CollectionAction.ADDREPLICAPROP.toString());

  params.set("collection", COLLECTION_NAME);
  params.set("shard", slice.getName());
  params.set("replica", rep.getName());
  params.set("property", prop);
  params.set("property.value", "true");
  // Test to insure that implicit shardUnique is added for preferredLeader.
  if (prop.toLowerCase(Locale.ROOT).equals("preferredleader") == false) {
    params.set("shardUnique", "true");
  }

  @SuppressWarnings({"rawtypes"})
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");
  cluster.getSolrClient().request(request);
  String propLC = prop.toLowerCase(Locale.ROOT);
  waitForState("Expecting property '" + prop + "'to appear on replica " + rep.getName(), COLLECTION_NAME,
      (n, c) -> "true".equals(c.getReplica(rep.getName()).getProperty(propLC)));

}
 
Example 7
Source File: TestCollectionAPI.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void clusterStatusWithCollection() throws IOException, SolrServerException {
    try (CloudSolrClient client = createCloudClient(null)) {
      ModifiableSolrParams params = new ModifiableSolrParams();
      params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
      params.set("collection", COLLECTION_NAME);
      @SuppressWarnings({"rawtypes"})
      SolrRequest request = new QueryRequest(params);
      request.setPath("/admin/collections");

      NamedList<Object> rsp = client.request(request);
      @SuppressWarnings({"unchecked"})
      NamedList<Object> cluster = (NamedList<Object>) rsp.get("cluster");
      assertNotNull("Cluster state should not be null", cluster);
      @SuppressWarnings({"unchecked"})
      NamedList<Object> collections = (NamedList<Object>) cluster.get("collections");
      assertNotNull("Collections should not be null in cluster state", collections);
      assertEquals(1, collections.size());
      @SuppressWarnings({"unchecked"})
      Map<String, Object> collection = (Map<String, Object>) collections.get(COLLECTION_NAME);
      assertNotNull(collection);
      assertEquals("conf1", collection.get("configName"));
//      assertEquals("1", collection.get("nrtReplicas"));
    }
  }
 
Example 8
Source File: TestCollectionAPI.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void listCollection() throws IOException, SolrServerException {
  try (CloudSolrClient client = createCloudClient(null)) {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("action", CollectionParams.CollectionAction.LIST.toString());
    @SuppressWarnings({"rawtypes"})
    SolrRequest request = new QueryRequest(params);
    request.setPath("/admin/collections");

    NamedList<Object> rsp = client.request(request);
    @SuppressWarnings({"unchecked"})
    List<String> collections = (List<String>) rsp.get("collections");
    assertTrue("control_collection was not found in list", collections.contains("control_collection"));
    assertTrue(DEFAULT_COLLECTION + " was not found in list", collections.contains(DEFAULT_COLLECTION));
    assertTrue(COLLECTION_NAME + " was not found in list", collections.contains(COLLECTION_NAME));
    assertTrue(COLLECTION_NAME1 + " was not found in list", collections.contains(COLLECTION_NAME1));
  }

}
 
Example 9
Source File: CollectionsAPIDistributedZkTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Test
public void testZeroNumShards() {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("action", CollectionAction.CREATE.toString());
  params.set("name", "acollection");
  params.set(REPLICATION_FACTOR, 10);
  params.set("numShards", 0);
  params.set("collection.configName", "conf");

  @SuppressWarnings({"rawtypes"})
  final SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");
  expectThrows(Exception.class, () -> {
    cluster.getSolrClient().request(request);
  });
}
 
Example 10
Source File: TestReplicaProperties.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void listCollection() throws IOException, SolrServerException {

    try (CloudSolrClient client = createCloudClient(null)) {
      ModifiableSolrParams params = new ModifiableSolrParams();
      params.set("action", CollectionParams.CollectionAction.LIST.toString());
      @SuppressWarnings({"rawtypes"})
      SolrRequest request = new QueryRequest(params);
      request.setPath("/admin/collections");

      NamedList<Object> rsp = client.request(request);
      @SuppressWarnings({"unchecked"})
      List<String> collections = (List<String>) rsp.get("collections");
      assertTrue("control_collection was not found in list", collections.contains("control_collection"));
      assertTrue(DEFAULT_COLLECTION + " was not found in list", collections.contains(DEFAULT_COLLECTION));
      assertTrue(COLLECTION_NAME + " was not found in list", collections.contains(COLLECTION_NAME));
    }
  }
 
Example 11
Source File: CdcrRequestHandler.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public Long call() throws Exception {
  try (HttpSolrClient server = new HttpSolrClient.Builder(baseUrl)
      .withConnectionTimeout(15000)
      .withSocketTimeout(60000)
      .build()) {

    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set(CommonParams.ACTION, CdcrParams.CdcrAction.SHARDCHECKPOINT.toString());

    @SuppressWarnings({"rawtypes"})
    SolrRequest request = new QueryRequest(params);
    request.setPath(cdcrPath);

    @SuppressWarnings({"rawtypes"})
    NamedList response = server.request(request);
    return (Long) response.get(CdcrParams.CHECKPOINT);
  }
}
 
Example 12
Source File: TestConfigSetsAPI.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 13
Source File: TestCollectionAPI.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private void clusterStatusWithCollectionAndShard() throws IOException, SolrServerException {

    try (CloudSolrClient client = createCloudClient(null)) {
      ModifiableSolrParams params = new ModifiableSolrParams();
      params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
      params.set("collection", COLLECTION_NAME);
      params.set("shard", SHARD1);
      @SuppressWarnings({"rawtypes"})
      SolrRequest request = new QueryRequest(params);
      request.setPath("/admin/collections");

      NamedList<Object> rsp = client.request(request);
      @SuppressWarnings({"unchecked"})
      NamedList<Object> cluster = (NamedList<Object>) rsp.get("cluster");
      assertNotNull("Cluster state should not be null", cluster);
      @SuppressWarnings({"unchecked"})
      NamedList<Object> collections = (NamedList<Object>) cluster.get("collections");
      assertNotNull("Collections should not be null in cluster state", collections);
      assertNotNull(collections.get(COLLECTION_NAME));
      assertEquals(1, collections.size());
      @SuppressWarnings({"unchecked"})
      Map<String, Object> collection = (Map<String, Object>) collections.get(COLLECTION_NAME);
      @SuppressWarnings({"unchecked"})
      Map<String, Object> shardStatus = (Map<String, Object>) collection.get("shards");
      assertEquals(1, shardStatus.size());
      @SuppressWarnings({"unchecked"})
      Map<String, Object> selectedShardStatus = (Map<String, Object>) shardStatus.get(SHARD1);
      assertNotNull(selectedShardStatus);

    }
  }
 
Example 14
Source File: BasicDistributedZkTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
protected CollectionAdminResponse createCollection(Map<String, List<Integer>> collectionInfos,
                                                   String collectionName, String configSetName, int numShards, int numReplicas, int maxShardsPerNode, SolrClient client, String createNodeSetStr) throws SolrServerException, IOException {
  // TODO: Use CollectionAdminRequest for this test
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("action", CollectionAction.CREATE.toString());

  params.set(OverseerCollectionMessageHandler.NUM_SLICES, numShards);
  params.set(ZkStateReader.REPLICATION_FACTOR, numReplicas);
  params.set(ZkStateReader.MAX_SHARDS_PER_NODE, maxShardsPerNode);
  if (createNodeSetStr != null) params.set(OverseerCollectionMessageHandler.CREATE_NODE_SET, createNodeSetStr);

  int clientIndex = clients.size() > 1 ? random().nextInt(2) : 0;
  List<Integer> list = new ArrayList<>();
  list.add(numShards);
  list.add(numReplicas);
  if (collectionInfos != null) {
    collectionInfos.put(collectionName, list);
  }
  params.set("name", collectionName);
  params.set("collection.configName", configSetName);
  @SuppressWarnings({"rawtypes"})
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");

  CollectionAdminResponse res = new CollectionAdminResponse();
  if (client == null) {
    final String baseUrl = ((HttpSolrClient) clients.get(clientIndex)).getBaseURL().substring(
        0,
        ((HttpSolrClient) clients.get(clientIndex)).getBaseURL().length()
            - DEFAULT_COLLECTION.length() - 1);
    
    try (SolrClient aClient = createNewSolrClient("", baseUrl)) {
      res.setResponse(aClient.request(request));
    }
  } else {
    res.setResponse(client.request(request));
  }
  return res;
}
 
Example 15
Source File: BaseCdcrDistributedZkTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Invokes a CDCR action on a given node.
 */
@SuppressWarnings({"rawtypes"})
protected NamedList invokeCdcrAction(CloudJettyRunner jetty, CdcrParams.CdcrAction action) throws Exception {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(CommonParams.ACTION, action.toString());

  SolrRequest request = new QueryRequest(params);
  request.setPath(CDCR_PATH);

  return jetty.client.request(request);
}
 
Example 16
Source File: TestCollectionAPI.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private void clusterStatusWithRouteKey() throws IOException, SolrServerException {
  try (CloudSolrClient client = createCloudClient(DEFAULT_COLLECTION)) {
    SolrInputDocument doc = new SolrInputDocument();
    doc.addField("id", "a!123"); // goes to shard2. see ShardRoutingTest for details
    client.add(doc);
    client.commit();

    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
    params.set("collection", DEFAULT_COLLECTION);
    params.set(ShardParams._ROUTE_, "a!");
    @SuppressWarnings({"rawtypes"})
    SolrRequest request = new QueryRequest(params);
    request.setPath("/admin/collections");

    NamedList<Object> rsp = client.request(request);
    @SuppressWarnings({"unchecked"})
    NamedList<Object> cluster = (NamedList<Object>) rsp.get("cluster");
    assertNotNull("Cluster state should not be null", cluster);
    @SuppressWarnings({"unchecked"})
    NamedList<Object> collections = (NamedList<Object>) cluster.get("collections");
    assertNotNull("Collections should not be null in cluster state", collections);
    assertNotNull(collections.get(DEFAULT_COLLECTION));
    assertEquals(1, collections.size());
    @SuppressWarnings({"unchecked"})
    Map<String, Object> collection = (Map<String, Object>) collections.get(DEFAULT_COLLECTION);
    assertEquals("conf1", collection.get("configName"));
    @SuppressWarnings({"unchecked"})
    Map<String, Object> shardStatus = (Map<String, Object>) collection.get("shards");
    assertEquals(1, shardStatus.size());
    @SuppressWarnings({"unchecked"})
    Map<String, Object> selectedShardStatus = (Map<String, Object>) shardStatus.get(SHARD2);
    assertNotNull(selectedShardStatus);
  }
}
 
Example 17
Source File: ShardSplitTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
protected void splitShard(String collection, String shardId, List<DocRouter.Range> subRanges, String splitKey, boolean offline) throws SolrServerException, IOException {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("action", CollectionParams.CollectionAction.SPLITSHARD.toString());
  params.set("timing", "true");
  params.set("offline", String.valueOf(offline));
  params.set("collection", collection);
  if (shardId != null)  {
    params.set("shard", shardId);
  }
  if (subRanges != null)  {
    StringBuilder ranges = new StringBuilder();
    for (int i = 0; i < subRanges.size(); i++) {
      DocRouter.Range subRange = subRanges.get(i);
      ranges.append(subRange.toString());
      if (i < subRanges.size() - 1)
        ranges.append(",");
    }
    params.set("ranges", ranges.toString());
  }
  if (splitKey != null) {
    params.set("split.key", splitKey);
  }
  @SuppressWarnings({"rawtypes"})
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");

  String baseUrl = ((HttpSolrClient) shardToJetty.get(SHARD1).get(0).client.getSolrClient()).getBaseURL();
  baseUrl = baseUrl.substring(0, baseUrl.length() - "collection1".length());

  try (HttpSolrClient baseServer = getHttpSolrClient(baseUrl, 30000, 60000 * 5)) {
    NamedList<Object> rsp = baseServer.request(request);
    if (log.isInfoEnabled()) {
      log.info("Shard split response: {}", Utils.toJSONString(rsp));
    }
  }
}
 
Example 18
Source File: BaseCdcrDistributedZkTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private CollectionAdminResponse createCollection(Map<String, List<Integer>> collectionInfos, String collectionName,
                                                 Map<String, Object> collectionProps, SolrClient client,
                                                 String confSetName)
    throws SolrServerException, IOException {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("action", CollectionParams.CollectionAction.CREATE.toString());
  for (Map.Entry<String, Object> entry : collectionProps.entrySet()) {
    if (entry.getValue() != null) params.set(entry.getKey(), String.valueOf(entry.getValue()));
  }
  Integer numShards = (Integer) collectionProps.get(OverseerCollectionMessageHandler.NUM_SLICES);
  if (numShards == null) {
    String shardNames = (String) collectionProps.get(OverseerCollectionMessageHandler.SHARDS_PROP);
    numShards = StrUtils.splitSmart(shardNames, ',').size();
  }
  Integer replicationFactor = (Integer) collectionProps.get(REPLICATION_FACTOR);
  if (replicationFactor == null) {
    replicationFactor = (Integer) OverseerCollectionMessageHandler.COLLECTION_PROPS_AND_DEFAULTS.get(REPLICATION_FACTOR);
  }

  if (confSetName != null) {
    params.set("collection.configName", confSetName);
  }

  List<Integer> list = new ArrayList<>();
  list.add(numShards);
  list.add(replicationFactor);
  if (collectionInfos != null) {
    collectionInfos.put(collectionName, list);
  }
  params.set("name", collectionName);
  @SuppressWarnings({"rawtypes"})
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");

  CollectionAdminResponse res = new CollectionAdminResponse();
  res.setResponse(client.request(request));
  return res;
}
 
Example 19
Source File: TestCollectionAPI.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({"unchecked"})
private void clusterStatusZNodeVersion() throws Exception {
  String cname = "clusterStatusZNodeVersion";
  try (CloudSolrClient client = createCloudClient(null)) {
    setV2(CollectionAdminRequest.createCollection(cname, "conf1", 1, 1).setMaxShardsPerNode(1)).process(client);
    assertV2CallsCount();
    waitForRecoveriesToFinish(cname, true);

    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
    params.set("collection", cname);
    @SuppressWarnings({"rawtypes"})
    SolrRequest request = new QueryRequest(params);
    request.setPath("/admin/collections");

    NamedList<Object> rsp = client.request(request);
    NamedList<Object> cluster = (NamedList<Object>) rsp.get("cluster");
    assertNotNull("Cluster state should not be null", cluster);
    NamedList<Object> collections = (NamedList<Object>) cluster.get("collections");
    assertNotNull("Collections should not be null in cluster state", collections);
    assertEquals(1, collections.size());
    Map<String, Object> collection = (Map<String, Object>) collections.get(cname);
    assertNotNull(collection);
    assertEquals("conf1", collection.get("configName"));
    Integer znodeVersion = (Integer) collection.get("znodeVersion");
    assertNotNull(znodeVersion);

    CollectionAdminRequest.AddReplica addReplica = CollectionAdminRequest.addReplicaToShard(cname, "shard1");
    setV2(addReplica);
    addReplica.process(client);
    assertV2CallsCount();
    waitForRecoveriesToFinish(cname, true);

    rsp = client.request(request);
    cluster = (NamedList<Object>) rsp.get("cluster");
    collections = (NamedList<Object>) cluster.get("collections");
    collection = (Map<String, Object>) collections.get(cname);
    Integer newVersion = (Integer) collection.get("znodeVersion");
    assertNotNull(newVersion);
    assertTrue(newVersion > znodeVersion);
  }
}
 
Example 20
Source File: AbstractFullDistribZkTestBase.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
protected CollectionAdminResponse createCollection(Map<String, List<Integer>> collectionInfos, String collectionName, Map<String, Object> collectionProps, SolrClient client, String confSetName)  throws SolrServerException, IOException, InterruptedException, TimeoutException{
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("action", CollectionAction.CREATE.toString());
  for (Map.Entry<String, Object> entry : collectionProps.entrySet()) {
    if(entry.getValue() !=null) params.set(entry.getKey(), String.valueOf(entry.getValue()));
  }
  Integer numShards = (Integer) collectionProps.get(OverseerCollectionMessageHandler.NUM_SLICES);
  if(numShards==null){
    String shardNames = (String) collectionProps.get(OverseerCollectionMessageHandler.SHARDS_PROP);
    numShards = StrUtils.splitSmart(shardNames,',').size();
  }
  Integer numNrtReplicas = (Integer) collectionProps.get(ZkStateReader.NRT_REPLICAS);
  if (numNrtReplicas == null) {
    numNrtReplicas = (Integer) collectionProps.get(ZkStateReader.REPLICATION_FACTOR);
  }
  if(numNrtReplicas == null){
    numNrtReplicas = (Integer) OverseerCollectionMessageHandler.COLLECTION_PROPS_AND_DEFAULTS.get(ZkStateReader.REPLICATION_FACTOR);
  }
  if (numNrtReplicas == null) {
    numNrtReplicas = Integer.valueOf(0);
  }
  Integer numTlogReplicas = (Integer) collectionProps.get(ZkStateReader.TLOG_REPLICAS);
  if (numTlogReplicas == null) {
    numTlogReplicas = Integer.valueOf(0);
  }
  Integer numPullReplicas = (Integer) collectionProps.get(ZkStateReader.PULL_REPLICAS);
  if (numPullReplicas == null) {
    numPullReplicas = Integer.valueOf(0);
  }
  if (confSetName != null) {
    params.set("collection.configName", confSetName);
  } else {
    params.set("collection.configName", "conf1");
  }

  int clientIndex = random().nextInt(2);
  List<Integer> list = new ArrayList<>();
  list.add(numShards);
  list.add(numNrtReplicas + numTlogReplicas + numPullReplicas);
  if (collectionInfos != null) {
    collectionInfos.put(collectionName, list);
  }
  params.set("name", collectionName);
  @SuppressWarnings({"rawtypes"})
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");

  CollectionAdminResponse res = new CollectionAdminResponse();
  if (client == null) {
    final String baseUrl = getBaseUrl((HttpSolrClient) clients.get(clientIndex));
    try (SolrClient adminClient = createNewSolrClient("", baseUrl)) {
      res.setResponse(adminClient.request(request));
    }
  } else {
    res.setResponse(client.request(request));
  }
  
  try {
    cloudClient.waitForState(collectionName, 30, TimeUnit.SECONDS, SolrCloudTestCase.activeClusterShape(numShards,
        numShards * (numNrtReplicas + numTlogReplicas + numPullReplicas)));
  } catch (TimeoutException e) {
    throw new RuntimeException("Timeout waiting for " + numShards + " shards and " + (numNrtReplicas + numTlogReplicas + numPullReplicas) + " replicas.", e);
  }
  return res;
}