com.cloudtran.coherence
Interface ManagerEventListener

All Known Implementing Classes:
DefaultManagerEventListener

public interface ManagerEventListener

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

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, NamedSemaphore commitSemaphore)
          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 doHospitalAction(Hospital.HospitalData hospitalData)
          This event is called when an irrecoverable error is found in CloudTran.
 boolean doTransactionLog(ManagerEvent event, boolean persisted, NamedSemaphore loggingSemaphore)
          This event is called when transaction 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 for the whole transaction manager. Do not make any access to caches or any external resource - this should be done by the client application during normal processing. Only write to disk in exceptional circumstances, such as fatal error conditions.

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,
                   NamedSemaphore commitSemaphore)
This event is called once the preCommit() method returns successfully. When this method is called, the transaction is in COMMITTING state and is guaranteed to commit.

The CloudTran replicator uses this event to relay the transaction (using event.gridObjects) to another grid transactionally. If you want to do your own replication, listen for this event and return true from your handler.

Do not do any persistence-related operations here - they should be done in the persister.

Parameters:
event - The ManagerEvent object
commitSemaphore - 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

doTransactionLog

boolean doTransactionLog(ManagerEvent event,
                         boolean persisted,
                         NamedSemaphore loggingSemaphore)
This event is called when transaction logging is to be performed.

The doTransactionLog() 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
loggingSemaphore - 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.

doHospitalAction

boolean doHospitalAction(Hospital.HospitalData hospitalData)
This event is called when an irrecoverable error is found in CloudTran. See HospitalDataHolder for more information.

Parameters:
hospitalData - the data for the ReplicatorPut errors.
Returns:
True if the method has handled the action on behalf of the manager: the manager will not call any further event listeners to process the event.