Skip to content

Feed aggregator

To-Do Lists with Eclipse Tasks View

Eclipse has a cool feature which might not be known to everyone: the "To-Do" (or Tasks) List which keeps track of what I have to do:

Tasks View

Categories: Communities

Couchbase XDCR using Docker Swarm, Machine and Compose

Miles to go ... - Arun Gupta - Sun, 05/29/2016 - 07:51

Cross Datacenter Replication (XDCR) in Couchbase provides an easy way to replicate data from one cluster to another. The clusters are typically set in geographically diverse data centers. This enables for disaster recovery or to bring data closer to users for faster data access.

This blog will show:

  • Setup two data centers using Docker Swarm
  • Run Couchbase containers on each node of Docker Swarm
  • Setup a Couchbase cluster on each Docker Swarm cluster
  • Configure one-way XDCR between two Couchbase clusters

For the purpose of this blog, the two data centers will be setup on a local machine using Docker Machine.


Complete code used in this blog is available at:

Create Consul Discovery Service

Each node in Docker Swarm needs to be registered with a discovery service. This blog will use Consul for that purpose. And even Consul will be running on a Docker Machine.

Typically, you’ll run a cluster of Consul but for simplicity a single instance is started in our case.

Create a Docker Machine and start Consul using this script:

# Docker Machine for Consul
docker-machine \
   create \
   -d virtualbox \

# Start Consul
docker $(docker-machine config consul-machine) run -d --restart=always \
         -p "8500:8500" \
         -h "consul" \
         progrium/consul -server -bootstrap

Create Docker Swarm cluster

Docker Swarm allows multiple Docker hosts to be viewed as a single unit. This allows your multi-container applications to easily run on multiple hosts. Docker Swarm serves the same Remote API as served by a single host. This allows your existing tools to target a single host or a cluster of hosts.

Both the Docker Swarm clusters will be registered with a single discovery service. This is achieved by using the following value for --swarm-discovery:

consul://$(docker-machine ip consul-machine):8500/v1/kv/<key>

Create a Docker Swarm cluster using Docker Machine using this script:

# Docker Swarm master
docker-machine \
  create \
  -d virtualbox \
  --swarm \
  --swarm-master \
  --swarm-discovery="consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster$1" \
  --engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster$1" \
  --engine-opt="cluster-advertise=eth1:2376" \

# Docker Swarm node-01
docker-machine \
  create \
  -d virtualbox \
  --swarm \
  --swarm-discovery="consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster$1" \
  --engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster$1" \
  --engine-opt="cluster-advertise=eth1:2376" \

# Docker Swarm node-02
docker-machine \
  create \
  -d virtualbox \
  --swarm \
  --swarm-discovery="consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster$1" \
  --engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster$1" \
  --engine-opt="cluster-advertise=eth1:2376" \

# Configure to use Docker Swarm cluster
eval "$(docker-machine env --swarm swarm-master-$1)"

The script needs to be invoked as:

./ A
./ B

This will create two Docker Swarm clusters with one “master” and two “worker” as shown below:

NAME              ACTIVE   DRIVER       STATE     URL                         SWARM                     DOCKER    ERRORS
consul-machine    -        virtualbox   Running   tcp://                             v1.11.1   
default           *        virtualbox   Running   tcp://                             v1.11.1   
swarm-master-A    -        virtualbox   Running   tcp://   swarm-master-A (master)   v1.11.1   
swarm-master-B    -        virtualbox   Running   tcp://   swarm-master-B (master)   v1.11.1   
swarm-node-A-01   -        virtualbox   Running   tcp://   swarm-master-A            v1.11.1   
swarm-node-A-02   -        virtualbox   Running   tcp://   swarm-master-A            v1.11.1   
swarm-node-B-01   -        virtualbox   Running   tcp://   swarm-master-B            v1.11.1   
swarm-node-B-02   -        virtualbox   Running   tcp://   swarm-master-B            v1.11.1

Consul is running on Docker Machine with IP address And so Consul UI is accessible at


It shows two Docker Swarm clusters that have been registered.

Exact list of nodes for each cluster can also be seen. Nodes in clusterA are shown:


Nodes in clusterB are shown:


Run Couchbase containers

Run Couchbase container on each node of Docker Swarm cluster using this Compose file.

version: "2"
    image: arungupta/couchbase
    network_mode: "host"
      - 8091:8091
      - 8092:8092
      - 8093:8093
      - 11210:11210

Configure Docker CLI for the first cluster and run 3 containers:

eval "$(docker-machine env --swarm swarm-master-A)"
docker-compose scale db=3

Check the running containers:

> docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS               NAMES
3ec0f15aaee0        arungupta/couchbase   "/ /opt/"   3 hours ago         Up 3 hours                              swarm-master-A/couchbasexdcrdocker_db_3
07af2ac53539        arungupta/couchbase   "/ /opt/"   3 hours ago         Up 3 hours                              swarm-node-A-02/couchbasexdcrdocker_db_2
c94878f543fd        arungupta/couchbase   "/ /opt/"   3 hours ago         Up 3 hours                              swarm-node-A-01/couchbasexdcrdocker_db_1

Configure Docker CLI for the second cluster and run 3 containers:

eval "$(docker-machine env --swarm swarm-master-B)"
docker-compose scale db=3

Check the running containers:

> eval "$(docker-machine env --swarm swarm-master-B)"
> docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS               NAMES
3e3a45480939        arungupta/couchbase   "/ /opt/"   3 hours ago         Up 3 hours                              swarm-master-B/couchbasexdcrdocker_db_3
1f31f23e337d        arungupta/couchbase   "/ /opt/"   3 hours ago         Up 3 hours                              swarm-node-B-01/couchbasexdcrdocker_db_1
1feab04c494c        arungupta/couchbase   "/ /opt/"   3 hours ago         Up 3 hours                              swarm-node-B-02/couchbasexdcrdocker_db_2

Create/Rebalance Couchbase cluster

Scaling and Rebalancing Couchbase Cluster using CLI explains how to create a cluster of Couchbase nodes and rebalance an existing cluster using Couchbase CLI.

Create Couchbase cluster on each Swarm cluster using this script.

export COUCHBASE_CLI=/Users/arungupta/tools/
for node in 01 02
        server-add \
        --cluster=$(docker-machine ip swarm-master-$1):8091 \
        --user Administrator \
        --password password \
        --server-add=$(docker-machine ip swarm-node-$1-$node) \
        --server-add-username=Administrator \

	setting-cluster \
	--cluster=$(docker-machine ip swarm-master-$1):8091 \
	--user Administrator \
	--password password \

The script needs to be invoked as:

./ A

And now rebalance this cluster using this script:

export COUCHBASE_CLI=/Users/arungupta/tools/
rebalance \
--cluster=$(docker-machine ip swarm-master-$1):8091 \
--user Administrator \
--password password \
--server-add-username=Administrator \

This script is invoked as:

./ A

Couchbase Web Console for any node in the cluster will show the output:


Invoke this script to create the second Couchbase cluster as:

./ B

Rebalance this cluster as:

./ B

Couchbase Web Console for any node in the second cluster will show the output:


Setup XDCR

Cross datacenter replication can be setup to be uni-directional, bi-directional or multi-directional. Uni-directional allows data to replicated from source cluster to destination cluster, bi-directional allows replication both ways, multi-directional allows to configure in any direction.

We’ll create a simple uni-directional replication using this script:

export COUCHBASE_CLI=/Users/arungupta/tools/
	xdcr-setup \
	--cluster=$(docker-machine ip swarm-master-$1):8091 \
	--user Administrator \
	--password password \
	--create \
	--xdcr-cluster-name=cluster$1 \
	--xdcr-hostname=$(docker-machine ip swarm-master-$2):8091 \
	--xdcr-username=Administrator \
	--xdcr-password=password \

	xdcr-replicate \
	--cluster $(docker-machine ip swarm-master-$1):8091 \
	--xdcr-cluster-name=cluster$1 \
	--user Administrator \
	--password password \
	--create \
	--xdcr-from-bucket=travel-sample \

This script is invoked as:

./ A B

A bi-directional replication can be easily created by executing the commands again but reversing the source and destination cluster.

Couchbase Web Console for the source cluster will show:


Couchbase Web Console for the destination cluster will show: swarm-xdcr-couchbase-clusterB-xdcr


This blog shows how you can simplify your complex deployments using Docker Machine, Docker Swarm, and Docker Compose.


The post Couchbase XDCR using Docker Swarm, Machine and Compose appeared first on Miles to go 3.0 ....

Related posts:

  1. Couchbase Cluster on Docker Swarm using Docker Compose and Docker Machine
  2. Docker Machine, Swarm and Compose for multi-container and multi-host applications with Couchbase and WildFly
  3. Docker Swarm Cluster using Consul

Categories: Companies

Builder in C#

C# has in many ways inherited its relationship with Builder from Java, where it was usually called by the more degenerative term “Factory” or “Factory pattern”. (Technically, what Java calls a “Factory pattern” is typically one of Builder, Factory Method, or Abstract Factory, depending on what precisely looks to be varied and/or encapsulated.) C#, however, never fell quite as deeply in love with the “Factory pattern” as the Java development crowd did, and as such it wasn’t as widely used.

We start with the target Product:

Categories: Communities

Integration Cloud Service (ICS): Execution Agent proxy issue: NumberFormatException

AMIS Technology blog - Sat, 05/28/2016 - 15:33

Integration Cloud Service (ICS) offers an Execution Agent which you can download and install on-premises. This provides a local ICS instance. The Execution Agent is useful in several situations. When you have an ICS trial, it is valid only for a period of 30 days. After initial installation (which does require an ICS subscription), you can use the Execution Agent indefinitely. Secondly, you have full control over the Execution Agent since it is a local installation and not managed by Oracle such as the Oracle Cloud instances. This means you can for example log all requests and replies, install and test a custom Cloud Adapter or browse the Service Bus log files and deployments in case something goes wrong. Currently this is not possible in the Oracle Public Cloud without creating SR’s. This blog post is based on the below version of ICS and might not be valid in future versions.

Integration Cloud Service
You can download the Execution Agent from the Agents page:


The installation requires Oracle Enterprise Linux 6 UC4 or above. Read the documentation here.

Execution Agent proxy error

When the Execution Agent is installed though, you will most likely encounter the following error sooner or later when accessing remote resources:

When accessing remote resources

When you check the log files you can see the following error:

Caused By: java.lang.NumberFormatException: For input string: "''"
at java.lang.NumberFormatException.forInputString(
at java.lang.Integer.parseInt(
at java.lang.Integer.parseInt(

As you can see from this stack trace, the error originates from when the java.lang.Integer.parseInt method is called. Using JD (Java Decompiler) the error can be traced back to the following line of code;

connConfig.setProxyAddress(new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort)));

Thus the error is caused by an empty proxyPort. During the installation of the Execution Agent, I needed to answer several questions:

Enter your ICS subscription URL for authentication:
Enter ICS subscription Username:
Enter ICS subscription Password:
Enter HTTPS Proxy Server Host Name:
Enter HTTPS Proxy Server Port Number:

I just pressed enter when asked for proxy settings.

How to solve it

There are 2 easy ways to solve this. First disable the proxy and second start using a proxy. After the installation you can change the proxy settings by editing:


This file contains the proxy settings:

EXTRA_JAVA_PROPERTIES="${EXTRA_JAVA_PROPERTIES} -Dhttps.proxyHost= -Dhttps.proxyPort= -Dhttp.proxyHost= -Dhttp.proxyPort="
Fix 1: Disable the proxy

These proxy settings were interpreted as empty strings which of course cannot be parsed to integers. In the NetworkUtil code, you can see in the NetworkUtil class code that if the proxyHost or proxyPort is not null, that the proxy will be used which causes this error. An empty string is of course not null. When I comment the below line in, the proxy settings are null though.

#EXTRA_JAVA_PROPERTIES="${EXTRA_JAVA_PROPERTIES} -Dhttps.proxyHost= -Dhttps.proxyPort= -Dhttp.proxyHost= -Dhttp.proxyPort="

The result of this is that ICS will not use a proxy server anymore.

Fix 2: Install a proxy server

Sometimes it can be difficult to debug ICS. See also my post here. It can help to have an external proxy server which can log all the incoming and outgoing requests. This way you can see exactly what ICS is sending, including all the headers and the exact response. You can use for example Squid or the JDeveloper HTTP analyzer.


Installing a proxy server on Oracle Enterprise Linux is easy: ‘sudo yum install squid’ and you are done. By default this proxy server only accepts connections from localhost and runs on port 3128. So now you can supply localhost as proxy server and port 3128 as proxy port. This way ICS will not complain about missing proxy ports and you can use Squid for some additional logging on requests and replies.


JDeveloper HTTP Analyzer

An alternative (which does require a bit more memory and diskspace) is to use the JDeveloper HTTP analyzer for this. If you are running a VM and JDeveloper is installed outside of the VM, you could encounter errors like

Caused by: Hostname verification failed:, hostname=vmserver.
at weblogic.socket.JSSEFilterImpl.unwrap(
at weblogic.socket.JSSEFilterImpl.unwrapAndHandleResults(
at weblogic.socket.JSSEFilterImpl.doHandshake(
at weblogic.socket.JSSEFilterImpl.doHandshake(
at weblogic.socket.JSSESocket.startHandshake(

When you have JDeveloper and the HTTP Analyzer installed inside the same VM as the Execution Agent, you will not encounter this issue.


The post Integration Cloud Service (ICS): Execution Agent proxy issue: NumberFormatException appeared first on AMIS Oracle and Java Blog.

Categories: Companies

MuleSoft: Method Entry Point Resolver

The Anypoint platform provides various components and built-in functions for integration purposes. Most of our needs in a project can be fulfilled easily, especially when we use the Enterprise Edition. Not only does this include the availability of ready-to-use connectors, but also a quick response from MuleSoft support.

Let's say we have to develop integration project using Community Edition. Obviously, with limited support from them. Although we can rely on the community forum with tons of ideas and discussions, sometimes we face a common impediment from our internal developers. In particular, they resist adopting the Anypoint platform and still engage with their preferred programming language. For example, they do not want to use MEL or expression component, but prefer to write a Java class.

Categories: Communities

Builder in Java

Java has long had a relationship with Builder, usually calling it by the more degenerative term “Factory” or “Factory pattern.” (Technically, what Java calls a “Factory pattern” is typically one of Builder, Factory Method, or Abstract Factory, depending on what precisely looks to be varied and/or encapsulated.)

We start with the target Product:

Categories: Communities

Java EE 8 Security API 1.0-m01 Is Available For Testing

Adam Bien's Weblog - Sat, 05/28/2016 - 07:18

Version 1.0-m01 of soteria, the Java EE 8 Security (JSR 375) (see all Java EE 8 specs), is available for testing on recent Java EE 7 servers.

Soteria comes with a set of useful sample use cases, from DB, over LDAP, to custom identity stores. Soteria is running on WildFly/JBoss, TomEE and Payara (see compatibility).

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home:

Real World Java EE Workshops [Airport Munich]>
Categories: Blogs

7 Options for Capturing Thread Dumps

Thread dumps are vital artifacts to diagnose CPU spikes, deadlocks, memory problems, unresponsive applications, poor response times, and other system problems. There are great online thread dump analysis tools such as that can analyze and spot problems. But to those tools you need provide proper thread dumps as input. Thus in this article, I have documented 7 different options to capture thread dumps.

1. jstack

‘jstack’ is an effective command line tool to capture thread dumps. The jstack tool is shipped in JDK_HOME\bin folder. Here is the command that you need to issue to capture thread dump:

Categories: Communities

Java EE 8, Current Status: Case Study for Completed Work Since Late 2015

For anyone who pays close attention to Java EE, it has become clear in the past six months that there has been a decline of activity...especially in those JSRs for which Oracle maintains the lead.  What's the deal?  There has been a lot of conversation in the Java EE community in this regard lately, and I think it is important that the developer community be given a fair timeline of what we can expect for the future of Java EE.  The uncertainty is becoming long in the tooth, and the community is becoming more concerned with the future of Java SE and Java EE as time goes on.

Let me give you a bit of background.  I'm an expert group member on a couple of JSRs targeted for Java EE 8, those being JSR 372 (JavaServer Faces 2.3), and JSR 378 (Portlet 3.0 Bridge for JavaServer Faces 2.2).  At the beginning of 2016, I had noticed that since October 2015 the number of emails on the Expert Group list for JSR 372 had really slowed down.   In fact, in the final quarter of 2015, the activity on JSR 372 had slowed down to a near halt, whereas it should be picking up momentum as time moves forward closer to the eventual final release.  In late January, I was contacted by a couple of members of the Java EE community, indicating that they also had seen a slowdown of activity and were very concerned.  I was then asked to join a community of concerned Java EE advocates on a Slack community...and when I joined and read the backlog of messages I could clearly see that it looked as though Oracle had stopped activity in just about every area of Java EE, specifically work on all of the JSRs that were Oracle-led.

Categories: Communities

Oracle vs Google: Where are the Oracle Supporters?

The verdict is in once again on the Oracle vs Google lawsuit regarding Google's use of Java in Android, and no sooner was Google declared the winner than Oracle announced their intent to appeal (at least) once more. The reaction to the verdict has been widespread in technology circles as one would expect, although the reaction is fairly one-sided (see thread examples here and here).

In reading some of the reaction on a range of site, I'm not seeing much (any?) sympathy for Oracle's loss, which might seem odd in a case like this. If you think about high-profile copyright/patent cases or questions of ownership in other industries, the public sympathy tends to be with the owner/creator. Remember Ice Ice Baby? (I'm trying to forget). The public was happy to see Vanilla Ice paying Queen royalties for using their song. Human nature in these types of cases would make one inclined to be behind Oracle, but this is a different case.

Categories: Communities

Arrays: Disarray or Datarray?


This is the first in the data structure reviews and likely the simplest: the humble array. The first issue is the term Array; its term differs depending on who uses it but we will get to that a bit later.

Generally, I think of an array like this:

Categories: Communities

Code Smells—Part II

In the last post, Code Smells - Part I, I talked about the bloaters: they are code smells that can be identified as Long Methods, Large Classes, Primitive Obsessions, Long Parameter List and Data Clumps. In this one, I would like to dig into the Object-Orientation Abusers and the Change Preventers.

Object-Orientation Abusers

This type of code smell usually happens when object-oriented principles are incomplete or incorrectly applied.

Categories: Communities

Thoughts on JSRs, TCKs, and Open Source

In the Java EE umbrella every piece of technology is standardized under a JSR (Java Specification Request). The Expert Groups of the JSRs have to deliver the specification, a Reference Implementation, and a TCK (Technology Compatibility Kit). For most of the JSRs, the TCK is licensed as closed-source software and is not available for the public.

That has the implication that any vendor who wants to implement a specific technology has to explicitly apply/ask for/buy the TCK in order to test their implementation and get officially certified. The problem with this situation is clearly that it raises the barrier for potential vendors. Or, in other words, it would be a benefit for vendors to more easily join in the game. Having that said it would then also be more favorable for users of Java EE to have more competition among implementations.

Categories: Communities

Build Configurations in Eclipse

Eclipse-based IDE’s have a powerful feature to make ‘variants’ of the same projects: Build Configurations. Build configurations are a powerful thing in Eclipse: they allow me to make ‘variants’ of a project. The project will share the common things, and I can simply tweak things one way or the other for example to produce a ‘release’ or a ‘debug’ binary of my application without duplicate the project.

Build configurations are managed through either the context menu on the project or with the top menu:

Categories: Communities

Notes on JPA L2 Caching

Quick Facts
  • JPA L2 cache was standardized in JPA 2.0 (Java EE 6)
  • Based on EntityManagerFactory (i.e. its a global cache common across all Persistence Units)
  • A layer which site between the L1 cache (EM) and the database i.e. the database is queried only if the entity is not in the L1 cache and L2 cache
  • This feature is optional (but most of the well known providers support it)
Initial Setup

@Cacheable: this annotation is used to declaratively configure L2 (shared) caching for a JPA entity

Cache Modes

Specified in persistence.xml or during Entity Manager Factory creation (programmatic)

Categories: Communities

Everything You Need to Know About the Brave Web Browser

The new Brave web browser is trying to do something radically different with your boring old browser. Brave burst onto the scene at the start of 2016, positioning itself as the latest battleground in the war between ad producers and ad blockers. Brave is built on the promise of faster load times and better privacy protection by blocking web trackers and targeted ads. If Brave users agree to replace those ads with anonymous ads from the Brave network, the user will be paid in bitcoin. Being paid to surf has been the dream of many web aficionados and Brave promises to make it real.

The Philosophy Behind Brave

Brave is the brainchild of Brendan Eich, one of the co-founders of Mozilla and the creator of the JavaScript language when he worked at Netscape. Eich announced the arrival of Brave by saying, “We are building a new browser and a connected private cloud service with anonymous ads,” Eich said. “I contend that the threat we face is ancient and, at bottom, human. Some call it advertising, others privacy. I view it as the Principal-Agent conflict of interest woven into the fabric of the web.”

Categories: Communities

Modelling Microservice Patterns in Code

Vanilla Java - Thu, 05/26/2016 - 19:52
Service InteractionsThere is a number of simple interactions a service can support. Which pattern is best for your application can depend on what an existing application expects, and what latency requirements you have. Broadly speaking these interactions fall into client-server and peir-to-peir messaging.For peir-to-peir messaging, one approach to take is Lambda Architecture however from supporting GUIs, client - server models can be easier to work with.I feel it is important to design components which could be tested and debugged together, as in a monolith, but can be deployed as multiple right sized services to different threads, JVMs, or machines.

Categories: Blogs

Java Web Weekly, Issue 126

baeldung - Coding and Testing Stuff - Thu, 05/26/2016 - 16:29
I just released the Starter Class of "Learn Spring Security":


At the very beginning of last year, I decided to track my reading habits and share the best stuff here, on Baeldung. Haven’t missed a review since.

Here we go

1. Spring and Java >> How We Migrated Our Backend to Spring Boot in 3 Weeks []

Definitely an interesting writeup of how Stormpath basically migrated their entire codebase to Spring Boot.

>> We Crunched 1 Billion Java Logged Errors – Here’s What Causes 97% of Them []

Some fun numbers and insights, despite the link-baity title.

>> How to persist additional attributes for a relationship with JPA and Hibernate []

Some advanced Hibernate/JPA goodness about more complex relationship information and understanding how to handle these well.

Also worth reading:

Webinars and presentations:

Time to upgrade:

2. Technical >> Hash and Salt Your Users’ Passwords []

When it comes to password storage, this writeup covers the basics, sure – but it does so in a well structured, clear way. Definitely worth a quick read.

Also worth reading:

3. Musings >> Observations and thoughts on the LinkedIn data breach []

Very interesting, in-depth analysis of the LinkedIn data breach.

>> Solve Small Problems []

This is definitely one to read, as it sheds some light into how real progress is usually made – one unassuming brick at a time.

Also worth reading:

4. Comics

And my favorite Dilberts of the week:

>> Don’t turn your back [] >> Just do your job and leave the strategy to management [] >> I’ll use this dummy to demonstrate … [] 5. Pick of the Week >> “We only hire the best” [] Get the early-bird price (20% Off) of my upcoming "Learn Spring Security" Course:


Categories: Blogs

Akka Notes: Finite State Machines Part 2

In the first part of notes on Akka FSM, we saw the basics of Akka FSM and the outline of the Coffee vending machine that we planned to build - the structure of the Actor and a list of messages we pass to the Actor. In this second and final part, we will go ahead and implement each of these States.


As a quick recap, let's look at the structure of the FSM and the messages that can be sent to it.

Categories: Communities