Fixed for bug #301 and added test for queue stats 48/4248/1
authorAnilGujele <angujele@in.ibm.com>
Wed, 15 Jan 2014 07:59:59 +0000 (13:29 +0530)
committerAnilGujele <angujele@in.ibm.com>
Wed, 15 Jan 2014 07:59:59 +0000 (13:29 +0530)
Change-Id: I305c4b6ef5d6ab0392c3e59847dddb65b76a4e2d
Signed-off-by: AnilGujele <angujele@in.ibm.com>
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestCommandProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java

index 202d7916fdc062db03757cbff4613e530cfb5d0b..3e1315e03c1bc9a94994ffacf804d4dd42dd5ffe 100644 (file)
@@ -44,9 +44,12 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
 
+    private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginMeterTestCommandProvider.class);
     private DataBrokerService dataBrokerService;
     private ProviderContext pc;
     private final BundleContext ctx;
@@ -96,23 +99,23 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
 
         @Override
         public void onMeterAdded(MeterAdded notification) {
-            System.out.println("Meter to be added.........................."+notification.toString());
-            System.out.println("Meter  Xid........................."+notification.getTransactionId().getValue());
-            System.out.println("-----------------------------------------------------------------------------------");            
+            LOG.info("Meter to be added.........................."+notification.toString());
+            LOG.info("Meter  Xid........................."+notification.getTransactionId().getValue());
+            LOG.info("-----------------------------------------------------------------------------------");            
         }
 
         @Override
         public void onMeterRemoved(MeterRemoved notification) {
-            System.out.println("Meter to be removed.........................."+notification.toString());
-            System.out.println("Meter  Xid........................."+notification.getTransactionId().getValue());
-            System.out.println("-----------------------------------------------------------------------------------");            
+            LOG.info("Meter to be removed.........................."+notification.toString());
+            LOG.info("Meter  Xid........................."+notification.getTransactionId().getValue());
+            LOG.info("-----------------------------------------------------------------------------------");            
         }
 
         @Override
         public void onMeterUpdated(MeterUpdated notification) {
-            System.out.println("Meter to be updated.........................."+notification.toString());
-            System.out.println("Meter  Xid........................."+notification.getTransactionId().getValue());
-            System.out.println("-----------------------------------------------------------------------------------");            
+            LOG.info("Meter to be updated.........................."+notification.toString());
+            LOG.info("Meter  Xid........................."+notification.getTransactionId().getValue());
+            LOG.info("-----------------------------------------------------------------------------------");            
         }
         
     }
index cbe9a7140fadb0ab008e4caad02201646bab9928..bd076326501ecdb226a45a640fb0f8d587c419ee 100644 (file)
@@ -16,12 +16,15 @@ 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.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
 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.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.framework.BundleContext;
 
@@ -154,6 +157,48 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
                            
        }
 
+    public void _queueStats(CommandInterpreter ci) {
+        boolean isFound = false;
+        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();) {
+                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);
+                // queue list is always empty, bug 307 is raised.
+                List<Queue> queueList = nodeConnector.getQueue();
+
+                for (Iterator<Queue> iterator3 = queueList.iterator(); iterator3.hasNext();) {
+                    QueueKey queueKey = iterator3.next().getKey();
+                    InstanceIdentifier<Queue> queueRef = InstanceIdentifier.builder(Nodes.class)
+                            .child(Node.class, nodeKey).child(NodeConnector.class, nodeConnectorKey)
+                            .augmentation(FlowCapableNodeConnector.class).child(Queue.class, queueKey).toInstance();
+                    Queue queue = (Queue) dataProviderService.readOperationalData(queueRef);
+                    FlowCapableNodeConnectorQueueStatisticsData data = queue
+                            .getAugmentation(FlowCapableNodeConnectorQueueStatisticsData.class);
+                    if (null != data) {
+                        isFound = true;
+                    }
+                }
+            }
+        }
+
+        if (isFound) {
+            ci.println("queueStats - Success");
+        } else {
+            ci.println("queueStats - Failed");
+            ci.println("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+        }
+
+    }
 
     public void _tableStats(CommandInterpreter ci) {
         int tableCount = 0;
index 3e8552ea3e630928c234dc075b8c426840732b43..dca5f3ec2868b00c92d9084d5cc003e632f420d4 100644 (file)
@@ -236,34 +236,33 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
         @Override
         public void onFlowAdded(FlowAdded notification) {
-            System.out.println("flow to be added.........................." + notification.toString());
-            System.out.println("added flow Xid........................." + notification.getTransactionId().getValue());
-            System.out.println("-----------------------------------------------------------------------------------");
+            LOG.info("flow to be added.........................." + notification.toString());
+            LOG.info("added flow Xid........................." + notification.getTransactionId().getValue());
+            LOG.info("-----------------------------------------------------------------------------------");
             addedFlows.add(notification);
         }
 
         @Override
         public void onFlowRemoved(FlowRemoved notification) {
-            System.out.println("removed flow.........................." + notification.toString());
-            System.out.println("remove flow Xid........................." + notification.getTransactionId().getValue());
-            System.out.println("-----------------------------------------------------------------------------------");
+            LOG.info("removed flow.........................." + notification.toString());
+            LOG.info("remove flow Xid........................." + notification.getTransactionId().getValue());
+            LOG.info("-----------------------------------------------------------------------------------");
             removedFlows.add(notification);
         };
 
         @Override
         public void onFlowUpdated(FlowUpdated notification) {
-            System.out.println("updated flow.........................." + notification.toString());
-            System.out
-                    .println("updated flow Xid........................." + notification.getTransactionId().getValue());
-            System.out.println("-----------------------------------------------------------------------------------");
+            LOG.info("updated flow.........................." + notification.toString());
+            LOG.info("updated flow Xid........................." + notification.getTransactionId().getValue());
+            LOG.info("-----------------------------------------------------------------------------------");
             updatedFlows.add(notification);
         }
 
         @Override
         public void onNodeErrorNotification(NodeErrorNotification notification) {
-            System.out.println("Error notification  flow Xid........................."
+            LOG.info("Error notification  flow Xid........................."
                     + notification.getTransactionId().getValue());
-            System.out.println("-----------------------------------------------------------------------------------");
+            LOG.info("-----------------------------------------------------------------------------------");
         }
 
         @Override
@@ -274,9 +273,8 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
         @Override
         public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
-            System.out
-                    .println("Switch flow removed : Cookies..................." + notification.getCookie().toString());
-            System.out.println("-----------------------------------------------------------------------------------");
+            LOG.info("Switch flow removed : Cookies..................." + notification.getCookie().toString());
+            LOG.info("-----------------------------------------------------------------------------------");
         }
 
     }
@@ -290,33 +288,33 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
         @Override
         public void onNodeConnectorRemoved(NodeConnectorRemoved notification) {
-            System.out.println("NodeConnectorRemoved Notification ...................");
-            System.out.println(notification.getNodeConnectorRef());
-            System.out.println("----------------------------------------------------------------------");
+            LOG.info("NodeConnectorRemoved Notification ...................");
+            LOG.info(notification.getNodeConnectorRef().toString());
+            LOG.info("----------------------------------------------------------------------");
             nodeConnectorRemoved.add(notification);
         }
 
         @Override
         public void onNodeConnectorUpdated(NodeConnectorUpdated notification) {
-            System.out.println("NodeConnectorUpdated Notification...................");
-            System.out.println(notification.getNodeConnectorRef());
-            System.out.println("----------------------------------------------------------------------");
+            LOG.info("NodeConnectorUpdated Notification...................");
+            LOG.info(notification.getNodeConnectorRef().toString());
+            LOG.info("----------------------------------------------------------------------");
             nodeConnectorUpdated.add(notification);
         }
 
         @Override
         public void onNodeRemoved(NodeRemoved notification) {
-            System.out.println("NodeConnectorUpdated Notification ...................");
-            System.out.println(notification.getNodeRef());
-            System.out.println("----------------------------------------------------------------------");
+            LOG.info("NodeConnectorUpdated Notification ...................");
+            LOG.info(notification.getNodeRef().toString());
+            LOG.info("----------------------------------------------------------------------");
             nodeRemoved.add(notification);
         }
 
         @Override
         public void onNodeUpdated(NodeUpdated notification) {
-            System.out.println("NodeConnectorUpdated Notification ...................");
-            System.out.println(notification.getNodeRef());
-            System.out.println("----------------------------------------------------------------------");
+            LOG.info("NodeConnectorUpdated Notification ...................");
+            LOG.info(notification.getNodeRef().toString());
+            LOG.info("----------------------------------------------------------------------");
             nodeUpdated.add(notification);
         }
     }