[bp] Move the code moving single vbucket data into a separate module.

No anonymous or private functions are spawned on remote nodes
now. Additionally, since all the code performing the actual move is
concentrated in a single module, it will be easier to update it on
remote nodes. Together with new master election algorithm this will
allow us to perform cross-version rebalance even if vbucket mover
versions differ across the cluster.

Originally reviewed on http://review.couchbase.org/8577

Change-Id: Ic9eccef11094157c1a3b46939b17a0e7c146a672
Reviewed-on: http://review.couchbase.org/13519
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
[bp] MB-4106 Update vbucket map after each vbucket movement.

Previous behavior was to update vbucket map only after rebalance is
finished.

Originally reviewed on http://review.couchbase.org/8579 and
http://review.couchbase.org/10733

Change-Id: Ib415c6999f2d81deddd8786f449f05ff0c1c259f
Reviewed-on: http://review.couchbase.org/13520
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
[bp] Do not replace standard error_logger and sasl handlers.

Change-Id: I786f811337792875e58c33fbf8267273ec76149f
Reviewed-on: http://review.couchbase.org/13525
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Fix error reporting in do_engage_cluster.

Change-Id: I8783d4445b478349af56417abefdb105af15797c
Reviewed-on: http://review.couchbase.org/13522
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Add ale to dependencies.

Change-Id: Ib8d6765230278bce9d0ec411db7a37f78a2cb84a
Reviewed-on: http://review.couchbase.org/13521
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Reformat ns_log_browser.

Change-Id: I14a1661e0dfc9de693a3880a1853911a5ede154d
Reviewed-on: http://review.couchbase.org/13524
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Use our logging macros instead of calling error_logger directly.

Change-Id: I5c9489982de30523f28da391fccb519508282cb5
Reviewed-on: http://review.couchbase.org/13523
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Initialize logging in ebucketmigrator.

Since ebucketmigrator uses ebucketmigrator_srv and since the latter
logs some information to ale loggers we must initialize these
loggers. The output just goes to stderr.

Originally reviewed on http://review.couchbase.org/9338

Change-Id: I74eafcd2ab02ec8d053ff25f55e409c4c3cf29bf
Reviewed-on: http://review.couchbase.org/13540
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
[bp] supervise ns_config_events subscription in ns_bucket_sup. MB-4400

So that restarts of ns_config_events for whatever reason does not
impact our ability to create/delete buckets.

Originally reviewed on http://review.couchbase.org/10636

Change-Id: Ib4db2ea41823aaeef47fe8f41d0e45f9bfa6d1aa
Reviewed-on: http://review.couchbase.org/13544
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
[bp] Remove subscribe_all and friends since they've never been used.

Originally reviewed on http://review.couchbase.org/12420

Change-Id: I9f8168fd772bac56dc3ad3e4e5e4a16343868f2e
Reviewed-on: http://review.couchbase.org/13543
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
[bp] Suppress sasl and error_logger tty handlers.

Change-Id: I60354597f37729022ef52bb17dd810fc54fa4c3d
Reviewed-on: http://review.couchbase.org/13526
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Our common logging macros now log to ale ns_server loggers.

Change-Id: I04446924331aef581230b087521887dabf77ad88
Reviewed-on: http://review.couchbase.org/13527
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Update diag_handler and ns_log_browser to new log format.

Change-Id: Icc11d4c144ac5e5780674e4e7076202948687d77
Reviewed-on: http://review.couchbase.org/13528
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Read loggers loglevels from static config.

Default loglevel is specified using {loglevel_default, <loglevel>}
tuple in the static config. Loglevel for a specific logger is
specified using {loglevel_<logger>, <loglevel>} tuple.

Change-Id: I9446ef24d1e222b1bdea27c77e02740cdf42f73c
Reviewed-on: http://review.couchbase.org/13529
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Use separate logger for user-visible messages.

All the messages that previously were logged using ns_log go now to
specific logger. All the messages from this logger get to the common
disk log. But additionally through the custom sink they are replicated
across the cluster as previously.

Change-Id: I48b4a5b713a3dc3e1b5c52de2d060bcdb2847d7c
Reviewed-on: http://review.couchbase.org/13530
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Use separate logger for menelaus messages.

Change-Id: Ice211a1b494328c3578dbe3a03272640fa9c243a
Reviewed-on: http://review.couchbase.org/13531
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Separate logger for ns_doctor.

Change-Id: Ia5e595e9ed7e971fdf25bbdb4336973dedb6c399
Reviewed-on: http://review.couchbase.org/13532
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Separate logger for stats.

Change-Id: I7c4c324ac8355f4b685a05175ab8f4b8ca2947cf
Reviewed-on: http://review.couchbase.org/13533
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Separate logger for rebalance-related messages.

Originally reviewed on http://review.couchbase.org/9337

Conflicts:

	src/ebucketmigrator_srv.erl
	src/ns_rebalancer.erl
	src/ns_single_vbucket_mover.erl

Change-Id: I072540a1d81ead6ea2577bd77b35bf4020839ffe
Reviewed-on: http://review.couchbase.org/13534
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[bp] Adapt ns_log_sink to the messages without a code.

This allows us to send usual log messages to this sink so that the
user can see them too. Such messages are logged with a fake 0 code. On
the other hand they are still announced locally with undefined code
for subscribers to know for sure that there are no code attached to
the message.

Originally reviewd on http://review.couchbase.org/9374

Change-Id: Ibe8d0e1e99d8885a3586c43e04ef9717676b1c48
Reviewed-on: http://review.couchbase.org/13535
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>