Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Heneveld ahgittin

View GitHub Profile
@ahgittin
ahgittin / gist:8736763
Created Jan 31, 2014
dse-cassandra-blueprint.yaml
View gist:8736763
name: dse-cassandra
# starts a single datacenter DSE cluster and an opscenter node
services:
- type: io.cloudsoft.datastax.dse.DSECassandraDatacenter
name: DSE Cluster
brooklyn.config:
cluster.initial.size: 5
cluster.initial.quorumSize: 3
datastax.cassandra.opscenter.entity: $brooklyn:component("opscenter")
@ahgittin
ahgittin / gist:9934210
Created Apr 2, 2014
brooklyn 070-snapshot oome info
View gist:9934210
Hosted AMP in SL running no blueprints currently, but previously deploying OG to SL and AWS
num #instances #bytes class name
----------------------------------------------
1: 5798577 185554464 java.util.concurrent.ConcurrentHashMap$HashEntry
2: 5403795 172921440 java.lang.String
3: 1431659 84584664 [C
4: 1528111 67764056 [Ljava.util.concurrent.ConcurrentHashMap$HashEntry;
5: 1528111 61124440 java.util.concurrent.ConcurrentHashMap$Segment
View simple-web-server.sh
cat > index.html << --EOF--
<html><body>
<h1>Hello World</h1>
<p>
This is a sample Brooklyn-deployed web server, built on netcat.
Of course you can use any script here, or pre-built blueprints for common webapp, nosql, message software,
services, clusters, or a pre-built imageId, or Chef -- up to you.
</p>
<p>
Management policies can then be mixed in.
View SampleMonitorEntity.java
package io.cloudsoft.ibm.mms.amp.util;
import brooklyn.config.ConfigKey;
import brooklyn.enricher.Enrichers;
import brooklyn.entity.basic.AbstractEntity;
import brooklyn.entity.basic.Attributes;
import brooklyn.entity.basic.ConfigKeys;
import brooklyn.event.AttributeSensor;
import brooklyn.event.basic.Sensors;
import brooklyn.event.feed.http.HttpFeed;
@ahgittin
ahgittin / gist:ef8a4b39695f6d4c684e
Created Apr 23, 2015
illustration of correct indentation for Apache Brooklyn `provisioning.properties` and how to specify those properties on the location
View gist:ef8a4b39695f6d4c684e
name: chef-mysql-sample
location:
jclouds:aws-ec2:us-west-1:
minRam: 4gb
services:
- type: chef:mysql
...
provisioning.properties:
# this will override `minRam` set above
minRam: 5046mb
View catalog.bom
brooklyn.catalog:
version: 0.1
description: Sample VM with a demo script
name: Alex-AWS-VM-1
location:
jclouds:aws-ec2:
region: eu-west-1
osFamily: ubuntu
@ahgittin
ahgittin / https call
Last active Aug 29, 2015
Brooklyn GUI groovy snippets
View https call
String urlBase = "https://HOSTNAME:8443";
String subUrl = "/";
String password = "PASSWORD";
org.apache.http.client.HttpClient c = new brooklyn.util.http.HttpTool.HttpClientBuilder().https(true).trustAll()
.uri(urlBase)
.credentials(new org.apache.http.auth.UsernamePasswordCredentials(
"admin", password)).build();
brooklyn.util.http.HttpToolResponse r = brooklyn.util.http.HttpTool.httpGet(c, java.net.URI.create(
urlBase+subUrl), null);
View test
interface Function2 { int apply(int a, int b); }
int factorial(int n) { return applyFromOneToN(new Function2() { int apply(int a, int b) { return a*b; } }, n); }
@ahgittin
ahgittin / gist:1314030
Created Oct 25, 2011
whirr-49 options for cluster controller
View gist:1314030
 public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(ClusterSpec spec,
       Predicate<NodeMetadata> condition, Statement statement) throws IOException, RunScriptOnNodesException {
   return runScriptOnNodesMatching(spec, condition, statement, null);
 }
 public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(ClusterSpec spec,
     Predicate<NodeMetadata> condition, Statement statement, RunScriptOptions options)
     throws IOException, RunScriptOnNodesException {
   Credentials credentials = new Credentials(spec.getClusterUser(), spec.getPrivateKey());
   if (options==null)
@ahgittin
ahgittin / gist:1445672
Created Dec 8, 2011
reflective equals timing test
View gist:1445672
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
public class ReflectiveEquals {
static class Fast {
public int a = 1;
public int b = 2;
public String c = "foo";