use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.
the class FlowStateCacheBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws PipelineException {
if (active) {
if (ComponentId.TICK_BOLT.name().equals(input.getSourceComponent())) {
flowStateCacheService.getFlows().forEach(flowId -> emit(input, new Values(flowId, getCommandContext())));
return;
}
if (FLOW_UPDATE_STREAM_ID.name().equals(input.getSourceStreamId())) {
CommandData payload = pullValue(input, COMMAND_DATA_FIELD, CommandData.class);
if (payload instanceof UpdateFlowCommand) {
UpdateFlowCommand updateFlowCommand = (UpdateFlowCommand) payload;
flowStateCacheService.updateFlow(updateFlowCommand);
emit(FLOW_UPDATE_STREAM_ID.name(), input, new Values(updateFlowCommand.getFlowId(), updateFlowCommand, getCommandContext()));
} else {
unhandledInput(input);
}
return;
}
if (FLOW_REMOVE_STREAM_ID.name().equals(input.getSourceStreamId())) {
String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
flowStateCacheService.removeFlow(flowId);
emit(FLOW_REMOVE_STREAM_ID.name(), input, new Values(flowId, getCommandContext()));
} else {
unhandledInput(input);
}
}
}
use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.
the class FlowCacheServiceTest method shouldChangeFlowPathInCache.
@Test
public void shouldChangeFlowPathInCache() {
Flow flow = createFlow();
when(clock.instant()).thenReturn(Instant.now());
service = new FlowCacheService(persistenceManager, clock, FLOW_RTT_STATS_EXPIRATION_TIME, carrier);
Long maxLatency = 100L;
Long maxLatencyTier2 = 200L;
UpdateFlowCommand updateFlowCommand = new UpdateFlowCommand(flow.getFlowId(), FlowPathDto.builder().id(flow.getFlowId()).forwardPath(Arrays.asList(new PathNodePayload(SRC_SWITCH, IN_PORT, ISL_SRC_PORT_2), new PathNodePayload(DST_SWITCH, ISL_DST_PORT_2, OUT_PORT))).reversePath(Arrays.asList(new PathNodePayload(DST_SWITCH, OUT_PORT, ISL_DST_PORT_2), new PathNodePayload(SRC_SWITCH, ISL_SRC_PORT_2, IN_PORT))).build(), maxLatency, maxLatencyTier2);
service.updateFlowInfo(updateFlowCommand);
service.processFlowLatencyCheck(flow.getFlowId());
List<Link> expectedForwardPath = getLinks(SRC_SWITCH, ISL_SRC_PORT_2, DST_SWITCH, ISL_DST_PORT_2);
verify(carrier).emitCalculateFlowLatencyRequest(flow.getFlowId(), FlowDirection.FORWARD, expectedForwardPath);
List<Link> expectedReversePath = reverse(expectedForwardPath);
verify(carrier).emitCalculateFlowLatencyRequest(flow.getFlowId(), FlowDirection.REVERSE, expectedReversePath);
verifyNoMoreInteractions(carrier);
}
Aggregations