Serializes the given protobuf object into a Netty ChannelBuffer. @param method The name of the method of the RPC we're going to send. @param pb The protobuf to serialize. @return A new channel buffer containing the serialized protobuf, with enough free space at the beginning to tack on the R
(final byte[] method,
final AbstractMessageLite pb)
| 922 | * enough free space at the beginning to tack on the RPC header. |
| 923 | */ |
| 924 | static final ChannelBuffer toChannelBuffer(final byte[] method, |
| 925 | final AbstractMessageLite pb) { |
| 926 | final int pblen = pb.getSerializedSize(); |
| 927 | final int vlen = CodedOutputStream.computeRawVarint32Size(pblen); |
| 928 | final byte[] buf = new byte[4 + 19 + method.length + vlen + pblen]; |
| 929 | try { |
| 930 | final CodedOutputStream out = CodedOutputStream.newInstance(buf, 4 + 19 + method.length, |
| 931 | vlen + pblen); |
| 932 | out.writeRawVarint32(pblen); |
| 933 | pb.writeTo(out); |
| 934 | out.checkNoSpaceLeft(); |
| 935 | } catch (IOException e) { |
| 936 | throw new RuntimeException("Should never happen", e); |
| 937 | } |
| 938 | return ChannelBuffers.wrappedBuffer(buf); |
| 939 | } |
| 940 | |
| 941 | /** |
| 942 | * Writes a {@link Boolean boolean} as an HBase RPC parameter. |
no outgoing calls
no test coverage detected