Package org.apache.zookeeper.jmx
Class MBeanRegistry
- java.lang.Object
-
- org.apache.zookeeper.jmx.MBeanRegistry
-
public class MBeanRegistry extends java.lang.Object
This class provides a unified interface for registering/unregistering of zookeeper MBeans with the platform MBean server. It builds a hierarchy of MBeans where each MBean represented by a filesystem-like path. Eventually, this hierarchy will be stored in the zookeeper data tree instance as a virtual data tree.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DOMAIN
-
Constructor Summary
Constructors Constructor Description MBeanRegistry()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MBeanRegistry
getInstance()
javax.management.MBeanServer
getPlatformMBeanServer()
Return the underlying MBeanServer that is being used to register MBean's.java.util.Set<ZKMBeanInfo>
getRegisteredBeans()
java.lang.String
makeFullPath(java.lang.String prefix, java.lang.String... name)
Generate a filesystem-like path.protected java.lang.String
makeFullPath(java.lang.String prefix, ZKMBeanInfo bean)
protected javax.management.ObjectName
makeObjectName(java.lang.String path, ZKMBeanInfo bean)
Builds an MBean path and creates an ObjectName instance using the path.void
register(ZKMBeanInfo bean, ZKMBeanInfo parent)
Registers a new MBean with the platform MBean server.static void
setInstance(MBeanRegistry instance)
Useful for unit tests.void
unregister(ZKMBeanInfo bean)
Unregister MBean.
-
-
-
Field Detail
-
DOMAIN
public static final java.lang.String DOMAIN
- See Also:
- Constant Field Values
-
-
Method Detail
-
setInstance
public static void setInstance(MBeanRegistry instance)
Useful for unit tests. Change the MBeanRegistry instance- Parameters:
instance
- new instance
-
getInstance
public static MBeanRegistry getInstance()
-
getPlatformMBeanServer
public javax.management.MBeanServer getPlatformMBeanServer()
Return the underlying MBeanServer that is being used to register MBean's. The returned MBeanServer may be a new empty MBeanServer if running through IKVM.
-
register
public void register(ZKMBeanInfo bean, ZKMBeanInfo parent) throws javax.management.JMException
Registers a new MBean with the platform MBean server.- Parameters:
bean
- the bean being registeredparent
- if not null, the new bean will be registered as a child node of this parent.- Throws:
javax.management.JMException
-
getRegisteredBeans
public java.util.Set<ZKMBeanInfo> getRegisteredBeans()
- Returns:
- a
Collection
with theZKMBeanInfo
instances not unregistered. Mainly for testing purposes.
-
unregister
public void unregister(ZKMBeanInfo bean)
Unregister MBean.- Parameters:
bean
-
-
makeFullPath
public java.lang.String makeFullPath(java.lang.String prefix, java.lang.String... name)
Generate a filesystem-like path.- Parameters:
prefix
- path prefixname
- path elements- Returns:
- absolute path
-
makeFullPath
protected java.lang.String makeFullPath(java.lang.String prefix, ZKMBeanInfo bean)
-
makeObjectName
protected javax.management.ObjectName makeObjectName(java.lang.String path, ZKMBeanInfo bean) throws javax.management.MalformedObjectNameException
Builds an MBean path and creates an ObjectName instance using the path.- Parameters:
path
- MBean pathbean
- the MBean instance- Returns:
- ObjectName to be registered with the platform MBean server
- Throws:
javax.management.MalformedObjectNameException
-
-