brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorbett <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Add all.members.up sensor to Dyna...
Date Fri, 20 Nov 2015 10:38:44 GMT
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1050#discussion_r45455633
  
    --- Diff: core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
---
    @@ -181,6 +189,34 @@ private void initialiseMemberId() {
             }
         }
     
    +    private void connectAllMembersUp() {
    +        allMembersUp = FunctionFeed.builder()
    +                .entity(this)
    +                .period(Duration.FIVE_SECONDS)
    +                .poll(new FunctionPollConfig<Boolean, Boolean>(ALL_MEMBERS_UP)
    +                        .onException(Functions.constant(Boolean.FALSE))
    +                        .callable(new AllMembersUpCallable()))
    +                .build();
    +    }
    +
    +    private class AllMembersUpCallable implements Callable<Boolean> {
    +
    +        @Override
    +        public Boolean call() throws Exception {
    +            if (DynamicClusterImpl.this.getMembers().isEmpty())
    +                return false;
    +
    +            if (Lifecycle.RUNNING != DynamicClusterImpl.this.sensors().get(SERVICE_STATE_ACTUAL))
    +                return false;
    +
    +            for (Entity member : DynamicClusterImpl.this.getMembers())
    +                if (Boolean.FALSE.equals(member.sensors().get(SERVICE_UP)))
    --- End diff --
    
    The callable is named `AllMembersUp` but this is checking that all members are not not
up. It will return true if a member's `SERVICE_UP` is null. I think you should swap the if
condition for `if (!Boolean.TRUE.equals(...))`.


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