Search in sources :

Example 1 with OfInstallException

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);
    }
}
Also used : ModifyMeterResponse(org.openkilda.messaging.info.switches.ModifyMeterResponse) InvalidMeterIdException(org.openkilda.floodlight.error.InvalidMeterIdException) SwitchId(org.openkilda.model.SwitchId) DatapathId(org.projectfloodlight.openflow.types.DatapathId) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) ErrorType(org.openkilda.messaging.error.ErrorType) ModifyDefaultMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) InfoMessage(org.openkilda.messaging.info.InfoMessage) OfInstallException(org.openkilda.floodlight.error.OfInstallException)

Aggregations

InvalidMeterIdException (org.openkilda.floodlight.error.InvalidMeterIdException)1 OfInstallException (org.openkilda.floodlight.error.OfInstallException)1 SwitchNotFoundException (org.openkilda.floodlight.error.SwitchNotFoundException)1 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)1 IKafkaProducerService (org.openkilda.floodlight.service.kafka.IKafkaProducerService)1 ModifyDefaultMeterForSwitchManagerRequest (org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest)1 ErrorType (org.openkilda.messaging.error.ErrorType)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 ModifyMeterResponse (org.openkilda.messaging.info.switches.ModifyMeterResponse)1 SwitchId (org.openkilda.model.SwitchId)1 DatapathId (org.projectfloodlight.openflow.types.DatapathId)1