use of org.openkilda.messaging.info.event.IslRoundTripLatency in project open-kilda by telstra.
the class IslStatsServiceTest method sendReverseRoundTripLatency.
private void sendReverseRoundTripLatency(int latency, Instant time) {
IslRoundTripLatency islRoundTripLatency = new IslRoundTripLatency(SWITCH_ID_2, PORT_2, latency, 0L);
islStatsService.handleRoundTripLatencyMetric(time.toEpochMilli(), islRoundTripLatency, REVERSE_DESTINATION);
}
use of org.openkilda.messaging.info.event.IslRoundTripLatency in project open-kilda by telstra.
the class IslStatsServiceTest method sendForwardRoundTripLatency.
private void sendForwardRoundTripLatency(int latency, Instant time) {
IslRoundTripLatency islRoundTripLatency = new IslRoundTripLatency(SWITCH_ID_1, PORT_1, latency, 0L);
islStatsService.handleRoundTripLatencyMetric(time.toEpochMilli(), islRoundTripLatency, FORWARD_DESTINATION);
}
use of org.openkilda.messaging.info.event.IslRoundTripLatency in project open-kilda by telstra.
the class IslCacheService method handleRoundTripLatency.
/**
* Update RTT latency for ISL.
*/
public void handleRoundTripLatency(IslRoundTripLatency data) {
List<Link> links = linkStates.keySet().stream().filter(link -> link.srcEquals(data.getSrcSwitchId(), data.getSrcPortNo())).collect(Collectors.toList());
Instant instant = clock.instant();
links.forEach(link -> {
LinkState linkState = linkStates.get(link);
if (linkState == null) {
linkStates.put(link, LinkState.builder().rttLatency(data.getLatency()).rttTimestamp(instant).build());
} else {
linkState.setRttLatency(data.getLatency());
linkState.setRttTimestamp(instant);
}
});
}
use of org.openkilda.messaging.info.event.IslRoundTripLatency in project open-kilda by telstra.
the class IslCacheServiceTest method shouldGetLatencyForLinkWithExpiredRttValue.
@Test
public void shouldGetLatencyForLinkWithExpiredRttValue() {
long oneWayLatency = 100L;
long rttLatency = 1000L;
IslOneWayLatency islOneWayLatency = new IslOneWayLatency(FIRST_SWITCH, ISL_SRC_PORT, SECOND_SWITCH, ISL_DST_PORT, oneWayLatency, 1L);
IslRoundTripLatency islRoundTripLatency = new IslRoundTripLatency(FIRST_SWITCH, ISL_SRC_PORT, rttLatency, 1L);
Instant start = Instant.now();
when(clock.instant()).thenReturn(start).thenReturn(start.plus(2, ChronoUnit.SECONDS).plus(ISL_RTT_LATENCY_EXPIRATION));
service.handleOneWayLatency(islOneWayLatency);
service.handleRoundTripLatency(islRoundTripLatency);
long actual = service.getLatencyForLink(LINK).getNano();
assertEquals(oneWayLatency, actual);
}
use of org.openkilda.messaging.info.event.IslRoundTripLatency in project open-kilda by telstra.
the class IslLatencyBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws PipelineException {
InfoData data = pullValue(input, LATENCY_DATA_FIELD, InfoData.class);
long timestamp = getCommandContext().getCreateTime();
if (data instanceof IslRoundTripLatency) {
Endpoint destination = pullValue(input, CACHE_DATA_FIELD, Endpoint.class);
islLatencyService.handleRoundTripIslLatency((IslRoundTripLatency) data, destination, timestamp);
} else if (data instanceof IslOneWayLatency) {
islLatencyService.handleOneWayIslLatency((IslOneWayLatency) data, timestamp);
} else {
unhandledInput(input);
}
}
Aggregations