com.atomikos.icatch.msg
Class MessageParticipant

java.lang.Object
  extended by com.atomikos.icatch.msg.MessageParticipant
All Implemented Interfaces:
Participant, Externalizable, Serializable

public class MessageParticipant
extends Object
implements Participant, Externalizable

A participant implementation that can be used on a message-based platform. This participant acts as a core proxy for remote participants that co-operate over a message-based 2PC protocol. By introducing the abstract message interface framework, the same participant instance can be reused for different message systems and different protocols.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.atomikos.icatch.Participant
READ_ONLY
 
Constructor Summary
MessageParticipant()
           
MessageParticipant(String remoteUri, Object address, Transport transport, HeuristicMessage[] msgs, boolean earlyPrepared, boolean readOnly)
           
 
Method Summary
 HeuristicMessage[] commit(boolean onePhase)
          Commits the participant's work.
 boolean equals(Object o)
           
 void forget()
          Indicates that a heuristic participant can forget about its work.
 Object getAddress()
           
 int getCommitProtocol()
          Getter for the commit protocol.
 int getFormat()
          Getter for the format.
 HeuristicMessage[] getHeuristicMessages()
           
 int getTransportProtocol()
          Getter for the transport protocol.
 String getURI()
           
 int hashCode()
           
 int prepare()
          Prepares the participant.
 void readExternal(ObjectInput in)
           
 boolean recover()
          Called by the transaction manager (TM) at recovery time, and this should reconstruct the internal state.
 HeuristicMessage[] rollback()
          Rollback of the participant's work.
 void setCascadeList(Dictionary allParticipants)
          For cascading 2PC, this method sets the information needed to cascade.
 void setGlobalSiblingCount(int count)
          Set by the root coordinator: the total no of siblings detected.
 String toString()
          Returns a string representation of this participant proxy.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageParticipant

public MessageParticipant()

MessageParticipant

public MessageParticipant(String remoteUri,
                          Object address,
                          Transport transport,
                          HeuristicMessage[] msgs,
                          boolean earlyPrepared,
                          boolean readOnly)
Method Detail

getTransportProtocol

public int getTransportProtocol()
Getter for the transport protocol.


getCommitProtocol

public int getCommitProtocol()
Getter for the commit protocol.


getFormat

public int getFormat()
Getter for the format.


writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

recover

public boolean recover()
                throws SysException
Description copied from interface: Participant
Called by the transaction manager (TM) at recovery time, and this should reconstruct the internal state.

Specified by:
recover in interface Participant
Returns:
boolean False if the instance could not be recovered. It is up to the transaction manager to determine the severity of this case.
Throws:
SysException
See Also:
Participant

getAddress

public Object getAddress()

getURI

public String getURI()
Specified by:
getURI in interface Participant
Returns:
String The unique URI for this remote participant, or null for local instances.
See Also:
Participant

setCascadeList

public void setCascadeList(Dictionary allParticipants)
                    throws SysException
Description copied from interface: Participant
For cascading 2PC, this method sets the information needed to cascade. This method is relevant only for transaction monitors; leave empty otherwise!

Specified by:
setCascadeList in interface Participant
Parameters:
allParticipants - The information needed by the transaction monitor.
Throws:
SysException
See Also:
Participant.

setGlobalSiblingCount

public void setGlobalSiblingCount(int count)
Description copied from interface: Participant
Set by the root coordinator: the total no of siblings detected. This method is relevant only for transaction monitors; leave empty otherwise!

Specified by:
setGlobalSiblingCount in interface Participant
Parameters:
count - The global count.
See Also:
Participant.

getHeuristicMessages

public HeuristicMessage[] getHeuristicMessages()
Specified by:
getHeuristicMessages in interface Participant
Returns:
HeuristicMessage[] An array of heuristic messages, or null if none.
See Also:
Participant

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Participant.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Returns a string representation of this participant proxy.

Overrides:
toString in class Object

prepare

public int prepare()
            throws RollbackException,
                   HeurHazardException,
                   HeurMixedException,
                   SysException
Description copied from interface: Participant
Prepares the participant. Any locks for this participant's work should be recoverable (either saved to an external file OR be part of the instance's non-transient state so that they can be flushed into the transaction manager's log).

Specified by:
prepare in interface Participant
Returns:
int READ_ONLY if no second round is needed. Participants that return this value on prepare will not be called by commit or rollback afterwards.
Throws:
RollbackException - For a NO vote. This indicates that the participant has already rolled back (or marked for rollback) the work on behalf of this participant.
HeurHazardException - On possible conflicts. This happens for remote participants instances, in case of communication failures.
HeurMixedException - If some subordinate participants voted YES, timed out and committed heuristically whereas afterwards some NO votes where received.
SysException
See Also:
Participant

commit

public HeuristicMessage[] commit(boolean onePhase)
                          throws HeurRollbackException,
                                 HeurHazardException,
                                 HeurMixedException,
                                 RollbackException,
                                 SysException
Description copied from interface: Participant
Commits the participant's work. NOTE: custom participant implementations should preferably be made for the server's local VM (e.g., it is better not to do this over RMI). Also, they should rely on the transaction manager for heuristic timeout (and NOT decide to terminate heuristically themselves). In that case, implementations never need to throw any of the heuristic exceptions of this method.

Specified by:
commit in interface Participant
Parameters:
onePhase - If true, one-phase commit is being started. If the participant has received a prepare call earlier, then it should throw a SysException here.
Returns:
HeuristicMessage[] An array of messages, null if none.
Throws:
HeurHazardException - On possible conflicts.
RollbackException - In case of one-phase commit, and the transaction has been rolled back at the time commit is called.
SysException
HeurRollbackException
HeurMixedException
See Also:
Participant

rollback

public HeuristicMessage[] rollback()
                            throws HeurCommitException,
                                   HeurMixedException,
                                   HeurHazardException,
                                   SysException
Description copied from interface: Participant
Rollback of the participant's work. NOTE: custom participant implementations should preferably be made for the server's local VM (e.g., it is better not to do this over RMI). Also, they should rely on the icatch transaction manager for heuristic timeout (and NOT decide to terminate heuristically themselves). In that case, implementations never need to throw any of the heuristic exceptions of this method.

Specified by:
rollback in interface Participant
Returns:
HeuristicMessage[] An array of messages, null if none.
Throws:
HeurCommitException - If the participant committed.
HeurMixedException - If part of the work was rolled back.
HeurHazardException - If the participant's final state is unsure.
SysException
See Also:
Participant

forget

public void forget()
Description copied from interface: Participant
Indicates that a heuristic participant can forget about its work. If implementations rely on the transaction manager to decide when to do heuristics (rather then deciding in the participant implementation), then leave this method empty.

Specified by:
forget in interface Participant
See Also:
Participant


Copyright © 2012. All Rights Reserved.