You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 09:53:29 UTC

[lucene] 15/45: refactor /cluster/aliases V2 API to use annotations

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

dweiss pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 49c494261769b7d178121a059ef7c930edeaf272
Author: Noble Paul <no...@gmail.com>
AuthorDate: Tue Feb 23 13:03:38 2021 +1100

    refactor /cluster/aliases V2 API to use annotations
---
 solr/core/src/java/org/apache/solr/handler/ClusterAPI.java   |  7 +++++++
 .../solr/client/solrj/request/CollectionApiMapping.java      |  3 ---
 solr/solrj/src/resources/apispec/cluster.aliases.json        | 12 ------------
 .../org/apache/solr/client/solrj/request/TestV2Request.java  |  5 +++++
 4 files changed, 12 insertions(+), 15 deletions(-)

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 945e4c7..a1a6d6f 100644
--- a/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
@@ -71,6 +71,13 @@ public class ClusterAPI {
   }
 
   @EndPoint(method = GET,
+      path = "/cluster/aliases",
+      permission = COLL_READ_PERM)
+  public void aliases(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+    CollectionsHandler.CollectionOperation.LISTALIASES_OP.execute(req, rsp, getCoreContainer().getCollectionsHandler());
+  }
+
+  @EndPoint(method = GET,
       path = "/cluster/overseer",
       permission = COLL_READ_PERM)
   public void getOverseerStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionApiMapping.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionApiMapping.java
index 9b106ab..3be93de 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionApiMapping.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionApiMapping.java
@@ -37,7 +37,6 @@ import org.apache.solr.common.util.Utils;
 import static org.apache.solr.client.solrj.SolrRequest.METHOD.DELETE;
 import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
 import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
-import static org.apache.solr.client.solrj.request.CollectionApiMapping.EndPoint.CLUSTER_ALIASES;
 import static org.apache.solr.client.solrj.request.CollectionApiMapping.EndPoint.COLLECTIONS_COMMANDS;
 import static org.apache.solr.client.solrj.request.CollectionApiMapping.EndPoint.COLLECTION_STATE;
 import static org.apache.solr.client.solrj.request.CollectionApiMapping.EndPoint.PER_COLLECTION;
@@ -56,7 +55,6 @@ public class CollectionApiMapping {
 
   public enum Meta implements CommandMeta {
     GET_A_COLLECTION(COLLECTION_STATE, GET, CLUSTERSTATUS),
-    LIST_ALIASES(CLUSTER_ALIASES, GET, LISTALIASES),
     CREATE_COLLECTION(COLLECTIONS_COMMANDS,
         POST,
         CREATE,
@@ -303,7 +301,6 @@ public class CollectionApiMapping {
   }
 
   public enum EndPoint implements V2EndPoint {
-    CLUSTER_ALIASES("cluster.aliases"),
     COLLECTIONS_COMMANDS("collections.Commands"),
     COLLECTION_STATE("collections.collection"),
     PER_COLLECTION("collections.collection.Commands"),
diff --git a/solr/solrj/src/resources/apispec/cluster.aliases.json b/solr/solrj/src/resources/apispec/cluster.aliases.json
deleted file mode 100644
index c614002..0000000
--- a/solr/solrj/src/resources/apispec/cluster.aliases.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
-  "documentation": "https://lucene.apache.org/solr/guide/collection-aliasing.html",
-  "description": "Provides list of collection aliases.",
-  "methods": [
-    "GET"
-  ],
-  "url": {
-    "paths": [
-      "/cluster/aliases"
-    ]
-  }
-}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java
index 3e36f7d..f261189 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestV2Request.java
@@ -57,6 +57,11 @@ public class TestV2Request extends SolrCloudTestCase {
     List l = (List) rsp._get("nodes",null);
     assertNotNull(l);
     assertFalse(l.isEmpty());
+    rsp = new V2Request.Builder("/cluster/aliases")
+        .forceV2(true)
+        .withMethod(SolrRequest.METHOD.GET).build()
+        .process(cluster.getSolrClient());
+    assertTrue(rsp.getResponse().indexOf("aliases", 0) > -1);
   }
   
   @After