Search in sources :

Example 1 with IslOneWayLatency

use of org.openkilda.messaging.info.event.IslOneWayLatency 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 IslOneWayLatency

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

the class IslCacheServiceTest method shouldGetLatencyForLinkByOneWayLatency.

@Test
public void shouldGetLatencyForLinkByOneWayLatency() {
    long latency = 100L;
    IslOneWayLatency islOneWayLatency = new IslOneWayLatency(FIRST_SWITCH, ISL_SRC_PORT, SECOND_SWITCH, ISL_DST_PORT, latency, 1L);
    when(clock.instant()).thenReturn(Instant.now());
    service.handleOneWayLatency(islOneWayLatency);
    long actual = service.getLatencyForLink(LINK).getNano();
    assertEquals(latency, actual);
}
Also used : IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 3 with IslOneWayLatency

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

the class IslCacheBolt method handleInput.

@Override
protected void handleInput(Tuple input) throws PipelineException {
    if (!active) {
        return;
    }
    if (ComponentId.ISL_SPLITTER_BOLT.name().equals(input.getSourceComponent())) {
        InfoData data = pullValue(input, INFO_DATA_FIELD, InfoData.class);
        if (ISL_UPDATE_STREAM_ID.name().equals(input.getSourceStreamId())) {
            if (data instanceof IslChangedInfoData) {
                islCacheService.handleIslChangedData((IslChangedInfoData) data);
            } else {
                unhandledInput(input);
            }
        } else if (data instanceof IslOneWayLatency) {
            islCacheService.handleOneWayLatency((IslOneWayLatency) data);
        } else if (data instanceof IslRoundTripLatency) {
            islCacheService.handleRoundTripLatency((IslRoundTripLatency) data);
        } else {
            unhandledInput(input);
        }
        return;
    }
    if (ComponentId.FLOW_CACHE_BOLT.name().equals(input.getSourceComponent())) {
        String requestId = pullValue(input, REQUEST_ID_FIELD, String.class);
        String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
        Link link = pullValue(input, LINK_FIELD, Link.class);
        Duration latency = islCacheService.getLatencyForLink(link);
        emit(input, new Values(requestId, flowId, link, latency, getCommandContext()));
    } else {
        unhandledInput(input);
    }
}
Also used : IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) InfoData(org.openkilda.messaging.info.InfoData) IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) Values(org.apache.storm.tuple.Values) Duration(java.time.Duration) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency)

Example 4 with IslOneWayLatency

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

the class PathVerificationService method handleDiscoveryPacket.

private void handleDiscoveryPacket(OfInput input, IOFSwitch destSwitch, DiscoveryPacketData data) {
    OFPort inPort = OFMessageUtils.getInPort((OFPacketIn) input.getMessage());
    long latencyMs = measureLatency(input, data.getTimestamp());
    dashboardLogger.onIslDiscovery(data.getRemoteSwitchId(), data.getRemotePort(), input.getDpId(), inPort, latencyMs, data.getPacketId(), input.getMessage().getXid());
    // this discovery packet was sent from remote switch/port to received switch/port
    // so the link direction is from remote switch/port to received switch/port
    PathNode source = new PathNode(new SwitchId(data.getRemoteSwitchId().getLong()), data.getRemotePort().getPortNumber(), 0);
    PathNode destination = new PathNode(new SwitchId(input.getDpId().getLong()), inPort.getPortNumber(), 1);
    long speed = getSwitchPortSpeed(destSwitch, inPort);
    IslInfoData path = IslInfoData.builder().source(source).destination(destination).speed(speed).state(IslChangeType.DISCOVERED).availableBandwidth(getAvailableBandwidth(speed)).packetId(data.getPacketId()).build();
    sendDiscovery(path);
    logger.debug("packet_in processed for {}-{}", input.getDpId(), inPort);
    IslOneWayLatency islOneWayLatency = new IslOneWayLatency(source.getSwitchId(), source.getPortNo(), destination.getSwitchId(), destination.getPortNo(), // TODO(surabujin): do we really need fake ns accuracy?
    scaleLatencyMsToNs(latencyMs), data.getPacketId());
    sendLatency(islOneWayLatency, source.getSwitchId());
}
Also used : OFPort(org.projectfloodlight.openflow.types.OFPort) SwitchId(org.openkilda.model.SwitchId) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency)

Example 5 with IslOneWayLatency

use of org.openkilda.messaging.info.event.IslOneWayLatency 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)

Aggregations

IslOneWayLatency (org.openkilda.messaging.info.event.IslOneWayLatency)10 IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)6 Test (org.junit.Test)4 InfoData (org.openkilda.messaging.info.InfoData)4 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)3 Endpoint (org.openkilda.wfm.share.model.Endpoint)3 Duration (java.time.Duration)1 Instant (java.time.Instant)1 Values (org.apache.storm.tuple.Values)1 Message (org.openkilda.messaging.Message)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 IslChangedInfoData (org.openkilda.messaging.info.event.IslChangedInfoData)1 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)1 PathNode (org.openkilda.messaging.info.event.PathNode)1 IslRttStatsData (org.openkilda.messaging.info.stats.IslRttStatsData)1 SwitchId (org.openkilda.model.SwitchId)1 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)1 Link (org.openkilda.wfm.topology.flowmonitoring.model.Link)1 IslKey (org.openkilda.wfm.topology.isllatency.model.IslKey)1 OFPort (org.projectfloodlight.openflow.types.OFPort)1