DESCRIPTION

JVMCBC-358: Round Robin Endpoint selection strategy

Motivation:
-----------
Current endpoint selection strategy is either `Random` or based on
`Partition`. It was observed that random selection could lead to a same
endpoint being chosen several times in a row, and with long running
requests (like N1QL queries) this can add up. Thus a round robin
selection is probably a better fit.

Modifications:
--------------
Added a new `SelectionStrategy`, the `RoundRobinSelectionStrategy`.
The strategy maintains an internal volatile int "skip" counter. When
wrapping around due to overflow, the counter is reset to 0.

Made `QueryService` use that strategy for its endpoints.

Results:
--------
Fairer endpoint selection strategy can now be used.

Change-Id: I5048bde97d239f72c3232becccdea7bea46c7313


COMMENTS

author: Estrella Humphrey
date: 2016-08-24 13:26:56.166000000

Uploaded patch set 2.

-------------------------------------
author: Estrella Humphrey
date: 2016-08-24 13:29:54.647000000

Patch Set 2: Verified+1

(1 comment)

added a test that covers the case where the skip counter overflows (would previously cause the offset to be negative)

Line:32, src/main/java/com/couchbase/client/core/service/strategies/RoundRobinSelectionStrategy.java -> made it volatile and made it so when it wraps, it resets to 0 (using Math.max instead of a simple ++ increment).

protected for testing purposes.

-------------------------------------
author: Natasha Sullivan
date: 2016-08-24 13:31:07.439000000

Patch Set 2: Code-Review+2

-------------------------------------
author: Gerrit Code Review
date: 2016-08-24 13:45:07.792000000

Change has been successfully cherry-picked as f76a739978ae9ddec227da89b9b8505fb7bae57d by Estrella Humphrey

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