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 2016/11/01 10:19:21 UTC

[GitHub] brooklyn-server pull request #390: BROOKLYN-356: fix race in transformer by ...

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

    https://github.com/apache/brooklyn-server/pull/390#discussion_r85903486
  
    --- Diff: camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java ---
    @@ -353,6 +386,33 @@ public DslSensorSupplier(DslComponent component, Object sensorIndicator) {
             }
     
             @Override
    +        public Maybe<Sensor<?>> getImmediately() {
    +            return getImmediately(sensorName, false);
    +        }
    +        
    +        protected Maybe<Sensor<?>> getImmediately(Object si, boolean resolved) {
    +            if (si instanceof Sensor) {
    +                return Maybe.<Sensor<?>>of((Sensor<?>)si);
    +            } else if (si instanceof String) {
    +                Entity targetEntity = component.get();
    +                Sensor<?> result = null;
    +                if (targetEntity!=null) {
    +                    result = targetEntity.getEntityType().getSensor((String)si);
    +                }
    +                if (result!=null) return Maybe.<Sensor<?>>of(result);
    +                return Maybe.<Sensor<?>>of(Sensors.newSensor(Object.class, (String)si));
    --- End diff --
    
    Not sure I follow. In `attributeWhenReady`, if we're given a sensor name then we will instantiate a new sensor object if it's not defined on the entity type; and then we look up the sensor's value (returning Maybe.absent if it's null). Here, we just want it to return the sensor object (rather than a sensor value) so we do the first half: instantiate a new sensor object if it's not defined on the entity type.
    
    This is consistent with the blocking `get()` method. We return `Maybe.absent()` if the `get()` method would have blocked, and otherwise we return the same value as `get()` would have returned.


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