os: KeyValueDB: create whole-space iterator and snapshot iterator

In-a-nutshell-version:
  1) Create a whole-space iterator interface, and implement the already
     existing, prefix-based iterator in terms of the new whole-space
     iterator;
  2) Add support for snapshot iterators.

This patch introduces a significant change on the architecture of
KeyValueDB's iterator, although its interface remains the same.

Before this patch, the KeyValueDB simply defined an interface for a
prefix-based interface, to be implemented by derivative classes. Being
constrained by a prefix-based approach to iterate over the store only makes
sense when we know which prefixes we want to iterate over, but for that we
must know about the prefixes beforehand. This approach didn't work when one
wanted to iterate over the whole key space, without any previous awareness
about the keys and their prefixes.

This patch introduces a new interface for a whole-space iterator, to be
implemented by derivative classes, which is prefix-independent. We also
define an abstract function to obtain this iterator, which must also be
implemented by the derivative class. With this interface in place, we are
then able to implement a prefix-dependent iterator in terms of the
whole-space iterator, which will be offered by the KeyValueDB class itself.

Furthermore, we also introduce support for a snapshot iterator. The task
of implementing such iterator is delegated to any derivative class.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
os: LevelDBStore: Implement whole-space and snapshot iterators

Following the changes to KeyValueDB, we get rid of the previous,
prefix-dependent iterator implementation, and we create a whole-space
iterator for a leveldb k/v store. We also add a snapshot iterator that
relies on the said whole-space iterator.

This snapshot iterator relies on leveldb's snapshots, and is intended as
a thread-safe iterator for those occasions when preventing concurrent
modification is not an option.

For instance, we need to iterate over a known, consistent store state
during monitor synchronization, while allowing updates to be performed for
Paxos sake -- and that means both insertion and removal of keys, which
could be, at best, problematic or simply bear unforeseen issues that could
ultimately only be seen during full-fledged concurrent accesses to the
store.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
test: KeyValueDBMemory: implement whole-space and snapshot iterators

Following the changes in KeyValueDB, this patch removes the in-memory,
prefix-dependent iterator and make it a whole-space iterator instead. We
also add a snapshot iterator based on the said whole-space iterator.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
test: KeyValueDBMemory: remove prefix when it runs out of keys

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
test: test_keyvaluedb_iterators: Test KeyValueDB implementations iterators

Such as KeyValueDBMemory's and LevelDBStore's whole-space iterators,
along with the snapshot version of each one.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
Makefile.am: add test_keyvaluedb_iterators to the build

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>