Search in sources :

Example 1 with RemoveFlowCommand

use of org.openkilda.messaging.info.flow.RemoveFlowCommand 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 RemoveFlowCommand

use of org.openkilda.messaging.info.flow.RemoveFlowCommand 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)

Aggregations

RemoveFlowCommand (org.openkilda.messaging.info.flow.RemoveFlowCommand)2 UpdateFlowCommand (org.openkilda.messaging.info.flow.UpdateFlowCommand)2 Values (org.apache.storm.tuple.Values)1 Message (org.openkilda.messaging.Message)1 CommandData (org.openkilda.messaging.command.CommandData)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 InfoData (org.openkilda.messaging.info.InfoData)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 FlowRttStatsData (org.openkilda.messaging.info.stats.FlowRttStatsData)1 FlowPathDto (org.openkilda.messaging.model.FlowPathDto)1 Flow (org.openkilda.model.Flow)1