Skip to content

Instantly share code, notes, and snippets.

View tsuna's full-sized avatar

Benoit Sigoure tsuna

View GitHub Profile
@tsuna
tsuna / clean_cache.sh
Created March 3, 2014 19:05
Shell script to automatically clean TSD's cache directory from a cron job
#!/bin/bash
CACHE_DIR=/tmp/tsd
diskSpaceIsShort() {
df -h "$CACHE_DIR" \
| awk 'NR==2{pct=$5; sub(/%/, "", pct); if (pct < 90) exit 1; exit 0;}'
}
if diskSpaceIsShort; then
@tsuna
tsuna / integration_test.go
Last active August 29, 2015 14:27
gohbase integration test to access a disabled table
func TestDisabledTable(t *testing.T) {
// TODO: We leak the master client.
master := gohbase.NewClient(*host, gohbase.Admin())
logrus.WithFields(logrus.Fields{"table": table}).Info("Disabling table")
_, err := master.SendRPC(hrpc.NewDisableTable(context.Background(), []byte(table)))
if err != nil {
t.Fatalf("Failed to disable %q: %s", table, err)
}
key := "TestDisabledTable"
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;
public class t {
static public void main(String[] args) {
HashMap<String, Integer> hm = new HashMap<String, Integer>();
hm.put("answer", 42);
@tsuna
tsuna / 0001-Don-t-shutdown-while-RPCs-are-waiting-for-a-ROOT-loo.patch
Created November 22, 2010 05:17
Netty getting stuck in an infinite loop during shutdown
From 07d1425781f08799ff9ef59f9cd578fa63a2e83f Mon Sep 17 00:00:00 2001
From: Benoit Sigoure <tsuna@stumbleupon.com>
Date: Sun, 21 Nov 2010 20:42:20 -0800
Subject: [PATCH] Don't shutdown while RPCs are waiting for a -ROOT- lookup.
The following scenario led to data loss:
1. Application starts.
2. A PutRequest is generated, triggers a -ROOT- lookup.
3. Application calls shutdown() on the HBaseClient, the client
terminates and the PutRequest is lost.
@tsuna
tsuna / 0001-Add-support-for-CDHb3.patch
Created January 18, 2011 08:28
Add support for CDHb3 in asynchbase.
From fd1d76efba48269aaec80e90f629f01ba4581fed Mon Sep 17 00:00:00 2001
From: Benoit Sigoure <tsuna@stumbleupon.com>
Date: Tue, 18 Jan 2011 00:21:20 -0800
Subject: [PATCH] Add support for CDHb3.
This change adds support for CDHb3. In order to enable the new code,
the JVM must be given the following system property in argument:
-Dorg.hbase.async.cdhb3
CDHb3 includes a temporary patch that changes the format of the "hello"
@tsuna
tsuna / 0001-Add-support-for-HBase-0.90.patch
Created January 28, 2011 01:36
Add support for HBase 0.90 in asynchbase.
From 7a538914c93f8a92b9c80e5c533e73d97e8423c8 Mon Sep 17 00:00:00 2001
From: Benoit Sigoure <tsuna@stumbleupon.com>
Date: Thu, 27 Jan 2011 17:33:37 -0800
Subject: [PATCH] Add support for HBase 0.90.
In order to enable the new code, the JVM must be given the following
system property in argument:
-Dorg.hbase.async.v0.90
For HBASE-3174, revision r1029115 (or 08e64aae in Git) changed the
@tsuna
tsuna / tsdq.py
Created February 27, 2011 09:29
Quick script to run a couple queries against a TSD and time it
#!/usr/bin/python
import httplib
import json
import os
import shutil
import time
def purge_tsd_cache():
for dir in (dir for dir in os.listdir("/tmp/tsd") if dir[0] != "."):
@tsuna
tsuna / gist:1119725
Created August 2, 2011 07:07
TSDB query start time underflow
diff --git a/src/core/TsdbQuery.java b/src/core/TsdbQuery.java
index 2edd53c..8776e89 100644
--- a/src/core/TsdbQuery.java
+++ b/src/core/TsdbQuery.java
@@ -401,7 +401,8 @@ final class TsdbQuery implements Query {
// but this doesn't really matter.
// Additionally, in case our sample_interval is large, we need to look
// even further before/after, so use that too.
- return getStartTime() - Const.MAX_TIMESPAN * 2 - sample_interval;
+ final long t = getStartTime() - Const.MAX_TIMESPAN * 2 - sample_interval;
@tsuna
tsuna / memcachemon.py
Created August 10, 2011 06:43
Memcache collector for tcollector
#!/usr/bin/env python
import socket
import subprocess
import sys
import time
COLLECTION_INTERVAL = 15 # seconds
@tsuna
tsuna / nagiosirc.pl
Created August 10, 2011 22:38
Handy little bot to get Nagios notifications on IRC
#!/usr/bin/perl -w
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (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.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing