use of org.openkilda.wfm.topology.flowhs.fsm.swapendpoints.FlowSwapEndpointsFsm in project open-kilda by telstra.
the class FlowSwapEndpointsHubService method handleTaskTimeout.
/**
* Handles timeout case.
*/
public void handleTaskTimeout(String key) {
log.debug("Handling timeout for {}", key);
FlowSwapEndpointsFsm fsm = fsmRegister.getFsmByKey(key).orElse(null);
if (fsm == null) {
log.warn("Failed to find a FSM: timeout event for non pending FSM with key {}", key);
return;
}
fsm.fire(Event.TIMEOUT);
removeIfFinished(fsm, key);
}
use of org.openkilda.wfm.topology.flowhs.fsm.swapendpoints.FlowSwapEndpointsFsm in project open-kilda by telstra.
the class FlowSwapEndpointsHubService method handleRequest.
/**
* Handles request for swap flow endpoints.
*/
public void handleRequest(String key, CommandContext commandContext, SwapFlowEndpointRequest request) {
if (yFlowRepository.isSubFlow(request.getFirstFlow().getFlowId())) {
sendForbiddenSubFlowOperationToNorthbound(request.getFirstFlow().getFlowId(), commandContext);
return;
}
if (yFlowRepository.isSubFlow(request.getSecondFlow().getFlowId())) {
sendForbiddenSubFlowOperationToNorthbound(request.getSecondFlow().getFlowId(), commandContext);
return;
}
log.debug("Handling swap flow endpoints request with key {} and flow IDs: {}, {}", key, request.getFirstFlow().getFlowId(), request.getSecondFlow().getFlowId());
if (fsmRegister.hasRegisteredFsmWithKey(key)) {
log.error("Attempt to create a FSM with key {}, while there's another active FSM with the same key.", key);
return;
}
RequestedFlow firstFlow = RequestedFlowMapper.INSTANCE.toRequestedFlow(request.getFirstFlow());
RequestedFlow secondFlow = RequestedFlowMapper.INSTANCE.toRequestedFlow(request.getSecondFlow());
FlowSwapEndpointsFsm fsm = fsmFactory.newInstance(commandContext, firstFlow, secondFlow);
fsmRegister.registerFsm(key, fsm);
fsm.fire(Event.NEXT);
removeIfFinished(fsm, key);
}
use of org.openkilda.wfm.topology.flowhs.fsm.swapendpoints.FlowSwapEndpointsFsm in project open-kilda by telstra.
the class FlowSwapEndpointsHubService method handleAsyncResponse.
/**
* Handles async response.
*/
public void handleAsyncResponse(String key, Message message) {
log.debug("Received response {}", message);
FlowSwapEndpointsFsm fsm = fsmRegister.getFsmByKey(key).orElse(null);
if (fsm == null) {
log.warn("Failed to find a FSM: received response with key {} for non pending FSM", key);
return;
}
if (message instanceof InfoMessage && ((InfoMessage) message).getData() instanceof FlowResponse) {
fsm.fire(Event.RESPONSE_RECEIVED, new FlowSwapEndpointsContext(((InfoMessage) message).getData()));
} else if (message instanceof ErrorMessage) {
fsm.fire(Event.ERROR_RECEIVED, new FlowSwapEndpointsContext(((ErrorMessage) message).getData()));
} else {
log.warn("Key: {}; Unhandled message {}", key, message);
}
removeIfFinished(fsm, key);
}
Aggregations