| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.flume.channel.BasicTransactionSemantics
public abstract class BasicTransactionSemantics
 An implementation of basic Transaction semantics designed
 to work in concert with BasicChannelSemantics to simplify
 creation of robust Channel implementations.  This class
 ensures that each transaction implementation method is called only
 while the transaction is in the correct state for that method, and
 only by the thread that created the transaction.  Nested calls to
 begin() and close() are supported as long
 as they are balanced.
 
 Subclasses need only implement doPut,
 doTake, doCommit, and
 doRollback, and the developer can rest assured that
 those methods are called only after transaction state preconditions
 have been properly met.  doBegin and
 doClose may also be implemented if there is work to be
 done at those points.
 
 All InterruptedException exceptions thrown from the implementations
 of the doXXX methods are automatically wrapped to
 become ChannelExceptions, but only after restoring the interrupted
 status of the thread so that any subsequent blocking method calls
 will themselves throw InterruptedException rather than blocking.
 The exception to this rule is doTake, which simply
 returns null instead of wrapping and propagating the
 InterruptedException, though it still first restores the
 interrupted status of the thread.
 
| Nested Class Summary | |
|---|---|
| protected static class | BasicTransactionSemantics.StateThe state of the Transactionto which it belongs. | 
| Nested classes/interfaces inherited from interface org.apache.flume.Transaction | 
|---|
| Transaction.TransactionState | 
| Constructor Summary | |
|---|---|
| protected  | BasicTransactionSemantics() | 
| Method Summary | |
|---|---|
|  void | begin()Starts a transaction boundary for the current channel operation. | 
|  void | close()Ends a transaction boundary for the current channel operation. | 
|  void | commit()Indicates that the transaction can be successfully committed. | 
| protected  void | doBegin() | 
| protected  void | doClose() | 
| protected abstract  void | doCommit() | 
| protected abstract  void | doPut(Event event) | 
| protected abstract  void | doRollback() | 
| protected abstract  Event | doTake() | 
| protected  BasicTransactionSemantics.State | getState() | 
| protected  void | put(Event event)The method to which BasicChannelSemanticsdelegates calls
 toput. | 
|  void | rollback()Indicates that the transaction can must be aborted. | 
| protected  Event | take()The method to which BasicChannelSemanticsdelegates calls
 totake. | 
|  String | toString() | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
|---|
protected BasicTransactionSemantics()
| Method Detail | 
|---|
protected void doBegin()
                throws InterruptedException
InterruptedException
protected abstract void doPut(Event event)
                       throws InterruptedException
InterruptedException
protected abstract Event doTake()
                         throws InterruptedException
InterruptedException
protected abstract void doCommit()
                          throws InterruptedException
InterruptedException
protected abstract void doRollback()
                            throws InterruptedException
InterruptedExceptionprotected void doClose()
protected void put(Event event)
 The method to which BasicChannelSemantics delegates calls
 to put.
 
protected Event take()
 The method to which BasicChannelSemantics delegates calls
 to take.
 
protected BasicTransactionSemantics.State getState()
public void begin()
TransactionStarts a transaction boundary for the current channel operation. If a transaction is already in progress, this method will join that transaction using reference counting.
Note: For every invocation of this method there must be a corresponding invocation of Transaction.close() method. Failure to ensure this can lead to dangling transactions and unpredictable results.
begin in interface Transactionpublic void commit()
Transaction
commit in interface Transactionpublic void rollback()
Transaction
rollback in interface Transactionpublic void close()
TransactionEnds a transaction boundary for the current channel operation. If a transaction is already in progress, this method will join that transaction using reference counting. The transaction is completed only if there are no more references left for this transaction.
Note: For every invocation of this method there must be a corresponding invocation of Transaction.begin() method. Failure to ensure this can lead to dangling transactions and unpredictable results.
close in interface Transactionpublic String toString()
toString in class Object| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||