// so keep generated messages in a temp map keyed by state
// desired-state->list of generated-messages
Map<State, List<Message>> messageMap = new HashMap<State, List<Message>>();
for (ParticipantId participantId : instanceStateMap.keySet()) {
State desiredState = instanceStateMap.get(participantId);
State currentState =
currentStateOutput.getCurrentState(resourceId, subUnitId, participantId);
if (currentState == null) {
currentState = stateModelDef.getTypedInitialState();
}
if (desiredState.equals(currentState)) {
continue;
}
State pendingState =
currentStateOutput.getPendingState(resourceId, subUnitId, participantId);
// TODO fix it
State nextState = stateModelDef.getNextStateForTransition(currentState, desiredState);
if (nextState == null) {
LOG.error("Unable to find a next state for partition: " + subUnitId
+ " from stateModelDefinition" + stateModelDef.getClass() + " from:" + currentState
+ " to:" + desiredState);
continue;
}
if (pendingState != null) {
if (nextState.equals(pendingState)) {
LOG.debug("Message already exists for " + participantId + " to transit " + subUnitId
+ " from " + currentState + " to " + nextState);
} else if (currentState.equals(pendingState)) {
LOG.info("Message hasn't been removed for " + participantId + " to transit"
+ subUnitId + " to " + pendingState + ", desiredState: " + desiredState);