<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 16 Dec 2010, at 11:34, Vladimir Blagojevic wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On 10-12-16 7:25 AM, Manik Surtani wrote:<br><blockquote type="cite"><br></blockquote><blockquote type="cite">I think it makes more sense on CacheManager because we might have a task operating on data of a few caches, not just one. So to be safe and not sorry I'd go with CacheManager. newDistributedTask can have parameters to specify which cache(s) to use.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">So you'd do CacheManager.newDistributedTask(task, Map&lt;String, K&gt; cacheNamesAndKeys)?<br></blockquote><blockquote type="cite"><br></blockquote><br>No, I'd shift these parameters to DistributedTask#execute unless we absolutely need them at for task creation. Let's keep factory method for DistributedTask as simple as possible. I'd rather have a single factory method and develop and grow DistributedTask API independently of CacheManager than have multiple overloaded factory methods for DistributedTask.<br></div></blockquote><div><br></div><div>Hmm. &nbsp;Maybe it is better to not involve an API on the CacheManager at all. &nbsp;Following JSR166y [1], we could do:</div><div><br></div><div>DistributedForkJoinPool p = DisributedForkJoinPool.newPool(cache); // I still think it should be on a per-cache basis</div><div><br></div><div>DistributedTask&lt;MyResultType, K, V&gt; dt = new DistributedTask&lt;MyResultType, K, V&gt;() {</div><div>&nbsp;&nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;public void map(Map.Entry&lt;K, V&gt; entry, Map&lt;K, V&gt; context) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// select the entries you are interested in. &nbsp;Transform if needed and store in context</div><div>&nbsp;&nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp;public&nbsp;MyResultType reduce(Map&lt;Address, Map&lt;K, V&gt;&gt; contexts) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// aggregate from context and return value.</div><div>&nbsp;&nbsp; &nbsp;};</div><div><br></div><div>};</div><div><br></div><div>MyResultType result = p.invoke(dt, key1, key2, key3); // keys are optional.</div><div><br></div><div>What I see happening is:</div><div><br></div><div>* dt is broadcast to all nodes that hold either of {key1, key2, key3}. &nbsp;If keys are not provided, broadcast to all.</div><div>* dt.map() is called on each node, for each key specified (if it exists on the local node).</div><div>* Contexts are sent back to the calling node and are passed to dt.reduce()</div><div>* Result of dt.reduce() passed to the caller of p.invoke()</div><div><br></div><div>What do you think?&nbsp;</div><div><br></div><div><br></div><div>[1]&nbsp;<a href="http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/index.html">http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/index.html</a></div><div>--</div></div><div><div><div>Manik Surtani</div><div><a href="mailto:manik@jboss.org">manik@jboss.org</a></div><div><a href="http://twitter.com/maniksurtani">twitter.com/maniksurtani</a></div><div><br></div><div>Lead, Infinispan</div><div><a href="http://www.infinispan.org">http://www.infinispan.org</a></div><div><br></div></div><br class="Apple-interchange-newline">
</div>
<br></body></html>