You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/03/11 00:22:17 UTC

[GitHub] [pulsar] rdhabalia opened a new pull request #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats

rdhabalia opened a new pull request #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats
URL: https://github.com/apache/pulsar/pull/6516
 
 
   ### Motivation
   Note: This PR is top on #6473 
   In PR: #6473 we have added REST-API to get stats for the pulsar-proxy.
   However, we also need cli tool to call such api and retrieve stats.
   
   ### Modification
   Added CLI for proxy-stats.
   
   **Note:**
   I will rebase this PR once, #6473 changes are reviewed and merged.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [pulsar] rdhabalia commented on a change in pull request #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats

Posted by GitBox <gi...@apache.org>.
rdhabalia commented on a change in pull request #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats
URL: https://github.com/apache/pulsar/pull/6516#discussion_r408543322
 
 

 ##########
 File path: pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdProxyStats.java
 ##########
 @@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.admin.cli;
+
+import java.io.IOException;
+
+import org.apache.pulsar.client.admin.PulsarAdmin;
+
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.Parameters;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+@Parameters(commandDescription = "Operations to collect broker statistics")
+public class CmdProxyStats extends CmdBase {
+    private static final String DEFAULT_INDENTATION = "    ";
+
+    @Parameters(commandDescription = "dump connections metrics for Monitoring")
+    private class CmdConnectionMetrics extends CliCommand {
+        @Parameter(names = { "-i", "--indent" }, description = "Indent JSON output", required = false)
+        private boolean indent = false;
+
+        @Override
+        void run() throws Exception {
+            JsonArray stats = admin.proxyStats().getConnections();
+            printStats(stats, indent);
+        }
+    }
+
+    @Parameters(commandDescription = "dump topics metrics for Monitoring")
+    private class CmdTopicsMetrics extends CliCommand {
+        @Parameter(names = { "-i", "--indent" }, description = "Indent JSON output", required = false)
+        private boolean indent = false;
+
+        @Override
+        void run() throws Exception {
+            JsonObject stats = admin.proxyStats().getTopics();
+            printStats(stats, indent);
+        }
+    }
+
+    public void printStats(JsonElement json, boolean indent) throws IOException {
+        GsonBuilder builder = new GsonBuilder();
+        Gson gson = indent ? builder.setPrettyPrinting().create() : builder.create();
+        System.out.println(gson.toJson(json));
+    }
+
+    public CmdProxyStats(PulsarAdmin admin) {
+        super("broker-stats", admin);
 
 Review comment:
   oops. good catch.let me fix it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [pulsar] rdhabalia commented on issue #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats

Posted by GitBox <gi...@apache.org>.
rdhabalia commented on issue #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats
URL: https://github.com/apache/pulsar/pull/6516#issuecomment-613780128
 
 
   @jiazhai @ @codelipenghui addressed the comments and also rebased. 👍 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [pulsar] codelipenghui commented on a change in pull request #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats
URL: https://github.com/apache/pulsar/pull/6516#discussion_r394747608
 
 

 ##########
 File path: pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdProxyStats.java
 ##########
 @@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.admin.cli;
+
+import java.io.IOException;
+
+import org.apache.pulsar.client.admin.PulsarAdmin;
+
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.Parameters;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+@Parameters(commandDescription = "Operations to collect broker statistics")
+public class CmdProxyStats extends CmdBase {
+    private static final String DEFAULT_INDENTATION = "    ";
+
+    @Parameters(commandDescription = "dump connections metrics for Monitoring")
+    private class CmdConnectionMetrics extends CliCommand {
+        @Parameter(names = { "-i", "--indent" }, description = "Indent JSON output", required = false)
+        private boolean indent = false;
+
+        @Override
+        void run() throws Exception {
+            JsonArray stats = admin.proxyStats().getConnections();
+            printStats(stats, indent);
+        }
+    }
+
+    @Parameters(commandDescription = "dump topics metrics for Monitoring")
+    private class CmdTopicsMetrics extends CliCommand {
+        @Parameter(names = { "-i", "--indent" }, description = "Indent JSON output", required = false)
+        private boolean indent = false;
+
+        @Override
+        void run() throws Exception {
+            JsonObject stats = admin.proxyStats().getTopics();
+            printStats(stats, indent);
+        }
+    }
+
+    public void printStats(JsonElement json, boolean indent) throws IOException {
+        GsonBuilder builder = new GsonBuilder();
+        Gson gson = indent ? builder.setPrettyPrinting().create() : builder.create();
+        System.out.println(gson.toJson(json));
+    }
+
+    public CmdProxyStats(PulsarAdmin admin) {
+        super("broker-stats", admin);
 
 Review comment:
   ```suggestion
           super("proxy-stats", admin);
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [pulsar] rdhabalia edited a comment on issue #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats

Posted by GitBox <gi...@apache.org>.
rdhabalia edited a comment on issue #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats
URL: https://github.com/apache/pulsar/pull/6516#issuecomment-613780128
 
 
   @jiazhai @ @codelipenghui addressed the comments and also rebased. I will add all CLI and Rest API documentation in separate PR with input and output descriptions later on. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [pulsar] codelipenghui commented on a change in pull request #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats
URL: https://github.com/apache/pulsar/pull/6516#discussion_r394747547
 
 

 ##########
 File path: pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdProxyStats.java
 ##########
 @@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.admin.cli;
+
+import java.io.IOException;
+
+import org.apache.pulsar.client.admin.PulsarAdmin;
+
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.Parameters;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+@Parameters(commandDescription = "Operations to collect broker statistics")
 
 Review comment:
   ```suggestion
   @Parameters(commandDescription = "Operations to collect proxy statistics")
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [pulsar] jiazhai commented on issue #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats

Posted by GitBox <gi...@apache.org>.
jiazhai commented on issue #6516: [pulsar-proxy] Add CLI support to get pulsar-proxy stats
URL: https://github.com/apache/pulsar/pull/6516#issuecomment-611267824
 
 
   @rdhabalia Would you please handle @codelipenghui 's comments and rebased with latest master?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services