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 void
addFailed(ID remote, Throwable failure)
protected void
addParticipants(ID[] ids)
protected void
doTMAbort(Throwable except)
protected void
doTMCommit()
protected ISharedObjectContext
getContext()
protected ID
getHomeID()
protected int
getMinFailedToAbort()
protected BaseSharedObject
getSharedObject()
protected int
getTimeout()
byte
getTransactionState()
Get state of transaction.protected void
handleActivated(ISharedObjectActivatedEvent event)
protected void
handleCreateResponse(ISharedObjectCreateResponseEvent event)
protected void
handleDeparted(IContainerDisconnectedEvent event)
protected void
handleJoined(IContainerConnectedEvent event)
protected void
handlePostCommitFailure(ID fromID, Throwable e, long identifier1)
protected void
handlePrimaryActivated(ISharedObjectActivatedEvent event)
protected void
handleReplicaActivated(ISharedObjectActivatedEvent event)
protected void
handleVotingCompletedCreateResponse(ID fromID, Throwable e, long identifier1)
protected boolean
isPrimary()
protected boolean
isVotingCompleted()
protected void
localCommitted()
boolean
processEvent(Event event)
Process given Eventprotected void
removeParticipant(ID id)
protected void
replicateTo(ID[] remotes)
protected void
sendCommit()
protected void
setTransactionState(byte state)
protected void
trace(String msg)
protected void
traceStack(String msg, Throwable t)
void
waitToCommit()
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:IEventProcessor
Process given Event- Specified by:
processEvent
in 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:ISharedObjectContainerTransaction
Get state of transaction. Returns one of 'ACTIVE', 'VOTING', 'PREPARED', 'COMMITTED', or 'ABORTED'.- Specified by:
getTransactionState
in interfaceISharedObjectContainerTransaction
- Returns:
- byte code. Returns one of 'ACTIVE', 'VOTING', 'PREPARED', 'COMMITTED', or 'ABORTED'.
-
setTransactionState
protected void setTransactionState(byte state)
-
waitToCommit
public void waitToCommit() throws SharedObjectAddAbortException
Description copied from interface:ISharedObjectContainerTransaction
Method called to wait for a transaction to complete.- Specified by:
waitToCommit
in 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
-
-