org.apache.hadoop.hbase.ipc
Class RpcClient.Connection
java.lang.Object
java.lang.Thread
org.apache.hadoop.hbase.ipc.RpcClient.Connection
- All Implemented Interfaces:
- Runnable
- Enclosing class:
- RpcClient
protected class RpcClient.Connection
- extends Thread
Thread that reads responses and notifies callers. Each connection owns a
socket connected to a remote address. Calls are multiplexed through this
socket: responses may be delivered out of order.
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 |
remoteId
protected RpcClient.ConnectionId remoteId
socket
protected Socket socket
in
protected DataInputStream in
out
protected DataOutputStream out
calls
protected final ConcurrentSkipListMap<Integer,RpcClient.Call> calls
lastActivity
protected final AtomicLong lastActivity
shouldCloseConnection
protected final AtomicBoolean shouldCloseConnection
closeException
protected IOException closeException
touch
protected void touch()
- Update lastActivity with the current time.
addCall
protected void addCall(RpcClient.Call call)
- Add a call to this connection's call queue and notify
a listener; synchronized. If the connection is dead, the call is not added, and the
caller is notified.
This function can return a connection that is already marked as 'shouldCloseConnection'
It is up to the user code to check this status.
- Parameters:
call
- to add
setupConnection
protected void setupConnection()
throws IOException
- Throws:
IOException
closeConnection
protected void closeConnection()
waitForWork
protected boolean waitForWork()
getRemoteAddress
public InetSocketAddress getRemoteAddress()
sendPing
protected void sendPing()
throws IOException
- Throws:
IOException
run
public void run()
- Specified by:
run
in interface Runnable
- Overrides:
run
in class Thread
setupIOstreams
protected void setupIOstreams()
throws IOException,
InterruptedException
- Throws:
IOException
InterruptedException
close
protected void close()
- Close the connection.
writeRequest
protected void writeRequest(RpcClient.Call call,
int priority)
- Initiates a call by sending the parameter to the remote server.
Note: this is not called from the Connection thread, but by other
threads.
- Parameters:
call
- priority
- - See Also:
readResponse()
readResponse
protected void readResponse()
markClosed
protected void markClosed(IOException e)
cleanupCalls
protected void cleanupCalls()
cleanupCalls
protected void cleanupCalls(long rpcTimeout)
Copyright © 2015 The Apache Software Foundation. All Rights Reserved.