Search in sources :

Example 1 with ListIslsRequest

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

the class Gate method listen.

@KafkaHandler
void listen(@Payload ListIslsRequest 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;
        }
        HashSet<Integer> portList = new HashSet<>();
        for (Any any : serverResponse.getResponseList()) {
            portList.add(any.unpack(IslEndpoint.class).getPort());
        }
        ListIslsResponse response = ListIslsResponse.builder().headers(data.getHeaders()).switchId(data.getSwitchId()).ports(portList).build();
        template.send(toStorm, response);
    } catch (InvalidProtocolBufferException e) {
        log.error("Marshalling error on {}", data, e);
    }
}
Also used : 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) ListIslsResponse(org.openkilda.server42.control.messaging.islrtt.ListIslsResponse) Any(com.google.protobuf.Any) HashSet(java.util.HashSet) KafkaHandler(org.springframework.kafka.annotation.KafkaHandler)

Aggregations

Any (com.google.protobuf.Any)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 HashSet (java.util.HashSet)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 ListIslsResponse (org.openkilda.server42.control.messaging.islrtt.ListIslsResponse)1 KafkaHandler (org.springframework.kafka.annotation.KafkaHandler)1