bp:MB-7671 Check fragmentation before compacting vbucket.

Backporting for MB-7074. Also includes prep-commit backport.

When we decide to compact or not to compact a bucket we just take a
random sample of vbuckets and check aggregated fragmentation of these
vbuckets. Although not very likely, it's possible that we'll decide to
compact entire bucket when only few vbuckets have high
fragmentation. To avoid an overhead of compacting vbuckets that don't
really need thie, now we check fragmentation of every single vbucket
before compacting it.

Change-Id: I7609a78cfcdb12e54c0e0ddcd08ef3be35c78bd6
Orig-Reviewed-on: http://review.couchbase.org/24280
Orig-Reviewed-on: http://review.couchbase.org/24279
Reviewed-on: http://review.couchbase.org/24391
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5650: Consider OSX setup path

Change-Id: I90a24e8198dcac3bb0cd188bbdae7a257d8780cc
Reviewed-on: http://review.couchbase.org/24393
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Steve Yen <steve.yen@gmail.com>
MB-7676: prioritize view compactions heavily when we wait for it

We've have found that with our typical sizing, db compaction can
easily take hours. On the other hand we don't need to wait for db
compaction during rebalance. Which previous implementation in fact it.

I assumed that it's better to avoid disturbing running compaction, but
it appears that it's better to drop whatever we're compacting and do
index compaction when we need that.

This commit also fixes subtle issue in implementation of vbucket move
orchestrator decisions. Previously it would incorrectly report
compaction as done simply when it started it. The idea was to avoid
waiting for very final index compaction. But it's not clear that such
misinformation may prevent vbucket move scheduling
optimization. I.e. vbucket move scheduler would think it's ok to run
certain move, when in fact move will have to wait for compaction
completion.

New code always drops bucket compaction when view compaction
inhibition is requested for it. It may have some slight negative
effect, especially when no indexes are defined.

Change-Id: I70ba6be701c750da9acbd83169bd5e1a16f0e83d
Reviewed-on: http://review.couchbase.org/24397
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-7562 Grab per node diags sequentially.

So that peak memory usage is lesser. This commit is only a
preparation. In reality we don't want to grab all diags completely
sequentially because then the overall time will be very sensitive to
slowness on individual nodes.

Change-Id: I0cec1478a54d9ed40c7bdaadc062b547510af8bd
Reviewed-on: http://review.couchbase.org/24456
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-7562 Process processes info one by one when formatting diag.

Erlang's pretty-printer is known memory hog and number of processes
may be quite noticeable. So it makes sense to format every process
info separately.

Change-Id: I7138c2fc43a3897d50da1a3b137644e0f185d172
Reviewed-on: http://review.couchbase.org/24457
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-7562 Format master activity events separately.

There're basically two reasons for these. As with processes, number of
events maybe quite big which causes pretty printer to consume a lot of
memory. The other reason is that we already have a better way to
format these messages. Namely, master_activity_events:event_to_jsons.

Change-Id: Ic4587273004130d28f094c892230e238a78c16cc
Reviewed-on: http://review.couchbase.org/24458
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-7562 Send per node diag in binary format.

This requires much less memory. We convert specific node's diag to
term just before the formatting and perform explicit garbage
collection afterwards to save space.

Change-Id: I5024f8b4cfcf45ab45c1b75ad0949ffc289a4406
Reviewed-on: http://review.couchbase.org/24459
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-7706 Delete _replicator db when joining cluster.

Change-Id: I67016cfd5cd2d6829505f30005a0268a12d39f11
Reviewed-on: http://review.couchbase.org/24515
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Merge remote-tracking branch 'origin/2.0.1' into b202

* origin/2.0.1:
  MB-7706 Delete _replicator db when joining cluster.
  MB-7562 Send per node diag in binary format.
  MB-7562 Format master activity events separately.
  MB-7562 Process processes info one by one when formatting diag.
  MB-7562 Grab per node diags sequentially.
  MB-7676: prioritize view compactions heavily when we wait for it
  MB-5650: Consider OSX setup path
  bp:MB-7671 Check fragmentation before compacting vbucket.

Change-Id: I697fa07a98a7f3b51d5a39f8db210683ebaf4572