Apache Solr open-source search software
SOLR-15748 : Created v2 equivalent of v1 'CLUSTERSTATUS' command (#1061)
Joshua Ouma79fba55c269d
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex b55af47762e..c7ef3c7ea8c 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -54,6 +54,9 @@ Improvementscause. This capability is now also present on Windows. Before, with bin/solr but notbin/solr.cmd, Solr would execute a script that killed the Solr pid, leaving a very small timewindow where Solr would continue to execute in an unpredictable state. (Shawn Heisey, Kevin Risden)++* SOLR-15478: A v2 equivalent of CLUSTERSTATUS command is now available at `GET /api/cluster`. Collection listing,+ previously at this path, can still be accessed at `GET /api/collections`. (Joshua Ouma via Jason Gerlowski)Optimizations---------------------diff --git a/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java b/solr/core/src/java/org/apache/solr/handler/ClusterAPI.javaindex a54ba441e65..1a56f7980d5 100644--- a/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java+++ b/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java@@ -25,7 +25,6 @@ import static org.apache.solr.common.params.CollectionParams.ACTION;import static org.apache.solr.common.params.CollectionParams.CollectionAction.ADDROLE;import static org.apache.solr.common.params.CollectionParams.CollectionAction.CLUSTERPROP;import static org.apache.solr.common.params.CollectionParams.CollectionAction.DELETESTATUS;-import static org.apache.solr.common.params.CollectionParams.CollectionAction.LIST;import static org.apache.solr.common.params.CollectionParams.CollectionAction.OVERSEERSTATUS;import static org.apache.solr.common.params.CollectionParams.CollectionAction.REMOVEROLE;import static org.apache.solr.common.params.CollectionParams.CollectionAction.REQUESTSTATUS;@@ -52,6 +51,8 @@ import org.apache.solr.common.annotation.JsonProperty;import org.apache.solr.common.cloud.ClusterProperties;import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.CollectionParams;+import org.apache.solr.common.params.CollectionParams.CollectionAction;+import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.DefaultSolrParams;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.ReflectMapWriter;@@ -209,11 +210,6 @@ public class ClusterAPI {collectionsHandler.handleRequestBody(wrapParams(req, "action", OVERSEERSTATUS.lowerName), rsp);}- @EndPoint(method = GET, path = "/cluster", permission = COLL_READ_PERM)- public void getCluster(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {- collectionsHandler.handleRequestBody(wrapParams(req, "action", LIST.lowerName), rsp);- }-@EndPoint(method = DELETE, path = "/cluster/command-status/{id}", permission = COLL_EDIT_PERM)public void deleteCommandStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {final Map<String, Object> v1Params = Maps.newHashMap();@@ -261,6 +257,13 @@ public class ClusterAPI {rsp.add("nodes", getCoreContainer().getZkController().getClusterState().getLiveNodes());}+ @EndPoint(method = GET, path = "/cluster", permission = COLL_READ_PERM)+ public void getClusterStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {+ final Map<String, Object> v1Params = Maps.newHashMap();+ v1Params.put(CommonParams.ACTION, CollectionAction.CLUSTERSTATUS.toLower());+ collectionsHandler.handleRequestBody(wrapParams(req, v1Params), rsp);+ }+private CoreContainer getCoreContainer() {return collectionsHandler.getCoreContainer();}diff --git a/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.javaindex b2e2b976e8b..c405a0551c8 100644--- a/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java+++ b/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java@@ -34,6 +34,7 @@ import java.util.Map;import org.apache.solr.api.Api;import org.apache.solr.api.ApiBag;import org.apache.solr.common.params.CollectionParams;+import org.apache.solr.common.params.CollectionParams.CollectionAction;import org.apache.solr.common.params.SolrParams;import org.apache.solr.common.util.CommandOperation;import org.apache.solr.common.util.ContentStreamBase;@@ -95,10 +96,10 @@ public class V2ClusterAPIMappingTest {}@Test- public void testListClusterAllParams() throws Exception {+ public void testClusterStatusAllParams() throws Exception {final SolrParams v1Params = captureConvertedV1Params("/cluster", "GET", null);- assertEquals(CollectionParams.CollectionAction.LIST.lowerName, v1Params.get(ACTION));+ assertEquals(CollectionAction.CLUSTERSTATUS.lowerName, v1Params.get(ACTION));}@Testdiff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/cluster-node-management.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/cluster-node-management.adocindex 1cf0fa3e8d9..48f592b6009 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/cluster-node-management.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/cluster-node-management.adoc@@ -60,8 +60,11 @@ http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS====[.tab-label]*V2 API*-We do not currently have a V2 equivalent.+[source,bash]+----+curl -X GET http://localhost:8983/api/cluster+----====--