Search in sources :

Example 6 with IslKey

use of org.openkilda.wfm.topology.isllatency.model.IslKey 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());
}
Also used : IslKey(org.openkilda.wfm.topology.isllatency.model.IslKey) LatencyRecord(org.openkilda.wfm.topology.isllatency.model.LatencyRecord)

Example 7 with IslKey

use of org.openkilda.wfm.topology.isllatency.model.IslKey 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);
    }
}
Also used : IslKey(org.openkilda.wfm.topology.isllatency.model.IslKey) LatencyRecord(org.openkilda.wfm.topology.isllatency.model.LatencyRecord)

Example 8 with IslKey

use of org.openkilda.wfm.topology.isllatency.model.IslKey in project open-kilda by telstra.

the class IslLatencyServiceTest method handleOneWayIslLatencyNonExistentIslTest.

@Test
public void handleOneWayIslLatencyNonExistentIslTest() {
    int fakePort = 999;
    IslKey islKey = new IslKey(SWITCH_ID_1, fakePort, SWITCH_ID_2, fakePort);
    assertTrue(islLatencyService.isUpdateRequired(islKey));
    IslOneWayLatency nonExistent = new IslOneWayLatency(SWITCH_ID_1, fakePort, SWITCH_ID_2, fakePort, 3, PACKET_ID);
    islLatencyService.handleOneWayIslLatency(nonExistent, System.currentTimeMillis());
    assertTrue(islLatencyService.isUpdateRequired(islKey));
}
Also used : IslKey(org.openkilda.wfm.topology.isllatency.model.IslKey) Endpoint(org.openkilda.wfm.share.model.Endpoint) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

IslKey (org.openkilda.wfm.topology.isllatency.model.IslKey)8 LatencyRecord (org.openkilda.wfm.topology.isllatency.model.LatencyRecord)4 Test (org.junit.Test)2 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)2 Endpoint (org.openkilda.wfm.share.model.Endpoint)2 Instant (java.time.Instant)1 IslOneWayLatency (org.openkilda.messaging.info.event.IslOneWayLatency)1 IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)1