AMQ-4760: Added dstat command to activemq karaf commands.

This commit is contained in:
Claus Ibsen 2013-10-01 16:19:19 +02:00
parent a80a1857d0
commit ee8b51b27b
2 changed files with 151 additions and 125 deletions

View File

@ -81,13 +81,13 @@ public class DstatCommand extends AbstractJmxCommand {
} }
} }
private void displayAllDestinations() throws IOException, Exception { private void displayAllDestinations() throws Exception {
String query = JmxMBeansUtil.createQueryString(queryString, "*"); String query = JmxMBeansUtil.createQueryString(queryString, "*");
List<?> queueList = JmxMBeansUtil.queryMBeans(createJmxConnection(), query); List<?> queueList = JmxMBeansUtil.queryMBeans(createJmxConnection(), query);
final String header = "%20s %10s %10s %10s %10s"; final String header = "%-60s %10s %10s %10s %10s";
final String tableRow = "%20s %10d %10d %10d %10d"; final String tableRow = "%-60s %10d %10d %10d %10d";
context.print(String.format(Locale.US, header, "Name", "Pending", "Consumers", "Enqueued", "Dequeued")); context.print(String.format(Locale.US, header, "Name", "Pending", "Consumers", "Enqueued", "Dequeued"));
@ -106,13 +106,13 @@ public class DstatCommand extends AbstractJmxCommand {
} }
} }
private void displayQueueStats() throws IOException, Exception { private void displayQueueStats() throws Exception {
String query = JmxMBeansUtil.createQueryString(queryString, "Queue"); String query = JmxMBeansUtil.createQueryString(queryString, "Queue");
List<?> queueList = JmxMBeansUtil.queryMBeans(createJmxConnection(), query); List<?> queueList = JmxMBeansUtil.queryMBeans(createJmxConnection(), query);
final String header = "%20s %10s %10s %10s %10s"; final String header = "%-60s %10s %10s %10s %10s";
final String tableRow = "%20s %10d %10d %10d %10d"; final String tableRow = "%-60s %10d %10d %10d %10d";
context.print(String.format(Locale.US, header, "Name", "Pending", "Consumers", "Enqueued", "Dequeued")); context.print(String.format(Locale.US, header, "Name", "Pending", "Consumers", "Enqueued", "Dequeued"));
@ -131,13 +131,13 @@ public class DstatCommand extends AbstractJmxCommand {
} }
} }
private void displayTopicStats() throws IOException, Exception { private void displayTopicStats() throws Exception {
String query = JmxMBeansUtil.createQueryString(queryString, "Topic"); String query = JmxMBeansUtil.createQueryString(queryString, "Topic");
List<?> topicsList = JmxMBeansUtil.queryMBeans(createJmxConnection(), query); List<?> topicsList = JmxMBeansUtil.queryMBeans(createJmxConnection(), query);
final String header = "%20s %10s %10s %10s"; final String header = "%-60s %10s %10s %10s";
final String tableRow = "%20s %10d %10d %10d"; final String tableRow = "%-60s %10d %10d %10d";
context.print(String.format(Locale.US, header, "Name", "Consumers", "Enqueued", "Dequeued")); context.print(String.format(Locale.US, header, "Name", "Consumers", "Enqueued", "Dequeued"));

View File

@ -19,135 +19,161 @@
--> -->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:shell="http://karaf.apache.org/xmlns/shell/v1.0.0"> xmlns:shell="http://karaf.apache.org/xmlns/shell/v1.0.0">
<!-- ActiveMQ List Command -->
<bean id="listcommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
<property name="blueprintContainer" ref="blueprintContainer"/>
<property name="blueprintConverter" ref="blueprintConverter"/>
<property name="actionId" value="listaction"/>
</bean>
<service ref="listcommand" activation="lazy" > <!-- ActiveMQ List Command -->
<interfaces> <bean id="listcommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
<value>org.apache.felix.service.command.Function</value> <property name="blueprintContainer" ref="blueprintContainer"/>
<value>org.apache.karaf.shell.console.CompletableFunction</value> <property name="blueprintConverter" ref="blueprintConverter"/>
</interfaces> <property name="actionId" value="listaction"/>
<service-properties> </bean>
<entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="list"/>
</service-properties>
</service>
<bean id="listaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport" <service ref="listcommand" activation="lazy">
activation="lazy" <interfaces>
scope="prototype"> <value>org.apache.felix.service.command.Function</value>
<property name="command"> <value>org.apache.karaf.shell.console.CompletableFunction</value>
<bean class="org.apache.activemq.console.command.ListCommand"/> </interfaces>
</property> <service-properties>
</bean> <entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="list"/>
</service-properties>
</service>
<!-- ActiveMQ Query Command --> <bean id="listaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
<bean id="querycommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand"> activation="lazy"
<property name="blueprintContainer" ref="blueprintContainer"/> scope="prototype">
<property name="blueprintConverter" ref="blueprintConverter"/> <property name="command">
<property name="actionId" value="queryaction"/> <bean class="org.apache.activemq.console.command.ListCommand"/>
</bean> </property>
</bean>
<service ref="querycommand" activation="lazy" > <!-- ActiveMQ Query Command -->
<interfaces> <bean id="querycommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
<value>org.apache.felix.service.command.Function</value> <property name="blueprintContainer" ref="blueprintContainer"/>
<value>org.apache.karaf.shell.console.CompletableFunction</value> <property name="blueprintConverter" ref="blueprintConverter"/>
</interfaces> <property name="actionId" value="queryaction"/>
<service-properties> </bean>
<entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="query"/>
</service-properties>
</service>
<bean id="queryaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport" <service ref="querycommand" activation="lazy">
activation="lazy" <interfaces>
scope="prototype"> <value>org.apache.felix.service.command.Function</value>
<property name="command"> <value>org.apache.karaf.shell.console.CompletableFunction</value>
<bean class="org.apache.activemq.console.command.QueryCommand"/> </interfaces>
</property> <service-properties>
</bean> <entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="query"/>
</service-properties>
</service>
<!-- ActiveMQ Browse Command --> <bean id="queryaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
<bean id="browsecommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand"> activation="lazy"
<property name="blueprintContainer" ref="blueprintContainer"/> scope="prototype">
<property name="blueprintConverter" ref="blueprintConverter"/> <property name="command">
<property name="actionId" value="browseaction"/> <bean class="org.apache.activemq.console.command.QueryCommand"/>
</bean> </property>
</bean>
<service ref="browsecommand" activation="lazy" > <!-- ActiveMQ Browse Command -->
<interfaces> <bean id="browsecommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
<value>org.apache.felix.service.command.Function</value> <property name="blueprintContainer" ref="blueprintContainer"/>
<value>org.apache.karaf.shell.console.CompletableFunction</value> <property name="blueprintConverter" ref="blueprintConverter"/>
</interfaces> <property name="actionId" value="browseaction"/>
<service-properties> </bean>
<entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="browse"/>
</service-properties>
</service>
<bean id="browseaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport" <service ref="browsecommand" activation="lazy">
activation="lazy" <interfaces>
scope="prototype"> <value>org.apache.felix.service.command.Function</value>
<property name="command"> <value>org.apache.karaf.shell.console.CompletableFunction</value>
<bean class="org.apache.activemq.console.command.AmqBrowseCommand"/> </interfaces>
</property> <service-properties>
</bean> <entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="browse"/>
</service-properties>
</service>
<!-- ActiveMQ Bstat Command --> <bean id="browseaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
<bean id="bstatcommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand"> activation="lazy"
<property name="blueprintContainer" ref="blueprintContainer"/> scope="prototype">
<property name="blueprintConverter" ref="blueprintConverter"/> <property name="command">
<property name="actionId" value="bstataction"/> <bean class="org.apache.activemq.console.command.AmqBrowseCommand"/>
</bean> </property>
</bean>
<service ref="bstatcommand" activation="lazy" > <!-- ActiveMQ Bstat Command -->
<interfaces> <bean id="bstatcommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
<value>org.apache.felix.service.command.Function</value> <property name="blueprintContainer" ref="blueprintContainer"/>
<value>org.apache.karaf.shell.console.CompletableFunction</value> <property name="blueprintConverter" ref="blueprintConverter"/>
</interfaces> <property name="actionId" value="bstataction"/>
<service-properties> </bean>
<entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="bstat"/>
</service-properties>
</service>
<bean id="bstataction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport" <service ref="bstatcommand" activation="lazy">
activation="lazy" <interfaces>
scope="prototype"> <value>org.apache.felix.service.command.Function</value>
<property name="command"> <value>org.apache.karaf.shell.console.CompletableFunction</value>
<bean class="org.apache.activemq.console.command.BstatCommand"/> </interfaces>
</property> <service-properties>
</bean> <entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="bstat"/>
</service-properties>
</service>
<!-- ActiveMQ Purge Command --> <bean id="bstataction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
<bean id="purgecommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand"> activation="lazy"
<property name="blueprintContainer" ref="blueprintContainer"/> scope="prototype">
<property name="blueprintConverter" ref="blueprintConverter"/> <property name="command">
<property name="actionId" value="purgeaction"/> <bean class="org.apache.activemq.console.command.BstatCommand"/>
</bean> </property>
</bean>
<service ref="purgecommand" activation="lazy" > <!-- ActiveMQ Purge Command -->
<interfaces> <bean id="purgecommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
<value>org.apache.felix.service.command.Function</value> <property name="blueprintContainer" ref="blueprintContainer"/>
<value>org.apache.karaf.shell.console.CompletableFunction</value> <property name="blueprintConverter" ref="blueprintConverter"/>
</interfaces> <property name="actionId" value="purgeaction"/>
<service-properties> </bean>
<entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="purge"/>
</service-properties>
</service>
<bean id="purgeaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport" <service ref="purgecommand" activation="lazy">
activation="lazy" <interfaces>
scope="prototype"> <value>org.apache.felix.service.command.Function</value>
<property name="command"> <value>org.apache.karaf.shell.console.CompletableFunction</value>
<bean class="org.apache.activemq.console.command.PurgeCommand"/> </interfaces>
</property> <service-properties>
</bean> <entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="purge"/>
</service-properties>
</service>
<bean id="purgeaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
activation="lazy"
scope="prototype">
<property name="command">
<bean class="org.apache.activemq.console.command.PurgeCommand"/>
</property>
</bean>
<!-- ActiveMQ Dstat Command -->
<bean id="dstatcommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
<property name="blueprintContainer" ref="blueprintContainer"/>
<property name="blueprintConverter" ref="blueprintConverter"/>
<property name="actionId" value="dstataction"/>
</bean>
<service ref="dstatcommand" activation="lazy">
<interfaces>
<value>org.apache.felix.service.command.Function</value>
<value>org.apache.karaf.shell.console.CompletableFunction</value>
</interfaces>
<service-properties>
<entry key="osgi.command.scope" value="activemq"/>
<entry key="osgi.command.function" value="dstat"/>
</service-properties>
</service>
<bean id="dstataction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
activation="lazy"
scope="prototype">
<property name="command">
<bean class="org.apache.activemq.console.command.DstatCommand"/>
</property>
</bean>
</blueprint> </blueprint>