use of org.openkilda.wfm.topology.flowmonitoring.model.Link in project open-kilda by telstra.
the class FlowCacheBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws PipelineException {
if (active) {
if (ComponentId.FLOW_STATE_CACHE_BOLT.name().equals(input.getSourceComponent())) {
if (FLOW_UPDATE_STREAM_ID.name().equals(input.getSourceStreamId())) {
UpdateFlowCommand updateFlowCommand = pullValue(input, COMMAND_DATA_FIELD, UpdateFlowCommand.class);
flowCacheService.updateFlowInfo(updateFlowCommand);
emit(FLOW_UPDATE_STREAM_ID.name(), input, new Values(updateFlowCommand.getFlowId(), updateFlowCommand, getCommandContext()));
} else if (FLOW_REMOVE_STREAM_ID.name().equals(input.getSourceStreamId())) {
String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
flowCacheService.removeFlowInfo(flowId);
emit(FLOW_REMOVE_STREAM_ID.name(), input, new Values(flowId, getCommandContext()));
} else {
String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
flowCacheService.processFlowLatencyCheck(flowId);
}
return;
}
if (ComponentId.ISL_CACHE_BOLT.name().equals(input.getSourceComponent())) {
String requestId = pullValue(input, REQUEST_ID_FIELD, String.class);
Link link = pullValue(input, LINK_FIELD, Link.class);
Duration latency = pullValue(input, LATENCY_FIELD, Duration.class);
calculateFlowLatencyService.handleGetLinkLatencyResponse(requestId, link, latency);
return;
}
FlowRttStatsData flowRttStatsData = pullValue(input, INFO_DATA_FIELD, FlowRttStatsData.class);
flowCacheService.processFlowRttStatsData(flowRttStatsData);
}
}
use of org.openkilda.wfm.topology.flowmonitoring.model.Link 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.wfm.topology.flowmonitoring.model.Link in project open-kilda by telstra.
the class FlowCacheServiceTest method shouldSendCheckFlowSlaRequests.
@Test
public void shouldSendCheckFlowSlaRequests() {
Flow flow = createFlow();
Instant now = Instant.now();
when(clock.instant()).thenReturn(now);
service = new FlowCacheService(persistenceManager, clock, FLOW_RTT_STATS_EXPIRATION_TIME, carrier);
long t0 = (now.getEpochSecond() << 32) + 1234;
long t1 = (now.getEpochSecond() << 32) + 2345;
FlowRttStatsData flowRttStatsData = FlowRttStatsData.builder().flowId(flow.getFlowId()).direction(FlowDirection.FORWARD.name().toLowerCase()).t0(t0).t1(t1).build();
service.processFlowRttStatsData(flowRttStatsData);
service.processFlowLatencyCheck(flow.getFlowId());
List<Link> expectedForwardPath = getLinks(SRC_SWITCH, ISL_SRC_PORT, DST_SWITCH, ISL_DST_PORT);
verify(carrier).emitCheckFlowLatencyRequest(flow.getFlowId(), FlowDirection.FORWARD, TimestampHelper.noviflowTimestampsToDuration(t0, t1));
List<Link> expectedReversePath = reverse(expectedForwardPath);
verify(carrier).emitCalculateFlowLatencyRequest(flow.getFlowId(), FlowDirection.REVERSE, expectedReversePath);
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.wfm.topology.flowmonitoring.model.Link in project open-kilda by telstra.
the class IslCacheService method handleOneWayLatency.
/**
* Update one way latency for ISL.
*/
public void handleOneWayLatency(IslOneWayLatency data) {
Link link = Link.builder().srcSwitchId(data.getSrcSwitchId()).srcPort(data.getSrcPortNo()).destSwitchId(data.getDstSwitchId()).destPort(data.getDstPortNo()).build();
LinkState linkState = linkStates.get(link);
if (linkState == null) {
linkStates.put(link, LinkState.builder().oneWayLatency(data.getLatency()).build());
} else {
linkState.setOneWayLatency(data.getLatency());
}
}
use of org.openkilda.wfm.topology.flowmonitoring.model.Link in project open-kilda by telstra.
the class IslCacheService method handleRoundTripLatency.
/**
* Update RTT latency for ISL.
*/
public void handleRoundTripLatency(IslRoundTripLatency data) {
List<Link> links = linkStates.keySet().stream().filter(link -> link.srcEquals(data.getSrcSwitchId(), data.getSrcPortNo())).collect(Collectors.toList());
Instant instant = clock.instant();
links.forEach(link -> {
LinkState linkState = linkStates.get(link);
if (linkState == null) {
linkStates.put(link, LinkState.builder().rttLatency(data.getLatency()).rttTimestamp(instant).build());
} else {
linkState.setRttLatency(data.getLatency());
linkState.setRttTimestamp(instant);
}
});
}
Aggregations