MB-8495 Increase docs_total estimate when docs_left increases.

It does not fix the root cause of the referenced bug. There we just
happened to see CHECKPOINT_START/CHECKPOINT_END messages. But since
it still seems to be possible to hit the same issue when there're
mutations going on during rebalance, I decided to make this fix.

Change-Id: Ic6b3ad28806ce1f353ca98882372b75e7930caf4
Reviewed-on: http://review.couchbase.org/28275
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5904 - change ns_config format of rouser credentials

from {"user","password"} to {"user", {password, "password"}}
so existing sanitization works for this password too

otherwise I will have to write special handling
for messages like this one:

config change:
read_only_user_creds ->
{"ruser","asdfghytr"}

Change-Id: Ie8e7892fca077f7f54abbee027234b3b939136d3
[alk@tut.by: fixed no-auth case]
Signed-off-by: Aliaksey Kandratsenka <alk@tut.by>
Reviewed-on: http://review.couchbase.org/28270
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-8801 ability to specify the password in cbreset_password

also:
- removed duplicate password validation code
- moved reset_admin_password to menelaus_web to reuse the validation code

Change-Id: I15015b934b4e82a3cdc4c1fc182a84b04328f6cd
Reviewed-on: http://review.couchbase.org/28238
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-5904 remove passwords from xdc status logging

Change-Id: I5a02b6c8a841176cb837dc6e1f01559b7a82e24f
Reviewed-on: http://review.couchbase.org/28277
Tested-by: Artem Stemkovski <artem@couchbase.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
MB-100: removed dead sasl password validation code

Change-Id: I8b18943423be1d65bc3718d3e88bcc6da035cc7e
Reviewed-on: http://review.couchbase.org/28305
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Artem Stemkovski <artem@couchbase.com>
MB-8731: disallow non-utf8 passwords

Because otherwise they cannot be sent over json

Change-Id: I53241a20d3426932f9edd248dd1503939522fa3c
Reviewed-on: http://review.couchbase.org/28306
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Artem Stemkovski <artem@couchbase.com>
MB-8787 Use correct parameter in get_replication_batch_size().

worker_batch_size is the batch size in items not in kilobytes.

Change-Id: Id4b0a5ce24dc1de304ad5fe664cd0a0a93f63f59
Reviewed-on: http://review.couchbase.org/28161
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Remove useless function.

It didn't do what it stated in it's name. And what it actually did is
already done by ensure_rep_db_exists called from changes_feed_loop.

Change-Id: Ie7c146427ab78cc6607ad30c48e9cffe372fae90
Reviewed-on: http://review.couchbase.org/28163
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Make xdcr logging don't repeat itself.

Change-Id: I9ee6b338db022d8ffeaf54f22d19291955e95b50
Reviewed-on: http://review.couchbase.org/28315
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Always grab options for databases from rep document.

Change-Id: Ib442302a2e5e8be51ff33588ce3ada760dbf65b7
Reviewed-on: http://review.couchbase.org/28165
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Don't parse fields that we never put to rep document.

Or those that are not actually read.

Change-Id: If18397f786a789eac770437943884c3b29d80f53
Reviewed-on: http://review.couchbase.org/28166
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Don't use couch_config where it makes no sense.

Particularly:
  1. don't ask for replicator db name because in many places we just
  assume its name is _replicator anyway
  2. currently our replications are always continuous and xdcr code
  doesn't even bother to check the value of 'continuous' parameter; so
  I got rid of it too

Change-Id: I6ceb802329bb678c435c51706784ef5c904cefe1
Reviewed-on: http://review.couchbase.org/28167
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Remove dump_parameters.

Parameters can be changed dynamically so it doesn't make sense to dump
them only once on xdc_rep_manager start.

Besides, all the #rep records are going to have a complete list of
parameters for the replication. And whenever replication gets
started, this record will be logged by standard erlang mechanisms.

Change-Id: I3b8f103960da708528050bebd59dc9566e0d8eeb
Reviewed-on: http://review.couchbase.org/28168
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Name global parameters similarly to the per rep ones.

To avoid additional confusion.

Change-Id: Ibab7c02a3cff6bff1a85228bb4b723557ebb5464
Reviewed-on: http://review.couchbase.org/28169
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-8663 Let users choose between xmem/capi replications.

I just added 'type' parameter to the ones understood by
createReplication REST endpoint. Valid values are capi and xmem. They
translate to type=xdc and type=xdc-xmem in replicator document
correspondingly.

Change-Id: Iacacd51d7525cf9c66259bcce72037eedd1667cd
Reviewed-on: http://review.couchbase.org/28170
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-8663 Use type from replicator document to decide on rep mode.

Change-Id: Ia856cdbacfefc25179e8d26af7083a6a94a626ee
Reviewed-on: http://review.couchbase.org/28171
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-8663 Expose replication type in xdcr task.

Change-Id: I55f11c066d6916a8a588287d2c4b79a53eed0163
Reviewed-on: http://review.couchbase.org/28172
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Don't torture ns_config for every single replicated doc.

Change-Id: I39745fcb32725356955c8abde05e38691e1602f2
Reviewed-on: http://review.couchbase.org/28173
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-8787 Account for worker_batch_size parameter too.

Change-Id: If22de82cbe3254680def894ff2fdd7c26cd40634
Reviewed-on: http://review.couchbase.org/28174
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
MB-100 Add xdc_rdoc_replication_srv:get_full_replicator_doc.

It returns a replicator document by id. Contrary to
find_all_replication_docs it doesn't strip any fields from the
document body and ensures that the field names are binaries.

Change-Id: I6e7b95332a5d332e50b29550d16d009e37978bc8
Reviewed-on: http://review.couchbase.org/28176
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>