Walk the tables directly 96/5296/5
authorRobert Varga <rovarga@cisco.com>
Thu, 13 Feb 2014 02:52:54 +0000 (03:52 +0100)
committerRobert Varga <rovarga@cisco.com>
Fri, 14 Feb 2014 19:35:00 +0000 (20:35 +0100)
This inlines a function with a single caller, such that we do not have
to create an interim list. This allows us to know the call site which
needs to know about tables.

Change-Id: I530233bd3ec8e85417a3b9efa878c80b683ce5ff
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java

index 8dea404..b7fb4e9 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.controller.md.statistics.manager;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
@@ -320,17 +319,21 @@ public class StatisticsProvider implements AutoCloseable {
 
     }
 
-    private void sendAggregateFlowsStatsFromAllTablesRequest(NodeKey targetNodeKey) throws InterruptedException, ExecutionException{
-
-        List<Short> tablesId = getTablesFromNode(targetNodeKey);
-
-        if(tablesId.size() != 0){
-            for(Short id : tablesId){
-
-                sendAggregateFlowsStatsFromTableRequest(targetNodeKey,id);
+    private void sendAggregateFlowsStatsFromAllTablesRequest(final NodeKey nodeKey) throws InterruptedException, ExecutionException{
+        FlowCapableNode node = (FlowCapableNode)dps.readOperationalData(
+                InstanceIdentifier.builder(Nodes.class).child(Node.class,nodeKey).augmentation(FlowCapableNode.class).build());
+        if (node != null) {
+            final List<Table> tables = node.getTable();
+            if (tables != null) {
+                spLogger.debug("Node {} supports {} table(s)", nodeKey, tables.size());
+                for(Table table : tables) {
+                    sendAggregateFlowsStatsFromTableRequest(nodeKey, table.getId());
+                }
+            } else {
+                spLogger.debug("Node {} has no associated tables", nodeKey);
             }
-        }else{
-            spLogger.debug("No details found in data store for flow tables associated with Node {}",targetNodeKey);
+        } else {
+            spLogger.debug("Node {} not found", nodeKey);
         }
     }
 
@@ -461,20 +464,6 @@ public class StatisticsProvider implements AutoCloseable {
         return handler;
     }
 
-    private List<Short> getTablesFromNode(NodeKey nodeKey){
-        InstanceIdentifier<FlowCapableNode> nodesIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class,nodeKey).augmentation(FlowCapableNode.class).toInstance();
-
-        FlowCapableNode node = (FlowCapableNode)dps.readOperationalData(nodesIdentifier);
-        List<Short> tablesId = new ArrayList<Short>();
-        if(node != null && node.getTable()!=null){
-            spLogger.debug("Number of tables {} supported by node {}",node.getTable().size(),nodeKey);
-            for(Table table: node.getTable()){
-                tablesId.add(table.getId());
-            }
-        }
-        return tablesId;
-    }
-
     @SuppressWarnings("unchecked")
     private NodeId getNodeId(NodeRef nodeRef){
         InstanceIdentifier<Node> nodeII = (InstanceIdentifier<Node>) nodeRef.getValue();

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.