Search in sources :

Example 6 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 7 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)

Example 8 with IslOneWayLatency

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

Example 9 with IslOneWayLatency

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

the class IslStatsBolt method handleLatencyData.

private void handleLatencyData(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);
        islStatsService.handleRoundTripLatencyMetric(timestamp, (IslRoundTripLatency) data, destination);
    } else if (data instanceof IslOneWayLatency) {
        islStatsService.handleOneWayLatencyMetric(timestamp, (IslOneWayLatency) data);
    } 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)

Example 10 with IslOneWayLatency

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

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