Hi Sam
I've got an iterator in my template:
<#list config['cm_host_port_list'] as cm_item>
<crn:item xsi:type="xsd:anyURI">http://$
{cm_item}/p2pd/servlet</crn:item>
</#list>
So, that's why I have an array.
So, I think I could do something with a Predicate, but I have no idea how
I would wire this into the yaml.
Thanks
Graham
From: Sam Corbett <[email protected]>
To: [email protected]
Date: 03/06/2017 10:36 AM
Subject: Re: How to express aggregator in yaml
Hi Graham,
May I ask how you intend to use the values in your template?
If it would be sufficient to combine them into a single string you
should use a `Joiner` enricher whose minimum size is the initial size of
the cluster:
brooklyn.config:
cluster.initial.size: 4
brooklyn.enrichers:
- type: org.apache.brooklyn.enricher.stock.Aggregator
brooklyn.config:
enricher.sourceSensor: mySensor
enricher.targetSensor: aggregated
enricher.aggregating.fromMembers: true
- type: org.apache.brooklyn.enricher.stock.Joiner
brooklyn.config:
enricher.sourceSensor: aggregated
enricher.targetSensor: joinedUp
enricher.joiner.quote: false
enricher.joiner.minimum: $brooklyn:config("cluster.initial.size")
In this example the value for `joinedUp` won't be published until the
`aggregated` sensor contains four non-null values.
With this approach you wouldn't need to use a latch; in your other
entity you'd assign the joiner's value to a config key:
brooklyn.config:
valueForTemplate:
$brooklyn:entity("cluster").attributeWhenReady("joinedUp")
And in your template write:
${config['valueForTemplate']
There is no equivalent of `enricher.joiner.minimum` for Aggregators so
if this approach is unsuitable - perhaps you want to iterate over the
values in your template - then it seems to be considerably more complex
to achieve what you want. I've got a few ideas but will wait to hear
whether the above is of any help before digging into them.
Sam
On 03/03/2017 19:12, Graham Ashby wrote:
> OK, I've got this problem:
> I have a list of hosts_ports that I've created in a cluster using an
> Aggregator. So far so good.. .By using attributeWhenReady, it fills in
> when all the values are ready.
> Now in another part of my application, I want to use this in a template.
> The thing is, I want to wait until all the elements in the list are not
> null before I do the template.install.
> I've got a resources.install.latch, which seems to be the right latch to
> use. However, it needs a boolean
>
> So my question is: How can I write an Aggregator in yaml that will only
> be true if all the elements of the list are not null?
> I'm sure it's possible, and I could do it if I was writing Java. But
> there isn't a lot of documentation on how to do this.
>
> Thanks
> Graham Ashby
> [email protected]
>
>