Class TwoPhaseCommitEventProcessor
- java.lang.Object
-
- org.eclipse.ecf.core.sharedobject.TwoPhaseCommitEventProcessor
-
- All Implemented Interfaces:
ISharedObjectContainerTransaction,IEventProcessor
public class TwoPhaseCommitEventProcessor extends Object implements IEventProcessor, ISharedObjectContainerTransaction
Implementation of two-phase commit for transactional replication of shared objects.
-
-
Constructor Summary
Constructors Constructor Description TwoPhaseCommitEventProcessor(BaseSharedObject bse, ISharedObjectTransactionConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddFailed(ID remote, Throwable failure)protected voidaddParticipants(ID[] ids)protected voiddoTMAbort(Throwable except)protected voiddoTMCommit()protected ISharedObjectContextgetContext()protected IDgetHomeID()protected intgetMinFailedToAbort()protected BaseSharedObjectgetSharedObject()protected intgetTimeout()bytegetTransactionState()Get state of transaction.protected voidhandleActivated(ISharedObjectActivatedEvent event)protected voidhandleCreateResponse(ISharedObjectCreateResponseEvent event)protected voidhandleDeparted(IContainerDisconnectedEvent event)protected voidhandleJoined(IContainerConnectedEvent event)protected voidhandlePostCommitFailure(ID fromID, Throwable e, long identifier1)protected voidhandlePrimaryActivated(ISharedObjectActivatedEvent event)protected voidhandleReplicaActivated(ISharedObjectActivatedEvent event)protected voidhandleVotingCompletedCreateResponse(ID fromID, Throwable e, long identifier1)protected booleanisPrimary()protected booleanisVotingCompleted()protected voidlocalCommitted()booleanprocessEvent(Event event)Process given Eventprotected voidremoveParticipant(ID id)protected voidreplicateTo(ID[] remotes)protected voidsendCommit()protected voidsetTransactionState(byte state)protected voidtrace(String msg)protected voidtraceStack(String msg, Throwable t)voidwaitToCommit()Method called to wait for a transaction to complete.
-
-
-
Constructor Detail
-
TwoPhaseCommitEventProcessor
public TwoPhaseCommitEventProcessor(BaseSharedObject bse, ISharedObjectTransactionConfig config)
-
-
Method Detail
-
trace
protected void trace(String msg)
-
getTimeout
protected int getTimeout()
-
getMinFailedToAbort
protected int getMinFailedToAbort()
-
isPrimary
protected boolean isPrimary()
-
getSharedObject
protected BaseSharedObject getSharedObject()
-
getHomeID
protected ID getHomeID()
-
addParticipants
protected void addParticipants(ID[] ids)
-
removeParticipant
protected void removeParticipant(ID id)
-
getContext
protected ISharedObjectContext getContext()
-
processEvent
public boolean processEvent(Event event)
Description copied from interface:IEventProcessorProcess given Event- Specified by:
processEventin interfaceIEventProcessor- Parameters:
event- the Event to process- Returns:
- true if the event has been successfully processed and no further processing should occur. False if the event should receive further processing by another event processor (e.g. in a chain)
-
handleActivated
protected void handleActivated(ISharedObjectActivatedEvent event)
-
replicateTo
protected void replicateTo(ID[] remotes)
-
handlePrimaryActivated
protected void handlePrimaryActivated(ISharedObjectActivatedEvent event)
-
handleReplicaActivated
protected void handleReplicaActivated(ISharedObjectActivatedEvent event)
-
handleJoined
protected void handleJoined(IContainerConnectedEvent event)
-
handleCreateResponse
protected void handleCreateResponse(ISharedObjectCreateResponseEvent event)
-
handleDeparted
protected void handleDeparted(IContainerDisconnectedEvent event)
-
handleVotingCompletedCreateResponse
protected void handleVotingCompletedCreateResponse(ID fromID, Throwable e, long identifier1)
-
handlePostCommitFailure
protected void handlePostCommitFailure(ID fromID, Throwable e, long identifier1)
-
sendCommit
protected void sendCommit() throws SharedObjectAddAbortException- Throws:
SharedObjectAddAbortException
-
getTransactionState
public byte getTransactionState()
Description copied from interface:ISharedObjectContainerTransactionGet state of transaction. Returns one of 'ACTIVE', 'VOTING', 'PREPARED', 'COMMITTED', or 'ABORTED'.- Specified by:
getTransactionStatein interfaceISharedObjectContainerTransaction- Returns:
- byte code. Returns one of 'ACTIVE', 'VOTING', 'PREPARED', 'COMMITTED', or 'ABORTED'.
-
setTransactionState
protected void setTransactionState(byte state)
-
waitToCommit
public void waitToCommit() throws SharedObjectAddAbortExceptionDescription copied from interface:ISharedObjectContainerTransactionMethod called to wait for a transaction to complete.- Specified by:
waitToCommitin interfaceISharedObjectContainerTransaction- Throws:
SharedObjectAddAbortException
-
doTMAbort
protected void doTMAbort(Throwable except) throws SharedObjectAddAbortException
- Throws:
SharedObjectAddAbortException
-
doTMCommit
protected void doTMCommit() throws SharedObjectAddAbortException- Throws:
SharedObjectAddAbortException
-
localCommitted
protected void localCommitted()
-
isVotingCompleted
protected boolean isVotingCompleted() throws SharedObjectAddAbortException- Throws:
SharedObjectAddAbortException
-
-