-
1. Re: Being notified by EvictionManager
vblagojevic Sep 29, 2010 12:07 PM (in response to eboily)1 of 1 people found this helpfulSo you want to be notified when expired entry is pruned/evicted from cache? We do not have that listener/event. We can either add a flag expired to CacheEntryEvictedEvent or add a new event say CacheEntryExpiredEvent which would mean that the entry has expired and has been evicted from cache.
Which one makes more sense to you? Anyone else?
Regards,
Vladimir
-
2. Re: Being notified by EvictionManager
eboily Sep 29, 2010 2:54 PM (in response to vblagojevic)My requirement is that I must know whenever an entry is removed from the cache.I see multiple situations where an entry is removed from the cache:1. an entry is explicitly evicted using cache.evict(key).2. a non expired entry is pruned when adding a new entry and maxEntries is reached.3. a non expired entry is pruned by the EvictionManager thread (in coming PIGGYBACK mode)4. an expired (over maxIdle) entry is removed by the EvictionManager thread5. an expired (over lifespan) entry is removed by the EvictionManager threadCases 1 and 2 are already supported by a notification. No issues here.However, cases 3, 4 and 5 are not currently supported by notifications.The notification can be either en evicted notification with a "reason" flag or a new expired notification. I think the "reason" flag would be more generic encompass the five types of eviction mentioned above.Hi again Vladimir,
My requirement is that I must know whenever an entry is removed from the cache.
I see multiple situations where an entry is removed from the cache:
- an entry is explicitly evicted using cache.evict(key).
- a non expired entry is pruned when adding a new entry and maxEntries is reached.
- a non expired entry is pruned by the EvictionManager thread (in coming PIGGYBACK mode)
- an expired (over maxIdle) entry is removed by the EvictionManager thread
- an expired (over lifespan) entry is removed by the EvictionManager thread
Cases 1 and 2 are already supported by the CacheEntryEvicted notification. No issues here.
However, cases 3, 4 and 5 are not currently supported by any notification (as far as I've looked in the code and experimented).
The notification can either be a CacheEntryEvicted notification with a "reason" flag or a new CacheEntryExpired notification. But I think the CacheEntryEvicted notification with a "reason" flag would be far more generic because it could encompass the five types of eviction mentioned above. This way you would have the "reason" flag settable to EXPLICIT, PRUNED and EXPIRED.
There is a business reason why one may want to differentiate pruned evictions from expired eviction: a pruned eviction implies the cache is full, which may trigger a different reaction than an expired eviction. These notifications and this distinction also greatly facilitates QA tasks.
My two cents.
Anybody else?
- Edouard
-
3. Re: Being notified by EvictionManager
vblagojevic Sep 30, 2010 11:06 AM (in response to eboily)1 of 1 people found this helpfulIn order to conform to an existing framework most likely we will have to implement a separate event - CacheEntryExpired. Also we probably can not differentiate if it was an explicit, pruned etc etc. Please create a JIRA task and we'll put it into task pipeline.
Best regards,
Vladimir
-
4. Re: Being notified by EvictionManager
eboily Sep 30, 2010 12:33 PM (in response to vblagojevic)Hi Vladimir,
If you want to go with an Expired event, I may have a quick patch that I did yesterday that implement this.
Please see the patch file attached to this message.
Basically, I overloaded
void purgeExpired();/*** Purges entries that have passed their expiry time and notify eviction listeners.*/void purgeExpired(CacheNotifier cacheNotifier);DataContainer.purgeExpired();
with
DataContainer.purgeExpired(CacheNotifier cacheNotifier);
and I call it from EvictionManagerImpl.processEviction(), replacing dataContainer.purgeExpired() by dataContainer.purgeExpired(cacheNotifier). I also created the proper event. However, I do not use exactly the same signature as for the other notifiers. I usevoid notifyCacheEntryExpired(Object key);instead of a signature similar tovoid notifyCacheEntryEvicted(Object key, boolean pre, InvocationContext ctx);It has been done quickly but it works.You can apply the patch file with a level 1 strip (-p1) as follows# cd infinispan-4.1.0.FINAL# patch -p1 <../ExpiredEvent.patchI hope this helps.Best redgards,- Edouard-
ExpiredEvent.patch.zip 3.1 KB
-
-
5. Re: Being notified by EvictionManager
trustin Oct 21, 2010 8:12 AM (in response to eboily)I left a comment to the JIRA issue - ISPN-694.