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

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.hadoop.hbase.ipc.HBaseClient.Connection
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
SecureClient.SecureConnection
Enclosing class:
HBaseClient

protected class HBaseClient.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 HBaseClient.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,HBaseClient.Call> calls
           
protected  IOException closeException
           
protected  DataInputStream in
           
protected  AtomicLong lastActivity
           
protected  DataOutputStream out
           
protected  HBaseClient.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(HBaseClient.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 receiveResponse()
           
 void run()
           
protected  void sendParam(HBaseClient.Call call)
           
protected  void sendPing()
           
protected  void setupConnection()
           
protected  void setupIOstreams()
          Connect to the server and set up the I/O streams.
protected  void touch()
          Update lastActivity with the current time.
protected  boolean waitForWork()
           
 
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 HBaseClient.ConnectionId remoteId

socket

protected Socket socket

in

protected DataInputStream in

out

protected DataOutputStream out

calls

protected final ConcurrentSkipListMap<Integer,HBaseClient.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(HBaseClient.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

setupIOstreams

protected void setupIOstreams()
                       throws IOException,
                              InterruptedException
Connect to the server and set up the I/O streams. It then sends a header to the server and starts the connection thread that waits for responses.

Throws:
IOException - e
InterruptedException

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

sendParam

protected void sendParam(HBaseClient.Call call)

receiveResponse

protected void receiveResponse()

markClosed

protected void markClosed(IOException e)

close

protected void close()
Close the connection.


cleanupCalls

protected void cleanupCalls()

cleanupCalls

protected void cleanupCalls(long rpcTimeout)


Copyright © 2015 The Apache Software Foundation. All Rights Reserved.