[ 
https://issues.apache.org/jira/browse/BROOKLYN-356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15625023#comment-15625023
 ] 

ASF GitHub Bot commented on BROOKLYN-356:
-----------------------------------------

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.


> The sensor Transformer enricher fails to resolve its targetValue 
> indeterministically.
> -------------------------------------------------------------------------------------
>
>                 Key: BROOKLYN-356
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-356
>             Project: Brooklyn
>          Issue Type: Bug
>            Reporter: Svetoslav Neykov
>
> The sensor {{Transformer}} enricher fails to resolve its {{targetValue}} 
> indeterministically, especially so on loaded systems. This is especially 
> problematic if sourceSensor/triggerSensors change infrequently or do not 
> change ever (when using default values).
> Bueprints using the {{Transformer}} behave perfectly fine during development 
> and on test setups, but will fail on production machines (i.e. under load).
> The code [doing the value 
> resolving|https://github.com/apache/brooklyn-server/blob/b59e7463a9b337c2d0e7931cd420d5bac68d8549/core/src/main/java/org/apache/brooklyn/enricher/stock/Transformer.java#L90-L94]
>  tries to do so in a non-blocking fashion by spinning a thread to try to 
> resolve and cancelling it after a short while without guarantees it ever got 
> scheduled to run. It's more likely to fail when nesting DSLs, for example 
> nesting several levels of {{$brooklyn:formatString}} and ending with a 
> {{$brooklyn:attributeWhenRready}}. It's a common pattern in moderately 
> complex blueprints. It needs to schedule a thread for each nesting level thus 
> maximizing the chance that the value will not be resolved in the allotted 
> time even if resolvabe. This is especially bad for sensors which don't get 
> updated, for example {{PortAttributeSensorAndConfigKey} set only when 
> initializing the entity or any config values which are always resolvable.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to