MB-5323: increased ebucketmigrator connection timeout

Because I see no good reason why it needs to be as low as 5 seconds
(even though it's huge by machine's terms). We've seen some
virtualization environments causing even greater latencies. Plus under
heavy IO load page faults can sometimes cause comparable latencies
even under "proper" hardware.

Change-Id: Ic32476cec36530d2329ffb997536e37ecd7e9b81
Reviewed-on: http://review.couchbase.org/16199
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5307: renamed vbucket_mover_start to vbucket_move_start

For consistency with vbucket_move_done. Also renamed {old,new}Chain to
chain{Before,After} for consistency with map update events.

Change-Id: I312ffa11c7bbfaeeff846b320866e2ffd2fda6ea
Reviewed-on: http://review.couchbase.org/16163
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: disallow "after" remote master events to overtake local

I've see that some remote events that happen strictly after some local
event (i.e. stop replication on remote node versus start vbucket mover
on master) are observed before that local event, breaking causality
and making some analyzes harder.

This seemingly happens because any master event (even local) needs to
pass through it's node's "master event submitting" work queue before
getting into master events ingress queue on master node. And
apparently because master events are more frequent on master node,
some of them need more time to get to ingress queue. Allowing "after"
but "faster" remote events to overtake them.

The fix is to have ingress queue listener to double as master events
submitter. It'll check if it's node is master node and if it is it
will bypass extra queuing step (which will be to it's own queue
anyways). If it's not, it'll pass event to ingress queue on remote
master node.

So for any master event that will cause some remote event, it's now
seemingly impossible for remote event to overtake master node's event
that produced it. I.e. because master node's event is strictly prior
to remote event it will be queued before to it's ingress queue before
remote event. And thus will be fully processed before remote event.

Change-Id: I7607944b9bf47cd670aa179ad56c77d6e5e7e96d
Reviewed-on: http://review.couchbase.org/16164
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: don't place extra quote around master events atoms

Change-Id: Icf968787b9de3bcdf42ec8981e68a000815ba278
Reviewed-on: http://review.couchbase.org/16165
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: made ebucketmigrator terminate event dump migrator args

We now have dedicated process that keeps eye on all interesting
process and sends out configured master event when some of them dies
with vital details such as Pid and most importantly Reason.

Change-Id: I7f3c39537b6eae7a793b0a2d44626a0a573b674c
Reviewed-on: http://review.couchbase.org/16166
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: added master activity event for death of vbucket mover

Change-Id: I249c7b34f6b6786579e3e3b7da782d6f04b45d2f
Reviewed-on: http://review.couchbase.org/16167
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: don't stop master events streaming on unknown event

Sending empty chunk is 'end-of-response' signal. And unknown event is
formatted as empty list. Thus we need to be careful not to send empty
chunk when this happens.

Change-Id: I1abbc27d53be0aefdb8810169235d5b1f6f46899
Reviewed-on: http://review.couchbase.org/16168
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: send out master activity event for vbucket filter change

Change-Id: Ic7f1ded2abf601d027ea11805afbc5a038cc81bc
Reviewed-on: http://review.couchbase.org/16169
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: implemented better observing for rebalance end event

I.e. via that newer observe_fate_of facility.

Change-Id: If0ded9135c56cda631d99d39445519fc252e9996
Reviewed-on: http://review.couchbase.org/16170
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: added master events for per-bucket rebalance start/end

Change-Id: Ib3d4a174ffa7e829f1116755ba15cc509a97e2a1
Reviewed-on: http://review.couchbase.org/16171
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: implemented master event for per bucket failover

Change-Id: I65957cd92d73d37b2822f6e712aa1ab5920adb1f
Reviewed-on: http://review.couchbase.org/16172
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: unregister tap name even of not vbuckets are ready

Previously it was possible that tap is not supposed to be reused _but_
has no vbuckets ready. So deregister_tap_client would not be sent,
then vbucket filter change arrives and we are supposedly reusing tap,
but intention is to reuse tap from previous instance and not from some
unknown source.

Change-Id: Ie590973193bfb152f7978395b502637efdf460d8
Reviewed-on: http://review.couchbase.org/16173
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: prevent vbucket filter change socket to be used twice

It's not normally possible, but just in case lets prevent it.

If for some reason get_downstream is requested by multiple processes,
previous implementation would give that same(!) downstream to all of
them. Potentially causing even more confusing bug.

Change-Id: I388b505d2f801e336f0573f26507ad99d790c32e
Reviewed-on: http://review.couchbase.org/16174
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: updated master event docs for new event types

Change-Id: I6b1c1b6c100b967761ad041363018977741c9efb
Reviewed-on: http://review.couchbase.org/16175
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-5307: added documentation for ns_server supervisor hierarchy

Change-Id: Ibf4c661e07e2ed46e158618de8c10627dec75ab0
Reviewed-on: http://review.couchbase.org/16208
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Merge remote-tracking branch 'origin/branch-181' into branch-18

* origin/branch-181:
  MB-5307: added documentation for ns_server supervisor hierarchy
  MB-5307: updated master event docs for new event types
  MB-5307: prevent vbucket filter change socket to be used twice
  MB-5307: unregister tap name even of not vbuckets are ready
  MB-5307: implemented master event for per bucket failover
  MB-5307: added master events for per-bucket rebalance start/end
  MB-5307: implemented better observing for rebalance end event
  MB-5307: send out master activity event for vbucket filter change
  MB-5307: don't stop master events streaming on unknown event
  MB-5307: added master activity event for death of vbucket mover
  MB-5307: made ebucketmigrator terminate event dump migrator args
  MB-5307: don't place extra quote around master events atoms
  MB-5307: disallow "after" remote master events to overtake local
  MB-5307: renamed vbucket_mover_start to vbucket_move_start
  MB-5323: increased ebucketmigrator connection timeout

Conflicts:
	src/ns_vbm_sup.erl

Change-Id: Id042b04266ec407c3956ccb56076545af6a0f456
Merge remote-tracking branch 'origin/branch-18' into merge

* origin/branch-18:
  MB-5307: added documentation for ns_server supervisor hierarchy
  MB-5307: updated master event docs for new event types
  MB-5307: prevent vbucket filter change socket to be used twice
  MB-5307: unregister tap name even of not vbuckets are ready
  MB-5307: implemented master event for per bucket failover
  MB-5307: added master events for per-bucket rebalance start/end
  MB-5307: implemented better observing for rebalance end event
  MB-5307: send out master activity event for vbucket filter change
  MB-5307: don't stop master events streaming on unknown event
  MB-5307: added master activity event for death of vbucket mover
  MB-5307: made ebucketmigrator terminate event dump migrator args
  MB-5307: don't place extra quote around master events atoms
  MB-5307: disallow "after" remote master events to overtake local
  MB-5307: renamed vbucket_mover_start to vbucket_move_start
  MB-5323: increased ebucketmigrator connection timeout

Change-Id: I6c36fc8c0cafb42827bcf4b922fb4aa402dc12c8