use of org.openkilda.wfm.topology.isllatency.model.LatencyRecord in project open-kilda by telstra.
the class IslStatsServiceTest method handleOneWayLatencyCollectsRecordsUntilTimeoutTest.
@Test
public void handleOneWayLatencyCollectsRecordsUntilTimeoutTest() {
// RTL: .....................
// OneWay: ..X.X.X.X.X.X.X.X....
// Timeout: ...|_____________|...
List<LatencyRecord> buffer = new ArrayList<>();
Instant time = Instant.now().minusSeconds(LATENCY_TIMEOUT).minusMillis(500);
for (int i = 0; i <= LATENCY_TIMEOUT; i++) {
sendForwardOneWayLatency(i, time);
// waiting for timeout and collecting one way records
verifyNoMoreInteractions(carrier);
buffer.add(new LatencyRecord(i, time.toEpochMilli()));
time = time.plusSeconds(1);
}
// first record is outdated and we must not emit it
buffer.remove(0);
// first record after timeout
// we received enough latency records and all stored records will be flushed
sendForwardOneWayLatency(100, time);
buffer.add(new LatencyRecord(100, time.toEpochMilli()));
// ISL down notification must flush one way latency storage
assertEmitLatency(buffer);
}
use of org.openkilda.wfm.topology.isllatency.model.LatencyRecord in project open-kilda by telstra.
the class IslStatsServiceTest method handleOneWayLatencyEmitOnIslDownTest.
@Test
public void handleOneWayLatencyEmitOnIslDownTest() {
// RTL: ...........................
// OneWay: ..X.X.X.X..................
// Timeout: ...|____________|..........
// ISL down: .........^.................
List<LatencyRecord> buffer = new ArrayList<>();
Instant time = Instant.now().minusSeconds(LATENCY_TIMEOUT).minusMillis(500);
for (int i = 0; i < 4; i++) {
sendForwardOneWayLatency(i, time);
// waiting for timeout and collecting one way records
verifyNoMoreInteractions(carrier);
buffer.add(new LatencyRecord(i, time.toEpochMilli()));
time = time.plusSeconds(1);
}
// first record is outdated and we must not emit it
buffer.remove(0);
islStatsService.handleIstStatusUpdateNotification(new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE));
assertEmitLatency(buffer);
}
use of org.openkilda.wfm.topology.isllatency.model.LatencyRecord in project open-kilda by telstra.
the class IslLatencyService method handleRoundTripIslLatency.
/**
* Handle round trip latency.
*
* @param data round trip latency info data
* @param destination isl destination endpoint
* @param timestamp latency timestamp
*/
public void handleRoundTripIslLatency(IslRoundTripLatency data, Endpoint destination, long timestamp) {
if (data.getLatency() < 0) {
log.warn("Received invalid round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}. Origin: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId(), data.getOrigin());
return;
}
log.debug("Received round trip latency {} for ISL {}_{} ===> {}_{}. Packet Id: {}. Origin: {}", data.getLatency(), data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getPacketId(), data.getOrigin());
IslKey islKey = new IslKey(data, destination);
roundTripLatencyStorage.putIfAbsent(islKey, new LinkedList<>());
roundTripLatencyStorage.get(islKey).add(new LatencyRecord(data.getLatency(), timestamp));
if (isUpdateRequired(islKey) || !roundTripLatencyIsSet.contains(islKey)) {
updateRoundTripLatency(data, destination, islKey);
}
}
use of org.openkilda.wfm.topology.isllatency.model.LatencyRecord in project open-kilda by telstra.
the class IslLatencyServiceTest method pollExpiredRecordsTest.
@Test
public void pollExpiredRecordsTest() {
Instant time = Instant.now().minusSeconds(LATENCY_UPDATE_TIME_RANGE * 2);
Queue<LatencyRecord> latencyRecords = new LinkedList<>();
for (int i = 0; i < 5; i++) {
latencyRecords.add(new LatencyRecord(i, time.toEpochMilli()));
time = time.plusSeconds(1);
}
time = Instant.now().minusSeconds(LATENCY_UPDATE_TIME_RANGE - 7);
for (int i = 5; i < 10; i++) {
latencyRecords.add(new LatencyRecord(i, time.toEpochMilli()));
time = time.plusSeconds(1);
}
assertEquals(10, latencyRecords.size());
islLatencyService.pollExpiredRecords(latencyRecords);
assertEquals(5, latencyRecords.size());
for (int i = 5; i < 10; i++) {
assertEquals(i, latencyRecords.poll().getLatency());
}
}
Aggregations