<commit_before>package brooklyn.demo

import brooklyn.entity.basic.AbstractEntity
import brooklyn.entity.trait.Startable

import java.util.Collection
import java.util.Map

import brooklyn.entity.Entity
import brooklyn.entity.basic.AbstractEntity
import brooklyn.entity.basic.JavaApp
import brooklyn.entity.group.DynamicCluster
import brooklyn.entity.proxy.nginx.NginxController
import brooklyn.entity.trait.Startable
import brooklyn.entity.webapp.DynamicWebAppCluster
import brooklyn.entity.webapp.JavaWebApp
import brooklyn.entity.webapp.tomcat.TomcatServer
import brooklyn.location.Location
import brooklyn.policy.Policy

/**
 * This group contains all the sub-groups and entities that go in to a single location.
 *
 * These are:
 * <ul>
 * <li>a {@link DynamicCluster} of {@link JavaWebApp}s
 * <li>a cluster controller
 * <li>a {@link Policy} to resize the DynamicCluster
 * </ul>
 */
public class WebCluster extends AbstractEntity implements Startable {

    DynamicWebAppCluster cluster
    NginxController controller

    WebCluster(Map props, Entity owner = null) {
        super(props, owner)
        def template = { Map properties ->
                def server = new TomcatServer(properties)
                server.setConfig(JavaApp.SUGGESTED_JMX_PORT, 32199)
                server.setConfig(JavaWebApp.HTTP_PORT.configKey, 8080)
                server.setConfig(TomcatServer.SUGGESTED_SHUTDOWN_PORT, 31880)
                return server;
            }
        cluster = new DynamicWebAppCluster(newEntity:template, this)
        cluster.setConfig(DynamicCluster.INITIAL_SIZE, 0)

        setAttribute(SERVICE_UP, false)
    }

    void start(Collection<Location> locations) {
        cluster.start(locations)
        cluster.resize(1)

        controller = new NginxController(
            owner:this,
            cluster:cluster,
            domain:'brooklyn.geopaas.org',
            port:8000,<commit_msg>WebCluster in demo: use defaults for config keys<commit_after>package brooklyn.demo

import brooklyn.entity.basic.AbstractEntity
import brooklyn.entity.trait.Startable

import java.util.Collection
import java.util.Map

import brooklyn.entity.Entity
import brooklyn.entity.basic.AbstractEntity
import brooklyn.entity.basic.JavaApp
import brooklyn.entity.group.DynamicCluster
import brooklyn.entity.proxy.nginx.NginxController
import brooklyn.entity.trait.Startable
import brooklyn.entity.webapp.DynamicWebAppCluster
import brooklyn.entity.webapp.JavaWebApp
import brooklyn.entity.webapp.tomcat.TomcatServer
import brooklyn.location.Location
import brooklyn.policy.Policy

/**
 * This group contains all the sub-groups and entities that go in to a single location.
 *
 * These are:
 * <ul>
 * <li>a {@link DynamicCluster} of {@link JavaWebApp}s
 * <li>a cluster controller
 * <li>a {@link Policy} to resize the DynamicCluster
 * </ul>
 */
public class WebCluster extends AbstractEntity implements Startable {

    DynamicWebAppCluster cluster
    NginxController controller

    WebCluster(Map props, Entity owner = null) {
        super(props, owner)
        def template = { Map properties ->
                def server = new TomcatServer(properties)
                server.setConfig(JavaWebApp.HTTP_PORT.configKey, 8080)
                return server;
            }
        cluster = new DynamicWebAppCluster(newEntity:template, this)
        cluster.setConfig(DynamicCluster.INITIAL_SIZE, 0)

        setAttribute(SERVICE_UP, false)
    }

    void start(Collection<Location> locations) {
        cluster.start(locations)
        cluster.resize(1)

        controller = new NginxController(
            owner:this,
            cluster:cluster,
            domain:'brooklyn.geopaas.org',
            port:8000,
{'fraction_non_alphanumeric': 0.08063219930350925, 'fraction_numerical': 0.008036431824270024, 'mean_word_length': 3.341860465116279, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2270449', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1041, 'n_words': 244}