Skip to content

Instantly share code, notes, and snippets.

@tsuna
Created January 28, 2011 01:36
Show Gist options
  • Save tsuna/799658 to your computer and use it in GitHub Desktop.
Save tsuna/799658 to your computer and use it in GitHub Desktop.
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
on-wire serialization of Get in a non-backwards compatible way.
Ultimately hbaseasync should be able to work around that by using
the `getProtocolVersion' RPC to automagically figure this out and
do the right thing.
Change-Id: Ic3ee9f1ae350529c0968ddb489667a0f3ffb2d2c
---
src/GetRequest.java | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/GetRequest.java b/src/GetRequest.java
index 6d9a656..9f965da 100644
--- a/src/GetRequest.java
+++ b/src/GetRequest.java
@@ -39,6 +39,16 @@ import org.jboss.netty.buffer.ChannelBuffer;
*/
public final class GetRequest extends HBaseRpc {
+ /**
+ * Are we going to talk to HBase 0.90?.
+ * For HBASE-3174, revision r1029115 (or 08e64aae in Git) changed the
+ * on-wire serialization of Get in a non-backwards compatible way.
+ * TODO(tsuna): Use the getProtocolVersion RPC to automagically figure
+ * this out and do the right thing.
+ */
+ private static final boolean hbase090 =
+ System.getProperty("org.hbase.async.v0.90") != null;
+
private static final byte[] GET = new byte[] { 'g', 'e', 't' };
private static final byte[] EXISTS =
new byte[] { 'e', 'x', 'i', 's', 't', 's' };
@@ -163,6 +173,9 @@ public final class GetRequest extends HBaseRpc {
size += 8; // long: Lock ID.
size += 4; // int: Max number of versions to return.
size += 1; // byte: Whether or not to use a filter.
+ if (hbase090) {
+ size += 1; // byte: Whether or not to cache the blocks read.
+ }
size += 8; // long: Minimum timestamp.
size += 8; // long: Maximum timestamp.
size += 1; // byte: Boolean: "all time".
@@ -196,6 +209,9 @@ public final class GetRequest extends HBaseRpc {
buf.writeLong(lockid); // Lock ID.
buf.writeInt(1); // Max number of versions to return.
buf.writeByte(0x00); // boolean (false): whether or not to use a filter.
+ if (hbase090) {
+ buf.writeByte(0x01); // boolean (true): whether or not to cache the blocks.
+ }
// If the previous boolean was true:
// writeByteArray(buf, filter name as byte array);
// write the filter itself
--
1.7.4.rc1.8.g429be
@tsuna
Copy link
Author

tsuna commented Jan 28, 2011

git clone git://github.com/stumbleupon/asynchbase.git
cd asynchbase
curl https://gist.github.com/raw/799658/6019df10a98f9e841a50d3f245291c394c450532/0001-Add-support-for-HBase-0.90.patch | git am -
make

Then simply copy build/hbaseasync-1.0.jar into the third_party/hbase directory of OpenTSDB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment