use of org.openkilda.floodlight.error.OfInstallException in project open-kilda by telstra.
the class RecordHandler method doModifyDefaultMeterForSwitchManager.
private void doModifyDefaultMeterForSwitchManager(CommandMessage message) {
ModifyDefaultMeterForSwitchManagerRequest request = (ModifyDefaultMeterForSwitchManagerRequest) message.getData();
IKafkaProducerService producerService = getKafkaProducer();
String replyToTopic = context.getKafkaSwitchManagerTopic();
long meterId = request.getMeterId();
SwitchId switchId = request.getSwitchId();
DatapathId dpid = DatapathId.of(switchId.toLong());
try {
context.getSwitchManager().modifyDefaultMeter(dpid, request.getMeterId());
InfoMessage response = new InfoMessage(new ModifyMeterResponse(switchId, request.getMeterId()), System.currentTimeMillis(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, message.getCorrelationId(), response);
} catch (UnsupportedSwitchOperationException e) {
logger.warn(format("Skip meter %d modification on switch %s because switch doesn't support meters", meterId, switchId), e);
} catch (InvalidMeterIdException | OfInstallException | SwitchNotFoundException e) {
logger.error("Failed to modify meter {} for switch: '{}'", request.getSwitchId(), meterId, e);
ErrorType errorType;
if (e instanceof InvalidMeterIdException) {
errorType = ErrorType.DATA_INVALID;
} else if (e instanceof SwitchNotFoundException) {
errorType = ErrorType.NOT_FOUND;
} else {
errorType = ErrorType.INTERNAL_ERROR;
}
anError(errorType).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
Aggregations