MB-5385: fixed standalone bucketmigrator to support sasl auth

So that it's possible to replicate & takeover non-default bucket. I've
also made it stop advertising vbucketmigrator flags it doesn't
understand. And made -v flag work by lowering log level to debug.

Change-Id: I7c76b23c1aa629d2b336f802e70e8b003c6ebffb
Reviewed-on: http://review.couchbase.org/16447
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5385: added support for specifying password on cmdline

Note: this is not secure. But for one-off cases where ebucketmigrator
is useful it seems ok.

Change-Id: I37b642ebd64e9e42486708c18e6d3d74d03f7cc6
Reviewed-on: http://review.couchbase.org/16453
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5344 list data files

Print out data files with file size, permissions and last
modification date

Change-Id: I40a486a002ef73940ffc8dd19e53a6b9409a416a
Reviewed-on: http://review.couchbase.org/16433
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Bin Cui <bin.cui@gmail.com>
Ensure that restored map's balanced before adding to history.

Seen in MB-5230.

Change-Id: I383006d0a43554fae418c0917c28a14af463676d
Reviewed-on: http://review.couchbase.org/15651
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Use logging instead of io in mb_map:is_balanced.

Change-Id: I00422879e86dac93ce9fbbb6edde3a52395d756e
Reviewed-on: http://review.couchbase.org/15649
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5307: made mc_client_binary use prim_inet instead of gen_tcp

gen_tcp is just a couple of layers of inneficiency on top of
prim_inet. And quite significantly slower for bunch of small reads.

This commit shaves off around 10% on "a bunch of stats requests"
benchmark.

Change-Id: I35f3825b4b22db67bd3fffe5041719af310c5934
Reviewed-on: http://review.couchbase.org/16424
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5307: implemented much faster memcached stats gathering

New implementation via mc_binary:quick_stats/5 uses
inet:setopts(Sock,[{active,once}]) to efficiently read all data from
socket and port driver. That data is then parsed. This ends up more
than twice faster than plain stats call that makes trip to driver
twice (for header and body) for each stat entry.

Change-Id: Ia98239fb3c14d51296740a0661d38ad7b0e342b4
Reviewed-on: http://review.couchbase.org/16425
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5279:bp: allow port_servers to send arbitrary data to port

Change-Id: Ic22a1327e3615e19b0bb50a267fb42488e183cd9
Originally-Reviewed-on: http://review.couchbase.org/14053
Reviewed-on: http://review.couchbase.org/16436
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5279:bp:made supervisor_cushion exit with same reason as child

So that termination with reason normal is normal.

Change-Id: Id057ba230d6affd2fab72a94b637dab1200763d1
Originally-Reviewed-on: http://review.couchbase.org/14054
Reviewed-on: http://review.couchbase.org/16437
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5279:bp: ask memcached to die real quick on failover

We send die! message that we expect memcached to just do _exit. We'll
then restart it, but the idea is that per bucket supervisors are
already shutting down for this node.

Change-Id: I497b0f12b4667056ed8df9958c084d59d1ea1bbe
Originally-Reviewed-on: http://review.couchbase.org/14055
Reviewed-on: http://review.couchbase.org/16438
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5279: send shutdown command instead of empty line to memcached

New memcached will ignore empty line. We need to send shutdown in
order to request graceful shutdown.

Change-Id: Ie506cec5b67ef28604a9ee2a95274f6ebf6958a0
Reviewed-on: http://review.couchbase.org/16483
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Merge remote-tracking branch 'origin/branch-181' into branch-18

* origin/branch-181:
  MB-5279: send shutdown command instead of empty line to memcached
  MB-5279:bp: ask memcached to die real quick on failover
  MB-5279:bp:made supervisor_cushion exit with same reason as child
  MB-5279:bp: allow port_servers to send arbitrary data to port
  MB-5307: implemented much faster memcached stats gathering
  MB-5307: made mc_client_binary use prim_inet instead of gen_tcp
  Use logging instead of io in mb_map:is_balanced.
  Ensure that restored map's balanced before adding to history.
  MB-5344 list data files
  MB-5385: added support for specifying password on cmdline
  MB-5385: fixed standalone bucketmigrator to support sasl auth

Conflicts:
	src/ns_memcached.erl

Change-Id: I80b3dcf55a3f654b1f6a22eddfe1559b867bc04f