Stateful handler that manages a connection to a specific RegionServer. This handler manages the RPC IDs, the serialization and de-serialization of RPC requests and responses, and keeps track of the RPC in flights for which a response is currently awaited, as well as temporarily buffered RPCs tha
| 86 | * channel isn't connected. |
| 87 | */ |
| 88 | final class RegionClient extends ReplayingDecoder<VoidEnum> { |
| 89 | |
| 90 | private static final Logger LOG = LoggerFactory.getLogger(RegionClient.class); |
| 91 | |
| 92 | /** Maps remote exception types to our corresponding types. */ |
| 93 | private static final HashMap<String, HBaseException> REMOTE_EXCEPTION_TYPES; |
| 94 | static { |
| 95 | REMOTE_EXCEPTION_TYPES = new HashMap<String, HBaseException>(); |
| 96 | REMOTE_EXCEPTION_TYPES.put(NoSuchColumnFamilyException.REMOTE_CLASS, |
| 97 | new NoSuchColumnFamilyException(null, null)); |
| 98 | REMOTE_EXCEPTION_TYPES.put(NotServingRegionException.REMOTE_CLASS, |
| 99 | new NotServingRegionException(null, null)); |
| 100 | REMOTE_EXCEPTION_TYPES.put(RegionMovedException.REMOTE_CLASS, |
| 101 | new RegionMovedException(null, null)); |
| 102 | REMOTE_EXCEPTION_TYPES.put(RegionOpeningException.REMOTE_CLASS, |
| 103 | new RegionOpeningException(null, null)); |
| 104 | REMOTE_EXCEPTION_TYPES.put(RegionServerAbortedException.REMOTE_CLASS, |
| 105 | new RegionServerAbortedException(null, null)); |
| 106 | REMOTE_EXCEPTION_TYPES.put(RegionServerStoppedException.REMOTE_CLASS, |
| 107 | new RegionServerStoppedException(null, null)); |
| 108 | REMOTE_EXCEPTION_TYPES.put(RegionTooBusyException.REMOTE_CLASS, |
| 109 | new RegionTooBusyException(null, null)); |
| 110 | REMOTE_EXCEPTION_TYPES.put(ServerNotRunningYetException.REMOTE_CLASS, |
| 111 | new ServerNotRunningYetException(null, null)); |
| 112 | REMOTE_EXCEPTION_TYPES.put(UnknownScannerException.REMOTE_CLASS, |
| 113 | new UnknownScannerException(null, null)); |
| 114 | REMOTE_EXCEPTION_TYPES.put(UnknownRowLockException.REMOTE_CLASS, |
| 115 | new UnknownRowLockException(null, null)); |
| 116 | REMOTE_EXCEPTION_TYPES.put(VersionMismatchException.REMOTE_CLASS, |
| 117 | new VersionMismatchException(null, null)); |
| 118 | REMOTE_EXCEPTION_TYPES.put(CallQueueTooBigException.REMOTE_CLASS, |
| 119 | new CallQueueTooBigException(null, null)); |
| 120 | REMOTE_EXCEPTION_TYPES.put(UnknownProtocolException.REMOTE_CLASS, |
| 121 | new UnknownProtocolException(null, null)); |
| 122 | } |
| 123 | |
| 124 | /** We don't know the RPC protocol version of the server yet. */ |
| 125 | private static final byte SERVER_VERSION_UNKNWON = 0; |
| 126 | |
| 127 | /** Protocol version we pretend to use for HBase 0.90 and before. */ |
| 128 | static final byte SERVER_VERSION_090_AND_BEFORE = 24; |
| 129 | |
| 130 | /** We know at that the server runs 0.92 to 0.94. */ |
| 131 | static final byte SERVER_VERSION_092_OR_ABOVE = 29; |
| 132 | |
| 133 | /** |
| 134 | * This is a made-up value for HBase 0.95 and above. |
| 135 | * As of 0.95 there is no longer a protocol version, because everything |
| 136 | * switched to Protocol Buffers. Internally we use this made-up value |
| 137 | * to refer to the post-protobuf era. |
| 138 | */ |
| 139 | static final byte SERVER_VERSION_095_OR_ABOVE = 95; |
| 140 | |
| 141 | /** The HBase client we belong to. */ |
| 142 | private final HBaseClient hbase_client; |
| 143 | |
| 144 | /** Whether or not to check the channel write status before sending RPCs */ |
| 145 | private final boolean check_write_status; |