Merge "Added DELETE on cors.allowed.methods for a few missing nb bundles. Also added...
authorEd Warnicke <eaw@cisco.com>
Mon, 2 Dec 2013 22:43:50 +0000 (22:43 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 2 Dec 2013 22:43:50 +0000 (22:43 +0000)
46 files changed:
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalInfo.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalTransactionalInfo.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManager.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/ModulesHolder.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/TransactionHolder.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTracker.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImplTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManagerTest.java
opendaylight/config/threadpool-config-impl/pom.xml
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java [deleted file]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java [deleted file]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java [deleted file]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java [deleted file]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/fixed/FixedThreadPoolModule.java [moved from opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModule.java with 50% similarity]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/fixed/FixedThreadPoolModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/flexible/FlexibleThreadPoolModule.java [moved from opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModule.java with 62% similarity]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/flexible/FlexibleThreadPoolModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-fixed.yang [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-flexible.yang [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-scheduled.yang [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/FixedThreadPoolConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/flexible/FlexibleThreadPoolConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/ScheduledThreadPoolConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/TestingScheduledThreadPoolModule.java
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/00-netty.conf [new file with mode: 0644]
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.conf [moved from opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/controller-config.2.txt with 100% similarity]
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/controller-config.1.txt [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/CodecRegistry.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/CodecMapping.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/GeneratorListener.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/InstanceIdentifierCodecImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/RuntimeGeneratedMappingServiceImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/TransformerGenerator.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataBrokerImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentDataServiceConnector.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/ClassLoaderUtils.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/YangSchemaUtils.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java

index 0fd6c5279409e3412de86a33735c3dc4daddf058..1b695a9bda2fe42a2fcdd042636e9bff4b0a511d 100644 (file)
@@ -129,10 +129,18 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
      */
     @Override
     public synchronized ObjectName beginConfig() {
-        return beginConfigInternal().getControllerObjectName();
+        return beginConfig(false);
     }
 
-    private synchronized ConfigTransactionControllerInternal beginConfigInternal() {
+    /**
+     * @param blankTransaction true if this transaction is created automatically by
+     *                         org.opendaylight.controller.config.manager.impl.osgi.BlankTransactionServiceTracker
+     */
+    public synchronized ObjectName beginConfig(boolean blankTransaction) {
+        return beginConfigInternal(blankTransaction).getControllerObjectName();
+    }
+
+    private synchronized ConfigTransactionControllerInternal beginConfigInternal(boolean blankTransaction) {
         versionCounter++;
         String transactionName = "ConfigTransaction-" + version + "-" + versionCounter;
         TransactionJMXRegistrator transactionRegistrator = baseJMXRegistrator
@@ -140,7 +148,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         Map<String, Map.Entry<ModuleFactory, BundleContext>> allCurrentFactories = Collections.unmodifiableMap(resolver.getAllFactories());
         ConfigTransactionControllerInternal transactionController = new ConfigTransactionControllerImpl(
                 transactionName, transactionRegistrator, version,
-                versionCounter, allCurrentFactories, transactionsMBeanServer, configMBeanServer, bundleContext);
+                versionCounter, allCurrentFactories, transactionsMBeanServer, configMBeanServer, blankTransaction);
         try {
             transactionRegistrator.registerMBean(transactionController, transactionController.getControllerObjectName());
         } catch (InstanceAlreadyExistsException e) {
@@ -223,7 +231,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
             RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator;
             if (entry.hasOldModule() == false) {
                 runtimeBeanRegistrator = baseJMXRegistrator
-                        .createRuntimeBeanRegistrator(entry.getName());
+                        .createRuntimeBeanRegistrator(entry.getIdentifier());
             } else {
                 // reuse old JMX registrator
                 runtimeBeanRegistrator = entry.getOldInternalInfo()
@@ -236,7 +244,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
                         .setRuntimeBeanRegistrator(runtimeBeanRegistrator);
             }
             // save it to info so it is accessible afterwards
-            runtimeRegistrators.put(entry.getName(), runtimeBeanRegistrator);
+            runtimeRegistrators.put(entry.getIdentifier(), runtimeBeanRegistrator);
         }
 
         // can register runtime beans
@@ -264,8 +272,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
             // determine if current instance was recreated or reused or is new
 
             // rules for closing resources:
-            // osgi registration - will be (re)created every time, so it needs
-            // to be closed here
+            // osgi registration - will be reused if possible.
             // module jmx registration - will be (re)created every time, needs
             // to be closed here
             // runtime jmx registration - should be taken care of by module
@@ -279,7 +286,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
                 ModuleInternalInfo oldInternalInfo = entry.getOldInternalInfo();
                 DynamicReadableWrapper oldReadableConfigBean = oldInternalInfo
                         .getReadableModule();
-                currentConfig.remove(entry.getName());
+                currentConfig.remove(entry.getIdentifier());
 
                 // test if old instance == new instance
                 if (oldReadableConfigBean.getInstance().equals(module.getInstance())) {
@@ -324,7 +331,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
                     BundleContext bc = configTransactionController.
                             getModuleFactoryBundleContext(moduleFactory.getImplementationName());
                     osgiRegistration = beanToOsgiServiceManager.registerToOsgi(module.getClass(),
-                            newReadableConfigBean.getInstance(), entry.getName(), bc);
+                            newReadableConfigBean.getInstance(), entry.getIdentifier(), bc);
                 } else {
                     throw new NullPointerException(entry.getIdentifier().getFactoryName() + " ModuleFactory not found.");
                 }
@@ -332,11 +339,11 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
             }
 
             RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator = runtimeRegistrators
-                    .get(entry.getName());
+                    .get(entry.getIdentifier());
             ModuleInternalInfo newInfo = new ModuleInternalInfo(
-                    entry.getName(), newReadableConfigBean, osgiRegistration,
+                    entry.getIdentifier(), newReadableConfigBean, osgiRegistration,
                     runtimeBeanRegistrator, newModuleJMXRegistrator,
-                    orderingIdx);
+                    orderingIdx, entry.isDefaultBean());
 
             newConfigEntries.put(module, newInfo);
             orderingIdx++;
@@ -367,7 +374,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
     /**
      * Abort open transactions and unregister read only modules. Since this
      * class is not responsible for registering itself under
-     * {@link ConfigRegistryMXBean#OBJECT_NAME}, it will not unregister itself
+     * {@link org.opendaylight.controller.config.api.ConfigRegistry#OBJECT_NAME}, it will not unregister itself
      * here.
      */
     @Override
index a9ab664fd6d44cd19a4b38c02248a96d938b41b9..3e53a7a217e1855dedb596a2b5f1dedcd707ca85 100644 (file)
@@ -78,13 +78,14 @@ class ConfigTransactionControllerImpl implements
             configBeanModificationDisabled);
     private final MBeanServer configMBeanServer;
 
-    private final BundleContext bundleContext;
+    private final boolean blankTransaction;
 
     public ConfigTransactionControllerImpl(String transactionName,
                                            TransactionJMXRegistrator transactionRegistrator,
                                            long parentVersion, long currentVersion,
                                            Map<String, Map.Entry<ModuleFactory, BundleContext>> currentlyRegisteredFactories,
-                                           MBeanServer transactionsMBeanServer, MBeanServer configMBeanServer, BundleContext bundleContext) {
+                                           MBeanServer transactionsMBeanServer, MBeanServer configMBeanServer,
+                                           boolean blankTransaction) {
 
         this.transactionIdentifier = new TransactionIdentifier(transactionName);
         this.controllerON = ObjectNameUtil
@@ -100,7 +101,7 @@ class ConfigTransactionControllerImpl implements
         this.dependencyResolverManager = new DependencyResolverManager(transactionName, transactionStatus);
         this.transactionsMBeanServer = transactionsMBeanServer;
         this.configMBeanServer = configMBeanServer;
-        this.bundleContext = bundleContext;
+        this.blankTransaction = blankTransaction;
     }
 
     @Override
@@ -143,7 +144,8 @@ class ConfigTransactionControllerImpl implements
                 // ensure default module to be registered to jmx even if its module factory does not use dependencyResolverFactory
                 DependencyResolver dependencyResolver = dependencyResolverManager.getOrCreate(module.getIdentifier());
                 try {
-                    putConfigBeanToJMXAndInternalMaps(module.getIdentifier(), module, moduleFactory, null, dependencyResolver);
+                    boolean defaultBean = true;
+                    putConfigBeanToJMXAndInternalMaps(module.getIdentifier(), module, moduleFactory, null, dependencyResolver, defaultBean);
                 } catch (InstanceAlreadyExistsException e) {
                     throw new IllegalStateException(e);
                 }
@@ -184,7 +186,8 @@ class ConfigTransactionControllerImpl implements
                     "Error while copying old configuration from %s to %s",
                     oldConfigBeanInfo, moduleFactory), e);
         }
-        putConfigBeanToJMXAndInternalMaps(moduleIdentifier, module, moduleFactory, oldConfigBeanInfo, dependencyResolver);
+        putConfigBeanToJMXAndInternalMaps(moduleIdentifier, module, moduleFactory, oldConfigBeanInfo, dependencyResolver,
+                oldConfigBeanInfo.isDefaultBean());
     }
 
     @Override
@@ -201,14 +204,15 @@ class ConfigTransactionControllerImpl implements
         DependencyResolver dependencyResolver = dependencyResolverManager.getOrCreate(moduleIdentifier);
         Module module = moduleFactory.createModule(instanceName, dependencyResolver,
                 getModuleFactoryBundleContext(moduleFactory.getImplementationName()));
+        boolean defaultBean = false;
         return putConfigBeanToJMXAndInternalMaps(moduleIdentifier, module,
-                moduleFactory, null, dependencyResolver);
+                moduleFactory, null, dependencyResolver, defaultBean);
     }
 
     private synchronized ObjectName putConfigBeanToJMXAndInternalMaps(
             ModuleIdentifier moduleIdentifier, Module module,
             ModuleFactory moduleFactory,
-            @Nullable ModuleInternalInfo maybeOldConfigBeanInfo, DependencyResolver dependencyResolver)
+            @Nullable ModuleInternalInfo maybeOldConfigBeanInfo, DependencyResolver dependencyResolver, boolean isDefaultBean)
             throws InstanceAlreadyExistsException {
 
         logger.debug("Adding module {} to transaction {}", moduleIdentifier, this);
@@ -232,14 +236,14 @@ class ConfigTransactionControllerImpl implements
                 .registerMBean(writableDynamicWrapper, writableON);
         ModuleInternalTransactionalInfo moduleInternalTransactionalInfo = new ModuleInternalTransactionalInfo(
                 moduleIdentifier, module, moduleFactory,
-                maybeOldConfigBeanInfo, transactionModuleJMXRegistration);
+                maybeOldConfigBeanInfo, transactionModuleJMXRegistration, isDefaultBean);
 
         dependencyResolverManager.put(moduleInternalTransactionalInfo);
         return writableON;
     }
 
     @Override
-    public void destroyModule(ObjectName objectName)
+    public synchronized void destroyModule(ObjectName objectName)
             throws InstanceNotFoundException {
         String foundTransactionName = ObjectNameUtil
                 .getTransactionName(objectName);
@@ -253,9 +257,17 @@ class ConfigTransactionControllerImpl implements
         destroyModule(moduleIdentifier);
     }
 
-    private void destroyModule(ModuleIdentifier moduleIdentifier) {
+    private synchronized void destroyModule(ModuleIdentifier moduleIdentifier) {
         logger.debug("Destroying module {} in transaction {}", moduleIdentifier, this);
         transactionStatus.checkNotAborted();
+
+        if (blankTransaction == false) {
+            ModuleInternalTransactionalInfo found =
+                    dependencyResolverManager.findModuleInternalTransactionalInfo(moduleIdentifier);
+            if (found.isDefaultBean()) {
+                logger.warn("Warning: removing default bean. This will be forbidden in next version of config-subsystem");
+            }
+        }
         ModuleInternalTransactionalInfo removedTInfo = dependencyResolverManager.destroyModule(moduleIdentifier);
         // remove from jmx
         removedTInfo.getTransactionModuleJMXRegistration().close();
index c675db5bff87d9c3b88bd109c68687454cfc559a..14a706dd9b990e9251233aacef2db022502fb1dc 100644 (file)
@@ -35,12 +35,14 @@ public class ModuleInternalInfo implements Comparable<ModuleInternalInfo>,
     private final OsgiRegistration osgiRegistration;
     private final ModuleJMXRegistrator moduleJMXRegistrator;
     private final int orderingIdx;
+    private final boolean isDefaultBean;
 
     public ModuleInternalInfo(ModuleIdentifier name,
             @Nullable DynamicReadableWrapper readableModule,
             OsgiRegistration osgiRegistration,
             RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator,
-            ModuleJMXRegistrator moduleJMXRegistrator, int orderingIdx) {
+            ModuleJMXRegistrator moduleJMXRegistrator, int orderingIdx,
+            boolean isDefaultBean) {
 
         if (osgiRegistration == null) {
             throw new IllegalArgumentException(
@@ -56,6 +58,7 @@ public class ModuleInternalInfo implements Comparable<ModuleInternalInfo>,
         this.name = name;
         this.moduleJMXRegistrator = moduleJMXRegistrator;
         this.orderingIdx = orderingIdx;
+        this.isDefaultBean = isDefaultBean;
     }
 
     public DynamicReadableWrapper getReadableModule() {
@@ -117,4 +120,8 @@ public class ModuleInternalInfo implements Comparable<ModuleInternalInfo>,
     public ModuleIdentifier getIdentifier() {
         return name;
     }
+
+    public boolean isDefaultBean() {
+        return isDefaultBean;
+    }
 }
index c4f40fbeeb42a6c05e08a6213fc2d928d2a912da..0a4ceacb439c363a5884b0e2296089d6f10ab6ef 100644 (file)
@@ -24,27 +24,22 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
     @Nullable
     private final ModuleInternalInfo maybeOldInternalInfo;
     private final TransactionModuleJMXRegistration transactionModuleJMXRegistration;
+    private final boolean isDefaultBean;
 
     ModuleInternalTransactionalInfo(ModuleIdentifier name, Module module,
             ModuleFactory moduleFactory,
             ModuleInternalInfo maybeOldInternalInfo,
-            TransactionModuleJMXRegistration transactionModuleJMXRegistration) {
+            TransactionModuleJMXRegistration transactionModuleJMXRegistration,
+            boolean isDefaultBean) {
         this.name = name;
         this.module = module;
         this.moduleFactory = moduleFactory;
         this.maybeOldInternalInfo = maybeOldInternalInfo;
         this.transactionModuleJMXRegistration = transactionModuleJMXRegistration;
+        this.isDefaultBean = isDefaultBean;
     }
 
 
-    /**
-     * Use {@link #getIdentifier()} instead.
-     */
-    @Deprecated
-    public ModuleIdentifier getName() {
-        return name;
-    }
-
     public boolean hasOldModule() {
         return maybeOldInternalInfo != null;
     }
@@ -85,4 +80,8 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
     public ModuleIdentifier getIdentifier() {
         return name;
     }
+
+    public boolean isDefaultBean() {
+        return isDefaultBean;
+    }
 }
index dea78c8b155d9f125783232bd7c5b531e673bce0..645aab37ff770cfc3cbe6399f139a7cf68a07470 100644 (file)
@@ -117,6 +117,11 @@ public class DependencyResolverManager implements TransactionHolder, DependencyR
                 jmxAttributeForReporting);
     }
 
+    @Override
+    public ModuleInternalTransactionalInfo findModuleInternalTransactionalInfo(ModuleIdentifier moduleIdentifier) {
+        return modulesHolder.findModuleInternalTransactionalInfo(moduleIdentifier);
+    }
+
     @Override
     public ModuleFactory findModuleFactory(ModuleIdentifier moduleIdentifier,
             JmxAttribute jmxAttributeForReporting) {
@@ -139,7 +144,7 @@ public class DependencyResolverManager implements TransactionHolder, DependencyR
         List<ModuleIdentifier> result = new ArrayList<>();
         for( ModuleInternalTransactionalInfo  info : modulesHolder.getAllInfos()) {
             if (factory.equals(info.getModuleFactory())) {
-                result.add(info.getName());
+                result.add(info.getIdentifier());
             }
         }
         return result;
index 6bbd7875a94b1fa8a1d4dd8662b2a9cb835420ea..7c7d9f95a4e71899ff5feec39bdb5433ebc6baa6 100644 (file)
@@ -85,7 +85,7 @@ class ModulesHolder implements TransactionHolder {
     public Map<ModuleIdentifier, Module> getAllModules() {
         Map<ModuleIdentifier, Module> result = new HashMap<>();
         for (ModuleInternalTransactionalInfo entry : commitMap.values()) {
-            ModuleIdentifier name = entry.getName();
+            ModuleIdentifier name = entry.getIdentifier();
             result.put(name, entry.getModule());
         }
         return result;
@@ -94,17 +94,17 @@ class ModulesHolder implements TransactionHolder {
     @Override
     public void put(
             ModuleInternalTransactionalInfo moduleInternalTransactionalInfo) {
-        commitMap.put(moduleInternalTransactionalInfo.getName(),
+        commitMap.put(moduleInternalTransactionalInfo.getIdentifier(),
                 moduleInternalTransactionalInfo);
     }
 
     @Override
     public ModuleInternalTransactionalInfo destroyModule(
             ModuleIdentifier moduleIdentifier) {
-        ModuleInternalTransactionalInfo found = commitMap
-                .remove(moduleIdentifier);
-        if (found == null)
+        ModuleInternalTransactionalInfo found = commitMap.remove(moduleIdentifier);
+        if (found == null) {
             throw new IllegalStateException("Not found:" + moduleIdentifier);
+        }
         if (found.hasOldModule()) {
             unorderedDestroyedFromPreviousTransactions.add(found);
         }
@@ -123,4 +123,13 @@ class ModulesHolder implements TransactionHolder {
     public Collection<ModuleInternalTransactionalInfo> getAllInfos(){
         return commitMap.values();
     }
+
+    @Override
+    public ModuleInternalTransactionalInfo findModuleInternalTransactionalInfo(ModuleIdentifier moduleIdentifier) {
+        ModuleInternalTransactionalInfo found = commitMap.get(moduleIdentifier);
+        if (found == null) {
+            throw new IllegalStateException("Not found:" + moduleIdentifier);
+        }
+        return found;
+    }
 }
index 8f05ed75ae74a64d4c45c42969ee32d235880395..bccd453af061080841349cf783c3e0ad40d39b21 100644 (file)
@@ -36,4 +36,6 @@ interface TransactionHolder {
     void assertNotExists(ModuleIdentifier moduleIdentifier)
             throws InstanceAlreadyExistsException;
 
+    ModuleInternalTransactionalInfo findModuleInternalTransactionalInfo(ModuleIdentifier moduleIdentifier);
+
 }
index 3d0decb93d3c98d5238de6bfc856906147141151..ec1a290cd204dedaf2c744dbcc97dc4cfcb36ce5 100644 (file)
@@ -44,7 +44,8 @@ public class BlankTransactionServiceTracker implements ServiceTrackerCustomizer<
         for (int i = 0; i < 10; i++) {
             try {
                 // create transaction
-                ObjectName tx = configRegistry.beginConfig();
+                boolean blankTransaction = true;
+                ObjectName tx = configRegistry.beginConfig(blankTransaction);
                 CommitStatus commitStatus = configRegistry.commitConfig(tx);
                 logger.debug("Committed blank transaction with status {}", commitStatus);
                 return;
index 3cb0f447b464d89efd32f69c84378d0de77a5671..22a959060cfaca6d598e8e84a41225352bd00eb1 100644 (file)
@@ -67,7 +67,7 @@ public class ConfigTransactionControllerImplTest extends
         testedTxController = new ConfigTransactionControllerImpl(
                 transactionName123, jmxRegistrator123, 1, 1,
                 currentlyRegisteredFactories, transactionsMBeanServer,
-                ManagementFactory.getPlatformMBeanServer(), null);
+                ManagementFactory.getPlatformMBeanServer(), false);
         TransactionModuleJMXRegistrator transactionModuleJMXRegistrator123 = testedTxController
                 .getTxModuleJMXRegistrator();
         transactionModuleJMXRegistrator123.registerMBean(
index a79cb83a3834230ff3b1bba45f3f70a234dff345..65b010532bfe342dd7db6b155ca8190d61e7b5b9 100644 (file)
@@ -86,7 +86,7 @@ public class DependencyResolverManagerTest {
     private static void mockGetInstance(DependencyResolverManager tested,
             ModuleIdentifier moduleIdentifier) {
         ModuleInternalTransactionalInfo mock = mock(ModuleInternalTransactionalInfo.class);
-        doReturn(moduleIdentifier).when(mock).getName();
+        doReturn(moduleIdentifier).when(mock).getIdentifier();
         doReturn(mockedModule()).when(mock).getModule();
         tested.put(mock);
     }
index 4cbe3976933afc070b3b0d81578bfe3f68e7033b..53b8b2b53ceab9ea205d964b3416249a31c9777b 100644 (file)
@@ -69,7 +69,7 @@
                   <Private-Package>
                      org.opendaylight.controller.config.threadpool.util,
                      javax.annotation.*,
-                     org.opendaylight.controller.config.yang.threadpool.impl,
+                     org.opendaylight.controller.config.yang.threadpool.impl*,
                   </Private-Package>
                   <Export-Package>
                       org.opendaylight.controller.config.threadpool.util,
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java
deleted file mode 100644 (file)
index 2803448..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Generated file
-
- * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-fixed
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 16:19:33 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.threadpool.impl;
-
-/**
-*
-*/
-public class FixedThreadPoolModuleFactory extends
-        org.opendaylight.controller.config.yang.threadpool.impl.AbstractFixedThreadPoolModuleFactory {
-
-}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java
deleted file mode 100644 (file)
index ef6ebd2..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Generated file
-
- * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-flexible
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 16:19:33 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.threadpool.impl;
-
-/**
-*
-*/
-public class FlexibleThreadPoolModuleFactory extends
-        org.opendaylight.controller.config.yang.threadpool.impl.AbstractFlexibleThreadPoolModuleFactory {
-
-}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java
deleted file mode 100644 (file)
index 42739b4..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Generated file
-
- * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-scheduled
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 16:19:33 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.threadpool.impl;
-
-import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper;
-
-/**
-*
-*/
-public final class ScheduledThreadPoolModule extends
-        org.opendaylight.controller.config.yang.threadpool.impl.AbstractScheduledThreadPoolModule {
-
-    public ScheduledThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public ScheduledThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-            ScheduledThreadPoolModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void validate() {
-        super.validate();
-        JmxAttributeValidationException.checkNotNull(getMaxThreadCount(), maxThreadCountJmxAttribute);
-        JmxAttributeValidationException.checkCondition(getMaxThreadCount() > 0, "must be greater than zero",
-                maxThreadCountJmxAttribute);
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        return new ScheduledThreadPoolWrapper(getMaxThreadCount(), getThreadFactoryDependency());
-    }
-}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java
deleted file mode 100644 (file)
index 489af82..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Generated file
-
- * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-scheduled
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 16:19:33 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.threadpool.impl;
-
-/**
-*
-*/
-public class ScheduledThreadPoolModuleFactory extends
-        org.opendaylight.controller.config.yang.threadpool.impl.AbstractScheduledThreadPoolModuleFactory {
-
-}
@@ -1,13 +1,13 @@
 /**
- * Generated file
+* Generated file
 
- * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-fixed
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 16:19:33 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.threadpool.impl;
+* Generated from: yang module name: threadpool-impl-fixed  yang module local name: threadpool-fixed
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Sun Dec 01 17:13:32 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.threadpool.impl.fixed;
 
 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
 import org.opendaylight.controller.config.threadpool.util.FixedThreadPoolWrapper;
@@ -15,22 +15,19 @@ import org.opendaylight.controller.config.threadpool.util.FixedThreadPoolWrapper
 /**
 *
 */
-public final class FixedThreadPoolModule extends
-        org.opendaylight.controller.config.yang.threadpool.impl.AbstractFixedThreadPoolModule {
+public final class FixedThreadPoolModule extends org.opendaylight.controller.config.yang.threadpool.impl.fixed.AbstractFixedThreadPoolModule
+{
 
-    public FixedThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    public FixedThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
-    public FixedThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-            FixedThreadPoolModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public FixedThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, FixedThreadPoolModule oldModule, java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
     @Override
-    public void validate() {
+    public void validate(){
         super.validate();
 
         JmxAttributeValidationException.checkNotNull(getMaxThreadCount(), maxThreadCountJmxAttribute);
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/fixed/FixedThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/fixed/FixedThreadPoolModuleFactory.java
new file mode 100644 (file)
index 0000000..1d3a37c
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+* Generated file
+
+* Generated from: yang module name: threadpool-impl-fixed  yang module local name: threadpool-fixed
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Sun Dec 01 17:13:32 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.threadpool.impl.fixed;
+
+/**
+*
+*/
+public class FixedThreadPoolModuleFactory extends org.opendaylight.controller.config.yang.threadpool.impl.fixed.AbstractFixedThreadPoolModuleFactory
+{
+
+
+}
@@ -1,13 +1,13 @@
 /**
- * Generated file
+* Generated file
 
- * Generated from: yang module name: threadpool-impl  yang module local name: threadpool-flexible
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 16:19:33 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.threadpool.impl;
+* Generated from: yang module name: threadpool-impl-flexible  yang module local name: threadpool-flexible
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Sun Dec 01 17:13:32 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.threadpool.impl.flexible;
 
 import java.util.concurrent.TimeUnit;
 
@@ -17,22 +17,19 @@ import org.opendaylight.controller.config.threadpool.util.FlexibleThreadPoolWrap
 /**
 *
 */
-public final class FlexibleThreadPoolModule extends
-        org.opendaylight.controller.config.yang.threadpool.impl.AbstractFlexibleThreadPoolModule {
+public final class FlexibleThreadPoolModule extends org.opendaylight.controller.config.yang.threadpool.impl.flexible.AbstractFlexibleThreadPoolModule
+{
 
-    public FlexibleThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    public FlexibleThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
-    public FlexibleThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-            FlexibleThreadPoolModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public FlexibleThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, FlexibleThreadPoolModule oldModule, java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
     @Override
-    public void validate() {
+    public void validate(){
         super.validate();
         JmxAttributeValidationException.checkNotNull(getKeepAliveMillis(), keepAliveMillisJmxAttribute);
         JmxAttributeValidationException.checkCondition(getKeepAliveMillis() > 0, "must be greater than zero",
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/flexible/FlexibleThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/flexible/FlexibleThreadPoolModuleFactory.java
new file mode 100644 (file)
index 0000000..878adcf
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+* Generated file
+
+* Generated from: yang module name: threadpool-impl-flexible  yang module local name: threadpool-flexible
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Sun Dec 01 17:13:32 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.threadpool.impl.flexible;
+
+/**
+*
+*/
+public class FlexibleThreadPoolModuleFactory extends org.opendaylight.controller.config.yang.threadpool.impl.flexible.AbstractFlexibleThreadPoolModuleFactory
+{
+
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModule.java
new file mode 100644 (file)
index 0000000..83c4ccc
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+* Generated file
+
+* Generated from: yang module name: threadpool-impl-scheduled  yang module local name: threadpool-scheduled
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Sun Dec 01 17:13:32 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.threadpool.impl.scheduled;
+
+import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper;
+
+/**
+*
+*/
+public final class ScheduledThreadPoolModule extends org.opendaylight.controller.config.yang.threadpool.impl.scheduled.AbstractScheduledThreadPoolModule
+{
+
+    public ScheduledThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public ScheduledThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, ScheduledThreadPoolModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate(){
+        super.validate();
+        JmxAttributeValidationException.checkNotNull(getMaxThreadCount(), maxThreadCountJmxAttribute);
+        JmxAttributeValidationException.checkCondition(getMaxThreadCount() > 0, "must be greater than zero",
+                maxThreadCountJmxAttribute);
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        return new ScheduledThreadPoolWrapper(getMaxThreadCount(), getThreadFactoryDependency());
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModuleFactory.java
new file mode 100644 (file)
index 0000000..ea345ba
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+* Generated file
+
+* Generated from: yang module name: threadpool-impl-scheduled  yang module local name: threadpool-scheduled
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Sun Dec 01 17:13:32 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.threadpool.impl.scheduled;
+
+/**
+*
+*/
+public class ScheduledThreadPoolModuleFactory extends org.opendaylight.controller.config.yang.threadpool.impl.scheduled.AbstractScheduledThreadPoolModuleFactory
+{
+
+
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-fixed.yang b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-fixed.yang
new file mode 100644 (file)
index 0000000..b09ce5b
--- /dev/null
@@ -0,0 +1,55 @@
+module threadpool-impl-fixed {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:fixed";
+    prefix "th-java-fixed";
+
+    import threadpool { prefix th; revision-date 2013-04-09; }
+    import config { prefix config; revision-date 2013-04-05; }
+    import rpc-context { prefix rpcx; revision-date 2013-06-17; }
+
+    organization "Cisco Systems, Inc.";
+
+    contact "Robert Varga <rovarga@cisco.com>";
+
+    description
+        "This module contains the base YANG definitions for
+         thread services pure Java implementation.
+
+        Copyright (c)2013 Cisco Systems, Inc. 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";
+
+    revision "2013-12-01" {
+        description
+            "Initial revision";
+    }
+
+
+    identity threadpool-fixed {
+        base config:module-type;
+        config:provided-service th:threadpool;
+        config:java-name-prefix FixedThreadPool;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case threadpool-fixed {
+            when "/config:modules/config:module/config:type = 'threadpool-fixed'";
+            leaf max-thread-count {
+                type uint16;
+            }
+
+            container threadFactory {
+                uses config:service-ref {
+                    refine type {
+                        //mandatory true;
+                        config:required-identity th:threadfactory;
+                    }
+                }
+            }
+        }
+    }
+}
+
diff --git a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-flexible.yang b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-flexible.yang
new file mode 100644 (file)
index 0000000..8d1a630
--- /dev/null
@@ -0,0 +1,59 @@
+module threadpool-impl-flexible {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible";
+    prefix "th-java-flexible";
+
+    import threadpool { prefix th; revision-date 2013-04-09; }
+    import config { prefix config; revision-date 2013-04-05; }
+    import rpc-context { prefix rpcx; revision-date 2013-06-17; }
+
+    organization "Cisco Systems, Inc.";
+
+    contact "Robert Varga <rovarga@cisco.com>";
+
+    description
+        "This module contains the base YANG definitions for
+         thread services pure Java implementation.
+
+        Copyright (c)2013 Cisco Systems, Inc. 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";
+
+    revision "2013-12-01" {
+        description
+            "Initial revision";
+    }
+
+    identity threadpool-flexible {
+        base config:module-type;
+        config:provided-service th:threadpool;
+        config:java-name-prefix FlexibleThreadPool;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case threadpool-flexible {
+            when "/config:modules/config:module/config:type = 'threadpool-flexible'";
+            leaf max-thread-count {
+                type uint16;
+            }
+            leaf minThreadCount {
+                type uint16;
+            }
+            leaf keepAliveMillis {
+                type uint32;
+            }
+
+            container threadFactory {
+                uses config:service-ref {
+                    refine type {
+                       // mandatory true;
+                        config:required-identity th:threadfactory;
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-scheduled.yang b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-scheduled.yang
new file mode 100644 (file)
index 0000000..07f6c5b
--- /dev/null
@@ -0,0 +1,53 @@
+module threadpool-impl-scheduled {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:scheduled";
+    prefix "th-java-scheduled";
+
+    import threadpool { prefix th; revision-date 2013-04-09; }
+    import config { prefix config; revision-date 2013-04-05; }
+    import rpc-context { prefix rpcx; revision-date 2013-06-17; }
+
+    organization "Cisco Systems, Inc.";
+
+    contact "Robert Varga <rovarga@cisco.com>";
+
+    description
+        "This module contains the base YANG definitions for
+         thread services pure Java implementation.
+
+        Copyright (c)2013 Cisco Systems, Inc. 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";
+
+    revision "2013-12-01" {
+        description
+            "Initial revision";
+    }
+
+    identity threadpool-scheduled {
+        base config:module-type;
+        config:provided-service th:scheduled-threadpool;
+        config:java-name-prefix ScheduledThreadPool;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case threadpool-scheduled {
+            when "/config:modules/config:module/config:type = 'threadpool-scheduled'";
+            leaf max-thread-count {
+                type uint16;
+            }
+
+            container threadFactory {
+                uses config:service-ref {
+                    refine type {
+                     //   mandatory true;
+                        config:required-identity th:threadfactory;
+                    }
+                }
+            }
+        }
+    }
+}
index a2366f285a0c0b8682b1093f18fb5ee184c9cde3..cc4af4d5969fec0fab92146b0732df31fa47b430 100644 (file)
@@ -1,4 +1,3 @@
-// vi: set smarttab et sw=4 tabstop=4:
 module threadpool-impl {
     yang-version 1;
     namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl";
@@ -17,11 +16,11 @@ module threadpool-impl {
          thread services pure Java implementation.
 
         Copyright (c)2013 Cisco Systems, Inc. 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";
+        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";
 
     revision "2013-04-05" {
         description
@@ -40,21 +39,21 @@ module threadpool-impl {
         config:java-name-prefix EventBus;
     }
 
-       augment "/config:modules/config:module/config:configuration" {
-               case eventbus {
-                       when "/config:modules/config:module/config:type = 'eventbus'";
-                       // No real configuration
+    augment "/config:modules/config:module/config:configuration" {
+        case eventbus {
+            when "/config:modules/config:module/config:type = 'eventbus'";
+            // No real configuration
         }
     }
 
-       augment "/config:modules/config:module/config:state" {
-               case eventbus {
-                       when "/config:modules/config:module/config:type = 'eventbus'";
-                       rpcx:rpc-context-instance "event-bus-rpc";
+    augment "/config:modules/config:module/config:state" {
+        case eventbus {
+            when "/config:modules/config:module/config:type = 'eventbus'";
+            rpcx:rpc-context-instance "event-bus-rpc";
         }
     }
 
-       identity event-bus-rpc;
+    identity event-bus-rpc;
 
     identity async-eventbus {
         base config:module-type;
@@ -62,134 +61,56 @@ module threadpool-impl {
         config:java-name-prefix AsyncEventBus;
     }
 
-       augment "/config:modules/config:module/config:configuration" {
-               case async-eventbus {
-                       when "/config:modules/config:module/config:type = 'async-eventbus'";
-                       container threadpool {
-                               uses config:service-ref {
-                                       refine type {
-                                               //mandatory true;
-                                               config:required-identity th:threadpool;
-                                       }
-                               }
-                       }
-               }
-       }
-
-       augment "/config:modules/config:module/config:state" {
-               case async-eventbus {
-                       when "/config:modules/config:module/config:type = 'async-eventbus'";
-                       rpcx:rpc-context-instance "event-bus-rpc";
+    augment "/config:modules/config:module/config:configuration" {
+        case async-eventbus {
+            when "/config:modules/config:module/config:type = 'async-eventbus'";
+            container threadpool {
+                uses config:service-ref {
+                    refine type {
+                        //mandatory true;
+                        config:required-identity th:threadpool;
+                    }
+                }
+            }
         }
     }
 
-       rpc get-dead-events-count {
-               config:java-name-prefix countDeadEvents;
-               input {
-                       uses rpcx:rpc-context-ref {
-                               refine context-instance {
-                                       rpcx:rpc-context-instance event-bus-rpc;
-                               }
-                       }
-               }
-               output {
-                       leaf result {
-                               type uint32;
-                       }
-               }
-       }
-       
-       identity threadfactory-naming {
-        base config:module-type;
-               config:provided-service th:threadfactory;
-        config:java-name-prefix NamingThreadFactory;
+    augment "/config:modules/config:module/config:state" {
+        case async-eventbus {
+            when "/config:modules/config:module/config:type = 'async-eventbus'";
+            rpcx:rpc-context-instance "event-bus-rpc";
+        }
     }
 
-       augment "/config:modules/config:module/config:configuration" {
-               case threadfactory-naming {
-                       when "/config:modules/config:module/config:type = 'threadfactory-naming'";
-                       leaf name-prefix {
-                               type string;
-                       }
+    rpc get-dead-events-count {
+        config:java-name-prefix countDeadEvents;
+        input {
+            uses rpcx:rpc-context-ref {
+                refine context-instance {
+                    rpcx:rpc-context-instance event-bus-rpc;
+                }
+            }
+        }
+        output {
+            leaf result {
+                type uint32;
+            }
         }
     }
 
-    identity threadpool-fixed {
-       base config:module-type;
-       config:provided-service th:threadpool;
-       config:java-name-prefix FixedThreadPool;
+    identity threadfactory-naming {
+        base config:module-type;
+        config:provided-service th:threadfactory;
+        config:java-name-prefix NamingThreadFactory;
     }
 
-       augment "/config:modules/config:module/config:configuration" {
-               case threadpool-fixed {
-                       when "/config:modules/config:module/config:type = 'threadpool-fixed'";
-                       leaf max-thread-count {
-                               type uint16;
-                       }
-
-                       container threadFactory {
-                               uses config:service-ref {
-                                       refine type {
-                                               //mandatory true;
-                                               config:required-identity th:threadfactory;
-                                       }
-                               }
-                       }
+    augment "/config:modules/config:module/config:configuration" {
+        case threadfactory-naming {
+            when "/config:modules/config:module/config:type = 'threadfactory-naming'";
+            leaf name-prefix {
+                type string;
+            }
         }
-       }
-
-       identity threadpool-flexible {
-               base config:module-type;
-               config:provided-service th:threadpool;
-               config:java-name-prefix FlexibleThreadPool;
-       }
-
-       augment "/config:modules/config:module/config:configuration" {
-               case threadpool-flexible {
-                       when "/config:modules/config:module/config:type = 'threadpool-flexible'";
-                       leaf max-thread-count {
-                               type uint16;
-                       }
-                       leaf minThreadCount {
-                               type uint16;
-                       }
-                       leaf keepAliveMillis {
-                               type uint32;
-                       }
-
-                       container threadFactory {
-                               uses config:service-ref {
-                                       refine type {
-                                          // mandatory true;
-                                               config:required-identity th:threadfactory;
-                                       }
-                               }
-                       }
-        }
-       }
-
-    identity threadpool-scheduled {
-               base config:module-type;
-               config:provided-service th:scheduled-threadpool;
-               config:java-name-prefix ScheduledThreadPool;
-       }
-
-       augment "/config:modules/config:module/config:configuration" {
-               case threadpool-scheduled {
-                       when "/config:modules/config:module/config:type = 'threadpool-scheduled'";
-                       leaf max-thread-count {
-                               type uint16;
-                       }
-
-                       container threadFactory {
-                               uses config:service-ref {
-                                       refine type {
-                                        //   mandatory true;
-                                               config:required-identity th:threadfactory;
-                                       }
-                               }
-                       }
-               }
-       }
+    }
 }
 
index 4fda06bf4c27cebb6a211c96f285124c847759f6..81455a9b21497c4cf1082cdf19542b5276facb92 100644 (file)
@@ -1,13 +1,5 @@
 package org.opendaylight.controller.config.threadpool.fixed;\r
 \r
-import static org.junit.Assert.assertThat;\r
-import static org.junit.Assert.fail;\r
-import static org.junit.matchers.JUnitMatchers.containsString;\r
-\r
-import javax.management.InstanceAlreadyExistsException;\r
-import javax.management.InstanceNotFoundException;\r
-import javax.management.ObjectName;\r
-\r
 import org.junit.Before;\r
 import org.junit.Test;\r
 import org.opendaylight.controller.config.api.ConflictingVersionException;\r
@@ -16,10 +8,18 @@ import org.opendaylight.controller.config.api.jmx.CommitStatus;
 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.FixedThreadPoolModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.FixedThreadPoolModuleMXBean;\r
 import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
 import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleMXBean;\r
+\r
+import javax.management.InstanceAlreadyExistsException;\r
+import javax.management.InstanceNotFoundException;\r
+import javax.management.ObjectName;\r
+\r
+import static org.junit.Assert.assertThat;\r
+import static org.junit.Assert.fail;\r
+import static org.junit.matchers.JUnitMatchers.containsString;\r
 \r
 public class FixedThreadPoolConfigBeanTest extends AbstractConfigTest {\r
 \r
index ee1de8f8ab633f7d277834a6761ed504aecaa446..5f1a3ee95723d737ce1ad2a7de2d1355fbf7cc45 100644 (file)
@@ -1,13 +1,5 @@
 package org.opendaylight.controller.config.threadpool.flexible;\r
 \r
-import static org.junit.Assert.assertThat;\r
-import static org.junit.Assert.fail;\r
-import static org.junit.matchers.JUnitMatchers.containsString;\r
-\r
-import javax.management.InstanceAlreadyExistsException;\r
-import javax.management.InstanceNotFoundException;\r
-import javax.management.ObjectName;\r
-\r
 import org.junit.Before;\r
 import org.junit.Test;\r
 import org.opendaylight.controller.config.api.ConflictingVersionException;\r
@@ -16,10 +8,18 @@ import org.opendaylight.controller.config.api.jmx.CommitStatus;
 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.FlexibleThreadPoolModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.FlexibleThreadPoolModuleMXBean;\r
 import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
 import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.flexible.FlexibleThreadPoolModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.flexible.FlexibleThreadPoolModuleMXBean;\r
+\r
+import javax.management.InstanceAlreadyExistsException;\r
+import javax.management.InstanceNotFoundException;\r
+import javax.management.ObjectName;\r
+\r
+import static org.junit.Assert.assertThat;\r
+import static org.junit.Assert.fail;\r
+import static org.junit.matchers.JUnitMatchers.containsString;\r
 \r
 public class FlexibleThreadPoolConfigBeanTest extends AbstractConfigTest {\r
 \r
index b4b1b60ffef8f6cabccf4c069f74edccb0dc5de6..1567896701f47e46b725fbc0af13d3c45388bc2c 100644 (file)
@@ -1,15 +1,5 @@
 package org.opendaylight.controller.config.threadpool.scheduled;\r
 \r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertThat;\r
-import static org.junit.Assert.assertTrue;\r
-import static org.junit.Assert.fail;\r
-import static org.junit.matchers.JUnitMatchers.containsString;\r
-\r
-import javax.management.InstanceAlreadyExistsException;\r
-import javax.management.InstanceNotFoundException;\r
-import javax.management.ObjectName;\r
-\r
 import org.junit.Before;\r
 import org.junit.Test;\r
 import org.opendaylight.controller.config.api.ConflictingVersionException;\r
@@ -20,8 +10,18 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
 import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
 import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.ScheduledThreadPoolModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.ScheduledThreadPoolModuleMXBean;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleFactory;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleMXBean;\r
+\r
+import javax.management.InstanceAlreadyExistsException;\r
+import javax.management.InstanceNotFoundException;\r
+import javax.management.ObjectName;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertThat;\r
+import static org.junit.Assert.assertTrue;\r
+import static org.junit.Assert.fail;\r
+import static org.junit.matchers.JUnitMatchers.containsString;\r
 \r
 public class ScheduledThreadPoolConfigBeanTest extends AbstractConfigTest {\r
 \r
index 27e60eef5cab734c64ba33622df00e2b230af020..d1464baa6e0ffb48d2aa7ebf84ac83b484846527 100644 (file)
@@ -1,27 +1,25 @@
 package org.opendaylight.controller.config.threadpool.scheduled;\r
 \r
-import static org.mockito.Matchers.any;\r
-import static org.mockito.Matchers.anyBoolean;\r
-import static org.mockito.Matchers.anyLong;\r
-import static org.mockito.Mockito.doNothing;\r
-import static org.mockito.Mockito.doReturn;\r
-import static org.mockito.Mockito.mock;\r
-\r
-import java.util.concurrent.ScheduledExecutorService;\r
-import java.util.concurrent.ScheduledFuture;\r
-import java.util.concurrent.TimeUnit;\r
-\r
-import javax.management.ObjectName;\r
-\r
+import com.google.common.util.concurrent.ListenableFutureTask;\r
 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
 import org.opendaylight.controller.config.api.ModuleIdentifier;\r
 import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;\r
 import org.opendaylight.controller.config.spi.Module;\r
 import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper;\r
 import org.opendaylight.controller.config.yang.threadpool.ScheduledThreadPoolServiceInterface;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.ScheduledThreadPoolModuleMXBean;\r
+import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleMXBean;\r
 \r
-import com.google.common.util.concurrent.ListenableFutureTask;\r
+import javax.management.ObjectName;\r
+import java.util.concurrent.ScheduledExecutorService;\r
+import java.util.concurrent.ScheduledFuture;\r
+import java.util.concurrent.TimeUnit;\r
+\r
+import static org.mockito.Matchers.any;\r
+import static org.mockito.Matchers.anyBoolean;\r
+import static org.mockito.Matchers.anyLong;\r
+import static org.mockito.Mockito.doNothing;\r
+import static org.mockito.Mockito.doReturn;\r
+import static org.mockito.Mockito.mock;\r
 \r
 public class TestingScheduledThreadPoolModule extends AbstractMockedModule implements\r
         ScheduledThreadPoolServiceInterface, Module, ScheduledThreadPoolModuleMXBean {\r
index b5bdb9e903d64e5a490b7f1e4f0530613d46e96c..b9b9c7337d8922e82b8f1f8927c40be8422d8d51 100644 (file)
@@ -28,6 +28,7 @@ netconf.config.persister.1.readonly=true
 
 netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
 netconf.config.persister.2.properties.fileStorage=configuration/current/controller.currentconfig.txt
+netconf.config.persister.2.properties.numberOfBackups=1
 
 
 yangstore.blacklist=.*controller.model.*
diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/00-netty.conf b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/00-netty.conf
new file mode 100644 (file)
index 0000000..ffee9c6
--- /dev/null
@@ -0,0 +1,48 @@
+//MODULES START
+       <module>
+               <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup">netty:netty-threadgroup-fixed</type>
+               <name>global-boss-group</name>
+       </module>
+       <module>
+               <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup">netty:netty-threadgroup-fixed</type>
+               <name>global-worker-group</name>
+       </module>
+       <module>
+               <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty:timer">netty:netty-hashed-wheel-timer</type>
+               <name>global-timer</name>
+       </module>
+       <module>
+               <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor">netty:netty-global-event-executor</type>
+               <name>global-event-executor</name>
+       </module>
+//SERVICES START
+       <service>
+               <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-threadgroup</type>
+               <instance>
+                       <name>global-boss-group</name>
+                       <provider>/config/modules/module[name='netty-threadgroup-fixed']/instance[name='global-boss-group']</provider>
+               </instance>
+               <instance>
+                       <name>global-worker-group</name>
+                       <provider>/config/modules/module[name='netty-threadgroup-fixed']/instance[name='global-worker-group']</provider>
+               </instance>
+       </service>
+       <service>
+               <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-event-executor</type>
+               <instance>
+                       <name>global-event-executor</name>
+                       <provider>/config/modules/module[name='netty-global-eventexecutor']/instance[name='global-event-executor']</provider>
+               </instance>
+       </service>
+       <service>
+               <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-timer</type>
+               <instance>
+                       <name>global-timer</name>
+                       <provider>/config/modules/module[name='netty-hashed-wheel-timer']/instance[name='global-timer']</provider>
+               </instance>
+       </service>
+//CAPABILITIES START
+urn:opendaylight:params:xml:ns:yang:controller:netty?module=netty&revision=2013-11-19
+urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12
+urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup?module=threadgroup&revision=2013-11-07
+urn:opendaylight:params:xml:ns:yang:controller:netty:timer?module=netty-timer&revision=2013-11-19
diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/controller-config.1.txt b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/controller-config.1.txt
deleted file mode 100644 (file)
index 689b45a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-//MODULES START
-//SERVICES START
-
-//CAPABILITIES START
-urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
index 79a11ce278cc057c33b72feadd9272ec74b066b1..172fb05292043e49612a8bee700750c6ca68810f 100644 (file)
@@ -59,7 +59,7 @@ public class CodecMapping {
         }
     }
 
-    public static void setAugmentationCodec(Class<? extends BindingCodec<Map<QName, Object>, Object>> dataCodec,
+    public static void setAugmentationCodec(Class<? extends BindingCodec<?,?>> dataCodec,
             BindingCodec<?,?> augmentableCodec) {
             Field instanceIdField;
             try {
index 0a8ea84cf60638f7290bc01ba1bfb4512d35c02c..0ac239d505b5995ce4061d158ace32aa6569a41f 100644 (file)
@@ -4,6 +4,7 @@ import java.util.Map;
 
 import org.opendaylight.yangtools.yang.binding.BindingCodec;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
 
 public interface GeneratorListener {
 
@@ -13,7 +14,9 @@ public interface GeneratorListener {
     
     void onCodecCreated(Class<?> codec);
     void onValueCodecCreated(Class<?> valueClass,Class<?> valueCodec);
-    void onChoiceCodecCreated(Class<?> choiceClass,Class<? extends BindingCodec<Map<QName, Object>,Object>> choiceCodec);
     void onCaseCodecCreated(Class<?> choiceClass,Class<? extends BindingCodec<Map<QName, Object>,Object>> choiceCodec);
-    public abstract void onDataContainerCodecCreated(Class<?> dataClass, Class<?  extends BindingCodec<Map<QName, Object>,Object>> dataCodec);
+    void onDataContainerCodecCreated(Class<?> dataClass, Class<?  extends BindingCodec<?,?>> dataCodec);
+
+    void onChoiceCodecCreated(Class<?> choiceClass,
+            Class<? extends BindingCodec<Map<QName, Object>, Object>> choiceCodec, ChoiceNode schema);
 }
index 270660980643cfa6e58a1bcc5fc7aeff856fc584..150d0f199f83f5615a9a5a8b7bda07347e6be309 100644 (file)
@@ -22,6 +22,10 @@ import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl
 import org.opendaylight.yangtools.yang.data.api.Node
 import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl
 import org.opendaylight.yangtools.yang.data.api.CompositeNode
+import org.opendaylight.yangtools.yang.binding.Augmentable
+import com.google.common.collect.ImmutableList
+import org.opendaylight.yangtools.yang.binding.Augmentation
+import java.util.concurrent.ConcurrentHashMap
 
 class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec {
     
@@ -29,7 +33,7 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec {
     val CodecRegistry codecRegistry;
     
     val Map<Class<?>,QName> classToQName = new WeakHashMap;
-    
+    val Map<Class<?>, Map<List<QName>, Class<?>>> classToPreviousAugment = new WeakHashMap;
     
     public new(CodecRegistry registry) {
         codecRegistry = registry;
@@ -44,8 +48,15 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec {
         for(biArg : biArgs) {
             scannedPath.add(biArg.nodeType);
             val baArg = deserializePathArgument(biArg,scannedPath)
-            baArgs.add(baArg)
             baType = baArg?.type
+            val injectAugment = classToPreviousAugment.get(baType);
+            if(injectAugment != null) {
+                val augment = injectAugment.get(scannedPath) as Class<? extends DataObject>;
+                if(augment != null) {
+                    baArgs.add(new Item(augment));
+                }
+            }
+            baArgs.add(baArg)
         }
         val ret = new InstanceIdentifier(baArgs,baType as Class<? extends DataObject>);
         return ret;
@@ -74,18 +85,41 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec {
     }
     
     override serialize(InstanceIdentifier input) {
+        var Class<?> previousAugmentation = null
         val pathArgs = input.path as List<org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument>
         var QName previousQName = null;
         val components = new ArrayList<PathArgument>(pathArgs.size);
+        val qnamePath = new ArrayList<QName>(pathArgs.size);
         for(baArg : pathArgs) { 
-            codecRegistry.bindingClassEncountered(baArg.type);
-            val biArg = serializePathArgument(baArg,previousQName);
-            previousQName = biArg.nodeType;
-            components.add(biArg);
+            
+            if(!Augmentation.isAssignableFrom(baArg.type)) {
+                
+                val biArg = serializePathArgument(baArg,previousQName);
+                previousQName = biArg.nodeType;
+                components.add(biArg);
+                qnamePath.add(biArg.nodeType);
+                val immutableList = ImmutableList.copyOf(qnamePath);
+                codecRegistry.putPathToClass(immutableList,baArg.type);
+                if(previousAugmentation !== null) {
+                    updateAugmentationInjection(baArg.type,immutableList,previousAugmentation)
+                }
+                
+                previousAugmentation = null;
+            } else {
+                previousQName = resolveQname(baArg.type);
+                previousAugmentation = baArg.type;
+            }
         }
         return new org.opendaylight.yangtools.yang.data.api.InstanceIdentifier(components);
     }
     
+    def updateAugmentationInjection(Class<? extends DataObject> class1, ImmutableList<QName> list, Class<?> augmentation) {
+        if(classToPreviousAugment.get(class1) == null) {
+            classToPreviousAugment.put(class1,new ConcurrentHashMap());
+        }
+        classToPreviousAugment.get(class1).put(list,augmentation);
+    }
+    
     private def dispatch PathArgument serializePathArgument(Item argument, QName previousQname) {
         val type = argument.type;
         val qname = resolveQname(type);
index 961cb2eb598bf7f8aaa0c45bbb9dbe2d5d303839..de6836489e6a6b970fb96a409e832876d02e82a7 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.controller.sal.binding.dom.serializer.api.DomCodec;
 import org.opendaylight.controller.sal.binding.dom.serializer.api.IdentifierCodec;
 import org.opendaylight.controller.sal.binding.dom.serializer.api.InstanceIdentifierCodec;
 import org.opendaylight.controller.sal.binding.dom.serializer.api.ValueWithQName;
+import org.opendaylight.controller.sal.binding.impl.util.ClassLoaderUtils;
 import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener;
 import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
 import org.opendaylight.yangtools.binding.generator.util.Types;
@@ -40,6 +41,8 @@ import org.opendaylight.yangtools.yang.binding.Identifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -48,6 +51,7 @@ import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -61,6 +65,8 @@ import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTy
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 
+import com.google.common.util.concurrent.CycleDetectingLockFactory.WithExplicitOrdering;
+
 public class LazyGeneratedCodecRegistry implements //
         CodecRegistry, //
         SchemaServiceListener, //
@@ -90,6 +96,7 @@ public class LazyGeneratedCodecRegistry implements //
     private CaseClassMapFacade classToCaseRawCodec = new CaseClassMapFacade();
 
     Map<SchemaPath, GeneratedTypeBuilder> pathToType = new ConcurrentHashMap<>();
+    Map<List<QName>, Type> pathToInstantiatedType = new ConcurrentHashMap<>();
 
     private SchemaContext currentSchema;
 
@@ -116,15 +123,27 @@ public class LazyGeneratedCodecRegistry implements //
     public Class<?> getClassForPath(List<QName> names) {
         DataSchemaNode node = getSchemaNode(names);
         SchemaPath path = node.getPath();
-        GeneratedTypeBuilder type = pathToType.get(path);
-        ReferencedTypeImpl typeref = new ReferencedTypeImpl(type.getPackageName(), type.getName());
+        Type type = pathToType.get(path);
+        if (type != null) {
+            type = new ReferencedTypeImpl(type.getPackageName(), type.getName());
+        } else {
+            type = pathToInstantiatedType.get(names);
+        }
         @SuppressWarnings("rawtypes")
-        WeakReference<Class> weakRef = typeToClass.get(typeref);
-        if(weakRef == null) {
-            LOG.error("Could not find loaded class for path: {} and type: {}",path,typeref.getFullyQualifiedName());
+        WeakReference<Class> weakRef = typeToClass.get(type);
+        if (weakRef == null) {
+            LOG.error("Could not find loaded class for path: {} and type: {}", path, type.getFullyQualifiedName());
         }
         return weakRef.get();
     }
+    
+    @Override
+    public void putPathToClass(List<QName> names,Class<?> cls) {
+        Type reference = Types.typeForClass(cls);
+        pathToInstantiatedType.put(names, reference );
+        bindingClassEncountered(cls);
+    }
+
 
     @Override
     public IdentifierCodec<?> getKeyCodecForPath(List<QName> names) {
@@ -150,27 +169,29 @@ public class LazyGeneratedCodecRegistry implements //
     @Override
     @SuppressWarnings("rawtypes")
     public void bindingClassEncountered(Class cls) {
-        
+
         ConcreteType typeRef = Types.typeForClass(cls);
-        if(typeToClass.containsKey(typeRef)) {
+        if (typeToClass.containsKey(typeRef)) {
             return;
         }
-        LOG.info("Binding Class {} encountered.",cls);
+        LOG.info("Binding Class {} encountered.", cls);
         WeakReference<Class> weakRef = new WeakReference<>(cls);
         typeToClass.put(typeRef, weakRef);
-        if(DataObject.class.isAssignableFrom(cls)) {
-            @SuppressWarnings({"unchecked","unused"})
+        if (Augmentation.class.isAssignableFrom(cls)) {
+
+        } else if (DataObject.class.isAssignableFrom(cls)) {
+            @SuppressWarnings({ "unchecked", "unused" })
             Object cdc = getCodecForDataObject((Class<? extends DataObject>) cls);
         }
     }
-    
+
     @Override
     public void onClassProcessed(Class<?> cls) {
         ConcreteType typeRef = Types.typeForClass(cls);
-        if(typeToClass.containsKey(typeRef)) {
+        if (typeToClass.containsKey(typeRef)) {
             return;
         }
-        LOG.info("Binding Class {} encountered.",cls);
+        LOG.info("Binding Class {} encountered.", cls);
         WeakReference<Class> weakRef = new WeakReference<>((Class) cls);
         typeToClass.put(typeRef, weakRef);
     }
@@ -294,7 +315,6 @@ public class LazyGeneratedCodecRegistry implements //
 
     public void onModuleContextAdded(SchemaContext schemaContext, Module module, ModuleContext context) {
         pathToType.putAll(context.getChildNodes());
-
         captureCases(context.getCases(), schemaContext);
     }
 
@@ -309,6 +329,7 @@ public class LazyGeneratedCodecRegistry implements //
                 continue;
             }
 
+            pathToType.put(caseNode.getKey(), caseNode.getValue());
             @SuppressWarnings("rawtypes")
             ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl(node);
             typeToCaseNodes.putIfAbsent(typeref, value);
@@ -323,7 +344,7 @@ public class LazyGeneratedCodecRegistry implements //
     @SuppressWarnings({ "unchecked", "rawtypes" })
     @Override
     public void onChoiceCodecCreated(Class<?> choiceClass,
-            Class<? extends BindingCodec<Map<QName, Object>, Object>> choiceCodec) {
+            Class<? extends BindingCodec<Map<QName, Object>, Object>> choiceCodec, ChoiceNode schema) {
         ChoiceCodec<?> oldCodec = choiceCodecs.get(choiceClass);
         checkState(oldCodec == null);
         BindingCodec<Map<QName, Object>, Object> delegate = newInstanceOf(choiceCodec);
@@ -331,6 +352,22 @@ public class LazyGeneratedCodecRegistry implements //
         choiceCodecs.put(choiceClass, newCodec);
         CodecMapping.setClassToCaseMap(choiceCodec, (Map<Class<?>, BindingCodec<?, ?>>) classToCaseRawCodec);
         CodecMapping.setCompositeNodeToCaseMap(choiceCodec, newCodec.getCompositeToCase());
+        
+        tryToCreateCasesCodecs(schema);
+
+    }
+
+    private void tryToCreateCasesCodecs(ChoiceNode schema) {
+        for(ChoiceCaseNode caseNode : schema.getCases()) {
+            SchemaPath path = caseNode.getPath();
+            GeneratedTypeBuilder type;
+            if(path != null && (type = pathToType.get(path)) != null) {
+                Class<?> caseClass = ClassLoaderUtils.tryToLoadClassWithTCCL(type.getFullyQualifiedName());
+                if(caseClass != null) {
+                    getCaseCodecFor(caseClass);
+                }
+            }
+        }
 
     }
 
@@ -345,7 +382,7 @@ public class LazyGeneratedCodecRegistry implements //
 
     @Override
     public void onDataContainerCodecCreated(Class<?> dataClass,
-            Class<? extends BindingCodec<Map<QName, Object>, Object>> dataCodec) {
+            Class<? extends BindingCodec<?,?>> dataCodec) {
         if (Augmentable.class.isAssignableFrom(dataClass)) {
             AugmentableCompositeCodec augmentableCodec = getAugmentableCodec(dataClass);
             CodecMapping.setAugmentationCodec(dataCodec, augmentableCodec);
@@ -478,7 +515,7 @@ public class LazyGeneratedCodecRegistry implements //
 
         @Override
         public boolean isAcceptable(Node<?> input) {
-            if (!(input instanceof CompositeNode)) {
+            if (input instanceof CompositeNode) {
                 if (augmenting) {
                     return checkAugmenting((CompositeNode) input);
                 } else {
@@ -492,7 +529,8 @@ public class LazyGeneratedCodecRegistry implements //
             QName parent = input.getNodeType();
             for (Node<?> childNode : input.getChildren()) {
                 QName child = childNode.getNodeType();
-                if (!Objects.equals(parent.getNamespace(), child.getNamespace()) || Objects.equals(parent.getRevision(), child.getRevision())) {
+                if (!Objects.equals(parent.getNamespace(), child.getNamespace())
+                        || !Objects.equals(parent.getRevision(), child.getRevision())) {
                     continue;
                 }
                 if (validNames.contains(child.getLocalName())) {
@@ -562,7 +600,7 @@ public class LazyGeneratedCodecRegistry implements //
         public BindingCodec get(Object key) {
             if (key instanceof Class) {
                 Class cls = (Class) key;
-                //bindingClassEncountered(cls);
+                // bindingClassEncountered(cls);
                 ChoiceCaseCodecImpl caseCodec = getCaseCodecFor(cls);
                 return caseCodec.getDelegate();
             }
@@ -592,8 +630,7 @@ public class LazyGeneratedCodecRegistry implements //
             }
             return null;
         }
-        
-        
+
     }
 
     /**
@@ -641,7 +678,7 @@ public class LazyGeneratedCodecRegistry implements //
         }
 
         @Override
-        public BindingCodec<Map<QName, Object>, Object> put(T key, BindingCodec<?,?> value) {
+        public BindingCodec<Map<QName, Object>, Object> put(T key, BindingCodec<?, ?> value) {
             throw notModifiable();
         }
 
@@ -705,9 +742,9 @@ public class LazyGeneratedCodecRegistry implements //
                 augmentationField.setAccessible(true);
                 Map<Class, Augmentation> augMap = (Map<Class, Augmentation>) augmentationField.get(input);
                 return augMap;
-            } catch (IllegalArgumentException | IllegalAccessException |NoSuchFieldException | SecurityException e) {
-                LOG.debug("Could not read augmentations for {}",input,e);
-            } 
+            } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
+                LOG.debug("Could not read augmentations for {}", input, e);
+            }
             return Collections.emptyMap();
         }
 
@@ -732,9 +769,9 @@ public class LazyGeneratedCodecRegistry implements //
                 rawAugmentationCodecs.put(key, ret);
                 return ret;
             } catch (InstantiationException e) {
-                LOG.error("Can not instantiate raw augmentation codec {}",key.getSimpleName(),e);
+                LOG.error("Can not instantiate raw augmentation codec {}", key.getSimpleName(), e);
             } catch (IllegalAccessException e) {
-                LOG.debug("BUG: Constructor for {} is not accessible.",key.getSimpleName(),e);
+                LOG.debug("BUG: Constructor for {} is not accessible.", key.getSimpleName(), e);
             }
             return null;
         }
index 0da7aec480e2c4f3d470cc9b02ad4c386f8f101f..7eb473ce3401a6774ed31f9690db658f24e4a576 100644 (file)
@@ -35,6 +35,8 @@ import java.util.Hashtable
 import org.osgi.framework.ServiceRegistration
 import org.opendaylight.controller.sal.binding.impl.connect.dom.DeserializationException
 import java.util.concurrent.Callable
+import org.opendaylight.yangtools.yang.binding.Augmentation
+import org.opendaylight.controller.sal.binding.impl.util.YangSchemaUtils
 
 class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingService, SchemaServiceListener, AutoCloseable {
 
@@ -83,8 +85,17 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
             updateBindingFor(context.cases, schemaContext);
 
             val typedefs = context.typedefs;
-            for (typedef : typedefs.values) {
-                binding.typeDefinitions.put(typedef, typedef as GeneratedType);
+            for (typedef : typedefs.entrySet) {
+                val typeRef = new ReferencedTypeImpl(typedef.value.packageName,typedef.value.name)
+                binding.typeDefinitions.put(typeRef, typedef.value as GeneratedType);
+                val schemaNode = YangSchemaUtils.findTypeDefinition(schemaContext,typedef.key);
+                if(schemaNode != null) {
+                    
+                    binding.typeToSchemaNode.put(typeRef,schemaNode);
+                } else {
+                    LOG.error("Type definition for {} is not available",typedef.value);
+                }
+                
             }
             val augmentations = context.augmentations;
             for (augmentation : augmentations) {
@@ -114,7 +125,14 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
         return ret as CompositeNode;
     }
 
-    private def waitForSchema(Class<? extends DataContainer> class1) {
+    private def void waitForSchema(Class<? extends DataContainer> class1) {
+        if(Augmentation.isAssignableFrom(class1)) {
+            /*  FIXME: We should wait also for augmentations. Currently YANGTools does not provide correct
+             *  mapping between java Augmentation classes and augmentations.
+             */
+            return;
+        }
+        
         val ref = Types.typeForClass(class1);
         getSchemaWithRetry(ref);
     }
@@ -161,9 +179,10 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
 
             //LOG.info("{} : {}",entry.key,entry.value.fullyQualifiedName)
             if (schemaNode != null) {
-                typeToSchemaNode.put(entry.value, schemaNode);
-                typeToDefinition.put(entry.value, entry.value);
-                updatePromisedSchemas(entry.value, schemaNode);
+                val typeRef = new ReferencedTypeImpl(entry.value.packageName,entry.value.name)
+                typeToSchemaNode.put(typeRef, schemaNode);
+                typeToDefinition.put(typeRef, entry.value);
+                updatePromisedSchemas(typeRef, schemaNode);
             }
         }
     }
@@ -213,6 +232,7 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
         if (typeDef !== null) {
             return typeDef;
         }
+        LOG.info("Thread blocked waiting for schema for: {}",type.fullyQualifiedName)
         return type.getSchemaInFuture.get();
     }
 
index ab2e96f05c09b0e79502547e9502ffc697dd8b2b..a732f152b25675612a21a3a6aad503c5971dbdaa 100644 (file)
@@ -46,6 +46,9 @@ import java.util.Iterator
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema
 import java.util.concurrent.ConcurrentHashMap
 import static extension org.opendaylight.controller.sal.binding.impl.util.YangSchemaUtils.*;
+import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl
+import org.opendaylight.yangtools.yang.model.util.ExtendedType
+import org.opendaylight.yangtools.yang.model.util.EnumerationType
 
 class TransformerGenerator {
 
@@ -221,6 +224,19 @@ class TransformerGenerator {
         ]
     }
 
+    private def Class<?> getValueSerializer(Enumeration type) {
+        val cls = loadClassWithTCCL(type.resolvedName);
+        val transformer = cls.generatedClass;
+        if (transformer !== null) {
+            return transformer;
+        }
+
+        return withClassLoaderAndLock(cls.classLoader, lock) [ |
+            val valueTransformer = generateValueTransformer(cls, type);
+            return valueTransformer;
+        ]
+    }
+
     private def generateKeyTransformerFor(Class<? extends Object> inputType, GeneratedType typeSpec, ListSchemaNode node) {
         try {
 
@@ -342,16 +358,18 @@ class TransformerGenerator {
                 method(Object, "deserialize", Object) [
                     body = '''
                         {
-                            
-                            return fromDomStatic(QNAME,$1);
+                            //System.out.println("«type.name»#deserialize: " +$1);
+                            java.util.Map.Entry _input = (java.util.Map.Entry) $1;
+                            return fromDomStatic((«QName.name»)_input.getKey(),_input.getValue());
                         }
                     '''
                 ]
             ]
 
-            val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)
+            val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)  as Class<? extends BindingCodec<Object, Object>>
+            listener?.onDataContainerCodecCreated(inputType,ret);
             log.info("DOM Codec for {} was generated {}", inputType, ret)
-            return ret as Class<? extends BindingCodec<Object, Object>>;
+            return ret;
         } catch (Exception e) {
             processException(inputType, e);
             return null;
@@ -548,7 +566,7 @@ class TransformerGenerator {
 
             val rawRet = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)
             val ret = rawRet as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-            listener?.onChoiceCodecCreated(inputType, ret);
+            listener?.onChoiceCodecCreated(inputType, ret, node);
             log.info("DOM Codec for {} was generated {}", inputType, ret)
             return ret;
         } catch (Exception e) {
@@ -759,6 +777,10 @@ class TransformerGenerator {
         («type.resolvedName») «type.valueSerializer.resolvedName».fromDomValue(«domParameter»)
     '''
 
+    private def dispatch String deserializeValue(Enumeration type, String domParameter) '''
+        («type.resolvedName») «type.valueSerializer.resolvedName».fromDomValue(«domParameter»)
+    '''
+
     private def dispatch Class<? extends BindingCodec<Map<QName, Object>, Object>> generateValueTransformer(
         Class<?> inputType, GeneratedTransferObject typeSpec) {
         try {
@@ -888,6 +910,9 @@ class TransformerGenerator {
 
     private def dispatch Class<?> generateValueTransformer(Class<?> inputType, Enumeration typeSpec) {
         try {
+            val typeRef = new ReferencedTypeImpl(typeSpec.packageName, typeSpec.name);
+            val schema = typeToSchemaNode.get(typeRef) as ExtendedType;
+            val enumSchema = schema.baseType as EnumerationType;
 
             //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
             val ctCls = createClass(typeSpec.codecClassName) [
@@ -895,12 +920,18 @@ class TransformerGenerator {
                 //implementsType(BINDING_CODEC)
                 method(Object, "toDomValue", Object) [
                     modifiers = PUBLIC + FINAL + STATIC
-                    body = '''
-                        if($1 == null) {
+                    body = '''{
+                            if($1 == null) {
+                                return null;
+                            }
+                            «typeSpec.resolvedName» _value = («typeSpec.resolvedName») $1;
+                            «FOR en : enumSchema.values»
+                            if(«typeSpec.resolvedName».«BindingGeneratorUtil.parseToClassName(en.name)».equals(_value)) {
+                                return "«en.name»";
+                            }
+                            «ENDFOR»
                             return null;
                         }
-                        «typeSpec.resolvedName» _value = («typeSpec.resolvedName») $1;
-                        return _value.getValue();
                     '''
                 ]
                 method(Object, "serialize", Object) [
@@ -911,12 +942,18 @@ class TransformerGenerator {
                 method(Object, "fromDomValue", Object) [
                     modifiers = PUBLIC + FINAL + STATIC
                     body = '''
-                        if($1 == null) {
+                        {
+                            if($1 == null) {
+                                return null;
+                            }
+                            String _value = (String) $1;
+                            «FOR en : enumSchema.values»
+                                if("«en.name»".equals(_value)) {
+                                    return «typeSpec.resolvedName».«BindingGeneratorUtil.parseToClassName(en.name)»;
+                                }
+                            «ENDFOR»
                             return null;
                         }
-                        _simpleValue = null;
-                        «typeSpec.resolvedName» _value = new «typeSpec.resolvedName»(null);
-                        return _value;
                     '''
                 ]
                 method(Object, "deserialize", Object) [
@@ -1126,6 +1163,8 @@ class TransformerGenerator {
     private def dispatch serializeValue(GeneratedTransferObject type, String parameter) '''«type.valueSerializer.
         resolvedName».toDomValue(«parameter»)'''
 
+    private def dispatch serializeValue(Enumeration type, String parameter) '''«type.valueSerializer.resolvedName».toDomValue(«parameter»)'''
+
     private def dispatch serializeValue(Type signature, String property) {
         if (INSTANCE_IDENTIFIER == signature) {
             return '''«INSTANCE_IDENTIFIER_CODEC».serialize(«property»)'''
index 02c59b2779ccd511975bd4fa8109b1e2700e6d0d..5db522f56c34b6c6816b067d96441034a01dfed1 100644 (file)
@@ -1,8 +1,9 @@
 package org.opendaylight.controller.sal.binding.impl;\r
 \r
+import java.util.Set;
 import java.util.concurrent.Future;\r
 import java.util.concurrent.atomic.AtomicLong;\r
-\r
+
 import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker;\r
 import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;\r
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;\r
@@ -99,5 +100,21 @@ public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier<? exte
     @Override\r
     public void close() throws Exception {\r
         \r
+    }
+    
+    
+    @Override
+    protected boolean isAffectedBy(InstanceIdentifier<? extends DataObject> key,
+            Set<InstanceIdentifier<? extends DataObject>> paths) {
+        if (paths.contains(key)) {
+            return true;
+        }
+        for (InstanceIdentifier<?> path : paths) {
+            if (key.containsWildcarded(path)) {
+                return true;
+            }
+        }
+
+        return false;
     }\r
 }
\ No newline at end of file
index 864c048a9133a71350d339ff3b62daae109bc44f..5f3189f7d2a196593ec2c903c1a2eb717c488ac5 100644 (file)
@@ -116,7 +116,7 @@ public class BindingIndependentDataServiceConnector implements //
                 DataObject baData = mappingService.dataObjectFromDataDom(baKey, entry.getValue());
                 target.putConfigurationData(baKey, baData);
             } catch (DeserializationException e) {
-                LOG.error("Ommiting from BA transaction: {}. Reason{}.", entry.getKey(), e);
+                LOG.error("Ommiting from BA transaction: {}. Reason {}.", entry.getKey(), e);
             }
         }
         for (Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> entry : source
@@ -127,7 +127,7 @@ public class BindingIndependentDataServiceConnector implements //
                 DataObject baData = mappingService.dataObjectFromDataDom(baKey, entry.getValue());
                 target.putOperationalData(baKey, baData);
             } catch (DeserializationException e) {
-                LOG.error("Ommiting from BA transaction: {}. Reason{}.", entry.getKey(), e);
+                LOG.error("Ommiting from BA transaction: {}. Reason {}.", entry.getKey(), e);
             }
         }
         for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry : source.getRemovedConfigurationData()) {
@@ -136,7 +136,7 @@ public class BindingIndependentDataServiceConnector implements //
                 InstanceIdentifier<?> baEntry = mappingService.fromDataDom(entry);
                 target.removeConfigurationData(baEntry);
             } catch (DeserializationException e) {
-                LOG.error("Ommiting from BA transaction: {}. Reason{}.", entry, e);
+                LOG.error("Ommiting from BA transaction: {}. Reason {}.", entry, e);
             }
         }
         for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry : source.getRemovedOperationalData()) {
@@ -312,7 +312,6 @@ public class BindingIndependentDataServiceConnector implements //
 
             org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = mappingService.toDataDom(registration
                     .getPath());
-            // FIXME: do registration based on only active commit handlers.
 
         }
 
index cb3206a3b30f8709fda36137ebd218edb8d4e06e..596329e07b1cdb23b2642d3f97e943aebcbf579a 100644 (file)
@@ -59,4 +59,13 @@ public final class ClassLoaderUtils {
 
         return Thread.currentThread().getContextClassLoader().loadClass(name);
     }
+
+    public static Class<?> tryToLoadClassWithTCCL(String fullyQualifiedName) {
+        try {
+            return loadClassWithTCCL(fullyQualifiedName);
+        } catch (ClassNotFoundException e) {
+            
+        }
+        return null;
+    }
 }
\ No newline at end of file
index b7a21cb022aa59011f6a66314d772e5e867fd911..1426089360ef2bd3c8e0530341e0b66cff8ee81f 100644 (file)
@@ -4,11 +4,16 @@ import java.util.List;
 
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 
 import com.google.common.base.Preconditions;
 
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
 public class YangSchemaUtils {
 
     public static final String AUGMENT_IDENTIFIER = "augment-identifier";
@@ -41,4 +46,25 @@ public class YangSchemaUtils {
         }
         return null;
     }
+
+
+    public static TypeDefinition<?> findTypeDefinition(SchemaContext context, SchemaPath path) {
+        List<QName> arguments = path.getPath();
+        QName first = arguments.get(0);
+        QName typeQName = arguments.get(arguments.size() -1);
+        DataNodeContainer previous = context.findModuleByNamespaceAndRevision(first.getNamespace(), first.getRevision());
+        if(previous == null) {
+            return null;
+        }
+        Preconditions.checkArgument(arguments.size() == 1);
+        for (QName qName : arguments) {
+            //previous.getDataChildByName(qName);
+        }
+        for(TypeDefinition<?> typedef : previous.getTypeDefinitions()) {
+            if(typedef.getQName().equals(typeQName)) {
+                return typedef;
+            }
+        }
+        return null;
+    }
 }
index 91163d80f2ff4f4db1dbfec370aa5a2cd801a737..d3ef2f3d6eaee93f728b724b0cb9fdd5b95a7b0a 100644 (file)
@@ -1,8 +1,9 @@
 package org.opendaylight.controller.sal.binding.test.bugfix;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 
-
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
@@ -11,6 +12,10 @@ import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SupportedActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SupportedActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.supported.actions.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.supported.actions.ActionTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
@@ -19,15 +24,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.SupportType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 
-
-
 import static org.junit.Assert.*;
 
 public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataChangeListener {
@@ -44,14 +50,34 @@ public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataCh
             .toInstance();
 
 
-    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(NODES_INSTANCE_ID_BA) //
+    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier//
+            .builder(NODES_INSTANCE_ID_BA) //
             .child(Node.class, NODE_KEY).toInstance();
+    
+    
+    private static final InstanceIdentifier<SupportedActions> SUPPORTED_ACTIONS_INSTANCE_ID_BA = InstanceIdentifier//
+            .builder(NODES_INSTANCE_ID_BA) //
+            .child(Node.class, NODE_KEY) //
+            .augmentation(FlowCapableNode.class) //
+            .child(SupportedActions.class)
+            .toInstance();
+    
 
     private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
     org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
             .node(Nodes.QNAME) //
             .nodeWithKey(Node.QNAME, NODE_KEY_BI) //
             .toInstance();
+    private static final QName SUPPORTED_ACTIONS_QNAME = QName.create(FlowCapableNode.QNAME, SupportedActions.QNAME.getLocalName());
+
+    
+    private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier SUPPORTED_ACTIONS_INSTANCE_ID_BI = //
+            org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
+                    .node(Nodes.QNAME) //
+                    .nodeWithKey(Node.QNAME, NODE_KEY_BI) //
+                    .node(SUPPORTED_ACTIONS_QNAME) //
+                    .toInstance();
+    
     private DataChangeEvent<InstanceIdentifier<?>, DataObject> receivedChangeEvent;
 
     
@@ -94,11 +120,31 @@ public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataCh
         Nodes nodes = checkForNodes();
         verifyNodes(nodes,original);
         
-        
-        
         testAddingNodeConnector();
         testNodeRemove();
+
+    }
+    
+    @Test
+    public void testAugmentNestedSerialization() throws Exception {
+        DataModificationTransaction transaction = baDataService.beginTransaction();
+        
+        SupportedActionsBuilder actions = new SupportedActionsBuilder();
+        ActionTypeBuilder action = new ActionTypeBuilder();
+        action.setAction("foo-action");
+        action.setSupportState(SupportType.Native);
+        List<ActionType> actionTypes = Collections.singletonList(action.build());
+        actions.setActionType(actionTypes );
         
+        transaction.putOperationalData(SUPPORTED_ACTIONS_INSTANCE_ID_BA, actions.build());
+        RpcResult<TransactionStatus> putResult = transaction.commit().get();
+        assertNotNull(putResult);
+        assertEquals(TransactionStatus.COMMITED, putResult.getResult());
+        SupportedActions readedTable = (SupportedActions) baDataService.readOperationalData(SUPPORTED_ACTIONS_INSTANCE_ID_BA);
+        assertNotNull(readedTable);
+        
+        CompositeNode biSupportedActions = biDataService.readOperationalData(SUPPORTED_ACTIONS_INSTANCE_ID_BI);
+        assertNotNull(biSupportedActions);
         
     }
 
@@ -121,10 +167,6 @@ public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataCh
         assertFalse(node.getNodeConnector().isEmpty());
         NodeConnector readedNc = node.getNodeConnector().get(0);
         assertNotNull(readedNc);
-        
-        
-        
-        
     }
 
     private void testNodeRemove() throws Exception {
index d83b1eaaf341931571ce723378f41145a3342154..b20577afd23fcdde6bb8f3ab50b3f7f73c0c0a6f 100644 (file)
@@ -229,7 +229,7 @@ public class ConfigPersisterNotificationHandler implements NotificationListener,
         // Socket should not be closed at this point
         // Activator unregisters this as JMX listener before close is called
 
-        logger.debug("Received notification {}", notification);
+        logger.info("Received notification {}", notification);
         if (notification instanceof CommitJMXNotification) {
             try {
                 handleAfterCommitNotification((CommitJMXNotification) notification);
@@ -246,7 +246,7 @@ public class ConfigPersisterNotificationHandler implements NotificationListener,
         try {
             persister.persistConfig(new CapabilityStrippingConfigSnapshotHolder(notification.getConfigSnapshot(),
                     notification.getCapabilities(), ignoredMissingCapabilityRegex));
-            logger.debug("Configuration persisted successfully");
+            logger.info("Configuration persisted successfully");
         } catch (IOException e) {
             throw new RuntimeException("Unable to persist configuration snapshot", e);
         }