From: Tony Tkacik Date: Sat, 15 Feb 2014 01:38:51 +0000 (+0000) Subject: Merge "Walk the tables directly" X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~448 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=0840e8281ad7e43b3c1c792c80d44b671a946f7a;hp=fa1fa1e80351e6f86e81f95d5c50a0521d0cbb93 Merge "Walk the tables directly" --- 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();