RPC opendaylight-direct-statistics:get-flow-statistics not taking nicira
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / extension / MatchExtensionHelper.java
index 8421b8dbffbfdc1ddfca8c27871572c38239df35..de3879b2dbf6358389be94e27a5c4074a052343c 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.extension;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
@@ -23,6 +26,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ge
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNotifSwitchFlowRemovedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNotifUpdateFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNotifUpdateFlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchRpcOutputFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchRpcOutputFlowStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.ExtensionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList;
@@ -32,9 +37,6 @@ import org.opendaylight.yangtools.yang.binding.Augmentable;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
 
 /**
  *
@@ -49,9 +51,10 @@ public final class MatchExtensionHelper {
     }
 
     /**
-     * @param matchEntries
-     * @param ofVersion
-     * @param matchPath
+     * @param matchEntries match entries
+     * @param ofVersion openflow version
+     * @param matchPath match path
+     * @param <EXT_POINT> extension point
      * @return augmentation wrapper containing augmentation depending on matchPath
      */
     @SuppressWarnings("unchecked")
@@ -92,6 +95,13 @@ public final class MatchExtensionHelper {
                             new AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.mod.removed.Match>(
                                     GeneralAugMatchNotifSwitchFlowRemoved.class, generalExtMatchAugBld3.build());
                     break;
+                case RPCFLOWSSTATISTICS_FLOWANDSTATISTICSMAPLIST_MATCH:
+                    GeneralAugMatchRpcOutputFlowStatsBuilder generalExtMatchAugBld4 = new GeneralAugMatchRpcOutputFlowStatsBuilder();
+                    generalExtMatchAugBld4.setExtensionList(extensionsList);
+                    augmentTuple = (AugmentTuple<EXT_POINT>)
+                            new AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match>(
+                                    GeneralAugMatchRpcOutputFlowStats.class, generalExtMatchAugBld4.build());
+                    break;
                 default:
                     LOG.warn("matchPath not supported: {}", matchPath);
             }
@@ -112,19 +122,19 @@ public final class MatchExtensionHelper {
         /** TODO: EXTENSION PROPOSAL (match, OFJava to MD-SAL) */
         MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> key = new MatchEntrySerializerKey<>(
                 ofVersion.getVersion(), matchEntry.getOxmClass(), matchEntry.getOxmMatchField());
-        ConvertorFromOFJava<MatchEntry, MatchPath> convertor = OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
-        if (convertor != null) {
-            ExtensionAugment<? extends Augmentation<Extension>> extensionMatch =
-                    convertor.convert(matchEntry, matchPath);
-            ExtensionBuilder extBld = new ExtensionBuilder();
-            extBld.addAugmentation(extensionMatch.getAugmentationClass(), extensionMatch.getAugmentationObject());
+        if (null != OFSessionUtil.getExtensionConvertorProvider()) {
+            ConvertorFromOFJava<MatchEntry, MatchPath> convertor = OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
+            if (convertor != null) {
+                ExtensionAugment<? extends Augmentation<Extension>> extensionMatch =
+                        convertor.convert(matchEntry, matchPath);
+                ExtensionBuilder extBld = new ExtensionBuilder();
+                extBld.addAugmentation(extensionMatch.getAugmentationClass(), extensionMatch.getAugmentationObject());
 
-            extListBld = new ExtensionListBuilder();
-            extListBld.setExtension(extBld.build());
-            extListBld.setExtensionKey(extensionMatch.getKey());
+                extListBld = new ExtensionListBuilder();
+                extListBld.setExtension(extBld.build());
+                extListBld.setExtensionKey(extensionMatch.getKey());
+            }
         }
-
-
         return extListBld;
     }