CacheListerer : identify node that has updated an entry
xavier.marquis Oct 1, 2019 10:28 AMHi,
I begin with infinispan, and I don't understand well the meaning of TransactionalEvent.isOriginLocal() getter method :
I've set a configuration for an distributed infinispan cache DIST_SYNC, with following flags :
IGNORE_RETURN_VALUES, SKIP_CACHE_LOAD and SKIP_REMOTE_LOOKUP
In my node application, I've created a CacheListener class like this :
@Listener(clustered = true, sync = false)
class CacheListener {
@CacheEntryCreated
public void onCacheEntryCreated(CacheEntryCreatedEvent event) {
// do something ...
}
@CacheEntryModified
public void onCacheEntryModified(CacheEntryModifiedEvent event) {
// do something ...
}
}
and called cache.addListener( new CacheListener() ).
Then, when nodeA and nodeB are started and sharing the same cache, and entry E1 is already present in the shared cache, i expected similar behaviour :
- When nodeA updates entry E1:
- CacheListener of nodeA notify it with an event whose isOriginLocal = true
- CacheListener of nodeB notify it with an event whose isOriginLocal = false
- When nodeB updates entry E1:
- CacheListener of nodeB notify it with an event whose isOriginLocal = true
- CacheListener of nodeA notify it with an event whose isOriginLocal = false
But that is not the case : During my test, It seems like isOriginLocal = true when E1 entry is updated by 'primary owner', where 'primary owner' could be defined like this :
primary owner :
- node that has created entry E1 (if it still is alive)
- one of the other nodes (implied with this cache), which own this entry and which has been considered as the new E1 creator, since first E1 creator exited cache.
> Q1. Can someone confirm my conclusion ?
If it is true, my initial aim was to distinguish, in cacheListener notification events, node that updates E1 from nodes that receives E1 update.
If cacheListener does not allow this functionnality, does infinispan framework give another element to deal with it ?
> Q2 : Another notice :
I don't understand why, but the only events CacheEntryEvent that my application receive are only those after update ( isPre = false ) ...
Thanks for reading,
Xavier