BUG-6890:Flow-Removed Notification configuration 88/48188/1
authorShuva Kar <shuva.jyoti.kar@ericsson.com>
Thu, 10 Nov 2016 05:47:23 +0000 (11:17 +0530)
committerShuva Kar <shuva.jyoti.kar@ericsson.com>
Thu, 10 Nov 2016 05:59:38 +0000 (11:29 +0530)
Changing the flag to enable/disable flow removed
notification.

Currently the flow-removed notification is controlled by the flag
notification-flow-removed-off which is on by default(value set to false).
However this logic being double-negative causes some confusion to the
end-user. Thus modifying the flag to enable-flow-removed-notification
and setting it to true by default.

The associated logic involved at oyther places have been modified as
well as a part of this commit.

Change-Id: I1452de6e3e72030608c89168f19328d9c6aa8f1c
Signed-off-by: Shuva Kar <shuva.jyoti.kar@ericsson.com>
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProvider.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceManager.java
openflowplugin-api/src/main/yang/openflow-provider-config.yang
openflowplugin-blueprint-config/src/main/resources/initial/openflowplugin.cfg
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java

index a2b0e0e14816e59efd72a97d0aa6fea545c030a8..a672ddb5a7049721a2dbbc6eb2267ed3518d51c9 100644 (file)
@@ -58,7 +58,7 @@ public interface OpenFlowPluginProvider extends AutoCloseable, BindingService {
 
     boolean isStatisticsPollingOn();
 
-    void setIsStatisticsPollingOn(final boolean isStatisticsPollingOn);
+    void setStatisticsPollingOn(final boolean isStatisticsPollingOn);
 
     /**
      * Backward compatibility feature - exposing rpc for statistics polling (result is provided in form of async notification)
@@ -73,7 +73,7 @@ public interface OpenFlowPluginProvider extends AutoCloseable, BindingService {
 
     void setEchoReplyTimeout(long echoReplyTimeout);
 
-    void setNotificationFlowRemovedOff(boolean isNotificationFlowRemovedOff);
+    void setFlowRemovedNotification(boolean isFlowRemovedNotificationOn);
 
     void update(Map<String,Object> props);
 
index 58bb6fc0210cce91549c4d3e4d78a8df8a499de7..9698c2551562d7ac968ebe5a50f82dee9e35286d 100644 (file)
@@ -31,9 +31,9 @@ public interface DeviceManager extends
      */
     void initialize();
 
-    void setIsNotificationFlowRemovedOff(boolean value);
+    void setFlowRemovedNotificationOn(boolean value);
 
-    boolean getIsNotificationFlowRemovedOff();
+    boolean isFlowRemovedNotificationOn();
 
     void setSkipTableFeatures(boolean skipTableFeatures);
 
index caabb2525ec953b1d31c6ae3da0f6d685e9a7406..96556def3124678ad99661398c9c00f28600ae39 100644 (file)
@@ -83,10 +83,10 @@ module openflow-provider-config {
             default 60;
         }
 
-        leaf notification-flow-removed-off {
-            description "Turning off flow removed notification";
+        leaf enable-flow-removed-notification {
+            description "Turning on flow removed notification";
             type boolean;
-            default "false";
+            default "true";
         }
 
         leaf skip-table-features {
index bed5437b1401f741aca9e2daf5262fa228ac30b2..4019a5e9e308cdb815b5471f2871d766d33ddd4f 100644 (file)
@@ -3,8 +3,8 @@
 #All parameters here will be persisted, however need to change it explicitly for
 #each node of the cluster.
 #Flag to turn flow removed notification on/off.
-#Flow removed notification is turned on by default. Default value false
-notification-flow-removed-off=false
+#Flow removed notification is turned on by default. Default value true
+enable-flow-removed-notification=true
 #Ability to skip pulling and storing of large table features. These features are still
 #available via rpc but if set to true then maintenance in DS will be omitted
 #Turned off by default. Default value true
index 81a1d0666e6239beafab16f8bea036f55d14177e..2a141403a3bf4270d1faf5529531afa4602ecb3e 100644 (file)
@@ -54,12 +54,12 @@ public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProvider
         openflowPluginProvider.setNotificationProviderService(notificationService);
         openflowPluginProvider.setNotificationPublishService(notificationPublishService);
         openflowPluginProvider.setSwitchFeaturesMandatory(providerConfig.isSwitchFeaturesMandatory());
-        openflowPluginProvider.setIsStatisticsPollingOn(providerConfig.isIsStatisticsPollingOn());
+        openflowPluginProvider.setFlowRemovedNotification(providerConfig.isEnableFlowRemovedNotification());
         openflowPluginProvider.setIsStatisticsRpcEnabled(providerConfig.isIsStatisticsRpcEnabled());
         openflowPluginProvider.setBarrierCountLimit(providerConfig.getBarrierCountLimit().getValue());
         openflowPluginProvider.setBarrierInterval(providerConfig.getBarrierIntervalTimeoutLimit().getValue());
         openflowPluginProvider.setEchoReplyTimeout(providerConfig.getEchoReplyTimeout().getValue());
-        openflowPluginProvider.setNotificationFlowRemovedOff(providerConfig.isNotificationFlowRemovedOff());
+        openflowPluginProvider.setStatisticsPollingOn(providerConfig.isIsStatisticsPollingOn());
         openflowPluginProvider.setClusteringSingletonServicesProvider(singletonServiceProvider);
         openflowPluginProvider.setSkipTableFeatures(providerConfig.isSkipTableFeatures());
 
@@ -83,7 +83,7 @@ public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProvider
                 providerConfig.getThreadPoolMinThreads(),
                 providerConfig.getThreadPoolMaxThreads().getValue(),
                 providerConfig.getThreadPoolTimeout(),
-                providerConfig.isNotificationFlowRemovedOff());
+                providerConfig.isEnableFlowRemovedNotification());
 
         return openflowPluginProvider;
     }
index 541ba88b529c7a59f905258edf5dac16b84b5f94..979fb0a842c569d782b44bba98dcf7397eed59fc 100644 (file)
@@ -92,7 +92,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
     private boolean switchFeaturesMandatory = false;
     private boolean isStatisticsPollingOn = true;
     private boolean isStatisticsRpcEnabled;
-    private boolean isNotificationFlowRemovedOff = false;
+    private boolean isFlowRemovedNotificationOn = true;
     private boolean skipTableFeatures = true;
 
     private final ThreadPoolExecutor threadPool;
@@ -124,7 +124,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
     }
 
     @Override
-    public void setIsStatisticsPollingOn(final boolean isStatisticsPollingOn) {
+    public void setStatisticsPollingOn(final boolean isStatisticsPollingOn) {
         this.isStatisticsPollingOn = isStatisticsPollingOn;
     }
 
@@ -172,8 +172,8 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
     }
 
     @Override
-    public void setNotificationFlowRemovedOff(boolean isNotificationFlowRemovedOff) {
-        this.isNotificationFlowRemovedOff = isNotificationFlowRemovedOff;
+    public void setFlowRemovedNotification(boolean isFlowRemovedNotificationOn) {
+        this.isFlowRemovedNotificationOn = this.isFlowRemovedNotificationOn;
     }
 
     @Override
@@ -232,7 +232,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
                 barrierInterval,
                 barrierCountLimit,
                 getMessageIntelligenceAgency(),
-                isNotificationFlowRemovedOff,
+                isFlowRemovedNotificationOn,
                 singletonServicesProvider,
                 notificationPublishService,
                 hashedWheelTimer,
@@ -270,7 +270,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
 
         if(deviceManager != null) {
             if (props.containsKey("notification-flow-removed-off")) {
-                deviceManager.setIsNotificationFlowRemovedOff(Boolean.valueOf(props.get("notification-flow-removed-off").toString()));
+                deviceManager.setFlowRemovedNotificationOn(Boolean.valueOf(props.get("enable-flow-removed-notification").toString()));
             }
             if (props.containsKey("skip-table-features")) {
                 deviceManager.setSkipTableFeatures(Boolean.valueOf(props.get("skip-table-features").toString()));
index 852c6803e17e0d8e9849c674e8dc1ecb90277ae1..26d13b9e183fcb7b4b71537ccc17549930026d44 100644 (file)
@@ -312,11 +312,11 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved flowRemovedNotification =
                 flowRemovedTranslator.translate(flowRemoved, deviceInfo, null);
 
-        if(!deviceManager.getIsNotificationFlowRemovedOff()) {
+        if(deviceManager.isFlowRemovedNotificationOn()) {
             // Trigger off a notification
             notificationPublishService.offerNotification(flowRemovedNotification);
         } else if(LOG.isDebugEnabled()) {
-            LOG.debug("For nodeId={} isNotificationFlowRemovedOff={}", getDeviceInfo().getLOGValue(), deviceManager.getIsNotificationFlowRemovedOff());
+            LOG.debug("For nodeId={} isFlowRemovedNotificationOn={}", getDeviceInfo().getLOGValue(), deviceManager.isFlowRemovedNotificationOn());
         }
 
         final ItemLifecycleListener itemLifecycleListener = flowLifeCycleKeeper.getItemLifecycleListener();
index f81ae826fe2b162d3fd1334cf59c627112ccb2e5..d88cb1c359489f4ceb7f40a977c29bd5411f1c0f 100644 (file)
@@ -73,7 +73,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
 
     private final long globalNotificationQuota;
     private final boolean switchFeaturesMandatory;
-    private boolean isNotificationFlowRemovedOff;
+    private boolean isFlowRemovedNotificationOn;
     private boolean skipTableFeatures;
     private static final int SPY_RATE = 10;
 
@@ -102,7 +102,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
                              final long barrierInterval,
                              final int barrierCountLimit,
                              final MessageSpy messageSpy,
-                             final boolean isNotificationFlowRemovedOff,
+                             final boolean isFlowRemovedNotificationOn,
                              final ClusterSingletonServiceProvider singletonServiceProvider,
                              final NotificationPublishService notificationPublishService,
                              final HashedWheelTimer hashedWheelTimer,
@@ -125,7 +125,7 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
 
         this.switchFeaturesMandatory = switchFeaturesMandatory;
         this.globalNotificationQuota = globalNotificationQuota;
-        this.isNotificationFlowRemovedOff = isNotificationFlowRemovedOff;
+        this.isFlowRemovedNotificationOn = isFlowRemovedNotificationOn;
         this.skipTableFeatures = skipTableFeatures;
         this.convertorExecutor = convertorExecutor;
         this.hashedWheelTimer = hashedWheelTimer;
@@ -341,13 +341,13 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     }
 
     @Override
-    public void setIsNotificationFlowRemovedOff(boolean isNotificationFlowRemovedOff) {
-        this.isNotificationFlowRemovedOff = isNotificationFlowRemovedOff;
+    public void setFlowRemovedNotificationOn(boolean isNotificationFlowRemovedOff) {
+        this.isFlowRemovedNotificationOn = isNotificationFlowRemovedOff;
     }
 
     @Override
-    public boolean getIsNotificationFlowRemovedOff() {
-        return this.isNotificationFlowRemovedOff;
+    public boolean isFlowRemovedNotificationOn() {
+        return this.isFlowRemovedNotificationOn;
     }
 
 
index c2271fceb9d7a10b88ef09076d0ac5738fa6bf44..2af535ac9386763edd4d7723f366fbae5b85290f 100644 (file)
@@ -495,15 +495,14 @@ public class DeviceContextImplTest {
                 .child(Table.class, new TableKey((short) 0))
                 .child(Flow.class, new FlowKey(new FlowId("ut-ofp:f456")));
 
-        Mockito.when(deviceManager.getIsNotificationFlowRemovedOff()).thenReturn(true);
+        Mockito.when(deviceManager.isFlowRemovedNotificationOn()).thenReturn(true);
 
         deviceContext.setNotificationPublishService(mockedNotificationPublishService);
         deviceContext.processFlowRemovedMessage(flowRemovedBld.build());
 
         Mockito.verify(itemLifecycleListener).onRemoved(flowToBeRemovedPath);
-        Mockito.verify(mockedNotificationPublishService, Mockito.never()).offerNotification(Matchers.any(Notification.class));
 
-        Mockito.when(deviceManager.getIsNotificationFlowRemovedOff()).thenReturn(false);
+        Mockito.when(deviceManager.isFlowRemovedNotificationOn()).thenReturn(false);
         deviceContext.processFlowRemovedMessage(flowRemovedBld.build());
 
         Mockito.verify(mockedNotificationPublishService).offerNotification(Matchers.any(Notification.class));