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.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(InvocationContext ctx, WriteCommand command)
          Logs a write command (if needed).
 void afterCommand(TxInvocationContext ctx, CommitCommand command)
          Logs a CommitCommand if needed.
 void afterCommand(TxInvocationContext ctx, LockControlCommand cmd)
          Notify the transaction logger after a lock control command.
 void afterCommand(TxInvocationContext ctx, PrepareCommand command)
          Logs a PrepareCommand if needed.
 void afterCommand(TxInvocationContext ctx, RollbackCommand command)
          Logs a RollbackCommand if needed.
 boolean areTransactionsBlocked()
           
 boolean beforeCommand(InvocationContext ctx, WriteCommand command)
          Notify the transaction logger before a write command, potentially blocking.
 boolean beforeCommand(TxInvocationContext ctx, CommitCommand command)
          Notify the transaction logger before a commit command, potentially blocking.
 boolean beforeCommand(TxInvocationContext ctx, LockControlCommand cmd)
          Notify the transaction logger before a lock control command, potentially blocking
 boolean beforeCommand(TxInvocationContext ctx, PrepareCommand command)
          Notify the transaction logger before a prepare command, potentially blocking.
 boolean beforeCommand(TxInvocationContext ctx, RollbackCommand command)
          Notify the transaction logger before a rollback 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 resumeTransactionLock(InvocationContext ctx)
          Re-acquire the transaction lock when a remote call returns.
 void suspendTransactionLock(InvocationContext ctx)
          Use before synchronous remote calls, as the remote call will also try to acquire the transaction lock on that node.
 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(InvocationContext ctx,
                  WriteCommand command)
                  throws InterruptedException
Logs a write command (if needed).

Parameters:
command - command to log
Throws:
InterruptedException

afterCommand

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

Parameters:
command - PrepoareCommand to log
Throws:
InterruptedException

afterCommand

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

Parameters:
command - CommitCommand to log
Throws:
InterruptedException

afterCommand

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

Parameters:
command - RollbackCommand to log
Throws:
InterruptedException

afterCommand

void afterCommand(TxInvocationContext ctx,
                  LockControlCommand cmd)
Notify the transaction logger after a lock control command.


isEnabled

boolean isEnabled()
Checks whether transaction logging is enabled

Returns:
true if enabled, false otherwise.

beforeCommand

boolean beforeCommand(InvocationContext ctx,
                      WriteCommand command)
                      throws InterruptedException,
                             TimeoutException
Notify the transaction logger before a write command, potentially blocking.

Returns:
true if the transaction can proceed, false otherwise
Throws:
InterruptedException
TimeoutException

beforeCommand

boolean beforeCommand(TxInvocationContext ctx,
                      PrepareCommand command)
                      throws InterruptedException,
                             TimeoutException
Notify the transaction logger before a prepare command, potentially blocking.

Returns:
true if the transaction can proceed, false otherwise
Throws:
InterruptedException
TimeoutException

beforeCommand

boolean beforeCommand(TxInvocationContext ctx,
                      CommitCommand command)
                      throws InterruptedException,
                             TimeoutException
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.

Returns:
true if the transaction can proceed, false otherwise
Throws:
InterruptedException
TimeoutException

beforeCommand

boolean beforeCommand(TxInvocationContext ctx,
                      RollbackCommand command)
                      throws InterruptedException,
                             TimeoutException
Notify the transaction logger before a rollback command, potentially blocking.

Returns:
true if the transaction can proceed, false otherwise
Throws:
InterruptedException
TimeoutException

beforeCommand

boolean beforeCommand(TxInvocationContext ctx,
                      LockControlCommand cmd)
                      throws TimeoutException,
                             InterruptedException
Notify the transaction logger before a lock control command, potentially blocking

Returns:
true if the transaction can proceed, false otherwise
Throws:
TimeoutException
InterruptedException

suspendTransactionLock

void suspendTransactionLock(InvocationContext ctx)
Use before synchronous remote calls, as the remote call will also try to acquire the transaction lock on that node. Since the rehashing process may try to acquire the same locks in reverse order, this could lead to deadlocks.


resumeTransactionLock

void resumeTransactionLock(InvocationContext ctx)
                           throws TimeoutException,
                                  InterruptedException
Re-acquire the transaction lock when a remote call returns.

Throws:
TimeoutException
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

areTransactionsBlocked

boolean areTransactionsBlocked()
Returns:
true if new transactions are blocked and false otherwise.

-->

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