KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > console > command > BstatCommand


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.console.command;
19
20 import java.util.List JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.ArrayList JavaDoc;
23
24 public class BstatCommand extends QueryCommand {
25     /**
26      * Performs a predefiend query option
27      * @param tokens - command arguments
28      * @throws Exception
29      */

30     protected void runTask(List JavaDoc tokens) throws Exception JavaDoc {
31         List JavaDoc queryTokens = new ArrayList JavaDoc();
32         // Find the first non-option token
33
String JavaDoc brokerName = "*";
34         for (Iterator JavaDoc i = tokens.iterator(); i.hasNext();) {
35             String JavaDoc token = (String JavaDoc)i.next();
36             if (!token.startsWith("-")) {
37                 brokerName = token;
38                 break;
39             } else {
40                 // Re-insert options
41
queryTokens.add(token);
42             }
43         }
44
45         // Build the predefined option
46
queryTokens.add("--objname");
47         queryTokens.add("Type=*,BrokerName=" + brokerName);
48         queryTokens.add("-xQTopic=ActiveMQ.Advisory.*");
49         queryTokens.add("--vuew");
50         queryTokens.add("Type,BrokerName,Destination,ConnectorName,EnqueueCount," +
51                         "DequeueCount,TotalEnqueueCount,TotalDequeueCount,Messages," +
52                         "TotalMessages,ConsumerCount,TotalConsumerCount,DispatchQueueSize");
53
54         // Call the query command
55
super.runTask(queryTokens);
56     }
57
58     protected String JavaDoc[] helpFile = new String JavaDoc[] {
59         "Task Usage: activemq-admin bstat [bstat-options] [broker-name]",
60         "Description: Performs a predefined query that displays useful statistics regarding the specified broker.",
61         " If no broker name is specified, it will try and select from all registered brokers.",
62         "",
63         "Bstat Options:",
64         " --jmxurl <url> Set the JMX URL to connect to.",
65         " --version Display the version information.",
66         " -h,-?,--help Display the query broker help information.",
67         "",
68         "Examples:",
69         " activemq-admin bstat localhost",
70         " - Display a summary of statistics for the broker 'localhost'"
71     };
72 }
73
Popular Tags