MB-9589: handle incomplete cluster leave

When cluster leave function fails we can end up in a state where node
remains in a limbo state forever.

New code places marker file on filesystem to indicate that leave is
happening. With that, if ns_cluster dies during leave cluster
procedure, it'll detect incomplete leave in init and complete it (or
fail while doing it).

Change-Id: I41fa757a2527de8e95cfdad95029b06216f7880b
Reviewed-on: http://review.couchbase.org/30413
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100: no need to replicate if srcMeta = destMeta

Change-Id: Id1a62e6d9ded77410ac434a0b675db58ae2b89f4
Reviewed-on: http://review.couchbase.org/30456
Tested-by: Junyi Xie <junyi.couchbase@gmail.com>
Reviewed-by: Junyi Xie <junyi.couchbase@gmail.com>
MB-9556: reduced acc management font

Change-Id: I1701236ac9c6adf980cc6857261ff9b919b6b489
Reviewed-on: http://review.couchbase.org/30479
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Pavel Blagodov <stochmail@gmail.com>
Tested-by: Pavel Blagodov <stochmail@gmail.com>
added scripts/memory_monitor.sh

Change-Id: I2a102daff2f651ce5e6d5b59c14d49f2b56b6855
correctly json-format errors from remote clusters POST

There was missing {struct, _} tuple around errors which caused crash
in json-ifier.

Change-Id: I705ca32db8fc099331244eb641c837e97fbdcf32
MB-4557: Allow changing cluster ram size from UI

- introduced Settings/Cluster tab where you can change
  cluster ram quota
- prohibited to set the quota that is less than sum of the
  buckets quotas
- added just_validate parameter to POST /pools/default API
- changed the error output of the POST /pools/default API
  from simple string to {"errors":{"memoryQuota":"message"}}

Change-Id: Ia1321c921693590f060e3456414a22620c344adf
Reviewed-on: http://review.couchbase.org/29530
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
un-leak memory in cluster settings form validation code

Previous code had unlikely code path where change of pool settings url
will cause form validation to be set up again and again etc...

In order to avoid that improbable bug I'm adding code to destroy
previous instance of form validation prior to overwriting it with new
instance.

Change-Id: I06f47903dc7e90dc66fba5858e220c421ffa1b1d
MB-9552: reduce message passing in XMem

Today in XMem XDCR, the vb replicator rep_worker process need to
send all docs to replicate to xmem_server process first, and the
xmem_server process will pass all these docs to its child xmem_worker
process. Consequently there are two big message passing among Erlang
processes which may cause some inefficiency.

This commit will make rep_worker process send all docs to replicate
directly to xmem_worker process and flush to remote. Therefore it
removes the first message passing above and initial XDCR test on
toybuild shows more than 15% throughput improvement.

Change-Id: Iccf3ab02137b30d9f9bdd5c41c6d168ec7f93da0
MB-9596: improved rebalance diagnostics

In MB-9596 logs it's not clear exactly why replica builder
shutdown_replicas call failed. And it's also obvious that entire
sequence of actions by single vbucket move is not logged very
clearly. This commit addresses it.

Change-Id: Iea7af5e5128a635d5dfeb5cd02164e7a0ae7a25a
Merge "added scripts/memory_monitor.sh" into for-rackaware
Merge "correctly json-format errors from remote clusters POST" into for-rackaware
MB-9339: changed menelaus_rest to use lhttpc

We'll need this in order to move remote_cluster_info facility to xdcr
connection pool.

Change-Id: I337864646dfbab897967b90f0816fcc265491de5
MB-9339: use xdcr lhttpc pool for remote_clusters_info requests

Change-Id: Ibf607fd4131546e604148b27e8b9b08589746c5a
MB-9339: amputate xmem checkpointing mode

because it will not be supported by xdcr-over-ssl

Change-Id: I915f9a4eec835bd9032da05f589bec5ca072e7fb
MB-9339: support success in mc_client_binary:map_status

Change-Id: I82b064ee33b1630db43a95b4d23f34b14bf8c8af
MB-9339: introduced ns_connection_pool

Change-Id: I8e509a6459a88f536a087b86296c1d09f4eee37b
MB-9339: added pooled_memcached_client and memcached_clients_pool

Change-Id: I64473163306b12fb9a1b5ef1fba33d841801da86
MB-9339: use pooled_memcached_client for xmem

Change-Id: I79c5341188b06050f1a8033508fc0296d4c93421
Merge remote-tracking branch 'origin/for-rackaware'

* origin/for-rackaware:
  MB-9339: use pooled_memcached_client for xmem
  MB-9339: added pooled_memcached_client and memcached_clients_pool
  MB-9339: introduced ns_connection_pool
  MB-9339: support success in mc_client_binary:map_status
  MB-9339: amputate xmem checkpointing mode
  MB-9339: use xdcr lhttpc pool for remote_clusters_info requests
  MB-9339: changed menelaus_rest to use lhttpc
  MB-9596: improved rebalance diagnostics
  MB-9552: reduce message passing in XMem
  un-leak memory in cluster settings form validation code
  MB-4557: Allow changing cluster ram size from UI
  correctly json-format errors from remote clusters POST
  added scripts/memory_monitor.sh
  MB-9556: reduced acc management font
  MB-100: no need to replicate if srcMeta = destMeta
  MB-9589: handle incomplete cluster leave

Conflicts:
	src/ns_single_vbucket_mover.erl

Change-Id: I80fc15ecbabc1c33ffa802bb1f8f1ea940234bcd