MB-12067 [3/6]: Unit test for degragmenter task

Basic smoketest for the defragmenter: Create a number of documents,
spanning at least two or more pages, then delete most (but not all) of
them - crucially ensure that one document from each page is still
present. This will result in the rest of that page being
'wasted'. Then verify that after defragmentation the actual memory
usage drops down to (close to) mem_used.

Change-Id: Ibfe8780fb02ad5eb504242b01e7583bc1e305184
Reviewed-on: http://review.couchbase.org/41496
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Dave Rigby <daver@couchbase.com>
MB-12067 [4/6]: Add age field to Blob; use as part of defragmenter policy

When a Blob object is allocated record the current 'age' of it. The
age is incremented when the runs, allowing us to measure how many
defragmenter passes have occurred, and consequently can be used by the
defragmenter to select Blob objects which have been in existance (and
haven't changed size) for a long period, and hence are candiates for
defragmentation.

Change-Id: I6380e6601ae5ee86ca630031e4edea9711a88433
Reviewed-on: http://review.couchbase.org/41497
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Dave Rigby <daver@couchbase.com>
MB-12067 [5/6]: pause/resume visitor support for epStore & HashTable

Add new visiting methods to HashTable and EventuallyPersistentStore to
allow a client to pause the visit at a particular position, and then
resume from approximately the same position at a later time.

The methods operate in a similar way to the existing visit() /
visitDepth() methods, with the addition of a start_pos parameter to
specify where to start at, and returning the position the visitation
got to.

Clients would typically call pauseResumeVisit() with a default
Position initially (to start from the beginning), and then when they
want to pause they return false from their visit() method.

Change-Id: I2542efc165e3200f0cc74d8120a16e2175f1341d
Reviewed-on: http://review.couchbase.org/41498
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Dave Rigby <daver@couchbase.com>
MB-12067 [6/6]: Use pause/resume visitor for defragmenter task

Expand the defragmenter to make use of the pause/resume visitor
methods on epStore & HashTable. This allows it to run for a
constrained period of time, pausing (and recording how far it got) if
it reaches its time limit. It can then resume from where it left off
at the next defragmentation internatl.

Change-Id: I82520aa907bb386f9c55fc7e92ac5338bf862cdf
Reviewed-on: http://review.couchbase.org/41499
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Dave Rigby <daver@couchbase.com>
MB-12067: Add additional defragmenter_num_visited stat

Records how many items have been visited (considered for
defragmentation). Useful to measure this against
defragmenter_num_moved.

Change-Id: I56f3509645349b0ef482afcb9b68c3049154143b
Reviewed-on: http://review.couchbase.org/43052
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Dave Rigby <daver@couchbase.com>
MB-12067: Allow runtime adjustment of defrag params

Allow defragmenter_{interval,age_threshold,chunk_duration} to be
adjusted at runtime, to assist in tuning sensible defaults.

Change-Id: Ifc5a1cd845cebb844d13f7f4fc2264630ad7c0fc
Reviewed-on: http://review.couchbase.org/43053
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Dave Rigby <daver@couchbase.com>