This post originated from an RSS feed registered with Java Buzz
by Talip Ozturk.
Original Post: Hazelcast 1.2beta: Distributed ExecutorService
Feed Title: Shared Memory
Feed URL: http://www.jroller.com/talipozturk/feed/entries/rss
Feed Description: about java, jcache, jini, javaspaces, distributed data structures and a little bit of me and life.
Another big milestone for Hazelcast: Distributed implementation of java.util.concurrent.ExecutorService is now available for download. It is time to execute code on cluster. You can tell Hazelcast to execute your code (Runnable, Callable):
on a specific cluster member you choose.
on the member owning the key you choose.
on the member Hazelcast will pick.
on all or subset of the cluster members.
Sample code will make it more understandable so let say you have a Echo callable that you want to execute:
import java.util.concurrent.Callable;
import java.io.Serializable;
public class Echo implements Callable, Serializable {
String input = null;
public Echo() {
super();
}
public Echo(String input) {
super();
this.input = input;
}
public String call() {
return Hazelcast.getCluster().getLocalMember().toString() + ":"
+ input;
}
}
Here are the methods to execute the Echo in a distributed way:
I plan to add couple of more features before the 1.2final such as executing multiple callable|runnables in shot. Make sure you check out the documentation at hazelcast.com for complete list of features and more sample code.
Feedback is always welcomed (oztalip@gmail.com or hazelcast@googlegroups.com)