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

Perhaps we could use serializeStream() instead to avoid relying on a ByteBuffer's array()?