Search in sources :

Example 6 with UpdateFlowCommand

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);
        }
    }
}
Also used : UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) Values(org.apache.storm.tuple.Values) CommandData(org.openkilda.messaging.command.CommandData)

Example 7 with UpdateFlowCommand

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);
}
Also used : UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) PathNodePayload(org.openkilda.messaging.payload.flow.PathNodePayload) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

UpdateFlowCommand (org.openkilda.messaging.info.flow.UpdateFlowCommand)7 Values (org.apache.storm.tuple.Values)3 Duration (java.time.Duration)2 Test (org.junit.Test)2 CommandData (org.openkilda.messaging.command.CommandData)2 RemoveFlowCommand (org.openkilda.messaging.info.flow.RemoveFlowCommand)2 FlowRttStatsData (org.openkilda.messaging.info.stats.FlowRttStatsData)2 FlowPathDto (org.openkilda.messaging.model.FlowPathDto)2 PathNodePayload (org.openkilda.messaging.payload.flow.PathNodePayload)2 Flow (org.openkilda.model.Flow)2 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)2 Link (org.openkilda.wfm.topology.flowmonitoring.model.Link)2 Message (org.openkilda.messaging.Message)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 InfoData (org.openkilda.messaging.info.InfoData)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 FlowDirection (org.openkilda.server42.messaging.FlowDirection)1 FlowLatencyMonitoringFsm (org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm)1