xorp

TransactionManager Class Reference

A class for managing transactions. More...

#include <transaction.hh>

Inheritance diagram for TransactionManager:
FibConfigTransactionManager FirewallTransactionManager IfConfigTransactionManager

List of all members.

Classes

class  Transaction
 Transaction class, just a list of operations to be dispatched. More...

Public Types

typedef ref_ptr
< TransactionOperation
Operation

Public Member Functions

 TransactionManager (EventLoop &e, uint32_t timeout_ms=0, uint32_t max_pending=10)
 Constuctor with a given event loop, timeout, and max pending commits.
virtual ~TransactionManager ()
 Destructor.
bool start (uint32_t &new_tid)
 Start transaction.
bool commit (uint32_t tid)
 Commit transaction.
bool abort (uint32_t tid)
 Abort transaction.
virtual bool add (uint32_t tid, const Operation &op)
 Add operation to transaction.
bool retrieve_size (uint32_t tid, uint32_t &count) const
 Retrieve number of operations in pending transaction.
uint32_t timeout_ms () const
 Get the inter-operation additional timeout.
uint32_t max_pending () const
 Get the maximum number of uncommited pending transactions.
uint32_t pending () const
 Get the current number of uncommited pending transactions.

Protected Member Functions

virtual void pre_commit (uint32_t tid)
 Overrideable function that can be called before the first operation in a commit is dispatched.
virtual void post_commit (uint32_t tid)
 Overrideable function that can be called after commit occurs.
virtual void operation_result (bool success, const TransactionOperation &op)
 Overrideable function that is called immediately after an individual operation is dispatched.
bool flush (uint32_t tid)
 Flush operations in transaction list.

Private Types

typedef map< uint32_t,
Transaction
TransactionDB

Private Member Functions

void timeout (uint32_t tid)
 Called when timeout timer expires.
void crank_tid ()
 Increment next transaction id by a randomized amount.

Private Attributes

EventLoop_e
TransactionDB _transactions
uint32_t _timeout_ms
uint32_t _max_pending
uint32_t _next_tid

Friends

class Transaction

Detailed Description

A class for managing transactions.

The TransactionManager creates, manages, and dispatches transactions. A Transaction is comprised of a sequence of TransactionOperation s. Each transaction is uniquely identified by a transaction id.


Constructor & Destructor Documentation

TransactionManager::TransactionManager ( EventLoop e,
uint32_t  timeout_ms = 0,
uint32_t  max_pending = 10 
) [inline]

Constuctor with a given event loop, timeout, and max pending commits.

Parameters:
ethe EventLoop instance.
timeout_msthe inter-operation addition timeout. If zero, timeouts are not used, otherwise a timeout will occur and the transaction aborted if the transaction is not updated for timeout_ms.
max_pendingthe maximum number of uncommitted transactions pending commit.

Member Function Documentation

bool TransactionManager::abort ( uint32_t  tid)

Abort transaction.

Parameters:
tidthe transaction ID.
Returns:
true on success, false on error.
bool TransactionManager::add ( uint32_t  tid,
const Operation op 
) [virtual]

Add operation to transaction.

Parameters:
tidthe transaction ID.
operationto be added.
Returns:
true on success, false if tid is invalid.
bool TransactionManager::commit ( uint32_t  tid)

Commit transaction.

Parameters:
tidthe transaction ID.
Returns:
true on success, false on error.
void TransactionManager::crank_tid ( ) [private]

Increment next transaction id by a randomized amount.

bool TransactionManager::flush ( uint32_t  tid) [protected]

Flush operations in transaction list.

May be use by operation_result methods to safely prevent further operations being dispatched when errors are detected. flush() always succeeds if transaction exists.

Parameters:
tidtransaction id of transaction to be flushed.
Returns:
true if transaction exists, false otherwise.
uint32_t TransactionManager::max_pending ( ) const [inline]

Get the maximum number of uncommited pending transactions.

Returns:
the maximum number of uncommitted transactions pending commit.
void TransactionManager::operation_result ( bool  success,
const TransactionOperation op 
) [protected, virtual]

Overrideable function that is called immediately after an individual operation is dispatched.

Default implementation is a no-op.

Parameters:
successwhether the operation succeed.
opthe operation.

Reimplemented in FibConfigTransactionManager, FirewallTransactionManager, and IfConfigTransactionManager.

uint32_t TransactionManager::pending ( ) const [inline]

Get the current number of uncommited pending transactions.

Returns:
the current number of uncommitted transactions pending commit.
void TransactionManager::post_commit ( uint32_t  tid) [protected, virtual]

Overrideable function that can be called after commit occurs.

Default implementation is a no-op.

Reimplemented in FibConfigTransactionManager.

void TransactionManager::pre_commit ( uint32_t  tid) [protected, virtual]

Overrideable function that can be called before the first operation in a commit is dispatched.

Default implementation is a no-op.

Reimplemented in FibConfigTransactionManager, FirewallTransactionManager, and IfConfigTransactionManager.

bool TransactionManager::retrieve_size ( uint32_t  tid,
uint32_t &  count 
) const

Retrieve number of operations in pending transaction.

Parameters:
tidthe transaction ID.
countvariable to be assigned number of operations in transaction.
Returns:
true if tid is valid, false otherwise.
bool TransactionManager::start ( uint32_t &  new_tid)

Start transaction.

Parameters:
new_tidvariable to assigned new transaction id.
Returns:
true on success, false if maximum number of pending transactions is reached.
uint32_t TransactionManager::timeout_ms ( ) const [inline]

Get the inter-operation additional timeout.

If the inter-operation addition timeout is zero, timeouts are not used, otherwise a timeout will occur and the transaction aborted if the transaction is not updated for timeout_ms.

Returns:
the inter-operation additional timeout.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations