Search in sources :

Example 1 with LinkState

use of org.openkilda.wfm.topology.flowmonitoring.model.LinkState in project open-kilda by telstra.

the class IslCacheService method handleOneWayLatency.

/**
 * Update one way latency for ISL.
 */
public void handleOneWayLatency(IslOneWayLatency data) {
    Link link = Link.builder().srcSwitchId(data.getSrcSwitchId()).srcPort(data.getSrcPortNo()).destSwitchId(data.getDstSwitchId()).destPort(data.getDstPortNo()).build();
    LinkState linkState = linkStates.get(link);
    if (linkState == null) {
        linkStates.put(link, LinkState.builder().oneWayLatency(data.getLatency()).build());
    } else {
        linkState.setOneWayLatency(data.getLatency());
    }
}
Also used : Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) LinkState(org.openkilda.wfm.topology.flowmonitoring.model.LinkState)

Example 2 with LinkState

use of org.openkilda.wfm.topology.flowmonitoring.model.LinkState 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 3 with LinkState

use of org.openkilda.wfm.topology.flowmonitoring.model.LinkState in project open-kilda by telstra.

the class IslCacheService method getLatencyForLink.

/**
 * Get latency for link.
 */
public Duration getLatencyForLink(Link link) {
    log.debug("Request for link latency {}", link);
    LinkState linkState = linkStates.get(link);
    if (linkState == null) {
        log.warn("Link not found in ISL cache {}", link);
        return Duration.ZERO;
    } else {
        return linkState.getLatency(clock.instant(), islRttLatencyExpiration);
    }
}
Also used : LinkState(org.openkilda.wfm.topology.flowmonitoring.model.LinkState)

Aggregations

LinkState (org.openkilda.wfm.topology.flowmonitoring.model.LinkState)3 Link (org.openkilda.wfm.topology.flowmonitoring.model.Link)2 Clock (java.time.Clock)1 Duration (java.time.Duration)1 Instant (java.time.Instant)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 IslChangedInfoData (org.openkilda.messaging.info.event.IslChangedInfoData)1 IslOneWayLatency (org.openkilda.messaging.info.event.IslOneWayLatency)1 IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)1 SwitchId (org.openkilda.model.SwitchId)1 PersistenceManager (org.openkilda.persistence.PersistenceManager)1 IslRepository (org.openkilda.persistence.repositories.IslRepository)1 LinkMapper (org.openkilda.wfm.topology.flowmonitoring.mapper.LinkMapper)1