Skip to content

Commit

Permalink
Created v2 equivalent of v1 'CLUSTERSTATUS' command
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgog committed Oct 10, 2022
1 parent d9acc07 commit fb50537
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions solr/core/src/java/org/apache/solr/handler/CollectionsAPI.java
Expand Up @@ -80,6 +80,22 @@ public void getCollections(SolrQueryRequest req, SolrQueryResponse rsp) throws E
collectionsHandler.handleRequestBody(wrapParams(req, v1Params), rsp);
}

/**
* V2 API for displaying basic information about all collections.
*
* <p>This API (GET /v2/collections?) is analogous to the v1
* /admin/collections?action=CLUSTERSTATUS command.
*/
@EndPoint(
path = {"/c?", "/collections?"},
method = GET,
permission = COLL_READ_PERM)
public void getCollectionsStatuses(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
final Map<String, Object> v1Params = Maps.newHashMap();
v1Params.put(ACTION, CollectionAction.CLUSTERSTATUS.toLower());
collectionsHandler.handleRequestBody(wrapParams(req, v1Params), rsp);
}

@EndPoint(
path = {"/c", "/collections"},
method = POST,
Expand Down
Expand Up @@ -281,4 +281,12 @@ public void testRestoreAllProperties() throws Exception {
assertEquals("bar2", v1Params.get("property.foo2"));
assertEquals(3, v1Params.getPrimitiveInt(ZkStateReader.REPLICATION_FACTOR));
}

@Test
public void testListCollectionsStatusesAllProperties() throws Exception {
final String noBody = null;
final SolrParams v1Params = captureConvertedV1Params("/collections?", "GET", noBody);

assertEquals(CollectionParams.CollectionAction.CLUSTERSTATUS.lowerName, v1Params.get(ACTION));
}
}

0 comments on commit fb50537

Please sign in to comment.