Do not rely od DataStore for all connected nodes 92/5292/5
authorRobert Varga <rovarga@cisco.com>
Thu, 13 Feb 2014 02:27:26 +0000 (03:27 +0100)
committerRobert Varga <rovarga@cisco.com>
Fri, 14 Feb 2014 19:35:00 +0000 (20:35 +0100)
Now that we track all connected flow-capable nodes we do need to go and
read all nodes just to find them. Just look at which handlers are
currently created.

Change-Id: I1a33b53399d0de0e2cdbdbd90512a09933d127c8
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 4851b441c36d6ab4b71b8ea74ba1dc94443088d3..8dea40473d57eed4583742844110897f5067e11f 100644 (file)
@@ -94,11 +94,10 @@ public class StatisticsProvider implements AutoCloseable {
     private static final Logger spLogger = LoggerFactory.getLogger(StatisticsProvider.class);
 
     private final MultipartMessageManager multipartMessageManager = new MultipartMessageManager();
     private static final Logger spLogger = LoggerFactory.getLogger(StatisticsProvider.class);
 
     private final MultipartMessageManager multipartMessageManager = new MultipartMessageManager();
-    private final InstanceIdentifier<Nodes> nodesIdentifier = InstanceIdentifier.builder(Nodes.class).toInstance();
     private final DataProviderService dps;
 
     //Local caching of stats
     private final DataProviderService dps;
 
     //Local caching of stats
-    private final ConcurrentMap<NodeId,NodeStatisticsHandler> handlers = new ConcurrentHashMap<>();
+    private final ConcurrentMap<NodeId, NodeStatisticsHandler> handlers = new ConcurrentHashMap<>();
 
     private OpendaylightGroupStatisticsService groupStatsService;
 
 
     private OpendaylightGroupStatisticsService groupStatsService;
 
@@ -236,19 +235,9 @@ public class StatisticsProvider implements AutoCloseable {
         return dps.beginTransaction();
     }
 
         return dps.beginTransaction();
     }
 
-    private void statsRequestSender(){
-
-        List<Node> targetNodes = getAllConnectedNodes();
-
-        if(targetNodes == null)
-            return;
-
-
-        for (Node targetNode : targetNodes){
-
-            if(targetNode.getAugmentation(FlowCapableNode.class) != null){
-                sendStatisticsRequestsToNode(targetNode.getKey());
-            }
+    private void statsRequestSender() {
+        for (NodeStatisticsHandler h : handlers.values()) {
+            sendStatisticsRequestsToNode(h.getTargetNodeKey());
         }
     }
 
         }
     }
 
@@ -472,15 +461,6 @@ public class StatisticsProvider implements AutoCloseable {
         return handler;
     }
 
         return handler;
     }
 
-    private List<Node> getAllConnectedNodes(){
-        Nodes nodes = (Nodes) dps.readOperationalData(nodesIdentifier);
-        if(nodes == null)
-            return null;
-
-        spLogger.debug("Number of connected nodes : {}",nodes.getNode().size());
-        return nodes.getNode();
-    }
-
     private List<Short> getTablesFromNode(NodeKey nodeKey){
         InstanceIdentifier<FlowCapableNode> nodesIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class,nodeKey).augmentation(FlowCapableNode.class).toInstance();
 
     private List<Short> getTablesFromNode(NodeKey nodeKey){
         InstanceIdentifier<FlowCapableNode> nodesIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class,nodeKey).augmentation(FlowCapableNode.class).toInstance();