You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2020/12/29 06:01:11 UTC

[lucene-solr] branch jira/solr15062 created (now af7cca5)

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

noble pushed a change to branch jira/solr15062
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


      at af7cca5  SOLR-15062: /api/cluster/zk/ls should give the stat of the current node

This branch includes the following new commits:

     new af7cca5  SOLR-15062: /api/cluster/zk/ls should give the stat of the current node

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[lucene-solr] 01/01: SOLR-15062: /api/cluster/zk/ls should give the stat of the current node

Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch jira/solr15062
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit af7cca573ba94e8acf64d27296fa943c8642726c
Author: noblepaul <no...@gmail.com>
AuthorDate: Tue Dec 29 17:00:43 2020 +1100

    SOLR-15062: /api/cluster/zk/ls should give the stat of the current node
---
 .../solr/handler/admin/ZookeeperReadAPI.java       | 33 ++++++++++++----------
 .../solr/handler/admin/ZookeeperReadAPITest.java   |  1 +
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperReadAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperReadAPI.java
index 60a53b8..18bed3e 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperReadAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperReadAPI.java
@@ -101,6 +101,11 @@ public class ZookeeperReadAPI {
     String path = req.getPathTemplateValues().get("*");
     if (path == null || path.isEmpty()) path = "/";
     try {
+      Stat stat = coreContainer.getZkController().getZkClient().exists(path, null, true);
+      rsp.add("stat", (MapWriter) ew -> printStat(ew, stat));
+      if(!req.getParams().getBool("c", true)) {
+        return;
+      }
       List<String> l = coreContainer.getZkController().getZkClient().getChildren(path, null, false);
       String prefix = path.endsWith("/") ? path : path + "/";
 
@@ -114,7 +119,7 @@ public class ZookeeperReadAPI {
       }
       rsp.add(path, (MapWriter) ew -> {
         for (Map.Entry<String, Stat> e : stats.entrySet()) {
-          printStat(ew, e.getKey(), e.getValue());
+         ew.put(e.getKey(), (MapWriter) ew1 -> printStat(ew1, e.getValue()));
         }
       });
     } catch (KeeperException.NoNodeException e) {
@@ -126,20 +131,18 @@ public class ZookeeperReadAPI {
     }
   }
 
-  private void printStat(MapWriter.EntryWriter ew, String s, Stat stat) throws IOException {
-    ew.put(s, (MapWriter) ew1 -> {
-      ew1.put("version", stat.getVersion());
-      ew1.put("aversion", stat.getAversion());
-      ew1.put("children", stat.getNumChildren());
-      ew1.put("ctime", stat.getCtime());
-      ew1.put("cversion", stat.getCversion());
-      ew1.put("czxid", stat.getCzxid());
-      ew1.put("ephemeralOwner", stat.getEphemeralOwner());
-      ew1.put("mtime", stat.getMtime());
-      ew1.put("mzxid", stat.getMzxid());
-      ew1.put("pzxid", stat.getPzxid());
-      ew1.put("dataLength", stat.getDataLength());
-    });
+  private void printStat(MapWriter.EntryWriter ew, Stat stat) throws IOException {
+    ew.put("version", stat.getVersion());
+    ew.put("aversion", stat.getAversion());
+    ew.put("children", stat.getNumChildren());
+    ew.put("ctime", stat.getCtime());
+    ew.put("cversion", stat.getCversion());
+    ew.put("czxid", stat.getCzxid());
+    ew.put("ephemeralOwner", stat.getEphemeralOwner());
+    ew.put("mtime", stat.getMtime());
+    ew.put("mzxid", stat.getMzxid());
+    ew.put("pzxid", stat.getPzxid());
+    ew.put("dataLength", stat.getDataLength());
   }
 
 }
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperReadAPITest.java b/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperReadAPITest.java
index d7ad7c6..3376d34 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperReadAPITest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/ZookeeperReadAPITest.java
@@ -73,6 +73,7 @@ public class ZookeeperReadAPITest extends SolrCloudTestCase {
           Utils.JSONCONSUMER);
       assertEquals("0", String.valueOf(getObjectByPath(o, true, split(":/configs:_default:dataLength", ':'))));
       assertEquals("0", String.valueOf(getObjectByPath(o, true, split(":/configs:conf:dataLength", ':'))));
+      assertEquals("0", String.valueOf(getObjectByPath(o, true, split("/stat/version", '/'))));
 
       o = Utils.executeGET(client.getHttpClient(),
           basezk + "/configs",