Skip to content
Nadeem Mohammad edited this page Oct 8, 2016 · 7 revisions

To distribute the execution of tasks using Apache Ignite, you have to use IgniteExecutionEngine, and follow this steps :

Step 1: Add dexecutor-ignite dependency

    <dependency>
     <groupId>com.github.dexecutor</groupId>
     <artifactId>dexecutor-ignite</artifactId>
     <version>LATEST_RELEASE</version>
   </dependency>

Step 2 : Start Ignite

   IgniteConfiguration cfg = new IgniteConfiguration();
   cfg.setGridName(nodeName);

   Ignite ignite = Ignition.start(cfg); 

Step 3 : Create Dexecutor using Ignite

if (isMaster) {
        DefaultDependentTasksExecutor<Integer, Integer> dexecutor = newTaskExecutor(ignite.compute());

	buildGraph(dexecutor);
	dexecutor.execute(ExecutionConfig.TERMINATING);
}

private DefaultDependentTasksExecutor<Integer, Integer> newTaskExecutor(final IgniteCompute igniteCompute) {
		DependentTasksExecutorConfig<Integer, Integer> config = new DependentTasksExecutorConfig<Integer, Integer>(
				new IgniteExecutionEngine<Integer, Integer>(igniteCompute), new SleepyTaskProvider());
		return new DefaultDependentTasksExecutor<Integer, Integer>(config);
	}

Step 4: Execution

Open three terminals and execute the following :

Terminal #1

  mvn test-compile exec:java -Djava.net.preferIPv4Stack=true -Dexec.mainClass="com.github.dexecutor.ignite.Node" -Dexec.classpathScope="test" -Dexec.args="s node-A"

Terminal #2

 mvn test-compile exec:java -Djava.net.preferIPv4Stack=true -Dexec.mainClass="com.github.dexecutor.ignite.Node" -Dexec.classpathScope="test" -Dexec.args="s node-B"
Terminal #3
  mvn test-compile exec:java  -Dexec.classpathScope="test" -Djava.net.preferIPv4Stack=true -Dexec.mainClass="com.github.dexecutor.ignite.Node" -Dexec.args="m node-C"

Refer this example for more detail.

Refer this blog for more detail