Search in sources :

Example 1 with IslRoundTripLatency

use of org.openkilda.messaging.info.event.IslRoundTripLatency in project open-kilda by telstra.

the class RouterBolt method handleInput.

@Override
protected void handleInput(Tuple input) throws PipelineException {
    Message message = pullValue(input, FIELD_ID_PAYLOAD, Message.class);
    if (active) {
        if (message instanceof InfoMessage) {
            log.debug("Received info message {}", message);
            InfoData data = ((InfoMessage) message).getData();
            if (data instanceof IslOneWayLatency) {
                handleOneWayLatency(input, (IslOneWayLatency) data);
            } else if (data instanceof IslRoundTripLatency) {
                handleRoundTripLatency(input, (IslRoundTripLatency) data);
            } else if (data instanceof IslRttStatsData) {
                handleRoundTripLatency(input, (IslRttStatsData) data);
            } else {
                unhandledInput(input);
            }
        } else {
            unhandledInput(input);
        }
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) IslRttStatsData(org.openkilda.messaging.info.stats.IslRttStatsData) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency)

Example 2 with IslRoundTripLatency

use of org.openkilda.messaging.info.event.IslRoundTripLatency in project open-kilda by telstra.

the class IslCacheServiceTest method shouldHandleMovedIslFromCache.

@Test
public void shouldHandleMovedIslFromCache() {
    IslRoundTripLatency islRoundTripLatency = new IslRoundTripLatency(FIRST_SWITCH, ISL_SRC_PORT, 7, 1L);
    service.handleRoundTripLatency(islRoundTripLatency);
    int newPort = 33;
    IslChangedInfoData islChangedInfoData = IslChangedInfoData.builder().source(NetworkEndpoint.builder().datapath(FIRST_SWITCH).portNumber(ISL_SRC_PORT).build()).destination(NetworkEndpoint.builder().datapath(THIRD_SWITCH).portNumber(newPort).build()).build();
    service.handleIslChangedData(islChangedInfoData);
    long rttLatency = 1000L;
    IslRoundTripLatency isl2RoundTripLatency = new IslRoundTripLatency(FIRST_SWITCH, ISL_SRC_PORT, rttLatency, 1L);
    when(clock.instant()).thenReturn(Instant.now());
    service.handleRoundTripLatency(isl2RoundTripLatency);
    long actual = service.getLatencyForLink(Link.builder().srcSwitchId(FIRST_SWITCH).srcPort(ISL_SRC_PORT).destSwitchId(THIRD_SWITCH).destPort(newPort).build()).getNano();
    assertEquals(rttLatency, actual);
}
Also used : IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 3 with IslRoundTripLatency

use of org.openkilda.messaging.info.event.IslRoundTripLatency in project open-kilda by telstra.

the class IslCacheServiceTest method shouldRemoveDeletedIslFromCache.

@Test
public void shouldRemoveDeletedIslFromCache() {
    long rttLatency = 1000L;
    IslRoundTripLatency islRoundTripLatency = new IslRoundTripLatency(FIRST_SWITCH, ISL_SRC_PORT, rttLatency, 1L);
    service.handleRoundTripLatency(islRoundTripLatency);
    IslChangedInfoData islChangedInfoData = IslChangedInfoData.builder().source(NetworkEndpoint.builder().datapath(FIRST_SWITCH).portNumber(ISL_SRC_PORT).build()).destination(NetworkEndpoint.builder().datapath(SECOND_SWITCH).portNumber(ISL_DST_PORT).build()).removed(true).build();
    service.handleIslChangedData(islChangedInfoData);
    long actual = service.getLatencyForLink(LINK).getNano();
    assertEquals(0, actual);
}
Also used : IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 4 with IslRoundTripLatency

use of org.openkilda.messaging.info.event.IslRoundTripLatency in project open-kilda by telstra.

the class PathVerificationService method handleRoundTripLatency.

private void handleRoundTripLatency(DiscoveryPacketData packetData, OfInput input) {
    SwitchId switchId = new SwitchId(input.getDpId().getLong());
    int port = OFMessageUtils.getInPort((OFPacketIn) input.getMessage()).getPortNumber();
    logIsl.debug("got round trip packet: {}_{}, T0: {}, T1: {}, id:{}", switchId, port, packetData.getSwitchT0(), packetData.getSwitchT1(), packetData.getPacketId());
    SwitchId switchIdFromPacket = new SwitchId(packetData.getRemoteSwitchId().getLong());
    int portFromPacket = packetData.getRemotePort().getPortNumber();
    if (!Objects.equals(switchId, switchIdFromPacket) || port != portFromPacket) {
        logger.warn("Endpoint from round trip latency package and endpoint from which the package was received " + "are different. Endpoint from package: {}-{}. " + "Endpoint from which package was received: {}-{}", switchIdFromPacket, portFromPacket, switchId, port);
        return;
    }
    long roundTripLatency = calculateRoundTripLatency(switchId, port, packetData.getSwitchT0(), packetData.getSwitchT1());
    IslRoundTripLatency latency = new IslRoundTripLatency(switchId, port, roundTripLatency, packetData.getPacketId(), "floodlight");
    logger.debug("Round trip latency packet processed for endpoint {}_{}. " + "t0 timestamp {}, t1 timestamp {}, latency {}.", switchId, port, packetData.getSwitchT0(), packetData.getSwitchT1(), roundTripLatency);
    sendLatency(latency, switchId);
    sendRoundTripDiscovery(latency);
}
Also used : IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) SwitchId(org.openkilda.model.SwitchId)

Example 5 with IslRoundTripLatency

use of org.openkilda.messaging.info.event.IslRoundTripLatency in project open-kilda by telstra.

the class CacheServiceTest method testGetDataFromCache.

private void testGetDataFromCache(IslStatus islStatus) {
    int srcPort = 7;
    int dstPort = 8;
    createIsl(switchRepository.findById(SWITCH_ID_1).get(), srcPort, switchRepository.findById(SWITCH_ID_2).get(), dstPort, 1, islStatus);
    IslRoundTripLatency forward = new IslRoundTripLatency(SWITCH_ID_1, srcPort, 1, 0L);
    checkHandleGetDataFromCacheDidNotCallEmitCacheData(forward);
    IslRoundTripLatency reverse = new IslRoundTripLatency(SWITCH_ID_2, dstPort, 1, 0L);
    checkHandleGetDataFromCacheDidNotCallEmitCacheData(reverse);
}
Also used : IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) Endpoint(org.openkilda.wfm.share.model.Endpoint)

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