This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 054f7e2e85 ARTEMIS-4743 Improve Queue Stat output by allowing --loop
as an option
054f7e2e85 is described below
commit 054f7e2e85097e9bc6303dfb1e3ce16b5af65dc2
Author: Clebert Suconic <[email protected]>
AuthorDate: Thu May 2 16:44:50 2024 -0400
ARTEMIS-4743 Improve Queue Stat output by allowing --loop as an option
---
.../artemis/cli/commands/queue/StatQueue.java | 27 +++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java
index a7d3816bba..935d19b926 100644
---
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java
+++
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java
@@ -18,6 +18,7 @@ package org.apache.activemq.artemis.cli.commands.queue;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
@@ -99,6 +100,12 @@ public class StatQueue extends ConnectionAbstract {
@Option(names = "--include-management", description = "Include queues
created for notification management in the output")
private boolean includeManagement = false;
+ @Option(names = "--loop", description = "Keep Queue Stat in a forever loop,
that you can interrupt with Ctrl-C, sleeping for --loop-time between each
iteration.")
+ private boolean useLoop = false;
+
+ @Option(names = "--loop-sleep", description = "Amount of Milliseconds to
sleep before each iteration on queue stat. Default=60000")
+ private long loopSleep = 60_000;
+
private int statCount = 0;
//easier for testing
@@ -162,6 +169,23 @@ public class StatQueue extends ConnectionAbstract {
}
createConnectionFactory();
+ singleExeuction(context, filter);
+
+ while (useLoop) {
+ getActionContext().out.println("Waiting " + loopSleep + " before
another queue stat iteration");
+ Thread.sleep(loopSleep);
+ getActionContext().out.print(new Date() + ">> Queue stat results for
" + getBrokerInstance());
+ try {
+ singleExeuction(context, filter);
+ } catch (Throwable e) {
+ e.printStackTrace(getActionContext().err);
+ }
+ }
+
+ return statCount;
+ }
+
+ private void singleExeuction(ActionContext context, String filter) throws
Exception {
try (SimpleManagement simpleManagement = new SimpleManagement(brokerURL,
user, password).open()) {
String nodeID = simpleManagement.getNodeID();
JsonArray topology = simpleManagement.listNetworkTopology();
@@ -193,9 +217,6 @@ public class StatQueue extends ConnectionAbstract {
}
}
}
-
-
- return statCount;
}
private void printStats(String uri, final String filter) throws Exception {