Search in sources :

Example 1 with SwitchOperationException

use of org.openkilda.floodlight.switchmanager.SwitchOperationException in project open-kilda by telstra.

the class RecordHandler method doProcessTransitFlow.

/**
 * Processes transit flow installing message.
 *
 * @param message command message for flow installation
 */
private void doProcessTransitFlow(final CommandMessage message, String replyToTopic, Destination replyDestination) throws FlowCommandException {
    InstallTransitFlow command = (InstallTransitFlow) message.getData();
    try {
        installTransitFlow(command);
        message.setDestination(replyDestination);
        context.getKafkaProducer().postMessage(replyToTopic, message);
    } catch (SwitchOperationException e) {
        throw new FlowCommandException(command.getId(), ErrorType.CREATION_FAILURE, e);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.switchmanager.SwitchOperationException) InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow)

Example 2 with SwitchOperationException

use of org.openkilda.floodlight.switchmanager.SwitchOperationException in project open-kilda by telstra.

the class RecordHandler method doProcessOneSwitchFlow.

/**
 * Processes one-switch flow installing message.
 *
 * @param message command message for flow installation
 */
private void doProcessOneSwitchFlow(final CommandMessage message, String replyToTopic, Destination replyDestination) throws FlowCommandException {
    InstallOneSwitchFlow command = (InstallOneSwitchFlow) message.getData();
    logger.debug("creating a flow through one switch: {}", command);
    try {
        installOneSwitchFlow(command);
        message.setDestination(replyDestination);
        context.getKafkaProducer().postMessage(replyToTopic, message);
    } catch (SwitchOperationException e) {
        throw new FlowCommandException(command.getId(), ErrorType.CREATION_FAILURE, e);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.switchmanager.SwitchOperationException) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow)

Example 3 with SwitchOperationException

use of org.openkilda.floodlight.switchmanager.SwitchOperationException in project open-kilda by telstra.

the class RecordHandler method doSyncRulesRequest.

/**
 * Installs missed flows on the switch.
 * @param message with list of flows.
 */
private void doSyncRulesRequest(final CommandMessage message) {
    InstallMissedFlowsRequest request = (InstallMissedFlowsRequest) message.getData();
    final String switchId = request.getSwitchId();
    logger.debug("Processing rules to be updated for switch {}", switchId);
    for (BaseInstallFlow command : request.getFlowCommands()) {
        logger.debug("Processing command for switch {} {}", switchId, command);
        try {
            if (command instanceof InstallIngressFlow) {
                installIngressFlow((InstallIngressFlow) command);
            } else if (command instanceof InstallEgressFlow) {
                installEgressFlow((InstallEgressFlow) command);
            } else if (command instanceof InstallTransitFlow) {
                installTransitFlow((InstallTransitFlow) command);
            } else if (command instanceof InstallOneSwitchFlow) {
                installOneSwitchFlow((InstallOneSwitchFlow) command);
            }
        } catch (SwitchOperationException e) {
            logger.error("Error during flow installation", e);
        }
    }
}
Also used : InstallIngressFlow(org.openkilda.messaging.command.flow.InstallIngressFlow) SwitchOperationException(org.openkilda.floodlight.switchmanager.SwitchOperationException) InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow) InstallMissedFlowsRequest(org.openkilda.messaging.command.switches.InstallMissedFlowsRequest) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) BaseInstallFlow(org.openkilda.messaging.command.flow.BaseInstallFlow) InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow)

Example 4 with SwitchOperationException

use of org.openkilda.floodlight.switchmanager.SwitchOperationException in project open-kilda by telstra.

the class RecordHandler method doProcessIngressFlow.

/**
 * Processes install ingress flow message.
 *
 * @param message command message for flow installation
 */
private void doProcessIngressFlow(final CommandMessage message, String replyToTopic, Destination replyDestination) throws FlowCommandException {
    InstallIngressFlow command = (InstallIngressFlow) message.getData();
    try {
        installIngressFlow(command);
        message.setDestination(replyDestination);
        context.getKafkaProducer().postMessage(replyToTopic, message);
    } catch (SwitchOperationException e) {
        throw new FlowCommandException(command.getId(), ErrorType.CREATION_FAILURE, e);
    }
}
Also used : InstallIngressFlow(org.openkilda.messaging.command.flow.InstallIngressFlow) SwitchOperationException(org.openkilda.floodlight.switchmanager.SwitchOperationException)

Example 5 with SwitchOperationException

use of org.openkilda.floodlight.switchmanager.SwitchOperationException in project open-kilda by telstra.

the class RecordHandler method doDeleteFlow.

/**
 * Removes flow.
 *
 * @param message command message for flow installation
 */
private void doDeleteFlow(final CommandMessage message, String replyToTopic, Destination replyDestination) throws FlowCommandException {
    RemoveFlow command = (RemoveFlow) message.getData();
    logger.debug("deleting a flow: {}", command);
    DatapathId dpid = DatapathId.of(command.getSwitchId());
    ISwitchManager switchManager = context.getSwitchManager();
    try {
        switchManager.deleteFlow(dpid, command.getId(), command.getCookie());
        Integer meterId = meterPool.deallocate(command.getSwitchId(), command.getId());
        if (meterId != null) {
            switchManager.deleteMeter(dpid, meterId);
        }
        message.setDestination(replyDestination);
        context.getKafkaProducer().postMessage(replyToTopic, message);
    } catch (SwitchOperationException e) {
        throw new FlowCommandException(command.getId(), ErrorType.DELETION_FAILURE, e);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.switchmanager.SwitchOperationException) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) DatapathId(org.projectfloodlight.openflow.types.DatapathId)

Aggregations

SwitchOperationException (org.openkilda.floodlight.switchmanager.SwitchOperationException)9 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)4 DatapathId (org.projectfloodlight.openflow.types.DatapathId)3 InstallEgressFlow (org.openkilda.messaging.command.flow.InstallEgressFlow)2 InstallIngressFlow (org.openkilda.messaging.command.flow.InstallIngressFlow)2 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)2 InstallTransitFlow (org.openkilda.messaging.command.flow.InstallTransitFlow)2 ErrorData (org.openkilda.messaging.error.ErrorData)2 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)2 InfoMessage (org.openkilda.messaging.info.InfoMessage)2 SwitchRulesResponse (org.openkilda.messaging.info.switches.SwitchRulesResponse)2 HashMap (java.util.HashMap)1 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)1 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)1 DeleteRulesAction (org.openkilda.messaging.command.switches.DeleteRulesAction)1 InstallMissedFlowsRequest (org.openkilda.messaging.command.switches.InstallMissedFlowsRequest)1 InstallRulesAction (org.openkilda.messaging.command.switches.InstallRulesAction)1 SwitchRulesDeleteRequest (org.openkilda.messaging.command.switches.SwitchRulesDeleteRequest)1 SwitchRulesInstallRequest (org.openkilda.messaging.command.switches.SwitchRulesInstallRequest)1 MessageError (org.openkilda.messaging.error.MessageError)1