|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.netarkivet.common.utils.JMXUtils
public class JMXUtils
Various JMX-related utility functions that have nowhere better to live.
Field Summary | |
---|---|
static org.apache.commons.logging.Log |
log
The logger. |
Constructor Summary | |
---|---|
JMXUtils()
|
Method Summary | |
---|---|
static java.lang.Object |
executeCommand(javax.management.remote.JMXConnector connector,
java.lang.String beanName,
java.lang.String command,
java.lang.String... arguments)
Execute a single command, closing the connector afterwards. |
static java.lang.Object |
executeCommand(javax.management.MBeanServerConnection connection,
java.lang.String beanName,
java.lang.String command,
java.lang.String... arguments)
Execute a command on a bean. |
static java.lang.Object |
getAttribute(javax.management.remote.JMXConnector connector,
java.lang.String beanName,
java.lang.String attribute)
Get the value of an attribute, closing the connector afterwards. |
static java.lang.Object |
getAttribute(java.lang.String beanName,
java.lang.String attribute,
javax.management.MBeanServerConnection connection)
Get the value of an attribute from a bean. |
static javax.management.ObjectName |
getBeanName(java.lang.String beanName)
Get a bean name from a string version. |
static javax.management.remote.JMXConnector |
getJMXConnector(java.lang.String hostName,
int jmxPort,
java.lang.String login,
java.lang.String password)
Get a JMXConnector to a given host and port, using login and password. |
static int |
getMaxTries()
The maximum number of times we back off on getting an mbean or a job. |
static javax.management.MBeanServerConnection |
getMBeanServerConnection(javax.management.remote.JMXServiceURL url,
java.util.Map<java.lang.String,java.lang.String[]> credentials)
Connects to the given (url-specified) service point, sending the given credentials as login. |
static javax.management.MBeanServerConnection |
getMBeanServerConnection(java.lang.String server,
int jmxPort,
int rmiPort,
java.lang.String userName,
java.lang.String password)
Returns a connection to a remote MbeanServer defined by the given arguments. |
static javax.management.openmbean.CompositeData |
getOneCompositeData(javax.management.openmbean.TabularData items)
Get a single CompositeData object out of a TabularData structure. |
static javax.management.remote.JMXServiceURL |
getUrl(java.lang.String server,
int jmxPort,
int rmiPort)
Constructs the same service URL that JConsole does on the basis of a server name, a JMX port number, and a RMI port number. |
static java.util.Map<java.lang.String,java.lang.String[]> |
packageCredentials(java.lang.String userName,
java.lang.String password)
Packages credentials as an environment for JMX connections. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.commons.logging.Log log
Constructor Detail |
---|
public JMXUtils()
Method Detail |
---|
public static int getMaxTries()
public static javax.management.remote.JMXServiceURL getUrl(java.lang.String server, int jmxPort, int rmiPort)
server
- The server that should be connected to using
the constructed URL.jmxPort
- The number of the JMX port that should be connected to
using the constructed URL (may not be a negative number)rmiPort
- The number of the RMI port that should be connected to
using the constructed URL, or -1 if the default RMI port should be used.
public static javax.management.MBeanServerConnection getMBeanServerConnection(java.lang.String server, int jmxPort, int rmiPort, java.lang.String userName, java.lang.String password)
server
- the remote servernamejmxPort
- the remote jmx-portrmiPort
- the remote rmi-portuserName
- the usernamepassword
- the password
public static javax.management.MBeanServerConnection getMBeanServerConnection(javax.management.remote.JMXServiceURL url, java.util.Map<java.lang.String,java.lang.String[]> credentials)
url
- The JMX service url of some JVM on some machine.credentials
- a map with (at least) one entry, mapping
"jmx.remote.credentials" to a String array of length 2.
Its first item should be the user name.
Its second item should be the password.
public static java.util.Map<java.lang.String,java.lang.String[]> packageCredentials(java.lang.String userName, java.lang.String password)
userName
- The user to login aspassword
- The password to use for that user
public static java.lang.Object executeCommand(javax.management.MBeanServerConnection connection, java.lang.String beanName, java.lang.String command, java.lang.String... arguments)
connection
- Connection to the server holding the bean.beanName
- Name of the bean.command
- Command to execute.arguments
- Arguments to the command. Only string arguments are
possible at the moment.
public static java.lang.Object getAttribute(java.lang.String beanName, java.lang.String attribute, javax.management.MBeanServerConnection connection)
beanName
- Name of the bean to get an attribute for.attribute
- Name of the attribute to get.connection
- A connection to the JMX server for the bean.
public static javax.management.ObjectName getBeanName(java.lang.String beanName)
beanName
- String representation of bean name
public static javax.management.remote.JMXConnector getJMXConnector(java.lang.String hostName, int jmxPort, java.lang.String login, java.lang.String password)
hostName
- The host to attempt to connect to.jmxPort
- The port on the host to connect to
(a non-negative number).login
- The login name to authenticate as (typically "controlRole"
or "monitorRole".password
- The password for JMX access.
IOFailure
- if connecting to JMX fails.public static javax.management.openmbean.CompositeData getOneCompositeData(javax.management.openmbean.TabularData items)
items
- TabularData structure as returned from JMX calls.
ArgumentNotValid
- if there is not exactly one item in items,
or items is null.public static java.lang.Object executeCommand(javax.management.remote.JMXConnector connector, java.lang.String beanName, java.lang.String command, java.lang.String... arguments)
connector
- A one-shot connector object.beanName
- The name of the bean to execute a command on.command
- The command to execute.arguments
- The arguments to the command (all strings)
public static java.lang.Object getAttribute(javax.management.remote.JMXConnector connector, java.lang.String beanName, java.lang.String attribute)
connector
- A one-shot connector object.beanName
- The name of the bean to get an attribute from.attribute
- The attribute to get.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |