X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Ftranslator%2FFlowRemovedTranslator.java;h=86d4c9c3a40983334157f3a031b8bb1bd69f7787;hb=371c65647d29712b92836dcc2b178d42aecbf9c7;hp=4aa08b00288f215fe1ec111544d5600e9e025941;hpb=f7bb5e29abc769d488b32d5ef74c4844e2aa31d8;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java index 4aa08b0028..86d4c9c3a4 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java @@ -7,36 +7,60 @@ */ package org.opendaylight.openflowplugin.impl.translator; -import org.opendaylight.openflowplugin.api.openflow.device.DeviceState; +import java.util.Objects; +import java.util.Optional; +import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator; -import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; -import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemovedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.RemovedFlowReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * translate {@link FlowRemoved} message to FlowRemoved notification (omit instructions) */ public class FlowRemovedTranslator implements MessageTranslator { + private final ConvertorExecutor convertorExecutor; + private static final Logger logger = LoggerFactory.getLogger(FlowRemovedTranslator.class); + public FlowRemovedTranslator(ConvertorExecutor convertorExecutor) { + this.convertorExecutor = convertorExecutor; + } + + protected ConvertorExecutor getConvertorExecutor() { + return convertorExecutor; + } @Override - public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceState deviceState, Object connectionDistinguisher) { + public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceInfo deviceInfo, Object connectionDistinguisher) { FlowRemovedBuilder flowRemovedBld = new FlowRemovedBuilder() - .setMatch(translateMatch(input, deviceState).build()) + .setMatch(translateMatch(input, deviceInfo).build()) .setCookie(new FlowCookie(input.getCookie())) - .setNode(new NodeRef(deviceState.getNodeInstanceIdentifier())) + .setNode(new NodeRef(deviceInfo.getNodeInstanceIdentifier())) .setPriority(input.getPriority()) .setTableId(translateTableId(input)); + if(Objects.nonNull(input.getReason())) { + flowRemovedBld.setReason(translateReason(input)); + } + return flowRemovedBld.build(); } - protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceState deviceState) { - return MatchConvertorImpl.fromOFMatchToSALMatch(flowRemoved.getMatch(), - deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF13); + protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) { + final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(deviceInfo.getVersion()); + datapathIdConvertorData.setDatapathId(deviceInfo.getDatapathId()); + + final Optional matchBuilderOptional = getConvertorExecutor().convert( + flowRemoved.getMatch(), + datapathIdConvertorData); + + return matchBuilderOptional.orElse(new MatchBuilder()); } /** @@ -48,4 +72,22 @@ public class FlowRemovedTranslator implements MessageTranslator