MB-8903: Add UPR project

In couch_upr will be all the code that is needed to get
changes from an UPR stream.

Change-Id: I1c71c64819e4369a38b32a20128e9d21fd7bd022
Reviewed-on: http://review.couchbase.org/29401
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: First version of couch_upr

See test/02-couch-upr.t for the API usage.

This commit also adds the fake UPR server.

Change-Id: I670f8e36196057399b4f942c7ffebfbdb9295066
Reviewed-on: http://review.couchbase.org/29402
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9058: Consume from fake UPR server

Instead of reading the changes from files, get them
via TCP from the fake UPR server.

Change-Id: If69433c4863de9a7ec2684da1c72d070c5406205
Reviewed-on: http://review.couchbase.org/29403
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9085: Don't hard-code UPR port

Instead of hard-coding the UPR port, use a configuration
setting for it. This makes it also possible to start the
fake UPR server on a random port (assigned by the
operating system), when the value is set to "0".

Hence it's now possible to run the set_view_tests in
parallel again.

Change-Id: I6c319dbb6fcac8b4f20f38ce8a44c6abed24658d
Reviewed-on: http://review.couchbase.org/29404
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9058: Remove all references to the database files

Access to the database files is no longer needed as
the information now gets in through the UPR stream.

A check for purging was removed. That is OK since with
UPR the logic to deal with purges needs to be re-done
anyway.

Change-Id: I3b751905867cda4453ebd98cbf48bd8144fbae0b
Reviewed-on: http://review.couchbase.org/29405
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Update according to transfer protocol changes

The transfer protocol changed quite heavily. This commits
makes the corresponding changes.

Change-Id: I860b072c96258f3045a5fcc94b34eaa91f65f4f0
Reviewed-on: http://review.couchbase.org/29406
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Switch defines from bytes to bits

Change-Id: Ic136a651c4e0f2563084b637693c9a25cd082cc6
Reviewed-on: http://review.couchbase.org/29407
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Simplify header parsing

Change-Id: I9e24502b8aea7a589f1edbcc19c063cf9daa605c
Reviewed-on: http://review.couchbase.org/29408
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
Fix dialyzer warnings

Change-Id: I440acf09dc913f3b56b68f7ce3ce4077fda07da2
Reviewed-on: http://review.couchbase.org/29409
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-9307: Add rollback to couch_upr

Add the rollback response to the couch_upr_fake_server when
the sequence number is too high. Also handle that case in
couch_upr.

Change-Id: Idf09828f29e6edc766d004a1f62f98f789d29f48
Reviewed-on: http://review.couchbase.org/29416
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Update according to transfer protocol changes

Change-Id: I2ff866f228c72f6e7aa2763a6c1495a294afed88
Reviewed-on: http://review.couchbase.org/29734
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Rename "stream start" to "stream request"

Align the names better with the specs and other implementations

Change-Id: Ib4fb81acbf859c6f82c8d42e5e4fad181172f544
Reviewed-on: http://review.couchbase.org/30174
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Make function names more uniform

Remove "request" from encode_open_connection_request

Change-Id: I7343c3ac66af523afcf4d4692aed5a0214eb4a5a
Reviewed-on: http://review.couchbase.org/30175
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Rename UPR_WIRE_* constants to UPR_*

This commit is just renaming the constants, without any
functional changes.

Change-Id: Ie6286f8118aa6b96e4dcda90a0b53dfe4772f640
Reviewed-on: http://review.couchbase.org/30541
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Rename UPR_REQUEST_TYPE_* to UPR_STATUS_*

Change-Id: Iabb7bd31b5ccee16f461ea334421fb7b9c8718ea
Reviewed-on: http://review.couchbase.org/30542
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Add failover log request

It's now possible to get the failover log with couch_upr.

Change-Id: I9b4868123babea93334a93dca447970d48e5ea35
Reviewed-on: http://review.couchbase.org/30543
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Fake UPR server should support multiple sockets

Only the latest socket was used to mutations. Instead all
sockets should receive their corresponding mutations.

Change-Id: I857369e8469c3e610b8670fda279b3a63113314a
Reviewed-on: http://review.couchbase.org/30544
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Fix couch_upr "make check"

Change-Id: I45c0ee7fe83197e433bb6a0a11243c867bb30d48
Reviewed-on: http://review.couchbase.org/30707
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Volker Mische <volker.mische@gmail.com>
MB-8903: Start UPR in group and not the updater

Starting the upr conection in the group makes more sense
as it is one connection per group anyway.

Change-Id: I1e6bd1ba489aeda9d72af1adbf1b47fec0befad4
Reviewed-on: http://review.couchbase.org/30545
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
MB-8903: Stream Request OK response returns Failover Log

couch_upr:enum_docs_since() now also returns the
Failover Log.

Change-Id: I2b940b8c62a31f741bcbfab7604c897b9859f345
Reviewed-on: http://review.couchbase.org/30836
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: buildbot <build@couchbase.com>