use of org.openkilda.floodlight.service.kafka.IKafkaProducerService in project open-kilda by telstra.
the class RecordHandler method doDeleteMeter.
private void doDeleteMeter(CommandMessage message, String replyToTopic) {
DeleteMeterRequest request = (DeleteMeterRequest) message.getData();
logger.info("Deleting meter '{}'. Switch: '{}'", request.getMeterId(), request.getSwitchId());
final IKafkaProducerService producerService = getKafkaProducer();
try {
DatapathId dpid = DatapathId.of(request.getSwitchId().toLong());
context.getSwitchManager().deleteMeter(dpid, request.getMeterId());
boolean deleted = context.getSwitchManager().dumpMeters(dpid).stream().noneMatch(config -> config.getMeterId() == request.getMeterId());
DeleteMeterResponse response = new DeleteMeterResponse(deleted);
InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, message.getCorrelationId(), infoMessage);
} catch (SwitchOperationException e) {
logger.error("Deleting meter '{}' from switch '{}' was unsuccessful: {}", request.getMeterId(), request.getSwitchId(), e.getMessage());
anError(ErrorType.DATA_INVALID).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
use of org.openkilda.floodlight.service.kafka.IKafkaProducerService in project open-kilda by telstra.
the class RecordHandler method doDumpSwitchPortsDescriptionRequest.
private void doDumpSwitchPortsDescriptionRequest(CommandMessage message) {
DumpSwitchPortsDescriptionRequest request = (DumpSwitchPortsDescriptionRequest) message.getData();
final IKafkaProducerService producerService = getKafkaProducer();
final String replyToTopic = context.getKafkaNorthboundTopic();
try {
SwitchId switchId = request.getSwitchId();
logger.info("Dump ALL ports description for switch {}", switchId);
SwitchPortsDescription response = getSwitchPortsDescription(switchId);
InfoMessage infoMessage = new InfoMessage(response, message.getTimestamp(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, infoMessage);
} catch (SwitchOperationException e) {
logger.error("Unable to dump switch port descriptions request", e);
anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("Unable to dump switch port descriptions request").withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
use of org.openkilda.floodlight.service.kafka.IKafkaProducerService in project open-kilda by telstra.
the class RecordHandler method doModifyFlowMeterForSwitchManager.
private void doModifyFlowMeterForSwitchManager(CommandMessage message) {
ModifyFlowMeterForSwitchManagerRequest request = (ModifyFlowMeterForSwitchManagerRequest) message.getData();
IKafkaProducerService producerService = getKafkaProducer();
long meterId = request.getMeterId();
SwitchId switchId = request.getSwitchId();
MeterConfig meterConfig = new MeterConfig(new MeterId(request.getMeterId()), request.getRate());
logger.info("Modifying flow meter {} on Switch {}", meterId, switchId);
handleSpeakerCommand(new MeterModifyCommand(new MessageContext(message), switchId, meterConfig));
InfoMessage response = new InfoMessage(new ModifyMeterResponse(switchId, request.getMeterId()), System.currentTimeMillis(), message.getCorrelationId());
producerService.sendMessageAndTrack(context.getKafkaSwitchManagerTopic(), message.getCorrelationId(), response);
}
use of org.openkilda.floodlight.service.kafka.IKafkaProducerService in project open-kilda by telstra.
the class RecordHandler method doDumpPortDescriptionRequest.
private void doDumpPortDescriptionRequest(CommandMessage message) {
DumpPortDescriptionRequest request = (DumpPortDescriptionRequest) message.getData();
final IKafkaProducerService producerService = getKafkaProducer();
final String replyToTopic = context.getKafkaNorthboundTopic();
try {
SwitchId switchId = request.getSwitchId();
logger.info("Get port {}_{} description", switchId, request.getPortNumber());
SwitchPortsDescription switchPortsDescription = getSwitchPortsDescription(switchId);
int port = request.getPortNumber();
PortDescription response = switchPortsDescription.getPortsDescription().stream().filter(x -> x.getPortNumber() == port).findFirst().orElseThrow(() -> new SwitchOperationException(DatapathId.of(switchId.toLong()), format("Port %s_%d does not exists.", switchId, port)));
InfoMessage infoMessage = new InfoMessage(response, message.getTimestamp(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, infoMessage);
} catch (SwitchOperationException e) {
logger.error("Unable to dump port description request", e);
anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("Unable to dump port description request").withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
use of org.openkilda.floodlight.service.kafka.IKafkaProducerService in project open-kilda by telstra.
the class SpeakerCommandProcessor method handleResult.
private void handleResult(SpeakerCommandRemoteReport report, String kafkaKey) {
KafkaUtilityService kafkaUtil = moduleContext.getServiceImpl(KafkaUtilityService.class);
IKafkaProducerService kafkaProducer = moduleContext.getServiceImpl(IKafkaProducerService.class);
report.reply(kafkaUtil.getKafkaChannel(), kafkaProducer, kafkaKey);
}
Aggregations