Defining and Deploying

Intro

This walkthrough will set up a sample application which you can use as foundation for creating your own applications.

The sample application is a three tier web service, composed of:

  • an Nginx load-balancer
  • a cluster of JBoss appservers
  • a MySQL database

Define your Application Blueprint

An application blueprint is defined as a Java class, as follows:

public class ClusterWebServerDatabaseSample extends AbstractApplication {
    @Override
    public void init() {
        MySqlNode mysql = addChild(EntitySpec.create(MySqlNode.class));
        ControlledDynamicWebAppCluster web = addChild(EntitySpec.create(ControlledDynamicWebAppCluster.class));
    }
}

The file ClusterWebServerDatabaseSample.java in src/main/java/com/acme/sample/brooklyn/sample/app/ provides a template to follow.

Deploying the Application

If you have not already done so, follow the instructions here to create a brooklyn.properties file containing credentials for your preferred cloud provider.

To launch this application, build the project and run the start.sh script in the resulting assembly:

$ mvn clean assembly:assembly

$ cd target/brooklyn-sample-0.1.0-SNAPSHOT-dist/brooklyn-sample-0.1.0-SNAPSHOT/

$ ./start.sh launch \
    --app com.acme.sample.brooklyn.sample.app.ClusterWebServerDatabaseSample \
    --location jclouds:aws-ec2:eu-west-1

(Amazon is used in this walkthrough, but lots of targets are supported, including --location localhost, fixed IP addresses, and everything supported by jclouds, from OpenStack to Google Compute.)

Your console will inform you that it has started a Brooklyn console at http://localhost:8081

Web Console

The management console provides a view on to the entities that launched, including the hierarchy (appservers grouped into a cluster) and their locations.

Brooklyn collects information from these entities (“sensors”), aggregates these for clusters and other groups (using “enrichers”), and exposes operations (“effectors”) that can be performed on entities.

Web Console Details

What Next?

In addition to the sample project created by the archetype, with its README and assembly build, you can find additional code related to this example included with Brooklyn as the simple-web-cluster example.

For your applications, you might want to mix in other data stores, messaging systems, or on-line services including PaaS. Brooklyn supports some of these out-of-the-box, including a wide-range of tools which it can use Whirr to provision, such as Hadoop. But if you have something you don’t see, let us know – we want to work with you to write a new entity or policy and contribute it.