tosca_definitions_version: tosca_simple_yaml_1_3

metadata:
  template_author: cloudsoft
  template_name: tomcat-cluster
  template_version: 0.1.0-SNAPSHOT

topology_template:
  node_templates:
    cluster:
      type: tosca.entity.DynamicCluster
      properties:
        cluster.initial.size: 1
        dynamiccluster.memberspec:
          $brooklyn:entitySpec:
            name: Tomcat Member
            type: io.cloudsoft.tomcat-member

  groups:
    - add_brooklyn_types:
        members: [ cluster ]
        type: brooklyn.tosca.groups.initializer
        properties:
          brooklyn.enrichers:
            - type: org.apache.brooklyn.enricher.stock.Aggregator
              brooklyn.config:
                enricher.sourceSensor: $brooklyn:sensor("reqs_per_sec")
                enricher.targetSensor: $brooklyn:sensor("request.per_sec.mean")
                enricher.aggregating.fromMembers: true
                transformation: average  # do not put enricher. in front of it!!!
          brooklyn.policies:
            - type: org.apache.brooklyn.policy.autoscaling.AutoScalerPolicy
              brooklyn.config:
                autoscaler.metric: $brooklyn:sensor("request.per_sec.mean")
                autoscaler.metricLowerBound: 5
                autoscaler.metricUpperBound: 10
                autoscaler.minPoolSize: 1
                autoscaler.maxPoolSize: 3
            - type: org.apache.brooklyn.policy.ha.ServiceReplacer
    - add_brooklyn_types:
        members: [ tomcat-cluster ]
        type: brooklyn.tosca.groups.initializer
        properties:
          location:
            - tosca.default.location
