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>
MB-100 extract reusable part of test-groups.rb to a separate file

... to be able to use in other tests

Change-Id: I9ee3b601e71f293384a73e121de9d62d8296d9a6
Reviewed-on: http://review.couchbase.org/30461
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100 fix for one more cluster_compat_mode related crash

- ns_config_ets_dup is still raceful (needs to be addressed
  separately)
- cluster_compat_version key is also raceful at the initial server
  start
- cluster_compat_version value is defaulted to 'undefined'
  which crashes ++ operator if called too early

Change-Id: Ied9a6ce2eae1b5ccad922d90a3ea4ef81dc50dfb
Reviewed-on: http://review.couchbase.org/30369
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@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-100 automated test for replication

- known problem with this test: it goes into infinite loop
  if the replication is not working. I'll add timeout later

Change-Id: I4e1048b3b3d3a6a54344eda51e940c3eff8547cf
Reviewed-on: http://review.couchbase.org/30498
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Artem Stemkovski <artem@couchbase.com>
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>
MB-9567 adopt new getRandomKey functionality of ep-engine

Change-Id: If076ce6136e1a3b717fa0f7eaa45b5eb69ff1725
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