MB-7960: XDCR on pipelined memcached binary protocol

This commit implements XDCR over binary memcached binary protocol
(MBP), namely, "xmem" replication mode. We keep current XDCR to
CAPI, namely "capi". The default replication mode will be "xmem",
but users can switch back to "capi" through ns_server parameter:

"xdcr_replication_mode",

or, environtment parameter:

XDCR_REPLICATION_MODE

e.g.  export XDCR_REPLICATION_MODE="capi"

Like existent XDCR parameters, env parameter will always override
ns_server paraemeter.

In "xmem" mode XDCR, each vb replicator creates a server process
(xmem_srv), which may create one or multiple child worker process
(xmem_worker) responsible for all communications to remote memcached,
e.g, connect, select_bucket, build and send memcahced request via
MBP, and disconnect. The server process will relay request from vb
replicator worker (vb_rep_worker) to xmem worker process, and return
results back to vb replicator worker. The xmem_srv process is also
repsonsible for load balancing, stats collection and report, and
replay errors from child xme_worker process to vb replicator. The
default num of xmem_worker created by xmem_srv is 1, which can be
adjusted by ns_server parameter "xdcr_xmem_worker" and environemnt
paraemeter "XDCR_XMEM_WORKER".

This enhancement provides an alternative replication mode along
with current CAPI mode. It is completely a lower level data commutation
protocol change and has no impact to upper level XDCR protocol. The
benefit is mostly performance-wise: increased throughput, improved
scalability, etc. It should be completely transparent to users, in
particular, we maintain these invariants:

no change to current replication protocol;
no change to current XDCR stats;
no change to current XDCR checkpoint behavior;
no change to current XDCR behavior during topology change;
all current XDCR functional tests shall pass.

Change-Id: I3c6acb885baed33bdcbeb4d2f5165d036146d080
Reviewed-on: http://review.couchbase.org/27696
Reviewed-by: Junyi Xie <junyi.couchbase@gmail.com>
Tested-by: Junyi Xie <junyi.couchbase@gmail.com>
MB-7960: handling unsupported select_bucket cmd in XMEM

If select_bucket command is no longer supported, we can safely
ignore the error msg returned from remote memcached when issuing
"select_bucket" command.

Change-Id: I4df3dc2ceb6a58f1b9afcfbe418925615e69ff33
Reviewed-on: http://review.couchbase.org/28040
Reviewed-by: Junyi Xie <junyi.couchbase@gmail.com>
Tested-by: Junyi Xie <junyi.couchbase@gmail.com>
MB-8748 script to reset admin password

- /couchbase/install/bin/cbreset_password
- doesn't work on the server started by cluster_run
  because dump_guts script doesn't work on it

Change-Id: Ic2e62930a2da87289ab518459e6fbc723b794774
Reviewed-on: http://review.couchbase.org/27982
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
trim for all serialized values

Change-Id: Id36397dc8ecd16e10e3ad169de8e3932d40a058c
Reviewed-on: http://review.couchbase.org/28013
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-8145: support of read-only user

Change-Id: Ia2b44e858e7cb08f2ba49e519b6c363a354ca357
Reviewed-on: http://review.couchbase.org/27941
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: introduced menelaus_util:reply_404/1

Change-Id: I57d8d1ab2829a70dcd85a64b94c8656393880f1e
Reviewed-on: http://review.couchbase.org/27942
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: killed auth_bucket_with_info menelaus_web action type

Change-Id: I3c4aca708271f09d30838e01073529962d7876f4
Reviewed-on: http://review.couchbase.org/27943
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: removed unused poolid argument from checking_bucket_uuid

Change-Id: Ib3f4d19d4b83e825e402fef371757d60e4496b49
Reviewed-on: http://review.couchbase.org/27944
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100:replaced extract_auth(username, ..) with explicit function

Change-Id: I6b3e17b634342ab28fd96b4a1df615f90a17aaf3
Reviewed-on: http://review.couchbase.org/27945
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: include otpNode even if auth is not admin

Because RO user UI will need this stuff.

Change-Id: I6dfd4b5007c3280d4d8b533b1614f3ca79e1243f
Reviewed-on: http://review.couchbase.org/27946
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: removed superfluous calls checking_bucket_access

Change-Id: Ieafe64ab40d0326678cb5b1c7eb6ebf9fcbef3b7
Reviewed-on: http://review.couchbase.org/27947
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: killed checking_bucket_access

Things appear clearer if we remove one layer of indirection here.

Change-Id: I54e9b44978242a6f637c8db3a04ff9f321250cfd
Reviewed-on: http://review.couchbase.org/27948
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: killed build_bucket_node_infos/5

"Extra arg" was not used.

Change-Id: I30049c5937ad3e066cfca69deccd41bdaa0bc0e5
Reviewed-on: http://review.couchbase.org/27949
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: dont send otpCookie to UI

Change-Id: I2088e824b21213898665d3f4cf5a0fa8a3fe4f0d
Reviewed-on: http://review.couchbase.org/27950
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: removed passing UserPassword to pool_info functions

We really only need to know if request is executed under admin or not.

Change-Id: Idf921acfd5f4457bab2bfc69b3df26f9f408fb82
Reviewed-on: http://review.couchbase.org/27951
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-8145: implemented auth for read-only admin

Change-Id: I8eed9d548db82b50e5b1b2b13491cfff7f934ea9
Reviewed-on: http://review.couchbase.org/27952
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: fixed minor compiler & dialyzer-found issues

Change-Id: I31aeeb8400e126a6b8685ba3e9214013bef9934d
Reviewed-on: http://review.couchbase.org/28065
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Merge remote-tracking branch 'origin/2.2.0'

* origin/2.2.0:
  MB-100: fixed minor compiler & dialyzer-found issues
  MB-8145: implemented auth for read-only admin
  MB-100: removed passing UserPassword to pool_info functions
  MB-100: dont send otpCookie to UI
  MB-100: killed build_bucket_node_infos/5
  MB-100: killed checking_bucket_access
  MB-100: removed superfluous calls checking_bucket_access
  MB-100: include otpNode even if auth is not admin
  MB-100:replaced extract_auth(username, ..) with explicit function
  MB-100: removed unused poolid argument from checking_bucket_uuid
  MB-100: killed auth_bucket_with_info menelaus_web action type
  MB-100: introduced menelaus_util:reply_404/1
  MB-8145: support of read-only user
  trim for all serialized values
  MB-8748 script to reset admin password
  MB-7960: handling unsupported select_bucket cmd in XMEM
  MB-7960: XDCR on pipelined memcached binary protocol

trivial merge

Change-Id: If2257601fdbd39dafaa6e178276bf426a2c76748