use of org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException in project open-kilda by telstra.
the class FlowValidationHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = pullKey(input);
FlowValidationRequest payload = pullValue(input, FIELD_ID_PAYLOAD, FlowValidationRequest.class);
try {
service.handleFlowValidationRequest(currentKey, getCommandContext(), 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 YFlowCreateHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = pullKey(input);
YFlowRequest payload = pullValue(input, FIELD_ID_PAYLOAD, YFlowRequest.class);
try {
yFlowCreateService.handleRequest(currentKey, getCommandContext(), 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 YFlowUpdateHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = pullKey(input);
CommandData payload = pullValue(input, FIELD_ID_PAYLOAD, CommandData.class);
try {
if (payload instanceof YFlowRequest) {
yflowUpdateService.handleRequest(currentKey, pullContext(input), (YFlowRequest) payload);
} else if (payload instanceof YFlowPartialUpdateRequest) {
yflowUpdateService.handlePartialUpdateRequest(currentKey, pullContext(input), (YFlowPartialUpdateRequest) payload);
} else {
unhandledInput(input);
}
} catch (DuplicateKeyException e) {
log.error("Failed to handle a request with key {}. {}", currentKey, e.getMessage());
} catch (FlowProcessingException e) {
ErrorData errorData = new ErrorData(e.getErrorType(), "Y-flow update error", e.getMessage());
CommandContext commandContext = getCommandContext();
ErrorMessage errorMessage = new ErrorMessage(errorData, commandContext.getCreateTime(), commandContext.getCorrelationId());
sendNorthboundResponse(errorMessage);
}
}
use of org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException in project open-kilda by telstra.
the class FlowCreateHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = pullKey(input);
FlowRequest payload = pullValue(input, FIELD_ID_PAYLOAD, FlowRequest.class);
try {
service.handleRequest(currentKey, getCommandContext(), 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 YFlowValidationHubServiceTest method shouldValidateAndFailIfSubFlowHasMissingRule.
@Test
public void shouldValidateAndFailIfSubFlowHasMissingRule() throws DuplicateKeyException {
// given
String yFlowId = "test_y_flow_1";
YFlow yFlow = createYFlowViaTransit(yFlowId);
YSubFlow failedSubFlow = yFlow.getSubFlows().stream().findFirst().orElseThrow(IllegalStateException::new);
Flow failedFlow = failedSubFlow.getFlow();
YFlowSwitchFlowEntriesBuilder flowEntriesBuilder = new YFlowSwitchFlowEntriesBuilder(yFlow, persistenceManager.getRepositoryFactory().createTransitVlanRepository(), persistenceManager.getRepositoryFactory().createVxlanRepository());
Map<SwitchId, Collection<FlowEntry>> flowEntries = flowEntriesBuilder.getFlowEntries();
flowEntries.forEach((s, f) -> f.removeIf(entry -> entry.getCookie() == failedFlow.getForwardPath().getCookie().getValue()));
Map<SwitchId, Collection<MeterEntry>> meterEntries = flowEntriesBuilder.getMeterEntries();
Map<SwitchId, Collection<GroupEntry>> groupEntries = flowEntriesBuilder.getGroupEntries();
YFlowValidationHubService service = makeYFlowValidationHubService();
service.handleRequest(yFlow.getYFlowId(), new CommandContext(), yFlow.getYFlowId());
// when
handleSpeakerRequests(service, yFlowId, flowEntries, meterEntries, groupEntries);
// then
YFlowValidationResponse response = getNorthboundResponse(yFlowValidationHubCarrier);
assertFalse(response.isAsExpected());
assertFalse(response.getYFlowValidationResult().isAsExpected());
response.getSubFlowValidationResults().forEach(result -> assertTrue(result.getFlowId().equals(failedFlow.getFlowId()) || result.getAsExpected()));
assertEquals(1, response.getSubFlowValidationResults().stream().filter(r -> !r.getAsExpected()).count());
}
Aggregations