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