Statistics polling is scheduled per one device 19/21119/1
authorMartin Bobak <mbobak@cisco.com>
Tue, 26 May 2015 10:52:29 +0000 (12:52 +0200)
committerMartin Bobak <mbobak@cisco.com>
Tue, 26 May 2015 10:52:29 +0000 (12:52 +0200)
Change-Id: Ic28ea509445ab6f557438337be2a5db9650efd03
Signed-off-by: Martin Bobak <mbobak@cisco.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java

index 31e8f3112fac12860147764fd9f7674ec9ce1dd8..ac1b5874eea3b07a5010bd868d1f9ac2dff98d56 100644 (file)
@@ -53,7 +53,6 @@ public class StatisticsManagerImpl implements StatisticsManager {
         if (null == hashedWheelTimer) {
             LOG.trace("This is first device that delivered timer. Starting statistics polling immediately.");
             hashedWheelTimer = deviceContext.getTimer();
-            pollStatistics();
         }
 
         final StatisticsContext statisticsContext = new StatisticsContextImpl(deviceContext);
@@ -65,6 +64,7 @@ public class StatisticsManagerImpl implements StatisticsManager {
                 if (statisticsGathered.booleanValue()) {
                     //there are some statistics on device worth gathering
                     contexts.put(deviceContext, statisticsContext);
+                    pollStatistics(statisticsContext);
                 }
                 LOG.trace("Device dynamic info collecting done. Going to announce raise to next level.");
                 deviceInitPhaseHandler.onDeviceContextLevelUp(deviceContext);
@@ -83,32 +83,30 @@ public class StatisticsManagerImpl implements StatisticsManager {
         });
     }
 
-    private void pollStatistics() {
+    private void pollStatistics(final StatisticsContext statisticsContext) {
         try {
             timeCounter.markStart();
-            for (final StatisticsContext statisticsContext : contexts.values()) {
-                ListenableFuture<Boolean> deviceStatisticsCollectionFuture = statisticsContext.gatherDynamicData();
-                Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
-                    @Override
-                    public void onSuccess(final Boolean o) {
-                        timeCounter.addTimeMark();
-                    }
+            ListenableFuture<Boolean> deviceStatisticsCollectionFuture = statisticsContext.gatherDynamicData();
+            Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
+                @Override
+                public void onSuccess(final Boolean o) {
+                    timeCounter.addTimeMark();
+                }
 
-                    @Override
-                    public void onFailure(final Throwable throwable) {
-                        timeCounter.addTimeMark();
-                        LOG.info("Statistics gathering for single node was not successful: {}", throwable.getMessage());
-                        LOG.debug("Statistics gathering for single node was not successful.. ", throwable);
-                    }
-                });
-            }
+                @Override
+                public void onFailure(final Throwable throwable) {
+                    timeCounter.addTimeMark();
+                    LOG.info("Statistics gathering for single node was not successful: {}", throwable.getMessage());
+                    LOG.debug("Statistics gathering for single node was not successful.. ", throwable);
+                }
+            });
         } finally {
             calculateTimerDelay();
             if (null != hashedWheelTimer) {
                 hashedWheelTimer.newTimeout(new TimerTask() {
                     @Override
                     public void run(final Timeout timeout) throws Exception {
-                        pollStatistics();
+                        pollStatistics(statisticsContext);
                     }
                 }, currentTimerDelay, TimeUnit.MILLISECONDS);
             }