org.apache.hadoop.hbase.ipc
Class RpcClient.Connection

java.lang.Object
  extended by java.lang.Thread
      extended by 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.


Nested Class Summary
protected  class RpcClient.Connection.PingInputStream
          This class sends a ping to the remote side when timeout on reading.
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  ConcurrentSkipListMap<Integer,RpcClient.Call> calls
           
protected  IOException closeException
           
protected  DataInputStream in
           
protected  AtomicLong lastActivity
           
protected  DataOutputStream out
           
protected  RpcClient.ConnectionId remoteId
           
protected  AtomicBoolean shouldCloseConnection
           
protected  Socket socket
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
protected  void addCall(RpcClient.Call call)
          Add a call to this connection's call queue and notify a listener; synchronized.
protected  void cleanupCalls()
           
protected  void cleanupCalls(long rpcTimeout)
           
protected  void close()
          Close the connection.
protected  void closeConnection()
           
 InetSocketAddress getRemoteAddress()
           
protected  void markClosed(IOException e)
           
protected  void readResponse()
           
 void run()
           
protected  void sendPing()
           
protected  void setupConnection()
           
protected  void setupIOstreams()
           
protected  void touch()
          Update lastActivity with the current time.
protected  boolean waitForWork()
           
protected  void writeRequest(RpcClient.Call call, int priority)
          Initiates a call by sending the parameter to the remote server.
 
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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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
Method Detail

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.