BUG-6890: Enabling statistics collection through a config 18/46718/4
authorShuva Kar <shuva.jyoti.kar@ericsson.com>
Mon, 10 Oct 2016 08:40:27 +0000 (14:10 +0530)
committerShuva Jyoti Kar <shuva.jyoti.kar@ericsson.com>
Fri, 14 Oct 2016 14:44:54 +0000 (14:44 +0000)
parameter in openflowplugin.cfg

Change-Id: If7dbedd50d7f23a075c53279654e36d33b212867
Signed-off-by: Shuva Kar <shuva.jyoti.kar@ericsson.com>
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/statistics/StatisticsManager.java
openflowplugin-blueprint-config/src/main/resources/initial/openflowplugin.cfg
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java

index c56e50ca252ac9156f384af236252f2053dad8ba..e16cec91303922b8bbe2b5e6a3ea4388e413e7f5 100644 (file)
@@ -34,4 +34,6 @@ public interface StatisticsManager extends DeviceLifecycleSupervisor, DeviceInit
     @Override
     void close();
 
+    void setIsStatisticsPollingOff(boolean isStatisticsPollingOff);
+
 }
index 6716ba6f8a7981ee4d723e47d835677a95abb829..e2036e2705f6b44c02ace94ff697270c4e95b82f 100644 (file)
@@ -17,3 +17,6 @@ barrier-count-limit=25600
 #Echo reply timeout specified on the controller side beyond which the connection is deemed dead
 #requires to be configured before switch connection, else require a switch restart
 echo-reply-timeout=2000
+#flag to turn on/off statistics polling
+#can be changed on demand
+is-statistics-polling-off=false
index 5001ca1d06a40afd6d94877ebb003a40e865088f..846cc7cb9170d3c5a342fa5e65b61eae65d4556b 100644 (file)
@@ -288,6 +288,10 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
         if (connectionManager != null && props.containsKey("echo-reply-timeout") ){
             connectionManager.setEchoReplyTimeout(Long.valueOf(props.get("echo-reply-timeout").toString()));
         }
+
+        if(statisticsManager != null && props.containsKey("is-statistics-polling-off")){
+            statisticsManager.setIsStatisticsPollingOff(Boolean.valueOf(props.get("is-statistics-polling-off").toString()));
+        }
     }
 
     private static void registerMXBean(final MessageIntelligenceAgency messageIntelligenceAgency) {
index 4fcac634240046ef15cec0158218e8d5de94439f..d190ca6ef0ea765362f67cabd72b629472d5ea53 100644 (file)
@@ -69,7 +69,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
 
     private StatisticsWorkMode workMode = StatisticsWorkMode.COLLECTALL;
     private final Semaphore workModeGuard = new Semaphore(1, true);
-    private boolean isStatisticsPollingEnabled;
+    private boolean isStatisticsPollingOff;
     private BindingAwareBroker.RpcRegistration<StatisticsManagerControlService> controlServiceRegistration;
 
     private final HashedWheelTimer hashedWheelTimer;
@@ -80,7 +80,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
     }
 
     public StatisticsManagerImpl(final RpcProviderRegistry rpcProviderRegistry,
-                                 final boolean isStatisticsPollingEnabled,
+                                 final boolean isStatisticsPollingOff,
                                  final HashedWheelTimer hashedWheelTimer,
                                  final ConvertorExecutor convertorExecutor) {
         Preconditions.checkArgument(rpcProviderRegistry != null);
@@ -88,7 +88,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
         this.controlServiceRegistration = Preconditions.checkNotNull(
                 rpcProviderRegistry.addRpcImplementation(StatisticsManagerControlService.class, this)
         );
-        this.isStatisticsPollingEnabled = isStatisticsPollingEnabled;
+        this.isStatisticsPollingOff = isStatisticsPollingOff;
         this.hashedWheelTimer = hashedWheelTimer;
     }
 
@@ -99,7 +99,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
         final StatisticsContext statisticsContext =
                 new StatisticsContextImpl(
                         deviceInfo,
-                        isStatisticsPollingEnabled,
+                        isStatisticsPollingOff,
                         lifecycleService,
                         converterExecutor,
                         this);
@@ -172,7 +172,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
         if (LOG.isDebugEnabled()) {
             LOG.debug("SCHEDULING NEXT STATISTICS POLLING for device: {}", deviceInfo.getNodeId());
         }
-        if (!isStatisticsPollingEnabled) {
+        if (!isStatisticsPollingOff) {
             final Timeout pollTimeout = hashedWheelTimer.newTimeout(
                     timeout -> pollStatistics(
                             deviceState,
@@ -231,7 +231,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
         if (workModeGuard.tryAcquire()) {
             final StatisticsWorkMode targetWorkMode = input.getMode();
             if (!workMode.equals(targetWorkMode)) {
-                isStatisticsPollingEnabled = StatisticsWorkMode.FULLYDISABLED.equals(targetWorkMode);
+                isStatisticsPollingOff = StatisticsWorkMode.FULLYDISABLED.equals(targetWorkMode);
                 // iterate through stats-ctx: propagate mode
                 for (Map.Entry<DeviceInfo, StatisticsContext> entry : contexts.entrySet()) {
                     final DeviceInfo deviceInfo = entry.getKey();
@@ -271,7 +271,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
 
     @Override
     public void startScheduling(final DeviceInfo deviceInfo) {
-        if (isStatisticsPollingEnabled) {
+        if (isStatisticsPollingOff) {
             LOG.info("Statistics are shutdown for device: {}", deviceInfo.getNodeId());
             return;
         }
@@ -330,4 +330,9 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
         this.deviceTerminPhaseHandler = handler;
     }
 
-}
+    @Override
+    public void setIsStatisticsPollingOff(boolean isStatisticsPollingOff){
+        this.isStatisticsPollingOff = isStatisticsPollingOff;
+    }
+
+}
\ No newline at end of file