From 55f62715cbd5bd05f81c05e850ed34f8f17fce8a Mon Sep 17 00:00:00 2001 From: Shuva Kar Date: Wed, 18 May 2016 00:23:10 +0530 Subject: [PATCH] BUG-5636: making table features configurable for the He plugin. DEFAULT will be ON, can be TURNED OFF. Change-Id: I16403590f068cd53806c15acde6e6ccbb3ade866 Signed-off-by: Shuva Kar Signed-off-by: Anil Vishnoi --- .../resources/initial/42-openflowplugin.xml | 12 +++--- .../md/core/role/OfEntityManager.java | 15 +++++-- .../md/core/sal/OpenflowPluginConfig.java | 43 +++++++++++++++++++ .../md/core/sal/OpenflowPluginProvider.java | 13 +++++- .../ConfigurableOpenFlowProviderModule.java | 23 ++++++++++ .../main/yang/openflow-plugin-cfg-impl.yang | 7 +++ .../core/sal/SalRegistrationManagerTest.java | 11 ++++- 7 files changed, 113 insertions(+), 11 deletions(-) create mode 100644 openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginConfig.java diff --git a/openflowplugin-controller-config/src/main/resources/initial/42-openflowplugin.xml b/openflowplugin-controller-config/src/main/resources/initial/42-openflowplugin.xml index f6c9453c26..70831eb720 100644 --- a/openflowplugin-controller-config/src/main/resources/initial/42-openflowplugin.xml +++ b/openflowplugin-controller-config/src/main/resources/initial/42-openflowplugin.xml @@ -117,11 +117,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html binding:binding-notification-service binding-notification-broker - - entity-ownership:entity-ownership-service - entity-ownership-service - - + + entity-ownership:entity-ownership-service + entity-ownership-service + + + + false diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/role/OfEntityManager.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/role/OfEntityManager.java index 26d92ec8cd..9963aaa8da 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/role/OfEntityManager.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/role/OfEntityManager.java @@ -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 rolePushResult = pool.submit(task); + final CheckedFuture rolePushResultChecked = RoleUtil.makeCheckedRuleRequestFxResult(rolePushResult); Futures.addCallback(rolePushResult, new FutureCallback(){ @@ -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 index 0000000000..1cda22ea86 --- /dev/null +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginConfig.java @@ -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);} + } +} diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java index c151c04faa..24b6533ea7 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OpenflowPluginProvider.java @@ -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; diff --git a/openflowplugin/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev140326/ConfigurableOpenFlowProviderModule.java b/openflowplugin/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev140326/ConfigurableOpenFlowProviderModule.java index 0c31a5821a..1542d5444b 100644 --- a/openflowplugin/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev140326/ConfigurableOpenFlowProviderModule.java +++ b/openflowplugin/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev140326/ConfigurableOpenFlowProviderModule.java @@ -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(); + } } diff --git a/openflowplugin/src/main/yang/openflow-plugin-cfg-impl.yang b/openflowplugin/src/main/yang/openflow-plugin-cfg-impl.yang index 0aa1eef2bc..0f031c00e0 100644 --- a/openflowplugin/src/main/yang/openflow-plugin-cfg-impl.yang +++ b/openflowplugin/src/main/yang/openflow-plugin-cfg-impl.yang @@ -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 { diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManagerTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManagerTest.java index 4bf473ac6c..367f0a0917 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManagerTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManagerTest.java @@ -90,7 +90,6 @@ public class SalRegistrationManagerTest { private ModelDrivenSwitch mdSwitchOF13; - CompositeObjectRegistration 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.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(); + + } } -- 2.36.6