public class SampledMBeanRegistrationProvider extends java.lang.Object implements MBeanRegistrationProvider, CacheManagerEventListener
MBeanRegistrationProvider
which registers
sampled MBeans for the CacheManager and its Caches.
This also implements CacheManagerEventListener
to add/remove/cleanup
MBeans for new caches added or removed
Modifier and Type | Field and Description |
---|---|
private CacheManager |
cacheManager |
private SampledCacheManager |
cacheManagerMBean |
private java.lang.String |
clientUUID |
private static org.slf4j.Logger |
LOG |
private static int |
MAX_MBEAN_REGISTRATION_RETRIES |
private java.util.Map<javax.management.ObjectName,java.lang.Object> |
mbeans |
private javax.management.MBeanServer |
mBeanServer |
private java.lang.String |
registeredCacheManagerName |
private Status |
status |
Constructor and Description |
---|
SampledMBeanRegistrationProvider()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Stop the listener and free any resources.
|
Status |
getStatus()
Returns the listener status.
|
void |
init()
CacheManagerEventListener.init() - no need to do anything here
|
void |
initialize(CacheManager cacheManagerParam,
ClusteredInstanceFactory clusteredInstanceFactory)
Initialize MBeanRegistration if necessary for the cacheManager
|
boolean |
isAlive()
Returns true if this
SampledMBeanRegistrationProvider is alive |
boolean |
isInitialized()
Returns
true if initialized otherwise false |
void |
notifyCacheAdded(java.lang.String cacheName)
Called immediately after a cache has been added and activated.
|
void |
notifyCacheRemoved(java.lang.String cacheName)
Called immediately after a cache has been disposed and removed.
|
private void |
registerCacheManagerMBean(SampledCacheManager cacheManagerMBean) |
private void |
registerCacheMBean(Ehcache cache) |
private void |
registerStoreMBean(Ehcache cache) |
void |
reinitialize(ClusteredInstanceFactory clusteredInstanceFactory)
Reinitialize the mbeans.
|
private static final org.slf4j.Logger LOG
private static final int MAX_MBEAN_REGISTRATION_RETRIES
private Status status
private CacheManager cacheManager
private java.lang.String clientUUID
private final javax.management.MBeanServer mBeanServer
private final java.util.Map<javax.management.ObjectName,java.lang.Object> mbeans
private volatile java.lang.String registeredCacheManagerName
private SampledCacheManager cacheManagerMBean
public SampledMBeanRegistrationProvider()
public void initialize(CacheManager cacheManagerParam, ClusteredInstanceFactory clusteredInstanceFactory)
initialize
in interface MBeanRegistrationProvider
private void registerCacheManagerMBean(SampledCacheManager cacheManagerMBean) throws java.lang.Exception
java.lang.Exception
public void reinitialize(ClusteredInstanceFactory clusteredInstanceFactory) throws MBeanRegistrationProviderException
CacheManager
to re-register the mbeansreinitialize
in interface MBeanRegistrationProvider
MBeanRegistrationProviderException
public boolean isInitialized()
true
if initialized otherwise falseisInitialized
in interface MBeanRegistrationProvider
true
if initializedpublic void init() throws CacheException
init
in interface CacheManagerEventListener
CacheException
- - all exceptions are wrapped in CacheExceptionprivate void registerCacheMBean(Ehcache cache) throws javax.management.InstanceAlreadyExistsException, javax.management.MBeanRegistrationException, javax.management.NotCompliantMBeanException
javax.management.InstanceAlreadyExistsException
javax.management.MBeanRegistrationException
javax.management.NotCompliantMBeanException
private void registerStoreMBean(Ehcache cache) throws javax.management.InstanceAlreadyExistsException, javax.management.MBeanRegistrationException, javax.management.NotCompliantMBeanException
javax.management.InstanceAlreadyExistsException
javax.management.MBeanRegistrationException
javax.management.NotCompliantMBeanException
public Status getStatus()
getStatus
in interface CacheManagerEventListener
public void dispose() throws CacheException
dispose
in interface CacheManagerEventListener
CacheException
- - all exceptions are wrapped in CacheExceptionpublic boolean isAlive()
SampledMBeanRegistrationProvider
is alivepublic void notifyCacheAdded(java.lang.String cacheName)
notifyCacheAdded
in interface CacheManagerEventListener
cacheName
- the name of the Cache
the operation relates toCacheEventListener
public void notifyCacheRemoved(java.lang.String cacheName)
notifyCacheRemoved
in interface CacheManagerEventListener
cacheName
- the name of the Cache
the operation relates to