You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by aledsage <gi...@git.apache.org> on 2014/10/07 10:46:21 UTC

[GitHub] incubator-brooklyn pull request: add support for configuring couch...

Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/221#discussion_r18507023
  
    --- 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();
                 } else {
    -                Entities.invokeEffectorWithArgs(this, getPrimaryNode(), CouchbaseNode.SERVER_ADD, webAdmin.toString(), username, password);
    +                Entities.invokeEffectorWithArgs(this, getPrimaryNode(), CouchbaseNode.SERVER_ADD, webAdmin.toString(), username, password).getUnchecked();
                 }
                 //FIXME check feedback of whether the server was added.
                 ((EntityInternal) serverToAdd).setAttribute(CouchbaseNode.IS_IN_CLUSTER, true);
             }
         }
     
    +    /** finds the cluster name specified for a node or a cluster, 
    +     * using {@link CouchbaseCluster#CLUSTER_NAME} or falling back to the cluster (or node) ID. */
    +    public static String getClusterName(Entity node) {
    +        String name = node.getConfig(CLUSTER_NAME);
    +        if (!Strings.isBlank(name)) return Strings.makeValidFilename(name);
    +        return getCluster(node).getId();
    --- End diff --
    
    Why isn't this calling `getCluster().getConfig(CLUSTER_NAME)`? i.e. the cluster's name rather than the cluster's id.


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