use of org.openkilda.messaging.model.FlowDto in project open-kilda by telstra.
the class OnFinishedWithErrorAction method performWithResponse.
@Override
protected Optional<Message> performWithResponse(State from, State to, Event event, FlowSwapEndpointsContext context, FlowSwapEndpointsFsm stateMachine) {
ErrorData data;
if (Event.TIMEOUT.equals(event)) {
data = new ErrorData(ErrorType.OPERATION_TIMED_OUT, getGenericErrorMessage(), "Flow swap endpoints failed by timeout");
} else if (Event.NEXT.equals(event)) {
List<String> flows = stateMachine.getFlowResponses().stream().map(FlowResponse::getPayload).map(FlowDto::getFlowId).collect(Collectors.toList());
data = new ErrorData(ErrorType.UPDATE_FAILURE, getGenericErrorMessage(), format("Reverted flows: %s", flows));
} else {
data = (ErrorData) context.getResponse();
}
if (!Event.VALIDATION_ERROR.equals(event)) {
saveActionToHistory(stateMachine, stateMachine.getFirstFlowId(), stateMachine.getSecondFlowId(), data.getErrorDescription());
saveActionToHistory(stateMachine, stateMachine.getSecondFlowId(), stateMachine.getFirstFlowId(), data.getErrorDescription());
}
updateFlowsStatuses(stateMachine);
CommandContext commandContext = stateMachine.getCommandContext();
return Optional.of(new ErrorMessage(data, commandContext.getCreateTime(), commandContext.getCorrelationId()));
}
use of org.openkilda.messaging.model.FlowDto in project open-kilda by telstra.
the class StubServiceFactory method putFlow.
private void putFlow(String flowId, FlowPayload flowPayload) {
flowPayloads.put(flowId, flowPayload);
FlowDto forwardFlow = new FlowDto(flowPayload);
forwardFlow.setMeterId(meterCounter++);
FlowDto reverseFlow = forwardFlow.toBuilder().sourceSwitch(forwardFlow.getDestinationSwitch()).sourcePort(forwardFlow.getDestinationPort()).sourceVlan(forwardFlow.getDestinationVlan()).destinationSwitch(forwardFlow.getSourceSwitch()).destinationPort(forwardFlow.getSourcePort()).destinationVlan(forwardFlow.getSourceVlan()).build();
flows.put(flowId, new FlowPairDto<>(forwardFlow, reverseFlow));
}
use of org.openkilda.messaging.model.FlowDto in project open-kilda by telstra.
the class FlowMapperTest method testStatusDetailsMapping.
@Test
public void testStatusDetailsMapping() {
Flow flow = buildFlow();
FlowDto flowDto = FlowMapper.INSTANCE.map(flow);
assertNotNull(flowDto.getFlowStatusDetails());
assertEquals(FlowPathStatus.ACTIVE, flowDto.getFlowStatusDetails().getMainFlowPathStatus());
assertEquals(FlowPathStatus.INACTIVE, flowDto.getFlowStatusDetails().getProtectedFlowPathStatus());
assertDetectConnectedDevices(flowDto.getDetectConnectedDevices(), flow.getDetectConnectedDevices());
}
use of org.openkilda.messaging.model.FlowDto in project open-kilda by telstra.
the class FlowServiceTest method createFlowLoop.
@Test
public void createFlowLoop() throws Exception {
String correlationId = "correlation-id";
RequestCorrelationId.create(correlationId);
String flowId = "flow-id";
SwitchId switchId = new SwitchId("1");
FlowDto dto = FlowDto.builder().flowId(flowId).loopSwitchId(switchId).build();
FlowResponse response = new FlowResponse(dto);
messageExchanger.mockResponse(correlationId, response);
FlowLoopResponse result = flowService.createFlowLoop(flowId, switchId).get();
assertEquals(flowId, result.getFlowId());
assertEquals(switchId, result.getSwitchId());
}
Aggregations