On Fri, Jul 22, 2011 at 8:58 AM, Abhishek Sanoujam <asanou...@terracottatech.com> wrote:
> That method will definitely clear the local cache of the map, but its got > some gotchas. Like when using strong consistency (or > invalidateOnChange=false at the CDSM level), it will also broadcast all > other nodes to clear its local cache. For eventual consistency > (invalidateOnChange=true), it will clear the local cache of that node only. I definitely don't want to clear the local cache on all nodes: given it seems that invalidateOnChange=false by default, I should set it to true, right? > Looks like you are using custom-dso mode, as that class isn't really exposed > from toolkit for express (though I think you can still use it). Nope, I'm using express mode with some little hacks partly contributed by Alex :) BTW, the code is open source: http://code.google.com/p/terrastore/source/browse/src/main/java/terrastore/internal/tc/TCMaster.java > Can you explain your use case a bit more, why the need to clear the local > cache explicitly. Sure: basically, I want full control over data locality, so that I can optimize memory usage and always do local reads. Let me explain those two points a little bit: I use a consistent hashing routing algorithm to partition data between L1s, in order to minimize L1/L2 communication, and I want every L1 to only hold the data it is responsible of given the routing algorithm; in order to do so, everytime an L1 joins/leaves the cluster, I manually flush local entries so that: 1) Data partitioning will change, so I want to flush entries which will "migrate" to other L1s; this way, memory usage is optimized. 2) Also, given I have complete control over data partitioning and routing, I can always do unsafe (unlocked) local reads because either: a) the value is there, and it is the up-to-date value because I can only read/write it from that node (and if another node joins, it will be *flushed*) b) the value is not there, which means it is the first time I access it, so it must be loaded from L2. Obviously, I don't want to clear *all* local caches, and it would be great if I could clear only selected entries (that is in my case, those entries whose routing destination changed). > You can rely on the consistency modes (strong or eventual) > (and in case of CDSM, invalidateOnChange=true/false) on when the local cache > gets invalidated. Trying to see if there is some feature request that can > come out of it. The consistency modes right now does all the hard work to > keep the cache consistent with the desired consistency, and messing it up > may give unexplained behaviors with expected consistency guarantees. Got it, but as you may see I have other requirements: do you see any specific problems with my usage of the "clearLocalCache" method? Thanks! Sergio B. -- Sergio Bossa http://www.linkedin.com/in/sergiob _______________________________________________ tc-dev mailing list tc-dev@lists.terracotta.org http://lists.terracotta.org/mailman/listinfo/tc-dev