org.infinispan.distribution
Interface TransactionLogger

All Known Implementing Classes:
TransactionLoggerImpl

public interface TransactionLogger

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 c = null; while (txLogger.size() > THRESHOLD) { c = txLogger.drain(); applyCommands(c); } c = txLogger.drainAndLock(); applyCommands(c); txLogger.unlockAndDisable();

Since:
4.0
Author:
Manik Surtani

Method Summary
 List<WriteCommand> drain()
          Drains the transaction log and returns a list of what has been drained.
 List<WriteCommand> drainAndLock()
          Similar to drain() except that relevant locks are acquired so that no more commands are added to the transaction log during this process, and transaction logging is disabled after draining.
 void enable()
           
 boolean isEnabled()
           
 boolean logIfNeeded(Collection<WriteCommand> commands)
          If logging is enabled, will log the commands and return true.
 void logIfNeeded(CommitCommand command)
           
 void logIfNeeded(PrepareCommand command)
           
 void logIfNeeded(RollbackCommand command)
           
 boolean logIfNeeded(WriteCommand command)
          If logging is enabled, will log the command and return true.
 int size()
           
 void unlockAndDisable()
           
 

Method Detail

enable

void enable()

drain

List<WriteCommand> drain()
Drains the transaction log and returns a list of what has been drained.

Returns:
a list of drained commands

drainAndLock

List<WriteCommand> drainAndLock()
Similar to drain() except that relevant locks are acquired so that no more commands are added to the transaction log during this process, and transaction logging is disabled after draining.

Returns:
list of drained commands

unlockAndDisable

void unlockAndDisable()

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)

logIfNeeded

void logIfNeeded(CommitCommand command)

logIfNeeded

void logIfNeeded(RollbackCommand command)

logIfNeeded

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

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

size

int size()

isEnabled

boolean isEnabled()

Google Analytics

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