Search in sources :

Example 1 with ListFlowsOnSwitch

use of org.openkilda.server42.control.messaging.flowrtt.ListFlowsOnSwitch in project open-kilda by telstra.

the class Gate method listen.

@KafkaHandler
void listen(ListFlowsOnSwitch data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) {
    CommandPacket commandPacket = getFlowListCommandPacket(switchIdKey);
    try {
        CommandPacketResponse serverResponse = zeroMqClient.send(commandPacket);
        if (serverResponse == null) {
            log.error("No response from server on {}", data.getHeaders().getCorrelationId());
            return;
        }
        for (Any any : serverResponse.getResponseList()) {
            String flowId = any.unpack(Flow.class).getFlowId();
            if (!data.getFlowIds().contains(flowId)) {
                removeFlow(flowId, FlowDirection.FORWARD);
                removeFlow(flowId, FlowDirection.REVERSE);
            }
        }
    } catch (InvalidProtocolBufferException e) {
        log.error("Marshalling error on {}", data);
    }
}
Also used : InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) CommandPacketResponse(org.openkilda.server42.control.messaging.Control.CommandPacketResponse) CommandPacket(org.openkilda.server42.control.messaging.Control.CommandPacket) Any(com.google.protobuf.Any) AddFlow(org.openkilda.server42.control.messaging.flowrtt.AddFlow) Flow(org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow) RemoveFlow(org.openkilda.server42.control.messaging.flowrtt.RemoveFlow) KafkaHandler(org.springframework.kafka.annotation.KafkaHandler)

Example 2 with ListFlowsOnSwitch

use of org.openkilda.server42.control.messaging.flowrtt.ListFlowsOnSwitch in project open-kilda by telstra.

the class FlowHandler method sendListOfFlowBySwitchId.

@Override
public void sendListOfFlowBySwitchId(SwitchId switchId, Set<String> flowOnSwitch) {
    ListFlowsOnSwitch listFlowsOnSwitch = ListFlowsOnSwitch.builder().headers(buildHeader()).flowIds(flowOnSwitch).build();
    emit(STREAM_CONTROL_COMMANDS_ID, getCurrentTuple(), new Values(switchId.toString(), listFlowsOnSwitch));
}
Also used : ListFlowsOnSwitch(org.openkilda.server42.control.messaging.flowrtt.ListFlowsOnSwitch) Values(org.apache.storm.tuple.Values)

Aggregations

Any (com.google.protobuf.Any)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 Values (org.apache.storm.tuple.Values)1 CommandPacket (org.openkilda.server42.control.messaging.Control.CommandPacket)1 CommandPacketResponse (org.openkilda.server42.control.messaging.Control.CommandPacketResponse)1 AddFlow (org.openkilda.server42.control.messaging.flowrtt.AddFlow)1 Flow (org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow)1 ListFlowsOnSwitch (org.openkilda.server42.control.messaging.flowrtt.ListFlowsOnSwitch)1 RemoveFlow (org.openkilda.server42.control.messaging.flowrtt.RemoveFlow)1 KafkaHandler (org.springframework.kafka.annotation.KafkaHandler)1