Skip to content

Instantly share code, notes, and snippets.


Aled Sage aledsage

View GitHub Profile
aledsage / gist:9964492
Created Apr 3, 2014
AWS TerminateInstances 500 Internal Server Error
View gist:9964492
2014-04-02 14:26:18,329 DEBUG o.j.h.i.JavaUrlHttpCommandExecutorService [brooklyn-execmanager-C7S2PVnJ-4771]: Sending request -467970851: POST HTTP/1.1
2014-04-02 14:26:18,329 DEBUG jclouds.wire [brooklyn-execmanager-C7S2PVnJ-4771]: >> "Action=TerminateInstances&InstanceId.1=i-ace13c8c&Signature=sigsnip&SignatureMethod=HmacSHA256&SignatureVersion
2014-04-02 14:26:18,330 DEBUG jclouds.headers [brooklyn-execmanager-C7S2PVnJ-4771]: >> POST HTTP/1.1
2014-04-02 14:26:18,330 DEBUG jclouds.headers [brooklyn-execmanager-C7S2PVnJ-4771]: >> Host:
2014-04-02 14:26:18,330 DEBUG jclouds.headers [brooklyn-execmanager-C7S2PVnJ-4771]: >> Content-Type: application/x-www-form-urlencoded
2014-04-02 14:26:18,330 DEBUG jclouds.headers [brooklyn-execmanager-C7S2PVnJ-4771]: >> Content-Length: 246
2014-04-02 14:26:19,097 DEBUG o.j.h.i.JavaUrlHttpCom
aledsage / gist:a8795292407d255e1b0b
Created Jul 1, 2014
Brooklyn yaml: simple cluster with policy
View gist:a8795292407d255e1b0b
location: localhost
- type:
initialSize: 2
type: brooklyn.entity.basic.EmptySoftwareProcess
- policyType: brooklyn.policy.autoscaling.AutoScalerPolicy
aledsage /
Created May 25, 2012
First stab at pure-java brooklyn application syntax
package brooklyn.demo;
import static brooklyn.event.basic.DependentConfiguration.valueWhenAttributeReady;
import brooklyn.entity.basic.AbstractApplication;
import brooklyn.entity.database.mysql.MySqlNode;
import brooklyn.entity.proxy.nginx.NginxController;
import brooklyn.entity.webapp.ControlledDynamicWebAppCluster;
import brooklyn.entity.webapp.DynamicWebAppCluster;
import brooklyn.entity.webapp.jboss.JBoss7Server;
aledsage / gist:3122026
Created Jul 16, 2012
Example brooklyn groovy code to poll an underlying resource, to update attributes (aka sensors)
View gist:3122026
// Polls a given URL, and uses the HTTP response to set the
// two Brooklyn entity attributes SERVICE_UP and REQUEST_COUNT
def http = sensorRegistry.register(
new HttpSensorAdapter("http://$host:$port/management/subsystem/web/connector/http/read-resource",
period: 200*TimeUnit.MILLISECONDS).
vars("include-runtime":true) )
with(http) {
poll(SERVICE_UP) { responseCode==200 }
aledsage / gist:3122130
Created Jul 16, 2012
Proposed brooklyn Java code to poll an underlying resource, to update attributes (aka sensors)
View gist:3122130
// Polls the given JMX attribute every minute; transforms the result from tabular data
// into a java.util.Map and sets the given brooklyn sensor (aka attribute) accordingly.
// The onSuccess is passed the JMX attribute's value.
JmxSensorAdapter jmxAdapter = registry.register(new JmxSensorAdapter());
.pollAttribute(new JmxAttributePollConfig<Map>(MY_BROOKLYN_SENSOR)
.period(1, TimeUnit.MINUTES)
aledsage / gist:3122497
Last active Oct 7, 2015
Entity-author example
View gist:3122497
* Everyone uses this interface when dealing with MySqlNode instances.
public interface MySqlNode extends Entity, Startable {
// Note needs this generic to make sub-classing simple
public static class Recipe<T extends MySqlNode> extends SoftwareProcessEntity.Recipe<T> {
private PortRange port = PortRanges.fromString("3306, 13306+");
private String creationScriptContents;
aledsage / gist:3122488
Last active Oct 7, 2015
Application-author example
View gist:3122488
// Application authors write an "ApplicationBuilder"...
// The advantage is that it separates the Entity API from this builder API,
// allowing each API to be optimised for the appropriate role (i.e. top-level
// methods for the common operations so they are easy to find and use).
// e.g. aim of ApplicationBuilder is to make it easy to create + configure +
// wire together pre-existing types of entity, and to associate policies with them.
// It uses the "Recipes" of these pre-existing entity types to configure them,
// without worrying about how that implementation handles its children etc.
aledsage / gist:3143723
Created Jul 19, 2012
Proposed brooklyn Java code to poll an underlying resource, to update attributes (aka sensors) - v2
View gist:3143723
// See v1 proposal at
// This example shows use of a builder pattern to construct an immmutable JmxSensorAdapter
// before passing it to register(...).
// Most contentious issues:
// 1. immutability of JmxSensorAdapter
// 2. explicitly passing in entity(...) so can infer the jmx url from its attributes
// 3. use of withObjectName(...) to create a kind of sub-context so subsequent calls to pollAttribute
// don't need to keep repeating the object name
aledsage / gist:4284263
Created Dec 14, 2012
Proposed "feeds" for polling an underlying resource for populating brooklyn attributes
View gist:4284263
// FROM JBOSS AS 7, polling its http management api
protected void connectSensors() {
httpFeed = HttpFeed.builder()
.baseUri(String.format("http://%s:%s/management/subsystem/web/connector/http/read-resource", host, port))
aledsage / gist:5095696
Created Mar 6, 2013
brooklyn docs build fails
View gist:5095696
Aleds-MacBook-Pro:docs aled [0.5.0-M2] $./_scripts/
Configuration from /Users/aled/repos/cloudsoft/brooklyn/docs/_config.yml
Building site: /Users/aled/repos/cloudsoft/brooklyn/docs -> /Users/aled/repos/cloudsoft/brooklyn/docs/_site
Liquid Exception: No such file or directory - /Users/aled/repos/cloudsoft/brooklyn/docs/use/guide/quickstart/ in
/Library/Ruby/Gems/1.8/gems/jekyll-0.12.1/bin/../lib/jekyll/convertible.rb:28:in `read'
/Library/Ruby/Gems/1.8/gems/jekyll-0.12.1/bin/../lib/jekyll/convertible.rb:28:in `read_yaml'
/Library/Ruby/Gems/1.8/gems/jekyll-0.12.1/bin/../lib/jekyll/page.rb:24:in `initialize'
/Users/aled/repos/cloudsoft/brooklyn/docs/_plugins/read.rb:51:in `new'
/Users/aled/repos/cloudsoft/brooklyn/docs/_plugins/read.rb:51:in `render'
/Library/Ruby/Gems/1.8/gems/liquid-2.4.1/lib/liquid/block.rb:94:in `render_all'