use of org.openkilda.messaging.info.event.IslChangedInfoData 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.IslChangedInfoData 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.IslChangedInfoData 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.IslChangedInfoData in project open-kilda by telstra.
the class IslDataSplitterBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws PipelineException {
Message message = pullValue(input, FIELD_ID_PAYLOAD, Message.class);
InfoData infoData;
if (message instanceof InfoMessage) {
infoData = ((InfoMessage) message).getData();
} else {
unhandledInput(input);
return;
}
if (infoData instanceof IslChangedInfoData) {
IslChangedInfoData data = (IslChangedInfoData) infoData;
emitWithContext(ISL_UPDATE_STREAM_ID.name(), input, new Values(getIslKey(data.getSource().getDatapath(), data.getSource().getPortNumber()), data));
emitWithContext(ISL_UPDATE_STREAM_ID.name(), input, new Values(getIslKey(data.getDestination().getDatapath(), data.getDestination().getPortNumber()), revert(data)));
} else if (infoData instanceof IslBaseLatency) {
IslBaseLatency islBaseLatency = (IslBaseLatency) infoData;
emit(input, new Values(getIslKey(islBaseLatency.getSrcSwitchId(), islBaseLatency.getSrcPortNo()), infoData, getCommandContext()));
} else {
unhandledInput(input);
}
}
use of org.openkilda.messaging.info.event.IslChangedInfoData in project open-kilda by telstra.
the class IslHandler method islChangedNotifyFlowMonitor.
@Override
public void islChangedNotifyFlowMonitor(IslReference reference, boolean removed) {
Endpoint src = reference.getSource();
Endpoint dst = reference.getDest();
IslChangedInfoData islChangedInfoData = IslChangedInfoData.builder().source(new NetworkEndpoint(src.getDatapath(), src.getPortNumber())).destination(new NetworkEndpoint(dst.getDatapath(), dst.getPortNumber())).removed(removed).build();
emit(STREAM_FLOW_MONITORING_ID, getCurrentTuple(), makeIslChangedTuple(islChangedInfoData));
}
Aggregations