Bug 3412 - Device should not be propagated if initial stats collection fails 11/21611/1
authorMartin Bobak <mbobak@cisco.com>
Thu, 28 May 2015 08:33:56 +0000 (10:33 +0200)
committermichal rehak <mirehak@cisco.com>
Tue, 2 Jun 2015 08:12:18 +0000 (08:12 +0000)
Change-Id: Ib9bf397331f9011e6909caeefa8cf403747d005f
Signed-off-by: Martin Bobak <mbobak@cisco.com>
(cherry picked from commit 42f8e33bbd8649cd4f78b1873e69b77ae00b10c4)

openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java

index 1ed062f97daa81f0c3a4a114e12f3f6d09842f72..9ab662d529b5df1cd60d9f4dce2558d643c25a74 100644 (file)
@@ -66,10 +66,17 @@ public class StatisticsManagerImpl implements StatisticsManager {
                     contexts.put(deviceContext, statisticsContext);
                     final TimeCounter timeCounter = new TimeCounter();
                     scheduleNextPolling(deviceContext, statisticsContext, timeCounter);
+                    LOG.trace("Device dynamic info collecting done. Going to announce raise to next level.");
+                    deviceInitPhaseHandler.onDeviceContextLevelUp(deviceContext);
+                    deviceContext.getDeviceState().setDeviceSynchronized(true);
+                } else {
+                    final String deviceAdress = deviceContext.getPrimaryConnectionContext().getConnectionAdapter().getRemoteAddress().toString();
+                    try {
+                        deviceContext.close();
+                    } catch (Exception e) {
+                        LOG.info("Statistics for device {} could not be gathered. Closing its device context.", deviceAdress);
+                    }
                 }
-                LOG.trace("Device dynamic info collecting done. Going to announce raise to next level.");
-                deviceInitPhaseHandler.onDeviceContextLevelUp(deviceContext);
-                deviceContext.getDeviceState().setDeviceSynchronized(true);
             }
 
             @Override