*/
@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
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) {
RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator;
if (entry.hasOldModule() == false) {
runtimeBeanRegistrator = baseJMXRegistrator
- .createRuntimeBeanRegistrator(entry.getName());
+ .createRuntimeBeanRegistrator(entry.getIdentifier());
} else {
// reuse old JMX registrator
runtimeBeanRegistrator = entry.getOldInternalInfo()
.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
// 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
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())) {
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.");
}
}
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++;
/**
* 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
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
this.dependencyResolverManager = new DependencyResolverManager(transactionName, transactionStatus);
this.transactionsMBeanServer = transactionsMBeanServer;
this.configMBeanServer = configMBeanServer;
- this.bundleContext = bundleContext;
+ this.blankTransaction = blankTransaction;
}
@Override
// 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);
}
"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
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);
.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);
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();
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(
this.name = name;
this.moduleJMXRegistrator = moduleJMXRegistrator;
this.orderingIdx = orderingIdx;
+ this.isDefaultBean = isDefaultBean;
}
public DynamicReadableWrapper getReadableModule() {
public ModuleIdentifier getIdentifier() {
return name;
}
+
+ public boolean isDefaultBean() {
+ return isDefaultBean;
+ }
}
@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;
}
public ModuleIdentifier getIdentifier() {
return name;
}
+
+ public boolean isDefaultBean() {
+ return isDefaultBean;
+ }
}
jmxAttributeForReporting);
}
+ @Override
+ public ModuleInternalTransactionalInfo findModuleInternalTransactionalInfo(ModuleIdentifier moduleIdentifier) {
+ return modulesHolder.findModuleInternalTransactionalInfo(moduleIdentifier);
+ }
+
@Override
public ModuleFactory findModuleFactory(ModuleIdentifier moduleIdentifier,
JmxAttribute jmxAttributeForReporting) {
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;
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;
@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);
}
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;
+ }
}
void assertNotExists(ModuleIdentifier moduleIdentifier)
throws InstanceAlreadyExistsException;
+ ModuleInternalTransactionalInfo findModuleInternalTransactionalInfo(ModuleIdentifier moduleIdentifier);
+
}
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;
testedTxController = new ConfigTransactionControllerImpl(
transactionName123, jmxRegistrator123, 1, 1,
currentlyRegisteredFactories, transactionsMBeanServer,
- ManagementFactory.getPlatformMBeanServer(), null);
+ ManagementFactory.getPlatformMBeanServer(), false);
TransactionModuleJMXRegistrator transactionModuleJMXRegistrator123 = testedTxController
.getTxModuleJMXRegistrator();
transactionModuleJMXRegistrator123.registerMBean(
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);
}
<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,
+++ /dev/null
-/**
- * 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 {
-
-}
+++ /dev/null
-/**
- * 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 {
-
-}
+++ /dev/null
-/**
- * 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());
- }
-}
+++ /dev/null
-/**
- * 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 {
-
-}
/**
- * 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;
/**
*
*/
-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);
--- /dev/null
+/**
+* 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
+{
+
+
+}
/**
- * 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;
/**
*
*/
-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",
--- /dev/null
+/**
+* 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
+{
+
+
+}
--- /dev/null
+/**
+* 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());
+ }
+}
--- /dev/null
+/**
+* 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
+{
+
+
+}
--- /dev/null
+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;
+ }
+ }
+ }
+ }
+ }
+}
+
--- /dev/null
+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;
+ }
+ }
+ }
+ }
+ }
+}
--- /dev/null
+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;
+ }
+ }
+ }
+ }
+ }
+}
-// vi: set smarttab et sw=4 tabstop=4:
module threadpool-impl {
yang-version 1;
namespace "urn:opendaylight:params:xml:ns:yang:controller: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
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;
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;
- }
- }
- }
- }
- }
+ }
}
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
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
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
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
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
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
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
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.*
--- /dev/null
+//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
+++ /dev/null
-//MODULES START
-//SERVICES START
-
-//CAPABILITIES START
-urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
void bindingClassEncountered(Class<?> cls);
+
+ void putPathToClass(List<QName> names, Class<?> cls);
}
}
}
- 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 {
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 {
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);
}
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 {
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;
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;
}
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);
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;
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;
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;
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, //
private CaseClassMapFacade classToCaseRawCodec = new CaseClassMapFacade();
Map<SchemaPath, GeneratedTypeBuilder> pathToType = new ConcurrentHashMap<>();
+ Map<List<QName>, Type> pathToInstantiatedType = new ConcurrentHashMap<>();
private SchemaContext currentSchema;
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) {
@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);
}
public void onModuleContextAdded(SchemaContext schemaContext, Module module, ModuleContext context) {
pathToType.putAll(context.getChildNodes());
-
captureCases(context.getCases(), schemaContext);
}
continue;
}
+ pathToType.put(caseNode.getKey(), caseNode.getValue());
@SuppressWarnings("rawtypes")
ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl(node);
typeToCaseNodes.putIfAbsent(typeref, value);
@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);
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);
+ }
+ }
+ }
}
@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);
@Override
public boolean isAcceptable(Node<?> input) {
- if (!(input instanceof CompositeNode)) {
+ if (input instanceof CompositeNode) {
if (augmenting) {
return checkAugmenting((CompositeNode) input);
} else {
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())) {
public BindingCodec get(Object key) {
if (key instanceof Class) {
Class cls = (Class) key;
- //bindingClassEncountered(cls);
+ // bindingClassEncountered(cls);
ChoiceCaseCodecImpl caseCodec = getCaseCodecFor(cls);
return caseCodec.getDelegate();
}
}
return null;
}
-
-
+
}
/**
}
@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();
}
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();
}
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;
}
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 {
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) {
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);
}
//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);
}
}
}
if (typeDef !== null) {
return typeDef;
}
+ LOG.info("Thread blocked waiting for schema for: {}",type.fullyQualifiedName)
return type.getSchemaInFuture.get();
}
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 {
]
}
+ 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 {
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;
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) {
(«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 {
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) [
//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) [
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) [
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»)'''
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
@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
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
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()) {
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()) {
org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = mappingService.toDataDom(registration
.getPath());
- // FIXME: do registration based on only active commit handlers.
}
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
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";
}
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;
+ }
}
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;
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;
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 {
.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;
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);
}
assertFalse(node.getNodeConnector().isEmpty());
NodeConnector readedNc = node.getNodeConnector().get(0);
assertNotNull(readedNc);
-
-
-
-
}
private void testNodeRemove() throws Exception {
// 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);
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);
}