use of org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException in project open-kilda by telstra.
the class YFlowValidationHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = pullKey(input);
YFlowValidationRequest payload = pullValue(input, FIELD_ID_PAYLOAD, YFlowValidationRequest.class);
try {
yFlowValidationHubService.handleRequest(currentKey, getCommandContext(), payload.getYFlowId());
} 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 YFlowDeleteService method handleRequest.
/**
* Handles request for y-flow deletion.
*
* @param key command identifier.
* @param request request data.
*/
public void handleRequest(@NonNull String key, @NonNull CommandContext commandContext, @NonNull YFlowDeleteRequest request) throws DuplicateKeyException {
String yFlowId = request.getYFlowId();
log.debug("Handling y-flow delete request with key {} and yFlowId {}", key, yFlowId);
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 delete y-flow", format("Y-flow %s is already creating now", yFlowId), commandContext);
return;
}
YFlowDeleteFsm fsm = fsmFactory.newInstance(commandContext, yFlowId, eventListeners);
fsmRegister.registerFsm(key, fsm);
YFlowDeleteContext context = YFlowDeleteContext.builder().build();
fsm.start(context);
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 YFlowUpdateService method handleRequest.
/**
* Handles request for y-flow updating.
*
* @param key command identifier.
* @param request request data.
*/
public void handleRequest(@NonNull String key, @NonNull CommandContext commandContext, @NonNull YFlowRequest request) throws DuplicateKeyException {
String yFlowId = request.getYFlowId();
log.debug("Handling y-flow update 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 update y-flow", format("Y-flow %s is already updating now", yFlowId), commandContext);
log.error("Attempt to create a FSM with key {}, while there's another active FSM for the same yFlowId {}.", key, yFlowId);
return;
}
if (yFlowId == null) {
yFlowId = generateFlowId(prefixForGeneratedYFlowId);
request.setYFlowId(yFlowId);
}
request.getSubFlows().forEach(subFlow -> {
if (subFlow.getFlowId() == null) {
subFlow.setFlowId(generateFlowId(prefixForGeneratedSubFlowId));
}
});
if (request.getEncapsulationType() == null) {
request.setEncapsulationType(kildaConfigurationRepository.getOrDefault().getFlowEncapsulationType());
}
if (request.getPathComputationStrategy() == null) {
request.setPathComputationStrategy(kildaConfigurationRepository.getOrDefault().getPathComputationStrategy());
}
YFlowUpdateFsm fsm = fsmFactory.newInstance(commandContext, yFlowId, eventListeners);
fsmRegister.registerFsm(key, fsm);
YFlowUpdateContext context = YFlowUpdateContext.builder().targetFlow(request).build();
fsm.start(context);
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 YFlowCreateService method handleRequest.
/**
* Handles request for y-flow creation.
*
* @param key command identifier.
* @param request request data.
*/
public void handleRequest(@NonNull String key, @NonNull CommandContext commandContext, @NonNull YFlowRequest request) throws DuplicateKeyException {
String yFlowId = request.getYFlowId();
log.debug("Handling y-flow create request with key {} and yFlowId {}", key, yFlowId);
if (fsmRegister.hasRegisteredFsmWithKey(key)) {
throw new DuplicateKeyException(key, "There's another active FSM with the same key");
}
if (yFlowId == null) {
yFlowId = generateFlowId(prefixForGeneratedYFlowId);
request.setYFlowId(yFlowId);
} else if (fsmRegister.hasRegisteredFsmWithFlowId(yFlowId)) {
sendErrorResponseToNorthbound(ErrorType.ALREADY_EXISTS, "Could not create y-flow", format("Y-flow %s is already creating now", yFlowId), commandContext);
return;
}
request.getSubFlows().forEach(subFlow -> {
if (subFlow.getFlowId() == null) {
subFlow.setFlowId(generateFlowId(prefixForGeneratedSubFlowId));
}
});
if (request.getEncapsulationType() == null) {
request.setEncapsulationType(kildaConfigurationRepository.getOrDefault().getFlowEncapsulationType());
}
if (request.getPathComputationStrategy() == null) {
request.setPathComputationStrategy(kildaConfigurationRepository.getOrDefault().getPathComputationStrategy());
}
YFlowCreateFsm fsm = fsmFactory.newInstance(commandContext, yFlowId, eventListeners);
fsmRegister.registerFsm(key, fsm);
YFlowCreateContext context = YFlowCreateContext.builder().targetFlow(request).build();
fsm.start(context);
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 FlowValidationHubService method startFlowValidation.
private void startFlowValidation(@NonNull String key, @NonNull CommandContext commandContext, @NonNull String flowId) throws DuplicateKeyException {
log.debug("Handling flow validation request with key {} and flow ID: {}", key, flowId);
if (fsmRegister.hasRegisteredFsmWithKey(key)) {
throw new DuplicateKeyException(key, "There's another active FSM with the same key");
}
FlowValidationFsm fsm = fsmFactory.newInstance(flowId, commandContext, eventListeners);
fsmRegister.registerFsm(key, fsm);
fsm.start();
fsmExecutor.fire(fsm, Event.NEXT, flowId);
removeIfFinished(fsm, key);
}
Aggregations