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