You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/10/11 15:04:35 UTC
[2/9] git commit: Move examples/simple-open-loop-policy to sandbox
Move examples/simple-open-loop-policy to sandbox
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/0549c26f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/0549c26f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/0549c26f
Branch: refs/heads/master
Commit: 0549c26f92eeec34c1a9e6f51462f951cb88b9ff
Parents: a13d062
Author: Aled Sage <al...@gmail.com>
Authored: Wed Oct 8 16:10:24 2014 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Oct 10 16:28:57 2014 +0100
----------------------------------------------------------------------
examples/pom.xml | 15 --
examples/simple-open-loop-policy/README.txt | 72 ---------
.../org.marre.smsj-1.0.0-20051126.jar | Bin 134604 -> 0 bytes
.../org.marre.smsj-1.0.0-20051126.pom | 9 --
.../org.marre.smsj/maven-metadata-local.xml | 30 ----
examples/simple-open-loop-policy/pom.xml | 141 -----------------
.../resources/jmeter-test-plan.jmx | 143 -----------------
.../src/main/java/brooklyn/demo/Sms.java | 63 --------
.../demo/WebClusterDatabaseOpenLoopExample.java | 157 -------------------
.../main/resources/visitors-creation-script.sql | 35 -----
.../src/test/java/brooklyn/demo/SmsTest.java | 50 ------
pom.xml | 1 +
.../examples/simple-open-loop-policy/README.txt | 72 +++++++++
.../org.marre.smsj-1.0.0-20051126.jar | Bin 0 -> 134604 bytes
.../org.marre.smsj-1.0.0-20051126.pom | 9 ++
.../org.marre.smsj/maven-metadata-local.xml | 30 ++++
.../examples/simple-open-loop-policy/pom.xml | 157 +++++++++++++++++++
.../resources/jmeter-test-plan.jmx | 143 +++++++++++++++++
.../src/main/java/brooklyn/demo/Sms.java | 63 ++++++++
.../demo/WebClusterDatabaseOpenLoopExample.java | 157 +++++++++++++++++++
.../main/resources/visitors-creation-script.sql | 35 +++++
.../src/test/java/brooklyn/demo/SmsTest.java | 50 ++++++
22 files changed, 717 insertions(+), 715 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index d4d1022..26d2cd6 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -55,19 +55,4 @@
<module>simple-messaging-pubsub</module>
<module>simple-nosql-cluster</module>
</modules>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes combine.children="append">
- <exclude>**/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.pom</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/simple-open-loop-policy/README.txt
----------------------------------------------------------------------
diff --git a/examples/simple-open-loop-policy/README.txt b/examples/simple-open-loop-policy/README.txt
deleted file mode 100644
index 85c9336..0000000
--- a/examples/simple-open-loop-policy/README.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-Instructions for Running Examples
-=================================
-
-The commands below assume that the `brooklyn` script is on your $PATH, this project has been built,
-and you are in this directory. Adjust to taste for other configurations.
-
- export BROOKLYN_CLASSPATH=$(pwd)/target/classes
-
- # Three-tier: auto-scaling app-server cluster fronted by nginx, MySql backend wired up, on localhost
- brooklyn launch --app brooklyn.demo.WebClusterDatabaseOpenLoopExample --location localhost
-
-The above requires passwordless `ssh localhost` and requires `gcc` to build `nginx`.
-You could instead target your favourite cloud, where this has been tried and tested:
-
-
-Redistributable embedded example:
-
- # To build a redistributable tar.gz with a start.sh script
- # which invokes the `main` method in the example class to start
- # (the redistributable will be at: target/brooklyn-*-bin.tar.gz )
- mvn clean assembly:assembly
-
-For more information, please visit:
-
- http://brooklyncentral.github.com/use/examples/webcluster/
-
-
-Developer Notes
-===============
-
-This example sends an SMS message when the cluster has reached its max size (and where the auto-scaler policy
-would continue to increase the size if it were not capped). The message is sent using clickatell.com,
-using http://smsj.sourceforge.net.
-
-Because smsj is not available on maven central, a custom local maven repo has been built (and checked in to git):
-
- wget http://sourceforge.net/projects/smsj/files/smsj/smsj-snapshot-20051126/smsj-20051126.jar/download
-
- mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file \
- -Dfile=smsj-20051126.jar \
- -DgroupId=io.brooklyn \
- -DartifactId=org.marre.smsj \
- -Dversion=1.0.0-20051126 \
- -Dpackaging=jar \
- -DlocalRepositoryPath=localrepo
-
-And in the pom, this local repo is referenced:
-
- <repositories>
- <repository>
- <id>brooklyn-examples-localrepo</id>
- <url>file://${basedir}/localrepo</url>
- </repository>
- </repositories>
-
-----
-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.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.jar
----------------------------------------------------------------------
diff --git a/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.jar b/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.jar
deleted file mode 100644
index a076a47..0000000
Binary files a/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.jar and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.pom
----------------------------------------------------------------------
diff --git a/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.pom b/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.pom
deleted file mode 100644
index 7361303..0000000
--- a/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.pom
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <groupId>io.brooklyn</groupId>
- <artifactId>org.marre.smsj</artifactId>
- <version>1.0.0-20051126</version>
- <description>POM was created from install:install-file</description>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/maven-metadata-local.xml
----------------------------------------------------------------------
diff --git a/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/maven-metadata-local.xml b/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/maven-metadata-local.xml
deleted file mode 100644
index c0018bb..0000000
--- a/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/maven-metadata-local.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<metadata>
- <groupId>io.brooklyn</groupId>
- <artifactId>org.marre.smsj</artifactId>
- <versioning>
- <release>1.0.0-20051126</release>
- <versions>
- <version>1.0.0-20051126</version>
- </versions>
- <lastUpdated>20130206095028</lastUpdated>
- </versioning>
-</metadata>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/simple-open-loop-policy/pom.xml
----------------------------------------------------------------------
diff --git a/examples/simple-open-loop-policy/pom.xml b/examples/simple-open-loop-policy/pom.xml
deleted file mode 100644
index 32a8807..0000000
--- a/examples/simple-open-loop-policy/pom.xml
+++ /dev/null
@@ -1,141 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <packaging>jar</packaging>
- <artifactId>brooklyn-example-simple-open-loop-policy</artifactId>
- <name>Brooklyn Simple Web Cluster Example</name>
-
- <!-- this is only needed for "mvn deploy"; the group and version can be extracted
- and parent block removed to run this standalone -->
- <parent>
- <groupId>org.apache.brooklyn.example</groupId>
- <artifactId>brooklyn-examples-parent</artifactId>
- <version>0.7.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <repositories>
- <repository>
- <id>brooklyn-examples-localrepo</id>
- <url>file://${basedir}/localrepo</url>
- </repository>
- </repositories>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>org.marre.smsj</artifactId>
- <version>${org.marre.smsj.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-all</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-logback-xml</artifactId>
- <version>${project.version}</version>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-test-support</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <!-- copy the WAR so it is available on the classpath for programmatic deployment -->
- <executions>
- <execution>
- <id>copy</id>
- <phase>process-classes</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <!-- these can fail in eclipse trying to copy _from_ target/classes.
- see http://jira.codehaus.org/browse/MDEP-259 -->
- <artifactItem>
- <groupId>org.apache.brooklyn.example</groupId>
- <artifactId>brooklyn-example-hello-world-webapp</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- <overWrite>true</overWrite>
- <outputDirectory>target/classes</outputDirectory>
- <destFileName>hello-world-webapp.war</destFileName>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.brooklyn.example</groupId>
- <artifactId>brooklyn-example-hello-world-sql-webapp</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- <overWrite>true</overWrite>
- <outputDirectory>target/classes</outputDirectory>
- <destFileName>hello-world-sql-webapp.war</destFileName>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <configuration>
- <filesets>
- <fileset>
- <directory>${project.basedir}</directory>
- <includes>
- <include>${project.artifactId}/</include>
- <include>brooklyn*.log</include>
- <include>brooklyn*.log.*</include>
- <include>stacktrace.log</include>
- </includes>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
-<!-- TODO assembly not supported for this example, currently
- <plugin>
--->
- <!-- TODO assembly not supported for this example, currently -->
- <!-- optional, with this block, `mvn assembly:assembly` will build a redistributable tgz -->
-<!--
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/assembly.xml</descriptor>
- </descriptors>
- </configuration>
- </plugin>
--->
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/simple-open-loop-policy/resources/jmeter-test-plan.jmx
----------------------------------------------------------------------
diff --git a/examples/simple-open-loop-policy/resources/jmeter-test-plan.jmx b/examples/simple-open-loop-policy/resources/jmeter-test-plan.jmx
deleted file mode 100644
index 0eb1741..0000000
--- a/examples/simple-open-loop-policy/resources/jmeter-test-plan.jmx
+++ /dev/null
@@ -1,143 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<jmeterTestPlan version="1.2" properties="2.1">
- <hashTree>
- <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Brooklyn local webapp test - load for localhost:8000" enabled="true">
- <stringProp name="TestPlan.comments"></stringProp>
- <boolProp name="TestPlan.functional_mode">false</boolProp>
- <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
- <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
- <collectionProp name="Arguments.arguments"/>
- </elementProp>
- <stringProp name="TestPlan.user_define_classpath"></stringProp>
- </TestPlan>
- <hashTree>
- <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Test Group - hitting site with 8 threads" enabled="true">
- <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
- <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
- <boolProp name="LoopController.continue_forever">false</boolProp>
- <intProp name="LoopController.loops">-1</intProp>
- </elementProp>
- <stringProp name="ThreadGroup.num_threads">8</stringProp>
- <stringProp name="ThreadGroup.ramp_time">1</stringProp>
- <longProp name="ThreadGroup.start_time">1326116677000</longProp>
- <longProp name="ThreadGroup.end_time">1326116677000</longProp>
- <boolProp name="ThreadGroup.scheduler">false</boolProp>
- <stringProp name="ThreadGroup.duration"></stringProp>
- <stringProp name="ThreadGroup.delay"></stringProp>
- </ThreadGroup>
- <hashTree>
- <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Timer - frequency 50 reqs/sec per thread (20 ms delay)" enabled="true">
- <stringProp name="ConstantTimer.delay">20</stringProp>
- </ConstantTimer>
- <hashTree/>
- <HTTPSampler guiclass="HttpTestSampleGui" testclass="HTTPSampler" testname="HTTP Request - localhost:8000" enabled="true">
- <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
- <collectionProp name="Arguments.arguments"/>
- </elementProp>
- <stringProp name="HTTPSampler.domain">localhost</stringProp>
- <stringProp name="HTTPSampler.port">8000</stringProp>
- <stringProp name="HTTPSampler.connect_timeout"></stringProp>
- <stringProp name="HTTPSampler.response_timeout"></stringProp>
- <stringProp name="HTTPSampler.protocol"></stringProp>
- <stringProp name="HTTPSampler.contentEncoding"></stringProp>
- <stringProp name="HTTPSampler.path"></stringProp>
- <stringProp name="HTTPSampler.method">GET</stringProp>
- <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
- <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
- <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
- <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
- <boolProp name="HTTPSampler.monitor">false</boolProp>
- <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
- </HTTPSampler>
- <hashTree/>
- <CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="HTTP Cookie Manager" enabled="true">
- <collectionProp name="CookieManager.cookies"/>
- <boolProp name="CookieManager.clearEachIteration">false</boolProp>
- </CookieManager>
- <hashTree/>
- </hashTree>
- <ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="Summary Report" enabled="true">
- <boolProp name="ResultCollector.error_logging">false</boolProp>
- <objProp>
- <name>saveConfig</name>
- <value class="SampleSaveConfiguration">
- <time>true</time>
- <latency>true</latency>
- <timestamp>true</timestamp>
- <success>true</success>
- <label>true</label>
- <code>true</code>
- <message>true</message>
- <threadName>true</threadName>
- <dataType>true</dataType>
- <encoding>false</encoding>
- <assertions>true</assertions>
- <subresults>true</subresults>
- <responseData>false</responseData>
- <samplerData>false</samplerData>
- <xml>true</xml>
- <fieldNames>false</fieldNames>
- <responseHeaders>false</responseHeaders>
- <requestHeaders>false</requestHeaders>
- <responseDataOnError>false</responseDataOnError>
- <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
- <assertionsResultsToSave>0</assertionsResultsToSave>
- <bytes>true</bytes>
- </value>
- </objProp>
- <stringProp name="filename"></stringProp>
- </ResultCollector>
- <hashTree/>
- <ResultCollector guiclass="SplineVisualizer" testclass="ResultCollector" testname="Spline Visualizer" enabled="true">
- <boolProp name="ResultCollector.error_logging">false</boolProp>
- <objProp>
- <name>saveConfig</name>
- <value class="SampleSaveConfiguration">
- <time>true</time>
- <latency>true</latency>
- <timestamp>true</timestamp>
- <success>true</success>
- <label>true</label>
- <code>true</code>
- <message>true</message>
- <threadName>true</threadName>
- <dataType>true</dataType>
- <encoding>false</encoding>
- <assertions>true</assertions>
- <subresults>true</subresults>
- <responseData>false</responseData>
- <samplerData>false</samplerData>
- <xml>true</xml>
- <fieldNames>false</fieldNames>
- <responseHeaders>false</responseHeaders>
- <requestHeaders>false</requestHeaders>
- <responseDataOnError>false</responseDataOnError>
- <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
- <assertionsResultsToSave>0</assertionsResultsToSave>
- <bytes>true</bytes>
- </value>
- </objProp>
- <stringProp name="filename"></stringProp>
- </ResultCollector>
- <hashTree/>
- </hashTree>
- </hashTree>
-</jmeterTestPlan>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/Sms.java
----------------------------------------------------------------------
diff --git a/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/Sms.java b/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/Sms.java
deleted file mode 100644
index 9a3d52e..0000000
--- a/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/Sms.java
+++ /dev/null
@@ -1,63 +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.io.IOException;
-
-import org.marre.SmsSender;
-import org.marre.sms.SmsException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class Sms {
-
- private static final Logger LOG = LoggerFactory.getLogger(Sms.class);
-
- private final String username;
- private final String password;
- private final String apiid;
- private final String sender;
-
- public Sms(String username, String password, String apiid) {
- this.username = username;
- this.password = password;
- this.apiid = apiid;
- this.sender = null;
- }
-
- /**
- *
- * @param receiver International number to reciever without leading "+"
- * @param msg The message that you want to send
- * @throws IOException
- * @throws SmsException
- */
- public void sendSms(String receiver, String msg) throws SmsException, IOException {
- // Send SMS with clickatell
- SmsSender smsSender = SmsSender.getClickatellSender(username, password, apiid);
-
- smsSender.connect();
- try {
- String msgid = smsSender.sendTextSms(msg, receiver, sender);
- LOG.debug("Sent SMS via {}@clickatell to {}, msg {}; id {}", new Object[] {username, receiver, msg, msgid});
- } finally {
- smsSender.disconnect();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/WebClusterDatabaseOpenLoopExample.java
----------------------------------------------------------------------
diff --git a/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/WebClusterDatabaseOpenLoopExample.java b/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/WebClusterDatabaseOpenLoopExample.java
deleted file mode 100644
index 466e4dd..0000000
--- a/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/WebClusterDatabaseOpenLoopExample.java
+++ /dev/null
@@ -1,157 +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 static brooklyn.entity.java.JavaEntityMethods.javaSysProp;
-import static brooklyn.event.basic.DependentConfiguration.attributeWhenReady;
-import static brooklyn.event.basic.DependentConfiguration.formatString;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.marre.sms.SmsException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.enricher.basic.SensorPropagatingEnricher;
-import brooklyn.enricher.basic.SensorTransformingEnricher;
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.database.mysql.MySqlNode;
-import brooklyn.entity.webapp.ControlledDynamicWebAppCluster;
-import brooklyn.entity.webapp.DynamicWebAppCluster;
-import brooklyn.entity.webapp.JavaWebAppService;
-import brooklyn.entity.webapp.WebAppService;
-import brooklyn.entity.webapp.WebAppServiceConstants;
-import brooklyn.event.SensorEvent;
-import brooklyn.event.SensorEventListener;
-import brooklyn.event.basic.BasicAttributeSensor;
-import brooklyn.event.basic.BasicNotificationSensor;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.launcher.BrooklynServerDetails;
-import brooklyn.location.Location;
-import brooklyn.location.basic.PortRanges;
-import brooklyn.policy.autoscaling.AutoScalerPolicy;
-import brooklyn.policy.autoscaling.MaxPoolSizeReachedEvent;
-import brooklyn.util.CommandLineUtil;
-
-import com.google.common.base.Functions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-/**
- * Launches a 3-tier app with nginx, clustered jboss, and mysql.
- **/
-public class WebClusterDatabaseOpenLoopExample extends ApplicationBuilder {
-
- public static final Logger LOG = LoggerFactory.getLogger(WebClusterDatabaseOpenLoopExample.class);
-
- public static final String WAR_PATH = "classpath://hello-world-sql-webapp.war";
-
- public static final String DB_SETUP_SQL_URL = "classpath://visitors-creation-script.sql";
-
- public static final String DB_TABLE = "visitors";
- public static final String DB_USERNAME = "brooklyn";
- public static final String DB_PASSWORD = "br00k11n";
-
- // TODO Replace these with your details, for a clickatell.com account that has credit to send SMS messages
- public static final String CLICKATELL_USERNAME = "brooklyndemo.uk";
- public static final String CLICKATELL_PASSWORD = "NAYLLHRLZEBYYA";
- public static final String CLICKATELL_APIID = "3411519";
- public static final String SMS_RECEIVER = "441234567890";
-
- public static final BasicAttributeSensor<Integer> APPSERVERS_COUNT = Sensors.newIntegerSensor(
- "appservers.count", "Number of app servers deployed");
-
- public static final BasicNotificationSensor<MaxPoolSizeReachedEvent> MAX_SIZE_REACHED = new BasicNotificationSensor<MaxPoolSizeReachedEvent>(
- MaxPoolSizeReachedEvent.class, "cluster.maxPoolSizeReached", "");
-
- protected void doBuild() {
- MySqlNode mysql = addChild(EntitySpec.create(MySqlNode.class)
- .configure("creationScriptUrl", DB_SETUP_SQL_URL));
-
- ControlledDynamicWebAppCluster web = addChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
- .configure(WebAppService.HTTP_PORT, PortRanges.fromString("8080+"))
- .configure(JavaWebAppService.ROOT_WAR, WAR_PATH)
- .configure(javaSysProp("brooklyn.example.db.url"),
- formatString("jdbc:%s%s?user=%s\\&password=%s",
- attributeWhenReady(mysql, MySqlNode.MYSQL_URL),
- DB_TABLE, DB_USERNAME, DB_PASSWORD)));
-
- // Subscribe not notifications about the auto-scaler policy reaching its max cluster size
- getManagementContext().getSubscriptionManager().subscribe(
- web.getCluster(),
- MAX_SIZE_REACHED,
- new SensorEventListener<MaxPoolSizeReachedEvent>() {
- @Override public void onEvent(SensorEvent<MaxPoolSizeReachedEvent> event) {
- onMaxPoolSizeReached(event.getValue());
- }
- });
-
- // simple scaling policy
- web.getCluster().addPolicy(AutoScalerPolicy.builder().
- metric(DynamicWebAppCluster.REQUESTS_PER_SECOND_IN_WINDOW_PER_NODE).
- metricRange(10, 100).
- sizeRange(1, 5).
- maxSizeReachedSensor(MAX_SIZE_REACHED).
-// maxReachedNotificationDelay(1000).
- build());
-
- // expose some KPI's
- getApp().addEnricher(SensorPropagatingEnricher.newInstanceListeningTo(web,
- WebAppServiceConstants.ROOT_URL,
- DynamicWebAppCluster.REQUESTS_PER_SECOND_IN_WINDOW));
- getApp().addEnricher(new SensorTransformingEnricher<Integer,Integer>(web,
- DynamicWebAppCluster.GROUP_SIZE, APPSERVERS_COUNT, Functions.<Integer>identity()));
- }
-
- private void onMaxPoolSizeReached(MaxPoolSizeReachedEvent event) {
- String msg = "Max-pool-size-reached: "+event;
- System.out.println("*** "+msg);
-
- try {
- new Sms(CLICKATELL_USERNAME, CLICKATELL_PASSWORD, CLICKATELL_APIID).sendSms(SMS_RECEIVER, msg);
- } catch (SmsException e) {
- LOG.warn("Error sending SMS message: "+e.getMessage(), e);
- } catch (IOException e) {
- LOG.warn("Error sending SMS message", e);
- }
- }
-
- 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", "localhost");
-
- BrooklynServerDetails server = BrooklynLauncher.newLauncher()
- .webconsolePort(port)
- .launch();
-
- Location loc = server.getManagementContext().getLocationRegistry().resolve(location);
-
- StartableApplication app = new WebClusterDatabaseOpenLoopExample()
- .appDisplayName("Brooklyn WebApp Cluster with Database example")
- .manage(server.getManagementContext());
-
- app.start(ImmutableList.of(loc));
-
- Entities.dumpInfo(app);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/simple-open-loop-policy/src/main/resources/visitors-creation-script.sql
----------------------------------------------------------------------
diff --git a/examples/simple-open-loop-policy/src/main/resources/visitors-creation-script.sql b/examples/simple-open-loop-policy/src/main/resources/visitors-creation-script.sql
deleted file mode 100644
index 0a805c4..0000000
--- a/examples/simple-open-loop-policy/src/main/resources/visitors-creation-script.sql
+++ /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.
---
-create database visitors;
-use visitors;
-create user 'brooklyn' identified by 'br00k11n';
-grant usage on *.* to 'brooklyn'@'%' identified by 'br00k11n';
-# ''@localhost is sometimes set up, overriding brooklyn@'%', so do a second explicit grant
-grant usage on *.* to 'brooklyn'@'localhost' identified by 'br00k11n';
-grant all privileges on visitors.* to 'brooklyn'@'%';
-flush privileges;
-
-CREATE TABLE MESSAGES (
- id INT NOT NULL AUTO_INCREMENT,
- NAME VARCHAR(30) NOT NULL,
- MESSAGE VARCHAR(400) NOT NULL,
- PRIMARY KEY (ID)
- );
-
-INSERT INTO MESSAGES values (default, 'Isaac Asimov', 'I grew up in Brooklyn' );
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/examples/simple-open-loop-policy/src/test/java/brooklyn/demo/SmsTest.java
----------------------------------------------------------------------
diff --git a/examples/simple-open-loop-policy/src/test/java/brooklyn/demo/SmsTest.java b/examples/simple-open-loop-policy/src/test/java/brooklyn/demo/SmsTest.java
deleted file mode 100644
index 8ea9119..0000000
--- a/examples/simple-open-loop-policy/src/test/java/brooklyn/demo/SmsTest.java
+++ /dev/null
@@ -1,50 +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 org.marre.sms.SmsException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-public class SmsTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(SmsTest.class);
-
- @Test(groups="Integration")
- public void testSendSms() throws Exception {
- // http://api.clickatell.com/http/sendmsg?user=brooklyndemo.uk&password=PASSWORD&api_id=3411519&to=447709428472&text=Message
- // Note this account has *no* credit card details; sending a message will result in a standard message from Clickatell.com,
- // rather than receiving the actual message body.
- //
- // TODO It's started failing with "Error 301, No Credit Left"
- // How to commit something that passes but without exposing credit card details?!
- Sms sender = new Sms("brooklyndemo.uk", "NAYLLHRLZEBYYA", "3411519");
- try {
- sender.sendSms("447709428472", "test sms sent in brooklyn");
- } catch (SmsException e) {
- if (e.toString().contains("Error 301, No Credit Left")) {
- // fair enough; let's not fail the test for this reason
- LOG.warn("Cannot test SMS because no credit left on account: "+e.toString());
- } else {
- throw e;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f61d56b..c43d9c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1255,6 +1255,7 @@
<module>sandbox/web-acceptance</module>
<module>sandbox/nosql</module>
<module>sandbox/monitoring</module>
+ <module>sandbox/examples/simple-open-loop-policy</module>
</modules>
</profile>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/sandbox/examples/simple-open-loop-policy/README.txt
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/README.txt b/sandbox/examples/simple-open-loop-policy/README.txt
new file mode 100644
index 0000000..85c9336
--- /dev/null
+++ b/sandbox/examples/simple-open-loop-policy/README.txt
@@ -0,0 +1,72 @@
+Instructions for Running Examples
+=================================
+
+The commands below assume that the `brooklyn` script is on your $PATH, this project has been built,
+and you are in this directory. Adjust to taste for other configurations.
+
+ export BROOKLYN_CLASSPATH=$(pwd)/target/classes
+
+ # Three-tier: auto-scaling app-server cluster fronted by nginx, MySql backend wired up, on localhost
+ brooklyn launch --app brooklyn.demo.WebClusterDatabaseOpenLoopExample --location localhost
+
+The above requires passwordless `ssh localhost` and requires `gcc` to build `nginx`.
+You could instead target your favourite cloud, where this has been tried and tested:
+
+
+Redistributable embedded example:
+
+ # To build a redistributable tar.gz with a start.sh script
+ # which invokes the `main` method in the example class to start
+ # (the redistributable will be at: target/brooklyn-*-bin.tar.gz )
+ mvn clean assembly:assembly
+
+For more information, please visit:
+
+ http://brooklyncentral.github.com/use/examples/webcluster/
+
+
+Developer Notes
+===============
+
+This example sends an SMS message when the cluster has reached its max size (and where the auto-scaler policy
+would continue to increase the size if it were not capped). The message is sent using clickatell.com,
+using http://smsj.sourceforge.net.
+
+Because smsj is not available on maven central, a custom local maven repo has been built (and checked in to git):
+
+ wget http://sourceforge.net/projects/smsj/files/smsj/smsj-snapshot-20051126/smsj-20051126.jar/download
+
+ mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file \
+ -Dfile=smsj-20051126.jar \
+ -DgroupId=io.brooklyn \
+ -DartifactId=org.marre.smsj \
+ -Dversion=1.0.0-20051126 \
+ -Dpackaging=jar \
+ -DlocalRepositoryPath=localrepo
+
+And in the pom, this local repo is referenced:
+
+ <repositories>
+ <repository>
+ <id>brooklyn-examples-localrepo</id>
+ <url>file://${basedir}/localrepo</url>
+ </repository>
+ </repositories>
+
+----
+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.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.jar
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.jar b/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.jar
new file mode 100644
index 0000000..a076a47
Binary files /dev/null and b/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.jar differ
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.pom
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.pom b/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.pom
new file mode 100644
index 0000000..7361303
--- /dev/null
+++ b/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.pom
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>io.brooklyn</groupId>
+ <artifactId>org.marre.smsj</artifactId>
+ <version>1.0.0-20051126</version>
+ <description>POM was created from install:install-file</description>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/maven-metadata-local.xml
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/maven-metadata-local.xml b/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/maven-metadata-local.xml
new file mode 100644
index 0000000..c0018bb
--- /dev/null
+++ b/sandbox/examples/simple-open-loop-policy/localrepo/io/brooklyn/org.marre.smsj/maven-metadata-local.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<metadata>
+ <groupId>io.brooklyn</groupId>
+ <artifactId>org.marre.smsj</artifactId>
+ <versioning>
+ <release>1.0.0-20051126</release>
+ <versions>
+ <version>1.0.0-20051126</version>
+ </versions>
+ <lastUpdated>20130206095028</lastUpdated>
+ </versioning>
+</metadata>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/sandbox/examples/simple-open-loop-policy/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/pom.xml b/sandbox/examples/simple-open-loop-policy/pom.xml
new file mode 100644
index 0000000..040630b
--- /dev/null
+++ b/sandbox/examples/simple-open-loop-policy/pom.xml
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>jar</packaging>
+ <artifactId>brooklyn-sandbox-example-simple-open-loop-policy</artifactId>
+ <groupId>io.brooklyn.sandbox.example</groupId>
+ <name>Brooklyn Simple Web Cluster Example</name>
+
+ <!-- this is only needed for "mvn deploy"; the group and version can be extracted
+ and parent block removed to run this standalone -->
+ <parent>
+ <groupId>org.apache.brooklyn.example</groupId>
+ <artifactId>brooklyn-examples-parent</artifactId>
+ <version>0.7.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <repositories>
+ <repository>
+ <id>brooklyn-examples-localrepo</id>
+ <url>file://${basedir}/localrepo</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>org.marre.smsj</artifactId>
+ <version>${org.marre.smsj.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-all</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-logback-xml</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-test-support</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes combine.children="append">
+ <exclude>**/localrepo/io/brooklyn/org.marre.smsj/1.0.0-20051126/org.marre.smsj-1.0.0-20051126.pom</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <!-- copy the WAR so it is available on the classpath for programmatic deployment -->
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <!-- these can fail in eclipse trying to copy _from_ target/classes.
+ see http://jira.codehaus.org/browse/MDEP-259 -->
+ <artifactItem>
+ <groupId>org.apache.brooklyn.example</groupId>
+ <artifactId>brooklyn-example-hello-world-webapp</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>target/classes</outputDirectory>
+ <destFileName>hello-world-webapp.war</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.brooklyn.example</groupId>
+ <artifactId>brooklyn-example-hello-world-sql-webapp</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>target/classes</outputDirectory>
+ <destFileName>hello-world-sql-webapp.war</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${project.basedir}</directory>
+ <includes>
+ <include>${project.artifactId}/</include>
+ <include>brooklyn*.log</include>
+ <include>brooklyn*.log.*</include>
+ <include>stacktrace.log</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+<!-- TODO assembly not supported for this example, currently
+ <plugin>
+-->
+ <!-- TODO assembly not supported for this example, currently -->
+ <!-- optional, with this block, `mvn assembly:assembly` will build a redistributable tgz -->
+<!--
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+-->
+ </plugins>
+
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/sandbox/examples/simple-open-loop-policy/resources/jmeter-test-plan.jmx
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/resources/jmeter-test-plan.jmx b/sandbox/examples/simple-open-loop-policy/resources/jmeter-test-plan.jmx
new file mode 100644
index 0000000..0eb1741
--- /dev/null
+++ b/sandbox/examples/simple-open-loop-policy/resources/jmeter-test-plan.jmx
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<jmeterTestPlan version="1.2" properties="2.1">
+ <hashTree>
+ <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Brooklyn local webapp test - load for localhost:8000" enabled="true">
+ <stringProp name="TestPlan.comments"></stringProp>
+ <boolProp name="TestPlan.functional_mode">false</boolProp>
+ <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
+ <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
+ <collectionProp name="Arguments.arguments"/>
+ </elementProp>
+ <stringProp name="TestPlan.user_define_classpath"></stringProp>
+ </TestPlan>
+ <hashTree>
+ <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Test Group - hitting site with 8 threads" enabled="true">
+ <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
+ <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
+ <boolProp name="LoopController.continue_forever">false</boolProp>
+ <intProp name="LoopController.loops">-1</intProp>
+ </elementProp>
+ <stringProp name="ThreadGroup.num_threads">8</stringProp>
+ <stringProp name="ThreadGroup.ramp_time">1</stringProp>
+ <longProp name="ThreadGroup.start_time">1326116677000</longProp>
+ <longProp name="ThreadGroup.end_time">1326116677000</longProp>
+ <boolProp name="ThreadGroup.scheduler">false</boolProp>
+ <stringProp name="ThreadGroup.duration"></stringProp>
+ <stringProp name="ThreadGroup.delay"></stringProp>
+ </ThreadGroup>
+ <hashTree>
+ <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Timer - frequency 50 reqs/sec per thread (20 ms delay)" enabled="true">
+ <stringProp name="ConstantTimer.delay">20</stringProp>
+ </ConstantTimer>
+ <hashTree/>
+ <HTTPSampler guiclass="HttpTestSampleGui" testclass="HTTPSampler" testname="HTTP Request - localhost:8000" enabled="true">
+ <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
+ <collectionProp name="Arguments.arguments"/>
+ </elementProp>
+ <stringProp name="HTTPSampler.domain">localhost</stringProp>
+ <stringProp name="HTTPSampler.port">8000</stringProp>
+ <stringProp name="HTTPSampler.connect_timeout"></stringProp>
+ <stringProp name="HTTPSampler.response_timeout"></stringProp>
+ <stringProp name="HTTPSampler.protocol"></stringProp>
+ <stringProp name="HTTPSampler.contentEncoding"></stringProp>
+ <stringProp name="HTTPSampler.path"></stringProp>
+ <stringProp name="HTTPSampler.method">GET</stringProp>
+ <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
+ <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
+ <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
+ <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
+ <boolProp name="HTTPSampler.monitor">false</boolProp>
+ <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
+ </HTTPSampler>
+ <hashTree/>
+ <CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="HTTP Cookie Manager" enabled="true">
+ <collectionProp name="CookieManager.cookies"/>
+ <boolProp name="CookieManager.clearEachIteration">false</boolProp>
+ </CookieManager>
+ <hashTree/>
+ </hashTree>
+ <ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="Summary Report" enabled="true">
+ <boolProp name="ResultCollector.error_logging">false</boolProp>
+ <objProp>
+ <name>saveConfig</name>
+ <value class="SampleSaveConfiguration">
+ <time>true</time>
+ <latency>true</latency>
+ <timestamp>true</timestamp>
+ <success>true</success>
+ <label>true</label>
+ <code>true</code>
+ <message>true</message>
+ <threadName>true</threadName>
+ <dataType>true</dataType>
+ <encoding>false</encoding>
+ <assertions>true</assertions>
+ <subresults>true</subresults>
+ <responseData>false</responseData>
+ <samplerData>false</samplerData>
+ <xml>true</xml>
+ <fieldNames>false</fieldNames>
+ <responseHeaders>false</responseHeaders>
+ <requestHeaders>false</requestHeaders>
+ <responseDataOnError>false</responseDataOnError>
+ <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
+ <assertionsResultsToSave>0</assertionsResultsToSave>
+ <bytes>true</bytes>
+ </value>
+ </objProp>
+ <stringProp name="filename"></stringProp>
+ </ResultCollector>
+ <hashTree/>
+ <ResultCollector guiclass="SplineVisualizer" testclass="ResultCollector" testname="Spline Visualizer" enabled="true">
+ <boolProp name="ResultCollector.error_logging">false</boolProp>
+ <objProp>
+ <name>saveConfig</name>
+ <value class="SampleSaveConfiguration">
+ <time>true</time>
+ <latency>true</latency>
+ <timestamp>true</timestamp>
+ <success>true</success>
+ <label>true</label>
+ <code>true</code>
+ <message>true</message>
+ <threadName>true</threadName>
+ <dataType>true</dataType>
+ <encoding>false</encoding>
+ <assertions>true</assertions>
+ <subresults>true</subresults>
+ <responseData>false</responseData>
+ <samplerData>false</samplerData>
+ <xml>true</xml>
+ <fieldNames>false</fieldNames>
+ <responseHeaders>false</responseHeaders>
+ <requestHeaders>false</requestHeaders>
+ <responseDataOnError>false</responseDataOnError>
+ <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
+ <assertionsResultsToSave>0</assertionsResultsToSave>
+ <bytes>true</bytes>
+ </value>
+ </objProp>
+ <stringProp name="filename"></stringProp>
+ </ResultCollector>
+ <hashTree/>
+ </hashTree>
+ </hashTree>
+</jmeterTestPlan>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/sandbox/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/Sms.java
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/Sms.java b/sandbox/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/Sms.java
new file mode 100644
index 0000000..9a3d52e
--- /dev/null
+++ b/sandbox/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/Sms.java
@@ -0,0 +1,63 @@
+/*
+ * 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.io.IOException;
+
+import org.marre.SmsSender;
+import org.marre.sms.SmsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Sms {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Sms.class);
+
+ private final String username;
+ private final String password;
+ private final String apiid;
+ private final String sender;
+
+ public Sms(String username, String password, String apiid) {
+ this.username = username;
+ this.password = password;
+ this.apiid = apiid;
+ this.sender = null;
+ }
+
+ /**
+ *
+ * @param receiver International number to reciever without leading "+"
+ * @param msg The message that you want to send
+ * @throws IOException
+ * @throws SmsException
+ */
+ public void sendSms(String receiver, String msg) throws SmsException, IOException {
+ // Send SMS with clickatell
+ SmsSender smsSender = SmsSender.getClickatellSender(username, password, apiid);
+
+ smsSender.connect();
+ try {
+ String msgid = smsSender.sendTextSms(msg, receiver, sender);
+ LOG.debug("Sent SMS via {}@clickatell to {}, msg {}; id {}", new Object[] {username, receiver, msg, msgid});
+ } finally {
+ smsSender.disconnect();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/sandbox/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/WebClusterDatabaseOpenLoopExample.java
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/WebClusterDatabaseOpenLoopExample.java b/sandbox/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/WebClusterDatabaseOpenLoopExample.java
new file mode 100644
index 0000000..466e4dd
--- /dev/null
+++ b/sandbox/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/WebClusterDatabaseOpenLoopExample.java
@@ -0,0 +1,157 @@
+/*
+ * 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 static brooklyn.entity.java.JavaEntityMethods.javaSysProp;
+import static brooklyn.event.basic.DependentConfiguration.attributeWhenReady;
+import static brooklyn.event.basic.DependentConfiguration.formatString;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.marre.sms.SmsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.enricher.basic.SensorPropagatingEnricher;
+import brooklyn.enricher.basic.SensorTransformingEnricher;
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.database.mysql.MySqlNode;
+import brooklyn.entity.webapp.ControlledDynamicWebAppCluster;
+import brooklyn.entity.webapp.DynamicWebAppCluster;
+import brooklyn.entity.webapp.JavaWebAppService;
+import brooklyn.entity.webapp.WebAppService;
+import brooklyn.entity.webapp.WebAppServiceConstants;
+import brooklyn.event.SensorEvent;
+import brooklyn.event.SensorEventListener;
+import brooklyn.event.basic.BasicAttributeSensor;
+import brooklyn.event.basic.BasicNotificationSensor;
+import brooklyn.launcher.BrooklynLauncher;
+import brooklyn.launcher.BrooklynServerDetails;
+import brooklyn.location.Location;
+import brooklyn.location.basic.PortRanges;
+import brooklyn.policy.autoscaling.AutoScalerPolicy;
+import brooklyn.policy.autoscaling.MaxPoolSizeReachedEvent;
+import brooklyn.util.CommandLineUtil;
+
+import com.google.common.base.Functions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+/**
+ * Launches a 3-tier app with nginx, clustered jboss, and mysql.
+ **/
+public class WebClusterDatabaseOpenLoopExample extends ApplicationBuilder {
+
+ public static final Logger LOG = LoggerFactory.getLogger(WebClusterDatabaseOpenLoopExample.class);
+
+ public static final String WAR_PATH = "classpath://hello-world-sql-webapp.war";
+
+ public static final String DB_SETUP_SQL_URL = "classpath://visitors-creation-script.sql";
+
+ public static final String DB_TABLE = "visitors";
+ public static final String DB_USERNAME = "brooklyn";
+ public static final String DB_PASSWORD = "br00k11n";
+
+ // TODO Replace these with your details, for a clickatell.com account that has credit to send SMS messages
+ public static final String CLICKATELL_USERNAME = "brooklyndemo.uk";
+ public static final String CLICKATELL_PASSWORD = "NAYLLHRLZEBYYA";
+ public static final String CLICKATELL_APIID = "3411519";
+ public static final String SMS_RECEIVER = "441234567890";
+
+ public static final BasicAttributeSensor<Integer> APPSERVERS_COUNT = Sensors.newIntegerSensor(
+ "appservers.count", "Number of app servers deployed");
+
+ public static final BasicNotificationSensor<MaxPoolSizeReachedEvent> MAX_SIZE_REACHED = new BasicNotificationSensor<MaxPoolSizeReachedEvent>(
+ MaxPoolSizeReachedEvent.class, "cluster.maxPoolSizeReached", "");
+
+ protected void doBuild() {
+ MySqlNode mysql = addChild(EntitySpec.create(MySqlNode.class)
+ .configure("creationScriptUrl", DB_SETUP_SQL_URL));
+
+ ControlledDynamicWebAppCluster web = addChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
+ .configure(WebAppService.HTTP_PORT, PortRanges.fromString("8080+"))
+ .configure(JavaWebAppService.ROOT_WAR, WAR_PATH)
+ .configure(javaSysProp("brooklyn.example.db.url"),
+ formatString("jdbc:%s%s?user=%s\\&password=%s",
+ attributeWhenReady(mysql, MySqlNode.MYSQL_URL),
+ DB_TABLE, DB_USERNAME, DB_PASSWORD)));
+
+ // Subscribe not notifications about the auto-scaler policy reaching its max cluster size
+ getManagementContext().getSubscriptionManager().subscribe(
+ web.getCluster(),
+ MAX_SIZE_REACHED,
+ new SensorEventListener<MaxPoolSizeReachedEvent>() {
+ @Override public void onEvent(SensorEvent<MaxPoolSizeReachedEvent> event) {
+ onMaxPoolSizeReached(event.getValue());
+ }
+ });
+
+ // simple scaling policy
+ web.getCluster().addPolicy(AutoScalerPolicy.builder().
+ metric(DynamicWebAppCluster.REQUESTS_PER_SECOND_IN_WINDOW_PER_NODE).
+ metricRange(10, 100).
+ sizeRange(1, 5).
+ maxSizeReachedSensor(MAX_SIZE_REACHED).
+// maxReachedNotificationDelay(1000).
+ build());
+
+ // expose some KPI's
+ getApp().addEnricher(SensorPropagatingEnricher.newInstanceListeningTo(web,
+ WebAppServiceConstants.ROOT_URL,
+ DynamicWebAppCluster.REQUESTS_PER_SECOND_IN_WINDOW));
+ getApp().addEnricher(new SensorTransformingEnricher<Integer,Integer>(web,
+ DynamicWebAppCluster.GROUP_SIZE, APPSERVERS_COUNT, Functions.<Integer>identity()));
+ }
+
+ private void onMaxPoolSizeReached(MaxPoolSizeReachedEvent event) {
+ String msg = "Max-pool-size-reached: "+event;
+ System.out.println("*** "+msg);
+
+ try {
+ new Sms(CLICKATELL_USERNAME, CLICKATELL_PASSWORD, CLICKATELL_APIID).sendSms(SMS_RECEIVER, msg);
+ } catch (SmsException e) {
+ LOG.warn("Error sending SMS message: "+e.getMessage(), e);
+ } catch (IOException e) {
+ LOG.warn("Error sending SMS message", e);
+ }
+ }
+
+ 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", "localhost");
+
+ BrooklynServerDetails server = BrooklynLauncher.newLauncher()
+ .webconsolePort(port)
+ .launch();
+
+ Location loc = server.getManagementContext().getLocationRegistry().resolve(location);
+
+ StartableApplication app = new WebClusterDatabaseOpenLoopExample()
+ .appDisplayName("Brooklyn WebApp Cluster with Database example")
+ .manage(server.getManagementContext());
+
+ app.start(ImmutableList.of(loc));
+
+ Entities.dumpInfo(app);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/sandbox/examples/simple-open-loop-policy/src/main/resources/visitors-creation-script.sql
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/src/main/resources/visitors-creation-script.sql b/sandbox/examples/simple-open-loop-policy/src/main/resources/visitors-creation-script.sql
new file mode 100644
index 0000000..0a805c4
--- /dev/null
+++ b/sandbox/examples/simple-open-loop-policy/src/main/resources/visitors-creation-script.sql
@@ -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.
+--
+create database visitors;
+use visitors;
+create user 'brooklyn' identified by 'br00k11n';
+grant usage on *.* to 'brooklyn'@'%' identified by 'br00k11n';
+# ''@localhost is sometimes set up, overriding brooklyn@'%', so do a second explicit grant
+grant usage on *.* to 'brooklyn'@'localhost' identified by 'br00k11n';
+grant all privileges on visitors.* to 'brooklyn'@'%';
+flush privileges;
+
+CREATE TABLE MESSAGES (
+ id INT NOT NULL AUTO_INCREMENT,
+ NAME VARCHAR(30) NOT NULL,
+ MESSAGE VARCHAR(400) NOT NULL,
+ PRIMARY KEY (ID)
+ );
+
+INSERT INTO MESSAGES values (default, 'Isaac Asimov', 'I grew up in Brooklyn' );
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0549c26f/sandbox/examples/simple-open-loop-policy/src/test/java/brooklyn/demo/SmsTest.java
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/src/test/java/brooklyn/demo/SmsTest.java b/sandbox/examples/simple-open-loop-policy/src/test/java/brooklyn/demo/SmsTest.java
new file mode 100644
index 0000000..8ea9119
--- /dev/null
+++ b/sandbox/examples/simple-open-loop-policy/src/test/java/brooklyn/demo/SmsTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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 org.marre.sms.SmsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+public class SmsTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SmsTest.class);
+
+ @Test(groups="Integration")
+ public void testSendSms() throws Exception {
+ // http://api.clickatell.com/http/sendmsg?user=brooklyndemo.uk&password=PASSWORD&api_id=3411519&to=447709428472&text=Message
+ // Note this account has *no* credit card details; sending a message will result in a standard message from Clickatell.com,
+ // rather than receiving the actual message body.
+ //
+ // TODO It's started failing with "Error 301, No Credit Left"
+ // How to commit something that passes but without exposing credit card details?!
+ Sms sender = new Sms("brooklyndemo.uk", "NAYLLHRLZEBYYA", "3411519");
+ try {
+ sender.sendSms("447709428472", "test sms sent in brooklyn");
+ } catch (SmsException e) {
+ if (e.toString().contains("Error 301, No Credit Left")) {
+ // fair enough; let's not fail the test for this reason
+ LOG.warn("Cannot test SMS because no credit left on account: "+e.toString());
+ } else {
+ throw e;
+ }
+ }
+ }
+}