Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/894#discussion_r39422861
--- Diff:
software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBClientSupport.java
---
@@ -96,12 +111,18 @@ private HostAndPort getServerHostAndPort() {
MongoClient client = client();
try {
DB db = client.getDB(database);
- CommandResult status;
- try {
- status = db.command(command);
- } catch (MongoException e) {
- LOG.warn("Command " + command + " on " +
getServerAddress() + " failed", e);
- return Optional.absent();
+ CommandResult status = null;
+ // The mongoDB client can occasionally fail to connect. Try up
to 5 times to run the command
+ for (int i = 0; i < 5; i++) {
--- End diff --
Would a `Repeater` be of any use? It allows you to give backoffs, etc. It's
a cleaner way of expressing this block.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---