Top Description Fields Constructors Methods
net.sf.ehcache.management.sampled

public Class SampledMBeanRegistrationProvider

extends Object
implements MBeanRegistrationProvider, CacheManagerEventListener
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.event.CacheManagerEventListener, net.sf.ehcache.management.provider.MBeanRegistrationProvider
Imports
java.lang.management.ManagementFactory, java.util.Map, .Set, java.util.concurrent.ConcurrentHashMap, javax.management.InstanceAlreadyExistsException, .MBeanRegistrationException, .MBeanServer, .MalformedObjectNameException, .NotCompliantMBeanException, .ObjectName, net.sf.ehcache.CacheException, .CacheManager, .Ehcache, .Status, net.sf.ehcache.event.CacheManagerEventListener, net.sf.ehcache.hibernate.management.impl.BaseEmitterBean, net.sf.ehcache.management.provider.MBeanRegistrationProvider, .MBeanRegistrationProviderException, net.sf.ehcache.terracotta.ClusteredInstanceFactory, org.slf4j.Logger, .LoggerFactory

An implementation of 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

Author
Abhishek Sanoujam
Since
1.7

Field Summary

Modifier and TypeField and Description
private CacheManager
private SampledCacheManager
private String
private static final Logger
private static final int
private final Map<ObjectName, Object>
private final MBeanServer
private volatile String
private Status

Constructor Summary

AccessConstructor and Description
public
SampledMBeanRegistrationProvider()

Default constructor

Method Summary

Modifier and TypeMethod and Description
public synchronized void
dispose()

Implements net.sf.ehcache.event.CacheManagerEventListener.dispose.

Stop the listener and free any resources.
public synchronized Status

Returns:

the status at the point in time the method is called
getStatus
()

Implements net.sf.ehcache.event.CacheManagerEventListener.getStatus.

Returns the listener status.
public void
init()

Implements net.sf.ehcache.event.CacheManagerEventListener.init.

CacheManagerEventListener.init() - no need to do anything here
public synchronized void
initialize(CacheManager cacheManagerParam, ClusteredInstanceFactory clusteredInstanceFactory)

Implements net.sf.ehcache.management.provider.MBeanRegistrationProvider.initialize.

Initialize MBeanRegistration if necessary for the cacheManager
public synchronized boolean

Returns:

true if alive otherwise false
isAlive
()

Returns true if this SampledMBeanRegistrationProvider is alive

public synchronized boolean
isInitialized()

Implements net.sf.ehcache.management.provider.MBeanRegistrationProvider.isInitialized.

Returns true if initialized otherwise false
public void
notifyCacheAdded(String
the name of the Cache the operation relates to
cacheName
)

Implements net.sf.ehcache.event.CacheManagerEventListener.notifyCacheAdded.

Called immediately after a cache has been added and activated.
public void
notifyCacheRemoved(String
the name of the Cache the operation relates to
cacheName
)

Implements net.sf.ehcache.event.CacheManagerEventListener.notifyCacheRemoved.

Called immediately after a cache has been disposed and removed.
private void
private void
private void
public synchronized void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheManagerback to summary
private CacheManager cacheManager
cacheManagerMBeanback to summary
private SampledCacheManager cacheManagerMBean
clientUUIDback to summary
private String clientUUID
LOGback to summary
private static final Logger LOG
MAX_MBEAN_REGISTRATION_RETRIESback to summary
private static final int MAX_MBEAN_REGISTRATION_RETRIES
mbeansback to summary
private final Map<ObjectName, Object> mbeans
mBeanServerback to summary
private final MBeanServer mBeanServer
registeredCacheManagerNameback to summary
private volatile String registeredCacheManagerName
statusback to summary
private Status status

Constructor Detail

SampledMBeanRegistrationProviderback to summary
public SampledMBeanRegistrationProvider()

Default constructor

Method Detail

disposeback to summary
public synchronized void dispose() throws CacheException

Implements net.sf.ehcache.event.CacheManagerEventListener.dispose.

Stop the listener and free any resources. Removes registered ObjectNames

Exceptions
CacheException:
- all exceptions are wrapped in CacheException
getStatusback to summary
public synchronized Status getStatus()

Implements net.sf.ehcache.event.CacheManagerEventListener.getStatus.

Returns the listener status.

Returns:Status

the status at the point in time the method is called

initback to summary
public void init() throws CacheException

Implements net.sf.ehcache.event.CacheManagerEventListener.init.

CacheManagerEventListener.init() - no need to do anything here

Exceptions
CacheException:

Doc from net.sf.ehcache.event.CacheManagerEventListener.init.

- all exceptions are wrapped in CacheException

initializeback to summary
public synchronized void initialize(CacheManager cacheManagerParam, ClusteredInstanceFactory clusteredInstanceFactory)

Implements net.sf.ehcache.management.provider.MBeanRegistrationProvider.initialize.

Doc from net.sf.ehcache.management.provider.MBeanRegistrationProvider.initialize.

Initialize MBeanRegistration if necessary for the cacheManager

isAliveback to summary
public synchronized boolean isAlive()

Returns true if this SampledMBeanRegistrationProvider is alive

Returns:boolean

true if alive otherwise false

isInitializedback to summary
public synchronized boolean isInitialized()

Implements net.sf.ehcache.management.provider.MBeanRegistrationProvider.isInitialized.

Doc from net.sf.ehcache.management.provider.MBeanRegistrationProvider.isInitialized.

Returns true if initialized otherwise false

Returns:boolean

true if initialized

notifyCacheAddedback to summary
public void notifyCacheAdded(String cacheName)

Implements net.sf.ehcache.event.CacheManagerEventListener.notifyCacheAdded.

Called immediately after a cache has been added and activated.

Parameters
cacheName:String

Doc from net.sf.ehcache.event.CacheManagerEventListener.notifyCacheAdded.

the name of the Cache the operation relates to

notifyCacheRemovedback to summary
public void notifyCacheRemoved(String cacheName)

Implements net.sf.ehcache.event.CacheManagerEventListener.notifyCacheRemoved.

Called immediately after a cache has been disposed and removed. The calling method will block until this method returns.

Parameters
cacheName:String

the name of the Cache the operation relates to

registerCacheManagerMBeanback to summary
private void registerCacheManagerMBean(SampledCacheManager cacheManagerMBean) throws Exception
registerCacheMBeanback to summary
private void registerCacheMBean(Ehcache cache) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException
registerStoreMBeanback to summary
private void registerStoreMBean(Ehcache cache) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException
reinitializeback to summary
public synchronized void reinitialize(ClusteredInstanceFactory clusteredInstanceFactory) throws MBeanRegistrationProviderException

Implements net.sf.ehcache.management.provider.MBeanRegistrationProvider.reinitialize.

Doc from net.sf.ehcache.management.provider.MBeanRegistrationProvider.reinitialize.

Reinitialize the mbeans. Uses the current name of the CacheManager to re-register the mbeans