You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ge...@apache.org on 2022/10/20 18:54:35 UTC

[solr] branch branch_9x updated: SOLR-15748 : Created v2 equivalent of v1 'CLUSTERSTATUS' command (#1061)

This is an automated email from the ASF dual-hosted git repository.

gerlowskija pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 82e642edfa7 SOLR-15748 : Created v2 equivalent of v1 'CLUSTERSTATUS' command (#1061)
82e642edfa7 is described below

commit 82e642edfa79b20fd2691a134de5393d52f99f6b
Author: Joshua Ouma <jo...@gmail.com>
AuthorDate: Tue Oct 18 18:02:42 2022 +0300

    SOLR-15748 : Created v2 equivalent of v1 'CLUSTERSTATUS' command (#1061)
---
 solr/CHANGES.txt                                          |  3 +++
 .../core/src/java/org/apache/solr/handler/ClusterAPI.java | 15 +++++++++------
 .../org/apache/solr/handler/V2ClusterAPIMappingTest.java  |  5 +++--
 .../deployment-guide/pages/cluster-node-management.adoc   |  5 ++++-
 4 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d2cb1427986..de15dccddec 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -29,6 +29,9 @@ Improvements
   cause.  This capability is now also present on Windows.  Before, with bin/solr but not
   bin/solr.cmd, Solr would execute a script that killed the Solr pid, leaving a very small time
   window where Solr would continue to execute in an unpredictable state. (Shawn Heisey, Kevin Risden)
+  
+* SOLR-15748: 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.java
index 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.java
index 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));
   }
 
   @Test
diff --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.adoc
index 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
 
+----
 ====
 --