Guest User

Untitled

a guest
Jul 20th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. From fd1d76efba48269aaec80e90f629f01ba4581fed Mon Sep 17 00:00:00 2001
  2. From: Benoit Sigoure <tsuna@stumbleupon.com>
  3. Date: Tue, 18 Jan 2011 00:21:20 -0800
  4. Subject: [PATCH] Add support for CDHb3.
  5.  
  6. This change adds support for CDHb3. In order to enable the new code,
  7. the JVM must be given the following system property in argument:
  8. -Dorg.hbase.async.cdhb3
  9.  
  10. CDHb3 includes a temporary patch that changes the format of the "hello"
  11. header that clients must send when they connect. The change is not
  12. backwards compatible and results in clients getting disconnected as
  13. soon as they send the header, because the HBase RPC protocol provides no
  14. mechanism to send an error message back to the client during the initial
  15. "hello" stage. Thus, older clients will never be able to get past the
  16. initial -ROOT- lookup.
  17.  
  18. For reference, the patch I'm referring to is:
  19. 74542880d740e9be24b103f1d5f5c6489d01911c
  20. CLOUDERA-BUILD. HBase running on secure hadoop, temporary patch.
  21.  
  22. This is not upstreamed, since it currently is very difficult to do this
  23. without reflection or a shim layer. This will be upstreamed with the
  24. larger project of HBase security later this year.
  25.  
  26. Change-Id: I421e89447e3b55b3000e4ebc486bc90abcbb7076
  27. ---
  28. src/RegionClient.java | 29 ++++++++++++++++++++++++++++-
  29. 1 files changed, 28 insertions(+), 1 deletions(-)
  30.  
  31. diff --git a/src/RegionClient.java b/src/RegionClient.java
  32. index be696b3..dcbf5a7 100644
  33. --- a/src/RegionClient.java
  34. +++ b/src/RegionClient.java
  35. @@ -1258,7 +1258,17 @@ final class RegionClient extends ReplayingDecoder<VoidEnum> {
  36. /** The header to send. */
  37. private static final byte[] HELLO_HEADER;
  38. static {
  39. - HELLO_HEADER = new byte[4 + 1 + 4 + 2 + 29 + 2 + 48 + 2 + 47];
  40. + if (System.getProperty("org.hbase.async.cdhb3") != null) {
  41. + final byte[] user = Bytes.UTF8(System.getProperty("user.name", "hbaseasync"));
  42. + HELLO_HEADER = new byte[4 + 1 + 4 + 4 + user.length];
  43. + headerCDHb3(user);
  44. + } else {
  45. + HELLO_HEADER = new byte[4 + 1 + 4 + 2 + 29 + 2 + 48 + 2 + 47];
  46. + header089();
  47. + }
  48. + }
  49. +
  50. + private static ChannelBuffer commonHeader() {
  51. final ChannelBuffer buf = ChannelBuffers.wrappedBuffer(HELLO_HEADER);
  52. buf.clear(); // Set the writerIndex to 0.
  53.  
  54. @@ -1266,6 +1276,12 @@ final class RegionClient extends ReplayingDecoder<VoidEnum> {
  55. // "hrpc" followed by the version (3).
  56. // See HBaseServer#HEADER and HBaseServer#CURRENT_VERSION.
  57. buf.writeBytes(new byte[] { 'h', 'r', 'p', 'c', 3 }); // 4 + 1
  58. + return buf;
  59. + }
  60. +
  61. + private static void header089() {
  62. + final ChannelBuffer buf = commonHeader();
  63. +
  64. // Serialized UserGroupInformation to say who we are.
  65. // We're not nice so we're not gonna say who we are and we'll just send
  66. // `null' (hadoop.io.ObjectWritable$NullInstance).
  67. @@ -1292,6 +1308,17 @@ final class RegionClient extends ReplayingDecoder<VoidEnum> {
  68. buf.setInt(5, buf.writerIndex() - 4 - 5);
  69. }
  70.  
  71. + private static void headerCDHb3(final byte[] user) {
  72. + // Our username.
  73. + final ChannelBuffer buf = commonHeader();
  74. +
  75. + // Length of the encoded string (useless).
  76. + buf.writeInt(4 + user.length); // 4
  77. + // String as encoded by `WritableUtils.writeString'.
  78. + buf.writeInt(user.length); // 4
  79. + buf.writeBytes(user); // length bytes
  80. + }
  81. +
  82. private SayHelloFirstRpc() { // Singleton, can't instantiate from outside.
  83. }
  84.  
  85. --
  86. 1.7.4.rc1.8.g429be
Add Comment
Please, Sign In to add comment