MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / deserialize

Method deserialize

src/RegionClient.java:1608–1647  ·  view source on GitHub ↗

De-serializes an RPC response. @param buf The buffer from which to de-serialize the response. @param rpc The RPC for which we're de-serializing the response. @return The de-serialized RPC response (which can be null or an exception).

(final ChannelBuffer buf, final HBaseRpc rpc)

Source from the content-addressed store, hash-verified

1606 * or an exception).
1607 */
1608 private Object deserialize(final ChannelBuffer buf, final HBaseRpc rpc) {
1609 // The 1st byte of the payload contains flags:
1610 // 0x00 Old style success (prior 0.92).
1611 // 0x01 RPC failed with an exception.
1612 // 0x02 New style success (0.92 and above).
1613 final int flags;
1614 if (secure_rpc_helper != null) {
1615 //0.94-security uses an int for the flag section
1616 flags = buf.readInt();
1617 } else {
1618 flags = buf.readByte();
1619 }
1620 if ((flags & HBaseRpc.RPC_FRAMED) != 0) {
1621 // Total size of the response, including the RPC ID (4 bytes) and flags
1622 // (1 byte) that we've already read, including the 4 bytes used by
1623 // the length itself, and including the 4 bytes used for the RPC status.
1624 final int length = buf.readInt() - 4 - 1 - 4 - 4;
1625 final int status = buf.readInt(); // Unused right now.
1626 try {
1627 HBaseRpc.checkArrayLength(buf, length);
1628 // Make sure we have that many bytes readable.
1629 // This will have to change to be able to do streaming RPCs where we
1630 // deserialize parts of the response as it comes off the wire.
1631 ensureReadable(buf, length);
1632 } catch (IllegalArgumentException e) {
1633 LOG.error("WTF? RPC #" + rpcid + ": ", e);
1634 }
1635 } else {
1636 LOG.info("RPC wasn't framed: " + rpc);
1637 }
1638
1639 if ((flags & HBaseRpc.RPC_ERROR) != 0) {
1640 return deserializeException(buf, rpc);
1641 }
1642 try {
1643 return deserializeObject(buf, rpc);
1644 } catch (IllegalArgumentException e) { // The RPC didn't look good to us.
1645 return new InvalidResponseException(e.getMessage(), e);
1646 }
1647 }
1648
1649 /**
1650 * Consumes a pre-protobuf RPC from HBase that has been timed out.

Callers 1

decodeMethod · 0.95

Calls 5

checkArrayLengthMethod · 0.95
ensureReadableMethod · 0.95
deserializeExceptionMethod · 0.95
deserializeObjectMethod · 0.95
getMessageMethod · 0.45

Tested by

no test coverage detected