Skip to content

Instantly share code, notes, and snippets.

@pcn
pcn / how-it-fails
Last active December 31, 2015 13:19
This function is supposed to allow a single thread to be the file writer for a spool which creates files only when needed.
carbon-relaj.core=> (>!! spool-channel ["a.b.c.d" (System/currentTimeMillis) (System/currentTimeMillis) ])
nil
Not nil: [a.b.c.d 1387219958954 1387219958954]
["a.b.c.d",1387219958954,1387219958954]
file-ref-map has ([:writable-file #<BufferedWriter java.io.BufferedWriter@1c62f6a>] [:file-name "/tmp/foo/temp/1387219958.962"] [:the-time 1387219958962])
writable-file is java.io.BufferedWriter@1c62f6a
Exception in thread "Thread-1" java.lang.IllegalArgumentException: No matching method found: write for class java.io.BufferedWriter
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:53)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at carbon_relaj.core$write_data_to_file.invoke(core.clj:199)
@pcn
pcn / breakage
Last active January 1, 2016 04:29
fs/link breaks
carbon-relaj.files=> (fs/link "/tmp/foo/temp/20-1387779747.793" "/tmp/foo/send/host-a/foo")
NoSuchFileException /tmp/foo/temp/20-1387779747.793 -> /tmp/foo/send/host-a/foo sun.nio.fs.UnixException.translateToIOException (UnixException.java:86)
; And in the opposite order:
carbon-relaj.files=> (fs/link "/tmp/foo/send/host-a/foo/20-1387779747.793" "/tmp/foo/temp/20-1387779747.793")
NoSuchFileException /tmp/foo/send/host-a/foo/20-1387779747.793 -> /tmp/foo/temp/20-1387779747.793 sun.nio.fs.UnixException.translateToIOException (UnixException.java:86)
@pcn
pcn / 1.install+build
Last active January 3, 2016 03:59
Testing writes on cassandra 1.2 with cassandra-stress
git clone https://github.com/apache/cassandra.git
cd cassandra
git checkout cassandra-1.2.13
ant
@pcn
pcn / gist:8547210
Created January 21, 2014 19:58
Fixup nagios for cassandra sedeploy
include_recipe 'nagios::client'
include_recipe 'nagios_discovery::virtualenv'
# FIXME we need to move this block to ohai or cb attributes
node.chef_environment =~ /(.*)-(.*)/
billing_env = $1
kcs_env = $2
azone = node['ec2']['placement_availability_zone']
region = azone[0, azone.length - 1]
@pcn
pcn / crude_1_liner
Created January 28, 2014 00:56
Crude renaming of cassandra sstables from a 3-node to a 1-node cluster for testing
for f in $(find . -type f) ; do mv $f $(echo $f | sed 's/-\([0-9]*\)-/-300\1-/') ; done
@pcn
pcn / 1.Find and remove the first node
Last active August 29, 2015 13:55
Testing moving cassandra from CFN to bare
```
$ kcs s create Cassandra CassandraPriamCluster.template PN ACount=2 DCount=2 ECount=2 InstanceCount=1
```
The resulting cluster looks something like this:
```
(python)7235 pn@pn-mbp 11:44 ~/dvcs/github/chef-repo/environments $ hss s pn-cassandra -terminated
0. running 2014-01-31T16:27 i-b281df92 ec2-184-72-147-62.compute-1.amazonaws.com Kerberos cassandra_pn_kcs,base,pn_kcs,pn-cassandra,pn-cassandra
1. running 2014-01-31T16:27 i-b181df91 ec2-54-226-107-205.compute-1.amazonaws.com Kerberos cassandra_pn_kcs,base,pn_kcs,pn-cassandra
2. running 2014-01-31T16:24 i-d0bd21f1 ec2-184-72-73-37.compute-1.amazonaws.com Kerberos cassandra_pn_kcs,base,pn_kcs,pn-cassandra,pn-cassandra
@pcn
pcn / _etc_initramfs-tools_scripts_local-top_assemble-md-arrays
Last active August 29, 2015 13:56
How to raid a cassandra cluster in ec2
#!/bin/sh
# the kernel doesn't seem to automatically
# discover arrays with the >v0.90 md superblock
# format - if I understand this properly.
# So, do this as a script from the initramfs
mdadm --assemble --scan
@pcn
pcn / run
Created February 13, 2014 17:41
carbon-relaj failing on *config* reading
$ lein run -c /tmp/foo
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
^[[BUnable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
Config-file is /tmp/foo
Config-file is /tmp/foo
nil
Exception in thread "main" java.lang.NullPointerException, compiling:(core.clj:34:33)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3463)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3457)
at clojure.lang.Compiler$DefExpr.eval(Compiler.java:408)
@pcn
pcn / try-a-threading-in-clojure
Last active August 29, 2015 13:56
what does -> do in clojure, when I want to update keys in a map and pass that down? Does it re-bind?
(def file-config-map {"channel-queue-size" "128",
"send-dir" "/tmp/foo/send",
"spool-dir" "/tmp/foo",
"file-rotation-period-ms" "1000",
"temp-dir" "/tmp/foo/temp",
"channel-timeout" "250",
"lineproto-port" "2003",
"target-list" "host-a,host-b,host-c,host-d"})
(defn parse-int [maybe-a-string]
@pcn
pcn / tmux.conf
Last active August 29, 2015 13:57 — forked from spicycode/tmux.conf
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys emacs
set -g history-limit 10000
setw -g mode-keys emacs
setw -g mode-mouse off