Search in sources :

Example 1 with ListIslPortsOnSwitch

use of org.openkilda.server42.control.messaging.islrtt.ListIslPortsOnSwitch in project open-kilda by telstra.

the class Gate method listen.

@KafkaHandler
void listen(@Payload ListIslPortsOnSwitch data) {
    Builder builder = CommandPacket.newBuilder();
    builder.setType(Type.LIST_ISLS);
    IslRttControl.ListIslsFilter listIslsFilter = IslRttControl.ListIslsFilter.newBuilder().setSwitchId(data.getSwitchId().toString()).build();
    builder.addCommand(Any.pack(listIslsFilter));
    try {
        CommandPacketResponse serverResponse = zeroMqClient.send(builder.build());
        if (serverResponse == null) {
            log.error("No response from server on {}", data.getHeaders().getCorrelationId());
            return;
        }
        for (Any any : serverResponse.getResponseList()) {
            IslRttControl.IslEndpoint endpoint = any.unpack(IslRttControl.IslEndpoint.class);
            if (!data.getIslPorts().contains(endpoint.getPort())) {
                removeIsl(data.getSwitchId(), endpoint.getPort());
            }
        }
    } catch (InvalidProtocolBufferException e) {
        log.error("Marshalling error on {}", data, e);
    }
}
Also used : IslEndpoint(org.openkilda.server42.control.messaging.islrtt.IslRttControl.IslEndpoint) Builder(org.openkilda.server42.control.messaging.Control.CommandPacket.Builder) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IslRttControl(org.openkilda.server42.control.messaging.islrtt.IslRttControl) CommandPacketResponse(org.openkilda.server42.control.messaging.Control.CommandPacketResponse) Any(com.google.protobuf.Any) KafkaHandler(org.springframework.kafka.annotation.KafkaHandler)

Example 2 with ListIslPortsOnSwitch

use of org.openkilda.server42.control.messaging.islrtt.ListIslPortsOnSwitch in project open-kilda by telstra.

the class IslHandler method sendListOfIslPortsBySwitchId.

@Override
public void sendListOfIslPortsBySwitchId(SwitchId switchId, Set<Integer> islPorts) {
    ListIslPortsOnSwitch listIslPortsOnSwitch = ListIslPortsOnSwitch.builder().headers(buildHeader()).switchId(switchId).islPorts(islPorts).build();
    emit(STREAM_CONTROL_COMMANDS_ID, getCurrentTuple(), new Values(switchId.toString(), listIslPortsOnSwitch));
}
Also used : ListIslPortsOnSwitch(org.openkilda.server42.control.messaging.islrtt.ListIslPortsOnSwitch) 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 Builder (org.openkilda.server42.control.messaging.Control.CommandPacket.Builder)1 CommandPacketResponse (org.openkilda.server42.control.messaging.Control.CommandPacketResponse)1 IslRttControl (org.openkilda.server42.control.messaging.islrtt.IslRttControl)1 IslEndpoint (org.openkilda.server42.control.messaging.islrtt.IslRttControl.IslEndpoint)1 ListIslPortsOnSwitch (org.openkilda.server42.control.messaging.islrtt.ListIslPortsOnSwitch)1 KafkaHandler (org.springframework.kafka.annotation.KafkaHandler)1