use of org.springframework.kafka.annotation.KafkaHandler in project open-kilda by telstra.
the class Gate method listen.
@KafkaHandler
void listen(ClearFlows data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) {
Builder builder = CommandPacket.newBuilder();
builder.setType(Type.CLEAR_FLOWS);
SwitchId switchId = new SwitchId(switchIdKey);
FlowRttControl.ClearFlowsFilter clearFlowsFilter = FlowRttControl.ClearFlowsFilter.newBuilder().setDstMac(switchId.toMacAddress()).build();
builder.addCommand(Any.pack(clearFlowsFilter));
try {
zeroMqClient.send(builder.build());
} catch (InvalidProtocolBufferException e) {
log.error("Marshalling error on {}", data);
}
}
use of org.springframework.kafka.annotation.KafkaHandler in project open-kilda by telstra.
the class Gate method listen.
@KafkaHandler
void listen(@Payload AddIsl data) {
Builder builder = CommandPacket.newBuilder();
builder.setType(Type.ADD_ISL);
SwitchId switchId = data.getSwitchId();
String switchIdKey = switchId.toString();
IslEndpoint endpoint = IslEndpoint.newBuilder().setSwitchId(switchIdKey).setPort(data.getPort()).build();
IslRttControl.AddIsl addIsl = IslRttControl.AddIsl.newBuilder().setIsl(endpoint).setSwitchMac(switchId.toMacAddress()).setUdpSrcPort(islRttUdpSrcPortOffset + data.getPort()).setTransitEncapsulationType(IslRttControl.AddIsl.EncapsulationType.VLAN).setTransitTunnelId(switchToVlanMap.get(switchIdKey)).setHashCode(data.hashCode()).build();
builder.addCommand(Any.pack(addIsl));
try {
zeroMqClient.send(builder.build());
} catch (InvalidProtocolBufferException e) {
log.error("Marshalling error on {}", data, e);
}
}
use of org.springframework.kafka.annotation.KafkaHandler in project open-kilda by telstra.
the class Gate method listen.
@KafkaHandler
void listen(PushSettings data) {
Builder builder = CommandPacket.newBuilder();
Control.PushSettings pushSettings = Control.PushSettings.newBuilder().setPacketGenerationIntervalInMs(data.getPacketGenerationIntervalInMs()).build();
builder.setType(Type.PUSH_SETTINGS);
builder.addCommand(Any.pack(pushSettings));
CommandPacket packet = builder.build();
try {
zeroMqClient.send(packet);
} catch (InvalidProtocolBufferException e) {
log.error("Marshalling error on {}", data);
}
}
use of org.springframework.kafka.annotation.KafkaHandler in project open-kilda by telstra.
the class Gate method listen.
@KafkaHandler
void listen(@Payload ClearIsls data) {
Builder builder = CommandPacket.newBuilder();
builder.setType(Type.CLEAR_ISLS);
IslRttControl.ClearIslsFilter clearIslsFilter = IslRttControl.ClearIslsFilter.newBuilder().setSwitchId(data.getSwitchId().toString()).build();
builder.addCommand(Any.pack(clearIslsFilter));
try {
zeroMqClient.send(builder.build());
} catch (InvalidProtocolBufferException e) {
log.error("Marshalling error on {}", data, e);
}
}
use of org.springframework.kafka.annotation.KafkaHandler in project open-kilda by telstra.
the class KafkaMessageListener method onMessage.
/**
* Handles all messages from kafka and sends to corresponding component for further processing.
*
* @param message received message.
*/
@KafkaHandler
public void onMessage(@Header(name = KafkaHeaders.RECEIVED_MESSAGE_KEY, required = false) String key, Message message) {
try (MDCCloseable closable = MDC.putCloseable(Utils.CORRELATION_ID, message.getCorrelationId())) {
log.debug("Message received: {} - {}", Thread.currentThread().getId(), message);
messageProcessor.processRequest(message, key);
}
}
Aggregations