MB-9343 upgrading bucket from tap to upr

- there are 2 types of upgrades: trivial and nontrivial.

- trivial is simply an upgrade of repl_type and is performed for
  buckets which do not have any replications.

- nontrivial is performed sequentially per vbucket after the
  rebalance. for each vbucket it will shutdown tap streams,
  setup upr streams and wait for the data move to happen

- the replication status at the beginning of the upgrade is
  equal to tap. at the end it is equal to upr. in the middle
  of the upgrade it will be set to {upr, RemainingTapPartitions}
  for each upgraded partition thus allowing the restart of
  the upgrade in case if it was stopped or failed

- partitions are upgraded sequentially for each master node.
  partitions for with different master nodes are upgraded in
  parallel

Change-Id: Ibd8bb7c914f7812cbcba0a4504e05d8f083fb137
Reviewed-on: http://review.couchbase.org/33548
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-9343 make replication_manager and upr_replicator to sync-shutdown

...their children on terminate

Change-Id: Ic904b252899d6b58e2a0d0379c7c5c2bd2cd97f1
Reviewed-on: http://review.couchbase.org/33973
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-9343 correctly close stream before the takeover

... so the replicator is aware of it and doesn't try to reopen
it again

Change-Id: I86607aef098a61dbb4136f72258c63c73a3c498d
Reviewed-on: http://review.couchbase.org/34129
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>