|
GemFire 7.0.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CacheListener<K,V>
A listener to handle region or entry related events.
Instead of implementing this interface it is recommended that you extend the
CacheListenerAdapter
class.
The methods on a CacheListener
are invoked while holding a lock
on the entry described by the EntryEvent
, as a result if the listener
method takes a long time to execute then it will cause the operation that
caused it to be invoked to take a long time. In addition, listener code which
calls Region
methods could result in a deadlock. For example, in
afterUpdate(EntryEvent)
for entry key k1,
put(k2, someVal)
is called at the same
time afterUpdate(EntryEvent)
for entry key k2 calls
put(k1, someVal)
a deadlock may result.
This co-key dependency example can be extended to a co-Region dependency
where listener code in Region "A" performs Region operations on "B" and
listener code in Region "B" performs Region operations on "A". Deadlocks may
be either java-level or distributed multi-VM dead locks depending on Region
configuration. To be assured of no deadlocks, listener code should cause some
other thread to access the region and must not wait for that thread to
complete the task.
Multiple events, on different entries, can cause concurrent invocation of
CacheListener
methods. Any exceptions thrown by the listener are
caught by GemFire and logged.
To declare a CacheListener in a Cache XML file, it must also implement
Declarable
AttributesFactory.addCacheListener(com.gemstone.gemfire.cache.CacheListener)
,
AttributesFactory.initCacheListeners(com.gemstone.gemfire.cache.CacheListener[])
,
RegionAttributes.getCacheListeners()
,
AttributesMutator.addCacheListener(com.gemstone.gemfire.cache.CacheListener)
,
AttributesMutator.removeCacheListener(com.gemstone.gemfire.cache.CacheListener)
,
AttributesMutator.initCacheListeners(com.gemstone.gemfire.cache.CacheListener[])
Method Summary | |
---|---|
void |
afterCreate(EntryEvent<K,V> event)
Handles the event of new key being added to a region. |
void |
afterDestroy(EntryEvent<K,V> event)
Handles the event of an entry being destroyed. |
void |
afterInvalidate(EntryEvent<K,V> event)
Handles the event of an entry's value being invalidated. |
void |
afterRegionClear(RegionEvent<K,V> event)
Handles the event of a region being cleared. |
void |
afterRegionCreate(RegionEvent<K,V> event)
Handles the event of a region being created. |
void |
afterRegionDestroy(RegionEvent<K,V> event)
Handles the event of a region being destroyed. |
void |
afterRegionInvalidate(RegionEvent<K,V> event)
Handles the event of a region being invalidated. |
void |
afterRegionLive(RegionEvent<K,V> event)
Handles the event of a region being live after receiving the marker from the server. |
void |
afterUpdate(EntryEvent<K,V> event)
Handles the event of an entry's value being modified in a region. |
Methods inherited from interface com.gemstone.gemfire.cache.CacheCallback |
---|
close |
Method Detail |
---|
void afterCreate(EntryEvent<K,V> event)
event
- the EntryEventRegion.create(Object, Object)
,
Region.put(Object, Object)
,
Region.get(Object)
void afterUpdate(EntryEvent<K,V> event)
event
- the EntryEventRegion.put(Object, Object)
void afterInvalidate(EntryEvent<K,V> event)
event
- the EntryEventRegion.invalidate(Object)
void afterDestroy(EntryEvent<K,V> event)
event
- the EntryEventRegion.destroy(Object)
void afterRegionInvalidate(RegionEvent<K,V> event)
regionInvalidated
event invoked on its listener.
event
- the RegionEventRegion.invalidateRegion()
,
Region.localInvalidateRegion()
void afterRegionDestroy(RegionEvent<K,V> event)
afterRegionDestroyed
event invoked on its listener.
event
- the RegionEventRegion.destroyRegion()
,
Region.localDestroyRegion()
,
Region.close()
,
RegionService.close()
void afterRegionClear(RegionEvent<K,V> event)
event
- the RegionEventRegion.clear()
void afterRegionCreate(RegionEvent<K,V> event)
Note that this method is only called
for creates done in the local vm. To be notified of creates done in remote
vms use RegionMembershipListener.afterRemoteRegionCreate(com.gemstone.gemfire.cache.RegionEvent
.
event
- the RegionEventCache.createRegion(java.lang.String, com.gemstone.gemfire.cache.RegionAttributes)
,
Region.createSubregion(java.lang.String, com.gemstone.gemfire.cache.RegionAttributes)
void afterRegionLive(RegionEvent<K,V> event)
event
- the RegionEventCache.readyForEvents()
|
GemFire 7.0.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |