Running Multiple Zookeeper Instances On Single Windows Machine

This is indeed correct with Zookeeper Runner

Running Zookeeper in windows in made so easy that even grandma can do it.

 Step 1: copy three instances of ZookeeperRunner on your local drive

I have copied it as instance1, instance2 and instance3


Step 2: copy required zookeeper jar files to [RUNNER_HOME]/lib

Note : you have to do it for all the instances.


Step 3: update the zoo config files

Note: you have to do it for all the instances.

client ports

instance1= 2181




Step 4: update the wrapper config


Step 5 : update the myid files


Step 6 : start Zookeeper instances

Note : you have to do it for all the instances.


Here are the running instances.





Multi Node Distributed Execution Using Infinispan and Dexecutor

We will try to execute Dexecutor in a distributed mode using Infinispan. For the demo we would be setting up multiple infinispan nodes on single machine.

Refer Introducing Dexecutor, to get an introduction on Dexecutor  and to understand the problem we would solve in a distribute fashion. In short:

We would be distributing the execution of dexecutor tasks on Infinispan nodes in a single machine.

To do that one of the nodes would act as master and submit the tasks to DistributedExecutorService to be executed by other infinispan worker nodes.

Step 1: Add dexecutor-infinispan dependency




Step 2: Add the default jgroups.xml

Step 3: Create the CacheManager

private DefaultCacheManager createCacheManagerProgrammatically(final String nodeName, final String cacheName) {
	DefaultCacheManager cacheManager = new DefaultCacheManager(globalConfiguration(nodeName), defaultConfiguration());
	cacheManager.defineConfiguration(cacheName, cacheConfiguration());
	return cacheManager;

private GlobalConfiguration globalConfiguration(String nodeName) {
	return GlobalConfigurationBuilder
				.addProperty("configurationFile", "jgroups.xml")

private Configuration defaultConfiguration() {
	return new ConfigurationBuilder()

private Configuration cacheConfiguration() {
	return new ConfigurationBuilder()

Step 4 : Create Dexecutor instance using InfinispanExecutionEngine

EmbeddedCacheManager cacheManager = createCacheManagerProgrammatically(nodeName, cacheName);
final Cache<String, String> cache = cacheManager.getCache(cacheName);
DefaultExecutorService distributedExecutorService = new DefaultExecutorService(cache);
DefaultDependentTasksExecutor<Integer, Integer> dexecutor = newTaskExecutor(distributedExecutorService);

private DefaultDependentTasksExecutor<Integer, Integer> newTaskExecutor(final DistributedExecutorService executorService) {
	return new DefaultDependentTasksExecutor<Integer, Integer>(taskExecutorConfig(executorService));

private DependentTasksExecutorConfig<Integer, Integer> taskExecutorConfig(final DistributedExecutorService executorService) {
	return new DependentTasksExecutorConfig<Integer, Integer>(executionEngine(executorService), new SleepyTaskProvider());

private InfinispanExecutionEngine<Integer, Integer> executionEngine(final DistributedExecutorService executorService) {
	return new InfinispanExecutionEngine<Integer, Integer>(executorService);

Step 5: Only master should create tasks

if (isMaster) {
	DefaultExecutorService distributedExecutorService = new DefaultExecutorService(cache);
	DefaultDependentTasksExecutor<Integer, Integer> dexecutor = newTaskExecutor(distributedExecutorService);


Refer the full code here

Step 4: Run the Application

Terminal #1 : run as worker

mvn test-compile exec:java -Dexec.mainClass="com.github.dexecutor.infinispan.Node" -Dexec.classpathScope="test" -Dexec.args="s node-A"

Terminal #2: run as worker

mvn test-compile exec:java -Dexec.mainClass="com.github.dexecutor.infinispan.Node" -Dexec.classpathScope="test" -Dexec.args="s node-B"


Terminal #3 : run as master

mvn test-compile exec:java  -Dexec.classpathScope="test" -Dexec.mainClass="com.github.dexecutor.infinispan.Node" -Dexec.args="m node-C"

Here is the output:



Introducing Dexecutor

From the Dexecutor Website

Executing dependent/Independent tasks in a reliable way, is made so easy that even grandma can do it.

That is indeed true with Dexecutor, specially considering the complexity involved writing error free programs involving dependent/Independent tasks. Without Dexecutor, you would end up writing tons of plumbing code rather than concentrating on the business.

With Dexecutor, you model your requirements in terms of Graph in an object oriented way, and rest would be taken care by the framework in a reliable way. Dynamically built graph, defines the executing order, what are all tasks that should run in parallel/sequential. For example if the graph built is the following


Then it means, Task#1,Task#12 and Task#11 would run in parallel, once one of them finishes execution, its child nodes would begin execution. For example lets say if Task#1 finishes, then Task#2 and Task#3 would begin, similarly with Task#12 and Task#11, until all the tasks are executed or if a task end up in an error (If the execution behaviour is terminating)

That’s great indeed…. But how it is done ?

 DefaultDependentTasksExecutor<Integer, Integer> executor = newTaskExecutor();

//Build the graph
executor.addDependency(1, 2);
executor.addDependency(1, 3);
executor.addDependency(3, 4);
executor.addDependency(3, 5);
executor.addDependency(3, 6);
//executor.addDependency(10, 2); // cycle
executor.addDependency(2, 7);
executor.addDependency(2, 9);
executor.addDependency(2, 8);
executor.addDependency(9, 10);
executor.addDependency(12, 13);
executor.addDependency(13, 4);
executor.addDependency(13, 14);

// Execute

Above code shows, Dexecutor expose two kind of APIs,

  • An API to construct the Graph (addDependency, addIndependent)
  • An API to Start execution (execute)

That’s simple indeed, You may be wondering, How the tasks are mapped?

TaskProvider to the rescue. TaskProviders, maps a graph node to a task, and is basically provided during Dexecutor instance creation. Refer to JavaDoc of Dexecutor Implementation, and an example of how to do it.

Well, the example is very simple, Can we get any real time example of how Dexecutor can be used?

Yes indeed, Dexecutor does have a sample application which provides a real time scenario, refer it for more details.

Finally I would like to quote the features of Dexecutor, Here is a snapshot from the website.



Publish Your Artifacts To Maven Central

Step by step guide to deploying  arftifacts to maven central. For this blog we will use Github


Step1: Make sure if you have installed JDK,Maven, Git etc.

Step 2: Create Github account (If not already done)


Step 3: Create a new Github repository


Step 4: Add a new SSH key to your Github account

Step 5: Push the code to Github

Step 6: Sign up for Sonatype Jira account!default.jspa

Step 7: Create A Jira issue for new project hosting

Here is a sample request


Step 8: Install GNU PG

Download from and install in your OS, verify as follows

Step 9: Generate the key pair

It would prompt you for phrase


Publishing Steps

Step 1: Add distributed management section in your POM.

Add deploy plugin

Add distribution Management Section in your POM

Step 2: Add ossrh server detail into your settings.xml under M2_REPO home.

Id element of servers/server in settings.xml should be identical to id element of snapshotRepository and repository in your POM file.

Step 3:  Add SCM section in your POM

Step 4:  Add maven release plugin

Add GPG passphrase as profile in maven settings.xml, passphrase you have generated while generating the key

Add nexus staging maven plugin

Step 5 : Add source and javadoc plugin

Step 6:  Configure to Sign artificats while releasing

Configure to sign artifacts while releasing

Step 7: Publish GPG key pair


Distribute your key to GPG servers

gpg –keyserver [KEY_SERVER] –send-key [KEY_ID]

KEY_ID in the above case is 5694AA563793429557F1727835B3BD2A223A

Some of the key servers


Step 8: Do the release

mvn clean

mvn release:prepare

mvn release:perform

Step 9: push the tag and code to your remote repo

git push –tags

git push origin master

Step 10: Verify the sonatype repository


Step 11: Update the Sonatype Jira Ticket


Refer this example POM file for more detail

If something goes wrong

Step 1: Undo the release

git reset –hard HEAD~1(You may have to do it second time, depending upon when the error happened)

git reset –hard HEAD~1

Step 2: Delete the tag

git tag -d tagName

git push origin :refs/tags/tagName