Class JMXUtils


  • public class JMXUtils
    extends JmxUtils
    Contains utilities for interfacing Attivio components to JMX.
    • Constructor Summary

      Constructors 
      Constructor Description
      JMXUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean confirmDeregistration()
      Checks the mbean server for the presence of any Attivio or Mule beans.
      static org.apache.curator.x.discovery.ServiceInstance<AieServiceInfo> expose​(javax.management.ObjectName oname, java.lang.Class<?> apiClass, java.lang.Object api, java.lang.String user, java.lang.String password, int rmiPort)
      Exposes the object via JMX and registers it as a service via the ServiceFactory.
      static javax.management.MBeanServer getMBeanServer()
      Gets the JMX MBeanServer for the application.
      static boolean isValidInvokable​(java.lang.reflect.Method method)
      Judges if a method is valid for JmxInvokable
      A valid method for JmxInvokable is defined as satisfying all the following:
      Method is public
      static boolean isValidReadable​(java.lang.reflect.Method method)
      Judges if a method is valid for JmxReadable
      A valid method for JmxReadable is defined as satisfying all the following:
      Method is public Takes no argument Return type is not Void.TYPE
      static boolean isValidWritable​(java.lang.reflect.Method method)
      Judges if a method is valid for JmxWritable
      A valid method for JmxWritable is defined as satisfying all the following:
      Method is public Takes one and only one argument Return type is Void.TYPE
      Note: Variable arity parameters will be treated as one Array object.
      static javax.management.ObjectName newObjectName​(java.lang.String format, java.lang.Object... args)
      Create a new ObjectName using a format string.
      static javax.management.ObjectName objectName​(java.lang.Class<?> clazz, java.lang.String type, java.lang.String category, java.lang.String instanceName)
      Creates a standard Attivio JMX object name with the provided parameters.
      static <T> javax.management.ObjectName register​(javax.management.ObjectName name, T bean)
      Register bean as name.
      static <T> javax.management.ObjectName registerMBean​(java.lang.Class<?> beanClass, T bean, javax.management.ObjectName oName)
      Registers bean with JMX under the provided object name using a specific targeted interface only (not the full bean class).
      static <T> javax.management.ObjectName registerMBean​(T bean, javax.management.ObjectName oName)
      Registers bean with JMX under the provided object name.
      static <T> javax.management.ObjectName registerMBeanInstance​(T bean, java.lang.String instance)
      Registers the object bean with the instance name instance with the JMX server.
      static javax.management.ObjectName unregister​(javax.management.ObjectName name)
      Unregisters the JMX MBean object with the given name.
      static void unregisterMBean​(javax.management.ObjectName oName)
      Unregisters the JMX MBean object with the given name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ATTIVIO_DOMAIN

        public static final java.lang.String ATTIVIO_DOMAIN
        Our JMX Domain.
        See Also:
        Constant Field Values
      • SYS_PROP_ENABLE_REMOTE_JMX

        public static final java.lang.String SYS_PROP_ENABLE_REMOTE_JMX
        The system property key used for indicating that jmx agent should be exposed remotely.
        See Also:
        Constant Field Values
      • SYS_PROP_JMX_AUTH_PROVIDER_BEAN_NAME

        public static final java.lang.String SYS_PROP_JMX_AUTH_PROVIDER_BEAN_NAME
        The system property key used to indicate the authentication provider for JMX
        See Also:
        Constant Field Values
      • SYS_PROP_ENABLE_SSL_JMX

        public static final java.lang.String SYS_PROP_ENABLE_SSL_JMX
        The system property key used for indicating that jmx agent authentication password.
        See Also:
        Constant Field Values
    • Constructor Detail

      • JMXUtils

        public JMXUtils()
    • Method Detail

      • newObjectName

        public static javax.management.ObjectName newObjectName​(java.lang.String format,
                                                                java.lang.Object... args)
        Create a new ObjectName using a format string.

        Usage: ObjectName = JMXUtils.newObjectName("type=%s,blah=%s", myType, myBlah)

        NOTE: the Domain for the the returned object name is ATTIVIO_DOMAIN.

      • objectName

        public static javax.management.ObjectName objectName​(java.lang.Class<?> clazz,
                                                             java.lang.String type,
                                                             java.lang.String category,
                                                             java.lang.String instanceName)
                                                      throws javax.management.MalformedObjectNameException
        Creates a standard Attivio JMX object name with the provided parameters.
        Throws:
        javax.management.MalformedObjectNameException
      • getMBeanServer

        public static javax.management.MBeanServer getMBeanServer()
        Gets the JMX MBeanServer for the application.
        Returns:
        MBean server
      • confirmDeregistration

        public static boolean confirmDeregistration()
        Checks the mbean server for the presence of any Attivio or Mule beans. Any such beans will be deregistered.
        Returns:
        true if all Mule and Attivio components were deregistered.
      • registerMBeanInstance

        public static <T> javax.management.ObjectName registerMBeanInstance​(T bean,
                                                                            java.lang.String instance)
                                                                     throws javax.management.MalformedObjectNameException,
                                                                            javax.management.MBeanRegistrationException,
                                                                            javax.management.NotCompliantMBeanException,
                                                                            javax.management.InstanceAlreadyExistsException
        Registers the object bean with the instance name instance with the JMX server.
        Parameters:
        bean - the bean
        instance - the name used to identify this instance of the object. may be null in which case the hash code for the object will be used.
        Throws:
        javax.management.MalformedObjectNameException
        javax.management.MBeanRegistrationException
        javax.management.NotCompliantMBeanException
        javax.management.InstanceAlreadyExistsException
      • registerMBean

        public static <T> javax.management.ObjectName registerMBean​(T bean,
                                                                    javax.management.ObjectName oName)
                                                             throws javax.management.MalformedObjectNameException,
                                                                    javax.management.MBeanRegistrationException,
                                                                    javax.management.NotCompliantMBeanException,
                                                                    javax.management.InstanceAlreadyExistsException
        Registers bean with JMX under the provided object name.
        Throws:
        javax.management.MalformedObjectNameException
        javax.management.MBeanRegistrationException
        javax.management.NotCompliantMBeanException
        javax.management.InstanceAlreadyExistsException
      • registerMBean

        public static <T> javax.management.ObjectName registerMBean​(java.lang.Class<?> beanClass,
                                                                    T bean,
                                                                    javax.management.ObjectName oName)
                                                             throws javax.management.MalformedObjectNameException,
                                                                    javax.management.MBeanRegistrationException,
                                                                    javax.management.NotCompliantMBeanException,
                                                                    javax.management.InstanceAlreadyExistsException
        Registers bean with JMX under the provided object name using a specific targeted interface only (not the full bean class).
        Throws:
        javax.management.MalformedObjectNameException
        javax.management.MBeanRegistrationException
        javax.management.NotCompliantMBeanException
        javax.management.InstanceAlreadyExistsException
      • register

        public static <T> javax.management.ObjectName register​(javax.management.ObjectName name,
                                                               T bean)
        Register bean as name.

        Returns null if registration failed, name otherwise.

      • unregister

        public static javax.management.ObjectName unregister​(javax.management.ObjectName name)
        Unregisters the JMX MBean object with the given name.

        Different from unregister(ObjectName) because this method will not throw an exception. Exception cases will result in a warning being logged.

      • expose

        public static org.apache.curator.x.discovery.ServiceInstance<AieServiceInfo> expose​(javax.management.ObjectName oname,
                                                                                            java.lang.Class<?> apiClass,
                                                                                            java.lang.Object api,
                                                                                            java.lang.String user,
                                                                                            java.lang.String password,
                                                                                            int rmiPort)
                                                                                     throws AttivioException
        Exposes the object via JMX and registers it as a service via the ServiceFactory. The rmiport must correspond to the remote JMX port. Caller is responsible for calling ServiceFactory.unregisterService(ServiceInstance) on the returned service instance. If the object has already been exposed via JMX, no service is registered and null is returned.
        Parameters:
        oname -
        apiClass -
        api -
        remoteAuth -
        rmiPort -
        Returns:
        the service instance that was exposed and registered.
        Throws:
        AttivioException
      • unregisterMBean

        public static void unregisterMBean​(javax.management.ObjectName oName)
                                    throws javax.management.InstanceNotFoundException,
                                           javax.management.MBeanRegistrationException
        Unregisters the JMX MBean object with the given name.
        Parameters:
        oName - the object name
        Throws:
        javax.management.InstanceNotFoundException
        javax.management.MBeanRegistrationException
      • isValidReadable

        public static boolean isValidReadable​(java.lang.reflect.Method method)
        Judges if a method is valid for JmxReadable
        A valid method for JmxReadable is defined as satisfying all the following:
        • Method is public
        • Takes no argument
        • Return type is not Void.TYPE
        Parameters:
        method - Input method
        Returns:
        true if valid; false otherwise
      • isValidWritable

        public static boolean isValidWritable​(java.lang.reflect.Method method)
        Judges if a method is valid for JmxWritable
        A valid method for JmxWritable is defined as satisfying all the following:
        • Method is public
        • Takes one and only one argument
        • Return type is Void.TYPE

        Note: Variable arity parameters will be treated as one Array object. See JLS for more info.
        Parameters:
        method - Input method
        Returns:
        true if valid; false otherwise
      • isValidInvokable

        public static boolean isValidInvokable​(java.lang.reflect.Method method)
        Judges if a method is valid for JmxInvokable
        A valid method for JmxInvokable is defined as satisfying all the following:
        • Method is public
        Parameters:
        method - Input method
        Returns:
        true if valid; false otherwise