Merge "BUG-4117: add support for meter and group old Notif"
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / FlowStatsResponseConvertor.java
index c3e8fc29d5c9e1fea3a1687a349b0240e7bc31a5..63f3da1456202b7b1a1d3a08f3e022ca132c9e4b 100644 (file)
@@ -1,17 +1,21 @@
 /*
- * Copyright IBM Corporation, 2013.  All rights reserved.
+ * Copyright (c) 2013, 2015 IBM Corporation and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
+
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
@@ -23,10 +27,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
 
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * Class is an utility class for converting flow related statistics messages coming from openflow
  * switch to MD-SAL messages.
@@ -38,8 +38,10 @@ public class FlowStatsResponseConvertor {
     /**
      * Method returns the list of MD-SAL format flow statistics, converted flow Openflow
      * specific flow statistics.
-     * @param allFlowStats
-     * @return
+     * @param allFlowStats all flow stats
+     * @param datapathid  datapath id
+     * @param ofVersion  openflow version
+     * @return list of flow and statistics mapping
      */
     public List<FlowAndStatisticsMapList> toSALFlowStatsList(List<FlowStats> allFlowStats, BigInteger datapathid, OpenflowVersion ofVersion){
 
@@ -55,8 +57,10 @@ public class FlowStatsResponseConvertor {
     /**
      * Method convert Openflow switch specific flow statistics to the MD-SAL format
      * flow statistics.
-     * @param flowStats
-     * @return
+     * @param flowStats flow statis
+     * @param datapathid  datapath id
+     * @param ofVersion  openflow version
+     * @return flow and statistics map
      */
     public FlowAndStatisticsMapList toSALFlowStats(FlowStats flowStats, BigInteger datapathid, OpenflowVersion ofVersion){
         FlowAndStatisticsMapListBuilder salFlowStatsBuilder = new FlowAndStatisticsMapListBuilder();
@@ -75,22 +79,22 @@ public class FlowStatsResponseConvertor {
         salFlowStatsBuilder.setPriority(flowStats.getPriority());
         salFlowStatsBuilder.setTableId(flowStats.getTableId());
         if(flowStats.getMatchV10() != null){
-            salFlowStatsBuilder.setMatch(MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowStats.getMatchV10(),datapathid, OpenflowVersion.OF10));
+            salFlowStatsBuilder.setMatch(MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowStats.getMatchV10(), datapathid, OpenflowVersion.OF10).build());
             if(flowStats.getAction() != null && flowStats.getAction().size()!=0){
                 salFlowStatsBuilder.setInstructions(OFToMDSalFlowConvertor.wrapOF10ActionsToInstruction(flowStats.getAction(), ofVersion));
             }
         }
         if(flowStats.getMatch() != null){
             MatchBuilder matchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(flowStats.getMatch(),datapathid, ofVersion);
-            
-            AugmentTuple<Match> matchExtensionWrap = 
+
+            AugmentTuple<Match> matchExtensionWrap =
                     MatchExtensionHelper.processAllExtensions(
-                            flowStats.getMatch().getMatchEntries(), ofVersion, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+                            flowStats.getMatch().getMatchEntry(), ofVersion, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
             if (matchExtensionWrap != null) {
                 matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
             }
-            
-            
+
+
             salFlowStatsBuilder.setMatch(matchBuilder.build());
             salFlowStatsBuilder.setFlags(
                     new FlowModFlags(flowStats.getFlags().isOFPFFCHECKOVERLAP(),