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

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

Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-docs/pull/159


> Cluster can't use transformer to get "host.name" sensor of 
> "cluster.first.entity"
> ---------------------------------------------------------------------------------
>
>                 Key: BROOKLYN-458
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-458
>             Project: Brooklyn
>          Issue Type: Improvement
>            Reporter: Aled Sage
>
> Mike shared the blueprint below (which I've turned into a unit test, against 
> 0.11.0-SNAPSHOT):
> {noformat}
>     @Test
>     public void testClusterGetsAttributeOfChild() throws Exception {
>         String yaml = Joiner.on("\n").join(
>                 "brooklyn.catalog:",
>                 "    version: 0.2-SNAPSHOT",
>                 "    items:",
>                 "    - id: test-cluster",
>                 "      name: test-cluster",
>                 "      item:",
>                 "        type: 
> org.apache.brooklyn.entity.group.DynamicCluster",
>                 "        memberSpec:",
>                 "          $brooklyn:entitySpec:",
>                 "            type: 
> org.apache.brooklyn.entity.software.base.EmptySoftwareProcess",
>                 "            name: \"Node\"",
>                 "        brooklyn.enrichers:",
>                 "          - type: 
> org.apache.brooklyn.enricher.stock.Transformer",
>                 "            brooklyn.config:",
>                 "              enricher.sourceSensor: 
> $brooklyn:sensor(\"cluster.first.entity\")",
>                 "              enricher.targetSensor: 
> $brooklyn:sensor(\"cluster_first_host\")",
>                 "              enricher.targetValue:",
>                 "                $brooklyn:formatString:",
>                 "                - \"%s\"",
>                 "                - 
> $brooklyn:entity($brooklyn:attributeWhenReady(\"cluster.first.entity\")).attributeWhenReady(\"host.name\")");
>                         addCatalogItems(yaml);
>                 
>         String appYaml = Joiner.on("\n").join(
>                 "location: localhost",
>                 "services:",
>                 "- type: test-cluster");
>         
>         Entity app = createAndStartApplication(appYaml);
>         Entity cluster = Iterables.getOnlyElement(app.getChildren());
>         
>         EntityAsserts.assertAttributeEqualsEventually(app, 
> Attributes.SERVICE_UP, true);
>         EntityAsserts.assertAttributeEqualsEventually(app, 
> Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
>         EntityAsserts.assertAttributeEventually(cluster, 
> Sensors.newStringSensor("cluster_first_host"), StringPredicates.isNonBlank());
>     }
> {noformat}
> It fails because sensor {{cluster_first_host}} is never set on the cluster 
> entity. This is because the targetValue evaluation is triggered whenever the 
> sourceSensor changes. However, when {{clsuter.first.entity}} is set, that 
> entity does not yet have a {{host.name}}. Therefore the 
> {{attributeWhenReady}} is not yet available. (Under-the-covers, it discovers 
> this by using {{getImmediately}}, and thus returns immediately without 
> blocking).
> Mike tried to work around this by setting the {{producer}} for the 
> transformer enricher, but that led to him hitting 
> https://issues.apache.org/jira/browse/BROOKLYN-457.
> This is not really a bug (but could probably do with improvements in our docs 
> to explain it!).
> We'd like a way to elegantly write this blueprint though (hence marking this 
> as an "improvement").



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to