Java Code Examples for org.apache.solr.client.solrj.request.CollectionAdminRequest#getClusterStatus()

The following examples show how to use org.apache.solr.client.solrj.request.CollectionAdminRequest#getClusterStatus() . 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: CollectionAdminRequestRequiredParamsTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public void testClusterStatus() {
  final CollectionAdminRequest.ClusterStatus request = CollectionAdminRequest.getClusterStatus();
  assertContainsParams(request.getParams(), ACTION);

  request.setCollectionName("foo");
  assertContainsParams(request.getParams(), ACTION, COLLECTION);
  
  request.setShardName("foo");
  assertContainsParams(request.getParams(), ACTION, COLLECTION, SHARD);

  request.setRouteKey("foo");
  request.setShardName(null);
  assertContainsParams(request.getParams(), ACTION, COLLECTION, ShardParams._ROUTE_);
  
}
 
Example 2
Source File: TestCollectionAPI.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private void testNoConfigset() throws Exception {
  String configSet = "delete_config";

  final String collection = "deleted_collection";
  try (CloudSolrClient client = createCloudClient(null)) {
    copyConfigUp(TEST_PATH().resolve("configsets"), "cloud-minimal", configSet, client.getZkHost());

    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("action", CollectionParams.CollectionAction.CREATE.toString());
    params.set("name", collection);
    params.set("numShards", "1");
    params.set("replicationFactor", "1");
    params.set("collection.configName", configSet);
    @SuppressWarnings({"rawtypes"})
    SolrRequest request = new QueryRequest(params);
    request.setPath("/admin/collections");

    client.request(request);

    waitForCollection(cloudClient.getZkStateReader(), collection, 1);
    waitForRecoveriesToFinish(collection, false);

    // Now try deleting the configset and doing a clusterstatus.
    String parent = ZkConfigManager.CONFIGS_ZKNODE + "/" + configSet;
    deleteThemAll(client.getZkStateReader().getZkClient(), parent);
    client.getZkStateReader().forciblyRefreshAllClusterStateSlow();

    final CollectionAdminRequest.ClusterStatus req = CollectionAdminRequest.getClusterStatus();
    NamedList<Object> rsp = client.request(req);
    @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("Testing to insure collections are returned", collections.get(COLLECTION_NAME1));
  }
}