Package org.apache.hadoop.hbase.ipc
Class BlockingRpcConnection.CallSender
java.lang.Object
java.lang.Thread
org.apache.hadoop.hbase.ipc.BlockingRpcConnection.CallSender
- All Implemented Interfaces:
Runnable
- Enclosing class:
- BlockingRpcConnection
If the client wants to interrupt its calls easily (i.e. call Thread#interrupt), it gets into a
java issue: an interruption during a write closes the socket/channel. A way to avoid this is to
use a different thread for writing. This way, on interruptions, we either cancel the writes or
ignore the answer if the write is already done, but we don't stop the write in the middle. This
adds a thread per region server in the client, so it's kept as an option.
The implementation is simple: the client threads adds their call to the queue, and then wait for an answer. The CallSender blocks on the queue, and writes the calls one after the other. On interruption, the client cancels its call. The CallSender checks that the call has not been canceled before writing it.
When the connection closes, all the calls not yet sent are dismissed. The client thread is notified with an appropriate exception, as if the call was already sent but the answer not yet received.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Modifier and TypeFieldDescriptionprivate final int
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
-
Method Summary
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
-
Field Details
-
callsToWrite
-
maxQueueSize
-
-
Constructor Details
-
CallSender
-
-
Method Details
-
sendCall
- Throws:
IOException
-
remove
-
run
Reads the call from the queue, write them on the socket. -
cleanup
Cleans the call not yet sent when we finish.
-