Merge "Added a signum to the SetMetaDataMask BigInt constructor"
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginStatsTestCommandProvider.java
index 7eaf33d89c137c59c35a66ebfa794385d3f4937d..8ee8833175b273a35e88a9bebee93a3b458f3dbd 100644 (file)
@@ -2,11 +2,11 @@ package org.opendaylight.openflowplugin.test;
 
 import java.util.Iterator;
 import java.util.List;
-
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
@@ -18,8 +18,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 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.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;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
@@ -27,322 +27,409 @@ 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 DataProviderService dataProviderService;
+    private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginStatsTestCommandProvider.class);
+    private DataBroker dataProviderService;
     private final BundleContext ctx;
 
     public OpenflowpluginStatsTestCommandProvider(BundleContext ctx) {
         this.ctx = ctx;
     }
-    
+
 
     public void onSessionInitiated(ProviderContext session) {
-        dataProviderService = session.getSALService(DataProviderService.class);
+        dataProviderService = session.getSALService(DataBroker.class);
         ctx.registerService(CommandProvider.class.getName(), this, null);
-        
+
     }
 
     public void _portStats(CommandInterpreter ci) {
         int nodeConnectorCount = 0;
         int nodeConnectorStatsCount = 0;
-            List<Node> nodes = getNodes();
-            for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
-                NodeKey nodeKey =  iterator.next().getKey();
-                InstanceIdentifier<Node> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).toInstance();
-                Node node = (Node)dataProviderService.readOperationalData(nodeRef);
-                List<NodeConnector> ports =  node.getNodeConnector();
-                for (Iterator<NodeConnector> iterator2 = ports.iterator(); iterator2.hasNext();) {
+        List<Node> nodes = getNodes();
+        for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
+            NodeKey nodeKey = iterator.next().getKey();
+            InstanceIdentifier<Node> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
+
+            ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+            Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+            if (node != null) {
+                List<NodeConnector> ports = node.getNodeConnector();
+                for (Iterator<NodeConnector> iterator2 = ports.iterator(); iterator2.hasNext(); ) {
                     nodeConnectorCount++;
                     NodeConnectorKey nodeConnectorKey = iterator2.next().getKey();
-                    InstanceIdentifier<NodeConnector> connectorRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).child(NodeConnector.class, nodeConnectorKey).toInstance();
-                    NodeConnector nodeConnector = (NodeConnector)dataProviderService.readOperationalData(connectorRef);
-                    FlowCapableNodeConnectorStatisticsData data = nodeConnector.getAugmentation(FlowCapableNodeConnectorStatisticsData.class);
-                    if(null != data)
-                    {
-                        nodeConnectorStatsCount++;
+                    InstanceIdentifier<NodeConnector> connectorRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).child(NodeConnector.class, nodeConnectorKey);
+                    NodeConnector nodeConnector = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, connectorRef);
+                    if (nodeConnector != null) {
+                        FlowCapableNodeConnectorStatisticsData data = nodeConnector.getAugmentation(FlowCapableNodeConnectorStatisticsData.class);
+                        if (null != data) {
+                            nodeConnectorStatsCount++;
+                        }
                     }
                 }
             }
-            
-            if(nodeConnectorCount == nodeConnectorStatsCount)
-            {
-                ci.println("portStats - Success");
-            }
-            else
-            {
-                ci.println("portStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
-            }
-                           
-       }
+        }
+
+        if (nodeConnectorCount == nodeConnectorStatsCount) {
+            LOG.debug("portStats - Success");
+        } else {
+            LOG.debug("portStats - Failed");
+            LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+        }
+
+    }
+
 
-    
     public void _portDescStats(CommandInterpreter ci) {
         int nodeConnectorCount = 0;
         int nodeConnectorDescStatsCount = 0;
-            List<Node> nodes = getNodes();
-            for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
-                NodeKey nodeKey =  iterator.next().getKey();
-                InstanceIdentifier<Node> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).toInstance();
-                Node node = (Node)dataProviderService.readOperationalData(nodeRef);
-
-               List<NodeConnector> ports =  node.getNodeConnector();
-                for (Iterator<NodeConnector> iterator2 = ports.iterator(); iterator2.hasNext();) {
+        List<Node> nodes = getNodes();
+        for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
+            NodeKey nodeKey = iterator.next().getKey();
+            InstanceIdentifier<Node> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
+
+            ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+            Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+            if (node != null) {
+                List<NodeConnector> ports = node.getNodeConnector();
+                for (Iterator<NodeConnector> iterator2 = ports.iterator(); iterator2.hasNext(); ) {
                     nodeConnectorCount++;
                     NodeConnectorKey nodeConnectorKey = iterator2.next().getKey();
-                    InstanceIdentifier<FlowCapableNodeConnector> connectorRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).child(NodeConnector.class, nodeConnectorKey).augmentation(FlowCapableNodeConnector.class).toInstance();
-                    FlowCapableNodeConnector nodeConnector = (FlowCapableNodeConnector)dataProviderService.readOperationalData(connectorRef);
-                    if(null != nodeConnector.getName() &&
-                            null != nodeConnector.getCurrentFeature() &&
-                            null != nodeConnector.getState() &&
-                            null != nodeConnector.getHardwareAddress() &&
-                            null != nodeConnector.getPortNumber())
-                    {
-                        nodeConnectorDescStatsCount++;
+                    InstanceIdentifier<FlowCapableNodeConnector> connectorRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).child(NodeConnector.class, nodeConnectorKey).augmentation(FlowCapableNodeConnector.class);
+                    FlowCapableNodeConnector nodeConnector = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, connectorRef);
+                    if (nodeConnector != null) {
+                        if (null != nodeConnector.getName() &&
+                                null != nodeConnector.getCurrentFeature() &&
+                                null != nodeConnector.getState() &&
+                                null != nodeConnector.getHardwareAddress() &&
+                                null != nodeConnector.getPortNumber()) {
+                            nodeConnectorDescStatsCount++;
+                        }
                     }
                 }
             }
-            
-            if(nodeConnectorCount == nodeConnectorDescStatsCount)
-            {
-                ci.println("portDescStats - Success");
-            }
-            else
-            {
-                ci.println("portDescStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
-            }
-                           
-       }
+        }
+
+        if (nodeConnectorCount == nodeConnectorDescStatsCount) {
+            LOG.debug("portDescStats - Success");
+        } else {
+            LOG.debug("portDescStats - Failed");
+            LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+        }
+
+    }
 
     public void _flowStats(CommandInterpreter ci) {
         int flowCount = 0;
         int flowStatsCount = 0;
-            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<Table> tables =  node.getTable();
-                for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext();) {
+        List<Node> nodes = getNodes();
+        for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
+            NodeKey nodeKey = iterator.next().getKey();
+            InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
+
+            ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+            FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+
+            if (node != null) {
+                List<Table> tables = node.getTable();
+                for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext(); ) {
                     TableKey tableKey = iterator2.next().getKey();
-                    InstanceIdentifier<Table> tableRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).toInstance();
-                    Table table = (Table)dataProviderService.readOperationalData(tableRef);
-                    List<Flow> flows = table.getFlow();
-                    for (Iterator<Flow> iterator3 = flows.iterator(); iterator3.hasNext();) {
-                        flowCount++;
-                        FlowKey flowKey =  iterator3.next().getKey();
-                        InstanceIdentifier<Flow> flowRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey).toInstance();
-                        Flow flow = (Flow)dataProviderService.readOperationalData(flowRef);
-                        FlowStatisticsData data = flow.getAugmentation(FlowStatisticsData.class);
-                        if(null != data)
-                        {
-                            flowStatsCount++;
+                    InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
+                    Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
+                    if (table != null) {
+                        List<Flow> flows = table.getFlow();
+                        for (Iterator<Flow> iterator3 = flows.iterator(); iterator3.hasNext(); ) {
+                            flowCount++;
+                            FlowKey flowKey = iterator3.next().getKey();
+                            InstanceIdentifier<Flow> flowRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
+                            Flow flow = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, flowRef);
+                            if (flow != null) {
+                                FlowStatisticsData data = flow.getAugmentation(FlowStatisticsData.class);
+                                if (null != data) {
+                                    flowStatsCount++;
+                                    LOG.debug("--------------------------------------------");
+                                    ci.print(data);
+                                }
+                            }
                         }
-                    }                    
+                    }
                 }
             }
-            
-            if(flowCount == flowStatsCount)
-            {
-                ci.println("flowStats - Success");
-            }
-            else
-            {
-                ci.println("flowStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
-            }
-                           
-       }
+        }
+
+        if (flowCount == flowStatsCount) {
+            LOG.debug("flowStats - Success");
+        } else {
+            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;
         int tableStatsCount = 0;
-            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<Table> tables =  node.getTable();
-                for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext();) {
+        List<Node> nodes = getNodes();
+        for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
+            NodeKey nodeKey = iterator.next().getKey();
+            InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
+
+            ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+            FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+            if (node != null) {
+                List<Table> tables = node.getTable();
+                for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext(); ) {
                     tableCount++;
                     TableKey tableKey = iterator2.next().getKey();
-                    InstanceIdentifier<Table> tableRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).toInstance();
-                    Table table = (Table)dataProviderService.readOperationalData(tableRef);
-                    FlowTableStatisticsData data = table.getAugmentation(FlowTableStatisticsData.class);
-                    if(null != data)
-                    {
-                        tableStatsCount++;
+                    InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
+                    Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
+                    if (table != null) {
+                        FlowTableStatisticsData data = table.getAugmentation(FlowTableStatisticsData.class);
+                        if (null != data) {
+                            tableStatsCount++;
+                        }
                     }
                 }
             }
-            
-            if(tableCount == tableStatsCount)
-            {
-                ci.println("tableStats - Success");
-            }
-            else
-            {
-                ci.println("tableStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
-            }
-                           
-       }
+        }
+
+        if (tableCount == tableStatsCount) {
+            LOG.debug("tableStats - Success");
+        } else {
+            LOG.debug("tableStats - Failed");
+            LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+        }
+
+    }
 
     public void _groupStats(CommandInterpreter ci) {
         int groupCount = 0;
         int groupStatsCount = 0;
-            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();) {
+        NodeGroupStatistics data = null;
+        List<Node> nodes = getNodes();
+        for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
+            NodeKey nodeKey = iterator.next().getKey();
+            InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
+            ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+            FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+            if (node != null) {
+                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);
-                    NodeGroupStatistics data = group.getAugmentation(NodeGroupStatistics.class);
-                    if(null != data)
-                    {
-                        groupStatsCount++;
+                    InstanceIdentifier<Group> groupRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
+                    Group group = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, groupRef);
+                    if (group != null) {
+                        data = group.getAugmentation(NodeGroupStatistics.class);
+                        if (null != data) {
+                            groupStatsCount++;
+                        }
                     }
                 }
             }
-            
-            if(groupCount == groupStatsCount)
-            {
-                ci.println("---------------------groupStats - Success-------------------------------");
+        }
+
+        if (groupCount == groupStatsCount) {
+            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.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
+            ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+            FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+
+            if (node != null) {
+                List<Group> groups = node.getGroup();
+                for (Iterator<Group> iterator2 = groups.iterator(); iterator2.hasNext(); ) {
+                    groupCount++;
+                    GroupKey groupKey = iterator2.next().getKey();
+                    InstanceIdentifier<Group> groupRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
+                    Group group = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, groupRef);
+                    if (group != null) {
+                        data = group.getAugmentation(NodeGroupDescStats.class);
+                        if (null != data) {
+                            groupDescStatsCount++;
+                        }
+                    }
+                }
             }
-            else
-            {
-                ci.println("------------------------------groupStats - Failed--------------------------");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
-            }                        
-       }
-    
+
+            if (groupCount == groupDescStatsCount) {
+                LOG.debug("---------------------groupDescStats - Success-------------------------------");
+            } else {
+                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;
-            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();) {
+        NodeMeterStatistics data = null;
+        List<Node> nodes = getNodes();
+        for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
+            NodeKey nodeKey = iterator.next().getKey();
+            InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
+            ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+            FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+            if (node != null) {
+                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);
-                    NodeMeterStatistics data = meter.getAugmentation(NodeMeterStatistics.class);
-                    if(null != data)
-                    {
-                        meterStatsCount++;
+                    InstanceIdentifier<Meter> meterRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
+                    Meter meter = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, meterRef);
+                    if (meter != null) {
+                        data = meter.getAugmentation(NodeMeterStatistics.class);
+                        if (null != data) {
+                            meterStatsCount++;
+                        }
                     }
                 }
             }
-            
-            if(meterCount == meterStatsCount)
-            {
-                ci.println("---------------------------meterStats - Success-------------------------------------");
+        }
+
+        if (meterCount == meterStatsCount) {
+            LOG.debug("---------------------------meterStats - Success-------------------------------------");
+        } else {
+            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.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
+            ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+            FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+            if (node != null) {
+                List<Meter> meters = node.getMeter();
+                for (Iterator<Meter> iterator2 = meters.iterator(); iterator2.hasNext(); ) {
+                    meterCount++;
+                    MeterKey meterKey = iterator2.next().getKey();
+                    InstanceIdentifier<Meter> meterRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
+                    Meter meter = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, meterRef);
+                    if (meter != null) {
+                        data = meter.getAugmentation(NodeMeterConfigStats.class);
+                        if (null != data) {
+                            meterConfigStatsCount++;
+                        }
+                    }
+                }
             }
-            else
-            {
-                ci.println("----------------------------meterStats - Failed-------------------------------------");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
-            }                        
-       }
-    
-    
+        }
+
+        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;
         int aggerateFlowStatsCount = 0;
-            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<Table> tables =  node.getTable();
-                for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext();) {
+        List<Node> nodes = getNodes();
+        for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
+            NodeKey nodeKey = iterator.next().getKey();
+            InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
+            ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+            FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+            if (node != null) {
+                List<Table> tables = node.getTable();
+                for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext(); ) {
                     aggregateFlowCount++;
                     TableKey tableKey = iterator2.next().getKey();
-                    InstanceIdentifier<Table> tableRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).toInstance();
-                    Table table = (Table)dataProviderService.readOperationalData(tableRef);
-                    AggregateFlowStatisticsData data = table.getAugmentation(AggregateFlowStatisticsData.class);
-                    if(null != data)
-                    {
-                        aggerateFlowStatsCount++;
+                    InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
+                    Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
+                    if (table != null) {
+                        AggregateFlowStatisticsData data = table.getAugmentation(AggregateFlowStatisticsData.class);
+                        if (null != data) {
+                            aggerateFlowStatsCount++;
+                        }
                     }
                 }
             }
-            
-            if(aggregateFlowCount == aggerateFlowStatsCount)
-            {
-                ci.println("aggregateStats - Success");
-            }
-            else
-            {
-                ci.println("aggregateStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
-            }
-                           
-       }
+        }
+
+        if (aggregateFlowCount == aggerateFlowStatsCount) {
+            LOG.debug("aggregateStats - Success");
+        } else {
+            LOG.debug("aggregateStats - Failed");
+            LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+        }
+
+    }
 
     public void _descStats(CommandInterpreter ci) {
         int descCount = 0;
         int descStatsCount = 0;
-            List<Node> nodes = getNodes();
-            for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext();) {
-                descCount++;
-                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);
-                    if(null != node.getHardware() &&
-                            null != node.getManufacturer() &&
-                            null != node.getSoftware())
-                    {
-                        descStatsCount++;
-                    }
-            }
-            
-            if(descCount == descStatsCount)
-            {
-                ci.println("descStats - Success");
-            }
-            else
-            {
-                ci.println("descStats - Failed");
-                ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+        List<Node> nodes = getNodes();
+        for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
+            descCount++;
+            NodeKey nodeKey = iterator.next().getKey();
+            InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
+            ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+            FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+            if (node != null) {
+                if (null != node.getHardware() &&
+                        null != node.getManufacturer() &&
+                        null != node.getSoftware()) {
+                    descStatsCount++;
+                }
             }
-                           
-       }    
-    
-    private List<Node> getNodes()
-    {
-        Nodes nodes = (Nodes)dataProviderService.readOperationalData(InstanceIdentifier.builder(Nodes.class).toInstance());
-        if(null == nodes)
-        {
+        }
+
+        if (descCount == descStatsCount) {
+            LOG.debug("descStats - Success");
+        } else {
+            LOG.debug("descStats - Failed");
+            LOG.debug("System fetches stats data in 50 seconds interval, so please wait and try again.");
+        }
+
+    }
+
+    private List<Node> getNodes() {
+        ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
+        InstanceIdentifier<Nodes> nodesID = InstanceIdentifier.create(Nodes.class);
+        Nodes nodes = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodesID);
+        if (nodes == null) {
             throw new RuntimeException("nodes are not found, pls add the node.");
         }
         return nodes.getNode();
-        
     }
-    
+
+
     @Override
     public String getHelp() {
         StringBuffer help = new StringBuffer();
@@ -350,5 +437,5 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
         return help.toString();
     }
 
+
 }