brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aled Sage (JIRA)" <>
Subject [jira] [Created] (BROOKLYN-458) Cluster can't use transformer to get "" sensor of "cluster.first.entity"
Date Thu, 23 Mar 2017 11:15:42 GMT
Aled Sage created BROOKLYN-458:

             Summary: Cluster can't use transformer to get "" sensor of "cluster.first.entity"
                 Key: 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):
    public void testClusterGetsAttributeOfChild() throws Exception {
        String yaml = Joiner.on("\n").join(
                "    version: 0.2-SNAPSHOT",
                "    items:",
                "    - id: test-cluster",
                "      name: test-cluster",
                "      item:",
                "        type:",
                "        memberSpec:",
                "          $brooklyn:entitySpec:",
                "            type:",
                "            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(\"\")");

        String appYaml = Joiner.on("\n").join(
                "location: localhost",
                "- 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,
        EntityAsserts.assertAttributeEventually(cluster, Sensors.newStringSensor("cluster_first_host"),

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

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

View raw message