brooklyn-example-simple-nosql-cluster: add org.apache package prefix

Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/44d2dc11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/44d2dc11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/44d2dc11

Branch: refs/heads/master
Commit: 44d2dc1163db52a35e1125654f1137f106c196dc
Parents: 0cdb2ed
Author: Ciprian Ciubotariu <[email protected]>
Authored: Wed Jul 15 11:06:56 2015 +0300
Committer: Ciprian Ciubotariu <[email protected]>
Committed: Wed Jul 15 18:47:01 2015 +0300

----------------------------------------------------------------------
 .../brooklyn/demo/CumulusRDFApplication.java    | 240 -------------------
 .../demo/HighAvailabilityCassandraCluster.java  |  89 -------
 .../java/brooklyn/demo/ResilientMongoDbApp.java | 106 --------
 .../java/brooklyn/demo/RiakClusterExample.java  |  76 ------
 .../brooklyn/demo/SimpleCassandraCluster.java   |  58 -----
 .../brooklyn/demo/SimpleCouchDBCluster.java     |  36 ---
 .../brooklyn/demo/SimpleMongoDBReplicaSet.java  |  39 ---
 .../java/brooklyn/demo/SimpleRedisCluster.java  |  35 ---
 .../main/java/brooklyn/demo/StormSampleApp.java |  70 ------
 .../brooklyn/demo/WideAreaCassandraCluster.java |  86 -------
 .../brooklyn/demo/CumulusRDFApplication.java    | 240 +++++++++++++++++++
 .../demo/HighAvailabilityCassandraCluster.java  |  89 +++++++
 .../brooklyn/demo/ResilientMongoDbApp.java      | 106 ++++++++
 .../brooklyn/demo/RiakClusterExample.java       |  76 ++++++
 .../brooklyn/demo/SimpleCassandraCluster.java   |  58 +++++
 .../brooklyn/demo/SimpleCouchDBCluster.java     |  36 +++
 .../brooklyn/demo/SimpleMongoDBReplicaSet.java  |  39 +++
 .../brooklyn/demo/SimpleRedisCluster.java       |  35 +++
 .../apache/brooklyn/demo/StormSampleApp.java    |  70 ++++++
 .../brooklyn/demo/WideAreaCassandraCluster.java |  86 +++++++
 .../brooklyn/demo/ha-cassandra-cluster.yaml     |  45 ----
 .../brooklyn/demo/simple-cassandra-cluster.yaml |  28 ---
 .../demo/wide-area-cassandra-cluster.yaml       |  41 ----
 .../brooklyn/demo/ha-cassandra-cluster.yaml     |  45 ++++
 .../brooklyn/demo/simple-cassandra-cluster.yaml |  28 +++
 .../demo/wide-area-cassandra-cluster.yaml       |  41 ++++
 26 files changed, 949 insertions(+), 949 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/CumulusRDFApplication.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/CumulusRDFApplication.java
 
b/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/CumulusRDFApplication.java
deleted file mode 100644
index 3379bd4..0000000
--- 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/CumulusRDFApplication.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * 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.
- */
-package brooklyn.demo;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.catalog.Catalog;
-import brooklyn.catalog.CatalogConfig;
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.Effector;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.EntityInternal;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.entity.basic.ServiceStateLogic;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.effector.EffectorBody;
-import brooklyn.entity.effector.Effectors;
-import brooklyn.entity.java.UsesJava;
-import brooklyn.entity.java.UsesJmx;
-import brooklyn.entity.nosql.cassandra.CassandraDatacenter;
-import brooklyn.entity.nosql.cassandra.CassandraFabric;
-import brooklyn.entity.nosql.cassandra.CassandraNode;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.software.SshEffectorTasks;
-import brooklyn.entity.trait.Startable;
-import brooklyn.entity.webapp.JavaWebAppService;
-import brooklyn.entity.webapp.tomcat.TomcatServer;
-import brooklyn.event.SensorEvent;
-import brooklyn.event.SensorEventListener;
-import brooklyn.event.basic.DependentConfiguration;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.location.Location;
-import brooklyn.location.basic.PortRanges;
-import brooklyn.policy.EnricherSpec;
-import brooklyn.policy.PolicySpec;
-import brooklyn.policy.ha.ServiceFailureDetector;
-import brooklyn.policy.ha.ServiceReplacer;
-import brooklyn.policy.ha.ServiceRestarter;
-import brooklyn.util.CommandLineUtil;
-import brooklyn.util.ResourceUtils;
-import brooklyn.util.collections.MutableList;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.config.ConfigBag;
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.task.DynamicTasks;
-import brooklyn.util.text.StringEscapes.JavaStringEscapes;
-import brooklyn.util.text.Strings;
-import brooklyn.util.text.TemplateProcessor;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.net.HostAndPort;
-
-/** CumulusRDF application with Cassandra cluster. */
-@Catalog(name="Cumulus RDF Application", description="CumulusRDF Application 
on a Tomcat server using a multi-region Cassandra fabric")
-public class CumulusRDFApplication extends AbstractApplication {
-
-    private static final Logger log = 
LoggerFactory.getLogger(CumulusRDFApplication.class);
-
-    @CatalogConfig(label="Cumulus Configuration File (URL)", priority=1)
-    public static final ConfigKey<String> CUMULUS_RDF_CONFIG_URL = 
ConfigKeys.newConfigKey(
-        "cumulus.config.url", "URL for the YAML configuration file for 
CumulusRDF", "classpath://cumulus.yaml");
-
-    @CatalogConfig(label="Cassandra Thrift Port", priority=1)
-    public static final ConfigKey<Integer> CASSANDRA_THRIFT_PORT = 
ConfigKeys.newConfigKey(
-        "cumulus.cassandra.port", "Port to contact the Cassandra cluster on", 
9160);
-
-    @CatalogConfig(label="Cassandra Cluster Size", priority=1)
-    public static final ConfigKey<Integer> CASSANDRA_CLUSTER_SIZE = 
ConfigKeys.newConfigKey(
-        "cumulus.cassandra.cluster.size", "Initial size of the Cassandra 
cluster", 2);
-
-    @CatalogConfig(label="Multi-region Fabric", priority=1)
-    public static final ConfigKey<Boolean> MULTI_REGION_FABRIC = 
ConfigKeys.newConfigKey(
-        "cumulus.cassandra.fabric", "Deploy a multi-region Cassandra fabric", 
false);
-
-    // TODO Fails when given two locations
-    // public static final String DEFAULT_LOCATIONS = "[ 
jclouds:aws-ec2:us-east-1,jclouds:rackspace-cloudservers-uk ]";
-    public static final String DEFAULT_LOCATIONS = "jclouds:aws-ec2:us-east-1";
-
-    private Effector<Void> cumulusConfig = Effectors.effector(Void.class, 
"cumulusConfig")
-            .description("Configure the CumulusRDF web application")
-            .buildAbstract();
-
-    private Entity cassandra;
-    private TomcatServer webapp;
-    private HostAndPort endpoint;
-    private final Object endpointMutex = new Object();
-
-    /**
-     * Create the application entities:
-     * <ul>
-     * <li>A {@link CassandraFabric} of {@link CassandraDatacenter}s 
containing {@link CassandraNode}s
-     * <li>A {@link TomcatServer}
-     * </ul>
-     */
-    @Override
-    public void initApp() {
-        // Cassandra cluster
-        EntitySpec<CassandraDatacenter> clusterSpec = 
EntitySpec.create(CassandraDatacenter.class)
-                .configure(CassandraDatacenter.MEMBER_SPEC, 
EntitySpec.create(CassandraNode.class)
-                        //FIXME can probably use JMXMP_AND_RMI now, to deploy 
to GCE and elsewhere
-                        .configure(UsesJmx.JMX_AGENT_MODE, 
UsesJmx.JmxAgentModes.JMX_RMI_CUSTOM_AGENT)
-                        .configure(UsesJmx.JMX_PORT, 
PortRanges.fromString("11099+"))
-                        .configure(UsesJmx.RMI_REGISTRY_PORT, 
PortRanges.fromString("9001+"))
-                        .configure(CassandraNode.THRIFT_PORT, 
PortRanges.fromInteger(getConfig(CASSANDRA_THRIFT_PORT)))
-                        
.enricher(EnricherSpec.create(ServiceFailureDetector.class))
-                        .policy(PolicySpec.create(ServiceRestarter.class)
-                                
.configure(ServiceRestarter.FAILURE_SENSOR_TO_MONITOR, 
ServiceFailureDetector.ENTITY_FAILED)))
-                .policy(PolicySpec.create(ServiceReplacer.class)
-                        .configure(ServiceReplacer.FAILURE_SENSOR_TO_MONITOR, 
ServiceRestarter.ENTITY_RESTART_FAILED));
-
-        if (getConfig(MULTI_REGION_FABRIC)) {
-            cassandra = addChild(EntitySpec.create(CassandraFabric.class)
-                    .configure(CassandraDatacenter.CLUSTER_NAME, "Brooklyn")
-                    .configure(CassandraDatacenter.INITIAL_SIZE, 
getConfig(CASSANDRA_CLUSTER_SIZE)) // per location
-                    .configure(CassandraDatacenter.ENDPOINT_SNITCH_NAME, 
"brooklyn.entity.nosql.cassandra.customsnitch.MultiCloudSnitch")
-                    .configure(CassandraNode.CUSTOM_SNITCH_JAR_URL, 
"classpath://brooklyn/entity/nosql/cassandra/cassandra-multicloud-snitch.jar")
-                    .configure(CassandraFabric.MEMBER_SPEC, clusterSpec));
-        } else {
-            cassandra = addChild(EntitySpec.create(clusterSpec)
-                    .configure(CassandraDatacenter.CLUSTER_NAME, "Brooklyn")
-                    .configure(CassandraDatacenter.INITIAL_SIZE, 
getConfig(CASSANDRA_CLUSTER_SIZE)));
-        }
-
-        // Tomcat web-app server
-        webapp = addChild(EntitySpec.create(TomcatServer.class)
-                .configure(UsesJmx.JMX_AGENT_MODE, 
UsesJmx.JmxAgentModes.JMX_RMI_CUSTOM_AGENT)
-                .configure(UsesJmx.JMX_PORT, PortRanges.fromString("11099+"))
-                .configure(UsesJmx.RMI_REGISTRY_PORT, 
PortRanges.fromString("9001+"))
-                .configure(JavaWebAppService.ROOT_WAR, 
"https://cumulusrdf.googlecode.com/svn/wiki/downloads/cumulusrdf-1.0.1.war";)
-                .configure(UsesJava.JAVA_SYSPROPS, 
MutableMap.of("cumulusrdf.config-file", "/tmp/cumulus.yaml")));
-
-        // Add an effector to tomcat to reconfigure with a new YAML config file
-        ((EntityInternal) 
webapp).getMutableEntityType().addEffector(cumulusConfig, new 
EffectorBody<Void>() {
-            @Override
-            public Void call(ConfigBag parameters) {
-                // Process the YAML template given in the application config
-                String url = 
Entities.getRequiredUrlConfig(CumulusRDFApplication.this, 
CUMULUS_RDF_CONFIG_URL);
-                Map<String, Object> config;
-                synchronized (endpointMutex) {
-                    config = MutableMap.<String, 
Object>of("cassandraHostname", endpoint.getHostText(), "cassandraThriftPort", 
endpoint.getPort());
-                }
-                String contents = 
TemplateProcessor.processTemplateContents(ResourceUtils.create(CumulusRDFApplication.this).getResourceAsString(url),
 config);
-                // Copy the file contents to the remote machine
-                return 
DynamicTasks.queue(SshEffectorTasks.put("/tmp/cumulus.yaml").contents(contents)).get();
-            }
-        });
-
-        // Listen for HOSTNAME changes from the Cassandra fabric to show at 
least one node is available
-        subscribe(cassandra, CassandraDatacenter.HOSTNAME, new 
SensorEventListener<String>() {
-            @Override
-            public void onEvent(SensorEvent<String> event) {
-                if (Strings.isNonBlank(event.getValue())) {
-                    synchronized (endpointMutex) {
-                        String hostname = 
Entities.submit(CumulusRDFApplication.this, 
DependentConfiguration.attributeWhenReady(cassandra, 
CassandraDatacenter.HOSTNAME)).getUnchecked();
-                        Integer thriftPort = 
Entities.submit(CumulusRDFApplication.this, 
DependentConfiguration.attributeWhenReady(cassandra, 
CassandraDatacenter.THRIFT_PORT)).getUnchecked();
-                        HostAndPort current = HostAndPort.fromParts(hostname, 
thriftPort);
-
-                        // Check if the cluster access point has changed
-                        if (!current.equals(endpoint)) {
-                            log.info("Setting cluster endpoint to {}", 
current.toString());
-                            endpoint = current;
-
-                            // Reconfigure the CumulusRDF application and 
restart tomcat if necessary
-                            webapp.invoke(cumulusConfig, MutableMap.<String, 
Object>of());
-                            if (webapp.getAttribute(Startable.SERVICE_UP)) {
-                                webapp.restart();
-                            }
-                        }
-                    }
-                }
-            }
-        });
-    }
-
-    /**
-     * Controls the startup locations for the webapp and the cassandra fabric.
-     *
-     * @see AbstractApplication#start(Collection)
-     */
-    @Override
-    public void start(Collection<? extends Location> locations) {
-        addLocations(locations);
-
-        // The web application only needs to run in one location, use the first
-        // TODO use a multi-region web cluster
-        Collection<? extends Location> first = 
MutableList.copyOf(Iterables.limit(locations, 1));
-
-        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
-        try {
-            Entities.invokeEffector(this, cassandra, Startable.START, 
MutableMap.of("locations", locations)).getUnchecked();
-            Entities.invokeEffector(this, webapp, Startable.START, 
MutableMap.of("locations", first)).getUnchecked();
-        } catch (Exception e) {
-            throw Exceptions.propagate(e);
-        } finally {
-            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
-        }
-        log.info("Started CumulusRDF in " + locations);
-    }
-
-
-    public static void main(String[] argv) {
-        List<String> args = Lists.newArrayList(argv);
-        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
-        String locations = CommandLineUtil.getCommandLineOption(args, 
"--locations", DEFAULT_LOCATIONS);
-
-        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
-                .application(EntitySpec.create(StartableApplication.class, 
CumulusRDFApplication.class).displayName("CumulusRDF application using 
Cassandra"))
-                .webconsolePort(port)
-                .locations(Strings.isBlank(locations) ? 
ImmutableList.<String>of() : 
JavaStringEscapes.unwrapJsonishListIfPossible(locations))
-                .start();
-
-        Entities.dumpInfo(launcher.getApplications());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/HighAvailabilityCassandraCluster.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/HighAvailabilityCassandraCluster.java
 
b/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/HighAvailabilityCassandraCluster.java
deleted file mode 100644
index a105783..0000000
--- 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/HighAvailabilityCassandraCluster.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.
- */
-package brooklyn.demo;
-
-import java.util.List;
-
-import brooklyn.catalog.Catalog;
-import brooklyn.catalog.CatalogConfig;
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.nosql.cassandra.CassandraDatacenter;
-import brooklyn.entity.nosql.cassandra.CassandraNode;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.policy.EnricherSpec;
-import brooklyn.policy.PolicySpec;
-import brooklyn.policy.ha.ServiceFailureDetector;
-import brooklyn.policy.ha.ServiceReplacer;
-import brooklyn.policy.ha.ServiceRestarter;
-import brooklyn.util.CommandLineUtil;
-
-import com.google.common.collect.Lists;
-
-@Catalog(name="HA Cassandra Cluster Application", description="Deploy a 
Cassandra cluster with a High Availability architecture.")
-public class HighAvailabilityCassandraCluster extends AbstractApplication {
-
-    public static final String DEFAULT_LOCATION_SPEC = "aws-ec2:us-east-1";
- 
-    @CatalogConfig(label="Number of Availability Zones", priority=1)
-    public static final ConfigKey<Integer> NUM_AVAILABILITY_ZONES = 
ConfigKeys.newConfigKey(
-        "cassandra.cluster.numAvailabilityZones", "Number of availability 
zones to spread the cluster across", 3); 
-    
-    @CatalogConfig(label="Initial Cluster Size", priority=2)
-    public static final ConfigKey<Integer> CASSANDRA_CLUSTER_SIZE = 
ConfigKeys.newConfigKey(
-        "cassandra.cluster.initialSize", "Initial size of the Cassandra 
cluster", 6);      
-    
-    
-    @Override
-    public void initApp() {
-        addChild(EntitySpec.create(CassandraDatacenter.class)
-                .configure(CassandraDatacenter.CLUSTER_NAME, "Brooklyn")
-                .configure(CassandraDatacenter.INITIAL_SIZE, 
getConfig(CASSANDRA_CLUSTER_SIZE))
-                .configure(CassandraDatacenter.ENABLE_AVAILABILITY_ZONES, true)
-                .configure(CassandraDatacenter.NUM_AVAILABILITY_ZONES, 
getConfig(NUM_AVAILABILITY_ZONES))
-                //See https://github.com/brooklyncentral/brooklyn/issues/973
-                //.configure(CassandraCluster.AVAILABILITY_ZONE_NAMES, 
ImmutableList.of("us-east-1b", "us-east-1c", "us-east-1e"))
-                .configure(CassandraDatacenter.ENDPOINT_SNITCH_NAME, 
"GossipingPropertyFileSnitch")
-                .configure(CassandraDatacenter.MEMBER_SPEC, 
EntitySpec.create(CassandraNode.class)
-                        
.enricher(EnricherSpec.create(ServiceFailureDetector.class))
-                        .policy(PolicySpec.create(ServiceRestarter.class)
-                                
.configure(ServiceRestarter.FAILURE_SENSOR_TO_MONITOR, 
ServiceFailureDetector.ENTITY_FAILED)))
-                .policy(PolicySpec.create(ServiceReplacer.class)
-                        .configure(ServiceReplacer.FAILURE_SENSOR_TO_MONITOR, 
ServiceRestarter.ENTITY_RESTART_FAILED)));
-    }
-    
-    public static void main(String[] argv) {
-        List<String> args = Lists.newArrayList(argv);
-        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
-        String location = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION_SPEC);
-        
-        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
-                 .application(EntitySpec.create(StartableApplication.class, 
HighAvailabilityCassandraCluster.class)
-                         .displayName("Cassandra"))
-                 .webconsolePort(port)
-                 .location(location)
-                 .start();
-             
-        Entities.dumpInfo(launcher.getApplications());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/ResilientMongoDbApp.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/ResilientMongoDbApp.java
 
b/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/ResilientMongoDbApp.java
deleted file mode 100644
index 4acbbea..0000000
--- 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/ResilientMongoDbApp.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.
- */
-package brooklyn.demo;
-
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.catalog.Catalog;
-import brooklyn.enricher.Enrichers;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.group.DynamicCluster;
-import brooklyn.entity.nosql.mongodb.MongoDBReplicaSet;
-import brooklyn.entity.nosql.mongodb.MongoDBServer;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.event.SensorEvent;
-import brooklyn.event.SensorEventListener;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.policy.ha.ServiceFailureDetector;
-import brooklyn.policy.ha.ServiceReplacer;
-import brooklyn.policy.ha.ServiceRestarter;
-import brooklyn.util.CommandLineUtil;
-
-import com.google.common.collect.Lists;
-
-/**
- * Sample showing a MongoDB replica set with resilience policies attached at 
nodes and the cluster.
- **/
-@Catalog(name="Resilient MongoDB")
-public class ResilientMongoDbApp extends AbstractApplication implements 
StartableApplication {
-    
-    public static final Logger LOG = 
LoggerFactory.getLogger(ResilientMongoDbApp.class);
-    
-    public static final String DEFAULT_LOCATION = "named:gce-europe-west1";
-
-    @Override
-    public void initApp() {
-        MongoDBReplicaSet rs = addChild(
-                EntitySpec.create(MongoDBReplicaSet.class)
-                        .configure(MongoDBReplicaSet.INITIAL_SIZE, 3));
-        
-        initResilience(rs);
-        
-        addEnricher(Enrichers.builder()
-                .propagating(MongoDBReplicaSet.REPLICA_SET_ENDPOINTS, 
MongoDBServer.REPLICA_SET_PRIMARY_ENDPOINT)
-                .from(rs)
-                .build());
-    }
-    
-    /** this attaches a policy at each MongoDB node listening for 
ENTITY_FAILED,
-     * attempting to _restart_ the process, and 
-     * failing that attempting to _replace_ the entity (e.g. a new VM), and 
-     * failing that setting the cluster "on-fire" */
-    protected void initResilience(MongoDBReplicaSet rs) {
-        subscribe(rs, DynamicCluster.MEMBER_ADDED, new 
SensorEventListener<Entity>() {
-            @Override
-            public void onEvent(SensorEvent<Entity> addition) {
-                initSoftwareProcess((SoftwareProcess)addition.getValue());
-            }
-        });
-        rs.addPolicy(new 
ServiceReplacer(ServiceRestarter.ENTITY_RESTART_FAILED));
-    }
-
-    /** invoked whenever a new MongoDB server is added (the server may not be 
started yet) */
-    protected void initSoftwareProcess(SoftwareProcess p) {
-        p.addEnricher(new ServiceFailureDetector());
-        p.addPolicy(new 
ServiceRestarter(ServiceFailureDetector.ENTITY_FAILED));
-    }
-    
-    public static void main(String[] argv) {
-        List<String> args = Lists.newArrayList(argv);
-        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
-        String location = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION);
-
-        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
-                 .application(EntitySpec.create(StartableApplication.class, 
ResilientMongoDbApp.class)
-                         .displayName("Resilient MongoDB"))
-                 .webconsolePort(port)
-                 .location(location)
-                 .start();
-             
-        Entities.dumpInfo(launcher.getApplications());
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/RiakClusterExample.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/RiakClusterExample.java
 
b/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/RiakClusterExample.java
deleted file mode 100644
index 58b6f60..0000000
--- 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/RiakClusterExample.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.
- */
-package brooklyn.demo;
-
-import java.util.List;
-
-import brooklyn.catalog.Catalog;
-import brooklyn.catalog.CatalogConfig;
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.nosql.riak.RiakCluster;
-import brooklyn.entity.nosql.riak.RiakNode;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.policy.EnricherSpec;
-import brooklyn.policy.PolicySpec;
-import brooklyn.policy.ha.ServiceFailureDetector;
-import brooklyn.policy.ha.ServiceRestarter;
-import brooklyn.util.CommandLineUtil;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-
-@Catalog(name = "Riak Cluster Application", description = "Riak ring 
deployment blueprint")
-public class RiakClusterExample extends AbstractApplication {
-
-    public static final String DEFAULT_LOCATION_SPEC = "aws-ec2:us-east-1";
-
-    @CatalogConfig(label = "Riak Ring Size")
-    public static final ConfigKey<Integer> RIAK_RING_SIZE = 
ConfigKeys.newConfigKey(
-            "riak.ring.size", "Initial size of the Riak Ring", 4);
-
-    public static void main(String[] argv) {
-        List<String> args = Lists.newArrayList(argv);
-        String port = CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
-        String location = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION_SPEC);
-        Preconditions.checkArgument(args.isEmpty(), "Unsupported args: " + 
args);
-
-        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
-                .application(EntitySpec.create(StartableApplication.class, 
RiakClusterExample.class))
-                .webconsolePort(port)
-                .location(location)
-                .start();
-
-        Entities.dumpInfo(launcher.getApplications());
-    }
-
-    public void initApp() {
-        addChild(EntitySpec.create(RiakCluster.class)
-                .configure(RiakCluster.INITIAL_SIZE, getConfig(RIAK_RING_SIZE))
-                .configure(RiakCluster.MEMBER_SPEC, 
EntitySpec.create(RiakNode.class)
-                        
.enricher(EnricherSpec.create(ServiceFailureDetector.class))
-                        .policy(PolicySpec.create(ServiceRestarter.class)
-                                
.configure(ServiceRestarter.FAILURE_SENSOR_TO_MONITOR, 
ServiceFailureDetector.ENTITY_FAILED))));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleCassandraCluster.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleCassandraCluster.java
 
b/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleCassandraCluster.java
deleted file mode 100644
index 94f792c..0000000
--- 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleCassandraCluster.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.
- */
-package brooklyn.demo;
-
-import java.util.List;
-
-import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.nosql.cassandra.CassandraDatacenter;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.util.CommandLineUtil;
-
-import com.google.common.collect.Lists;
-
-public class SimpleCassandraCluster extends AbstractApplication {
-
-    private static final String DEFAULT_LOCATION = "localhost";
-
-    @Override
-    public void initApp() {
-        addChild(EntitySpec.create(CassandraDatacenter.class)
-                .configure(CassandraDatacenter.INITIAL_SIZE, 1)
-                .configure(CassandraDatacenter.CLUSTER_NAME, "Brooklyn"));
-    }
-    
-    public static void main(String[] argv) {
-        List<String> args = Lists.newArrayList(argv);
-        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
-        String location = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION);
-        
-        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
-                 .application(EntitySpec.create(StartableApplication.class, 
SimpleCassandraCluster.class)
-                         .displayName("Cassandra"))
-                         .webconsolePort(port)
-                 .location(location)
-                 .start();
-             
-        Entities.dumpInfo(launcher.getApplications());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleCouchDBCluster.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleCouchDBCluster.java
 
b/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleCouchDBCluster.java
deleted file mode 100644
index 6f249e2..0000000
--- 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleCouchDBCluster.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-package brooklyn.demo;
-
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.nosql.couchdb.CouchDBCluster;
-import brooklyn.entity.proxying.EntitySpec;
-
-/** CouchDB cluster. */
-public class SimpleCouchDBCluster extends ApplicationBuilder {
-
-    /** Create entities. */
-    protected void doBuild() {
-        addChild(EntitySpec.create(CouchDBCluster.class)
-                .configure("initialSize", "2")
-                .configure("clusterName", "Brooklyn")
-                .configure("httpPort", "8000+"));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleMongoDBReplicaSet.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleMongoDBReplicaSet.java
 
b/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleMongoDBReplicaSet.java
deleted file mode 100644
index 5597590..0000000
--- 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleMongoDBReplicaSet.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.
- */
-package brooklyn.demo;
-
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.nosql.mongodb.MongoDBReplicaSet;
-import brooklyn.entity.nosql.mongodb.MongoDBServer;
-import brooklyn.entity.proxying.EntitySpec;
-
-public class SimpleMongoDBReplicaSet extends ApplicationBuilder {
-
-    protected void doBuild() {
-        addChild(EntitySpec.create(MongoDBReplicaSet.class)
-            .configure("name", "Simple MongoDB replica set")
-            .configure("initialSize", 3)
-            .configure("replicaSetName", "simple-replica-set")
-            .configure("memberSpec", EntitySpec.create(MongoDBServer.class)
-                    .configure("mongodbConfTemplateUrl", 
"classpath:///mongodb.conf")
-                    .configure("enableRestInterface", true)
-                    .configure("port", "27017+")));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleRedisCluster.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleRedisCluster.java
 
b/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleRedisCluster.java
deleted file mode 100644
index ed899b3..0000000
--- 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/SimpleRedisCluster.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.
- */
-package brooklyn.demo;
-
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.nosql.redis.RedisCluster;
-import brooklyn.entity.proxying.EntitySpec;
-
-/** Redis cluster. */
-public class SimpleRedisCluster extends ApplicationBuilder {
-
-    /** Create entities. */
-    protected void doBuild() {
-        addChild(EntitySpec.create(RedisCluster.class)
-                .configure("initialSize", "2")
-                .configure("clusterName", "Brooklyn"));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/StormSampleApp.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/StormSampleApp.java 
b/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/StormSampleApp.java
deleted file mode 100644
index 732ccd5..0000000
--- 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/StormSampleApp.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.
- */
-package brooklyn.demo;
-
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.catalog.Catalog;
-import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.messaging.storm.StormDeployment;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.util.CommandLineUtil;
-
-import com.google.common.collect.Lists;
-
-/**
- * Sample showing a storm analyticscluster
- **/
-@Catalog(name="Storm Sample App",
-description="Creates a Storm analytics cluster",
-    iconUrl="classpath://brooklyn/demo/glossy-3d-blue-web-icon.png")
-public class StormSampleApp extends AbstractApplication implements 
StartableApplication {
-
-    public static final Logger LOG = 
LoggerFactory.getLogger(StormSampleApp.class);
-
-    public static final String DEFAULT_LOCATION = "named:gce-europe-west1";
-
-    @Override
-    public void initApp() {
-        addChild(EntitySpec.create(StormDeployment.class)
-            .configure(StormDeployment.SUPERVISORS_COUNT, 2)
-            .configure(StormDeployment.ZOOKEEPERS_COUNT, 1));
-    }
-
-    public static void main(String[] argv) {
-        List<String> args = Lists.newArrayList(argv);
-        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
-        String location = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION);
-
-        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
-            .application(EntitySpec.create(StartableApplication.class, 
StormSampleApp.class)
-                .displayName("Storm App"))
-                .webconsolePort(port)
-                .location(location)
-                .start();
-
-        Entities.dumpInfo(launcher.getApplications());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/WideAreaCassandraCluster.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/WideAreaCassandraCluster.java
 
b/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/WideAreaCassandraCluster.java
deleted file mode 100644
index 7c441ee..0000000
--- 
a/examples/simple-nosql-cluster/src/main/java/brooklyn/demo/WideAreaCassandraCluster.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.
- */
-package brooklyn.demo;
-
-import java.util.Arrays;
-import java.util.List;
-
-import brooklyn.catalog.Catalog;
-import brooklyn.catalog.CatalogConfig;
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.nosql.cassandra.CassandraDatacenter;
-import brooklyn.entity.nosql.cassandra.CassandraFabric;
-import brooklyn.entity.nosql.cassandra.CassandraNode;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.policy.EnricherSpec;
-import brooklyn.policy.PolicySpec;
-import brooklyn.policy.ha.ServiceFailureDetector;
-import brooklyn.policy.ha.ServiceReplacer;
-import brooklyn.policy.ha.ServiceRestarter;
-import brooklyn.util.CommandLineUtil;
-
-import com.google.common.collect.Lists;
-
-@Catalog(name="Wide Area Cassandra Cluster Application", description="Deploy a 
Cassandra cluster across multiple geographies.")
-public class WideAreaCassandraCluster extends AbstractApplication {
-
-    public static final String DEFAULT_LOCATION_SPEC = 
"aws-ec2:us-east-1,rackspace-cloudservers-uk";
-    
-    @CatalogConfig(label="Initial Cluster Size (per location)", priority=2)
-    public static final ConfigKey<Integer> CASSANDRA_CLUSTER_SIZE = 
ConfigKeys.newConfigKey(
-        "cassandra.cluster.initialSize", "Initial size of the Cassandra 
clusterss", 2);      
-    
-    
-    
-    @Override
-    public void initApp() {
-        addChild(EntitySpec.create(CassandraFabric.class)
-                .configure(CassandraDatacenter.CLUSTER_NAME, "Brooklyn")
-                .configure(CassandraDatacenter.INITIAL_SIZE, 
getConfig(CASSANDRA_CLUSTER_SIZE)) // per location
-                .configure(CassandraDatacenter.ENDPOINT_SNITCH_NAME, 
"brooklyn.entity.nosql.cassandra.customsnitch.MultiCloudSnitch")
-                .configure(CassandraNode.CUSTOM_SNITCH_JAR_URL, 
"classpath://brooklyn/entity/nosql/cassandra/cassandra-multicloud-snitch.jar")
-                .configure(CassandraFabric.MEMBER_SPEC, 
EntitySpec.create(CassandraDatacenter.class)
-                        .configure(CassandraDatacenter.MEMBER_SPEC, 
EntitySpec.create(CassandraNode.class)
-                                
.enricher(EnricherSpec.create(ServiceFailureDetector.class))
-                                
.policy(PolicySpec.create(ServiceRestarter.class)
-                                        
.configure(ServiceRestarter.FAILURE_SENSOR_TO_MONITOR, 
ServiceFailureDetector.ENTITY_FAILED)))
-                        .policy(PolicySpec.create(ServiceReplacer.class)
-                                
.configure(ServiceReplacer.FAILURE_SENSOR_TO_MONITOR, 
ServiceRestarter.ENTITY_RESTART_FAILED))));
-    }
-    
-    public static void main(String[] argv) {
-        List<String> args = Lists.newArrayList(argv);
-        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
-        String locations = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION_SPEC);
-
-        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
-                 .application(EntitySpec.create(StartableApplication.class, 
WideAreaCassandraCluster.class)
-                         .displayName("Cassandra"))
-                 .webconsolePort(port)
-                 .locations(Arrays.asList(locations))
-                 .start();
-             
-        Entities.dumpInfo(launcher.getApplications());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/CumulusRDFApplication.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/CumulusRDFApplication.java
 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/CumulusRDFApplication.java
new file mode 100644
index 0000000..f2ec860
--- /dev/null
+++ 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/CumulusRDFApplication.java
@@ -0,0 +1,240 @@
+/*
+ * 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.
+ */
+package org.apache.brooklyn.demo;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.catalog.Catalog;
+import brooklyn.catalog.CatalogConfig;
+import brooklyn.config.ConfigKey;
+import brooklyn.entity.Effector;
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.AbstractApplication;
+import brooklyn.entity.basic.ConfigKeys;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.EntityInternal;
+import brooklyn.entity.basic.Lifecycle;
+import brooklyn.entity.basic.ServiceStateLogic;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.effector.EffectorBody;
+import brooklyn.entity.effector.Effectors;
+import brooklyn.entity.java.UsesJava;
+import brooklyn.entity.java.UsesJmx;
+import brooklyn.entity.nosql.cassandra.CassandraDatacenter;
+import brooklyn.entity.nosql.cassandra.CassandraFabric;
+import brooklyn.entity.nosql.cassandra.CassandraNode;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.software.SshEffectorTasks;
+import brooklyn.entity.trait.Startable;
+import brooklyn.entity.webapp.JavaWebAppService;
+import brooklyn.entity.webapp.tomcat.TomcatServer;
+import brooklyn.event.SensorEvent;
+import brooklyn.event.SensorEventListener;
+import brooklyn.event.basic.DependentConfiguration;
+import brooklyn.launcher.BrooklynLauncher;
+import brooklyn.location.Location;
+import brooklyn.location.basic.PortRanges;
+import brooklyn.policy.EnricherSpec;
+import brooklyn.policy.PolicySpec;
+import brooklyn.policy.ha.ServiceFailureDetector;
+import brooklyn.policy.ha.ServiceReplacer;
+import brooklyn.policy.ha.ServiceRestarter;
+import brooklyn.util.CommandLineUtil;
+import brooklyn.util.ResourceUtils;
+import brooklyn.util.collections.MutableList;
+import brooklyn.util.collections.MutableMap;
+import brooklyn.util.config.ConfigBag;
+import brooklyn.util.exceptions.Exceptions;
+import brooklyn.util.task.DynamicTasks;
+import brooklyn.util.text.StringEscapes.JavaStringEscapes;
+import brooklyn.util.text.Strings;
+import brooklyn.util.text.TemplateProcessor;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.net.HostAndPort;
+
+/** CumulusRDF application with Cassandra cluster. */
+@Catalog(name="Cumulus RDF Application", description="CumulusRDF Application 
on a Tomcat server using a multi-region Cassandra fabric")
+public class CumulusRDFApplication extends AbstractApplication {
+
+    private static final Logger log = 
LoggerFactory.getLogger(CumulusRDFApplication.class);
+
+    @CatalogConfig(label="Cumulus Configuration File (URL)", priority=1)
+    public static final ConfigKey<String> CUMULUS_RDF_CONFIG_URL = 
ConfigKeys.newConfigKey(
+        "cumulus.config.url", "URL for the YAML configuration file for 
CumulusRDF", "classpath://cumulus.yaml");
+
+    @CatalogConfig(label="Cassandra Thrift Port", priority=1)
+    public static final ConfigKey<Integer> CASSANDRA_THRIFT_PORT = 
ConfigKeys.newConfigKey(
+        "cumulus.cassandra.port", "Port to contact the Cassandra cluster on", 
9160);
+
+    @CatalogConfig(label="Cassandra Cluster Size", priority=1)
+    public static final ConfigKey<Integer> CASSANDRA_CLUSTER_SIZE = 
ConfigKeys.newConfigKey(
+        "cumulus.cassandra.cluster.size", "Initial size of the Cassandra 
cluster", 2);
+
+    @CatalogConfig(label="Multi-region Fabric", priority=1)
+    public static final ConfigKey<Boolean> MULTI_REGION_FABRIC = 
ConfigKeys.newConfigKey(
+        "cumulus.cassandra.fabric", "Deploy a multi-region Cassandra fabric", 
false);
+
+    // TODO Fails when given two locations
+    // public static final String DEFAULT_LOCATIONS = "[ 
jclouds:aws-ec2:us-east-1,jclouds:rackspace-cloudservers-uk ]";
+    public static final String DEFAULT_LOCATIONS = "jclouds:aws-ec2:us-east-1";
+
+    private Effector<Void> cumulusConfig = Effectors.effector(Void.class, 
"cumulusConfig")
+            .description("Configure the CumulusRDF web application")
+            .buildAbstract();
+
+    private Entity cassandra;
+    private TomcatServer webapp;
+    private HostAndPort endpoint;
+    private final Object endpointMutex = new Object();
+
+    /**
+     * Create the application entities:
+     * <ul>
+     * <li>A {@link CassandraFabric} of {@link CassandraDatacenter}s 
containing {@link CassandraNode}s
+     * <li>A {@link TomcatServer}
+     * </ul>
+     */
+    @Override
+    public void initApp() {
+        // Cassandra cluster
+        EntitySpec<CassandraDatacenter> clusterSpec = 
EntitySpec.create(CassandraDatacenter.class)
+                .configure(CassandraDatacenter.MEMBER_SPEC, 
EntitySpec.create(CassandraNode.class)
+                        //FIXME can probably use JMXMP_AND_RMI now, to deploy 
to GCE and elsewhere
+                        .configure(UsesJmx.JMX_AGENT_MODE, 
UsesJmx.JmxAgentModes.JMX_RMI_CUSTOM_AGENT)
+                        .configure(UsesJmx.JMX_PORT, 
PortRanges.fromString("11099+"))
+                        .configure(UsesJmx.RMI_REGISTRY_PORT, 
PortRanges.fromString("9001+"))
+                        .configure(CassandraNode.THRIFT_PORT, 
PortRanges.fromInteger(getConfig(CASSANDRA_THRIFT_PORT)))
+                        
.enricher(EnricherSpec.create(ServiceFailureDetector.class))
+                        .policy(PolicySpec.create(ServiceRestarter.class)
+                                
.configure(ServiceRestarter.FAILURE_SENSOR_TO_MONITOR, 
ServiceFailureDetector.ENTITY_FAILED)))
+                .policy(PolicySpec.create(ServiceReplacer.class)
+                        .configure(ServiceReplacer.FAILURE_SENSOR_TO_MONITOR, 
ServiceRestarter.ENTITY_RESTART_FAILED));
+
+        if (getConfig(MULTI_REGION_FABRIC)) {
+            cassandra = addChild(EntitySpec.create(CassandraFabric.class)
+                    .configure(CassandraDatacenter.CLUSTER_NAME, "Brooklyn")
+                    .configure(CassandraDatacenter.INITIAL_SIZE, 
getConfig(CASSANDRA_CLUSTER_SIZE)) // per location
+                    .configure(CassandraDatacenter.ENDPOINT_SNITCH_NAME, 
"brooklyn.entity.nosql.cassandra.customsnitch.MultiCloudSnitch")
+                    .configure(CassandraNode.CUSTOM_SNITCH_JAR_URL, 
"classpath://brooklyn/entity/nosql/cassandra/cassandra-multicloud-snitch.jar")
+                    .configure(CassandraFabric.MEMBER_SPEC, clusterSpec));
+        } else {
+            cassandra = addChild(EntitySpec.create(clusterSpec)
+                    .configure(CassandraDatacenter.CLUSTER_NAME, "Brooklyn")
+                    .configure(CassandraDatacenter.INITIAL_SIZE, 
getConfig(CASSANDRA_CLUSTER_SIZE)));
+        }
+
+        // Tomcat web-app server
+        webapp = addChild(EntitySpec.create(TomcatServer.class)
+                .configure(UsesJmx.JMX_AGENT_MODE, 
UsesJmx.JmxAgentModes.JMX_RMI_CUSTOM_AGENT)
+                .configure(UsesJmx.JMX_PORT, PortRanges.fromString("11099+"))
+                .configure(UsesJmx.RMI_REGISTRY_PORT, 
PortRanges.fromString("9001+"))
+                .configure(JavaWebAppService.ROOT_WAR, 
"https://cumulusrdf.googlecode.com/svn/wiki/downloads/cumulusrdf-1.0.1.war";)
+                .configure(UsesJava.JAVA_SYSPROPS, 
MutableMap.of("cumulusrdf.config-file", "/tmp/cumulus.yaml")));
+
+        // Add an effector to tomcat to reconfigure with a new YAML config file
+        ((EntityInternal) 
webapp).getMutableEntityType().addEffector(cumulusConfig, new 
EffectorBody<Void>() {
+            @Override
+            public Void call(ConfigBag parameters) {
+                // Process the YAML template given in the application config
+                String url = 
Entities.getRequiredUrlConfig(CumulusRDFApplication.this, 
CUMULUS_RDF_CONFIG_URL);
+                Map<String, Object> config;
+                synchronized (endpointMutex) {
+                    config = MutableMap.<String, 
Object>of("cassandraHostname", endpoint.getHostText(), "cassandraThriftPort", 
endpoint.getPort());
+                }
+                String contents = 
TemplateProcessor.processTemplateContents(ResourceUtils.create(CumulusRDFApplication.this).getResourceAsString(url),
 config);
+                // Copy the file contents to the remote machine
+                return 
DynamicTasks.queue(SshEffectorTasks.put("/tmp/cumulus.yaml").contents(contents)).get();
+            }
+        });
+
+        // Listen for HOSTNAME changes from the Cassandra fabric to show at 
least one node is available
+        subscribe(cassandra, CassandraDatacenter.HOSTNAME, new 
SensorEventListener<String>() {
+            @Override
+            public void onEvent(SensorEvent<String> event) {
+                if (Strings.isNonBlank(event.getValue())) {
+                    synchronized (endpointMutex) {
+                        String hostname = 
Entities.submit(CumulusRDFApplication.this, 
DependentConfiguration.attributeWhenReady(cassandra, 
CassandraDatacenter.HOSTNAME)).getUnchecked();
+                        Integer thriftPort = 
Entities.submit(CumulusRDFApplication.this, 
DependentConfiguration.attributeWhenReady(cassandra, 
CassandraDatacenter.THRIFT_PORT)).getUnchecked();
+                        HostAndPort current = HostAndPort.fromParts(hostname, 
thriftPort);
+
+                        // Check if the cluster access point has changed
+                        if (!current.equals(endpoint)) {
+                            log.info("Setting cluster endpoint to {}", 
current.toString());
+                            endpoint = current;
+
+                            // Reconfigure the CumulusRDF application and 
restart tomcat if necessary
+                            webapp.invoke(cumulusConfig, MutableMap.<String, 
Object>of());
+                            if (webapp.getAttribute(Startable.SERVICE_UP)) {
+                                webapp.restart();
+                            }
+                        }
+                    }
+                }
+            }
+        });
+    }
+
+    /**
+     * Controls the startup locations for the webapp and the cassandra fabric.
+     *
+     * @see AbstractApplication#start(Collection)
+     */
+    @Override
+    public void start(Collection<? extends Location> locations) {
+        addLocations(locations);
+
+        // The web application only needs to run in one location, use the first
+        // TODO use a multi-region web cluster
+        Collection<? extends Location> first = 
MutableList.copyOf(Iterables.limit(locations, 1));
+
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+        try {
+            Entities.invokeEffector(this, cassandra, Startable.START, 
MutableMap.of("locations", locations)).getUnchecked();
+            Entities.invokeEffector(this, webapp, Startable.START, 
MutableMap.of("locations", first)).getUnchecked();
+        } catch (Exception e) {
+            throw Exceptions.propagate(e);
+        } finally {
+            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
+        }
+        log.info("Started CumulusRDF in " + locations);
+    }
+
+
+    public static void main(String[] argv) {
+        List<String> args = Lists.newArrayList(argv);
+        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
+        String locations = CommandLineUtil.getCommandLineOption(args, 
"--locations", DEFAULT_LOCATIONS);
+
+        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
+                .application(EntitySpec.create(StartableApplication.class, 
CumulusRDFApplication.class).displayName("CumulusRDF application using 
Cassandra"))
+                .webconsolePort(port)
+                .locations(Strings.isBlank(locations) ? 
ImmutableList.<String>of() : 
JavaStringEscapes.unwrapJsonishListIfPossible(locations))
+                .start();
+
+        Entities.dumpInfo(launcher.getApplications());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/HighAvailabilityCassandraCluster.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/HighAvailabilityCassandraCluster.java
 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/HighAvailabilityCassandraCluster.java
new file mode 100644
index 0000000..b6800f1
--- /dev/null
+++ 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/HighAvailabilityCassandraCluster.java
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+package org.apache.brooklyn.demo;
+
+import java.util.List;
+
+import brooklyn.catalog.Catalog;
+import brooklyn.catalog.CatalogConfig;
+import brooklyn.config.ConfigKey;
+import brooklyn.entity.basic.AbstractApplication;
+import brooklyn.entity.basic.ConfigKeys;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.nosql.cassandra.CassandraDatacenter;
+import brooklyn.entity.nosql.cassandra.CassandraNode;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.launcher.BrooklynLauncher;
+import brooklyn.policy.EnricherSpec;
+import brooklyn.policy.PolicySpec;
+import brooklyn.policy.ha.ServiceFailureDetector;
+import brooklyn.policy.ha.ServiceReplacer;
+import brooklyn.policy.ha.ServiceRestarter;
+import brooklyn.util.CommandLineUtil;
+
+import com.google.common.collect.Lists;
+
+@Catalog(name="HA Cassandra Cluster Application", description="Deploy a 
Cassandra cluster with a High Availability architecture.")
+public class HighAvailabilityCassandraCluster extends AbstractApplication {
+
+    public static final String DEFAULT_LOCATION_SPEC = "aws-ec2:us-east-1";
+ 
+    @CatalogConfig(label="Number of Availability Zones", priority=1)
+    public static final ConfigKey<Integer> NUM_AVAILABILITY_ZONES = 
ConfigKeys.newConfigKey(
+        "cassandra.cluster.numAvailabilityZones", "Number of availability 
zones to spread the cluster across", 3); 
+    
+    @CatalogConfig(label="Initial Cluster Size", priority=2)
+    public static final ConfigKey<Integer> CASSANDRA_CLUSTER_SIZE = 
ConfigKeys.newConfigKey(
+        "cassandra.cluster.initialSize", "Initial size of the Cassandra 
cluster", 6);      
+    
+    
+    @Override
+    public void initApp() {
+        addChild(EntitySpec.create(CassandraDatacenter.class)
+                .configure(CassandraDatacenter.CLUSTER_NAME, "Brooklyn")
+                .configure(CassandraDatacenter.INITIAL_SIZE, 
getConfig(CASSANDRA_CLUSTER_SIZE))
+                .configure(CassandraDatacenter.ENABLE_AVAILABILITY_ZONES, true)
+                .configure(CassandraDatacenter.NUM_AVAILABILITY_ZONES, 
getConfig(NUM_AVAILABILITY_ZONES))
+                //See https://github.com/brooklyncentral/brooklyn/issues/973
+                //.configure(CassandraCluster.AVAILABILITY_ZONE_NAMES, 
ImmutableList.of("us-east-1b", "us-east-1c", "us-east-1e"))
+                .configure(CassandraDatacenter.ENDPOINT_SNITCH_NAME, 
"GossipingPropertyFileSnitch")
+                .configure(CassandraDatacenter.MEMBER_SPEC, 
EntitySpec.create(CassandraNode.class)
+                        
.enricher(EnricherSpec.create(ServiceFailureDetector.class))
+                        .policy(PolicySpec.create(ServiceRestarter.class)
+                                
.configure(ServiceRestarter.FAILURE_SENSOR_TO_MONITOR, 
ServiceFailureDetector.ENTITY_FAILED)))
+                .policy(PolicySpec.create(ServiceReplacer.class)
+                        .configure(ServiceReplacer.FAILURE_SENSOR_TO_MONITOR, 
ServiceRestarter.ENTITY_RESTART_FAILED)));
+    }
+    
+    public static void main(String[] argv) {
+        List<String> args = Lists.newArrayList(argv);
+        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
+        String location = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION_SPEC);
+        
+        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
+                 .application(EntitySpec.create(StartableApplication.class, 
HighAvailabilityCassandraCluster.class)
+                         .displayName("Cassandra"))
+                 .webconsolePort(port)
+                 .location(location)
+                 .start();
+             
+        Entities.dumpInfo(launcher.getApplications());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/ResilientMongoDbApp.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/ResilientMongoDbApp.java
 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/ResilientMongoDbApp.java
new file mode 100644
index 0000000..d98a11c
--- /dev/null
+++ 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/ResilientMongoDbApp.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+package org.apache.brooklyn.demo;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.catalog.Catalog;
+import brooklyn.enricher.Enrichers;
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.AbstractApplication;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.SoftwareProcess;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.group.DynamicCluster;
+import brooklyn.entity.nosql.mongodb.MongoDBReplicaSet;
+import brooklyn.entity.nosql.mongodb.MongoDBServer;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.event.SensorEvent;
+import brooklyn.event.SensorEventListener;
+import brooklyn.launcher.BrooklynLauncher;
+import brooklyn.policy.ha.ServiceFailureDetector;
+import brooklyn.policy.ha.ServiceReplacer;
+import brooklyn.policy.ha.ServiceRestarter;
+import brooklyn.util.CommandLineUtil;
+
+import com.google.common.collect.Lists;
+
+/**
+ * Sample showing a MongoDB replica set with resilience policies attached at 
nodes and the cluster.
+ **/
+@Catalog(name="Resilient MongoDB")
+public class ResilientMongoDbApp extends AbstractApplication implements 
StartableApplication {
+    
+    public static final Logger LOG = 
LoggerFactory.getLogger(ResilientMongoDbApp.class);
+    
+    public static final String DEFAULT_LOCATION = "named:gce-europe-west1";
+
+    @Override
+    public void initApp() {
+        MongoDBReplicaSet rs = addChild(
+                EntitySpec.create(MongoDBReplicaSet.class)
+                        .configure(MongoDBReplicaSet.INITIAL_SIZE, 3));
+        
+        initResilience(rs);
+        
+        addEnricher(Enrichers.builder()
+                .propagating(MongoDBReplicaSet.REPLICA_SET_ENDPOINTS, 
MongoDBServer.REPLICA_SET_PRIMARY_ENDPOINT)
+                .from(rs)
+                .build());
+    }
+    
+    /** this attaches a policy at each MongoDB node listening for 
ENTITY_FAILED,
+     * attempting to _restart_ the process, and 
+     * failing that attempting to _replace_ the entity (e.g. a new VM), and 
+     * failing that setting the cluster "on-fire" */
+    protected void initResilience(MongoDBReplicaSet rs) {
+        subscribe(rs, DynamicCluster.MEMBER_ADDED, new 
SensorEventListener<Entity>() {
+            @Override
+            public void onEvent(SensorEvent<Entity> addition) {
+                initSoftwareProcess((SoftwareProcess)addition.getValue());
+            }
+        });
+        rs.addPolicy(new 
ServiceReplacer(ServiceRestarter.ENTITY_RESTART_FAILED));
+    }
+
+    /** invoked whenever a new MongoDB server is added (the server may not be 
started yet) */
+    protected void initSoftwareProcess(SoftwareProcess p) {
+        p.addEnricher(new ServiceFailureDetector());
+        p.addPolicy(new 
ServiceRestarter(ServiceFailureDetector.ENTITY_FAILED));
+    }
+    
+    public static void main(String[] argv) {
+        List<String> args = Lists.newArrayList(argv);
+        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
+        String location = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION);
+
+        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
+                 .application(EntitySpec.create(StartableApplication.class, 
ResilientMongoDbApp.class)
+                         .displayName("Resilient MongoDB"))
+                 .webconsolePort(port)
+                 .location(location)
+                 .start();
+             
+        Entities.dumpInfo(launcher.getApplications());
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/RiakClusterExample.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/RiakClusterExample.java
 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/RiakClusterExample.java
new file mode 100644
index 0000000..672aba3
--- /dev/null
+++ 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/RiakClusterExample.java
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+package org.apache.brooklyn.demo;
+
+import java.util.List;
+
+import brooklyn.catalog.Catalog;
+import brooklyn.catalog.CatalogConfig;
+import brooklyn.config.ConfigKey;
+import brooklyn.entity.basic.AbstractApplication;
+import brooklyn.entity.basic.ConfigKeys;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.nosql.riak.RiakCluster;
+import brooklyn.entity.nosql.riak.RiakNode;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.launcher.BrooklynLauncher;
+import brooklyn.policy.EnricherSpec;
+import brooklyn.policy.PolicySpec;
+import brooklyn.policy.ha.ServiceFailureDetector;
+import brooklyn.policy.ha.ServiceRestarter;
+import brooklyn.util.CommandLineUtil;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+
+@Catalog(name = "Riak Cluster Application", description = "Riak ring 
deployment blueprint")
+public class RiakClusterExample extends AbstractApplication {
+
+    public static final String DEFAULT_LOCATION_SPEC = "aws-ec2:us-east-1";
+
+    @CatalogConfig(label = "Riak Ring Size")
+    public static final ConfigKey<Integer> RIAK_RING_SIZE = 
ConfigKeys.newConfigKey(
+            "riak.ring.size", "Initial size of the Riak Ring", 4);
+
+    public static void main(String[] argv) {
+        List<String> args = Lists.newArrayList(argv);
+        String port = CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
+        String location = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION_SPEC);
+        Preconditions.checkArgument(args.isEmpty(), "Unsupported args: " + 
args);
+
+        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
+                .application(EntitySpec.create(StartableApplication.class, 
RiakClusterExample.class))
+                .webconsolePort(port)
+                .location(location)
+                .start();
+
+        Entities.dumpInfo(launcher.getApplications());
+    }
+
+    public void initApp() {
+        addChild(EntitySpec.create(RiakCluster.class)
+                .configure(RiakCluster.INITIAL_SIZE, getConfig(RIAK_RING_SIZE))
+                .configure(RiakCluster.MEMBER_SPEC, 
EntitySpec.create(RiakNode.class)
+                        
.enricher(EnricherSpec.create(ServiceFailureDetector.class))
+                        .policy(PolicySpec.create(ServiceRestarter.class)
+                                
.configure(ServiceRestarter.FAILURE_SENSOR_TO_MONITOR, 
ServiceFailureDetector.ENTITY_FAILED))));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleCassandraCluster.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleCassandraCluster.java
 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleCassandraCluster.java
new file mode 100644
index 0000000..2ba6ba3
--- /dev/null
+++ 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleCassandraCluster.java
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+package org.apache.brooklyn.demo;
+
+import java.util.List;
+
+import brooklyn.entity.basic.AbstractApplication;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.nosql.cassandra.CassandraDatacenter;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.launcher.BrooklynLauncher;
+import brooklyn.util.CommandLineUtil;
+
+import com.google.common.collect.Lists;
+
+public class SimpleCassandraCluster extends AbstractApplication {
+
+    private static final String DEFAULT_LOCATION = "localhost";
+
+    @Override
+    public void initApp() {
+        addChild(EntitySpec.create(CassandraDatacenter.class)
+                .configure(CassandraDatacenter.INITIAL_SIZE, 1)
+                .configure(CassandraDatacenter.CLUSTER_NAME, "Brooklyn"));
+    }
+    
+    public static void main(String[] argv) {
+        List<String> args = Lists.newArrayList(argv);
+        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
+        String location = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION);
+        
+        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
+                 .application(EntitySpec.create(StartableApplication.class, 
SimpleCassandraCluster.class)
+                         .displayName("Cassandra"))
+                         .webconsolePort(port)
+                 .location(location)
+                 .start();
+             
+        Entities.dumpInfo(launcher.getApplications());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleCouchDBCluster.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleCouchDBCluster.java
 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleCouchDBCluster.java
new file mode 100644
index 0000000..0919c24
--- /dev/null
+++ 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleCouchDBCluster.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+package org.apache.brooklyn.demo;
+
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.nosql.couchdb.CouchDBCluster;
+import brooklyn.entity.proxying.EntitySpec;
+
+/** CouchDB cluster. */
+public class SimpleCouchDBCluster extends ApplicationBuilder {
+
+    /** Create entities. */
+    protected void doBuild() {
+        addChild(EntitySpec.create(CouchDBCluster.class)
+                .configure("initialSize", "2")
+                .configure("clusterName", "Brooklyn")
+                .configure("httpPort", "8000+"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleMongoDBReplicaSet.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleMongoDBReplicaSet.java
 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleMongoDBReplicaSet.java
new file mode 100644
index 0000000..249431c
--- /dev/null
+++ 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleMongoDBReplicaSet.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+package org.apache.brooklyn.demo;
+
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.nosql.mongodb.MongoDBReplicaSet;
+import brooklyn.entity.nosql.mongodb.MongoDBServer;
+import brooklyn.entity.proxying.EntitySpec;
+
+public class SimpleMongoDBReplicaSet extends ApplicationBuilder {
+
+    protected void doBuild() {
+        addChild(EntitySpec.create(MongoDBReplicaSet.class)
+            .configure("name", "Simple MongoDB replica set")
+            .configure("initialSize", 3)
+            .configure("replicaSetName", "simple-replica-set")
+            .configure("memberSpec", EntitySpec.create(MongoDBServer.class)
+                    .configure("mongodbConfTemplateUrl", 
"classpath:///mongodb.conf")
+                    .configure("enableRestInterface", true)
+                    .configure("port", "27017+")));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleRedisCluster.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleRedisCluster.java
 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleRedisCluster.java
new file mode 100644
index 0000000..96268c3
--- /dev/null
+++ 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/SimpleRedisCluster.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+package org.apache.brooklyn.demo;
+
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.nosql.redis.RedisCluster;
+import brooklyn.entity.proxying.EntitySpec;
+
+/** Redis cluster. */
+public class SimpleRedisCluster extends ApplicationBuilder {
+
+    /** Create entities. */
+    protected void doBuild() {
+        addChild(EntitySpec.create(RedisCluster.class)
+                .configure("initialSize", "2")
+                .configure("clusterName", "Brooklyn"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/44d2dc11/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/StormSampleApp.java
----------------------------------------------------------------------
diff --git 
a/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/StormSampleApp.java
 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/StormSampleApp.java
new file mode 100644
index 0000000..37d0ec4
--- /dev/null
+++ 
b/examples/simple-nosql-cluster/src/main/java/org/apache/brooklyn/demo/StormSampleApp.java
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+package org.apache.brooklyn.demo;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.catalog.Catalog;
+import brooklyn.entity.basic.AbstractApplication;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.messaging.storm.StormDeployment;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.launcher.BrooklynLauncher;
+import brooklyn.util.CommandLineUtil;
+
+import com.google.common.collect.Lists;
+
+/**
+ * Sample showing a storm analyticscluster
+ **/
+@Catalog(name="Storm Sample App",
+description="Creates a Storm analytics cluster",
+    iconUrl="classpath://brooklyn/demo/glossy-3d-blue-web-icon.png")
+public class StormSampleApp extends AbstractApplication implements 
StartableApplication {
+
+    public static final Logger LOG = 
LoggerFactory.getLogger(StormSampleApp.class);
+
+    public static final String DEFAULT_LOCATION = "named:gce-europe-west1";
+
+    @Override
+    public void initApp() {
+        addChild(EntitySpec.create(StormDeployment.class)
+            .configure(StormDeployment.SUPERVISORS_COUNT, 2)
+            .configure(StormDeployment.ZOOKEEPERS_COUNT, 1));
+    }
+
+    public static void main(String[] argv) {
+        List<String> args = Lists.newArrayList(argv);
+        String port =  CommandLineUtil.getCommandLineOption(args, "--port", 
"8081+");
+        String location = CommandLineUtil.getCommandLineOption(args, 
"--location", DEFAULT_LOCATION);
+
+        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
+            .application(EntitySpec.create(StartableApplication.class, 
StormSampleApp.class)
+                .displayName("Storm App"))
+                .webconsolePort(port)
+                .location(location)
+                .start();
+
+        Entities.dumpInfo(launcher.getApplications());
+    }
+}

Reply via email to