org.infinispan.distribution
Interface TransactionLogger

All Superinterfaces:
RemoteTransactionLogger
All Known Implementing Classes:
TransactionLoggerImpl

public interface TransactionLogger
extends RemoteTransactionLogger

Typically adding a command, the following pattern would be used:

if (txLogger.logIfNeeded(cmd)) { // do NOT proceed with executing this command! } else { // proceed with executing this command as per normal! }

When draining, the following pattern should be used:

List<WriteCommand> c = null; while (txLogger.shouldDrainWithoutLock()) { c = txLogger.drain(); applyCommands(c); } c = txLogger.drainAndLock(); applyCommands(c); applyPendingPrepares(txLogger.getPendingPrepares()); txLogger.unlockAndDisable();

Since:
4.0
Author:
Manik Surtani

Method Summary
 void blockNewTransactions()
          Causes new transactions to block when testing isEnabled().
 void enable()
          Enables transaction logging
 boolean isEnabled()
          Checks whether transaction logging is enabled
 void logIfNeeded(CommitCommand command, TxInvocationContext context)
          Logs a CommitCommand if needed.
 void logIfNeeded(PrepareCommand command)
          Logs a PrepareCommand if needed.
 void logIfNeeded(RollbackCommand command)
          Logs a RollbackCommand if needed.
 boolean logIfNeeded(WriteCommand command)
          If logging is enabled, will log the command and return true.
 void logModificationsIfNeeded(CommitCommand commit, TxInvocationContext context)
          A mechanism for commit commands to register modifications instead of a prepare.
 void unblockNewTransactions()
          Unblocks anything blocking on isEnabled().
 
Methods inherited from interface org.infinispan.distribution.RemoteTransactionLogger
drain, drainAndLock, getPendingPrepares, shouldDrainWithoutLock, unlockAndDisable
 

Method Detail

enable

void enable()
Enables transaction logging


logIfNeeded

boolean logIfNeeded(WriteCommand command)
If logging is enabled, will log the command and return true. Otherwise, will just return false.

Parameters:
command - command to log
Returns:
true if logged, false otherwise

logIfNeeded

void logIfNeeded(PrepareCommand command)
Logs a PrepareCommand if needed.

Parameters:
command - PrepoareCommand to log

logIfNeeded

void logIfNeeded(CommitCommand command,
                 TxInvocationContext context)
Logs a CommitCommand if needed.

Parameters:
command - CommitCommand to log

logIfNeeded

void logIfNeeded(RollbackCommand command)
Logs a RollbackCommand if needed.

Parameters:
command - RollbackCommand to log

isEnabled

boolean isEnabled()
Checks whether transaction logging is enabled

Returns:
true if enabled, false otherwise.

logModificationsIfNeeded

void logModificationsIfNeeded(CommitCommand commit,
                              TxInvocationContext context)
A mechanism for commit commands to register modifications instead of a prepare. Used for when transaction logging was disabled during prepare, but was enabled before commit.

Parameters:
commit - commit command
context - context from which to extract modification list

blockNewTransactions

void blockNewTransactions()
Causes new transactions to block when testing isEnabled().


unblockNewTransactions

void unblockNewTransactions()
Unblocks anything blocking on isEnabled().



Copyright © 2011 JBoss, a division of Red Hat. All Rights Reserved.