From: Robert Varga Date: Thu, 13 Feb 2014 02:52:54 +0000 (+0100) Subject: Walk the tables directly X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~448^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=51f23bab3264b691066a2954aeb65c5049ce29ca Walk the tables directly 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 --- diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java index 8dea40473d..b7fb4e9473 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java @@ -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 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 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 getTablesFromNode(NodeKey nodeKey){ - InstanceIdentifier nodesIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class,nodeKey).augmentation(FlowCapableNode.class).toInstance(); - - FlowCapableNode node = (FlowCapableNode)dps.readOperationalData(nodesIdentifier); - List tablesId = new ArrayList(); - 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 nodeII = (InstanceIdentifier) nodeRef.getValue();