use of org.openkilda.messaging.model.FlowDto in project open-kilda by telstra.
the class FlowMapperTest method testMirrorPointStatusesMapping.
@Test
public void testMirrorPointStatusesMapping() {
Flow flow = buildFlow();
FlowDto flowDto = FlowMapper.INSTANCE.map(flow, new HashSet<>(), new HashSet<>(), buildFlowMirrorPathList());
assertNotNull(flowDto.getMirrorPointStatuses());
assertEquals(2, flowDto.getMirrorPointStatuses().size());
assertEquals(MIRROR_PATH_ID_A.getId(), flowDto.getMirrorPointStatuses().get(0).getMirrorPointId());
assertEquals(FLOW_PATH_STATUS_A.toString().toLowerCase(), flowDto.getMirrorPointStatuses().get(0).getStatus());
assertEquals(MIRROR_PATH_ID_B.getId(), flowDto.getMirrorPointStatuses().get(1).getMirrorPointId());
assertEquals(FLOW_PATH_STATUS_B.toString().toLowerCase(), flowDto.getMirrorPointStatuses().get(1).getStatus());
}
use of org.openkilda.messaging.model.FlowDto in project open-kilda by telstra.
the class FlowMapperTest method testFlowPairToDto.
@Test
public void testFlowPairToDto() {
PathInfoData pathInfoData = new PathInfoData();
pathInfoData.setLatency(1L);
pathInfoData.setPath(asList(new PathNode(SRC_SWITCH_ID, 1, 1, 1L, 1L), new PathNode(DST_SWITCH_ID, 2, 2, 2L, 2L)));
FlowDto forwardFlow = new FlowDto();
forwardFlow.setSourceSwitch(SRC_SWITCH_ID);
forwardFlow.setDestinationSwitch(DST_SWITCH_ID);
forwardFlow.setFlowId("12");
forwardFlow.setCookie(11);
forwardFlow.setSourcePort(113);
forwardFlow.setSourceVlan(1112);
forwardFlow.setDestinationPort(113);
forwardFlow.setDestinationVlan(1112);
forwardFlow.setBandwidth(23);
forwardFlow.setDescription("SOME FLOW");
forwardFlow.setLastUpdated("2011-12-03T10:15:30Z");
forwardFlow.setTransitEncapsulationId(87);
forwardFlow.setMeterId(65);
forwardFlow.setIgnoreBandwidth(true);
forwardFlow.setPeriodicPings(true);
forwardFlow.setEncapsulationType(FlowEncapsulationType.TRANSIT_VLAN);
forwardFlow.setDetectConnectedDevices(new DetectConnectedDevicesDto(false, true, true, false, false, false, true, true));
PathInfoData reversePathInfoData = new PathInfoData();
reversePathInfoData.setLatency(1L);
reversePathInfoData.setPath(asList(new PathNode(DST_SWITCH_ID, 2, 2, 2L, 2L), new PathNode(SRC_SWITCH_ID, 1, 1, 1L, 1L)));
FlowDto reverseFlow = new FlowDto();
reverseFlow.setSourceSwitch(forwardFlow.getDestinationSwitch());
reverseFlow.setDestinationSwitch(SRC_SWITCH_ID);
reverseFlow.setFlowId("12");
reverseFlow.setCookie(12);
reverseFlow.setSourcePort(113);
reverseFlow.setSourceVlan(1112);
reverseFlow.setDestinationPort(113);
reverseFlow.setDestinationVlan(1112);
reverseFlow.setBandwidth(23);
reverseFlow.setDescription("SOME FLOW");
reverseFlow.setLastUpdated("2011-12-03T10:15:30Z");
reverseFlow.setTransitEncapsulationId(88);
reverseFlow.setMeterId(66);
reverseFlow.setIgnoreBandwidth(true);
reverseFlow.setPeriodicPings(true);
reverseFlow.setEncapsulationType(FlowEncapsulationType.TRANSIT_VLAN);
reverseFlow.setDetectConnectedDevices(new DetectConnectedDevicesDto(true, false, false, true, false, false, true, true));
FlowPairDto<FlowDto, FlowDto> pair = new FlowPairDto<>(forwardFlow, reverseFlow);
Flow p = FlowMapper.INSTANCE.map(pair, () -> KildaConfiguration.DEFAULTS);
assertEquals(p.getFlowId(), pair.getLeft().getFlowId());
assertDetectConnectedDevices(forwardFlow.getDetectConnectedDevices(), p.getDetectConnectedDevices());
}
use of org.openkilda.messaging.model.FlowDto in project open-kilda by telstra.
the class FlowMapper method map.
/**
* Convert {@link FlowDto} to {@link Flow}.
* If encapsulation type and/or path computation strategy is not provided then values from KildaConfiguration
* will be used.
*/
public Flow map(FlowDto flow, Supplier<KildaConfiguration> kildaConfiguration) {
Switch srcSwitch = Switch.builder().switchId(flow.getSourceSwitch()).build();
Switch destSwitch = Switch.builder().switchId(flow.getDestinationSwitch()).build();
return Flow.builder().flowId(flow.getFlowId()).srcSwitch(srcSwitch).destSwitch(destSwitch).srcPort(flow.getSourcePort()).destPort(flow.getDestinationPort()).srcVlan(flow.getSourceVlan()).destVlan(flow.getDestinationVlan()).status(map(flow.getState())).statusInfo(flow.getStatusInfo()).description(flow.getDescription()).bandwidth(flow.getBandwidth()).ignoreBandwidth(flow.isIgnoreBandwidth()).periodicPings(Boolean.TRUE.equals(flow.getPeriodicPings())).allocateProtectedPath(flow.isAllocateProtectedPath()).encapsulationType(Optional.ofNullable(flow.getEncapsulationType()).map(encapsulationType -> FlowEncapsulationType.valueOf(encapsulationType.name())).orElse(kildaConfiguration.get().getFlowEncapsulationType())).pathComputationStrategy(Optional.ofNullable(flow.getPathComputationStrategy()).map(pathComputationStrategy -> PathComputationStrategy.valueOf(pathComputationStrategy.name())).orElse(kildaConfiguration.get().getPathComputationStrategy())).maxLatency(flow.getMaxLatency()).priority(flow.getPriority()).pinned(flow.isPinned()).detectConnectedDevices(DetectConnectedDevicesMapper.INSTANCE.map(flow.getDetectConnectedDevices())).build();
}
use of org.openkilda.messaging.model.FlowDto in project open-kilda by telstra.
the class FlowMapper method map.
/**
* Convert {@link Flow} to {@link FlowDto} with diverse flow ids, mirror paths and flow properties.
*/
public FlowDto map(Flow flow, Set<String> diverseWith, Set<String> diverseWithYFlows, List<FlowMirrorPath> flowMirrorPaths, FlowStats flowStats) {
FlowDto flowDto = map(flow);
flowDto.setDiverseWith(diverseWith);
flowDto.setDiverseWithYFlows(diverseWithYFlows);
flowDto.setMirrorPointStatuses(map(flowMirrorPaths));
flowDto.setForwardLatency(flowStats.getForwardLatency());
flowDto.setReverseLatency(flowStats.getReverseLatency());
flowDto.setLatencyLastModifiedTime(flowStats.getTimeModify());
return flowDto;
}
use of org.openkilda.messaging.model.FlowDto in project open-kilda by telstra.
the class FlowServiceTest method swapFlowEndpoint.
@Test
public void swapFlowEndpoint() throws Exception {
String correlationId = "bulk-flow-update";
RequestCorrelationId.create(correlationId);
String firstFlowId = "bulk-flow-1";
String secondFlowId = "bulk-flow-2";
FlowEndpointV2 firstEndpoint = new FlowEndpointV2(new SwitchId("ff:00"), 1, 1, new DetectConnectedDevicesV2(false, false));
FlowEndpointV2 secondEndpoint = new FlowEndpointV2(new SwitchId("ff:01"), 2, 2, new DetectConnectedDevicesV2(false, false));
SwapFlowPayload firstFlowPayload = SwapFlowPayload.builder().flowId(firstFlowId).source(firstEndpoint).destination(firstEndpoint).build();
SwapFlowPayload secondFlowPayload = SwapFlowPayload.builder().flowId(secondFlowId).source(secondEndpoint).destination(secondEndpoint).build();
SwapFlowEndpointPayload input = new SwapFlowEndpointPayload(firstFlowPayload, secondFlowPayload);
FlowDto firstResponse = FlowDto.builder().flowId(firstFlowId).bandwidth(10000).description(firstFlowId).state(FlowState.UP).sourceSwitch(new SwitchId("ff:00")).sourcePort(1).sourceVlan(1).destinationSwitch(new SwitchId("ff:01")).destinationPort(2).destinationVlan(2).build();
FlowDto secondResponse = FlowDto.builder().flowId(secondFlowId).bandwidth(20000).description(secondFlowId).state(FlowState.UP).sourceSwitch(new SwitchId("ff:01")).sourcePort(2).sourceVlan(2).destinationSwitch(new SwitchId("ff:00")).destinationPort(1).destinationVlan(1).build();
SwapFlowResponse response = new SwapFlowResponse(new FlowResponse(firstResponse), new FlowResponse(secondResponse));
messageExchanger.mockResponse(correlationId, response);
SwapFlowEndpointPayload result = flowService.swapFlowEndpoint(input).get();
assertEquals(secondEndpoint, result.getFirstFlow().getDestination());
assertEquals(firstEndpoint, result.getSecondFlow().getDestination());
}
Aggregations