replace hard-coded OpenflowProviderConfig with XML configuration file
authorMichael Vorburger <mike@vorburger.ch>
Wed, 19 Dec 2018 00:23:14 +0000 (01:23 +0100)
committerMichael Vorburger <mike@vorburger.ch>
Wed, 1 Jul 2020 23:37:49 +0000 (01:37 +0200)
Note how the test proves that the default from the YANG is used!

Signed-off-by: Michael Vorburger <mike@vorburger.ch>
src/main/java/org/opendaylight/openflowplugin/simple/OpenFlowPluginWiring.java
src/main/resources/initial/openflow-provider-config.xml [new file with mode: 0644]
src/test/java/org/opendaylight/openflowplugin/simple/test/OpenFlowPluginWiringTest.java

index 01738459d69a5f22ff898e481557301e7caa7bb6..b391b5d8b866cbeb87e93186f7dd75150ada3b76 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 import com.google.inject.Provides;
 import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.simple.ConfigReader;
 import org.opendaylight.infrautils.inject.guice.AutoWiringModule;
 import org.opendaylight.infrautils.inject.guice.GuiceClassPathBinder;
 import org.opendaylight.mdsal.simple.PingPong;
@@ -25,10 +26,7 @@ import org.opendaylight.openflowplugin.impl.configuration.ConfigurationServiceFa
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint16Type;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfigBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -55,34 +53,6 @@ public class OpenFlowPluginWiring extends AutoWiringModule {
         bind(ForwardingRulesManagerConfig.class).toInstance(
                 new ForwardingRulesManagerConfigBuilder().setDisableReconciliation(false).setStaleMarkingEnabled(false)
                         .setReconciliationRetryCount(5).setBundleBasedReconciliationEnabled(false).build());
-        // TODO ConfigReader for OpenflowProviderConfig XML - but there is none in OFP?  Hard-code, for now:
-        // perhaps we can just replace it with an empty XML??
-        bind(OpenflowProviderConfig.class).toInstance(new OpenflowProviderConfigBuilder()
-                .setRpcRequestsQuota(new NonZeroUint16Type(20000))
-                .setSwitchFeaturesMandatory(false)
-                .setGlobalNotificationQuota(64000L)
-                .setIsStatisticsPollingOn(true)
-                .setIsTableStatisticsPollingOn(true)
-                .setIsFlowStatisticsPollingOn(true)
-                .setIsGroupStatisticsPollingOn(true)
-                .setIsMeterStatisticsPollingOn(true)
-                .setIsPortStatisticsPollingOn(true)
-                .setIsQueueStatisticsPollingOn(true)
-                .setIsStatisticsRpcEnabled(false)
-                .setBarrierIntervalTimeoutLimit(new NonZeroUint32Type(500L))
-                .setBarrierCountLimit(new NonZeroUint16Type(25600))
-                .setEchoReplyTimeout(new NonZeroUint32Type(2000L))
-                .setThreadPoolMinThreads(1)
-                .setThreadPoolMaxThreads(new NonZeroUint16Type(32000))
-                .setThreadPoolTimeout(60L)
-                .setEnableFlowRemovedNotification(true)
-                .setSkipTableFeatures(true)
-                .setBasicTimerDelay(new NonZeroUint32Type(3000L))
-                .setMaximumTimerDelay(new NonZeroUint32Type(900000L))
-                .setUseSingleLayerSerialization(true)
-                .setEnableEqualRole(false)
-                .setDeviceConnectionRateLimitPerMin(0)
-                .build());
     }
 
     @Provides
@@ -101,6 +71,11 @@ public class OpenFlowPluginWiring extends AutoWiringModule {
         return openFlowJavaWiring.getSwitchConnectionProviderList();
     }
 
+    @Provides
+    @Singleton OpenflowProviderConfig getUpgradeConfig(ConfigReader configReader) {
+        return configReader.read("/initial/openflow-provider-config", OpenflowProviderConfig.class);
+    }
+
     private static class NoPacketProcessingService implements PacketProcessingService {
 
         // TODO <odl:action-provider
diff --git a/src/main/resources/initial/openflow-provider-config.xml b/src/main/resources/initial/openflow-provider-config.xml
new file mode 100644 (file)
index 0000000..3ab3acf
--- /dev/null
@@ -0,0 +1,2 @@
+<openflow-provider-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:provider:config">
+</openflow-provider-config>
index 63917f7ce0deb47e0e25ccfabe11979d7fc217bb..390182c35af0abe42f03c0f6fb1cf7c0a677ab96 100644 (file)
@@ -7,7 +7,11 @@
  */
 package org.opendaylight.openflowplugin.simple.test;
 
+import static com.google.common.truth.Truth.assertThat;
+
+import javax.inject.Inject;
 import org.junit.Rule;
+import org.junit.Test;
 import org.opendaylight.controller.simple.ControllerWiring;
 import org.opendaylight.infrautils.inject.guice.GuiceClassPathBinder;
 import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
@@ -18,6 +22,7 @@ import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTe
 import org.opendaylight.infrautils.web.WebWiring;
 import org.opendaylight.openflowplugin.simple.OpenFlowPluginWiring;
 import org.opendaylight.serviceutils.simple.ServiceUtilsWiring;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
 
 public class OpenFlowPluginWiringTest extends AbstractSimpleDistributionTest {
 
@@ -27,4 +32,10 @@ public class OpenFlowPluginWiringTest extends AbstractSimpleDistributionTest {
             new ControllerWiring(), new DiagStatusWiring(), new WebWiring(), new ReadyWiring(),
             new AnnotationsModule());
 
+    @Inject OpenflowProviderConfig ofpConfig;
+
+    @Test public void testConfig() {
+        assertThat(ofpConfig.getGlobalNotificationQuota()).named("globalNotificationQuota").isEqualTo(64000L);
+    }
+
 }