MB-10400: don't import a bunch of couch_util functions in header file

Change-Id: I2472efedca9c0789d4648678a1260901707928ed
Reviewed-on: http://review.couchbase.org/34808
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10400: commented out "behind purger check"

which we cannot yet do in upr world

Change-Id: Iab4a041e5d0c98e619b7339ffeee37fa370ca4a2
Reviewed-on: http://review.couchbase.org/34809
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10400: use better api for opening src master vbucket

Change-Id: I93ce7bab82c53b56cbc4ea5c0606a9c2fe370b60
Reviewed-on: http://review.couchbase.org/34810
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10400: removed duplication in queue_fetch_loop

Change-Id: I930e163f8d5b39d4f1e327b22ead24425cdb036b
Reviewed-on: http://review.couchbase.org/34811
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10400: dropped use tgt_master_db

Because it's not used

Change-Id: If8dea776326765bf24c37964566668808b97cd25
Reviewed-on: http://review.couchbase.org/34812
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10400: added xdcr_upr_sockets_pool

Change-Id: Ifcd228367684970b15150200cc83ff3451ff3079
Reviewed-on: http://review.couchbase.org/34813
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10400: added xdcr_upr_streamer

This is initial implemenation of performance-oriented upr client for
xdcr. There are plenty of code that will change when upr server
actually supports flow control. And there are plenty of debugging
stuff that I'm leaving in for now, until implementation is finalized.

Change-Id: I8460ebe1dda9ae7f895a1b2479eed1a178d90113
Reviewed-on: http://review.couchbase.org/34814
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10400: initial xdcr-over-upr implementation

Note that I've decided to keep old xdcr path alive for some
time. Particularly bacause make simple-test is failing. And because
upr implementation has some known bugs (like upr stream getting stuck).

There's ns_config switch which value is picked based on environment
variable. If XDCR_USE_NEW_PATH environment variable is set, then new,
upr-based code path is selected. Otherwise old path is picked.

Note that xdc_vbucket_rep_worker for old path was merely copied from
prior revision of this file. There is no attempt to keep shared code
shared in this place of code. That is because old path is expected to
die reasonably soon. And to make killing it easier.

This commit implements both upr-based mutations consumption as well as
upr-based checkpointing.

Remote end of upr-based xdcr is using seqno + vbucket uuid in order to
represent commitopaque. And vbucket uuid is used as vbopaque.

Local end is saving seqno, last snapshot seqno and (local) vbucket
uuid to represent it "consumer coordinates". On resumption, those
local coordinates are used to establish upr stream. And upr rollback
is used to handle partial or full data loss. I.e. there is no notion
of "checking local end of checkpoint for validness" because local end
is always valid. UPR handles proper resumption for us.

Change-Id: I07ddba2f53eb88b3bc182040ac897f677bfb36b2
Reviewed-on: http://review.couchbase.org/34815
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100 log status of the proxy in case of unhandled cast

Change-Id: I622e1cc672af0c4f1e5dd8317868a0d913e90231
Reviewed-on: http://review.couchbase.org/34903
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 check partition id for stream_req during the takeover

Change-Id: I2a91821b94454db0be8ca06c195a3b440c816032
Reviewed-on: http://review.couchbase.org/34909
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
MB-100 change set_vbucket_state from call to cast

because apparently cast doesn't cause race

Change-Id: I34722aae9bc1b4f95ee2be00c86ba205f759cf0d
Reviewed-on: http://review.couchbase.org/34916
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
improve casperjs testrunner

Change-Id: I782362a36d188220d75710181c3b942344b2ca3b
Reviewed-on: http://review.couchbase.org/34260
Reviewed-by: Pavel Blagodov <stochmail@gmail.com>
Tested-by: Pavel Blagodov <stochmail@gmail.com>
Set ERL_CRASH_DUMP in cluster_run.

Change-Id: Ie48d159f4c69c21f2273ff5a84ff4710d3890424
Reviewed-on: http://review.couchbase.org/34948
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Ensure all our beams have different ERL_CRASH_DUMPs.

Change-Id: I9ab9e4df596ac254e2bc8f92878b31a2911be6d1
Reviewed-on: http://review.couchbase.org/34949
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10540 Ignore empty server groups.

When checking that only one server group exists and converting such a
configuration into undefined. Because otherwise map_opts_hash would
change when an empty group is created. This happens because tags
property stops being undefined and becomes something like [{n1,
<<"0">>}, {n2, <<"0">>}]. Any additional number of empty server groups
doesn't lead to the same effect.

Initially my patch just removed this logic completely because it's not
needed anymore. But since every node decides *locally* if rebalance is
needed, this lead 2.5 nodes to believe that rebalance was always
required when there was only one server group.

Change-Id: I97965bec6d3c2487884093c1f1c13130f6d752a1
Reviewed-on: http://review.couchbase.org/34952
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10309 Disable mlockall in cluster_run.

I discovered that memory consumption problems that we saw on R16* go
away if I disable mlockall. I suspect that it has something to do with
mseg allocator overhaul that was part of R16 release. Since currently
we support R16 only for development, we can just disable mlockall in
cluster_run to mitigate the issue. Making us ready for production on
R16 would require more effort though.

Change-Id: Id2b9171add9601dcd6145687ddc9b0104bc4d14e
Reviewed-on: http://review.couchbase.org/34968
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Don't spawn the shell to read the prefix.

Change-Id: Id093e5e4dccbf4ba659eb76f5694a822e58068a6
Reviewed-on: http://review.couchbase.org/35006
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Don't use find utility to find ebin directories.

Change-Id: I1375fc47e73d1c4a1449d4df88a99cb65c259f7b
Reviewed-on: http://review.couchbase.org/35007
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-10415 moxi and sample loader should use auth token instead

...of user/pwd combination since the password won't be stored
in config after MB-10415

Change-Id: I0780ee45a885187cbdf31b65a329928dbc0f262a
Reviewed-on: http://review.couchbase.org/34617
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-10415 use temp auth token for cluster join

Change-Id: Ib50f91f6789815302f55ca50c164e21d339deeef
Reviewed-on: http://review.couchbase.org/34787
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Artem Stemkovski <artem@couchbase.com>