<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 12 Apr 2010, at 14:08, Mircea Markus wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Another way to do it is by specifying an associator (not my idea TBH [1]).<div>This is non-intrusive and no-api changes as well.</div></div></blockquote><div><br></div><div>Is it non-intrusive? &nbsp;Doesn't this mean that keys need to implement an interface?</div><div><br></div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Cheers.</div><div>Mircea<br><div><br></div><div><div><div><div>[1]&nbsp;<a href="http://coherence.oracle.com/display/COH35UG/Data+Affinity">http://coherence.oracle.com/display/COH35UG/Data+Affinity</a>&nbsp;</div><div><div><br><div><div>On 12 Apr 2010, at 15:36, Manik Surtani wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Re: subject (see&nbsp;<a href="https://jira.jboss.org/jira/browse/ISPN-359">https://jira.jboss.org/jira/browse/ISPN-359</a>), there are a couple of approaches that could be taken:</div><div><br></div><div>1. &nbsp;Don't use key.hashcode() as the seed in determining to which nodes an entry is mapped, but instead on a well-known method or annotated method (e.g., int getGroupID() or a method annotated with @GroupId). &nbsp;The way I see it, this approach has:</div><div><br></div><div>+ Will work, no additional overheads of AtomicMaps</div><div>- Cost (reflection)</div><div>- Intrusive (what if users have no control over the key class, e.g., String keys?)</div><div><br></div><div>2. &nbsp;Additional API methods on the cache - cache.put(K, V, G), cache.putAll(Map, G), etc.</div><div><br></div><div>+ Non-intrusive</div><div>- Overhead of AtomicMaps + additional entries for mappings</div><div>+ or - (depending on how you look at it) all keys in the group will be locked together, etc, a side-effect of using AtomicMaps</div><div><br></div><div>My pref is for approach #2. &nbsp;In terms of implementation, here is what I have in mind:</div><div><br></div><div>* A GroupingInterceptor that intercepts the call early on if the call is a put(K, V, G) or something similar. &nbsp;</div><div>* Breaks up the call to a put(K, G) and a getAtomicMap(G).put(K, V). &nbsp;Wrapped in a tx to ensure atomicity.</div><div>* get(K), etc intercepted as well, replaced with getAtomicMap(get(K)).get(K)</div><div>* remove(K), etc intercepted with&nbsp;getAtomicMap(get(K)).remove(K)</div><div><br></div><div>One of the issues with the API approach is that it heavily pollutes the Cache API. &nbsp;It will double the number of put() methods on Cache (currently 18 variants of put, including ones that take in lifespans and maxIdles, async versions that return futures, etc.) &nbsp;Perhaps this could be in an additional sub-interface interface? &nbsp;GroupedCache? &nbsp;Or is this degree of method overloading not too confusing?</div><div><br></div><div>Cheers,</div><div>
<span class="Apple-style-span" style="font-size: 12px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--</div><div>Manik Surtani</div><div><a href="mailto:manik@jboss.org">manik@jboss.org</a></div><div>Lead, Infinispan</div><div>Lead, JBoss Cache</div><div><a href="http://www.infinispan.org/">http://www.infinispan.org</a></div><div><a href="http://www.jbosscache.org/">http://www.jbosscache.org</a></div><div><br></div></div></span><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br></div>_______________________________________________<br>infinispan-dev mailing list<br><a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a></blockquote></div><br></div></div></div></div></div></div></div>_______________________________________________<br>infinispan-dev mailing list<br><a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/infinispan-dev</blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--</div><div>Manik Surtani</div><div><a href="mailto:manik@jboss.org">manik@jboss.org</a></div><div>Lead, Infinispan</div><div>Lead, JBoss Cache</div><div><a href="http://www.infinispan.org">http://www.infinispan.org</a></div><div><a href="http://www.jbosscache.org">http://www.jbosscache.org</a></div><div><br></div></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline">
</div>
<br></body></html>