Search in sources :

Example 16 with IslRoundTripLatency

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);
}
Also used : IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency)

Example 17 with IslRoundTripLatency

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);
}
Also used : IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency)

Example 18 with IslRoundTripLatency

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);
        }
    });
}
Also used : HashMap(java.util.HashMap) LinkState(org.openkilda.wfm.topology.flowmonitoring.model.LinkState) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) SwitchId(org.openkilda.model.SwitchId) LinkMapper(org.openkilda.wfm.topology.flowmonitoring.mapper.LinkMapper) IslRepository(org.openkilda.persistence.repositories.IslRepository) Duration(java.time.Duration) Map(java.util.Map) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) Clock(java.time.Clock) PersistenceManager(org.openkilda.persistence.PersistenceManager) IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency) Instant(java.time.Instant) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) LinkState(org.openkilda.wfm.topology.flowmonitoring.model.LinkState)

Example 19 with IslRoundTripLatency

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);
}
Also used : IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) Instant(java.time.Instant) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 20 with IslRoundTripLatency

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);
    }
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) InfoData(org.openkilda.messaging.info.InfoData) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency)

Aggregations

IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)23 Test (org.junit.Test)11 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)10 IslOneWayLatency (org.openkilda.messaging.info.event.IslOneWayLatency)7 Endpoint (org.openkilda.wfm.share.model.Endpoint)6 InfoData (org.openkilda.messaging.info.InfoData)4 IslChangedInfoData (org.openkilda.messaging.info.event.IslChangedInfoData)4 SwitchId (org.openkilda.model.SwitchId)4 Duration (java.time.Duration)2 Instant (java.time.Instant)2 Values (org.apache.storm.tuple.Values)2 IslStatusUpdateNotification (org.openkilda.messaging.info.event.IslStatusUpdateNotification)2 Link (org.openkilda.wfm.topology.flowmonitoring.model.Link)2 Clock (java.time.Clock)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Message (org.openkilda.messaging.Message)1