use of org.openkilda.messaging.payload.flow.PathNodePayload in project open-kilda by telstra.
the class FlowSteps method getAvailableBandwidthAndSpeed.
@And("^get available bandwidth and maximum speed for flow (.*) and alias them as '(.*)' " + "and '(.*)' respectively$")
public void getAvailableBandwidthAndSpeed(String flowAlias, String bwAlias, String speedAlias) {
FlowPayload flow = topologyUnderTest.getAliasedObject(flowAlias);
List<PathNodePayload> flowPath = northboundService.getFlowPath(flow.getId()).getForwardPath();
List<IslInfoData> allLinks = northboundService.getAllLinks();
long minBw = Long.MAX_VALUE;
long minSpeed = Long.MAX_VALUE;
/*
Take flow path and all links. Now for every pair in flow path find a link.
Take minimum available bandwidth and minimum available speed from those links
(flow's speed and left bandwidth depends on the weakest isl)
*/
for (int i = 1; i < flowPath.size(); i++) {
PathNodePayload from = flowPath.get(i - 1);
PathNodePayload to = flowPath.get(i);
IslInfoData isl = allLinks.stream().filter(link -> link.getSource().getSwitchId().equals(from.getSwitchId()) && link.getDestination().getSwitchId().equals(to.getSwitchId())).findFirst().orElseThrow(() -> new IllegalStateException(format("Isl from %s to %s not found.", from.getSwitchId(), to.getSwitchId())));
minBw = Math.min(isl.getAvailableBandwidth(), minBw);
minSpeed = Math.min(isl.getSpeed(), minSpeed);
}
topologyUnderTest.addAlias(bwAlias, minBw);
topologyUnderTest.addAlias(speedAlias, minSpeed);
}
use of org.openkilda.messaging.payload.flow.PathNodePayload in project open-kilda by telstra.
the class FlowCacheServiceTest method shouldChangeFlowPathInCache.
@Test
public void shouldChangeFlowPathInCache() {
Flow flow = createFlow();
when(clock.instant()).thenReturn(Instant.now());
service = new FlowCacheService(persistenceManager, clock, FLOW_RTT_STATS_EXPIRATION_TIME, carrier);
Long maxLatency = 100L;
Long maxLatencyTier2 = 200L;
UpdateFlowCommand updateFlowCommand = new UpdateFlowCommand(flow.getFlowId(), FlowPathDto.builder().id(flow.getFlowId()).forwardPath(Arrays.asList(new PathNodePayload(SRC_SWITCH, IN_PORT, ISL_SRC_PORT_2), new PathNodePayload(DST_SWITCH, ISL_DST_PORT_2, OUT_PORT))).reversePath(Arrays.asList(new PathNodePayload(DST_SWITCH, OUT_PORT, ISL_DST_PORT_2), new PathNodePayload(SRC_SWITCH, ISL_SRC_PORT_2, IN_PORT))).build(), maxLatency, maxLatencyTier2);
service.updateFlowInfo(updateFlowCommand);
service.processFlowLatencyCheck(flow.getFlowId());
List<Link> expectedForwardPath = getLinks(SRC_SWITCH, ISL_SRC_PORT_2, DST_SWITCH, ISL_DST_PORT_2);
verify(carrier).emitCalculateFlowLatencyRequest(flow.getFlowId(), FlowDirection.FORWARD, expectedForwardPath);
List<Link> expectedReversePath = reverse(expectedForwardPath);
verify(carrier).emitCalculateFlowLatencyRequest(flow.getFlowId(), FlowDirection.REVERSE, expectedReversePath);
verifyNoMoreInteractions(carrier);
}
Aggregations