SPY-135: Expose asyncCAS with Expiration and default transcoder.

Change-Id: I99ecf0b293a9d52871b81e9166f07a35f90c712a
Reviewed-on: http://review.couchbase.org/29346
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-138: Allow the ExecutorService to be overridden.

Change-Id: I6f9c577f734c33f2d6004031253dd561b6302b4c
Reviewed-on: http://review.couchbase.org/29373
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
SPY-137: Properly shutdown executorService on shutdown().

Change-Id: I23bf0a30cc96c5721d6ed0d5c16bdfc2113c0fe4
Reviewed-on: http://review.couchbase.org/29372
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-140: Use LinkedBlockingQueue for listener task queuing.

Change-Id: I3e3db7861a6e6e6c24c61c40ea02b19c8bc57fab
Reviewed-on: http://review.couchbase.org/29548
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-141: Do not assume positive CAS.

This changeset makes sure that when loading the CAS value, there
is no assumption of the actual value done on the client side.
Especially, -1 is a valid CAS and can cause issues when running
with -ea in production (since the callback is executed on the
IO thread, it can die for no reason).

Change-Id: Ic944bca9c7e005fb793edc0ddb3a51674f2d2be0
Reviewed-on: http://review.couchbase.org/29584
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-106: Allow GetAndTouchOperation to be cloned.

This fixes an issue where GAT called during rebalance, causing it
to be cloned potentially, fails the IO threads since its not
supported in there properly.

Change-Id: I3ff86456c5f2f28e206612890c08834fc96935f1
Reviewed-on: http://review.couchbase.org/29585
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-136: Do not timeout when waiting on the sasl mechs.

Since we also dont timeout on the return of the auth op, keeping
the process consistent. This avoids the situation where the server
is potentially rebooting and the timeout occurs. In combination with
code depending on the sasl list, exceptions can occur and the auth
thread dies.

Change-Id: I270e91e0794ea7de10cd26a9dafc85e35f87095d
Reviewed-on: http://review.couchbase.org/29657
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-144: Avoid growing callstack on get* clones.

This changeset makes sure that if an operation gets cloned over
and over again (which is not the norm, but can happen in certain
failure scenarios), it will not lead to a stack overflow.

Special thanks to Kirill Safonov for pointing out the right fix.

Change-Id: I6846fe9b23d43d9f2e257a5206a511f941aed8ff
Reviewed-on: http://review.couchbase.org/30415
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Allow OperationImpl to be used elswhere.

Change-Id: I89818f2a94e8e746c562b5a115602f8d3ccfb8d2
Reviewed-on: http://review.couchbase.org/30447
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
This changeset refactors the MemcachedConnection class.

It also breaks out certain large blocks into their own methods
to make it better readable and easier for the JIT to inline
the code.

Change-Id: I3369606afeef00b50740e54c01a78e89682cade1
Reviewed-on: http://review.couchbase.org/30416
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-145: Make OperationImpl inline properly.

Change-Id: Ia03701670d9b3bb82d7e8c4798dd5cb99c9e25c7
Reviewed-on: http://review.couchbase.org/30418
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-146: Use correct length of key in observe.

This changeset makes sure that the correct length of the key is used in the
protocol. Since UTF-8 chars like the pound sign (currency) are represented
in two bytes but are one character in a string, the length of the key needs
to be determined after it is converted into a byte array.

Change-Id: I48b68127f384e3bcb963a5df1cddd5b5c2d5ca7a
Reviewed-on: http://review.couchbase.org/30701
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-145: Make MemcachedConnection inline properly.

Change-Id: I1be0a3ea410e9bed0a155ac821d41bf64125beac
Reviewed-on: http://review.couchbase.org/30417
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Syncing MemcachedClientIF with MemcachedClient.

This changeset makes sure all implemented methods are available
in the interface. Also, @Override annotations are added for
clarity.

Change-Id: Iedb899ed9d70a5d76e7d3891524336a21edf34b8
Reviewed-on: http://review.couchbase.org/31669
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Cleanup of MemcachedClient.

This changeset adds more @Override annotations and does some minor
cleanup.

Change-Id: I1a9140635781bf622c6aeba4156f5e1cb7f5b468
Reviewed-on: http://review.couchbase.org/31670
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-149: Notify Listeners after Complete.

This changeset honors the fact that setting the status and actually
completing the latch can happen at two different points in time.
Without this change, effects can be observed that a listener is called
but the latch has not been counted down yet, leading to weird effects.

Also see https://github.com/mathieuancelin/play2-couchbase/issues/33
for a dependent issue.

Change-Id: I99686c212d8610299f78078b28d31b7891da8d1c
Reviewed-on: http://review.couchbase.org/31714
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Add missing import.

Change-Id: I261bcf045264b041bdea8ec0df0fab3c711cd64f
Reviewed-on: http://review.couchbase.org/31732
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-151: Interrupt pending AuthThreads during shutdown.

This changeset fixes hanging auth threads while shutting down the
connection.

Change-Id: I386fea0da2d06b655c7e3cd0d843761d59ee7e28
Reviewed-on: http://review.couchbase.org/31828
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-150: Check connection status before waiting on the latch.

Change-Id: Ic9de6711a32575c81a499b360923f21d8cfd13ff
Reviewed-on: http://review.couchbase.org/32337
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>