Skip to content

Instantly share code, notes, and snippets.

View ahgittin's full-sized avatar

Alex Heneveld ahgittin

View GitHub Profile
@ahgittin
ahgittin / brooklyn-dependent-entity-config.json
Created July 26, 2012 15:18 — forked from andreisavu/brooklyn-dependent-entity-config.json
Suggestions from Alex for Brooklyn dependent entitiy configuration
{
"name":"web-and-db",
"entities":[{
"type":"brooklyn.entity.webapp.ElasticJavaWebAppService",
"config":{
"java.options":{
"type":"Map",
"operation":"put",
"values":{
"brooklyn.example.db.url":{
@ahgittin
ahgittin / jstack-active
Created September 16, 2012 22:19
script to run jstack but just show those threads which are active ... a poor man's profiler, or how to make eclipse beach ball slightly more exciting :)
#!/bin/bash
jstack $@ | awk '
function onTraceBegin() {
onTraceEnd()
data["lineCount"]=0
data["head"]=$0
}
function onTraceEnd() {
if ("head" in data) {
@ahgittin
ahgittin / pss
Last active October 10, 2015 18:47
script to quickly list find and kill processes
#/bin/bash
help() {
echo "pss [command [option]]+ -- quickly list, find and kill processes"
echo "commands:"
echo " h -- help"
echo " g X -- grep X"
echo " gi X -- grep -i X (ignore case)"
echo " gv X -- grep -v X (show non-matching)"
echo " g2 X Y -- grep for X or Y (also g3, g4)"
echo " k -- kill"
@ahgittin
ahgittin / brooklyn-rebinding-notes.txt
Created September 20, 2012 09:58
Brooklyn RebindLocation notes, general mechanism for persistence and revivification
Rebindable (Entity)
- REBINDING_STATUS sensor -> empty (not rebinding), REBINDING, COMPLETED, FAILED
- getRebindLocationGenerator() -> returns a generator suitable for rebinding this entity
(where the generator produces a RebindLocation initially, but might also produce json/xml;
and allow interrogation about whether all descendents etc are rebindable)
RebindLocation {
/** takes no action but says whether it can rebind */
boolean canRebind(Entity);
/** sets config & sensors on entity, returns the locations where the entity should proceed to start
BrooklynServerDetails details = BrooklynLauncher.newLauncher().
// to add a custom webapp
webapp("/cdh", "classpath://brooklyn-cdh-frontend.war").
webconsolePort(CommandLineUtil.getCommandLineOption(args, "--port", "8081+")).
launch();
// then things below linked to buttons / etc in app
// get the mgmt context (and also the webconsole URL) from this details container
ManagementContext mgmt;
@ahgittin
ahgittin / EntityAddChildSyntaxSnippet.java
Last active December 15, 2015 04:50
simplifying entity/app construction API
// current syntax
MySqlNode mysql = (MySqlNode) addChild(
getEntityManager().createEntity(
BasicEntitySpec.newInstance(MySqlNode.class)
.configure(MySqlNode.CREATION_SCRIPT_URL, getConfig(DB_SETUP_SQL_URL))) );
// step 1 (uncontroversial?): allow addChild to take a spec directly
MySqlNode mysql1 = (MySqlNode) addChild(
BasicEntitySpec.newInstance(MySqlNode.class)
.configure(MySqlNode.CREATION_SCRIPT_URL, getConfig(DB_SETUP_SQL_URL)) );
@ahgittin
ahgittin / MapRSyntaxPlaying.java
Created April 2, 2013 19:45
experimenting with syntax for creating MapR clusters
public class NewMapRSyntaxPlaying {
{
// 0.5.0-rc.1
// option 1 -- clusters with spec
// core = addChild(cluster(
@ahgittin
ahgittin / 0-three-tier-as-yaml.txt
Last active December 15, 2015 19:29
playing with Oasis CAMP PDP syntax
# yaml variant, similar to #3 below, with an explicit load balancer
# this format makes it much easier for mortals to read and write,
# based significantly on https://wiki.openstack.org/wiki/Heat/DSL
name: "Hello WebApp Cluster with Database"
components:
# key here equivalent to supplying a map with this as the value for key 'id'
hello_war:
content: hello.war
requires:
- type: com.example.java:WarDeploymentRequirement # explicit req type says to "deploy"
[
{
"type" : "DeploymentPlan"
"href" : "data://...",
},
{
"type" : "Requirement",
"id" : "file1",
"href" : "data://...",
},
@ahgittin
ahgittin / jetty-spring.xml
Created June 13, 2013 10:47
Additional lines to insert into OpenGamma jetty-spring.xml to enable the Jetty MX bean. http://forums.opengamma.com/forum/discussion/comment/743
<bean id="standardMBeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
<property name="locateExistingServerIfPossible" value="true" />
</bean>
<bean id="jettyJMXExporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="com.opengamma.jetty:service=HttpConnector" value-ref="connector" />
<entry key="com.opengamma.jetty:service=HttpServer" value-ref="server" />
</map>