org.apache.bookkeeper.client
Class BookieHandle

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.bookkeeper.client.BookieHandle
All Implemented Interfaces:
Runnable

public class BookieHandle
extends Thread

Maintains a queue of request to a given bookie. For verifiable ledgers, it computes the digest.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
 int halt()
          Halt this bookie handle independent of the number of ledgers using it.
 void run()
           
 void sendAdd(LedgerHandle lh, QuorumEngine.SubOp.SubAddOp r, long entry)
          Sending add operation to bookie.
 void sendRead(LedgerHandle lh, QuorumEngine.SubOp.SubReadOp r, long entry)
          Sending read operation to bookie
 void shutdown()
          Stop this bookie handle completely.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

sendAdd

public void sendAdd(LedgerHandle lh,
                    QuorumEngine.SubOp.SubAddOp r,
                    long entry)
             throws IOException,
                    BKException
Sending add operation to bookie. We have to synchronize the send to guarantee that requests will either get a response or throw an exception.

Parameters:
r -
cb -
ctx -
Throws:
IOException
BKException

sendRead

public void sendRead(LedgerHandle lh,
                     QuorumEngine.SubOp.SubReadOp r,
                     long entry)
              throws IOException,
                     BKException
Sending read operation to bookie

Parameters:
r -
entry -
cb -
ctx -
Throws:
IOException
BKException

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

halt

public int halt()
Halt this bookie handle independent of the number of ledgers using it. Called upon a failure to write. This method cannot be called by this thread because it may cause a deadlock as shutdown invokes sendStop. The deadlock comes from sendAdd blocking on incomingQueue when the queue is full and the thread also blocking on it when trying to send the stop marker. Because this thread is actually the consumer, if it does not make progress, then we have a deadlock.

Returns:
int reference counter

shutdown

public void shutdown()
Stop this bookie handle completely.