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());
}
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);
}
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);
}
}
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);
}
}
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));
}
Aggregations