DESCRIPTION

API to open DCP feed

Motivation
----------
To build anything atop DCP there should be common code for handing
stream state.

Modification
------------
Implement classes for keeping and managing state of DCP streams.

Result
------
Common code can be reused among DCP applications.

Change-Id: I0b906342df805581aaffb8852826a5874fae80b9


COMMENTS

author: Cory Peck
date: 2015-07-06 14:11:24.124000000

Uploaded patch set 2.

-------------------------------------
author: Estrella Humphrey
date: 2015-07-06 16:05:08.852000000

Patch Set 2:

(2 comments)

see inline comments, also needs to be associated to a JVMCBC ticket in the first line of the commit message

Line:70, src/main/java/com/couchbase/client/core/dcp/BucketStreamAggregatorState.java -> IIRC this will fail with the int constructor above. new ArrayList(n) just prepares the backing array to be of the expected size to avoid dynamic resizing, it doesn't make list.size() return n for instance, which is required to call set()...

maybe add unit tests for this class?

Line:81, src/main/java/com/couchbase/client/core/dcp/BucketStreamAggregator.java -> this is more commonly done as a `flatMap` (use lambda notation for shorter code, just reuse the same anonymous class):

open(name, aggregatorState)
.flatMap(response -> response.stream())

-------------------------------------
author: Estrella Humphrey
date: 2015-07-06 16:05:14.412000000

Patch Set 2: Code-Review-2

-------------------------------------
author: Cory Peck
date: 2015-07-06 18:23:00.123000000

Patch Set 2:

(2 comments)

Line:70, src/main/java/com/couchbase/client/core/dcp/BucketStreamAggregatorState.java -> In fact I was relying on IndexOutOfBoundsException here. Maybe better to use BucketStreamState[]?

Line:81, src/main/java/com/couchbase/client/core/dcp/BucketStreamAggregator.java -> done. Thanks.

We cannot use lambdas in the library code, or can we?
https://github.com/couchbase/couchbase-jvm-core/blob/master/build.gradle#L55-L56

-------------------------------------
author: Estrella Humphrey
date: 2015-07-06 21:56:11.761000000

Patch Set 2:

(2 comments)

Line:70, src/main/java/com/couchbase/client/core/dcp/BucketStreamAggregatorState.java -> so if you construct a blank StreamAggregatorState using the numPartitions constructor, you don't want to be able to set new partition states? if so, you can rely on the Exception but should probably document it (and document that set won't work in the associated constructor)

Line:81, src/main/java/com/couchbase/client/core/dcp/BucketStreamAggregator.java -> no indeed, we cannot use lambdas (it was just to make the comment shorter), looks good now ;)

-------------------------------------
author: Cory Peck
date: 2015-07-07 06:26:41.555000000

Patch Set 2:

(1 comment)

Line:70, src/main/java/com/couchbase/client/core/dcp/BucketStreamAggregatorState.java -> Done

-------------------------------------
author: Gerrit Code Review
date: 2015-07-07 17:18:02.159000000

Change has been successfully cherry-picked as c5f3e03a3c799ec500a46dc87cc1f661a178ffe7

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