public class CoordinatorCompletionCoordinatorEngine extends Object implements CoordinatorCompletionCoordinatorInboundEvents
Constructor and Description |
---|
CoordinatorCompletionCoordinatorEngine(String id,
W3CEndpointReference participant)
Construct the initial engine for the coordinator.
|
CoordinatorCompletionCoordinatorEngine(String id,
W3CEndpointReference participant,
State state,
boolean recovered)
Construct the engine for the coordinator in a specified state and register it.
|
Modifier and Type | Method and Description |
---|---|
State |
cancel()
Handle the cancel event.
|
void |
cancelled(NotificationType cancelled,
MAP map,
ArjunaContext arjunaContext)
Handle the cancelled event.
|
void |
cannotComplete(NotificationType cannotComplete,
MAP map,
ArjunaContext arjunaContext)
Handle the cannot complete event.
|
State |
close()
Handle the close event.
|
void |
closed(NotificationType closed,
MAP map,
ArjunaContext arjunaContext)
Handle the closed event.
|
State |
compensate()
Handle the compensate event.
|
void |
compensated(NotificationType compensated,
MAP map,
ArjunaContext arjunaContext)
Handle the compensated event.
|
State |
complete()
Handle the complete event.
|
void |
completed(NotificationType completed,
MAP map,
ArjunaContext arjunaContext)
Handle the completed event.
|
void |
exit(NotificationType exit,
MAP map,
ArjunaContext arjunaContext)
Handle the exit event.
|
void |
fail(ExceptionType fail,
MAP map,
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
|
State |
getStatus()
Handle the get status event.
|
void |
getStatus(NotificationType getStatus,
MAP map,
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(SoapFault soapFault,
MAP map,
ArjunaContext arjunaContext)
Handle the soap fault event.
|
void |
status(StatusType status,
MAP map,
ArjunaContext arjunaContext)
Handle the status event.
|
public CoordinatorCompletionCoordinatorEngine(String id, W3CEndpointReference participant)
id
- The coordinator id.participant
- The participant endpoint reference.public CoordinatorCompletionCoordinatorEngine(String id, W3CEndpointReference participant, State state, boolean recovered)
id
- The coordinator id.participant
- The participant endpoint reference.state
- The initial state.public void setCoordinator(BAParticipantManager coordinator)
coordinator
- public void cancelled(NotificationType cancelled, MAP map, ArjunaContext arjunaContext)
cancelled
in interface CoordinatorCompletionCoordinatorInboundEvents
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 -> Endedpublic void closed(NotificationType closed, MAP map, ArjunaContext arjunaContext)
closed
in interface CoordinatorCompletionCoordinatorInboundEvents
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 -> Endedpublic void compensated(NotificationType compensated, MAP map, ArjunaContext arjunaContext)
compensated
in interface CoordinatorCompletionCoordinatorInboundEvents
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 -> Endedpublic void completed(NotificationType completed, MAP map, ArjunaContext arjunaContext)
completed
in interface CoordinatorCompletionCoordinatorInboundEvents
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 -> Endedpublic void exit(NotificationType exit, MAP map, ArjunaContext arjunaContext)
exit
in interface CoordinatorCompletionCoordinatorInboundEvents
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)public void fail(ExceptionType fail, MAP map, ArjunaContext arjunaContext)
fail
in interface CoordinatorCompletionCoordinatorInboundEvents
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.public void cannotComplete(NotificationType cannotComplete, MAP map, ArjunaContext arjunaContext)
cannotComplete
in interface CoordinatorCompletionCoordinatorInboundEvents
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)public void getStatus(NotificationType getStatus, MAP map, ArjunaContext arjunaContext)
getStatus
in interface CoordinatorCompletionCoordinatorInboundEvents
getStatus
- The getStatus notification.map
- The addressing context.arjunaContext
- The arjuna context.public void status(StatusType status, MAP map, ArjunaContext arjunaContext)
status
in interface CoordinatorCompletionCoordinatorInboundEvents
status
- The status.map
- The addressing context.arjunaContext
- The arjuna context.public State getStatus()
public State cancel()
public State compensate()
public State complete()
public State close()
public void soapFault(SoapFault soapFault, MAP map, ArjunaContext arjunaContext)
soapFault
in interface CoordinatorCompletionCoordinatorInboundEvents
soapFault
- The soap fault.map
- The addressing context.arjunaContext
- The arjuna context.public String getId()
public W3CEndpointReference getParticipant()
public BAParticipantManager getCoordinator()
public boolean isRecovered()
Copyright © 2018 JBoss by Red Hat. All rights reserved.