Class JmxUtils

  • Direct Known Subclasses:
    JMXUtils

    public class JmxUtils
    extends java.lang.Object
    Set of base-level JMX utilities needed for remote JMX invocation
    • 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 JMX ObjectName for apiClass.
      static javax.management.ObjectName getAdminObjectName​(java.lang.Class<?> apiClass, java.lang.String name)
      Gets the JMX ObjectName for apiClass.
      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 by endpoint.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • JmxUtils

        public JmxUtils()
    • 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 implementation
        host - the host name where the jmx mbean resides
        remotePort - 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 JMX ObjectName for apiClass. Presumes only a single object of this class will be registered.
        Parameters:
        apiClass - the registered class, generally an ExposedApi.
        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 JMX ObjectName for apiClass.
        Parameters:
        apiClass - the registered class, generally an ExposedApi
        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 by endpoint. The endpoint is expected to represent an API of the type clazz.

        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 plus DefaultEndpoints.Ports.REMOTE_JMX_PORT_OFFSET. The typical use case will be to call JMXConnector.getMBeanServerConnection(), use the returned value, then call JMXConnector.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 plus DefaultEndpoints.Ports.REMOTE_JMX_PORT_OFFSET. The typical use case will be to call JMXConnector.getMBeanServerConnection(), use the returned value, then call JMXConnector.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