Skip to content

Instantly share code, notes, and snippets.

View jbrisbin's full-sized avatar

Jon Brisbin jbrisbin

View GitHub Profile
@jbrisbin
jbrisbin / KeyValueStoreKey.java
Created November 12, 2010 14:07
Example KeyValueStoreKey representation to handle keys for various NoSQL stores.
public class KeyValueStoreKey {
protected Object family;
protected Object key;
public KeyValueStoreKey() {
}
public KeyValueStoreKey(Object family, Object key) {
this.family = family;
@jbrisbin
jbrisbin / gist:674126
Created November 12, 2010 14:09
Bucket and Key extraction from a single, composite-key-like object
Object bucket = null;
Object key = null;
if (obj instanceof Map) {
Map m = (Map) obj;
bucket = m.get("bucket");
key = m.get("key");
} else {
// Override from Annotation?
KeyValueStoreMetaData meta = obj.getClass().getAnnotation(KeyValueStoreMetaData.class);
if (null != meta && null != meta.family()) {
@jbrisbin
jbrisbin / rabbit_riak_queue.erl
Created January 31, 2011 14:07
Errors I'm getting trying to persist RabbitMQ messages to an external store.
%% 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 rights and limitations
%% under the License.
%%
@jbrisbin
jbrisbin / rabbitmq_2.3.0_homebrew.diff
Created February 2, 2011 20:12
Diff to update local Homebrew formula for RabbitMQ to version 2.3.0
--- a/Library/Formula/rabbitmq.rb
+++ b/Library/Formula/rabbitmq.rb
@@ -2,8 +2,8 @@ require 'formula'
class Rabbitmq <Formula
homepage 'http://rabbitmq.com'
- url 'http://www.rabbitmq.com/releases/rabbitmq-server/v2.2.0/rabbitmq-server-2.2.0.tar.gz'
- md5 '65d0644aa4bf24398d13553b6aa6465f'
+ url 'http://www.rabbitmq.com/releases/rabbitmq-server/v2.3.0/rabbitmq-server-2.3.0.tar.gz'
+ md5 '71cc70b07f879cbd130b7a0a6cf35beb'
HTTP/1.1 200 OK
X-Riak-Vclock: a85hYGBgzGDKBVIsrB2/NTOYEhnzWBn4t3Ie58sCAA==
X-Riak-Meta-Test: header
Vary: Accept-Encoding
Server: MochiWeb/1.1 WebMachine/1.7.3 (participate in the frantic)
Link: </riak/riak>; rel="up"
Last-Modified: Fri, 01 Apr 2011 02:31:43 GMT
Etag: "Hy9r79iYjmwVewonL2Lc7"
Date: Fri, 01 Apr 2011 02:31:49 GMT
Content-Type: text/plain
@jbrisbin
jbrisbin / gist:1215194
Created September 13, 2011 21:12
StateMachine implementation for Java test code
@Test
public void testSimpleStateMachine() throws ExecutionException, InterruptedException {
final StateMachine m = new StateMachine("first");
m.on("first", new Handler<StringBuffer>() {
@Override public void handle(StringBuffer sb) {
sb.append("1");
m.state("second", sb);
}
});
m.on("second", new Handler<StringBuffer>() {
@jbrisbin
jbrisbin / gist:1292660
Created October 17, 2011 14:01
Error messages when compiling project that uses rebarized RabbitMQ libraries
./rebar compile
==> rabbit_common (compile)
Compiled src/gen_server2.erl
Compiled src/supervisor2.erl
Compiled src/rabbit_msg_store_index.erl
Compiled src/rabbit_exchange_type.erl
Compiled src/rabbit_backing_queue.erl
Compiled src/rabbit_auth_mechanism.erl
Compiled src/rabbit_auth_backend.erl
src/mirrored_supervisor.erl:126: Warning: conflicting behaviours - callback init/1 required by both 'supervisor2' and 'gen_server2' (line 125)
@jbrisbin
jbrisbin / gist:1444077
Created December 7, 2011 18:50
Reactor-based framework versus Node.js streaming

I've been hacking away recently at a JVM framework for doing asynchronous, non-blocking applications using a variation of the venerable Reactor pattern. The core of the framework is currently in Java. I started with Scala then went with Java and am now considering Scala again for the core. What can I say: I'm a grass-is-greener waffler! :) But it understands how to invoke Groovy Closures, Scala anonymous functions, and Clojure functions, so you can use the framework directly without needing wrappers.

I've been continually micro-benchmarking this framework because I feel that the JVM is a better foundation on which to build highly-concurrent, highly-scalable, C100K applications than V8 or Ruby. The problem has been, so far, no good tools exist for JVM developers to leverage the excellent performance and manageability of the JVM. This yet-to-be-publicly-released framework is an effort to give Java, Groovy, Scala, [X JVM language] developers access to an easy-to-use programming model that removes the necessity

@jbrisbin
jbrisbin / DisruptorTest.java
Created December 30, 2011 17:22
Disruptor RingBuffer-based simplistic NIO HTTP test server
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
@jbrisbin
jbrisbin / NioScalabilityTest.java
Created January 3, 2012 22:14
Pure Java NIO scalability test
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;