reconnect to mongodb on connection failure

Try to reconnect to mongodb when the client library raised a
ConnectionFailure error. This is especially useful when mongodb is in
the process of initializing a replica set and it does not respond to
connections even though the mongodb service is up.

Change-Id: I1818d90c135b248a28b35dc0b9f6106cf89496ab
Closes-Bug: #1305920
Merge "reconnect to mongodb on connection failure"