com.atomikos.icatch.msg
Class CommitServer

java.lang.Object
  extended by com.atomikos.icatch.msg.CommitServer
All Implemented Interfaces:
MessageListener, TSListener

public class CommitServer
extends Object
implements MessageListener, TSListener

A CommitServer takes care of incoming 2PC events (prepare, commit, rollback, forget and replay requests). It does this by listening on the transport for these types of messages. This class is generic and can be used with any 2PC message protocol.


Constructor Summary
CommitServer()
          Constructs a new instance.
CommitServer(boolean trustClientTM)
           
 
Method Summary
static String createGlobalUri(String addressPart, String localIdPart)
          Creates a globally unique URI from a given (unique) address part and a local ID part.
static String extractLocalIdPart(String globalUri)
          Extracts the local ID part from a global URI that belongs to a local coordinator.
 void init(boolean before, Properties p)
          Called before and after initialization.
 void init(TransactionService service, Transport[] transports)
          Initializes the instance.
 boolean messageReceived(TransactionMessage msg, Transport transport)
          The callback method, called by the transport when a message is received for this listener.
 void shutdown(boolean before)
          Called before and after shutdown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommitServer

public CommitServer()
Constructs a new instance.


CommitServer

public CommitServer(boolean trustClientTM)
Method Detail

createGlobalUri

public static final String createGlobalUri(String addressPart,
                                           String localIdPart)
Creates a globally unique URI from a given (unique) address part and a local ID part. This is needed because the core needs to use the client's ID for an imported coordinator (to be able to detect orphans). Consequently, an imported coordinator's ID is not a valid URI that uniquely identifies the work on our site! By combining with the (globally unique) address of the transaction service core, we get uniqueness.

Parameters:
addressPart - The globally unique address part.
localIdPart - The locally unique ID part.
Returns:
A globally unique URI

extractLocalIdPart

public static final String extractLocalIdPart(String globalUri)
Extracts the local ID part from a global URI that belongs to a local coordinator. This method should only be called for URIs that correspond to a local coordinator, or the extraction will not work. In practice, this means that only the CommitServer should call this method, since this is the only class that needs to interpret incoming messages for local coordinators.

Parameters:
globalUri - The URI.
Returns:
The local ID part.

init

public void init(TransactionService service,
                 Transport[] transports)
          throws SysException
Initializes the instance. This should be the first method called.

Parameters:
service - The transaction service.
transports - The transport list to listen on.
Throws:
SysException - On failure.

init

public void init(boolean before,
                 Properties p)
Description copied from interface: TSListener
Called before and after initialization.

Specified by:
init in interface TSListener
Parameters:
before - True indicates that initialization is about to start. False indicates that initialization has finished. This means that recovery has been done and the transaction service is now ready to start new transactions.
p - The initialization properties.
See Also:
TSListener

shutdown

public void shutdown(boolean before)
Description copied from interface: TSListener
Called before and after shutdown.

Specified by:
shutdown in interface TSListener
Parameters:
before - True if shutdown is about to start. False if shutdown has finished.
See Also:
TSListener

messageReceived

public boolean messageReceived(TransactionMessage msg,
                               Transport transport)
Description copied from interface: MessageListener
The callback method, called by the transport when a message is received for this listener.

Specified by:
messageReceived in interface MessageListener
Parameters:
msg - The message that was received.
Returns:
boolean False if the listener wants no more messages (and can be removed).
See Also:
MessageListener


Copyright © 2012. All Rights Reserved.