[
https://issues.apache.org/jira/browse/BROOKLYN-458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15948568#comment-15948568
]
ASF GitHub Bot commented on BROOKLYN-458:
-----------------------------------------
GitHub user mikezaccardo opened a pull request:
https://github.com/apache/brooklyn-docs/pull/159
Add docs for enricher.producer values
Adds documentation to address the problem described by
https://issues.apache.org/jira/browse/BROOKLYN-458.
Questions for reviewers:
* Should the "Enrichers" list be moved to its own page entirely, rather
than being on the "Policies" page?
* Should the workaround listed in
https://issues.apache.org/jira/browse/BROOKLYN-458 be included in the docs?
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/mikezaccardo/brooklyn-docs
add-enricher-producer-docs
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/brooklyn-docs/pull/159.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #159
----
commit 450f0ac844b863e3cc56c75609ffd37c4a6fb686
Author: Mike Zaccardo <[email protected]>
Date: 2017-03-30T07:27:54Z
Add docs for enricher.producer values
----
> 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)