BUG-1416 clean up flow statistic models 93/9293/4
authorMichal Rehak <mirehak@cisco.com>
Thu, 24 Jul 2014 15:25:32 +0000 (17:25 +0200)
committeravishnoi <avishnoi@in.ibm.com>
Wed, 30 Jul 2014 06:55:04 +0000 (06:55 +0000)
- duplicate flow model removed from statistics augment
- statistics notification processing adapted
- sal-binding-dom-it fixed

Change-Id: I7ad5bae45b47f5ea8ed918459fc83cbd839b0e3a
Signed-off-by: Michal Rehak <mirehak@cisco.com>
opendaylight/md-sal/model/model-flow-statistics/src/main/yang/opendaylight-flow-statistics.yang
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/FlowStatsTracker.java

index e0df924a0ea5434f81a804efec6447169c22448b..f7a0652e45f042bf891c58a1a7fcdb017e811a2c 100644 (file)
@@ -25,7 +25,6 @@ module opendaylight-flow-statistics {
     grouping flow-statistics {
         container flow-statistics {
             //config "false";
     grouping flow-statistics {
         container flow-statistics {
             //config "false";
-            uses flow-types:flow;
             uses stat-types:generic-statistics;
         }
     }
             uses stat-types:generic-statistics;
         }
     }
index fb5fd1fa6c8f438b120078d1d995ca839dc6b5a7..735138a530ab801149adbaceb79e38c3b27d92b9 100644 (file)
@@ -78,13 +78,12 @@ public class DeleteNestedAugmentationListenParentTest extends AbstractDataServic
         FlowBuilder builder = new FlowBuilder()
             .setKey(FLOW_KEY)
             .addAugmentation(FlowStatisticsData.class,new FlowStatisticsDataBuilder()
         FlowBuilder builder = new FlowBuilder()
             .setKey(FLOW_KEY)
             .addAugmentation(FlowStatisticsData.class,new FlowStatisticsDataBuilder()
-                    .setFlowStatistics(new FlowStatisticsBuilder()
-                        .setBarrier(true)
-                        .setMatch(new MatchBuilder()
-                            .build())
-                        .build())
+                    .setFlowStatistics(new FlowStatisticsBuilder().build())
                     .build())
                     .build())
-        ;//.build();
+            .setBarrier(true)
+            .setMatch(new MatchBuilder()
+            .build())
+        ;
         return builder.build();
     }
 
         return builder.build();
     }
 
index add46bd162fc5644a0f4a5bf13fed72e5ad0a6d2..edf7388a769a662a0ea7848694501c08a864ac0a 100644 (file)
@@ -64,31 +64,15 @@ final class FlowStatsTracker extends AbstractListeningStatsTracker<FlowAndStatis
     protected FlowStatsEntry updateSingleStat(final DataModificationTransaction trans, final FlowAndStatisticsMapList map) {
         short tableId = map.getTableId();
 
     protected FlowStatsEntry updateSingleStat(final DataModificationTransaction trans, final FlowAndStatisticsMapList map) {
         short tableId = map.getTableId();
 
-        FlowBuilder flowBuilder = new FlowBuilder();
-
         FlowStatisticsDataBuilder flowStatisticsData = new FlowStatisticsDataBuilder();
 
         FlowStatisticsDataBuilder flowStatisticsData = new FlowStatisticsDataBuilder();
 
-        FlowBuilder flow = new FlowBuilder();
-        flow.setContainerName(map.getContainerName());
-        flow.setBufferId(map.getBufferId());
-        flow.setCookie(map.getCookie());
-        flow.setCookieMask(map.getCookieMask());
-        flow.setFlags(map.getFlags());
-        flow.setFlowName(map.getFlowName());
-        flow.setHardTimeout(map.getHardTimeout());
-        if(map.getFlowId() != null)
+        FlowBuilder flow = new FlowBuilder(map);
+        if(map.getFlowId() != null) {
             flow.setId(new FlowId(map.getFlowId().getValue()));
             flow.setId(new FlowId(map.getFlowId().getValue()));
-        flow.setIdleTimeout(map.getIdleTimeout());
-        flow.setInstallHw(map.isInstallHw());
-        flow.setInstructions(map.getInstructions());
-        if(map.getFlowId()!= null)
+        }
+        if(map.getFlowId()!= null) {
             flow.setKey(new FlowKey(new FlowId(map.getKey().getFlowId().getValue())));
             flow.setKey(new FlowKey(new FlowId(map.getKey().getFlowId().getValue())));
-        flow.setMatch(map.getMatch());
-        flow.setOutGroup(map.getOutGroup());
-        flow.setOutPort(map.getOutPort());
-        flow.setPriority(map.getPriority());
-        flow.setStrict(map.isStrict());
-        flow.setTableId(tableId);
+        }
 
         Flow flowRule = flow.build();
 
 
         Flow flowRule = flow.build();
 
@@ -105,22 +89,6 @@ final class FlowStatsTracker extends AbstractListeningStatsTracker<FlowAndStatis
         flowStatistics.setByteCount(flowStats.getByteCount());
         flowStatistics.setPacketCount(flowStats.getPacketCount());
         flowStatistics.setDuration(flowStats.getDuration());
         flowStatistics.setByteCount(flowStats.getByteCount());
         flowStatistics.setPacketCount(flowStats.getPacketCount());
         flowStatistics.setDuration(flowStats.getDuration());
-        flowStatistics.setContainerName(map.getContainerName());
-        flowStatistics.setBufferId(map.getBufferId());
-        flowStatistics.setCookie(map.getCookie());
-        flowStatistics.setCookieMask(map.getCookieMask());
-        flowStatistics.setFlags(map.getFlags());
-        flowStatistics.setFlowName(map.getFlowName());
-        flowStatistics.setHardTimeout(map.getHardTimeout());
-        flowStatistics.setIdleTimeout(map.getIdleTimeout());
-        flowStatistics.setInstallHw(map.isInstallHw());
-        flowStatistics.setInstructions(map.getInstructions());
-        flowStatistics.setMatch(map.getMatch());
-        flowStatistics.setOutGroup(map.getOutGroup());
-        flowStatistics.setOutPort(map.getOutPort());
-        flowStatistics.setPriority(map.getPriority());
-        flowStatistics.setStrict(map.isStrict());
-        flowStatistics.setTableId(tableId);
 
         flowStatisticsData.setFlowStatistics(flowStatistics.build());
 
 
         flowStatisticsData.setFlowStatistics(flowStatistics.build());
 
@@ -143,13 +111,12 @@ final class FlowStatsTracker extends AbstractListeningStatsTracker<FlowAndStatis
                             .augmentation(FlowCapableNode.class)
                             .child(Table.class, new TableKey(tableId))
                             .child(Flow.class,existingFlow.getKey()).toInstance();
                             .augmentation(FlowCapableNode.class)
                             .child(Table.class, new TableKey(tableId))
                             .child(Flow.class,existingFlow.getKey()).toInstance();
-                    flowBuilder.setKey(existingFlow.getKey());
-                    flowBuilder.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build());
+                    flow.setKey(existingFlow.getKey());
+                    flow.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build());
                     logger.debug("Found matching flow in the datastore, augmenting statistics");
                     // Update entry with timestamp of latest response
                     logger.debug("Found matching flow in the datastore, augmenting statistics");
                     // Update entry with timestamp of latest response
-                    flow.setKey(existingFlow.getKey());
                     FlowStatsEntry flowStatsEntry = new FlowStatsEntry(tableId,flow.build());
                     FlowStatsEntry flowStatsEntry = new FlowStatsEntry(tableId,flow.build());
-                    trans.putOperationalData(flowRef, flowBuilder.build());
+                    trans.putOperationalData(flowRef, flow.build());
                     return flowStatsEntry;
                 }
             }
                     return flowStatsEntry;
                 }
             }
@@ -168,13 +135,12 @@ final class FlowStatsTracker extends AbstractListeningStatsTracker<FlowAndStatis
                                 .augmentation(FlowCapableNode.class)
                                 .child(Table.class, new TableKey(tableId))
                                 .child(Flow.class,existingFlow.getKey()).toInstance();
                                 .augmentation(FlowCapableNode.class)
                                 .child(Table.class, new TableKey(tableId))
                                 .child(Flow.class,existingFlow.getKey()).toInstance();
-                        flowBuilder.setKey(existingFlow.getKey());
-                        flowBuilder.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build());
+                        flow.setKey(existingFlow.getKey());
+                        flow.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build());
                         logger.debug("Found matching unaccounted flow in the operational datastore, augmenting statistics");
                         // Update entry with timestamp of latest response
                         logger.debug("Found matching unaccounted flow in the operational datastore, augmenting statistics");
                         // Update entry with timestamp of latest response
-                        flow.setKey(existingFlow.getKey());
                         FlowStatsEntry flowStatsEntry = new FlowStatsEntry(tableId,flow.build());
                         FlowStatsEntry flowStatsEntry = new FlowStatsEntry(tableId,flow.build());
-                        trans.putOperationalData(flowRef, flowBuilder.build());
+                        trans.putOperationalData(flowRef, flow.build());
                         return flowStatsEntry;
                     }
                 }
                         return flowStatsEntry;
                     }
                 }
@@ -187,15 +153,15 @@ final class FlowStatsTracker extends AbstractListeningStatsTracker<FlowAndStatis
         InstanceIdentifier<Flow> flowRef = getNodeIdentifierBuilder().augmentation(FlowCapableNode.class)
                     .child(Table.class, new TableKey(tableId))
                     .child(Flow.class,newFlowKey).toInstance();
         InstanceIdentifier<Flow> flowRef = getNodeIdentifierBuilder().augmentation(FlowCapableNode.class)
                     .child(Table.class, new TableKey(tableId))
                     .child(Flow.class,newFlowKey).toInstance();
-        flowBuilder.setKey(newFlowKey);
-        flowBuilder.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build());
+        flow.setKey(newFlowKey);
+        flow.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build());
         logger.debug("Flow {} is not present in config data store, augmenting statistics as an unaccounted flow",
         logger.debug("Flow {} is not present in config data store, augmenting statistics as an unaccounted flow",
-                    flowBuilder.build());
+                    flow.build());
 
         // Update entry with timestamp of latest response
         flow.setKey(newFlowKey);
         FlowStatsEntry flowStatsEntry = new FlowStatsEntry(tableId,flow.build());
 
         // Update entry with timestamp of latest response
         flow.setKey(newFlowKey);
         FlowStatsEntry flowStatsEntry = new FlowStatsEntry(tableId,flow.build());
-        trans.putOperationalData(flowRef, flowBuilder.build());
+        trans.putOperationalData(flowRef, flow.build());
         return flowStatsEntry;
     }
 
         return flowStatsEntry;
     }