brooklyn-dev mailing list archives

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

    https://github.com/apache/incubator-brooklyn/pull/221#discussion_r18508051
  
    --- 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);
             }
         }
     
         protected void addServer(Entity serverToAdd) {
             Preconditions.checkNotNull(serverToAdd);
    +        if (serverToAdd.equals(getPrimaryNode())) {
    +            // no need to add; but we pass it in anyway because it makes the calling
logic easier
    +            return;
    +        }
             if (!isMemberInCluster(serverToAdd)) {
                 HostAndPort webAdmin = BrooklynAccessUtils.getBrooklynAccessibleAddress(serverToAdd,
serverToAdd.getAttribute(CouchbaseNode.COUCHBASE_WEB_ADMIN_PORT));
                 String username = serverToAdd.getConfig(CouchbaseNode.COUCHBASE_ADMIN_USERNAME);
                 String password = serverToAdd.getConfig(CouchbaseNode.COUCHBASE_ADMIN_PASSWORD);
     
                 if (isClusterInitialized()) {
    -                Entities.invokeEffectorWithArgs(this, getPrimaryNode(), CouchbaseNode.SERVER_ADD_AND_REBALANCE,
webAdmin.toString(), username, password);
    +                Entities.invokeEffectorWithArgs(this, getPrimaryNode(), CouchbaseNode.SERVER_ADD_AND_REBALANCE,
webAdmin.toString(), username, password).getUnchecked();
    --- End diff --
    
    no reason - i'm just fixing a bug where we already assumed the call had finished before
progressing, went with the minimal change.


---
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