Fix config attributes with same names for different modules. 91/9291/9
authorMaros Marsalek <mmarsale@cisco.com>
Thu, 24 Jul 2014 15:09:53 +0000 (17:09 +0200)
committerMaros Marsalek <mmarsale@cisco.com>
Tue, 29 Jul 2014 06:45:44 +0000 (08:45 +0200)
Yang does not allow attributes in different cases to have the same name.
In yang modules for config, the configuration is located in cases and if 2 cases in same yang module contain child with same name, the transformation of data from CompositeNode to NormalizedNode

NOTE: This might break bgpcep and SP distribution, check.

Change-Id: I9bad24df9ac149da74b745ff648c72345e33deb1
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyFactoryModule.java
opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyFactoryModule.java
opendaylight/commons/protocol-framework/src/main/yang/odl-protocol-framework-cfg.yang
opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/ReconnectImmediatelyStrategyModuleTest.java
opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/controller/config/yang/protocol/framework/TimedReconnectStrategyModuleTest.java
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java
opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang

index 580a53be94c57ad08ce7b69352994eb028486311..12b771df808ccf49b2a57ab1b4411f17f298fb65 100644 (file)
@@ -32,14 +32,14 @@ public final class ReconnectImmediatelyStrategyFactoryModule extends org.openday
 
     @Override
     protected void customValidation(){
-        JmxAttributeValidationException.checkNotNull(getTimeout(), "value is not set.", timeoutJmxAttribute);
-        JmxAttributeValidationException.checkCondition(getTimeout() >= 0, "value " + getTimeout() + " is less than 0",
-                timeoutJmxAttribute);
+        JmxAttributeValidationException.checkNotNull(getReconnectTimeout(), "value is not set.", reconnectTimeoutJmxAttribute);
+        JmxAttributeValidationException.checkCondition(getReconnectTimeout() >= 0, "value " + getReconnectTimeout() + " is less than 0",
+                reconnectTimeoutJmxAttribute);
     }
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        return new ReconnectImmediatelyStrategyFactoryCloseable(getExecutorDependency(), getTimeout());
+        return new ReconnectImmediatelyStrategyFactoryCloseable(getReconnectExecutorDependency(), getReconnectTimeout());
     }
 
     private static final class ReconnectImmediatelyStrategyFactoryCloseable implements ReconnectStrategyFactory, AutoCloseable {
index b8849c7a1d7c8b42db885274f3f8311b2c6626e3..0b4a7baf6fb43737b3d673723d5a3da7ad29a08c 100644 (file)
@@ -49,7 +49,7 @@ public final class TimedReconnectStrategyFactoryModule extends org.opendaylight.
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        return new TimedReconnectStrategyFactoryCloseable(getExecutorDependency(),
+        return new TimedReconnectStrategyFactoryCloseable(getTimedReconnectExecutorDependency(),
                 getConnectTime(), getMinSleep(), getSleepFactor().doubleValue(), getMaxSleep(), getMaxAttempts(),
                 getDeadline());
     }
index 1856369178c0c2230db2eca3e24288ce5ca2f0b3..cd84d4a95e24156453d9d56b0b02ee072f2d036a 100644 (file)
@@ -77,12 +77,12 @@ module protocol-framework {
         case reconnect-immediately-strategy-factory {
             when "/config:modules/config:module/config:type = 'reconnect-immediately-strategy-factory'";
 
-            leaf timeout {
+            leaf reconnect-timeout {
                 mandatory true;
                 type int32;
             }
 
-            container executor {
+            container reconnect-executor {
                 uses config:service-ref {
                     refine type {
                         mandatory true;
@@ -138,7 +138,7 @@ module protocol-framework {
                 units "milliseconds";
             }
 
-            container executor {
+            container timed-reconnect-executor {
                 uses config:service-ref {
                     refine type {
                         mandatory true;
index 9beadc4dbb2b7f8aa34a0390e9aa65614168d666..cfdf3bff28729e5f80a4c9811316eb04e2b1bcc6 100644 (file)
@@ -78,7 +78,7 @@ public class ReconnectImmediatelyStrategyModuleTest extends AbstractConfigTest {
         final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(
                 transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
                 ReconnectImmediatelyStrategyFactoryModuleMXBean.class);
-        mxBean.setTimeout(200);
+        mxBean.setReconnectTimeout(200);
         final CommitStatus status = transaction.commit();
         assertBeanCount(1, FACTORY_NAME);
         assertStatus(status, 0, 1, 1);
@@ -99,8 +99,8 @@ public class ReconnectImmediatelyStrategyModuleTest extends AbstractConfigTest {
         final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
         final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
                 ReconnectImmediatelyStrategyFactoryModuleMXBean.class);
-        mxBean.setTimeout(timeout);
-        mxBean.setExecutor(GlobalEventExecutorUtil.create(transaction));
+        mxBean.setReconnectTimeout(timeout);
+        mxBean.setReconnectExecutor(GlobalEventExecutorUtil.create(transaction));
         return nameCreated;
     }
 
index a8cdff711905ead55193384baed9362d1f7df909..1c068a98e748e76e0404fc5b71c87d97e839f75d 100644 (file)
@@ -7,6 +7,13 @@
  */
 package org.opendaylight.controller.config.yang.protocol.framework;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.math.BigDecimal;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
@@ -17,14 +24,6 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.netty.eventexecutor.GlobalEventExecutorModuleFactory;
 
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-import java.math.BigDecimal;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 public class TimedReconnectStrategyModuleTest extends AbstractConfigTest {
 
     private static final String INSTANCE_NAME = "timed-reconect-stategy-facotry-impl";
@@ -158,7 +157,7 @@ public class TimedReconnectStrategyModuleTest extends AbstractConfigTest {
         mxBean.setMaxSleep(maxSleep);
         mxBean.setMinSleep(minSleep);
         mxBean.setSleepFactor(sleepFactor);
-        mxBean.setExecutor(GlobalEventExecutorUtil.create(transaction));
+        mxBean.setTimedReconnectExecutor(GlobalEventExecutorUtil.create(transaction));
         return nameCreated;
     }
 
index 9534094fa85fca88574225ad5c0e241f9927ca94..03da7f0ccd6cd37a4044404e3426a8f5307f580b 100644 (file)
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">prefix:inmemory-operational-datastore-provider</type>
                     <name>operational-store-service</name>
-                    <schema-service>
+                    <operational-schema-service>
                         <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
                         <name>yang-schema-service</name>
-                    </schema-service>
+                    </operational-schema-service>
                 </module>
                 <!--
                      Tree-based in-memory data store. This is the data store which is currently
index 172b0dbc01b0deb3e384a12a46722806db273bbc..b39c9bbbd8ca7f0cbe504470ec5f9237e88c0a70 100644 (file)
@@ -23,7 +23,7 @@ public class InMemoryOperationalDataStoreProviderModule extends org.opendaylight
     @Override
     public java.lang.AutoCloseable createInstance() {
       InMemoryDOMDataStore ids = new InMemoryDOMDataStore("DOM-OPER", MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()));
-      getSchemaServiceDependency().registerSchemaServiceListener(ids);
+      getOperationalSchemaServiceDependency().registerSchemaServiceListener(ids);
       return ids;
     }
 
index 03220a3e5d1b2bd3a8d39b2da43e279ac4dd769f..d4f57b53fed168dae3f1402123f9164f8c772455 100644 (file)
@@ -58,7 +58,10 @@ module opendaylight-inmemory-datastore-provider {
             case inmemory-operational-datastore-provider {
                 when "/config:modules/config:module/config:type = 'inmemory-operational-datastore-provider'";
 
-                container schema-service {
+                // Yang does not allow two cases from same namespaces with same children
+                // Schema-service dependency renamed to operational-schema-service
+                // to prevent conflict with schema-service container from inmemory-config-datastore-provider
+                container operational-schema-service {
                   uses config:service-ref {
                        refine type {
                               mandatory false;