Created
January 18, 2011 08:28
-
-
Save tsuna/784136 to your computer and use it in GitHub Desktop.
Add support for CDHb3 in asynchbase.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From fd1d76efba48269aaec80e90f629f01ba4581fed Mon Sep 17 00:00:00 2001 | |
From: Benoit Sigoure <[email protected]> | |
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" | |
header that clients must send when they connect. The change is not | |
backwards compatible and results in clients getting disconnected as | |
soon as they send the header, because the HBase RPC protocol provides no | |
mechanism to send an error message back to the client during the initial | |
"hello" stage. Thus, older clients will never be able to get past the | |
initial -ROOT- lookup. | |
For reference, the patch I'm referring to is: | |
74542880d740e9be24b103f1d5f5c6489d01911c | |
CLOUDERA-BUILD. HBase running on secure hadoop, temporary patch. | |
This is not upstreamed, since it currently is very difficult to do this | |
without reflection or a shim layer. This will be upstreamed with the | |
larger project of HBase security later this year. | |
Change-Id: I421e89447e3b55b3000e4ebc486bc90abcbb7076 | |
--- | |
src/RegionClient.java | 29 ++++++++++++++++++++++++++++- | |
1 files changed, 28 insertions(+), 1 deletions(-) | |
diff --git a/src/RegionClient.java b/src/RegionClient.java | |
index be696b3..dcbf5a7 100644 | |
--- a/src/RegionClient.java | |
+++ b/src/RegionClient.java | |
@@ -1258,7 +1258,17 @@ final class RegionClient extends ReplayingDecoder<VoidEnum> { | |
/** The header to send. */ | |
private static final byte[] HELLO_HEADER; | |
static { | |
- HELLO_HEADER = new byte[4 + 1 + 4 + 2 + 29 + 2 + 48 + 2 + 47]; | |
+ if (System.getProperty("org.hbase.async.cdhb3") != null) { | |
+ final byte[] user = Bytes.UTF8(System.getProperty("user.name", "hbaseasync")); | |
+ HELLO_HEADER = new byte[4 + 1 + 4 + 4 + user.length]; | |
+ headerCDHb3(user); | |
+ } else { | |
+ HELLO_HEADER = new byte[4 + 1 + 4 + 2 + 29 + 2 + 48 + 2 + 47]; | |
+ header089(); | |
+ } | |
+ } | |
+ | |
+ private static ChannelBuffer commonHeader() { | |
final ChannelBuffer buf = ChannelBuffers.wrappedBuffer(HELLO_HEADER); | |
buf.clear(); // Set the writerIndex to 0. | |
@@ -1266,6 +1276,12 @@ final class RegionClient extends ReplayingDecoder<VoidEnum> { | |
// "hrpc" followed by the version (3). | |
// See HBaseServer#HEADER and HBaseServer#CURRENT_VERSION. | |
buf.writeBytes(new byte[] { 'h', 'r', 'p', 'c', 3 }); // 4 + 1 | |
+ return buf; | |
+ } | |
+ | |
+ private static void header089() { | |
+ final ChannelBuffer buf = commonHeader(); | |
+ | |
// Serialized UserGroupInformation to say who we are. | |
// We're not nice so we're not gonna say who we are and we'll just send | |
// `null' (hadoop.io.ObjectWritable$NullInstance). | |
@@ -1292,6 +1308,17 @@ final class RegionClient extends ReplayingDecoder<VoidEnum> { | |
buf.setInt(5, buf.writerIndex() - 4 - 5); | |
} | |
+ private static void headerCDHb3(final byte[] user) { | |
+ // Our username. | |
+ final ChannelBuffer buf = commonHeader(); | |
+ | |
+ // Length of the encoded string (useless). | |
+ buf.writeInt(4 + user.length); // 4 | |
+ // String as encoded by `WritableUtils.writeString'. | |
+ buf.writeInt(user.length); // 4 | |
+ buf.writeBytes(user); // length bytes | |
+ } | |
+ | |
private SayHelloFirstRpc() { // Singleton, can't instantiate from outside. | |
} | |
-- | |
1.7.4.rc1.8.g429be |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then simply copy
build/hbaseasync-1.0.jar
into thethird_party/hbase
directory of OpenTSDB.