SPARK-1830 Deploy failover, Make Persistence engine and LeaderAgent Pluggable.

Refactored Leader Election agent and added a RecoveryModeFactory.

Implemented new proposal with some convenient modifications.

Added a read method.
Code review