Add an ActiveStream class

The ActiveStream class will maintain the state for a stream that
is on the producer side of the connection. I wil add a similar
PassiveStream for consumer-side stream state in the future.

Change-Id: If884c335131da9f9138e63a2dda15d28fdc9a3b5
Reviewed-on: http://review.couchbase.org/31459
Reviewed-by: David Liao <david.liao@couchbase.com>
Tested-by: David Liao <david.liao@couchbase.com>
Move towards using C++11 atomics

Start by renamimg all use of Atomics that doesn't "break" by
switching to std::atomic to AtomicValue (when the transition
is done we'll rename everything back).

Change-Id: I3f694856dab498c565806c9ac1ee5baf3bc07b17
Reviewed-on: http://review.couchbase.org/31333
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Check for headerfiles used in C++11

Some people have reported build failures where the compiler
defines __cplusplus >= 201103L, but don't have <atomic>

Change-Id: Iffad592b50e713b1bf211f4d632104806869c82d
Reviewed-on: http://review.couchbase.org/31565
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Refactor: Split atomic.h into multiple files

The AtomicQueue is only used in one place, and the ThreadLocal
is also just two places. This is the first step trying to
minimize their scope.

Change-Id: I390ad00685b2d4b789790eca1e4d29617c573e03
Reviewed-on: http://review.couchbase.org/31416
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Refactor: Remove include of tapconnmap.h from ep_engine.h

This is the only client using the AtomicQueue implementation
reducing the visibility of all of the symbols.

Change-Id: Ia2eafc6a47640c704570f33fe6ca4f30252e0b9a
Reviewed-on: http://review.couchbase.org/31527
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Completely hide CouchbaseAtomic for win32

Change-Id: I1a66d40bfb2134a72c88eaaba0cdfdf66ed272dc
Reviewed-on: http://review.couchbase.org/31567
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Add TLS for win32

Change-Id: Ib76ca222ee830de8b73c34a78abcffadb988fc3d
Reviewed-on: http://review.couchbase.org/31570
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Fix sporadic tap unit test failures

There were two issues here. The first is that we must wait for the
persistence cursor to move into the open checkpoint for the estimate
vb move test. This is because during checkpoint registration we now
place the cursor in the checkpoint that contains the persistence
cursor as opposed to just putting it into the open checkpoint. The
second issue was with the way we were calculating the cursor offset.

Change-Id: I48afb516479c1a19e52215fb4ab46de057fc46fa
MB-9785: Allow the checkpoint manager to work with upr streams

This is a large change that does a few things other than just
allowing a stream to access the checkpoint manager. The main
feature of this change is that the Stream class is now a state
machine that contains states for pending, backfilling, in-memory,
and dead and the stream moves through these states based on how
far behind or up to date the mutations being sent from the stream
are. The Stream class also becomes the main place for handling
mutations in an UPR connection.

Change-Id: I4f5d6a49e31e992bd34b2bce5d8089ccbaffb1f4
Remove backfill callbacks from the ConnMap class

UPR will have it's own seperate backfilling code so we no longer
need to use the callbacks that Tap conenctions use when they do
backfill. Having our own UPR backfilling logic should also lower
lock contention since we will lock based on the Stream as opposed
to the Connection.

Change-Id: I6786b0f1397d94b6ed126a7b62afb30eaceae53a
Don't assign checkpoint start/end/dummy items a by sequence number

Assigning checkpoint meta items sequence numbers can make consumers
think that more items have been added to a vbucket when no new items
have actually been added. This change also makes it easier to predict
the high sequence number when inserting a given amount of items into
a vbucket.

Change-Id: Ib374ccda99179b93c80bdd8d36cdfb4bf0caaf4e
MB-9821: Add takeover stream logic

The change adds two more states to the producer stream state
machine to allow a producer to properly hand off a vbucket to
another node.

Change-Id: Ia7925442b9f8cb984639b331ae642d90c9ef94a0
Make sure consumer stream request response is a valid consumer

Change-Id: Ibb8be9d4a5cf6d8990fa1beeb9733feb33a6a0ab
Only add a failover log if the stream was succesfully created

Calling the failover callback can actually cause two responses to be
sent in the case of stream request failure. This can cause clients
to become confused and drop connections.

Change-Id: Ibe1b7116b0424c048144682ebe43a3f204e6e4be
Add warning level log messages whenever there is an upr disconnect

This was requested by people that are developing upr consumers and
will greatly help diagnose why a connection is dropped unexpectedly.

Change-Id: I76b1509de1b4ee3b43d060ded4cf18a10ded3109
Add sanity checks for start/end seqno's when doing a stream request

Return an ERANGE error if the start and end sequence numbers do not
make sense for a given request.

Change-Id: I9859defd587b748a17175b95e66a20adcac65eca
Add couch_notifier_enabled engine parameter

This allows us to disable couchdb notifications so that
we can run memcached with ep-engine and couchstore

Change-Id: I9a3c50443ff35b7a602803f229ea0b0b793b7125