brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <>
Subject [GitHub] incubator-brooklyn pull request: Add basic sensors to RedisCluster
Date Fri, 31 Jul 2015 23:51:22 GMT
Github user aledsage commented on a diff in the pull request:
    --- Diff: software/nosql/src/main/java/brooklyn/entity/nosql/redis/
    @@ -20,49 +20,73 @@
     import java.util.Collection;
    +import brooklyn.enricher.Enrichers;
     import brooklyn.entity.Entity;
     import brooklyn.entity.basic.AbstractEntity;
     import brooklyn.entity.basic.Entities;
     import brooklyn.entity.proxying.EntitySpec;
     import brooklyn.entity.trait.Startable;
    +import brooklyn.event.AttributeSensor;
    +import brooklyn.event.basic.Sensors;
     import brooklyn.location.Location;
     public class RedisClusterImpl extends AbstractEntity implements RedisCluster {
    -    protected RedisStore master;
    -    protected DynamicCluster slaves;
    +    private AttributeSensor<RedisStore> MASTER = Sensors.newSensor(RedisStore.class,
    +    private AttributeSensor<DynamicCluster> SLAVES = Sensors.newSensor(DynamicCluster.class,
         public RedisClusterImpl() {
         public RedisStore getMaster() {
    -        return master;
    +        return getAttribute(MASTER);
         public DynamicCluster getSlaves() {
    -        return slaves;
    +        return getAttribute(SLAVES);
         public void start(Collection<? extends Location> locations) {
    --- End diff --
    If you go down that road of setting starting/running, then I'd probably also separate
it out into the two methods - delegate to something like `doStart()` to actually invoke start
on the entities.
    I think you're free to instantiate the `slave` cluster before calling master.start. That
will mean the web-console will show the master + slaves in the tree immediately, rather than
waiting for the master to start before the cluster appears.
    You could also move the instantiation of the master + slave entities into init. Then you
wouldn't need to guard for null either (and don't need to call `Entities.manage()` when inside
init - on completion of init, any child entities will immediately get managed).

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

View raw message