Package org.jppf.management
Class JMXConnectionWrapper
java.lang.Object
org.jppf.utils.concurrent.ThreadSynchronization
org.jppf.management.AbstractJMXConnectionWrapper
org.jppf.management.JMXConnectionWrapper
- All Implemented Interfaces:
Serializable,AutoCloseable,JPPFAdminMBean
- Direct Known Subclasses:
JMXDriverConnectionWrapper,JMXNodeConnectionWrapper
Wrapper around a JMX connection, providing a thread-safe way of handling disconnections and recovery.
- Author:
- Laurent Cohen
- See Also:
-
Field Summary
Fields inherited from class org.jppf.utils.concurrent.ThreadSynchronization
stopped -
Constructor Summary
ConstructorsConstructorDescriptionInitialize a local connection (same JVM) to the MBean server.JMXConnectionWrapper(String host, int port, boolean sslEnabled) Initialize the connection to the remote MBean server. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener to this connection wrapper.voidaddNotificationListener(String mBeanName, NotificationListener listener) Adds a listener to the specified MBean.voidaddNotificationListener(String mBeanName, NotificationListener listener, NotificationFilter filter, Object handback) Adds a listener to the specified MBean.voidclose()voidconnect()Initialize the connection to the remote MBean server.booleanconnectAndWait(long timeout) Initiate the connection and wait until the connection is established or the timeout has expired, whichever comes first.getAttribute(String mbeanName, String attribute) Get the value of an attribute of the specified MBean.Get a proxy to the diagnostics/JVM health MBean.getHost()Get the host the server is running on.The JMX client connector.Get the connection to the MBean server.getNotificationInfo(String mBeanName) Get theMBeanNotificationInfodescriptors for the specified MBean.intgetPort()Get the JMX remote port used by the server.<T> TObtain a proxy to the specified remote MBean.<T> TgetProxy(ObjectName objectName, Class<T> inf) Obtain a proxy to the specified remote MBean.getURL()Get the service URL of the MBean server.Invoke a method on the specified MBean.Invoke a method on the specified MBean.booleanDetermines whether the connection to the JMX server has been established.booleanisSecure()Determine whether the JMX connection is secure or not.voidRemove a listener from this connection wrapper.voidremoveNotificationListener(String mBeanName, NotificationListener listener) Remove a listener from the specified MBean.voidremoveNotificationListener(String mBeanName, NotificationListener listener, NotificationFilter filter, Object handback) Remove a listener from the specified MBean.voidsetAttribute(String mbeanName, String attribute, Object value) Set the value of an attribute of the specified MBean.Get detailed information about the node's JVM properties, environment variables and runtime information such as memory usage and available processors.Methods inherited from class org.jppf.management.AbstractJMXConnectionWrapper
getDisplayName, getId, getLastConnectionException, getProtocol, isReconnectOnError, setReconnectOnError, toStringMethods inherited from class org.jppf.utils.concurrent.ThreadSynchronization
goToSleep, goToSleep, goToSleep, isStopped, setStopped, wakeUp
-
Constructor Details
-
JMXConnectionWrapper
public JMXConnectionWrapper()Initialize a local connection (same JVM) to the MBean server. -
JMXConnectionWrapper
Initialize the connection to the remote MBean server.- Parameters:
host- the host the server is running on.port- the port used by the server.sslEnabled- specifies whether the jmx connection should be secure or not.
-
-
Method Details
-
connect
public void connect()Initialize the connection to the remote MBean server.- Specified by:
connectin classAbstractJMXConnectionWrapper
-
connectAndWait
public boolean connectAndWait(long timeout) Initiate the connection and wait until the connection is established or the timeout has expired, whichever comes first.- Specified by:
connectAndWaitin classAbstractJMXConnectionWrapper- Parameters:
timeout- the maximum time to wait for, a value of zero means no timeout and this method just waits until the connection is established.- Returns:
trueif the connection was established in the specified time,falseotherwise.
-
close
public void close() -
invoke
public Object invoke(String mbeanName, String methodName, Object[] params, String[] signature) throws Exception Invoke a method on the specified MBean.- Parameters:
mbeanName- the name of the MBean.methodName- the name of the method to invoke.params- the method parameter values.signature- the types of the method parameters.- Returns:
- an object or null.
- Throws:
Exception- if the invocation failed.
-
invoke
Invoke a method on the specified MBean. This is a convenience method to be used when invoking a remote MBean method with no parameters.
This is equivalent to callinginvoke(name, methodName, (Object[]) null, (String[]) null).- Parameters:
mbeanName- the name of the MBean.methodName- the name of the method to invoke.- Returns:
- an object or null.
- Throws:
Exception- if the invocation failed.
-
getAttribute
Get the value of an attribute of the specified MBean.- Parameters:
mbeanName- the name of the MBean.attribute- the name of the attribute to read.- Returns:
- an object or null.
- Throws:
Exception- if the invocation failed.
-
setAttribute
Set the value of an attribute of the specified MBean.- Parameters:
mbeanName- the name of the MBean.attribute- the name of the attribute to write.value- the value to set on the attribute.- Throws:
Exception- if the invocation failed.
-
getHost
Get the host the server is running on.- Returns:
- the host as a string.
-
getPort
public int getPort()Get the JMX remote port used by the server.- Returns:
- the port as an int.
-
getURL
Get the service URL of the MBean server.- Returns:
- a
JMXServiceURLinstance, ornullif this object represents a local MBean server connection.
-
getMbeanConnection
Get the connection to the MBean server.- Returns:
- a
MBeanServerConnectioninstance.
-
isConnected
public boolean isConnected()Determines whether the connection to the JMX server has been established.- Returns:
- true if the connection is established, false otherwise.
-
getProxy
Obtain a proxy to the specified remote MBean.- Type Parameters:
T- the type of the MBean (must be an interface).- Parameters:
name- the name of the mbean to retrieve.inf- the class of the MBean interface.- Returns:
- an instance of the specified proxy interface.
- Throws:
Exception- if any error occurs.
-
getProxy
Obtain a proxy to the specified remote MBean.- Type Parameters:
T- the type of the MBean (must be an interface).- Parameters:
objectName- the name of the mbean to retrieve.inf- the class of the MBean interface.- Returns:
- an instance of the specified proxy interface.
- Throws:
Exception- if any error occurs.
-
getDiagnosticsProxy
Get a proxy to the diagnostics/JVM health MBean.- Returns:
- a DiagnosticsMBean instance.
- Throws:
Exception- if any error occurs.
-
addNotificationListener
public void addNotificationListener(String mBeanName, NotificationListener listener) throws Exception Adds a listener to the specified MBean.- Parameters:
mBeanName- the name of the MBean on which the listener should be added.listener- the listener to add.- Throws:
Exception- if any error occurs.
-
addNotificationListener
public void addNotificationListener(String mBeanName, NotificationListener listener, NotificationFilter filter, Object handback) throws Exception Adds a listener to the specified MBean.- Parameters:
mBeanName- the name of the MBean on which the listener should be added.listener- the listener to add.filter- the filter object.handback- the handback object to use.- Throws:
Exception- if any error occurs.
-
removeNotificationListener
public void removeNotificationListener(String mBeanName, NotificationListener listener) throws Exception Remove a listener from the specified MBean.- Parameters:
mBeanName- the name of the MBean from which the listener should be removed.listener- the listener to remove.- Throws:
Exception- if any error occurs.
-
removeNotificationListener
public void removeNotificationListener(String mBeanName, NotificationListener listener, NotificationFilter filter, Object handback) throws Exception Remove a listener from the specified MBean.- Parameters:
mBeanName- the name of the MBean from which the listener should be removed.listener- the listener to remove.filter- the filter object.handback- the handback object used.- Throws:
Exception- if any error occurs.
-
getNotificationInfo
Get theMBeanNotificationInfodescriptors for the specified MBean.- Parameters:
mBeanName- the name of the MBean.- Returns:
- a an array of
MBeanNotificationInfo, which is empty if the MBean does not implementNotificationBroadcaster. - Throws:
Exception- if any error occurs.
-
systemInformation
Description copied from interface:JPPFAdminMBeanGet detailed information about the node's JVM properties, environment variables and runtime information such as memory usage and available processors.- Returns:
- a
JPPFSystemInformationinstance. - Throws:
Exception- if any error occurs.
-
isSecure
public boolean isSecure()Determine whether the JMX connection is secure or not.- Returns:
trueif this connection is secure,falseotherwise.
-
getJmxconnector
The JMX client connector.- Returns:
- a
JMXConnectorinstance.
-
addJMXConnectionWrapperListener
Add a listener to this connection wrapper.- Parameters:
listener- the listener to add.
-
removeJMXConnectionWrapperListener
Remove a listener from this connection wrapper.- Parameters:
listener- the listener to add.
-