Hash Trees for use in Cluster Metadata

hashtree_tree implements a data structure for efficiently determining
the differences between keys in two different stores. Unlike hashtree,
which this module is based on, keys can be logically grouped such that
differences found include missing groups as well as which groups the
differing or missing keys belong to.

This commit copies hashtree.erl from riak_kv (it will be removed in
that repo). In addition, it adds a (temporary) dependency on eleveldb,
which is used by hashtree.erl. hashtree_tree is intended to be used
ephermerally (although there is no reason it cannot be persistent) but
hashtree must first be extended to have pluggable backends.
Add Prefix Iterators to Metadata Manager

These iterators are necessary to build hashtrees and
repair divergent or missing full-prefixes
Cluster Metadata: Track Local Changes w/ hashtree_tree

Use hashtree_tree to store hashes for data in
riak_core_metadata_manager.  The tree is managed by
riak_core_metadata_hashtree. Hashes are inserted into the tree,
synchronously (for now) by metadata manager in the write path. In
addition, metadata_hashtree builds the tree with hashes for data
already stored on disk (ensuring not to trample new updates in the
process). Once the tree is built, it is periodically updated. Minus
the periodic update, the metadata_hashtree process is akin to
riak_kv_index_hashtree in Riak's AAE subsystem.

The API to access hashes is exposed via riak_core_metadata:prefix_hash/1.
Add Remote Iterators to Metadata Manager

Iterating from a node other than the one running the metadata manager
was not possible, previously -- ets continuations cannot cross
nodes. This is intedended for use in repair after hashtree exchanges.

In addition, iterator_close/1 has been added. This is necessary to cleanup
remote iterators. For local iterators it is a no-op.

This API is not exposed via riak_core_metadata since the iterface is
primarly meant to be local.
Cluster Metadata Exchanges

Use metadata hashtrees between nodes to determine differences or
missing keys and (full-)prefixes. Repair using metadata manager's
merge function (an additional version has been added to merge remotely).
The metadadata_exchange_fsm is the managing process.

NOTE: currently exchanges are not "plugged in" anywhere. They are not
started automatically. This commit simply implements the determination
of differences and the repair of those differences.
add metadata hashtree modules to .app
Add General Exchanges to riak_core_broadcast

to ensure at-once delivery riak_core_broadcast must periodically
trigger full exchanges between two nodes. Since riak_core_broadcast is
meant to be general and can be used by multiple sub-systems
simultaneously, the definition of "exchange" is losesly
defined. Broadcast, now, simply takes a list of modules that will
broadcast messages (this list is not, yet?, checked on broadcast) and
periodically asks them to exchange with a peer.  An exchange may
involve database shipping or exchanges and repair using hashtrees --
as is done for riak_core_metadata_manager in this commit.
copy in hashtree docs & eqc

these were originally in riak_kv. since hashtree.erl is now
in riak_core these should be here too
Make Broadcast/Cluster Meta Exchanges more robust

* better process failure handling
* monitor exchanges from broadcast process
* don't link exchange fsm
cleanup metadata hashtrees on open

in the case that riak crashes, cluster metadata's hashtrees
may not be properly cleaned up. because we only want them for the lifetime
of a running node, we destroy the trees on open and then re-open them. Not
exactly ideal, but quick and easy.
whitespace cleanup in cluster metadata code
add simple logging to metadata exchange fsm
More Metadata Iterator Improvements

* Use safe_fixtable/2 for iterators that do first/next traversal of
ets tables
* Open iterators inside the calling process. this allows iterators to
take advantage of monitoring built into ets for processes using
safe_fixtable/2 and possibly select/match_object depending on
the implementation of ets. In addition, this prevents serialization through
the metadata manager.
* Closing iterators is now mandatory for all iterator types. when an iterator,
using select/match_object has been closed that has not been fully iterated,
closing the iterator will complete the iteration. This is a definisive measure
since its is unclear if this is necessary from the ets documentation.
* Processes using remote iterators are monitored. On death, their iterators are
closed.
Fix Some Metadata Exchange Bugs

* properly merge local object with remote node
* handle missing remote object on reconcile
add module documentation for metadata hashtree mods
update hashtree app env calls

try to get application env from riak_kv and if it doesn't exist
fallback to riak_core and then the default values. this is to ensure
upgrades do not lose settings specified in riak_kv.
hashtree_tree: better cleanup before creating node

extends hashtree:destroy to take a path and pass it directly to
eleveldb
prevent leakage of hsahtree_tree snaphots

delete the ets data if its still valid, catch the error otherwise
change metadata manager/hashtree to use infinity timeouts
link hashtree update proc to metadata_hashtree

otherwise the caller is not notified of its crash and waits
infinitely