org.apache.flume
Interface Transaction

All Known Implementing Classes:
BasicTransactionSemantics, JdbcTransactionImpl, PseudoTxnMemoryChannel.NoOpTransaction

public interface Transaction

Provides the transaction boundary while accessing a channel.

A Transaction instance is used to encompass channel access via the following idiom:


 Channel ch = ...
 Transaction tx = ch.getTransaction();
 try {
   tx.begin();
   ...
   // ch.put(event) or ch.take()
   ...
   tx.commit();
 } catch (ChannelException ex) {
   tx.rollback();
   ...
 } finally {
   tx.close();
 }
 

Depending upon the implementation of the channel, the transaction semantics may be strong, or best-effort only.

Transactions must be thread safe. To provide a guarantee of thread safe access to Transactions, see BasicChannelSemantics and BasicTransactionSemantics.

See Also:
Channel

Nested Class Summary
static class Transaction.TransactionState
           
 
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.
 void rollback()
          Indicates that the transaction can must be aborted.
 

Method Detail

begin

void begin()

Starts 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 close() method. Failure to ensure this can lead to dangling transactions and unpredictable results.


commit

void commit()
Indicates that the transaction can be successfully committed. It is required that a transaction be in progress when this method is invoked.


rollback

void rollback()
Indicates that the transaction can must be aborted. It is required that a transaction be in progress when this method is invoked.


close

void close()

Ends 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 begin() method. Failure to ensure this can lead to dangling transactions and unpredictable results.



Copyright © 2009-2013 Apache Software Foundation. All Rights Reserved.