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:

txLogger.beforeCommand(); try { // execute this command! } finally { txLogger.afterCommand(cmd); }

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, Dan Berindei

Method Summary
 void afterCommand(CommitCommand command, TxInvocationContext context)
          Logs a CommitCommand if needed.
 void afterCommand(PrepareCommand command)
          Logs a PrepareCommand if needed.
 void afterCommand(RollbackCommand command)
          Logs a RollbackCommand if needed.
 void afterCommand(WriteCommand command)
          Logs a write command (if needed).
 void beforeCommand(CommitCommand command, TxInvocationContext context)
          Notify the transaction logger before a commit command, potentially blocking.
 void beforeCommand(PrepareCommand command)
          Notify the transaction logger before a prepare command, potentially blocking.
 void beforeCommand(RollbackCommand command)
          Notify the transaction logger before a rollback command, potentially blocking.
 void beforeCommand(WriteCommand command)
          Notify the transaction logger before a write command, potentially blocking.
 void blockNewTransactions()
          Causes new transactions to block when calling beforeCommand().
 void enable()
          Enables transaction logging
 boolean isEnabled()
          Checks whether transaction logging is enabled
 void unblockNewTransactions()
          Unblocks anything blocking on beforeCommand().
 
Methods inherited from interface org.infinispan.distribution.RemoteTransactionLogger
drain, drainAndLock, getPendingPrepares, shouldDrainWithoutLock, unlockAndDisable
 

Method Detail

enable

void enable()
Enables transaction logging


afterCommand

void afterCommand(WriteCommand command)
                  throws InterruptedException
Logs a write command (if needed).

Parameters:
command - command to log
Throws:
InterruptedException

afterCommand

void afterCommand(PrepareCommand command)
                  throws InterruptedException
Logs a PrepareCommand if needed.

Parameters:
command - PrepoareCommand to log
Throws:
InterruptedException

afterCommand

void afterCommand(CommitCommand command,
                  TxInvocationContext context)
                  throws InterruptedException
Logs a CommitCommand if needed.

Parameters:
command - CommitCommand to log
Throws:
InterruptedException

afterCommand

void afterCommand(RollbackCommand command)
                  throws InterruptedException
Logs a RollbackCommand if needed.

Parameters:
command - RollbackCommand to log
Throws:
InterruptedException

isEnabled

boolean isEnabled()
Checks whether transaction logging is enabled

Returns:
true if enabled, false otherwise.

beforeCommand

void beforeCommand(WriteCommand command)
                   throws InterruptedException
Notify the transaction logger before a write command, potentially blocking.

Throws:
InterruptedException

beforeCommand

void beforeCommand(PrepareCommand command)
                   throws InterruptedException
Notify the transaction logger before a prepare command, potentially blocking.

Throws:
InterruptedException

beforeCommand

void beforeCommand(CommitCommand command,
                   TxInvocationContext context)
                   throws InterruptedException
Notify the transaction logger before a commit command, potentially blocking. If transaction logging was not enabled during the prepare command, use the context to extract the list of modifications.

Throws:
InterruptedException

beforeCommand

void beforeCommand(RollbackCommand command)
                   throws InterruptedException
Notify the transaction logger before a rollback command, potentially blocking.

Throws:
InterruptedException

blockNewTransactions

void blockNewTransactions()
                          throws InterruptedException
Causes new transactions to block when calling beforeCommand().

Throws:
InterruptedException

unblockNewTransactions

void unblockNewTransactions()
                            throws InterruptedException
Unblocks anything blocking on beforeCommand().

Throws:
InterruptedException

-->

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