Group and Meter desc statistics testing 73/4473/2
authoretusgoy <goyaltushar7@gmail.com>
Tue, 21 Jan 2014 07:25:48 +0000 (12:55 +0530)
committeretusgoy <goyaltushar7@gmail.com>
Tue, 21 Jan 2014 07:25:48 +0000 (12:55 +0530)
Signed-off-by: etusgoy <goyaltushar7@gmail.com>
Change-Id: I06e0fe1af27ba32e1a2bee2a5beab525b0fe73d2

test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java

index c989663f9ddd0d70efa7a75433cdef99368fe543..23e752d7b4ba5c2b3878c1f6267c5834f17f17d6 100644 (file)
@@ -1,10 +1,3 @@
-/**
- * Copyright IBM Corporation, 2013.  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.test;
 
 import java.util.Iterator;
@@ -24,7 +17,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
@@ -34,13 +31,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
 
+       private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginStatsTestCommandProvider.class);
     private DataProviderService dataProviderService;
     private final BundleContext ctx;
 
@@ -52,7 +53,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
     public void onSessionInitiated(ProviderContext session) {
         dataProviderService = session.getSALService(DataProviderService.class);
         ctx.registerService(CommandProvider.class.getName(), this, null);
-        
+      
     }
 
     public void _portStats(CommandInterpreter ci) {
@@ -79,12 +80,12 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
             
             if(nodeConnectorCount == nodeConnectorStatsCount)
             {
-                ci.println("portStats - Success");
+                LOG.debug("portStats - Success");
             }
             else
             {
-                ci.println("portStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+                LOG.debug("portStats - Failed");
+                LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
             }
                            
        }
@@ -118,12 +119,12 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
             
             if(nodeConnectorCount == nodeConnectorDescStatsCount)
             {
-                ci.println("portDescStats - Success");
+                LOG.debug("portDescStats - Success");
             }
             else
             {
-                ci.println("portDescStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+                LOG.debug("portDescStats - Failed");
+                LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
             }
                            
        }
@@ -151,6 +152,8 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
                         if(null != data)
                         {
                             flowStatsCount++;
+                            LOG.debug("--------------------------------------------");
+                            ci.print(data);
                         }
                     }                    
                 }
@@ -158,17 +161,18 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
             
             if(flowCount == flowStatsCount)
             {
-                ci.println("flowStats - Success");
+                LOG.debug("flowStats - Success");
             }
             else
             {
-                ci.println("flowStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+                LOG.debug("flowStats - Failed");
+                LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
             }
                            
        }
 
    
 
     public void _tableStats(CommandInterpreter ci) {
         int tableCount = 0;
@@ -195,12 +199,12 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
             
             if(tableCount == tableStatsCount)
             {
-                ci.println("tableStats - Success");
+                LOG.debug("tableStats - Success");
             }
             else
             {
-                ci.println("tableStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+                LOG.debug("tableStats - Failed");
+                LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
             }
                            
        }
@@ -208,6 +212,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
     public void _groupStats(CommandInterpreter ci) {
         int groupCount = 0;
         int groupStatsCount = 0;
+        NodeGroupStatistics data = null;
             List<Node> nodes = getNodes();
             for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
                 NodeKey nodeKey =  iterator.next().getKey();
@@ -220,7 +225,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
                     GroupKey groupKey = iterator2.next().getKey();
                     InstanceIdentifier<Group> groupRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey).toInstance();
                     Group group = (Group)dataProviderService.readOperationalData(groupRef);
-                    NodeGroupStatistics data = group.getAugmentation(NodeGroupStatistics.class);
+                    data = group.getAugmentation(NodeGroupStatistics.class);
                     if(null != data)
                     {
                         groupStatsCount++;
@@ -230,18 +235,54 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
             
             if(groupCount == groupStatsCount)
             {
-                ci.println("---------------------groupStats - Success-------------------------------");
+                LOG.debug("---------------------groupStats - Success-------------------------------");           
+            }
+            else
+            {
+                LOG.debug("------------------------------groupStats - Failed--------------------------");
+                LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+            }                        
+       }
+    
+    public void _groupDescStats(CommandInterpreter ci) {
+        int groupCount = 0;
+        int groupDescStatsCount = 0;
+        NodeGroupDescStats data = null;
+            List<Node> nodes = getNodes();
+            for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
+                NodeKey nodeKey =  iterator.next().getKey();
+                InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+                FlowCapableNode node = (FlowCapableNode)dataProviderService.readOperationalData(nodeRef);
+
+               List<Group> groups =  node.getGroup();
+                for (Iterator<Group> iterator2 = groups.iterator(); iterator2.hasNext();) {
+                    groupCount++;
+                    GroupKey groupKey = iterator2.next().getKey();
+                    InstanceIdentifier<Group> groupRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey).toInstance();
+                    Group group = (Group)dataProviderService.readOperationalData(groupRef);
+                    data = group.getAugmentation(NodeGroupDescStats.class);
+                    if(null != data)
+                    {
+                        groupDescStatsCount++;
+                    }
+                }
+            }
+            
+            if(groupCount == groupDescStatsCount)
+            {
+                LOG.debug("---------------------groupDescStats - Success-------------------------------");
             }
             else
             {
-                ci.println("------------------------------groupStats - Failed--------------------------");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+                LOG.debug("------------------------------groupDescStats - Failed--------------------------");
+                LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
             }                        
        }
     
     public void _meterStats(CommandInterpreter ci) {
         int meterCount = 0;
         int meterStatsCount = 0;
+        NodeMeterStatistics data = null;
             List<Node> nodes = getNodes();
             for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
                 NodeKey nodeKey =  iterator.next().getKey();
@@ -254,7 +295,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
                     MeterKey meterKey = iterator2.next().getKey();
                     InstanceIdentifier<Meter> meterRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Meter.class, meterKey).toInstance();
                     Meter meter = (Meter)dataProviderService.readOperationalData(meterRef);
-                    NodeMeterStatistics data = meter.getAugmentation(NodeMeterStatistics.class);
+                    data = meter.getAugmentation(NodeMeterStatistics.class);
                     if(null != data)
                     {
                         meterStatsCount++;
@@ -264,15 +305,51 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
             
             if(meterCount == meterStatsCount)
             {
-                ci.println("---------------------------meterStats - Success-------------------------------------");
+                LOG.debug("---------------------------meterStats - Success-------------------------------------");
             }
             else
             {
-                ci.println("----------------------------meterStats - Failed-------------------------------------");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+                LOG.debug("----------------------------meterStats - Failed-------------------------------------");
+                LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
             }                        
        }
-    
+    public void _meterConfigStats(CommandInterpreter ci) {
+        int meterCount = 0;
+        int meterConfigStatsCount = 0;
+        NodeMeterConfigStats data = null;
+            List<Node> nodes = getNodes();
+            for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
+                NodeKey nodeKey =  iterator.next().getKey();
+                InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+                FlowCapableNode node = (FlowCapableNode)dataProviderService.readOperationalData(nodeRef);
+
+               List<Meter> meters =  node.getMeter();
+                for (Iterator<Meter> iterator2 = meters.iterator(); iterator2.hasNext();) {
+                    meterCount++;
+                    MeterKey meterKey = iterator2.next().getKey();
+                    InstanceIdentifier<Meter> meterRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Meter.class, meterKey).toInstance();
+                    Meter meter = (Meter)dataProviderService.readOperationalData(meterRef);
+                    data = meter.getAugmentation(NodeMeterConfigStats.class);
+                    if(null != data)
+                    {
+                        meterConfigStatsCount++;
+                    }
+                }
+            }
+            
+            if(meterCount == meterConfigStatsCount)
+            {
+                LOG.debug("---------------------------meterConfigStats - Success-------------------------------------");
+                ci.print(data);
+            }
+            else
+            {
+                LOG.debug("----------------------------meterConfigStats - Failed-------------------------------------");
+                LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+            }                        
+       }
     
     public void _aggregateStats(CommandInterpreter ci) {
         int aggregateFlowCount = 0;
@@ -299,12 +376,12 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
             
             if(aggregateFlowCount == aggerateFlowStatsCount)
             {
-                ci.println("aggregateStats - Success");
+                LOG.debug("aggregateStats - Success");
             }
             else
             {
-                ci.println("aggregateStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+                LOG.debug("aggregateStats - Failed");
+                LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
             }
                            
        }
@@ -328,12 +405,12 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
             
             if(descCount == descStatsCount)
             {
-                ci.println("descStats - Success");
+                LOG.debug("descStats - Success");
             }
             else
             {
-                ci.println("descStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+                LOG.debug("descStats - Failed");
+                LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
             }
                            
        }