Merge branch 'for-rackaware'

* for-rackaware:
  MB-9209: fix unbounded worker stats dictionary

Trivial merge

Change-Id: I7b0f363d8faf4f029c4e5340101b543f060791b1
MB-100: implemented ns_config:run_txn

Which implements optimistic transactions on top of cas_config. And
thus avoids running arbitrary and potentially dangerous code inside
ns_server.

Change-Id: I59bf6a192baad4a6c6f370a381931111df81ec7c
Reviewed-on: http://review.couchbase.org/29865
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100: killed online config upgrade for xdcr settings

Which was never really working

Change-Id: I80baa22cb73d3a0c3d40bcd8ece6b08a20fcfb71
Reviewed-on: http://review.couchbase.org/29866
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Merge branch 'for-rackaware' (early part)

* 'for-rackaware' (early part):
  MB-100: implemented ns_config:run_txn

This is trivial merge

Change-Id: I457a2145ca2df50daf03f25891aadb567a804bc2
MB-1143: added server groups

Because removal of nodes requires removal of node from it's server
group I decided to create new compat mode: [2, 5].

Once all nodes are 2.5+ our node addition code becomes aware of server
groups. Node ejection code is always aware of it.

Change-Id: Ica7e6e0824c7e4b8decf4d3cfc81d64aaf21d2c8
Reviewed-on: http://review.couchbase.org/29867
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-1143: added REST API for server groups

Change-Id: I11eb4a39445baaa15a05bb36390e1bffdb59e2dd
Reviewed-on: http://review.couchbase.org/29868
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-1143: refresh pool details on server group updates

I.e. so that ?v trick works

Change-Id: I46f6b9feb8f212aafc1238d1899a2f841bb10fd6
Reviewed-on: http://review.couchbase.org/29869
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-1143: added internal unittest for server groups API

Change-Id: I83d70fd86ceb75c1a5dbc277b64edce9530bd134
Reviewed-on: http://review.couchbase.org/29870
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-1143: added api doc for server groups REST API

Change-Id: Iabaaa4383568df4146808e312074f49873acab1e
Reviewed-on: http://review.couchbase.org/29873
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: corrected typespec for ns_cluster:do_complete_join

Somehow R14's dialyzer suddenly started seeing that obvious issue.

Change-Id: I4f300a6ba92b5b5254f38fd7b7f881ca9da32a96
Reviewed-on: http://review.couchbase.org/29879
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-1143: enable adding 2.5 nodes to 2.0 clusters

Change-Id: If58bc3a30a6b3a7ec6583af9806a0b320169e63a
Reviewed-on: http://review.couchbase.org/29880
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Revert "MB-9096: killed ns_online_config_upgrader"

This reverts commit 6c13b6f64379b21e83429c149d4399b7c486fcea.

It turns out 2.5 needs this back. In order to simplify merge it looks
worth reviving that guy.

In addition to simply reverting it, I've removed "on-join" config
upgrade and made it handle "upgrade" to 3.0.

Change-Id: Id2320ede37e6145008a35a22867421a29e83e46c
Reviewed-on: http://review.couchbase.org/29933
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Merge commit 'b0b286e3b25a80dd5631d923f4e2ea0323052463'

* commit 'b0b286e3b25a80dd5631d923f4e2ea0323052463':
  MB-1143: added server groups
  MB-100: killed online config upgrade for xdcr settings

Conflicts:
	src/cluster_compat_mode.erl
	src/ns_online_config_upgrader.erl

Change-Id: I6dc106a60fd68a6d34ea295bad25730b1017d6be
Merge branch 'for-rackaware'

* for-rackaware:
  MB-1143: enable adding 2.5 nodes to 2.0 clusters
  MB-100: corrected typespec for ns_cluster:do_complete_join
  MB-1143: added api doc for server groups REST API
  MB-1143: added internal unittest for server groups API
  MB-1143: refresh pool details on server group updates
  MB-1143: added REST API for server groups

Conflicts:
	src/menelaus_web.erl

Change-Id: Id478fe864f0b28448b1a4fc3e01e18ea148e6fcf
MB-100: actually make config upgrader work

Change-Id: If51fff197bd042f8accea9a2a06a1e6b5ed31e92
Reviewed-on: http://review.couchbase.org/29944
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100: cut unused config upgrade from 1.8.1 to 2.0

Change-Id: Ib4665c3364f5e56d65dd2528f385fc5aafc6a3ba
Reviewed-on: http://review.couchbase.org/29945
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-1143 Update vbmap.

Change-Id: I6a414c9b68bcb92843265a6396599d39eedf12f5
Reviewed-on: http://review.couchbase.org/29614
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-1143 Rack-aware vbucket map generation (replica count = 1).

Besides the limitation on number of replicas, if rack-aware vbucket
map couldn't be generated, then we fallback to rack-unaware vbucket
map generator. Eventually vbmap tool will learn how to find
approximate solutions.

Change-Id: I537d0987b147c75f5f93f7585595a67d26213fec
Reviewed-on: http://review.couchbase.org/29615
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-1143: use server groups for vbucket map generation

Change-Id: I9175dcb1fd5b2954b007f614049726e5af5f1fee
Reviewed-on: http://review.couchbase.org/29953
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Merge remote-tracking branch 'origin/for-rackaware'

* origin/for-rackaware:
  MB-1143: use server groups for vbucket map generation
  MB-1143 Rack-aware vbucket map generation (replica count = 1).
  MB-1143 Update vbmap.

Change-Id: I507293795369c8ae4952cc95767282197b26a111