BUG-5636: making table features configurable for the He plugin. 05/39005/7
authorShuva Kar <shuva.jyoti.kar@ericsson.com>
Tue, 17 May 2016 18:53:10 +0000 (00:23 +0530)
committerAnil Vishnoi <vishnoianil@gmail.com>
Wed, 25 May 2016 23:20:02 +0000 (16:20 -0700)
DEFAULT will be ON, can be TURNED OFF.

Change-Id: I16403590f068cd53806c15acde6e6ccbb3ade866
Signed-off-by: Shuva Kar <shuva.jyoti.kar@ericsson.com>
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
openflowplugin-controller-config/src/main/resources/initial/42-openflowplugin.xml
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/role/OfEntityManager.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginConfig.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java
openflowplugin/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev140326/ConfigurableOpenFlowProviderModule.java
openflowplugin/src/main/yang/openflow-plugin-cfg-impl.yang
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManagerTest.java

index f6c9453c26fc2b636e329011379d542376de1f48..70831eb720f6ad1ce5e52f106045456b707a98ba 100644 (file)
@@ -117,11 +117,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
                 <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
                 <name>binding-notification-broker</name>
             </notification-service>
-           <ownership-service>
-               <type xmlns:entity-ownership="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">entity-ownership:entity-ownership-service</type>
-               <name>entity-ownership-service</name>
-           </ownership-service>
-           
+            <ownership-service>
+                <type xmlns:entity-ownership="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">entity-ownership:entity-ownership-service</type>
+                <name>entity-ownership-service</name>
+            </ownership-service>
+
+          <!-- openflowplugin configuraion -->
+          <skip-table-features>false</skip-table-features>
 
         </module>
       </modules>
index 26d92ec8cdb1812b4007e6c5065c2111cbfcdf15..9963aaa8da6c6e7f814122d7fc5fc56a3443ed84 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipC
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginConfig;
 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -40,7 +41,6 @@ import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.FutureCallback;
-import java.util.concurrent.ArrayBlockingQueue;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.CheckedFuture;
 import org.slf4j.Logger;
@@ -63,8 +63,11 @@ public class OfEntityManager implements TransactionChainListener{
 
     private final ListeningExecutorService pool;
 
-    public OfEntityManager( EntityOwnershipService entityOwnershipService ) {
+    private final OpenflowPluginConfig openflowPluginConfig;
+
+    public OfEntityManager(EntityOwnershipService entityOwnershipService, OpenflowPluginConfig ofPluginConfig) {
         this.entityOwnershipService = entityOwnershipService;
+        openflowPluginConfig = ofPluginConfig;
         ownershipListener = new OpenflowOwnershipListener(this);
         entsession = new ConcurrentHashMap<>();
         entRegistrationMap = new ConcurrentHashMap<>();
@@ -243,6 +246,7 @@ public class OfEntityManager implements TransactionChainListener{
             final String targetSwitchDPId = sessionContext.getFeatures().getDatapathId().toString();
             RolePushTask task = new RolePushTask(newRole, sessionContext);
             ListenableFuture<Boolean> rolePushResult = pool.submit(task);
+
             final CheckedFuture<Boolean, RolePushException> rolePushResultChecked =
                 RoleUtil.makeCheckedRuleRequestFxResult(rolePushResult);
             Futures.addCallback(rolePushResult, new FutureCallback<Boolean>(){
@@ -250,7 +254,12 @@ public class OfEntityManager implements TransactionChainListener{
                 public void onSuccess(Boolean result){
                     LOG.info("onDeviceOwnershipChanged: Controller is successfully set as a " +
                             "MASTER controller for {}", targetSwitchDPId);
-                    entsession.get(entity).getOfSwitch().sendEmptyTableFeatureRequest();
+                    if(!openflowPluginConfig.skipTableFeatures()) {
+                        if(LOG.isDebugEnabled()){
+                            LOG.debug("Send table feature request for entity {}",entity.getId());
+                        }
+                        entsession.get(entity).getOfSwitch().sendEmptyTableFeatureRequest();
+                    }
                     sendNodeAddedNotification(entsession.get(entity));
 
                 }
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginConfig.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginConfig.java
new file mode 100644 (file)
index 0000000..1cda22e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016 Ericsson Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal;
+
+/**
+ * Created by eshuvka on 5/16/2016.
+ */
+public class OpenflowPluginConfig {
+
+    private final boolean skipTableFeatures;
+
+    private OpenflowPluginConfig (OpenflowPluginConfigBuilder builder){
+        skipTableFeatures = builder.skipTableFeatures();
+    }
+
+    public boolean skipTableFeatures(){
+        return skipTableFeatures;
+    }
+
+    public static OpenflowPluginConfigBuilder builder(){
+        return new OpenflowPluginConfigBuilder();
+    }
+
+    public static class OpenflowPluginConfigBuilder{
+        private boolean skipTableFeatures;
+
+        public boolean skipTableFeatures(){
+            return skipTableFeatures;
+        }
+
+        public void setSkipTableFeatures(boolean skip){
+            skipTableFeatures = skip;
+        }
+
+        public OpenflowPluginConfig build() {return new OpenflowPluginConfig(this);}
+    }
+}
index c151c04faa30ad41317fe1e2a9386d8145a56169..24b6533ea72e0f0bd90a4c277dde10a1c89fbaac 100644 (file)
@@ -56,6 +56,8 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
     private RpcProviderRegistry rpcRegistry;
     private EntityOwnershipService entityOwnershipService;
 
+    private OpenflowPluginConfig openflowPluginConfig;
+
     /**
      * Initialization of services and msgSpy counter
      */
@@ -63,7 +65,7 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         messageCountProvider = new MessageSpyCounterImpl();
         extensionConverterManager = new ExtensionConverterManagerImpl();
         roleManager = new OFRoleManager(OFSessionUtil.getSessionManager());
-        entManager = new OfEntityManager(entityOwnershipService);
+        entManager = new OfEntityManager(entityOwnershipService,getOpenflowPluginConfig());
         entManager.setDataBroker(dataBroker);
 
         LOG.debug("dependencies gathered..");
@@ -160,6 +162,15 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         this.entityOwnershipService = entityOwnershipService;
     }
 
+    public void setOpenflowPluginConfig(OpenflowPluginConfig openflowPluginConfig) {
+        this.openflowPluginConfig = openflowPluginConfig;
+    }
+
+    @VisibleForTesting
+    public OpenflowPluginConfig getOpenflowPluginConfig() {
+        return openflowPluginConfig;
+    }
+
     @VisibleForTesting
     protected RpcProviderRegistry getRpcRegistry() {
         return rpcRegistry;
index 0c31a5821a0b1aa0c354ccede34f711f4a51a1b7..1542d5444bacf717e81ed154717b3f9987528975 100644 (file)
@@ -11,15 +11,23 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflo
 
 import com.google.common.base.MoreObjects;
 import javax.management.ObjectName;
+
+import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginConfig;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
 *
 */
 public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.AbstractConfigurableOpenFlowProviderModule {
 
+    private static final Logger LOG = LoggerFactory.getLogger(ConfigurableOpenFlowProviderModule.class);
+
     private OpenflowPluginProvider pluginProvider;
 
+    private static final boolean SKIP_TABLE_FEATURES = false;
+
     /**
      * @param identifier module identifier
      * @param dependencyResolver dependency resolver
@@ -54,6 +62,7 @@ public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.y
         pluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
         pluginProvider.setEntityOwnershipService(getOwnershipServiceDependency());
         pluginProvider.setRole(getRole());
+        pluginProvider.setOpenflowPluginConfig(readConfig());
         pluginProvider.initialization();
         return pluginProvider;
     }
@@ -85,4 +94,18 @@ public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.y
 
         return recycled;
     }
+
+    private OpenflowPluginConfig readConfig(){
+
+        final OpenflowPluginConfig.OpenflowPluginConfigBuilder openflowCfgBuilder = OpenflowPluginConfig.builder();
+
+        if(getSkipTableFeatures()!=null){
+            openflowCfgBuilder.setSkipTableFeatures(getSkipTableFeatures().booleanValue());
+        } else{
+            LOG.warn("Could not load XML configuration file via ConfigSubsystem! Fallback to default config value(s)");
+            openflowCfgBuilder.setSkipTableFeatures(SKIP_TABLE_FEATURES);
+        }
+
+        return openflowCfgBuilder.build();
+    }
 }
index 0aa1eef2bc5b12c3eb2a3d3346fabe39a278fcf5..0f031c00e01d67ae2e2fd8e566739d35f1439f86 100644 (file)
@@ -107,6 +107,13 @@ module openflow-provider-impl {
                 type ofp-role;
                 default "NOCHANGE";
             }
+
+            leaf skip-table-features {
+                description "Ability to skip pulling and storing of large table features. These features are still
+                    available via rpc, so if use set it to true, it won't store table feature data in DataStore.";
+                type boolean;
+                default "false";
+            }
         }
 
         case msg-spy-service-impl {
index 4bf473ac6c4d62b678750935a73f13660861660e..367f0a0917be5f2df0da62a7364dbb962cec5e77 100644 (file)
@@ -90,7 +90,6 @@ public class SalRegistrationManagerTest {
 
     private ModelDrivenSwitch mdSwitchOF13;
 
-
     CompositeObjectRegistration<ModelDrivenSwitch> registration;
 
 
@@ -106,7 +105,7 @@ public class SalRegistrationManagerTest {
         context.setFeatures(features);
         context.setNotificationEnqueuer(notificationEnqueuer);
 
-       OfEntityManager entManager = new OfEntityManager(entityOwnershipService);
+       OfEntityManager entManager = new OfEntityManager(entityOwnershipService,getConfig());
         mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context);
         registration = new CompositeObjectRegistration<>(mdSwitchOF13, Collections.<Registration>emptyList());
         context.setProviderRegistration(registration);
@@ -193,5 +192,13 @@ public class SalRegistrationManagerTest {
         SwitchSessionKeyOF switchSessionKeyOF = new SwitchSessionKeyOF();
         salRegistrationManager.onSessionAdded(switchSessionKeyOF, context);
     }
+
+    public OpenflowPluginConfig getConfig(){
+        OpenflowPluginConfig.OpenflowPluginConfigBuilder cfgBuilder =
+                new OpenflowPluginConfig.OpenflowPluginConfigBuilder();
+        cfgBuilder.setSkipTableFeatures(true);
+        return cfgBuilder.build();
+
+    }
 }