JCBC-403: Harden reconfigures on view-based workloads.

This changeset makes sure that even on view-based workloads, lost
streaming connections are detected properly, leading to faster
working states again. In particular, it contains:

 - Signaling an outdated config also on failing http requests
 - Signaling an outdated config on bulkget workloads (by identifying
   inactive nodes)
 - Making sure the proper resubscriber is called with the bucket
   config when the monitor is disconnected.

Change-Id: Ib64faa78a983347d38479a1ab1c3ac9c181ae7ed
Reviewed-on: http://review.couchbase.org/32727
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Updating Spymemcached to 2.10.5

Removing the shutdown method because it is now part of the
inherited spymemcached connection.

Change-Id: Icf881d3de30f11655920091600badba3987e615d
Reviewed-on: http://review.couchbase.org/33285
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Brett Lawson <brett19@gmail.com>
configurable cluster.adminname, cluster.password

provide option to set cluster.adminname and cluster.password in the
build.xml test related properties section.

Change-Id: I46c2e595ed16d477bbd09062cf554c7df2915928
Reviewed-on: http://review.couchbase.org/33137
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-400 : New feature test for credential encryption CRAM-MD5 or PLAIN

Change-Id: I003f5987f56392bd50b871e7a1eb4182008ccc2b
Reviewed-on: http://review.couchbase.org/32355
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Deepti Dawar <deepti.dawar@globallogic.com>
JCBC-337: Update Config from NMVB-Responses.

This changeset takes an incoming "Not My VBucket" response from the server,
does some conversion logic and then passes it on to the ConfigurationProvider.

The config then gets parsed and stored as any other configuration coming
from a streaming response. A test case is added to veriy that behaviour.

Change-Id: I83a838ca0c086426779c092001329b00d11a19e7
Reviewed-on: http://review.couchbase.org/32425
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Suppress unchecked warnings on completion listeners.

Change-Id: Icf7af9df6b7a1fa3df6892ec0a3b3e4175f86d33
Reviewed-on: http://review.couchbase.org/30375
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-337: Implement a Combined Configuration Provider (Binary + HTTP)

This changeset provides a combined http and binary configuration provider. It is
designed to handle bootstrap and monitoring completely autonomously, further
decoupling it from the rest of the codebase.

Change-Id: I13b5029b98c9327cac6927ea35efe529edbb2f84
Reviewed-on: http://review.couchbase.org/32589
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Correcting mailmap for shortlog

Change-Id: I83c239dc4a7ced77059261ae7c689d0ae6bd54cd
Reviewed-on: http://review.couchbase.org/30682
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-240 Add total number of rows in ViewResponse

Change-Id: I82bcb65e48e3d6fde8d5361ee242f89960d38a6f
Reviewed-on: http://review.couchbase.org/25027
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Rename config types for clarity.

This changeset renames the DefaultConfig in CouchbaseConfig and
the CacheConfig into MemcacheConfig to more accurately describe
the type of buckets they are referring to.

Change-Id: Icfa43b63595a362d14c1b0938094fc1d4fcc56b3
Reviewed-on: http://review.couchbase.org/30373
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Use CouchbaseConfig instead of the incorrectly used DefaultConfig.

Change-Id: I2081ef6cf37b83c8a3cb9c7237b01ccafdcf58eb
Reviewed-on: http://review.couchbase.org/33788
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-418: Fix potential deadlock when reconfiguring.

This changeset fixes a potential deadlock which can happen during
reconfiguration and a failing node. When a 500 error response comes
back from the server, the httpcore IO pool handles the retry and
passes it back to our logic, where it grabs a new node to ask. This
node list is synchronized.

In parallel, when a reconfiguration happens, we synchronize on this
list and mark the appropriate node in the pool for shutdown. We
arrive in a deadlock situation because in our code the node list
is synchronized (waiting/holding) and in the httpcore code there
is a lock (waiting/holding) on the internal node to shutdown, but
it is still hold by the retry process.

This changeset moves the actual shutdown out of the synchronized
block, making sure that parallel requests can progress. The node
has been removed out of the list already, so it will not be
tried again for a regular view request (and we can shut down the
open connections behind the scenes).

Change-Id: I0f65d440ce593d0a795ee068e5d84348b9207b5b
Reviewed-on: http://review.couchbase.org/33827
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Enable SNAPSHOT uploading through ant target.

This changeset adds an additional ant target which deploys snapshot
releases directly into the sonatype snapshot repository.

See https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide#SonatypeOSSMavenRepositoryUsageGuide-7c.DeploySnapshotsandStageReleaseswithAnt
for more details on how to setup local authentication.

Change-Id: I3dc26b70c3547e42c0181486bc4e189b5e30ace9
Reviewed-on: http://review.couchbase.org/33881
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Upgrade Spymemcached to 2.10.6

Change-Id: I48d1f2857f9d4b3e394e994f8a9344ace029a278
Reviewed-on: http://review.couchbase.org/33907
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-417: Expose (async)getsFromReplica.

This changeset exposes the same replica read functionality as before,
but this time also exposes its underlying CASValue. The signature is
a mix between a replica get and a gets operation.

Change-Id: Id094092280115e66af6962eb8898a6e4b5f27f78
Reviewed-on: http://review.couchbase.org/33884
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Harden "bucket state"-dependent test cases.

This changeset makes sure that various test cases which depend
on bucket state (that is mostly warmup happening) are more
resilient to false-negatives. This is mostly achieved through
larger allowed timeouts, which allows slower disks also to
catch up between the unit tests.

It increases the timeout for the http cluster
operations in the test from 2.5 seconds (operationTimeout) to
the more realistic HttpTimeout (75 seconds).

Change-Id: I4d884c74802ad9906b3a44e91ff9b45f1ca6b650
Reviewed-on: http://review.couchbase.org/32306
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-421: Rewriting the Query internals for better performance.

This changeset is a complete rewrite of the Query object internals while
keeping the external API completely identical. Under the covers, it now
uses a String array instead of a HashMap to provide faster looping and
better cache friendliness.

Also, values are now encoded and quoted (if needed at all) during the set time
and not when the query string is created. This gives even better performance
when most of the Query objects are cached and just fields changed on the fly.

It also uses a custom compiled regex to identify JSON objects and does not rely
on the slower spymemcached "isJSONObject" anymore.

In JMH benchmark tests, performance was 100% better or more compared to the
old implementation. The performance difference is even higher when more params
are set on the Query object.

Change-Id: I73e9157093d5f0ea82b72d424548d1bc34afd5b5
Reviewed-on: http://review.couchbase.org/33930
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
JCBC-426: Add support for manually disabling carrier or http bootstrap.

This changeset adds the possibility to manually disable both carrier and
http bootstrap through system properties.

Carrier: System.setProperty("cbclient.disableCarrierBootstrap", "true");
Http: System.setProperty("cbclient.disableHttpBootstrap", "true");

If such a setting is issued, a INFO level message is logged to make it easier
during debugging and failure analysis. Note that in general, tweaking such
params is not necessary, althogh it might help in certain debugging and
failure conditions.

Change-Id: I654bcecd0a1ffa576b7a5c146dc4580e37a7995e
Reviewed-on: http://review.couchbase.org/34380
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
JCBC-427: Update enclosed HTTP provider with new configs.

This changeset makes sure that the enclosed HTTP configuration
provider also gets new configurations during runtime, so that once
it needs it, it doesnt override a good one with a very old one.

This is particularly important when the HTTP connection gets closed,
because then a "notifyDisconnect" would override a good config with
a old and outdated one, leading to inconsistencies.

Change-Id: Iffce8028c49844eb5a834fcfc1e93e7525128536
Reviewed-on: http://review.couchbase.org/34378
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Upgrade spymemcached to 2.11.0

Motivation
----------
Spymemcached 2.11.0 contains many changes that help with more stability
during authentication, reconneaction, and other scenarios. Also, more
methods are exposed for async mutating and typesafe status codes.

Modifications
-------------
Upgrade the dependency and adapt the test cases to fit with the new interface.

Result
------
Upgraded dependency.

Change-Id: I5543c028a2ee7c9bee0035d04f3fb576ee96bcf8
Reviewed-on: http://review.couchbase.org/35264
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>