Package com.attivio.util
Class JmxUtils
- java.lang.Object
-
- com.attivio.util.JmxUtils
-
- Direct Known Subclasses:
JMXUtils
public class JmxUtils extends java.lang.Object
Set of base-level JMX utilities needed for remote JMX invocation
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ATTIVIO_ADMIN_DOMAIN
Our JMX Domain for admin components.static java.lang.String
OBJECT_NAME_FORMAT
The format string for all Admin MBeans.static java.lang.String
SYSTEM_PROPERTY_JMX_AUTHENTICATE
The system property to determine whether authentication is enabled on jmxstatic java.lang.String
SYSTEM_PROPERTY_JMX_PORT
The system property to specify the port on which JMX should runstatic java.lang.String
SYSTEM_PROPERTY_JMX_SSL
The system property to determine whether ssl is enabled on jmx
-
Constructor Summary
Constructors Constructor Description JmxUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.management.remote.JMXConnector
connectToRemoteServer(java.lang.String host, int port)
Connects to an unauthenticated jmx server.static javax.management.remote.JMXConnector
connectToRemoteServer(java.lang.String host, int port, java.lang.String userName, java.lang.String password)
Creates a JMXConnector connected to the remote host and port.static javax.management.remote.JMXConnector
connectToRemoteServer(java.lang.String host, int port, java.lang.String userName, java.lang.String password, boolean useJmxMp)
Creates a JMXConnector connected to the remote host and port.static javax.management.ObjectName
getAdminObjectName(java.lang.Class<?> apiClass)
Gets the JMXObjectName
forapiClass
.static javax.management.ObjectName
getAdminObjectName(java.lang.Class<?> apiClass, java.lang.String name)
Gets the JMXObjectName
forapiClass
.static <T> T
getRemoteJmxApi(java.lang.Class<T> clazz, java.lang.String host, int remotePort)
static <T> T
getRemoteJmxApi(java.lang.Class<T> clazz, java.lang.String host, int remotePort, java.lang.String username, java.lang.String password)
static <T> T
getRemoteProxy(RemoteJmxEndpoint endpoint, java.lang.Class<T> clazz)
Returns a proxy to the remote instance of the API described byendpoint
.
-
-
-
Field Detail
-
ATTIVIO_ADMIN_DOMAIN
public static final java.lang.String ATTIVIO_ADMIN_DOMAIN
Our JMX Domain for admin components.- See Also:
- Constant Field Values
-
OBJECT_NAME_FORMAT
public static final java.lang.String OBJECT_NAME_FORMAT
The format string for all Admin MBeans.- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JMX_AUTHENTICATE
public static final java.lang.String SYSTEM_PROPERTY_JMX_AUTHENTICATE
The system property to determine whether authentication is enabled on jmx- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JMX_SSL
public static final java.lang.String SYSTEM_PROPERTY_JMX_SSL
The system property to determine whether ssl is enabled on jmx- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JMX_PORT
public static final java.lang.String SYSTEM_PROPERTY_JMX_PORT
The system property to specify the port on which JMX should run- See Also:
- Constant Field Values
-
-
Method Detail
-
getRemoteJmxApi
public static final <T> T getRemoteJmxApi(java.lang.Class<T> clazz, java.lang.String host, int remotePort) throws AttivioException
- Parameters:
clazz
- an ExposedApi implementationhost
- the host name where the jmx mbean residesremotePort
- of the node- Returns:
- A remote proxy to the exposed api
- Throws:
AttivioException
-
getRemoteJmxApi
public static final <T> T getRemoteJmxApi(java.lang.Class<T> clazz, java.lang.String host, int remotePort, java.lang.String username, java.lang.String password) throws AttivioException
- Throws:
AttivioException
-
getAdminObjectName
public static javax.management.ObjectName getAdminObjectName(java.lang.Class<?> apiClass) throws javax.management.MalformedObjectNameException, java.lang.NullPointerException
Gets the JMXObjectName
forapiClass
. Presumes only a single object of this class will be registered.- Parameters:
apiClass
- the registered class, generally anExposedApi
.- Throws:
javax.management.MalformedObjectNameException
java.lang.NullPointerException
-
getAdminObjectName
public static javax.management.ObjectName getAdminObjectName(java.lang.Class<?> apiClass, java.lang.String name) throws javax.management.MalformedObjectNameException, java.lang.NullPointerException
Gets the JMXObjectName
forapiClass
.- Parameters:
apiClass
- the registered class, generally anExposedApi
name
- detail name if more than one of these gets exposed- Throws:
javax.management.MalformedObjectNameException
java.lang.NullPointerException
-
getRemoteProxy
public static final <T> T getRemoteProxy(RemoteJmxEndpoint endpoint, java.lang.Class<T> clazz) throws java.io.IOException
Returns a proxy to the remote instance of the API described byendpoint
. The endpoint is expected to represent an API of the typeclazz
.This method uses system property
#JMX_AUTH_USERNAME
and#JMX_AUTH_PASSWORD
to authenticate when specified.- Parameters:
endpoint
-clazz
-- Returns:
- Throws:
java.io.IOException
-
connectToRemoteServer
public static javax.management.remote.JMXConnector connectToRemoteServer(java.lang.String host, int port, java.lang.String userName, java.lang.String password) throws java.io.IOException
Creates a JMXConnector connected to the remote host and port. The port must be for a remote JMX listener. This listener is typically set to be the baseport of the AIE instance plusDefaultEndpoints.Ports.REMOTE_JMX_PORT_OFFSET
. The typical use case will be to callJMXConnector.getMBeanServerConnection()
, use the returned value, then callJMXConnector.close()
when finished.- Parameters:
host
-port
-- Returns:
- a JMXConnector connected to the remote host and port.
- Throws:
java.io.IOException
-
connectToRemoteServer
public static javax.management.remote.JMXConnector connectToRemoteServer(java.lang.String host, int port, java.lang.String userName, java.lang.String password, boolean useJmxMp) throws java.io.IOException
Creates a JMXConnector connected to the remote host and port. The port must be for a remote JMX listener. This listener is typically set to be the baseport of the AIE instance plusDefaultEndpoints.Ports.REMOTE_JMX_PORT_OFFSET
. The typical use case will be to callJMXConnector.getMBeanServerConnection()
, use the returned value, then callJMXConnector.close()
when finished.- Parameters:
host
-port
-- Returns:
- a JMXConnector connected to the remote host and port.
- Throws:
java.io.IOException
-
connectToRemoteServer
public static javax.management.remote.JMXConnector connectToRemoteServer(java.lang.String host, int port) throws java.io.IOException
Connects to an unauthenticated jmx server.- Parameters:
host
-port
-- Throws:
java.io.IOException
-
-