brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: add support for configuring couch...
Date Tue, 07 Oct 2014 09:06:33 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/221#discussion_r18507791
  
    --- Diff: software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java
---
    @@ -397,30 +414,60 @@ public boolean isQuorate(int sizeHealthy, int totalSize) {
         
         protected void addServers(Set<Entity> serversToAdd) {
             Preconditions.checkNotNull(serversToAdd);
    -        for (Entity e : serversToAdd) {
    -            if (!isMemberInCluster(e)) {
    -                addServer(e);
    -            }
    +        for (Entity s : serversToAdd) {
    +            addServerSeveralTimes(s, 12, Duration.TEN_SECONDS);
    +        }
    +    }
    +
    +    /** try adding in a loop because we are seeing spurious port failures in AWS */
    +    protected void addServerSeveralTimes(Entity s, int numAttempts, Duration delayOnFailure)
{
    +        try {
    +            addServer(s);
    +        } catch (Exception e) {
    +            Exceptions.propagateIfFatal(e);
    +            if (numAttempts<=0) throw Exceptions.propagate(e);
    +            // retry once after sleep because we are getting some odd primary-change
events
    +            log.warn("Error adding "+s+" to "+this+", "+numAttempts+" more attempts;
will retry after delay ("+e+")");
    +            Time.sleep(delayOnFailure);
    +            addServerSeveralTimes(s, numAttempts-1, delayOnFailure);
    --- End diff --
    
    Personal preference: instead of recursive, I'd have gone for a loop. Then the final exception
could be a composite exception of all the failures, and the top-level message could include
the number of attempts made. But no strong feelings.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message