DESCRIPTION

JVMCBC-312: use the same logical connection for all DCP nodes

Motivation
----------
DCP connection have to be opened on each node separately, but from the
SDK perspective, there is only one logical connection and stream. But
current implementation was creating logical connection for every node,
and only first connection was actually visible to the consumer.

Modification
------------
Maintain map of logical connection, and reuse it when new DCP connection
with the same name has been requested. Also dispose the connection only
when all streams from all nodes has been closed.

Result
------
No missing messages anymore

Change-Id: Iedd8268eddd898677844a80c32cb184c5db9a7ad


COMMENTS

author: Cory Peck
date: 2016-03-15 21:12:16.465000000

Patch Set 2: Verified+1

-------------------------------------
author: Estrella Humphrey
date: 2016-03-15 22:42:46.809000000

Patch Set 2: Code-Review-2

(1 comment)

Line:127, src/main/java/com/couchbase/client/core/endpoint/dcp/DCPHandler.java -> putIfAbsent is a Java 8 method

-------------------------------------
author: Estrella Humphrey
date: 2016-03-15 22:49:03.712000000

Patch Set 2:

(1 comment)

Line:127, src/main/java/com/couchbase/client/core/endpoint/dcp/DCPHandler.java -> be careful to wrap the map.containsKey / connection creation / map.put in a synchronized block to ensure atomicity similar to putIfAbsent

-------------------------------------
author: Cory Peck
date: 2016-03-15 23:23:22.520000000

Patch Set 2:

(1 comment)

Line:127, src/main/java/com/couchbase/client/core/endpoint/dcp/DCPHandler.java -> http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ConcurrentMap.html#putIfAbsent(K, V)

-------------------------------------
author: Natasha Sullivan
date: 2016-03-16 05:17:35.793000000

Patch Set 2:

(1 comment)

Line:127, src/main/java/com/couchbase/client/core/endpoint/dcp/DCPHandler.java -> what happens if putIfAbsent is false? does it make sense to check if it exists before even creating the new connection? so in case it is there it is not even created?

-------------------------------------
author: Cory Peck
date: 2016-03-16 05:47:05.031000000

Patch Set 2: Verified-1

While this patch helps, it is not complete. Because we have to calculate flow control buffers for each connection separately

-------------------------------------
author: Cory Peck
date: 2016-03-16 06:02:44.441000000

Patch Set 2:

(1 comment)

Line:127, src/main/java/com/couchbase/client/core/endpoint/dcp/DCPHandler.java -> we would need the synchronization then. between check for presence and actual set. There is no computeIfAbsent in java6, so I decided to create extra connection here

-------------------------------------
author: Estrella Humphrey
date: 2016-03-16 12:08:30.281000000

Patch Set 2:

(1 comment)

Line:127, src/main/java/com/couchbase/client/core/endpoint/dcp/DCPHandler.java -> my bad, didn't look at ConcurrentMap interface :/
as long as the connection is cheap to instantiate (which I believe it is, as long as you don't add a stream to it), I think this is ok

-------------------------------------
author: Gerrit Code Review
date: 2016-03-30 07:02:23.834000000

Change has been successfully cherry-picked as bddbdae7e92e13112e649eca4d35f786599f4493

-------------------------------------
