Add start of SnapshotFile to assist in reading/writing snapshots
Add methods to Tree to dump/load its state for snapshotting
Add truncatePrefix operation to Log

This isn't called from anywhere yet but will be needed after
snapshotting.

Also changed metadata block in SimpleFileLog from a list of entries to a
start and end entry (range). This is the more sane representation now
that I know there won't be any gaps.
Make the state machine take a snapshot after every entry

Just a stepping stone -- a lot of TODOs added in this commit.
Change smoketest to clear out existing snapshots

Also add an assertion to initlog.py to check for existing snapshots
Change SnapshotFile::Reader to throw an exception if the file is not found
Add reading/writing of snapshots to consensus module

Two things are missing for this to be useful:
 - Need to prevent the consensus module from accessing discarded log
   entries (none can be discarded now as a result)
 - Need to write the configuration into the snapshot
Load/store cluster membership configurations in snapshots

This adds a new configurationDescriptions map, which contains a copy of
all the configurations in the log and usually one configuration from the
latest snapshot.
Place logs and snapshots under storagePath (from config file)

This is the right long-term approach and makes it easier to create
temporary directories for testing.
Change FilesystemUtil, Checksum lengths to uint64_t

Was uint32_t before, but that may not be large enough for snapshots. I'm
not sure why I was stingy about these before.
Change the way SnapshotFiles get saved

Now SnapshotFile::Writer writes to a temporary file. On save(), it
atomically overwrites the good snapshot, while on discard() it throws
this file away.

Discard is needed in case a follower gets a new snapshot from a leader
while its state machine produces a stale snapshot.
Add transferring of snapshots from leader to stale follower

This adds a new RPC called AppendSnapshotChunk. It's similar in a lot of
ways to AppendEntries.
Remove RaftLog::getTerm(), fix unsafe getEntry calls

This was making me a bit nervous, since it just returned 0 when the
entry you asked for wasn't part of your log. With snapshots, that gets a
little scary. The alternative now is to call getEntry(index).term(),
which will throw an exception if the entry isn't found.

All RaftLog::getEntry() calls should now be safe even if a prefix is
truncated after a snapshot.
Add last included term to snapshots

Before the code assumed the log always overlapped with the snapshot
in the last entry, so all terms could come from the log. Unfortunately
that doesn't really make sense, since for example with a new follower,
you have to send a snapshot first, then send log entries (to satisfy the
consistency check).

So instead, snapshot headers now include the term of the last entry they
cover, and this term is used throughout the code.
Add ConfigurationManager class

This class basically shadows the configurations found in the log and
latest snapshot, and sets the current configuration accordingly. Making
this a separate class cleans up this logic that was previously scattered
throughout the consensus code, makes it testable and more efficient, and
should make it easier to truncate prefixes from the log.
Fix wedge in upToDateLeader() when log prefixes are discarded

The problem occurred before if a snapshot was taken covering the entire
log, then the entire log was discarded. In that case, because the method
didn't consult lastSnapshotTerm, it couldn't tell that the term of the
commitIndex entry was its current term, so upToDateLeader was stuck in
an infinite sleep.
Discard log prefixes when redundant with the server's snapshot
Have state machine decide when to snapshot

Adds getSnapshotStats method to Consensus, which provides a bunch of
information up to the state machine, and adds a simple heuristic to the
state machine to decide when to snapshot.
smoketest: Add environment variable to easily wrap servers

This is useful to run the servers through programs like valgrind for
debugging or eatmydata for performance.
Extend SnapshotFile to support forking

This paves the way for child processes to safely write to the snapshot
file and then return to the parent.