Bug 8497 - Provide config knob to disable the Forwarding Rule Manager reconciliation 14/57314/5
authorAnil Vishnoi <vishnoianil@gmail.com>
Wed, 17 May 2017 21:46:19 +0000 (14:46 -0700)
committerAnil Vishnoi <vishnoianil@gmail.com>
Wed, 31 May 2017 23:03:59 +0000 (23:03 +0000)
Resolves: Bug 8497, Bug 7957

Change-Id: Ib798d9282f019e0c8dd520c15d8794678ee9af3d
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
13 files changed:
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastership.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java
applications/forwardingrules-manager/src/main/resources/org/opendaylight/blueprint/forwardingrules-manager.xml
applications/forwardingrules-manager/src/test/java/test/mock/FlowListenerTest.java
applications/forwardingrules-manager/src/test/java/test/mock/GroupListenerTest.java
applications/forwardingrules-manager/src/test/java/test/mock/MeterListenerTest.java
applications/forwardingrules-manager/src/test/java/test/mock/NodeListenerTest.java
applications/forwardingrules-manager/src/test/java/test/mock/TableFeaturesListenerTest.java
openflowplugin-blueprint-config/src/main/resources/initial/openflowplugin.cfg
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java

index bef847c025e96e7ba4bbc6b5a1861d586ae9be9f..0dcd3aa17674830a51a07021b36f6d7fb6ab7e47 100644 (file)
@@ -119,10 +119,22 @@ public interface ForwardingRulesManager extends AutoCloseable {
     ForwardingRulesCommiter<TableFeatures> getTableFeaturesCommiter();
 
     /**
-     * Returns the config-subsystem/fallback configuration of FRM
-     * @return ForwardingRulesManagerConfig
+     * Check if reconciliation is disabled by user.
+     * @return true if reconciliation is disabled, else false
      */
-    ForwardingRulesManagerConfig getConfiguration();
+    boolean isReconciliationDisabled();
+
+    /**
+     * Check if stale marking is enabled for switch reconciliation.
+     * @return true if stale marking is enabled, else false
+     */
+    boolean isStaleMarkingEnabled();
+
+    /**
+     * Return number of reconciliation retry are allowed.
+     * @return number of retries.
+     */
+    int getReconciliationRetryCount();
 
     /**
      * Method checks if *this* instance of openflowplugin is owner of
index 5a77d9e1cd76341c9464809715ec79021ee3a789..c3df34644ca33d6038041a80bf482e48c058da94 100644 (file)
@@ -64,7 +64,7 @@ public abstract class AbstractListeningCommiter <T extends DataObject> implement
                 }
             }
             else{
-                if (provider.getConfiguration().isStaleMarkingEnabled()) {
+                if (provider.isStaleMarkingEnabled()) {
                     LOG.info("Stale-Marking ENABLED and switch {} is NOT connected, storing stale entities",
                             nodeIdent.toString());
                     // Switch is NOT connected
index 182b95343cae338eedaecb6acdc057677f69dd43..82aec1cba4138fd81906638e414fe4b77695a797 100644 (file)
@@ -77,7 +77,6 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable
     public void setDeviceOperationalStatus(boolean inOperDS) {
         isDeviceInOperDS.set(inOperDS);
         if(canReconcile()) {
-            LOG.info("Triggering reconciliation for device {}", nodeId.getValue());
             reconcliationAgent.reconcileConfiguration(fcnIID);
         }
     }
index 52522f7230330072bc05c64a7fa850b4a822eafc..c530713c59c3ca7ddfbafcfb19acd8502930c708 100644 (file)
@@ -106,8 +106,14 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
 
     @Override
     public void reconcileConfiguration(InstanceIdentifier<FlowCapableNode> connectedNode) {
+        if (provider.isReconciliationDisabled()) {
+            LOG.debug("Reconciliation is disabled by user. Skipping reconciliation of node : {}", connectedNode
+                    .firstKeyOf(Node.class));
+            return;
+        }
         if (provider.isNodeOwner(connectedNode)) {
-            if (provider.getConfiguration().isStaleMarkingEnabled()) {
+            LOG.info("Triggering reconciliation for device {}", connectedNode.firstKeyOf(Node.class));
+            if (provider.isStaleMarkingEnabled()) {
                 LOG.info("Stale-Marking is ENABLED and proceeding with deletion of stale-marked entities on switch {}",
                         connectedNode.toString());
                 reconciliationPreProcess(connectedNode);
@@ -164,7 +170,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
                 Map<Long, ListenableFuture<?>> groupFutures = new HashMap<>();
 
                 while ((!(toBeInstalledGroups.isEmpty()) || !(suspectedGroups.isEmpty())) &&
-                        (counter <= provider.getConfiguration().getReconciliationRetryCount())) { //also check if the counter has not crossed the threshold
+                        (counter <= provider.getReconciliationRetryCount())) { //also check if the counter has not crossed the threshold
 
                     if (toBeInstalledGroups.isEmpty() && !suspectedGroups.isEmpty()) {
                         LOG.error("These Groups are pointing to node-connectors that are not up yet {}", suspectedGroups.toString());
@@ -249,7 +255,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
                 if (!toBeInstalledGroups.isEmpty()) {
                     for (Group group : toBeInstalledGroups) {
                         LOG.error("Installing the group {} finally although the port is not up after checking for {} times "
-                                , group.getGroupId().toString(), provider.getConfiguration().getReconciliationRetryCount());
+                                , group.getGroupId().toString(), provider.getReconciliationRetryCount());
                         addGroup(groupFutures, group);
                     }
                 }
index d055ca260d5e7a8cc44eacd3fca92066ba3a59ea..9bfa94363938c9942216c7044c0ba9c51c051447 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.Objects;
 import java.util.concurrent.atomic.AtomicLong;
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -62,6 +63,9 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
     private final ForwardingRulesManagerConfig forwardingRulesManagerConfig;
     private final ClusterSingletonServiceProvider clusterSingletonServiceProvider;
     private final NotificationProviderService notificationService;
+    private final boolean disableReconciliation;
+    private final boolean staleMarkingEnabled;
+    private final int reconciliationRetryCount;
 
     private ForwardingRulesCommiter<Flow> flowListener;
     private ForwardingRulesCommiter<Group> groupListener;
@@ -75,7 +79,10 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
                                       final RpcConsumerRegistry rpcRegistry,
                                       final ForwardingRulesManagerConfig config,
                                       final ClusterSingletonServiceProvider clusterSingletonService,
-                                      final NotificationProviderService notificationService) {
+                                      final NotificationProviderService notificationService,
+                                      final boolean disableReconciliation,
+                                      final boolean staleMarkingEnabled,
+                                      final int reconciliationRetryCount) {
         this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
         this.forwardingRulesManagerConfig = Preconditions.checkNotNull(config, "Configuration for FRM cannot be null");
         this.clusterSingletonServiceProvider = Preconditions.checkNotNull(clusterSingletonService,
@@ -93,6 +100,10 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
                 "RPC SalMeterService not found.");
         this.salTableService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalTableService.class),
                 "RPC SalTableService not found.");
+
+        this.disableReconciliation = disableReconciliation;
+        this.staleMarkingEnabled = staleMarkingEnabled;
+        this.reconciliationRetryCount = reconciliationRetryCount;
     }
 
     @Override
@@ -217,8 +228,18 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
     }
 
     @Override
-    public ForwardingRulesManagerConfig getConfiguration() {
-        return forwardingRulesManagerConfig;
+    public boolean isReconciliationDisabled() {
+        return this.disableReconciliation;
+    }
+
+    @Override
+    public boolean isStaleMarkingEnabled() {
+        return this.staleMarkingEnabled;
+    }
+
+    @Override
+    public int getReconciliationRetryCount() {
+        return this.reconciliationRetryCount;
     }
 
     @Override
index c7d81bdc0213e165b918b736508f7a142e1c9387..34a6dc8f455f03674fa1e5cf9caaaabcbced241f 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
         odl:use-default-for-reference-types="true">
 
   <odl:clustered-app-config id="frmConfig"
       binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig"/>
 
+  <cm:property-placeholder persistent-id="org.opendaylight.openflowplugin"
+                           placeholder-prefix="${frm-"
+                           update-strategy="none">
+    <cm:default-properties>
+      <!-- Disable switch reconciliation -->
+      <cm:property name="disable-reconciliation" value="false"/>
+      <!-- Enable stale marking for switch reconciliation -->
+      <cm:property name="stale-marking-enabled" value="false"/>
+      <!-- Number of retries for switch reconciliation -->
+      <cm:property name="reconciliation-retry-count" value="5"/>
+    </cm:default-properties>
+  </cm:property-placeholder>
+
   <bean id="frmManager" class="org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl"
           init-method="start" destroy-method="close">
     <argument ref="dataBroker"/>
@@ -18,5 +32,9 @@
     <argument ref="frmConfig"/>
     <argument ref="clusterSingletonService"/>
     <argument ref="notificationService"/>
+    <argument value="${frm-disable-reconciliation}"/>
+    <argument value="${frm-stale-marking-enabled}"/>
+    <argument value="${frm-reconciliation-retry-count}"/>
+
   </bean>
 </blueprint>
\ No newline at end of file
index 997c556f756b412a5e40e2427ba0e8e70eb4d5e8..5246750de9afd6c176b3536549adb85a14f5b350 100644 (file)
@@ -74,7 +74,7 @@ public class FlowListenerTest extends FRMTest {
                 rpcProviderRegistryMock,
                 getConfig(),
                 clusterSingletonService,
-                notificationService);
+                notificationService, false, false, 5);
         forwardingRulesManager.start();
         // TODO consider tests rewrite (added because of complicated access)
         forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
index 91f437c955a4bde97c7f71fae0064a37b601aca5..7c990531d340a4bddfa1effa77d693a2b0d77938 100644 (file)
@@ -64,7 +64,7 @@ public class GroupListenerTest extends FRMTest {
                 rpcProviderRegistryMock,
                 getConfig(),
                 clusterSingletonService,
-                notificationService);
+                notificationService, false, false, 5);
         forwardingRulesManager.start();
         // TODO consider tests rewrite (added because of complicated access)
         forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
index 1afff7b91405f82da35a5d9596b07948becd4274..6fca053ef61ad0963ad6c6863784116a17d5a334 100644 (file)
@@ -64,7 +64,7 @@ public class MeterListenerTest extends FRMTest {
                 rpcProviderRegistryMock,
                 getConfig(),
                 clusterSingletonService,
-                notificationService);
+                notificationService, false, false, 5);
         forwardingRulesManager.start();
         // TODO consider tests rewrite (added because of complicated access)
         forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
index 4834f9f84037d24bb8892fbfd1f5e93cf4c10317..cfae7190217fe69c057187610ce58b7435a220f1 100644 (file)
@@ -46,7 +46,7 @@ public class NodeListenerTest extends FRMTest {
                 rpcProviderRegistryMock,
                 getConfig(),
                 clusterSingletonService,
-                notificationService);
+                notificationService, false ,false ,5);
         forwardingRulesManager.start();
     }
 
index 1060e795bde9eb1268effc99027183eb3840d5b9..52e0b851697eaf02f53dc9dda16945aa999f7127 100644 (file)
@@ -59,7 +59,7 @@ public class TableFeaturesListenerTest extends FRMTest {
                 rpcProviderRegistryMock,
                 getConfig(),
                 clusterSingletonService,
-                notificationService);
+                notificationService, false, false , 5);
         forwardingRulesManager.start();
         // TODO consider tests rewrite (added because of complicated access)
         forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
index 0adf815b8aa561f08ca932bbf3a6f5186655e9ee..a3759234c52c00aa9cd9d3aecb8f0d18870d06aa 100644 (file)
 # then to format supported by device, and reversed when deserializing.
 #
 # use-single-layer-serialization=true
+
+#############################################################################
+#                                                                           #
+#            Forwarding Rule Manager Application Configuration              #
+#                                                                           #
+#############################################################################
+
+# Disable the default switch reconciliation mechanism
+# disable-reconciliation=false
+
+# Enable stale marking for switch reconciliation. Once user enable this feature
+# forwarding rule manager will keep track of any change to the config data store
+# while the switch is disconnected from controller. Once switch reconnect to the
+# controller it will apply those changes to the switch and do the reconciliation
+# of other configuration as well.
+# NOTE: This option will be effective only if disable_reconciliation=false.
+# stale-marking-enabled=false
+
+# Number of time forwarding rules manager should retry to reconcile any specific
+# configuration.
+# reconciliation-retry-count=5
index 3b53c96815adbaab1586f1263ed7aab618164689..c919099948de5c035f3686c5da1c5a53d6a13e63 100644 (file)
@@ -457,7 +457,6 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
                     modifiable = false;
                     break;
                 default:
-                    LOG.warn("Unsupported configuration property '{}={}'", key, sValue);
                     return;
             }