-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Nadeem Mohammad edited this page Oct 11, 2016
·
4 revisions
To distribute the execution of tasks using Hazelcast, you have to use HazelcastExecutionEngine
, and follow this steps :
<dependency>
<groupId>com.github.dexecutor</groupId>
<artifactId>dexecutor-hazelcast</artifactId>
<version>LATEST_RELEASE</version>
</dependency>
Config cfg = new Config();
HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
IExecutorService executorService = instance.getExecutorService("test");
if (isMaster) {
DefaultDependentTasksExecutor<Integer, Integer> dexecutor = newTaskExecutor(executorService);
buildGraph(dexecutor);
dexecutor.execute(ExecutionConfig.TERMINATING);
}
private DefaultDependentTasksExecutor<Integer, Integer> newTaskExecutor(IExecutorService executorService) {
DependentTasksExecutorConfig<Integer, Integer> config = new DependentTasksExecutorConfig<Integer, Integer>(
new HazelcastExecutionEngine<Integer, Integer>(executorService), new SleepyTaskProvider());
return new DefaultDependentTasksExecutor<Integer, Integer>(config);
}
Open three terminals and execute the following :
mvn test-compile exec:java -Djava.net.preferIPv4Stack=true -Dexec.mainClass="com.github.dexecutor.hazelcast.Node" -Dexec.classpathScope="test" -Dexec.args="s node-A"
mvn test-compile exec:java -Djava.net.preferIPv4Stack=true -Dexec.mainClass="com.github.dexecutor.hazelcast.Node" -Dexec.classpathScope="test" -Dexec.args="s node-B"
mvn test-compile exec:java -Djava.net.preferIPv4Stack=true -Dexec.mainClass="com.github.dexecutor.hazelcast.Node" -Dexec.classpathScope="test" -Dexec.args="m node-C"
Refer this example for more detail.
Refer this blog post for more detail