incubator-s4-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthieu Morel <>
Subject Re: onRemove() method and Cache evictions
Date Tue, 26 Nov 2013 18:45:30 GMT
Hi, see comments inline


i'm currently trying to develop an application with s4 to calculate analytics for a service:
number of request for every content, most requested content etc etc (similar to what Twitter
example does let's say).
I was experimenting with setPECache() method and it seems to me that when a PE instance is
removed the onRemove() method is not called, is this normal?

You can override the setPECache method in order to call the onRemove method upon eviction.
It can be useful if you have some cleanup code and resources to release.

I see that S4 is using a LoadingCache object to manage the different PE instances, but i'm
not very familiar on how it works.

Have a look at the guava documentation here:

I want to control the life-span of my PEs and perform some operations before deleting them,
how can i achieve this?

You are on track, override the onRemove method to add the cleanup code, and add an eviction
listener in the guava cache.

On a side note i noticed that whenever i call setPECache() the metrics won't report the number
of PE in cache (file myPE-cache-entries.csv always report 0 for every node).

This could be a bug, you might want to report it. From a quick look at the code I don't see
anything wrong though.



View raw message