Add support of snapshots to the Raft implementation.

Now the implementation truncates too long log and saves state of state machine to snapshots.