JCBC-366: Properly override ExecutorService and Metrics.

Change-Id: Ia1987d3dc9ca8cf8c73435ba505ada1fd83f265e
Reviewed-on: http://review.couchbase.org/29374
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Mock should use a empty list instead of null for the servers.

Change-Id: I103606e82f609231846998b59719fa170bd4624a
Reviewed-on: http://review.couchbase.org/29466
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Make sure random tests have better chance of succeeding.

Change-Id: Iacc07dfd949ffaaacb64e68349580952c6c51df2
Reviewed-on: http://review.couchbase.org/29465
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Make CouchbaseClientTests more resilient.

Change-Id: I7476a1dc625000669d40f4f707e5c9003508fe11
Reviewed-on: http://review.couchbase.org/29467
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Updating spymemcached to 2.10.1

Change-Id: Ide6d9c0191fc91a492b64022e2f12afb6f76083c
Reviewed-on: http://review.couchbase.org/29468
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-368: Avoid potential netty deadlock on failing streaming conn.

Change-Id: Ia3246b960e2e05515c0d54214b1732cbaf570c8b
Reviewed-on: http://review.couchbase.org/29539
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-371: Removing redundant reference of bucket/vBucket.

This changeset removes the redundant this.bucket reference in
the BucketMonitor, reducing memory a bit. Also, the observe
notifiers are now called directly and the needed bucket
config is referenced from the parent ConfigurationProvider.

Change-Id: I0b044388d570b8e321c6285488d9f07b6c0f163d
Reviewed-on: http://review.couchbase.org/29714
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Removing redundant declarations and making more fields final.

Change-Id: I9f2dcb6e37544c237d11e6f4050fe1120344aecb
Reviewed-on: http://review.couchbase.org/29537
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Convert local-used only fields to local.

Change-Id: I5711371b06a255b05c037cbaaa9ea1e46b6bbb68
Reviewed-on: http://review.couchbase.org/29538
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Make property tests more solid by clearing them properly.

Change-Id: I63d73e441551b5944206c628dbfd47505ac070cf
Reviewed-on: http://review.couchbase.org/29735
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Refactor the ConfigurationParserJSON for clarity.

This changeset doesnt change any functionality but only refactors
and properly comments the ConfigurationParserJSON.

Change-Id: Ic534336f5421e9c0e928520665bde454cee4f653
Reviewed-on: http://review.couchbase.org/29849
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Refactor ConfigFactory and optimize VBucket memory heap size.

This changeset refactors the ConfigFactory but not changing how it
works internally. In addition, VBucket objects are moved from int
to short and only allocate as much memory as needed.

Change-Id: Ifa8d2eff9a9cd7fe44fabb83ce8ec4ab1192f32b
Reviewed-on: http://review.couchbase.org/29850
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-373: The replica get future to complete is not thread safe.

This leads to false positives while the future could be completed
but never is because of visibility issues.

Change-Id: I28a74e3f44d28ab8e4f3780ddb158527484fd59d
Reviewed-on: http://review.couchbase.org/29823
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-374: Also trigger completion on active node replica doc.

This changeset makes sure that when a replica get (that is
fanned out to all replica nodes + the active node) from the
active node returns first, the replica get future is also
completed.

This fixes the situation where 1 replica is defined, this node
is failed over and no data is returned (while of course the
master node is still reachable and returns the result). Before
the data was returned properly but the latch on the replica get
future was never counted down, and as a result never indicating
success.

Change-Id: Ib6b513819ed9a686fdc80956ebb58edf9cfc6a43
Reviewed-on: http://review.couchbase.org/29848
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-369: Fix observePoll delete logic.

This changeset refactors the observePoll method, making it faster
and also correcting the delete logic which is not correct for
certain scenarios (now it is correct with respect to the non-delete
methods).

Also, it optimizes the observe() method to only add those nodes
to the bcast list that are actually needed to fulfill the
constraint.

Change-Id: Ib101af5f1212123fcb103d335d40fb2bc79f8964
Reviewed-on: http://review.couchbase.org/29545
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Moving CouchbaseClient docblocks to the IF and adding @Override.

Since the CouchbaseClient grows out of bounds with the recent
additions, moving the docblocks makes it shorter. Also, this is
where they belong to anyway. Actual refactoring of the code
will follow in separate commits.

Change-Id: I8d9f3a6c64a41b58c9a25df69fc17864acabd6ff
Reviewed-on: http://review.couchbase.org/29541
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Further hardening of ReplicaRead.

This changeset hardens the implementation of ReplicaRead further
by applying the following changes:

 - Make sure the completedFuture is not overriden by later calls.
 - The "cancel" iterations on the monitoredFutures is synched as
   advised by Collections#synchronizedList.
 - Make sure that replica reads are only "fanned out" to nodes that
   are actually configured as a replica at the moment. For that
   reason, a new method is added to the VBucketNodeLocator to return
   a list of servable nodes for this specific key.
 - Along the lines of the previous point, make sure that an additional
   request to the proper active master is only sent when it is actually
   reachable (not -1 in the vbucket map).

Change-Id: I6568e1c1fd5d779acf3fd1e52ed2d88b46a1a8b7
Reviewed-on: http://review.couchbase.org/30009
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-375: Correctly reorder resubscriber to prevent race condition.

This changeset makes sure that the old reconfigurable is taken out
of the old provider before it gets shut down to avoid a situation
where it is null, leading to failures on subsequent reconnect
attempts.

Change-Id: I733ae5ecc0965a95299dbe5a8b9ca4f25742be31
Reviewed-on: http://review.couchbase.org/30010
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reuse VBucket objects from last Configs to lower GC pressure.

This changeset allows to (optionally) pass in a existing Config
and if VBucket objects are the same, those get reused in the new
Config and not creating new ones all the time. This lowers GC
pressure, especially during rebalance phases when 10 or more
CouchbaseClient objects are used.

Tests have been added, please note that the JSON configs will
be separated out into resource files in a different commit.

Change-Id: If979b5a52ffbcf7e87a4c59bb14f781bf48deaee
Reviewed-on: http://review.couchbase.org/29887
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Adapting test case for the latest observe changes.

Change-Id: I0dab4692c29411d96ddea5297d8fd2959640626b
Reviewed-on: http://review.couchbase.org/30045
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>