Search in sources :

Example 1 with UpdateFlowCommand

use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.

the class NotifyFlowMonitorAction method getFlowInfo.

private CommandData getFlowInfo(String flowId) {
    Optional<Flow> flow = flowRepository.findById(flowId);
    if (!flow.isPresent() || flow.get().isOneSwitchFlow()) {
        return new RemoveFlowCommand(flowId);
    }
    FlowPathDto flowPathDto = toFlowPathDtoBuilder(flow.get()).build();
    return new UpdateFlowCommand(flowId, flowPathDto, flow.get().getMaxLatency(), flow.get().getMaxLatencyTier2());
}
Also used : UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) FlowPathDto(org.openkilda.messaging.model.FlowPathDto) RemoveFlowCommand(org.openkilda.messaging.info.flow.RemoveFlowCommand) Flow(org.openkilda.model.Flow)

Example 2 with UpdateFlowCommand

use of org.openkilda.messaging.info.flow.UpdateFlowCommand 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);
    }
}
Also used : UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) FlowRttStatsData(org.openkilda.messaging.info.stats.FlowRttStatsData) Values(org.apache.storm.tuple.Values) Duration(java.time.Duration) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link)

Example 3 with UpdateFlowCommand

use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.

the class FlowSplitterBolt method handleInput.

@Override
protected void handleInput(Tuple input) throws PipelineException {
    Message message = pullValue(input, FIELD_ID_PAYLOAD, Message.class);
    if (message instanceof InfoMessage) {
        InfoData infoData = ((InfoMessage) message).getData();
        if (infoData instanceof FlowRttStatsData) {
            FlowRttStatsData flowRttStatsData = (FlowRttStatsData) infoData;
            emit(input, new Values(flowRttStatsData.getFlowId(), flowRttStatsData, getCommandContext()));
        } else {
            unhandledInput(input);
        }
        return;
    }
    if (message instanceof CommandMessage) {
        CommandData commandData = pullValue(input, FIELD_ID_PAYLOAD, CommandMessage.class).getData();
        if (commandData instanceof UpdateFlowCommand) {
            UpdateFlowCommand updateFlowCommand = (UpdateFlowCommand) commandData;
            emit(FLOW_UPDATE_STREAM_ID.name(), input, new Values(updateFlowCommand.getFlowId(), updateFlowCommand, getCommandContext()));
        } else if (commandData instanceof RemoveFlowCommand) {
            RemoveFlowCommand removeFlowCommand = (RemoveFlowCommand) commandData;
            emit(FLOW_REMOVE_STREAM_ID.name(), input, new Values(removeFlowCommand.getFlowId(), getCommandContext()));
        } else {
            unhandledInput(input);
        }
    } else {
        unhandledInput(input);
    }
}
Also used : UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowRttStatsData(org.openkilda.messaging.info.stats.FlowRttStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) Values(org.apache.storm.tuple.Values) RemoveFlowCommand(org.openkilda.messaging.info.flow.RemoveFlowCommand) CommandData(org.openkilda.messaging.command.CommandData) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 4 with UpdateFlowCommand

use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.

the class ActionServiceTest method shouldUpdateFlowInfo.

@Test
public void shouldUpdateFlowInfo() {
    service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.FORWARD, NANOSECOND);
    service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.REVERSE, NANOSECOND);
    FlowPathDto path = FlowPathDto.builder().forwardPath(Arrays.asList(new PathNodePayload(SRC_SWITCH, 1, 2), new PathNodePayload(DST_SWITCH, 3, 4))).reversePath(Arrays.asList(new PathNodePayload(DST_SWITCH, 4, 3), new PathNodePayload(SRC_SWITCH, 2, 1))).build();
    long maxLatency = flow.getMaxLatency() / 2;
    long maxLatencyTier2 = flow.getMaxLatencyTier2() / 2;
    UpdateFlowCommand info = new UpdateFlowCommand(flow.getFlowId(), path, maxLatency, maxLatencyTier2);
    service.updateFlowInfo(info);
    assertEquals(2, service.fsms.values().size());
    FlowLatencyMonitoringFsm fsm = service.fsms.values().stream().findAny().orElseThrow(() -> new IllegalStateException("Fsm not found"));
    assertEquals(maxLatency, fsm.getMaxLatency());
    assertEquals(maxLatencyTier2, fsm.getMaxLatencyTier2());
    verifyNoMoreInteractions(carrier);
}
Also used : UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) FlowPathDto(org.openkilda.messaging.model.FlowPathDto) PathNodePayload(org.openkilda.messaging.payload.flow.PathNodePayload) FlowLatencyMonitoringFsm(org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 5 with UpdateFlowCommand

use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.

the class ActionBolt method handleInput.

@Override
protected void handleInput(Tuple input) throws PipelineException {
    if (!active) {
        return;
    }
    if (FLOW_UPDATE_STREAM_ID.name().equals(input.getSourceStreamId())) {
        UpdateFlowCommand updateFlowCommand = pullValue(input, COMMAND_DATA_FIELD, UpdateFlowCommand.class);
        actionService.updateFlowInfo(updateFlowCommand);
        return;
    }
    if (FLOW_REMOVE_STREAM_ID.name().equals(input.getSourceStreamId())) {
        String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
        actionService.removeFlowInfo(flowId);
        return;
    }
    if (ACTION_STREAM_ID.name().equals(input.getSourceStreamId())) {
        String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
        FlowDirection direction = pullValue(input, FLOW_DIRECTION_FIELD, FlowDirection.class);
        Duration latency = pullValue(input, LATENCY_FIELD, Duration.class);
        actionService.processFlowLatencyMeasurement(flowId, direction, latency);
        return;
    }
    if (ComponentId.TICK_BOLT.name().equals(input.getSourceComponent())) {
        actionService.processTick();
    } else {
        unhandledInput(input);
    }
}
Also used : UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) FlowDirection(org.openkilda.server42.messaging.FlowDirection) Duration(java.time.Duration)

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