com.cloudtran.coherence.llapi
Interface ManagerEventListener

All Known Implementing Classes:
AbstractManagerEventListener

public interface ManagerEventListener

ManagerEventListeners get events from the manager during the commit and persistence processing. These events are different Cache events, which are generated by actions on application caches. Manager events are generated in the manager handling a given transaction.

This is application code.

The design of the ManagerEventListener allows you to create listeners that just do one job. This is an issue because some of these methods change the internal state of the transaction manager.

preCommit() method rolls back a transaction by throwing an exception.

committing() and doLog() can do replication and logging on behalf of the manager, and may cause the manager to wait for the semaphore passed to them; they will normally only have one event listener performing the action (replicate/log). These methods return a boolean; if this is true, the method has handled the action on behalf of the manager and no other event listeners need to be called. To allow the manager


Method Summary
 boolean committing(ManagerEvent event, Semaphore semaphore)
          This event is called once the preCommit() method returns successfully.
 void complete(ManagerEvent event)
          This event is called once all actions on this transaction (log, commit to the grid and persist) have completed.
 boolean doLog(ManagerEvent event, Semaphore loggingSemaphore)
          This event is called when logging is to be performed.
 void preCommit(ManagerEvent event)
          This event is called before the committing state.
 void rollback(ManagerEvent event)
          This event is called when an abort has been called.
 

Method Detail

preCommit

void preCommit(ManagerEvent event)
               throws TransactionExceptionNonRetriable
This event is called before the committing state.

You can do further validation at this point. To abort the transaction, throw a RuntimeException. If this method returns normally, the transaction will commit.

This is an in-manager operation and is performance critical. Do not make any access to caches or any external resource - this should be done by the client application during normal processing.

Parameters:
event - The ManagerEvent object
Throws:
TransactionExceptionNonRetriable - to indicate that the transaction cannot be committed. It will be rolled back.

committing

boolean committing(ManagerEvent event,
                   Semaphore semaphore)
This event is called once the preCommit() method returns successfully. The transaction is guaranteed to commit before this method is called.

Use this to relay the transaction (using event.gridObjects) to another grid transactionally. Do not do any persistence-related operations here - they should be done in the persister.

Parameters:
event - The ManagerEvent object
semaphore - A semaphore for the committing() method to release when its work is done. If this method returns true, it *must* release the semaphore in a timely fashion. If this method returns false, it must *not* release the semaphore.
Returns:
True if the method has handled the action on behalf of the manager: the manager will not call the committing() method any other event listeners.

complete

void complete(ManagerEvent event)
This event is called once all actions on this transaction (log, commit to the grid and persist) have completed.

It does not include transactions have been aborted

Parameters:
event - The ManagerEvent object

rollback

void rollback(ManagerEvent event)
This event is called when an abort has been called.

The abort process can not be guaranteed to have finished when this event is called.

Parameters:
event - The ManagerEvent object

doLog

boolean doLog(ManagerEvent event,
              Semaphore loggingSemaphore)
This event is called when logging is to be performed.

The doLog() method should not hold up the manager by calling logging synchronously. Instead, it should put the event onto a log queue and return immediately. When the asynchronous logging action has completed, it should release the passed semaphore.

If no ManagerEventListener handles the doLog event (i.e. returns true to this method), then the manager will perform the built-in logging.

Parameters:
event - The ManagerEvent object
semaphore - A semaphore for the committing event to release when its work is done. If this method returns true, it *must* release the semaphore in a timely fashion. If this method returns false, it must *not* release the semaphore.
Returns:
True if the method has handled the action on behalf of the manager: the manager will not call the doLog() method of any other event listeners or do the standard CloudTran logging.