use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.
the class YFlowCreateHubBolt method onWorkerResponse.
@Override
protected void onWorkerResponse(Tuple input) throws PipelineException {
String operationKey = pullKey(input);
currentKey = KeyProvider.getParentKey(operationKey);
SpeakerResponse speakerResponse = pullValue(input, FIELD_ID_PAYLOAD, SpeakerResponse.class);
try {
yFlowCreateService.handleAsyncResponse(currentKey, speakerResponse);
} catch (UnknownKeyException e) {
log.error("Received a response with unknown key {}.", currentKey);
}
}
use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.
the class YFlowRerouteHubBolt method onWorkerResponse.
@Override
protected void onWorkerResponse(Tuple input) throws PipelineException {
String operationKey = pullKey(input);
currentKey = KeyProvider.getParentKey(operationKey);
SpeakerResponse speakerResponse = pullValue(input, FIELD_ID_PAYLOAD, SpeakerResponse.class);
try {
yFlowRerouteService.handleAsyncResponse(currentKey, speakerResponse);
} catch (UnknownKeyException e) {
log.error("Received a response with unknown key {}.", currentKey);
}
}
use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.
the class YFlowDeleteService method handleAsyncResponse.
/**
* Handles async response from worker.
*
* @param key command identifier.
*/
public void handleAsyncResponse(@NonNull String key, @NonNull SpeakerResponse speakerResponse) throws UnknownKeyException {
log.debug("Received flow command response: {}", speakerResponse);
YFlowDeleteFsm fsm = fsmRegister.getFsmByKey(key).orElseThrow(() -> new UnknownKeyException(key));
if (speakerResponse instanceof SpeakerFlowSegmentResponse) {
SpeakerFlowSegmentResponse response = (SpeakerFlowSegmentResponse) speakerResponse;
String flowId = response.getMetadata().getFlowId();
if (fsm.getDeletingSubFlows().contains(flowId)) {
flowDeleteService.handleAsyncResponseByFlowId(flowId, response);
}
} else if (speakerResponse instanceof SpeakerCommandResponse) {
SpeakerCommandResponse response = (SpeakerCommandResponse) speakerResponse;
YFlowDeleteContext context = YFlowDeleteContext.builder().speakerResponse(response).build();
fsmExecutor.fire(fsm, Event.RESPONSE_RECEIVED, context);
} else {
log.debug("Received unexpected speaker response: {}", speakerResponse);
}
// After handling an event by FlowDelete services, we should propagate execution to the FSM.
if (!fsm.isTerminated()) {
fsmExecutor.fire(fsm, Event.NEXT);
}
removeIfFinished(fsm, key);
}
use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.
the class YFlowRerouteService method handleAsyncResponse.
/**
* Handles async response from worker.
*
* @param key command identifier.
*/
public void handleAsyncResponse(@NonNull String key, @NonNull SpeakerResponse speakerResponse) throws UnknownKeyException {
log.debug("Received flow command response {}", speakerResponse);
YFlowRerouteFsm fsm = fsmRegister.getFsmByKey(key).orElseThrow(() -> new UnknownKeyException(key));
if (speakerResponse instanceof SpeakerFlowSegmentResponse) {
SpeakerFlowSegmentResponse response = (SpeakerFlowSegmentResponse) speakerResponse;
String flowId = response.getMetadata().getFlowId();
if (fsm.getReroutingSubFlows().contains(flowId)) {
flowRerouteService.handleAsyncResponseByFlowId(flowId, response);
}
} else if (speakerResponse instanceof SpeakerCommandResponse) {
SpeakerCommandResponse response = (SpeakerCommandResponse) speakerResponse;
YFlowRerouteContext context = YFlowRerouteContext.builder().speakerResponse(response).build();
fsmExecutor.fire(fsm, Event.RESPONSE_RECEIVED, context);
} else {
log.debug("Received unexpected speaker response: {}", speakerResponse);
}
// After handling an event by FlowReroute service, we should propagate execution to the FSM.
if (!fsm.isTerminated()) {
fsmExecutor.fire(fsm, Event.NEXT);
}
removeIfFinished(fsm, key);
}
use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.
the class YFlowRerouteService method handleTimeout.
/**
* Handles timeout case.
*
* @param key command identifier.
*/
public void handleTimeout(@NonNull String key) throws UnknownKeyException {
log.debug("Handling timeout for {}", key);
YFlowRerouteFsm fsm = fsmRegister.getFsmByKey(key).orElseThrow(() -> new UnknownKeyException(key));
// Propagate timeout event to all sub-flow processing FSMs.
fsm.getReroutingSubFlows().forEach(flowId -> {
try {
flowRerouteService.handleTimeoutByFlowId(flowId);
} catch (UnknownKeyException e) {
log.error("Failed to handle a timeout event by FlowRerouteService for {}.", flowId);
}
});
fsmExecutor.fire(fsm, Event.TIMEOUT);
removeIfFinished(fsm, key);
}
Aggregations