| # |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| # |
| # example showing how enrichers can be set |
| # |
| name: test-app-with-enrichers |
| description: Testing many enrichers |
| services: |
| - type: org.apache.brooklyn.entity.group.DynamicCluster |
| id: cluster |
| initialSize: 3 |
| location: localhost |
| memberSpec: |
| $brooklyn:entitySpec: |
| type: org.apache.brooklyn.core.test.entity.TestEntity |
| brooklyn.enrichers: |
| - type: org.apache.brooklyn.enricher.stock.Transformer |
| # transform "ip" (which we expect a feed, not shown here, to set) to a URL; |
| # you can curl an address string to the sensors/ip endpoint an entity to trigger these enrichers |
| brooklyn.config: |
| enricher.sourceSensor: $brooklyn:sensor("ip") |
| enricher.targetSensor: $brooklyn:sensor("url") |
| enricher.targetValue: $brooklyn:formatString("http://%s/", $brooklyn:attributeWhenReady("ip")) |
| - type: org.apache.brooklyn.enricher.stock.Propagator |
| # use propagator to duplicate one sensor as another, giving the supplied sensor mapping; |
| # the other use of Propagator is where you specify a producer (using $brooklyn:entity(...) as below) |
| # from which to take sensors; in that mode you can specify `propagate` as a list of sensors whose names are unchanged, |
| # instead of (or in addition to) this map |
| brooklyn.config: |
| producer: $brooklyn:component("this", "ignored") |
| sensorMapping: |
| $brooklyn:sensor("url"): $brooklyn:sensor("org.apache.brooklyn.core.entity.Attributes", "main.uri") |
| brooklyn.enrichers: |
| - type: org.apache.brooklyn.enricher.stock.Aggregator |
| # aggregate `url` sensors from children into a list |
| brooklyn.config: |
| enricher.sourceSensor: $brooklyn:sensor("url") |
| enricher.targetSensor: $brooklyn:sensor("urls.list") |
| enricher.aggregating.fromMembers: true |
| - type: org.apache.brooklyn.enricher.stock.Joiner |
| # create a string from that list, for use e.g. in bash scripts |
| brooklyn.config: |
| enricher.sourceSensor: $brooklyn:sensor("urls.list") |
| enricher.targetSensor: $brooklyn:sensor("urls.list.comma_separated.max_2") |
| maximum: 2 |
| # TODO infer uniqueTag, name etc |
| uniqueTag: urls.list.comma_separated.max_2 |
| - type: org.apache.brooklyn.enricher.stock.Joiner |
| # pick one uri as the main one to use |
| brooklyn.config: |
| enricher.sourceSensor: $brooklyn:sensor("urls.list") |
| enricher.targetSensor: $brooklyn:sensor("org.apache.brooklyn.core.entity.Attributes", "main.uri") |
| quote: false |
| maximum: 1 |
| brooklyn.enrichers: |
| - type: org.apache.brooklyn.enricher.stock.Propagator |
| # if nothing specified for `propagating` or `sensorMapping` then |
| # Propagator will do all but the usual lifecycle defaults, handy at the root! |
| brooklyn.config: |
| producer: $brooklyn:entity("cluster") |
| propagatingAll: true |