Skip to content

Instantly share code, notes, and snippets.

@murdoaird
Last active January 27, 2016 11:53
Show Gist options
  • Save murdoaird/0cdcff47786533433c1d to your computer and use it in GitHub Desktop.
Save murdoaird/0cdcff47786533433c1d to your computer and use it in GitHub Desktop.
Basic Enrichers
name: Bash Web Server and Riak Cluster (Brooklyn Example)
# this example *references* the previous one,
# combining it with a stock blueprint for a Riak cluster,
# and shows how a sensor from the latter can be injected
services:
# reference template 2, overriding message to point at riak
- type: 2-bash-web-server-template
locations: []
brooklyn.config:
my.message: $brooklyn:formatString("connected to Riak at %s",
$brooklyn:entity("riak-cluster").attributeWhenReady("log.location.list.joined"))
customize.command: |
# create the web page to serve
cat > index.html << EOF
${MESSAGE:-a Brooklyn sample}.
EOF
# use the off-the-shelf Riak cluster
- type: org.apache.brooklyn.entity.nosql.riak.RiakCluster
id: riak-cluster
initialSize: 2
# and add a policy to scale based on ops per minute
brooklyn.policies:
- type: org.apache.brooklyn.policy.autoscaling.AutoScalerPolicy
brooklyn.config:
metric: riak.node.ops.1m.perNode
# more than 100 ops per second (6k/min) scales out, less than 50 scales back
# up to a max of 3 riak nodes here (can be changed in GUI / REST API afterwards)
metricLowerBound: 3000
metricUpperBound: 6000
minPoolSize: 1
maxPoolSize: 3
resizeUpStabilizationDelay: 30s
resizeDownStabilizationDelay: 5m
brooklyn.enrichers:
- type: org.apache.brooklyn.enricher.stock.Aggregator
# aggregate `log.location` sensors from children into a list
brooklyn.config:
enricher.sourceSensor: $brooklyn:sensor("log.location")
enricher.targetSensor: $brooklyn:sensor("log.location.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("log.location.list")
enricher.targetSensor: $brooklyn:sensor("log.location.list.joined")
enricher.joiner.separator: .
location: byon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment