use of org.openkilda.wfm.topology.isllatency.model.LatencyRecord in project open-kilda by telstra.
the class IslLatencyServiceTest method calculateAverageLatencyTest.
@Test
public void calculateAverageLatencyTest() {
Queue<LatencyRecord> latencyRecords = new LinkedList<>();
for (int i = 1; i <= 5; i++) {
latencyRecords.add(new LatencyRecord(i, 1));
}
assertEquals(3, islLatencyService.calculateAverageLatency(latencyRecords));
}
use of org.openkilda.wfm.topology.isllatency.model.LatencyRecord in project open-kilda by telstra.
the class IslStatsServiceTest method handleOneWayLatencyEmitByOneAfterTimeoutTest.
@Test
public void handleOneWayLatencyEmitByOneAfterTimeoutTest() {
// RTL: ...........................
// OneWay: ..X.X.X.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
sendForwardOneWayLatency(100, time);
buffer.add(new LatencyRecord(100, time.toEpochMilli()));
time = time.plusSeconds(1);
// all records after timeout will be emit immediately
for (int i = 10; i < 13; i++) {
sendForwardOneWayLatency(i, time);
buffer.add(new LatencyRecord(i, time.toEpochMilli()));
time = time.plusSeconds(1);
}
assertEmitLatency(buffer);
}
use of org.openkilda.wfm.topology.isllatency.model.LatencyRecord in project open-kilda by telstra.
the class IslStatsServiceTest method handleOneWayLatencyEmitOnFirstIslDownTest.
@Test
public void handleOneWayLatencyEmitOnFirstIslDownTest() throws InterruptedException {
// RTL: ............................
// OneWay: ..X.X.X.X........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);
}
buffer.remove(0);
islStatsService.handleIstStatusUpdateNotification(new IslStatusUpdateNotification(SWITCH_ID_1, PORT_1, SWITCH_ID_2, PORT_2, INACTIVE));
time = Instant.now();
int secondPartOfPacketsSize = 4;
for (int i = 0; i < secondPartOfPacketsSize; i++) {
sendForwardOneWayLatency(i + secondPartOfPacketsSize, time);
// we do not add this record into buffer because we must not emit it
time = time.plusMillis(500);
// need to real shift of system clock
sleep(50);
}
assertEmitLatency(buffer);
}
use of org.openkilda.wfm.topology.isllatency.model.LatencyRecord in project open-kilda by telstra.
the class IslStatsServiceTest method handleOneWayLatencyUseForwardsRtlNotReverseRtlTest.
@Test
public void handleOneWayLatencyUseForwardsRtlNotReverseRtlTest() {
// RTL: ...X.X.X.X.X.X.X.X.X.X.....
// Reverse RTL: ...X.X.X.X.X.X.X.X.X.X.....
// OneWay: ..X.X.X.X.X.X.X.X.X.X......
List<LatencyRecord> buffer = new ArrayList<>();
Instant time = Instant.now();
for (int i = 0; i < 10; i++) {
sendForwardOneWayLatency(i + 10000, time);
time = time.plusMillis(10);
sendForwardRoundTripLatency(i, time);
sendReverseRoundTripLatency(i + 100, time);
// we must emit only forward RTL
buffer.add(new LatencyRecord(i, time.toEpochMilli()));
time = time.plusSeconds(1);
}
assertEmitLatency(buffer);
}
use of org.openkilda.wfm.topology.isllatency.model.LatencyRecord in project open-kilda by telstra.
the class IslStatsService method handleRoundTripLatencyMetric.
/**
* Handle round trip latency metric.
*
* @param timestamp timestamp of metric
* @param data round trip latency info data
* @param destination isl destination endpoint
*/
public void handleRoundTripLatencyMetric(long timestamp, IslRoundTripLatency data, Endpoint destination) {
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.put(islKey, new LatencyRecord(data.getLatency(), timestamp));
oneWayLatencyEmitTimeoutMap.remove(islKey);
oneWayLatencyEmitTimeoutMap.remove(islKey.getReverse());
clearOneWayRecords(islKey);
clearOneWayRecords(islKey.getReverse());
carrier.emitLatency(data.getSrcSwitchId(), data.getSrcPortNo(), destination.getDatapath(), destination.getPortNumber(), data.getLatency(), timestamp, data.getOrigin());
}
Aggregations