Package com.attivio.client.exposedapi
Class JMXUtils
- java.lang.Object
-
- com.attivio.util.JmxUtils
-
- com.attivio.client.exposedapi.JMXUtils
-
public class JMXUtils extends JmxUtils
Contains utilities for interfacing Attivio components to JMX.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJMXUtils.JmxConnectionErrorPredicate
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringATTIVIO_DOMAINOur JMX Domain.static java.lang.StringSYS_PROP_ENABLE_REMOTE_JMXThe system property key used for indicating that jmx agent should be exposed remotely.static java.lang.StringSYS_PROP_ENABLE_SSL_JMXThe system property key used for indicating that jmx agent authentication password.static java.lang.StringSYS_PROP_JMX_AUTH_PROVIDER_BEAN_NAMEThe system property key used to indicate the authentication provider for JMX-
Fields inherited from class com.attivio.util.JmxUtils
ATTIVIO_ADMIN_DOMAIN, OBJECT_NAME_FORMAT, SYSTEM_PROPERTY_JMX_AUTHENTICATE, SYSTEM_PROPERTY_JMX_PORT, SYSTEM_PROPERTY_JMX_SSL
-
-
Constructor Summary
Constructors Constructor Description JMXUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanconfirmDeregistration()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 theServiceFactory.static javax.management.MBeanServergetMBeanServer()Gets the JMX MBeanServer for the application.static booleanisValidInvokable(java.lang.reflect.Method method)Judges if a method is valid forJmxInvokable
A valid method forJmxInvokableis defined as satisfying all the following:
Method is publicstatic booleanisValidReadable(java.lang.reflect.Method method)Judges if a method is valid forJmxReadable
A valid method forJmxReadableis defined as satisfying all the following:
Method is public Takes no argument Return type is notVoid.TYPEstatic booleanisValidWritable(java.lang.reflect.Method method)Judges if a method is valid forJmxWritable
A valid method forJmxWritableis defined as satisfying all the following:
Method is public Takes one and only one argument Return type isVoid.TYPE
Note: Variable arity parameters will be treated as one Array object.static javax.management.ObjectNamenewObjectName(java.lang.String format, java.lang.Object... args)Create a new ObjectName using a format string.static javax.management.ObjectNameobjectName(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.ObjectNameregister(javax.management.ObjectName name, T bean)Registerbeanasname.static <T> javax.management.ObjectNameregisterMBean(java.lang.Class<?> beanClass, T bean, javax.management.ObjectName oName)Registersbeanwith JMX under the provided object name using a specific targeted interface only (not the full bean class).static <T> javax.management.ObjectNameregisterMBean(T bean, javax.management.ObjectName oName)Registersbeanwith JMX under the provided object name.static <T> javax.management.ObjectNameregisterMBeanInstance(T bean, java.lang.String instance)Registers the objectbeanwith the instance nameinstancewith the JMX server.static javax.management.ObjectNameunregister(javax.management.ObjectName name)Unregisters the JMX MBean object with the given name.static voidunregisterMBean(javax.management.ObjectName oName)Unregisters the JMX MBean object with the given name.-
Methods inherited from class com.attivio.util.JmxUtils
connectToRemoteServer, connectToRemoteServer, connectToRemoteServer, getAdminObjectName, getAdminObjectName, getRemoteJmxApi, getRemoteJmxApi, getRemoteProxy
-
-
-
-
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
-
-
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.MalformedObjectNameExceptionCreates 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.InstanceAlreadyExistsExceptionRegisters the objectbeanwith the instance nameinstancewith the JMX server.- Parameters:
bean- the beaninstance- 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.MalformedObjectNameExceptionjavax.management.MBeanRegistrationExceptionjavax.management.NotCompliantMBeanExceptionjavax.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.InstanceAlreadyExistsExceptionRegistersbeanwith JMX under the provided object name.- Throws:
javax.management.MalformedObjectNameExceptionjavax.management.MBeanRegistrationExceptionjavax.management.NotCompliantMBeanExceptionjavax.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.InstanceAlreadyExistsExceptionRegistersbeanwith JMX under the provided object name using a specific targeted interface only (not the full bean class).- Throws:
javax.management.MalformedObjectNameExceptionjavax.management.MBeanRegistrationExceptionjavax.management.NotCompliantMBeanExceptionjavax.management.InstanceAlreadyExistsException
-
register
public static <T> javax.management.ObjectName register(javax.management.ObjectName name, T bean)Registerbeanasname.Returns
nullif registration failed,nameotherwise.
-
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 theServiceFactory. The rmiport must correspond to the remote JMX port. Caller is responsible for callingServiceFactory.unregisterService(ServiceInstance)on the returned service instance. If the object has already been exposed via JMX, no service is registered andnullis 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.MBeanRegistrationExceptionUnregisters the JMX MBean object with the given name.- Parameters:
oName- the object name- Throws:
javax.management.InstanceNotFoundExceptionjavax.management.MBeanRegistrationException
-
isValidReadable
public static boolean isValidReadable(java.lang.reflect.Method method)
Judges if a method is valid forJmxReadable
A valid method forJmxReadableis 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 forJmxWritable
A valid method forJmxWritableis 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 forJmxInvokable
A valid method forJmxInvokableis defined as satisfying all the following:
- Method is public
- Parameters:
method- Input method- Returns:
- true if valid; false otherwise
-
-