org.apache.activemq.console.command.QueryCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of activemq-osgi Show documentation
Show all versions of activemq-osgi Show documentation
Puts together an ActiveMQ OSGi bundle
/**
* 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.activemq.console.command;
import javax.management.ObjectName;
import org.apache.activemq.console.util.JmxMBeansUtil;
import java.util.*;
public class QueryCommand extends AbstractJmxCommand {
// Predefined type=identifier query
private static final Properties PREDEFINED_OBJNAME_QUERY = new Properties();
static {
PREDEFINED_OBJNAME_QUERY.setProperty("Broker", "brokerName=%1");
PREDEFINED_OBJNAME_QUERY.setProperty("Connection", "connector=clientConnectors,connectionViewType=*,connectionName=%1,*");
PREDEFINED_OBJNAME_QUERY.setProperty("Connector", "connector=clientConnectors,connectorName=%1");
PREDEFINED_OBJNAME_QUERY.setProperty("NetworkConnector", "connector=networkConnectors,networkConnectorName=%1");
PREDEFINED_OBJNAME_QUERY.setProperty("Queue", "destinationType=Queue,destinationName=%1");
PREDEFINED_OBJNAME_QUERY.setProperty("Topic", "destinationType=Topic,destinationName=%1");
};
protected String[] helpFile = new String[] {
"Task Usage: Main query [query-options]",
"Description: Display selected broker component's attributes and statistics.",
"",
"Query Options:",
" -Q= Add to the search list the specific object type matched",
" by the defined object identifier.",
" -xQ= Remove from the search list the specific object type",
" matched by the object identifier.",
" --objname Add to the search list objects matched by the query similar",
" to the JMX object name format.",
" --xobjname Remove from the search list objects matched by the query",
" similar to the JMX object name format.",
" --view ,,... Select the specific attribute of the object to view.",
" By default all attributes will be displayed.",
" --invoke Specify the operation to invoke on matching objects",
" --jmxurl Set the JMX URL to connect to.",
" --pid Set the pid to connect to (only on Sun JVM).",
" --jmxuser Set the JMX user used for authenticating.",
" --jmxpassword Set the JMX password used for authenticating.",
" --jmxlocal Use the local JMX server instead of a remote one.",
" --version Display the version information.",
" -h,-?,--help Display the query broker help information.",
"", "Examples:",
" query",
" - Print all the attributes of all registered objects queues, topics, connections, etc).",
"",
" query -QQueue=TEST.FOO",
" - Print all the attributes of the queue with destination name TEST.FOO.",
"",
" query -QTopic=*",
" - Print all the attributes of all registered topics.",
"",
" query --view EnqueueCount,DequeueCount",
" - Print the attributes EnqueueCount and DequeueCount of all registered objects.",
"",
" query -QTopic=* --view EnqueueCount,DequeueCount",
" - Print the attributes EnqueueCount and DequeueCount of all registered topics.",
"",
" query -QTopic=* -QQueue=* --view EnqueueCount,DequeueCount",
" - Print the attributes EnqueueCount and DequeueCount of all registered topics and",
" queues.",
"",
" query -QTopic=* -xQTopic=ActiveMQ.Advisory.*",
" - Print all attributes of all topics except those that has a name that begins",
" with \"ActiveMQ.Advisory\".",
"",
" query --objname type=Broker,brokerName=*,connector=clientConnectors,connectorName=* -xQNetworkConnector=*",
" - Print all attributes of all connectors, connections excluding network connectors",
" that belongs to the broker that begins with local.",
"",
" query -QQueue=* -xQQueue=????",
" - Print all attributes of all queues except those that are 4 letters long.",
"",
" query -QQueue=* --invoke pause",
" - Pause all queues.",
"",
};
private final List queryAddObjects = new ArrayList(10);
private final List querySubObjects = new ArrayList(10);
private final Set queryViews = new LinkedHashSet();
private final List opAndParams = new ArrayList(10);
@Override
public String getName() {
return "query";
}
@Override
public String getOneLineDescription() {
return "Display selected broker component's attributes and statistics.";
}
/**
* Queries the mbeans registered in the specified JMX context
*
* @param tokens - command arguments
* @throws Exception
*/
protected void runTask(List tokens) throws Exception {
// Query for the mbeans to add
Map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy