You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2014/11/11 15:17:05 UTC

[01/11] incubator-brooklyn git commit: remove simple-open-loop-policy, it is a bad example, and has an unavailable dependency; and notes on disabling maven incremental build

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master dc53cec5d -> 9352bbe90


remove simple-open-loop-policy, it is a bad example, and has an unavailable dependency; and notes on disabling maven incremental build


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

Branch: refs/heads/master
Commit: df5fb25f4ed9a609a0e17b6b62d876cc87deb3b0
Parents: dc53cec
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Nov 7 09:05:02 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 11 10:46:48 2014 +0000

----------------------------------------------------------------------
 pom.xml                                         |   7 +
 .../examples/simple-open-loop-policy/README.md  |  63 --------
 .../examples/simple-open-loop-policy/pom.xml    | 150 -----------------
 .../resources/jmeter-test-plan.jmx              | 143 -----------------
 .../src/main/java/brooklyn/demo/Sms.java        |  63 --------
 .../demo/WebClusterDatabaseOpenLoopExample.java | 160 -------------------
 .../main/resources/visitors-creation-script.sql |  35 ----
 .../src/test/java/brooklyn/demo/SmsTest.java    |  50 ------
 8 files changed, 7 insertions(+), 664 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/df5fb25f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f40ed09..045f3a8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -971,6 +971,13 @@
                                     <ignore />
                                   </action>
                                 </pluginExecution>
+                                <pluginExecution>
+                                  <action>
+                                    <execute>
+                                      <runOnIncremental>false</runOnIncremental>
+                                    </execute>
+                                  </action>
+                                </pluginExecution>
                             </pluginExecutions>
                         </lifecycleMappingMetadata>
                     </configuration>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/df5fb25f/sandbox/examples/simple-open-loop-policy/README.md
----------------------------------------------------------------------
diff --git a/sandbox/examples/simple-open-loop-policy/README.md b/sandbox/examples/simple-open-loop-policy/README.md
deleted file mode 100644
index de28c21..0000000
--- a/sandbox/examples/simple-open-loop-policy/README.md
+++ /dev/null
@@ -1,63 +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, you must obtain this library yourself and install it into
-your local Maven repository:
-
-  wget -Osmsj-20051126.jar 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
-
-----
-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.

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/df5fb25f/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
deleted file mode 100644
index bbeaa2a..0000000
--- a/sandbox/examples/simple-open-loop-policy/pom.xml
+++ /dev/null
@@ -1,150 +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-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>
-
-    <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/df5fb25f/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
deleted file mode 100644
index 0eb1741..0000000
--- a/sandbox/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/df5fb25f/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
deleted file mode 100644
index 9a3d52e..0000000
--- a/sandbox/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/df5fb25f/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
deleted file mode 100644
index 3af573f..0000000
--- a/sandbox/examples/simple-open-loop-policy/src/main/java/brooklyn/demo/WebClusterDatabaseOpenLoopExample.java
+++ /dev/null
@@ -1,160 +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.proxying.EntitySpec;
-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.AttributeSensor;
-import brooklyn.event.SensorEvent;
-import brooklyn.event.SensorEventListener;
-import brooklyn.event.basic.BasicNotificationSensor;
-import brooklyn.event.basic.Sensors;
-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 AttributeSensor<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");
-
-        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
-                .webconsolePort(port)
-                .start();
-        BrooklynServerDetails server = launcher.getServerDetails();
-        
-        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/df5fb25f/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
deleted file mode 100644
index 0a805c4..0000000
--- a/sandbox/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/df5fb25f/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
deleted file mode 100644
index 8ea9119..0000000
--- a/sandbox/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;
-            }
-        }
-    }
-}


[03/11] incubator-brooklyn git commit: track soft references (esp script output) and report reclaimable memory as part of brooklyn-gc reporting

Posted by he...@apache.org.
track soft references (esp script output) and report reclaimable memory as part of brooklyn-gc reporting


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

Branch: refs/heads/master
Commit: b6068e3febd005eb279cb5d9c7537a0d2ae0f100
Parents: 396c600
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Nov 11 01:11:27 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 11 13:54:54 2014 +0000

----------------------------------------------------------------------
 .../brooklyn/entity/basic/BrooklynTaskTags.java |  7 +-
 .../internal/BrooklynGarbageCollector.java      |  4 +-
 .../main/java/brooklyn/util/guava/Maybe.java    | 15 ++--
 .../util/javalang/MemoryUsageTracker.java       | 72 ++++++++++++++++++++
 .../util/javalang/MemoryUsageTrackerTest.java   | 67 ++++++++++++++++++
 5 files changed, 157 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b6068e3f/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java b/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
index 959a405..5c92b43 100644
--- a/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
+++ b/core/src/main/java/brooklyn/entity/basic/BrooklynTaskTags.java
@@ -38,6 +38,7 @@ import brooklyn.management.ExecutionManager;
 import brooklyn.management.Task;
 import brooklyn.management.entitlement.EntitlementContext;
 import brooklyn.util.guava.Maybe;
+import brooklyn.util.javalang.MemoryUsageTracker;
 import brooklyn.util.stream.Streams;
 import brooklyn.util.task.TaskTags;
 import brooklyn.util.task.Tasks;
@@ -208,14 +209,16 @@ public class BrooklynTaskTags extends TaskTags {
     /** not a stream, but inserted with the same mechanism */
     public static final String STREAM_ENV = "env";
     
+    private static final Maybe<ByteArrayOutputStream> STREAM_GARBAGE_COLLECTED_MAYBE = Maybe.of(Streams.byteArrayOfString("<contents-garbage-collected>"));
+
     /** creates a tag suitable for marking a stream available on a task */
     public static WrappedStream tagForStream(String streamType, ByteArrayOutputStream stream) {
         return new WrappedStream(streamType, stream);
     }
     /** creates a tag suitable for marking a stream available on a task, but which might be GC'd */
     public static WrappedStream tagForStreamSoft(String streamType, ByteArrayOutputStream stream) {
-        Maybe<ByteArrayOutputStream> weakStream = Maybe.softThen(stream, 
-            Maybe.of(Streams.byteArrayOfString("<contents-garbage-collected>")));
+        MemoryUsageTracker.SOFT_REFERENCES.track(stream, stream.size());
+        Maybe<ByteArrayOutputStream> weakStream = Maybe.softThen(stream, STREAM_GARBAGE_COLLECTED_MAYBE);
         return new WrappedStream(streamType,
             Suppliers.compose(Functions.toStringFunction(), weakStream),
             Suppliers.compose(Streams.sizeFunction(), weakStream));

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b6068e3f/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java b/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
index c69e6b3..ed9b227 100644
--- a/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
+++ b/core/src/main/java/brooklyn/management/internal/BrooklynGarbageCollector.java
@@ -54,6 +54,7 @@ import brooklyn.util.collections.MutableList;
 import brooklyn.util.collections.MutableMap;
 import brooklyn.util.collections.MutableSet;
 import brooklyn.util.exceptions.Exceptions;
+import brooklyn.util.javalang.MemoryUsageTracker;
 import brooklyn.util.task.BasicExecutionManager;
 import brooklyn.util.task.ExecutionListener;
 import brooklyn.util.task.Tasks;
@@ -219,7 +220,8 @@ public class BrooklynGarbageCollector {
     public String getUsageString() {
         return
             Strings.makeSizeString(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())+" / "+
-            Strings.makeSizeString(Runtime.getRuntime().totalMemory()) + " memory; "+
+            Strings.makeSizeString(Runtime.getRuntime().totalMemory()) + " memory" +
+            " ("+Strings.makeSizeString(MemoryUsageTracker.SOFT_REFERENCES.getBytesUsed()) + " soft); "+
             "storage: " + storage.getStorageMetrics() + "; " +
             "tasks: " +
             executionManager.getNumActiveTasks()+" active, "+

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b6068e3f/utils/common/src/main/java/brooklyn/util/guava/Maybe.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/guava/Maybe.java b/utils/common/src/main/java/brooklyn/util/guava/Maybe.java
index 86c82fc..8d18057 100644
--- a/utils/common/src/main/java/brooklyn/util/guava/Maybe.java
+++ b/utils/common/src/main/java/brooklyn/util/guava/Maybe.java
@@ -248,11 +248,16 @@ public abstract class Maybe<T> implements Serializable, Supplier<T> {
         @Override
         public T get() {
             T result = value.get();
-            if (result==null) {
-                if (defaultValue==null) throw new IllegalStateException("Softly present item has been GC'd");
-                return defaultValue.get();
-            }
-            return result;
+            if (result!=null) return result;
+            if (defaultValue==null) throw new IllegalStateException("Softly present item has been GC'd");
+            return defaultValue.get();
+        }
+        @Override
+        public T orNull() {
+            T result = value.get();
+            if (result!=null) return result;
+            if (defaultValue==null) return null;
+            return defaultValue.orNull();
         }
         @Override
         public boolean isPresent() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b6068e3f/utils/common/src/main/java/brooklyn/util/javalang/MemoryUsageTracker.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/javalang/MemoryUsageTracker.java b/utils/common/src/main/java/brooklyn/util/javalang/MemoryUsageTracker.java
new file mode 100644
index 0000000..e8bb896
--- /dev/null
+++ b/utils/common/src/main/java/brooklyn/util/javalang/MemoryUsageTracker.java
@@ -0,0 +1,72 @@
+/*
+ * 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.util.javalang;
+
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.util.concurrent.atomic.AtomicLong;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.RemovalListener;
+import com.google.common.cache.RemovalNotification;
+
+/** 
+ * Tracks the amount of memory consumed by the given objects in use.
+ * <p>
+ * {@link WeakReference}s are used internally, so that shortly after a {@link #track(Object, long)}ed object is GC'd, 
+ * the {@link #getBytesUsed()} value decrements appropriately.
+ */
+public class MemoryUsageTracker {
+
+    /**
+     * Shared instance for use for tracking memory used by {@link SoftReference}.
+     * <p>
+     * Callers should only use this field to {@link #track(Object, long)} objects which have (or will soon have)
+     * given up their strong references, so that only soft or weak references remain.
+     * Provided size estimates are accurate, {@link #getBytesUsed()} will report
+     * the amount of used memory which is reclaimable by collecting soft references.
+     * <p>
+     * This is particularly handy for tracking {@link SoftReference}s, because otherwise you can quickly get to a state
+     * where {@link Runtime#freeMemory()} looks very low.
+     **/
+    public static final MemoryUsageTracker SOFT_REFERENCES = new MemoryUsageTracker();
+    
+    AtomicLong bytesUsed = new AtomicLong(0);
+    
+    Cache<Object, Long> memoryTrackedReferences = CacheBuilder.newBuilder()
+            .weakKeys()
+            .removalListener(new RemovalListener<Object,Long>() {
+                @Override
+                public void onRemoval(RemovalNotification<Object, Long> notification) {
+                    bytesUsed.addAndGet(-notification.getValue());
+                }
+            }).build();
+    
+    public void track(Object instance, long bytesUsedByInstance) {
+        bytesUsed.addAndGet(bytesUsedByInstance);
+        memoryTrackedReferences.put(instance, bytesUsedByInstance);
+    }
+    
+    public long getBytesUsed() {
+        memoryTrackedReferences.cleanUp();
+        return bytesUsed.get();
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b6068e3f/utils/common/src/test/java/brooklyn/util/javalang/MemoryUsageTrackerTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/brooklyn/util/javalang/MemoryUsageTrackerTest.java b/utils/common/src/test/java/brooklyn/util/javalang/MemoryUsageTrackerTest.java
new file mode 100644
index 0000000..24f101b
--- /dev/null
+++ b/utils/common/src/test/java/brooklyn/util/javalang/MemoryUsageTrackerTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.util.javalang;
+
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.util.collections.MutableList;
+import brooklyn.util.guava.Maybe;
+import brooklyn.util.text.Strings;
+
+public class MemoryUsageTrackerTest {
+
+    @Test(groups="Integration")
+    public void testBigUsage() {
+        List<Maybe<byte[]>> references = MutableList.of();
+        long created = 0;
+        while (created < 2*Runtime.getRuntime().maxMemory()) {
+            byte d[] = new byte[1000000];
+            references.add(Maybe.soft(d));
+            MemoryUsageTracker.SOFT_REFERENCES.track(d, d.length);
+            created += d.length;
+            
+            System.out.println("created "+Strings.makeSizeString(created) +
+                " ... in use: "+Strings.makeSizeString(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())+" / " +
+                Strings.makeSizeString(Runtime.getRuntime().totalMemory()) +
+                " ... reclaimable: "+Strings.makeSizeString(MemoryUsageTracker.SOFT_REFERENCES.getBytesUsed()) +
+                " ... live refs: "+Strings.makeSizeString(sizeOfActiveReferences(references)));
+            
+            assertLessThan(MemoryUsageTracker.SOFT_REFERENCES.getBytesUsed(), Runtime.getRuntime().maxMemory());
+            assertLessThan(MemoryUsageTracker.SOFT_REFERENCES.getBytesUsed(), Runtime.getRuntime().totalMemory());
+            assertLessThan(MemoryUsageTracker.SOFT_REFERENCES.getBytesUsed(), Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
+        }
+    }
+
+    private long sizeOfActiveReferences(List<Maybe<byte[]>> references) {
+        long size = 0;
+        for (Maybe<byte[]> ref: references) {
+            byte[] deref = ref.orNull();
+            if (deref!=null) size += deref.length;
+        }
+        return size;
+    }
+    
+    private static void assertLessThan(long lhs, long rhs) {
+        Assert.assertTrue(lhs<rhs, "Expected "+lhs+" < "+rhs);
+    }
+    
+}


[08/11] incubator-brooklyn git commit: additional m2e excludes for 4.4

Posted by he...@apache.org.
additional m2e excludes for 4.4


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

Branch: refs/heads/master
Commit: a883604983021970d40746c932f26e8844259749
Parents: 08d0257
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Nov 11 10:44:54 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 11 13:54:55 2014 +0000

----------------------------------------------------------------------
 pom.xml | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a8836049/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 045f3a8..2bc84a9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -971,6 +971,7 @@
                                     <ignore />
                                   </action>
                                 </pluginExecution>
+<!-- This is suggested if Eclipse runs too many incremental maven plugins, but it also seems to cause NPE's in maven build.
                                 <pluginExecution>
                                   <action>
                                     <execute>
@@ -978,6 +979,26 @@
                                     </execute>
                                   </action>
                                 </pluginExecution>
+-->
+                                <pluginExecution>
+                                  <pluginExecutionFilter>
+                                    <groupId>
+                                      org.apache.felix
+                                    </groupId>
+                                    <artifactId>
+                                      maven-bundle-plugin
+                                    </artifactId>
+                                    <versionRange>
+                                      [2.3.4,)
+                                    </versionRange>
+                                    <goals>
+                                      <goal>manifest</goal>
+                                    </goals>
+                                  </pluginExecutionFilter>
+                                  <action>
+                                    <ignore></ignore>
+                                  </action>
+                                </pluginExecution>
                             </pluginExecutions>
                         </lifecycleMappingMetadata>
                     </configuration>


[09/11] incubator-brooklyn git commit: fix mis-attribution in notice, and other tidies there (punctuation mainly)

Posted by he...@apache.org.
fix mis-attribution in notice, and other tidies there (punctuation mainly)


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

Branch: refs/heads/master
Commit: f4785fe02b92cf8b101c1e62389c31a6302bdb0e
Parents: a883604
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Nov 11 12:29:52 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 11 13:54:55 2014 +0000

----------------------------------------------------------------------
 NOTICE | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f4785fe0/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index 4466310..dd496d3 100644
--- a/NOTICE
+++ b/NOTICE
@@ -45,7 +45,7 @@ Copyright (c) Twitter, Inc (2012).
 Licensed under the Apache License 2.0.
 typeahead.js, bloodhound.js
 Copyright (c) Twitter, Inc (2013).
-Licensed under the MIT License
+Licensed under the MIT License.
 
 This product includes software developed by Yehuda Katz (https://github.com/wycats/):
 handlebars*.js.
@@ -84,46 +84,46 @@ Licensed under the MIT license.
 
 This product includes configuation files developed at MariaDB (https://mariadb.org/):
 Configuration file in software/database/src/main/resources/brooklyn/entity/database/mariadb/my.cnf
-Copyright (c) The MariaDB Foundation
-Licensed under GNU General Public License, version 2
+Copyright (c) The MariaDB Foundation.
+Licensed under GNU General Public License, version 2.
 
 This product includes configuation files developed at MySQL (http://www.mysql.com/):
 Configuration file in software/database/src/main/resources/brooklyn/entity/database/mysql/mysql.conf
-Copyright (c) The Oracle Corporation
-Licensed under Oracle’s Free and Open Source Software ("FOSS") License Exception
+Copyright (c) The Oracle Corporation.
+Licensed under Oracle’s Free and Open Source Software ("FOSS") License Exception.
 
 This product includes configuation files developed at PostgreSQL (http://www.postgresql.org/):
 Configuration file in software/database/src/main/resources/brooklyn/entity/database/postgresql/postgresql.conf
-Copyright (c) PostgreSQL Global Development Group
-Licensed under The PostgreSQL Licence (http://opensource.org/licenses/postgresql)
+Copyright (c) PostgreSQL Global Development Group.
+Licensed under the PostgreSQL Licence (http://opensource.org/licenses/postgresql).
 
 This product includes configuation files developed at rubyrep (http://www.rubyrep.org/):
 Configuration file in software/database/src/main/resources/brooklyn/entity/database/rubyrep/rubyrep.conf
-Licensed under MIT License
+Licensed under the MIT License.
 
 This product includes configuation files developed at Apache ActiveMQ (http://activemq.apache.org/):
 Configuration file in software/messaging/src/main/resources/brooklyn/entity/messaging/activemq/activemq.xml
-Copyright (c) The Apache Software Foundation
+Copyright (c) The Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Apache Kafka (http://kafka.apache.org/):
 Configuration files in software/messaging/src/main/resources/brooklyn/entity/messaging/kafka/*
-Copyright (c) The Apache Software Foundation
+Copyright (c) The Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Apache Storm (https://storm.incubator.apache.org/):
 Configuration file in software/messaging/src/main/resources/brooklyn/entity/messaging/storm/storm.yaml
-Copyright (c) The Apache Software Foundation
+Copyright (c) The Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Apache Cassandra (http://cassandra.apache.org/):
 Configuration file in software/nosql/src/main/resources/brooklyn/entity/nosql/cassandra/*
-Copyright (c) The Apache Software Foundation
+Copyright (c) The Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Apache CouchDB (http://couchdb.apache.org/):
 Configuration file in software/nosql/src/main/resources/brooklyn/entity/nosql/couchdb/couch.ini
-Copyright (c) The Apache Software Foundation
+Copyright (c) The Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at MongoDB (http://www.mongodb.org/):
@@ -133,19 +133,20 @@ Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Redis (http://redis.io/):
 Configuration files in software/nosql/src/main/resources/brooklyn/entity/nosql/redis/*.conf
-Licensed under the Three Clause BSD license
+Copyright (c) Salvatore Sanfilippo, Pieter Noordhuis, and other contributors as listed in the git history.
+Licensed under the Three Clause BSD license.
 
 This product includes configuation files developed at Basho (http://basho.com/riak/):
 Configuration file in software/nosql/src/main/resources/brooklyn/entity/nosql/riak/app.config
-Copyright (c) Basho.
+Copyright (c) Basho Technologies.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Apache Solr (http://lucene.apache.org/solr/):
 Configuration file in software/nosql/src/main/resources/brooklyn/entity/nosql/solr/solr.xml
-Copyright (c) Apache Software Foundation
+Copyright (c) Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
-This product includes configuation files developed at Apache Solr (http://jbossas.jboss.org/):
+This product includes configuation files developed at Red Hat JBoss (http://jbossas.jboss.org/):
 Configuration file in software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/*.xml
-Copyright (c) JBoss
-Licensed under LGPL
+Copyright (c) Red Hat, Inc.
+Licensed under the Lesser GNU Public License 2.1.


[10/11] incubator-brooklyn git commit: This closes #313

Posted by he...@apache.org.
This closes #313


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

Branch: refs/heads/master
Commit: c458bafc7ece1c2c4a9d631d78e3c5ccd216782c
Parents: dc53cec f4785fe
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Nov 11 14:16:38 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 11 14:16:38 2014 +0000

----------------------------------------------------------------------
 NOTICE                                          |  39 ++---
 .../basic/internal/ApiObjectsFactory.java       |   3 +-
 .../brooklyn/entity/basic/BrooklynTaskTags.java |   7 +-
 .../basic/EntityTransientCopyInternal.java      |   8 +
 .../entity/proxying/EntityProxyImpl.java        |   4 +
 .../internal/BrooklynGarbageCollector.java      |   4 +-
 .../java/brooklyn/util/file/ArchiveBuilder.java |   7 +-
 docs/use/guide/persistence/index.md             |  25 ++-
 pom.xml                                         |  28 ++++
 .../examples/simple-open-loop-policy/README.md  |  63 --------
 .../examples/simple-open-loop-policy/pom.xml    | 150 -----------------
 .../resources/jmeter-test-plan.jmx              | 143 -----------------
 .../src/main/java/brooklyn/demo/Sms.java        |  63 --------
 .../demo/WebClusterDatabaseOpenLoopExample.java | 160 -------------------
 .../main/resources/visitors-creation-script.sql |  35 ----
 .../src/test/java/brooklyn/demo/SmsTest.java    |  50 ------
 .../entity/webapp/tomcat/Tomcat7SshDriver.java  |   9 +-
 .../main/webapp/assets/js/view/ha-summary.js    |  26 ++-
 .../launcher/src/test/resources/couchbase.yaml  |   2 +-
 .../main/java/brooklyn/util/guava/Maybe.java    |  15 +-
 .../util/javalang/MemoryUsageTracker.java       |  72 +++++++++
 .../util/javalang/MemoryUsageTrackerTest.java   |  67 ++++++++
 utils/jmx/jmxmp-ssl-agent/pom.xml               |   4 -
 23 files changed, 278 insertions(+), 706 deletions(-)
----------------------------------------------------------------------



[02/11] incubator-brooklyn git commit: fix mis-attribution in notice, and other tidies there (punctuation mainly)

Posted by he...@apache.org.
fix mis-attribution in notice, and other tidies there (punctuation mainly)


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

Branch: refs/heads/master
Commit: 0a2c304b30223cc52e05c95a955c0df7ecf997f9
Parents: dc53cec
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Nov 11 12:29:52 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 11 12:43:09 2014 +0000

----------------------------------------------------------------------
 NOTICE | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0a2c304b/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index 4466310..dd496d3 100644
--- a/NOTICE
+++ b/NOTICE
@@ -45,7 +45,7 @@ Copyright (c) Twitter, Inc (2012).
 Licensed under the Apache License 2.0.
 typeahead.js, bloodhound.js
 Copyright (c) Twitter, Inc (2013).
-Licensed under the MIT License
+Licensed under the MIT License.
 
 This product includes software developed by Yehuda Katz (https://github.com/wycats/):
 handlebars*.js.
@@ -84,46 +84,46 @@ Licensed under the MIT license.
 
 This product includes configuation files developed at MariaDB (https://mariadb.org/):
 Configuration file in software/database/src/main/resources/brooklyn/entity/database/mariadb/my.cnf
-Copyright (c) The MariaDB Foundation
-Licensed under GNU General Public License, version 2
+Copyright (c) The MariaDB Foundation.
+Licensed under GNU General Public License, version 2.
 
 This product includes configuation files developed at MySQL (http://www.mysql.com/):
 Configuration file in software/database/src/main/resources/brooklyn/entity/database/mysql/mysql.conf
-Copyright (c) The Oracle Corporation
-Licensed under Oracle’s Free and Open Source Software ("FOSS") License Exception
+Copyright (c) The Oracle Corporation.
+Licensed under Oracle’s Free and Open Source Software ("FOSS") License Exception.
 
 This product includes configuation files developed at PostgreSQL (http://www.postgresql.org/):
 Configuration file in software/database/src/main/resources/brooklyn/entity/database/postgresql/postgresql.conf
-Copyright (c) PostgreSQL Global Development Group
-Licensed under The PostgreSQL Licence (http://opensource.org/licenses/postgresql)
+Copyright (c) PostgreSQL Global Development Group.
+Licensed under the PostgreSQL Licence (http://opensource.org/licenses/postgresql).
 
 This product includes configuation files developed at rubyrep (http://www.rubyrep.org/):
 Configuration file in software/database/src/main/resources/brooklyn/entity/database/rubyrep/rubyrep.conf
-Licensed under MIT License
+Licensed under the MIT License.
 
 This product includes configuation files developed at Apache ActiveMQ (http://activemq.apache.org/):
 Configuration file in software/messaging/src/main/resources/brooklyn/entity/messaging/activemq/activemq.xml
-Copyright (c) The Apache Software Foundation
+Copyright (c) The Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Apache Kafka (http://kafka.apache.org/):
 Configuration files in software/messaging/src/main/resources/brooklyn/entity/messaging/kafka/*
-Copyright (c) The Apache Software Foundation
+Copyright (c) The Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Apache Storm (https://storm.incubator.apache.org/):
 Configuration file in software/messaging/src/main/resources/brooklyn/entity/messaging/storm/storm.yaml
-Copyright (c) The Apache Software Foundation
+Copyright (c) The Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Apache Cassandra (http://cassandra.apache.org/):
 Configuration file in software/nosql/src/main/resources/brooklyn/entity/nosql/cassandra/*
-Copyright (c) The Apache Software Foundation
+Copyright (c) The Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Apache CouchDB (http://couchdb.apache.org/):
 Configuration file in software/nosql/src/main/resources/brooklyn/entity/nosql/couchdb/couch.ini
-Copyright (c) The Apache Software Foundation
+Copyright (c) The Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at MongoDB (http://www.mongodb.org/):
@@ -133,19 +133,20 @@ Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Redis (http://redis.io/):
 Configuration files in software/nosql/src/main/resources/brooklyn/entity/nosql/redis/*.conf
-Licensed under the Three Clause BSD license
+Copyright (c) Salvatore Sanfilippo, Pieter Noordhuis, and other contributors as listed in the git history.
+Licensed under the Three Clause BSD license.
 
 This product includes configuation files developed at Basho (http://basho.com/riak/):
 Configuration file in software/nosql/src/main/resources/brooklyn/entity/nosql/riak/app.config
-Copyright (c) Basho.
+Copyright (c) Basho Technologies.
 Licensed under the Apache License 2.0.
 
 This product includes configuation files developed at Apache Solr (http://lucene.apache.org/solr/):
 Configuration file in software/nosql/src/main/resources/brooklyn/entity/nosql/solr/solr.xml
-Copyright (c) Apache Software Foundation
+Copyright (c) Apache Software Foundation.
 Licensed under the Apache License 2.0.
 
-This product includes configuation files developed at Apache Solr (http://jbossas.jboss.org/):
+This product includes configuation files developed at Red Hat JBoss (http://jbossas.jboss.org/):
 Configuration file in software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/*.xml
-Copyright (c) JBoss
-Licensed under LGPL
+Copyright (c) Red Hat, Inc.
+Licensed under the Lesser GNU Public License 2.1.


[05/11] incubator-brooklyn git commit: remove pom instructions generating index.list file

Posted by he...@apache.org.
remove pom instructions generating index.list file

removing because it is including dependencies meant only for a shaded jar, which causes other tools to assume other jars do NOT provide certain packages; can manifest as guava not being found by osgi when constructing boot classpath; have confirmed JMX agent works without it (and the other jmx agent did not have it)


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

Branch: refs/heads/master
Commit: 08d0257cd977cd56236bcd54dad728a50f4452f5
Parents: b6068e3
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Nov 11 01:26:28 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 11 13:54:54 2014 +0000

----------------------------------------------------------------------
 utils/jmx/jmxmp-ssl-agent/pom.xml | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/08d0257c/utils/jmx/jmxmp-ssl-agent/pom.xml
----------------------------------------------------------------------
diff --git a/utils/jmx/jmxmp-ssl-agent/pom.xml b/utils/jmx/jmxmp-ssl-agent/pom.xml
index 4a43c4e..d327f70 100644
--- a/utils/jmx/jmxmp-ssl-agent/pom.xml
+++ b/utils/jmx/jmxmp-ssl-agent/pom.xml
@@ -83,10 +83,6 @@
                 <artifactId>maven-jar-plugin</artifactId>
                 <configuration>
                     <archive>
-                        <index>true</index>
-                        <manifest>
-                            <addClasspath>true</addClasspath>
-                        </manifest>
                         <manifestEntries>
                             <Premain-Class>brooklyn.util.jmx.jmxmp.JmxmpAgent</Premain-Class>
                             <Agent-Class>brooklyn.util.jmx.jmxmp.JmxmpAgent</Agent-Class>


[06/11] incubator-brooklyn git commit: fix bug where getMembers() used by the GUI was disallowed for entities in hot standby

Posted by he...@apache.org.
fix bug where getMembers() used by the GUI was disallowed for entities in hot standby


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

Branch: refs/heads/master
Commit: 6a5242a69946ede5d36a5a13d47fa44081b4607b
Parents: cc77677
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Nov 10 22:22:16 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 11 13:54:54 2014 +0000

----------------------------------------------------------------------
 .../brooklyn/entity/basic/EntityTransientCopyInternal.java   | 8 ++++++++
 .../main/java/brooklyn/entity/proxying/EntityProxyImpl.java  | 4 ++++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6a5242a6/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java b/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
index 0082768..576e182 100644
--- a/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
+++ b/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
@@ -110,4 +110,12 @@ public interface EntityTransientCopyInternal {
     ExecutionContext getExecutionContext();
     void setCatalogItemId(String id);
     
+    /** more methods, but which are only on selected entities */
+    public interface SpecialEntityTransientCopyInternal {
+        // from Group
+        Collection<Entity> getMembers();
+        boolean hasMember(Entity member);
+        Integer getCurrentSize();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6a5242a6/core/src/main/java/brooklyn/entity/proxying/EntityProxyImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/proxying/EntityProxyImpl.java b/core/src/main/java/brooklyn/entity/proxying/EntityProxyImpl.java
index 4163204..611eba3 100644
--- a/core/src/main/java/brooklyn/entity/proxying/EntityProxyImpl.java
+++ b/core/src/main/java/brooklyn/entity/proxying/EntityProxyImpl.java
@@ -37,6 +37,7 @@ import brooklyn.entity.basic.AbstractEntity;
 import brooklyn.entity.basic.EntityInternal;
 import brooklyn.entity.basic.EntityLocal;
 import brooklyn.entity.basic.EntityTransientCopyInternal;
+import brooklyn.entity.basic.EntityTransientCopyInternal.SpecialEntityTransientCopyInternal;
 import brooklyn.entity.effector.EffectorWithBody;
 import brooklyn.entity.rebind.RebindManagerImpl.RebindTracker;
 import brooklyn.management.ManagementContext;
@@ -102,6 +103,9 @@ public class EntityProxyImpl implements java.lang.reflect.InvocationHandler {
             throw new IllegalStateException("Entity read-only methods contains items not known as Entity methods: "+
                 extras);
         }
+        for (Method m : SpecialEntityTransientCopyInternal.class.getMethods()) {
+            ENTITY_PERMITTED_READ_ONLY_METHODS.add(new MethodSignature(m));
+        }
     }
     
     public EntityProxyImpl(Entity entity) {


[07/11] incubator-brooklyn git commit: misc doc fixes and code comments/reporting

Posted by he...@apache.org.
misc doc fixes and code comments/reporting

including improving persistence docs, and comments on tomcat and typo in couchbase


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

Branch: refs/heads/master
Commit: cc77677ed9c41740d5c6830740bf3ba51c6da388
Parents: df5fb25
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Nov 10 11:36:10 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 11 13:54:54 2014 +0000

----------------------------------------------------------------------
 .../basic/internal/ApiObjectsFactory.java       |  3 ++-
 .../java/brooklyn/util/file/ArchiveBuilder.java |  7 ++++--
 docs/use/guide/persistence/index.md             | 25 +++++++++++++++++++-
 .../entity/webapp/tomcat/Tomcat7SshDriver.java  |  9 ++++++-
 .../launcher/src/test/resources/couchbase.yaml  |  2 +-
 5 files changed, 40 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cc77677e/api/src/main/java/brooklyn/basic/internal/ApiObjectsFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/basic/internal/ApiObjectsFactory.java b/api/src/main/java/brooklyn/basic/internal/ApiObjectsFactory.java
index ecbb7fb..5a87805 100644
--- a/api/src/main/java/brooklyn/basic/internal/ApiObjectsFactory.java
+++ b/api/src/main/java/brooklyn/basic/internal/ApiObjectsFactory.java
@@ -47,7 +47,8 @@ public class ApiObjectsFactory {
             INSTANCE = Maybe.of(item);
             return INSTANCE.get();
         }
-        INSTANCE = Maybe.absent("Implementation of " + ApiObjectsFactoryInterface.class + " not found on classpath");
+        INSTANCE = Maybe.absent("Implementation of " + ApiObjectsFactoryInterface.class + " not found on classpath; "
+            + "can be caused by IDE not copying resources, or by something else clobbering non-class resources needed for service loading");
         return INSTANCE.get();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cc77677e/core/src/main/java/brooklyn/util/file/ArchiveBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/file/ArchiveBuilder.java b/core/src/main/java/brooklyn/util/file/ArchiveBuilder.java
index 88cd111..6985406 100644
--- a/core/src/main/java/brooklyn/util/file/ArchiveBuilder.java
+++ b/core/src/main/java/brooklyn/util/file/ArchiveBuilder.java
@@ -35,14 +35,12 @@ import java.util.zip.ZipOutputStream;
 
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.file.ArchiveUtils.ArchiveType;
-import brooklyn.util.io.FileUtil;
 import brooklyn.util.os.Os;
 
 import com.google.common.annotations.Beta;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.LinkedHashMultimap;
 import com.google.common.collect.Multimap;
-import com.google.common.io.ByteStreams;
 import com.google.common.io.Files;
 
 /**
@@ -86,6 +84,11 @@ public class ArchiveBuilder {
         return new ArchiveBuilder(ArchiveType.JAR);
     }
 
+    // TODO would be nice to support TAR and TGZ
+    // e.g. using commons-compress
+    // TarArchiveOutputStream out = new TarArchiveOutputStream(new GZIPOutputStream(bytes));
+    // but I think the way entries are done is slightly different so we'd need a bit of refactoring
+    
     private final ArchiveType type;
     private File archive;
     private Manifest manifest;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cc77677e/docs/use/guide/persistence/index.md
----------------------------------------------------------------------
diff --git a/docs/use/guide/persistence/index.md b/docs/use/guide/persistence/index.md
index bdbbf70..22ba5ce 100644
--- a/docs/use/guide/persistence/index.md
+++ b/docs/use/guide/persistence/index.md
@@ -45,7 +45,6 @@ To persist to the file system, start brooklyn with:
 brooklyn launch --persist auto --persistenceDir /path/to/myPersistenceDir
 {% endhighlight %}
 
-an
 If there is already data at `/path/to/myPersistenceDir`, then a backup of the directory will 
 be made. This will have a name like `/path/to/myPersistenceDir.20140701-142101345.bak`.
 
@@ -106,6 +105,25 @@ HTTP or JMX). This new state will be reported in the web-console and can also tr
 any registered policies.
 
 
+<a name="copy-state"></a>
+Copying Persistence State
+-------------------------
+
+Brooklyn includes a command to copy persistence state easily between two locations.
+The `copy-state` CLI command takes the following arguments:
+
+* `--persistenceDir` <source persistence dir>
+  The directory to read persisted state (or container name if using an object store).
+* `--persistenceLocation` <source persistence location>
+  The location spec for an object store to read persisted state.
+* `--destinationDir` <target persistence dir>
+  The directory to copy persistence data to (or container name if using an object store).
+* `--destinationLocation` <target persistence location>
+  The location spec for an object store to copy data to.
+* `--transformations` <transformations>
+  The local transformations file to be applied to the copy of the data before uploading it.
+
+
 <a name="handling-rebind-failures"></a>
 Handling Rebind Failures
 ------------------------
@@ -224,6 +242,11 @@ including setting priority to control which nodes will be promoted on master fai
 * `/server/ha/priority`: Returns the HA node priority for MASTER failover (GET),
   or sets that priority (POST)
 
+Note that when POSTing to a non-master server it is necessary to pass a `Brooklyn-Allow-Non-Master-Access: true` header.
+For example, the following cURL command could be used to change the state of a `STANDBY` node on `localhost:8082` to `HOT_STANDBY`:
+
+    curl -v -X POST -d mode=HOT_STANDBY -H "Brooklyn-Allow-Non-Master-Access: true" http://localhost:8082/v1/server/ha/state
+
 
 <a name="writing-persistable-code"></a>
 Writing Persistable Code

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cc77677e/software/webapp/src/main/java/brooklyn/entity/webapp/tomcat/Tomcat7SshDriver.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/tomcat/Tomcat7SshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/tomcat/Tomcat7SshDriver.java
index 05d8fc2..3593bc0 100644
--- a/software/webapp/src/main/java/brooklyn/entity/webapp/tomcat/Tomcat7SshDriver.java
+++ b/software/webapp/src/main/java/brooklyn/entity/webapp/tomcat/Tomcat7SshDriver.java
@@ -24,8 +24,9 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import com.google.common.collect.Iterables;
+
 import brooklyn.entity.basic.Entities;
-import brooklyn.entity.drivers.downloads.DownloadResolver;
 import brooklyn.entity.webapp.JavaWebAppSshDriver;
 import brooklyn.location.basic.SshMachineLocation;
 import brooklyn.util.collections.MutableList;
@@ -69,6 +70,12 @@ public class Tomcat7SshDriver extends JavaWebAppSshDriver implements Tomcat7Driv
         commands.add(BashCommands.INSTALL_TAR);
         commands.add(format("tar xvzf %s", saveAs));
 
+        if (getEnabledProtocols().size()!=1) {
+            log.warn("TomcatServer only supports one protocol, http; ignoring requested protocols "+getEnabledProtocols());
+        } else if (!"http".equalsIgnoreCase(Iterables.getOnlyElement(getEnabledProtocols()))) {
+            log.warn("TomcatServer only supports one protocol, http; ignoring requested protocol "+getEnabledProtocols());
+        }
+        
         newScript(INSTALLING)
                 .environmentVariablesReset()
                 .body.append(commands)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cc77677e/usage/launcher/src/test/resources/couchbase.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/couchbase.yaml b/usage/launcher/src/test/resources/couchbase.yaml
index bba8670..11b1b09 100644
--- a/usage/launcher/src/test/resources/couchbase.yaml
+++ b/usage/launcher/src/test/resources/couchbase.yaml
@@ -16,7 +16,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-name: Couchbase Two Bucket
+name: Couchbase One Bucket
 
 location: softlayer:wdc01
 


[04/11] incubator-brooklyn git commit: fix JS GUI server time race (rendering)

Posted by he...@apache.org.
fix JS GUI server time race (rendering)

fixes a bug where a server with clock a few seconds ahead of local causes weird message "in a few seconds" and possible flapping with "a few seconds ago"; just backdate it to be a few seconds ago if delta < 10s, else say "server clock in future by a few seconds" (or other time if it's really out of sync)


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

Branch: refs/heads/master
Commit: 396c600b15e2fb34882dbe0a1d95447d3bd2a0b2
Parents: 6a5242a
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Nov 10 23:14:01 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 11 13:54:54 2014 +0000

----------------------------------------------------------------------
 .../main/webapp/assets/js/view/ha-summary.js    | 26 ++++++++++++++++----
 1 file changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/396c600b/usage/jsgui/src/main/webapp/assets/js/view/ha-summary.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/ha-summary.js b/usage/jsgui/src/main/webapp/assets/js/view/ha-summary.js
index f700e34..fb96ea1 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/ha-summary.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/ha-summary.js
@@ -30,7 +30,7 @@ define([
                 "<% if (isSelf) { %><span class='pull-right badge badge-success'>this</span><% } %>" +
             "</td>" +
             "<td><%= status %></td>" +
-            "<td><span class='timestamp' data-timestamp='<%= timestamp %>'><%= timestampDisplay %><span></td>" +
+            "<td><%= timestampDisplayPrefix %><span class='timestamp' data-timestamp='<%= timestamp %>'><%= timestampDisplay %><span><%= timestampDisplaySuffix %></td>" +
         "</tr>");
     var noServers = "<tr><td colspan='3'><i>Failed to load servers!</i></td></tr>";
 
@@ -59,22 +59,38 @@ define([
             $target.empty();
             // undefined check just in case server returns something odd
             if (nodes == undefined || _.isEmpty(nodes)) {
-                $target.html(noServers)
+                $target.html(noServers);
             } else {
                 _.each(nodes, function (n) {
                     var node = _.clone(n);
+                    node.timestampDisplayPrefix = "";
+                    node.timestampDisplaySuffix = "";
                     if (node['remoteTimestamp']) {
                         node.timestamp = node.remoteTimestamp;
-                        node.timestampDisplay = moment(node.remoteTimestamp).fromNow();
                     } else {
                         node.timestamp = node.localTimestamp;
-                        node.timestampDisplay = moment(node.localTimestamp).fromNow()+" (local)";
+                        node.timestampDisplaySuffix = " (local)";
                     }
+                    if (node.timestamp >= moment().utc() + 10*1000) {
+                        // if server reports time significantly in future, report this, with no timestampe
+                        node.timestampDisplayPrefix = "server clock in future by "+
+                            moment.duration(moment(node.timestamp).diff(moment())).humanize();
+                        node.timestamp = "";
+                        node.timestampDisplay = "";
+                    } else {
+                        // else use timestamp
+                        if (node.timestamp >= moment().utc()) {
+                            // but if just a little bit in future, backdate to show "a few seconds ago"
+                            node.timestamp = moment().utc()-1;
+                        }
+                        node.timestampDisplay = moment(node.timestamp).fromNow();
+                    }
+                    
                     node.isSelf = node.nodeId == self;
                     node.isMaster = self == master;
                     node.isTerminated = node.status == "TERMINATED";
                     $target.append(nodeRowTemplate(node));
-                })
+                });
             }
         },
         updateTimestamps: function() {


[11/11] incubator-brooklyn git commit: This closes #316

Posted by he...@apache.org.
This closes #316


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

Branch: refs/heads/master
Commit: 9352bbe90fcc8499ae3a36874876a4200c4dfc7c
Parents: c458baf 0a2c304
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Nov 11 14:16:41 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Nov 11 14:16:41 2014 +0000

----------------------------------------------------------------------

----------------------------------------------------------------------