/** Hello header for HBase 0.90 and earlier. */ private ChannelBuffer header090() { final byte[] buf = new byte[4 + 1 + 4 + 2 + 29 + 2 + 48 + 2 + 47]; final ChannelBuffer header = commonHeader(buf, HRPC3); // 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). // First, we need the size of the whole damn UserGroupInformation thing. // We skip 4 bytes now and will set it to the actual size at the end. header.writerIndex(header.writerIndex() + 4); // 4 // Write the class name of the object. // See hadoop.io.ObjectWritable#writeObject // See hadoop.io.UTF8#writeString // String length as a short followed by UTF-8 string. String klass = "org.apache.hadoop.io.Writable"; header.writeShort(klass.length()); // 2 header.writeBytes(Bytes.ISO88591(klass)); // 29 klass = "org.apache.hadoop.io.ObjectWritable$NullInstance"; header.writeShort(klass.length()); // 2 header.writeBytes(Bytes.ISO88591(klass)); // 48 klass = "org.apache.hadoop.security.UserGroupInformation"; header.writeShort(klass.length()); // 2 header.writeBytes(Bytes.ISO88591(klass)); // 47 // Now set the length of the whole damn thing. // -4 because the length itself isn't part of the payload. // -5 because the "hrpc" + version isn't part of the payload. header.setInt(5, header.writerIndex() - 4 - 5); return header; }
/** Hello header for HBase 0.92 to 0.94. */ private ChannelBuffer header092() { final byte[] buf = new byte[4 + 1 + 4 + 1 + 44]; final ChannelBuffer header = commonHeader(buf, HRPC3); // Serialized ipc.ConnectionHeader // We skip 4 bytes now and will set it to the actual size at the end. header.writerIndex(header.writerIndex() + 4); // 4 final String klass = "org.apache.hadoop.hbase.ipc.HRegionInterface"; header.writeByte(klass.length()); // 1 header.writeBytes(Bytes.ISO88591(klass)); // 44 // Now set the length of the whole damn thing. // -4 because the length itself isn't part of the payload. // -5 because the "hrpc" + version isn't part of the payload. header.setInt(5, header.writerIndex() - 4 - 5); return header; }