Skip to content

Instantly share code, notes, and snippets.

View jsanda's full-sized avatar

John Sanda jsanda

View GitHub Profile
@jsanda
jsanda / dbreset.py
Last active December 17, 2015 02:18
from org.rhq.cassandra.schema import SchemaManager
if project.properties['db'] == 'dev':
self.log('PERFORMING STORAGE NODE SETUP TO LATEST SCHEMA')
username = project.properties.get('rhq.dev.cassandra.username', 'cassandra')
password = project.properties.get('rhq.dev.cassandra.password', 'cassandra')
seeds = project.properties.get('rhq.dev.cassandra.seeds', '127.0.0.1|9160|9142')
schemaManager = SchemaManager(username, password, seeds)
importClass(org.rhq.cassandra.schema.SchemaManager);
if (project.properties['db'] == 'dev') {
self.log('PERFORMING STORAGE NODE SETUP TO LATEST SCHEMA');
username = project.properties['rhq.dev.cassandra.username'] ? project.properties['rhq.dev.cassandra.username'] : 'cassandra';
password = project.properties['rhq.dev.cassandra.password'] ? project.properties['rhq.dev.cassandra.password'] : 'cassandra';
seeds = project.properties['rhq.dev.cassandra.seeds'] ? project.properties['rhq.dev.cassandra.seeds'] : '127.0.0.1|9160|9142';
schemaManager = SchemaManager(username, password, seeds);
<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<!-- Explicitly indicate that we do not want sub deployments isolated; subdeployments need to see each other's classes -->
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<!-- This corresponds to the top level deployment - which in this case in the EAR module -->
<deployment>
<dependencies>
<module name="org.jboss.common-core" export="true" /> <!-- needed to fix https://issues.jboss.org/browse/AS7-5336 -->
public class SnappyNativeLoader
{
private static HashMap<String, Boolean> loadedLibFiles = new HashMap<String, Boolean>();
private static HashMap<String, Boolean> loadedLib = new HashMap<String, Boolean>();
public static synchronized void load(String lib) {
if (loadedLibFiles.containsKey(lib) && loadedLibFiles.get(lib) == true)
return;
try {
(ns rhq.rest.client
(:require [clojure.data.json :as json])
(:require [clj-http.client :as http]))
(def server-url "http://localhost:7080/rest/")
(def schedule-types
{:trait "TRAIT"
:numeric "MEASUREMENT"})
(ns immutant.init
(:use immutant-demo.core)
(:require [immutant.web :as web]
[immutant.jobs :as jobs]
[rhq.rest.client :as rhq]
[clojure.tools.logging :as logging]))
(web/start ring-handler)
(web/start "/biscuits" another-ring-handler)
@jsanda
jsanda / gist:7881321
Created December 9, 2013 21:31
RHQ's Cassandra schema for metrics data
CREATE TABLE rhq.raw_metrics (
schedule_id int,
time timestamp,
value double,
PRIMARY KEY (schedule_id, time)
) WITH COMPACT STORAGE;
CREATE TABLE rhq.one_hour_metrics (
schedule_id int,
time timestamp,
public class ServerTest extends MetricsTest {
private static final int TTL = 360;
private PlatformManager platformManager;
private DataAccess dataAccess;
private RawMetricMapper rawMapper;
@Test//(dependsOnMethods = "insertMetricsForOneId")
public void findRawMetricsForSingleId() throws Exception {
final String metricId = UUID.randomUUID().toString();
long timestamp1 = System.currentTimeMillis();
double value1 = 2.17;
ResultSetFuture insertFuture = dataAccess.insertData("raw", metricId, timestamp1,
ImmutableMap.of(DataType.RAW.ordinal(), value1), TTL);
// wait for the insert to finish
getUninterruptibly(insertFuture);
@jsanda
jsanda / CalculateAggregate.java
Created May 14, 2014 18:42
bug in aggregation code
private AggregateNumericMetric calculateAggregate(Iterable<AggregateNumericMetric> metrics, long timestamp) {
double min = Double.NaN;
double max = min;
int count = 0;
ArithmeticMeanCalculator mean = new ArithmeticMeanCalculator();
for (AggregateNumericMetric metric : metrics) {
if (count == 0) {
min = metric.getMin();
max = metric.getMax();