use of org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException in project open-kilda by telstra.
the class YFlowRerouteHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = pullKey(input);
YFlowRerouteRequest payload = pullValue(input, FIELD_ID_PAYLOAD, YFlowRerouteRequest.class);
try {
yFlowRerouteService.handleRequest(currentKey, pullContext(input), payload);
} catch (DuplicateKeyException e) {
log.error("Failed to handle a request with key {}. {}", currentKey, e.getMessage());
}
}
use of org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException in project open-kilda by telstra.
the class FlowDeleteHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = pullKey(input);
FlowDeleteRequest request = pullValue(input, FIELD_ID_PAYLOAD, FlowDeleteRequest.class);
try {
service.handleRequest(currentKey, getCommandContext(), request.getFlowId());
} catch (DuplicateKeyException e) {
log.error("Failed to handle a request with key {}. {}", currentKey, e.getMessage());
}
}
use of org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException in project open-kilda by telstra.
the class FlowUpdateHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = input.getStringByField(MessageKafkaTranslator.FIELD_ID_KEY);
Object payload = input.getValueByField(FIELD_ID_PAYLOAD);
try {
if (payload instanceof FlowRequest) {
FlowRequest flowRequest = (FlowRequest) payload;
service.handleUpdateRequest(currentKey, pullContext(input), flowRequest);
} else if (payload instanceof CreateFlowLoopRequest) {
CreateFlowLoopRequest flowLoopRequest = (CreateFlowLoopRequest) payload;
service.handleCreateFlowLoopRequest(currentKey, pullContext(input), flowLoopRequest);
} else if (payload instanceof DeleteFlowLoopRequest) {
DeleteFlowLoopRequest flowLoopRequest = (DeleteFlowLoopRequest) payload;
service.handleDeleteFlowLoopRequest(currentKey, pullContext(input), flowLoopRequest);
} else {
unhandledInput(input);
}
} catch (DuplicateKeyException e) {
log.error("Failed to handle a request with key {}. {}", currentKey, e.getMessage());
}
}
use of org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException in project open-kilda by telstra.
the class FlowUpdateService method startFlowUpdating.
private void startFlowUpdating(String key, CommandContext commandContext, RequestedFlow request, boolean doNotRevert, Set<String> bulkUpdateFlowIds, String sharedBandwidthGroupId) throws DuplicateKeyException {
String flowId = request.getFlowId();
log.debug("Handling flow update request with key {} and flow ID: {}", key, request.getFlowId());
if (fsmRegister.hasRegisteredFsmWithKey(key)) {
throw new DuplicateKeyException(key, "There's another active FSM with the same key");
}
if (fsmRegister.hasRegisteredFsmWithFlowId(flowId)) {
sendErrorResponseToNorthbound(ErrorType.REQUEST_INVALID, "Could not update flow", format("Flow %s is updating now", flowId), commandContext);
log.error("Attempt to create a FSM with key {}, while there's another active FSM for the same flowId {}.", key, flowId);
return;
}
FlowUpdateFsm fsm = fsmFactory.newInstance(request.getFlowId(), commandContext, eventListeners);
fsm.setSharedBandwidthGroupId(sharedBandwidthGroupId);
fsmRegister.registerFsm(key, fsm);
if (request.getFlowEncapsulationType() == null) {
request.setFlowEncapsulationType(kildaConfigurationRepository.getOrDefault().getFlowEncapsulationType());
}
FlowUpdateContext context = FlowUpdateContext.builder().targetFlow(request).doNotRevert(doNotRevert).bulkUpdateFlowIds(bulkUpdateFlowIds).build();
fsmExecutor.fire(fsm, Event.NEXT, context);
removeIfFinished(fsm, key);
}
use of org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException in project open-kilda by telstra.
the class YFlowRerouteService method handleRequest.
/**
* Handles request for y-flow rerouting.
*
* @param key command identifier.
* @param request request data.
*/
public void handleRequest(@NonNull String key, @NonNull CommandContext commandContext, @NonNull YFlowRerouteRequest request) throws DuplicateKeyException {
String yFlowId = request.getYFlowId();
log.debug("Handling y-flow reroute request with key {} and flow ID: {}", key, request.getYFlowId());
if (fsmRegister.hasRegisteredFsmWithKey(key)) {
throw new DuplicateKeyException(key, "There's another active FSM with the same key");
}
if (fsmRegister.hasRegisteredFsmWithFlowId(yFlowId)) {
sendErrorResponseToNorthbound(ErrorType.ALREADY_EXISTS, "Could not reroute y-flow", format("Y-flow %s is already rerouting now", yFlowId), commandContext);
return;
}
YFlowRerouteFsm fsm = fsmFactory.newInstance(commandContext, request.getYFlowId(), eventListeners);
fsmRegister.registerFsm(key, fsm);
YFlowRerouteContext context = YFlowRerouteContext.builder().rerouteRequest(request).build();
fsm.start(context);
fsmExecutor.fire(fsm, Event.NEXT, context);
removeIfFinished(fsm, key);
}
Aggregations