com.arjuna.wst11.messaging.engines
Class CoordinatorCompletionCoordinatorEngine

java.lang.Object
  extended by com.arjuna.wst11.messaging.engines.CoordinatorCompletionCoordinatorEngine
All Implemented Interfaces:
com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents

public class CoordinatorCompletionCoordinatorEngine
extends Object
implements com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents

The coordinator completion coordinator state engine

Author:
kevin

Constructor Summary
CoordinatorCompletionCoordinatorEngine(String id, W3CEndpointReference participant)
          Construct the initial engine for the coordinator.
CoordinatorCompletionCoordinatorEngine(String id, W3CEndpointReference participant, com.arjuna.webservices11.wsba.State state, boolean recovered)
          Construct the engine for the coordinator in a specified state and register it.
 
Method Summary
 com.arjuna.webservices11.wsba.State cancel()
          Handle the cancel event.
 void cancelled(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType cancelled, org.jboss.ws.api.addressing.MAP map, com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
          Handle the cancelled event.
 void cannotComplete(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType cannotComplete, org.jboss.ws.api.addressing.MAP map, com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
          Handle the cannot complete event.
 com.arjuna.webservices11.wsba.State close()
          Handle the close event.
 void closed(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType closed, org.jboss.ws.api.addressing.MAP map, com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
          Handle the closed event.
 com.arjuna.webservices11.wsba.State compensate()
          Handle the compensate event.
 void compensated(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType compensated, org.jboss.ws.api.addressing.MAP map, com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
          Handle the compensated event.
 com.arjuna.webservices11.wsba.State complete()
          Handle the complete event.
 void completed(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType completed, org.jboss.ws.api.addressing.MAP map, com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
          Handle the completed event.
 void exit(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType exit, org.jboss.ws.api.addressing.MAP map, com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
          Handle the exit event.
 void fail(org.oasis_open.docs.ws_tx.wsba._2006._06.ExceptionType fail, org.jboss.ws.api.addressing.MAP map, com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
          Handle the fail event.
 BAParticipantManager getCoordinator()
          Get the associated coordinator.
 String getId()
          Get the coordinator id.
 W3CEndpointReference getParticipant()
          Get the participant endpoint reference
 com.arjuna.webservices11.wsba.State getStatus()
          Handle the get status event.
 void getStatus(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType getStatus, org.jboss.ws.api.addressing.MAP map, com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
          Handle the getStatus event.
 boolean isRecovered()
          check whether this participant's details have been recovered from the log
 void setCoordinator(BAParticipantManager coordinator)
          Set the coordinator
 void soapFault(com.arjuna.webservices.SoapFault soapFault, org.jboss.ws.api.addressing.MAP map, com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
          Handle the soap fault event.
 void status(org.oasis_open.docs.ws_tx.wsba._2006._06.StatusType status, org.jboss.ws.api.addressing.MAP map, com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
          Handle the status event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoordinatorCompletionCoordinatorEngine

public CoordinatorCompletionCoordinatorEngine(String id,
                                              W3CEndpointReference participant)
Construct the initial engine for the coordinator.

Parameters:
id - The coordinator id.
participant - The participant endpoint reference.

CoordinatorCompletionCoordinatorEngine

public CoordinatorCompletionCoordinatorEngine(String id,
                                              W3CEndpointReference participant,
                                              com.arjuna.webservices11.wsba.State state,
                                              boolean recovered)
Construct the engine for the coordinator in a specified state and register it.

Parameters:
id - The coordinator id.
participant - The participant endpoint reference.
state - The initial state.
Method Detail

setCoordinator

public void setCoordinator(BAParticipantManager coordinator)
Set the coordinator

Parameters:
coordinator -

cancelled

public void cancelled(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType cancelled,
                      org.jboss.ws.api.addressing.MAP map,
                      com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
Handle the cancelled event.

Specified by:
cancelled in interface com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents
Parameters:
cancelled - The cancelled notification.
map - The addressing context.
arjunaContext - The arjuna context. Active -> Active (invalid state) Canceling-Active -> Ended Canceling-Completing -> Ended Completing -> Completing (invalid state) Completed -> Completed (invalid state) Closing -> Closing (invalid state) Compensating -> Compensating (invalid state) Failing-Active -> Failing-Active (invalid state) Failing-Canceling -> Failing-Canceling (invalid state) Failing-Completing -> Failing-Completing (invalid state) Failing-Compensating -> Failing-Compensating (invalid state) NotCompleting -> NotCompleting (invalid state) Exiting -> Exiting (invalid state) Ended -> Ended

closed

public void closed(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType closed,
                   org.jboss.ws.api.addressing.MAP map,
                   com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
Handle the closed event.

Specified by:
closed in interface com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents
Parameters:
closed - The closed notification.
map - The addressing context.
arjunaContext - The arjuna context. Active -> Active (invalid state) Canceling-Active -> Canceling-Active (invalid state) Canceling-Completing -> Canceling-Completing (invalid state) Completing -> Completing (invalid state) Completed -> Completed (invalid state) Closing -> Ended Compensating -> Compensating (invalid state) Failing-Active -> Failing-Active (invalid state) Failing-Canceling -> Failing-Canceling (invalid state) Failing-Completing -> Failing-Completing (invalid state) Failing-Compensating -> Failing-Compensating (invalid state) NotCompleting -> NotCompleting (invalid state) Exiting -> Exiting (invalid state) Ended -> Ended

compensated

public void compensated(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType compensated,
                        org.jboss.ws.api.addressing.MAP map,
                        com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
Handle the compensated event.

Specified by:
compensated in interface com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents
Parameters:
compensated - The compensated notification.
map - The addressing context.
arjunaContext - The arjuna context. Active -> Active (invalid state) Canceling-Active -> Canceling-Active (invalid state) Canceling-Completing -> Canceling-Completing (invalid state) Completing -> Completing (invalid state) Completed -> Completed (invalid state) Closing -> Closing (invalid state) Compensating -> Ended Failing-Active -> Failing-Active (invalid state) Failing-Canceling -> Failing-Canceling (invalid state) Failing-Completing -> Failing-Completing (invalid state) Failing-Compensating -> Failing-Compensating (invalid state) NotCompleting -> NotCompleting (invalid state) Exiting -> Exiting (invalid state) Ended -> Ended

completed

public void completed(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType completed,
                      org.jboss.ws.api.addressing.MAP map,
                      com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
Handle the completed event.

Specified by:
completed in interface com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents
Parameters:
completed - The completed notification.
map - The addressing context.
arjunaContext - The arjuna context. Active -> Active (invalid state) Canceling-Active -> Canceling-Active (invalid state) Canceling-Completing -> Canceling-Completing (invalid state) Completing -> Completing (invalid state) Completed -> Completed (invalid state) Closing -> Closing (invalid state) Compensating -> Ended Failing-Active -> Failing-Active (invalid state) Failing-Canceling -> Failing-Canceling (invalid state) Failing-Completing -> Failing-Completing (invalid state) Failing-Compensating -> Failing-Compensating (invalid state) NotCompleting -> NotCompleting (invalid state) Exiting -> Exiting (invalid state) Ended -> Ended

exit

public void exit(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType exit,
                 org.jboss.ws.api.addressing.MAP map,
                 com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
Handle the exit event.

Specified by:
exit in interface com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents
Parameters:
exit - The exit notification.
map - The addressing context.
arjunaContext - The arjuna context. Active -> Exiting Canceling -> Exiting Canceling-Active -> Exiting Canceling-Completing -> Exiting Completing -> Exiting Completed -> Completed (invalid state) Closing -> Closing (invalid state) Compensating -> Compensating (invalid state) Faulting -> Faulting (invalid state) Faulting-Active -> Faulting (invalid state) Faulting-Compensating -> Faulting (invalid state) Exiting -> Exiting Ended -> Ended (resend Exited)

fail

public void fail(org.oasis_open.docs.ws_tx.wsba._2006._06.ExceptionType fail,
                 org.jboss.ws.api.addressing.MAP map,
                 com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
Handle the fail event.

Specified by:
fail in interface com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents
Parameters:
fail - The fail exception.
map - The addressing context.
arjunaContext - The arjuna context. Active -> Failing-Active Canceling-Active -> Failing-Canceling Canceling-Completing -> Failing-Canceling Completing -> Failing-Completing Completed -> Completed (invalid state) Closing -> Closing (invalid state) Compensating -> Failing-Compensating Failing-Active -> Failing-Active Failing-Canceling -> Failing-Canceling Failing-Completing -> Failing-Completing Failing-Compensating -> Failing-Compensating NotCompleting -> NotCompleting (invalid state) Exiting -> Exiting (invalid state) Ended -> Ended (resend Failed) In fact we only execute the transition to FAILING_ACTIVE and in this case we send a message to the coordinator by calling executeFail. This propagates the failure back thorugh the activityy hierarchy to the relevant participant and also marks the acivity as ABORT_ONLY. In the other failure cases we do not change to a FAILING_XXX state but instead go straight to ENDED and save the failing state in a field failureState. In these cases there will be a coordinator close/cancel/compensate thread waiting on the change to state FAILING_XXX. The change to FAILING_XXX will wake it up and, if the state is still FAILING_XXX, return a fault to the coordinator, However, the failing thread also sends a failed response and then call ended. This means the state might be transitioned to ENDED before the coordinator thread is scheduled. So, we have to avoid this race by going straight to ENDED and saving a failureState which the coordinator thread can check. The failureState also avoids another race condition for these (non-ACTIVE) cases. It means we don't have to send a message to the coordinator to notify the failure. We would need to do this after the state change as we need to exclude threads handling resent messages. However, the waiting coordinator thread is woken by the state change and so it might complete and remove the activity before the message is sent causing a NoSuchActivity exception in this thread. Settign the failureState ensures that the failure is detected cleanly by any waiting coordinator thread. Fortuitously, this also avoids problems during recovery. During recovery we have no link to our coordinator available since there is no activity hierarchy in the current context. So, communicating failures via the failureState is the only way to ensure that the recovreed coordinator sees a failure. There is a further wrinkle here too. If a recovered coordinator times out waiting for a response we need to leave the engine in place when we ditch the recovered coordinator and then reestablish a link to it next time we recreate the coordinator. We cannot afford to miss a failure during this interval but the] engine must transition to ENDED after handling the failure. Saving the failure state ensures that the next time the coordinator calls cancel, compensate or close it receives a fault indicating a failure rather than just detecting that the pariticpant has ended.

cannotComplete

public void cannotComplete(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType cannotComplete,
                           org.jboss.ws.api.addressing.MAP map,
                           com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
Handle the cannot complete event.

Specified by:
cannotComplete in interface com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents
Parameters:
cannotComplete - The cannotComplete exception.
map - The addressing context.
arjunaContext - The arjuna context. Active -> NotComleting Canceling-Active -> NotCompleting Canceling-Completing -> NotCompleting Completing -> NotCompleting Completed -> Completed (invalid state) Closing -> Closing (invalid state) Compensating -> Compensating (invalid state) Failing-Active -> Failing-Active (invalid state) Failing-Canceling -> Failing-Canceling (invalid state) Failing-Completing -> Failing-Completing (invalid state) Failing-Compensating -> Failing-Compensating (invalid state) NotCompleting -> NotCompleting Exiting -> Exiting (invalid state) Ended -> Ended (resend NotCompleted)

getStatus

public void getStatus(org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType getStatus,
                      org.jboss.ws.api.addressing.MAP map,
                      com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
Handle the getStatus event.

Specified by:
getStatus in interface com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents
Parameters:
getStatus - The getStatus notification.
map - The addressing context.
arjunaContext - The arjuna context.

status

public void status(org.oasis_open.docs.ws_tx.wsba._2006._06.StatusType status,
                   org.jboss.ws.api.addressing.MAP map,
                   com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
Handle the status event.

Specified by:
status in interface com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents
Parameters:
status - The status.
map - The addressing context.
arjunaContext - The arjuna context.

getStatus

public com.arjuna.webservices11.wsba.State getStatus()
Handle the get status event.

Returns:
The state.

cancel

public com.arjuna.webservices11.wsba.State cancel()
Handle the cancel event.

Returns:
The state. Active -> Canceling-Active Canceling-Active -> Canceling-Active Canceling-Completing -> Canceling-Completing Completing -> Canceling-Completing Completed -> Completed (invalid state) Closing -> Closing (invalid state) Compensating -> Compensating (invalid state) Failing-Active -> Failing-Active (invalid state) Failing-Canceling -> Failing-Canceling (invalid state) Failing-Completing -> Failing-Completing (invalid state) Failing-Compensating -> Failing-Compensating (invalid state) NotCompleting -> NotCompleting (invalid state) Exiting -> Exiting (invalid state) Ended -> Ended (invalid state)

compensate

public com.arjuna.webservices11.wsba.State compensate()
Handle the compensate event.

Returns:
The state. Active -> Active (invalid state) Canceling-Active -> Canceling-Active (invalid state) Canceling-Completing -> Canceling-Completing (invalid state) Completing -> Completing (invalid state) Completed -> Compensating Closing -> Closing (invalid state) Compensating -> Compensating Failing-Active -> Failing-Active (invalid state) Failing-Canceling -> Failing-Canceling (invalid state) Failing-Completing -> Failing-Completing (invalid state) Failing-Compensating -> Failing-Compensating (invalid state) NotCompleting -> NotCompleting (invalid state) Exiting -> Exiting (invalid state) Ended -> Ended (invalid state)

complete

public com.arjuna.webservices11.wsba.State complete()
Handle the complete event.

Returns:
The state. Active -> Completing Canceling-Active -> Canceling-Active (invalid state) Canceling-Completing -> Canceling-Completing (invalid state) Completing -> Completing Completed -> Completed (invalid state) Closing -> Closing (invalid state) Compensating -> Compensating (invalid state) Failing-Active -> Failing-Active (invalid state) Failing-Canceling -> Failing-Canceling (invalid state) Failing-Completing -> Failing-Completing (invalid state) Failing-Compensating -> Failing-Compensating (invalid state) NotCompleting -> NotCompleting (invalid state) Exiting -> Exiting (invalid state) Ended -> Ended (invalid state)

close

public com.arjuna.webservices11.wsba.State close()
Handle the close event.

Returns:
The state. Active -> Active (invalid state) Canceling-Active -> Canceling-Active (invalid state) Canceling-Completing -> Canceling-Completing (invalid state) Completing -> Completing (invalid state) Completed -> Closing Closing -> Closing Compensating -> Compensating (invalid state) Failing-Active -> Failing-Active (invalid state) Failing-Canceling -> Failing-Canceling (invalid state) Failing-Completing -> Failing-Completing (invalid state) Failing-Compensating -> Failing-Compensating (invalid state) NotCompleting -> NotCompleting (invalid state) Exiting -> Exiting (invalid state) Ended -> Ended (invalid state)

soapFault

public void soapFault(com.arjuna.webservices.SoapFault soapFault,
                      org.jboss.ws.api.addressing.MAP map,
                      com.arjuna.webservices11.wsarj.ArjunaContext arjunaContext)
Handle the soap fault event.

Specified by:
soapFault in interface com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents
Parameters:
soapFault - The soap fault.
map - The addressing context.
arjunaContext - The arjuna context.

getId

public String getId()
Get the coordinator id.

Returns:
The coordinator id.

getParticipant

public W3CEndpointReference getParticipant()
Get the participant endpoint reference

Returns:
The participant endpoint reference

getCoordinator

public BAParticipantManager getCoordinator()
Get the associated coordinator.

Returns:
The associated coordinator.

isRecovered

public boolean isRecovered()
check whether this participant's details have been recovered from the log

Returns:
true if the participant is recovered otherwise false


Copyright © 2012. All Rights Reserved.