hibernate idle xmem processes

Change-Id: I07e4dbbc40cb38e3068566a13c470995d0798d15
Reviewed-on: http://review.couchbase.org/30359
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Junyi Xie <junyi.couchbase@gmail.com>
MB-100: copy couch_api_wrap* to ns_server

Because we'll need to change it possibly heavily in order to support
xdcr-over-ssl. And it's not really used in couchdb.

I plan to remove and all it's unused users from couchdb in one of
subsequent commits

Change-Id: I46d487ed0b212d6534ebefa66a5b9b193eb18ee7
Reviewed-on: http://review.couchbase.org/30346
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
introduced xdc_lhttpc_pool for all our lhttpc connections

Previously every single instance of couch_api_wrap database we've used
was creating it's own separate http connections pool.

It can be easily seen how it causes tons of sockets in TIMED_WAIT
state. I.e. due to connections frequently opened/closed.

xdc_lhttpc_pool is a central pool of connections that solves
TIMED_WAIT problem. And moves us closer towards supporting
xdcr-over-ssl proxy.

Change-Id: If554588220cad208054ccd07341398428e12f017
Reviewed-on: http://review.couchbase.org/30347
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
use proc_lib to spawn slow_updater of ns_heart

I.e. so that if it dies we have some diagnostics

Change-Id: I73b721a2e1a561a4ee1e49a663540414a8cf5ac4
Reviewed-on: http://review.couchbase.org/30349
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
crash ns_heart if it's slow_updater child dies

Change-Id: I92c2740770f5b1f1ba76f14ec47a5ddd10fa8abf
Reviewed-on: http://review.couchbase.org/30350
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Artem Stemkovski <artem@couchbase.com>
shutdown ns_heart slow_updater in terminate

I.e. so that if ns_heart crashes it's restarted instance will not have
problems spawning slow_updater child and registering it's name

Change-Id: I6feec959f4e8e521baad39da3ebc63059078fa8e
fixed ns_heart crash caused by wrong format string

Change-Id: I1769d7397dad7ce9f72f53f2a9dfb25a6df413e6
Reviewed-on: http://review.couchbase.org/30352
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Artem Stemkovski <artem@couchbase.com>
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>