<groupId>org.opendaylight.yangtools</groupId>
<artifactId>mockito-configuration</artifactId>
</dependency>
+
+ <!--Dependencies regardign RuntimeGeneratedMappingService-->
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>binding-generator-impl</artifactId>
+ </dependency>
+ <!--End-->
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>config-util</artifactId>
this.service = service;
CodecRegistry codecRegistry = service.getCodecRegistry();
logger.debug("Codec registry acquired {}", codecRegistry);
- activator.initConfigManager(ctx, codecRegistry);
+// activator.initConfigManager(ctx, codecRegistry);
return service;
}
package org.opendaylight.controller.config.manager.impl.osgi;
import java.lang.management.ManagementFactory;
+import java.util.Collection;
import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanServer;
import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl;
import org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator;
+import org.opendaylight.controller.config.manager.impl.osgi.mapping.ModuleInfoBundleTracker;
+import org.opendaylight.controller.config.manager.impl.osgi.mapping.RuntimeGeneratedMappingServiceActivator;
import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.slf4j.LoggerFactory;
public class ConfigManagerActivator implements BundleActivator {
- private static final Logger logger = LoggerFactory
- .getLogger(ConfigManagerActivator.class);
+ private static final Logger logger = LoggerFactory.getLogger(ConfigManagerActivator.class);
- private ExtenderBundleTracker extenderBundleTracker;
+ private ExtensibleBundleTracker<Collection<Registration<YangModuleInfo>>> bundleTracker;
private ConfigRegistryImpl configRegistry;
private ConfigRegistryJMXRegistrator configRegistryJMXRegistrator;
private ServiceRegistration configRegistryServiceRegistration;
- private ServiceTracker<BindingIndependentMappingService, BindingIndependentMappingService> tracker;
+ private final MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer();
+
+ private RuntimeGeneratedMappingServiceActivator mappingServiceActivator;
@Override
public void start(BundleContext context) throws Exception {
- BindingIndependentMappingServiceTracker mappingServiceTracker = new BindingIndependentMappingServiceTracker(
- context, this);
- tracker = new ServiceTracker<BindingIndependentMappingService, BindingIndependentMappingService>(
- context, BindingIndependentMappingService.class, mappingServiceTracker);
-
- logger.debug("Waiting for codec registry");
-
- tracker.open();
- }
- void initConfigManager(BundleContext context, CodecRegistry codecRegistry) {
- BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver =
- new BundleContextBackedModuleFactoriesResolver(context);
- MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer();
+ // track bundles containing YangModuleInfo
+ ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker();
+ mappingServiceActivator = new RuntimeGeneratedMappingServiceActivator(moduleInfoBundleTracker);
+ CodecRegistry codecRegistry = mappingServiceActivator.startRuntimeMappingService(context).getCodecRegistry();
+ // start config registry
+ BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver(
+ context);
+ configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, configMBeanServer,
+ codecRegistry);
- // TODO push codecRegistry/IdentityCodec to dependencyResolver
+ // track bundles containing factories
+ BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker(
+ configRegistry);
+ ModuleFactoryBundleTracker moduleFactoryBundleTracker = new ModuleFactoryBundleTracker(
+ blankTransactionServiceTracker);
- configRegistry = new ConfigRegistryImpl(
- bundleContextBackedModuleFactoriesResolver, configMBeanServer, codecRegistry);
+ // start extensible tracker
+ bundleTracker = new ExtensibleBundleTracker<>(context, moduleInfoBundleTracker, moduleFactoryBundleTracker);
+ bundleTracker.open();
// register config registry to OSGi
configRegistryServiceRegistration = context.registerService(ConfigRegistryImpl.class, configRegistry, null);
throw new RuntimeException("Config Registry was already registered to JMX", e);
}
- // track bundles containing factories
- BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker(configRegistry);
- extenderBundleTracker = new ExtenderBundleTracker(context, blankTransactionServiceTracker);
- extenderBundleTracker.open();
-
- ServiceTracker<?, ?> serviceTracker = new ServiceTracker(context, ModuleFactory.class, blankTransactionServiceTracker);
+ ServiceTracker<ModuleFactory, Object> serviceTracker = new ServiceTracker<>(context, ModuleFactory.class,
+ blankTransactionServiceTracker);
serviceTracker.open();
}
@Override
public void stop(BundleContext context) throws Exception {
- try {
- tracker.close();
- } catch (Exception e) {
- logger.warn("Exception while closing tracker", e);
- }
try {
configRegistry.close();
} catch (Exception e) {
logger.warn("Exception while closing config registry", e);
}
try {
- extenderBundleTracker.close();
+ bundleTracker.close();
} catch (Exception e) {
logger.warn("Exception while closing extender", e);
}
} catch (Exception e) {
logger.warn("Exception while unregistering config registry", e);
}
+ try {
+ mappingServiceActivator.close();
+ } catch (Exception e) {
+ logger.warn("Exception while closing mapping service", e);
+ }
}
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.manager.impl.osgi;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * Extensible bundle tracker. Takes several BundleTrackerCustomizers and propagates bundle events to all of them.
+ * Primary customizer
+ *
+ * @param <T>
+ */
+public final class ExtensibleBundleTracker<T> extends BundleTracker<T> {
+
+ private final BundleTrackerCustomizer<T> primaryTracker;
+ private final BundleTrackerCustomizer<?>[] additionalTrackers;
+
+ private static final Logger logger = LoggerFactory.getLogger(ExtensibleBundleTracker.class);
+
+ public ExtensibleBundleTracker(BundleContext context, BundleTrackerCustomizer<T> primaryBundleTrackerCustomizer,
+ BundleTrackerCustomizer<?>... additionalBundleTrackerCustomizers) {
+ this(context, Bundle.ACTIVE, primaryBundleTrackerCustomizer, additionalBundleTrackerCustomizers);
+ }
+
+ public ExtensibleBundleTracker(BundleContext context, int bundleState,
+ BundleTrackerCustomizer<T> primaryBundleTrackerCustomizer,
+ BundleTrackerCustomizer<?>... additionalBundleTrackerCustomizers) {
+ super(context, bundleState, null);
+ this.primaryTracker = primaryBundleTrackerCustomizer;
+ this.additionalTrackers = additionalBundleTrackerCustomizers;
+ logger.trace("Registered as extender with context {} and bundle state {}", context, bundleState);
+ }
+
+ @Override
+ public T addingBundle(final Bundle bundle, final BundleEvent event) {
+ T primaryTrackerRetVal = primaryTracker.addingBundle(bundle, event);
+
+ forEachAdditionalBundle(new BundleStrategy() {
+ @Override
+ public void execute(BundleTrackerCustomizer<?> tracker) {
+ tracker.addingBundle(bundle, event);
+ }
+ });
+
+ return primaryTrackerRetVal;
+ }
+
+ @Override
+ public void modifiedBundle(final Bundle bundle, final BundleEvent event, final T object) {
+ primaryTracker.modifiedBundle(bundle, event, object);
+
+ forEachAdditionalBundle(new BundleStrategy() {
+ @Override
+ public void execute(BundleTrackerCustomizer<?> tracker) {
+ tracker.modifiedBundle(bundle, event, null);
+ }
+ });
+
+ }
+
+ @Override
+ public void removedBundle(final Bundle bundle, final BundleEvent event, final T object) {
+ primaryTracker.removedBundle(bundle, event, object);
+
+ forEachAdditionalBundle(new BundleStrategy() {
+ @Override
+ public void execute(BundleTrackerCustomizer<?> tracker) {
+ tracker.removedBundle(bundle, event, null);
+ }
+ });
+ }
+
+ private void forEachAdditionalBundle(BundleStrategy lambda) {
+ for (BundleTrackerCustomizer<?> trac : additionalTrackers) {
+ lambda.execute(trac);
+ }
+ }
+
+ private static interface BundleStrategy {
+ void execute(BundleTrackerCustomizer<?> tracker);
+ }
+
+}
import org.apache.commons.io.IOUtils;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* the services are unregistered automatically.
* Code based on http://www.toedter.com/blog/?p=236
*/
-public class ExtenderBundleTracker extends BundleTracker<Object> {
+public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer<Object> {
private final BlankTransactionServiceTracker blankTransactionServiceTracker;
- private static final Logger logger = LoggerFactory.getLogger(ExtenderBundleTracker.class);
+ private static final Logger logger = LoggerFactory.getLogger(ModuleFactoryBundleTracker.class);
- public ExtenderBundleTracker(BundleContext context, BlankTransactionServiceTracker blankTransactionServiceTracker) {
- super(context, Bundle.ACTIVE, null);
+ public ModuleFactoryBundleTracker(BlankTransactionServiceTracker blankTransactionServiceTracker) {
this.blankTransactionServiceTracker = blankTransactionServiceTracker;
- logger.trace("Registered as extender with context {}", context);
}
@Override
return bundle;
}
+ @Override
+ public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
+ // NOOP
+ }
+
@Override
public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
- super.removedBundle(bundle,event,object);
// workaround for service tracker not getting removed service event
blankTransactionServiceTracker.blankTransaction();
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.manager.impl.osgi.mapping;
+
+import org.apache.commons.io.IOUtils;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import static java.lang.String.format;
+
+/**
+ * Tracks bundles and attempts to retrieve YangModuleInfo.
+ */
+public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Collection<Registration<YangModuleInfo>>> {
+
+ private static final Logger logger = LoggerFactory.getLogger(ModuleInfoBundleTracker.class);
+ public static final String GET_MODULE_INFO_METHOD = "getModuleInfo";
+
+ public static final String MODULE_INFO_PROVIDER_PATH_PREFIX = "META-INF/services/";
+
+ private ModuleInfoBackedContext moduleInfoLoadingStrategy = ModuleInfoBackedContext.create();
+
+ public GeneratedClassLoadingStrategy getModuleInfoLoadingStrategy() {
+ return moduleInfoLoadingStrategy;
+ }
+
+ @Override
+ public Collection<Registration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
+ URL resource = bundle.getEntry(MODULE_INFO_PROVIDER_PATH_PREFIX + YangModelBindingProvider.class.getName());
+
+ if(resource==null) {
+ return null;
+ }
+
+ List<Registration<YangModuleInfo>> registrations = new LinkedList<>();
+
+ try (InputStream inputStream = resource.openStream()) {
+ List<String> lines = IOUtils.readLines(inputStream);
+ for (String moduleInfoName : lines) {
+ YangModuleInfo moduleInfo = retrieveModuleInfo(moduleInfoName, bundle);
+ registrations.add(moduleInfoLoadingStrategy.registerModuleInfo(moduleInfo));
+ }
+
+
+ } catch (Exception e) {
+ logger.error("Error while reading {}", resource, e);
+ throw new RuntimeException(e);
+ }
+
+ return registrations;
+ }
+
+ @Override
+ public void modifiedBundle(Bundle bundle, BundleEvent event, Collection<Registration<YangModuleInfo>> object) {
+ // NOOP
+ }
+
+ @Override
+ public void removedBundle(Bundle bundle, BundleEvent event, Collection<Registration<YangModuleInfo>> regs) {
+ if(regs == null) {
+ return;
+ }
+
+ for (Registration<YangModuleInfo> reg : regs) {
+ try {
+ reg.close();
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to unregister YangModuleInfo " + reg.getInstance(), e);
+ }
+ }
+ }
+
+ private static YangModuleInfo retrieveModuleInfo(String moduleInfoClass, Bundle bundle) {
+ String errorMessage;
+ Class<?> clazz = loadClass(moduleInfoClass, bundle);
+
+ if (YangModelBindingProvider.class.isAssignableFrom(clazz) == false) {
+ errorMessage = logMessage("Class {} does not implement {} in bundle {}", clazz, YangModelBindingProvider.class, bundle);
+ throw new IllegalStateException(errorMessage);
+ }
+
+ try {
+ Object instance = clazz.newInstance();
+ Object result = clazz.getMethod(GET_MODULE_INFO_METHOD).invoke(instance);
+
+ if (YangModuleInfo.class.isAssignableFrom(result.getClass()) == false) {
+ errorMessage = logMessage("Error invoking method not found {} in bundle {}, reason {}",
+ GET_MODULE_INFO_METHOD, bundle, "Not assignable from " + YangModuleInfo.class);
+ } else {
+ return (YangModuleInfo) result;
+ }
+
+ } catch (InstantiationException e) {
+ errorMessage = logMessage("Could not instantiate {} in bundle {}, reason {}", moduleInfoClass, bundle, e);
+ } catch (IllegalAccessException e) {
+ errorMessage = logMessage("Illegal access during instatiation of class {} in bundle {}, reason {}",
+ moduleInfoClass, bundle, e);
+ } catch (NoSuchMethodException e) {
+ errorMessage = logMessage("Method not found {} in bundle {}, reason {}", GET_MODULE_INFO_METHOD, bundle, e);
+ } catch (InvocationTargetException e) {
+ errorMessage = logMessage("Error invoking method {} in bundle {}, reason {}", GET_MODULE_INFO_METHOD,
+ bundle, e);
+ }
+
+ throw new IllegalStateException(errorMessage);
+ }
+
+ private static Class<?> loadClass(String moduleInfoClass, Bundle bundle) {
+ try {
+ return bundle.loadClass(moduleInfoClass);
+ } catch (ClassNotFoundException e) {
+ String errorMessage = logMessage("Could not find class {} in bunde {}, reason {}", moduleInfoClass, bundle, e);
+ throw new IllegalStateException(errorMessage);
+ }
+ }
+
+ public static String logMessage(String slfMessage, Object... params) {
+ logger.info(slfMessage, params);
+ String formatMessage = slfMessage.replaceAll("\\{\\}", "%s");
+ return format(formatMessage, params);
+ }
+}
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.sal.binding.osgi;
+package org.opendaylight.controller.config.manager.impl.osgi.mapping;
-import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
+import javassist.ClassPool;
import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
-import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import java.util.Hashtable;
-public class Activator implements BundleActivator {
+public class RuntimeGeneratedMappingServiceActivator implements AutoCloseable {
+
+ private static final ClassPool CLASS_POOL = ClassPool.getDefault();
- private ServiceRegistration<?> reg;
private ServiceRegistration<SchemaServiceListener> listenerReg;
private ServiceRegistration<BindingIndependentMappingService> mappingReg;
+ private ModuleInfoBundleTracker moduleInfoBundleTracker;
- @Override
- public void start(BundleContext context) throws Exception {
- RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl();
- service.setPool(SingletonHolder.CLASS_POOL);
+ public RuntimeGeneratedMappingServiceActivator(ModuleInfoBundleTracker moduleInfoBundleTracker) {
+ this.moduleInfoBundleTracker = moduleInfoBundleTracker;
+ }
+
+ public RuntimeGeneratedMappingServiceImpl startRuntimeMappingService(BundleContext context) {
+ RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl(moduleInfoBundleTracker.getModuleInfoLoadingStrategy());
+ service.setPool(CLASS_POOL);
service.init();
startRuntimeMappingService(service, context);
+ return service;
}
private void startRuntimeMappingService(RuntimeGeneratedMappingServiceImpl service, BundleContext context) {
Hashtable<String, String> properties = new Hashtable<String, String>();
listenerReg = context.registerService(SchemaServiceListener.class, service, properties);
mappingReg = context.registerService(BindingIndependentMappingService.class, service, properties);
-
+
}
@Override
- public void stop(BundleContext context) throws Exception {
- if(listenerReg != null) {
- listenerReg.unregister();
- }
- if(mappingReg != null) {
- mappingReg.unregister();
- }
+ public void close() throws Exception {
+ mappingReg.unregister();
+ listenerReg.unregister();
}
}
*/
package org.opendaylight.controller.config.yang.netty.eventexecutor;
-import io.netty.util.concurrent.AbstractEventExecutor;
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
import io.netty.util.concurrent.EventExecutor;
-import io.netty.util.concurrent.EventExecutorGroup;
-import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GlobalEventExecutor;
-import io.netty.util.concurrent.ScheduledFuture;
-import java.util.concurrent.Callable;
+import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;
-/**
-*
-*/
public final class GlobalEventExecutorModule extends
org.opendaylight.controller.config.yang.netty.eventexecutor.AbstractGlobalEventExecutorModule {
@Override
public java.lang.AutoCloseable createInstance() {
- return new GlobalEventExecutorCloseable(GlobalEventExecutor.INSTANCE);
+ final CloseableGlobalEventExecutorMixin closeableGlobalEventExecutorMixin =
+ new CloseableGlobalEventExecutorMixin(GlobalEventExecutor.INSTANCE);
+ return Reflection.newProxy(AutoCloseableEventExecutor.class, new AbstractInvocationHandler() {
+ @Override
+ protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
+ if (method.getName().equals("close")) {
+ closeableGlobalEventExecutorMixin.close();
+ return null;
+ } else {
+ return method.invoke(GlobalEventExecutor.INSTANCE, args);
+ }
+ }
+ });
}
- static final private class GlobalEventExecutorCloseable extends AbstractEventExecutor implements AutoCloseable {
-
- private EventExecutor executor;
-
- public GlobalEventExecutorCloseable(EventExecutor executor) {
- this.executor = executor;
- }
-
- @Override
- public EventExecutorGroup parent() {
- return this.executor.parent();
- }
-
- @Override
- public boolean inEventLoop(Thread thread) {
- return this.executor.inEventLoop(thread);
- }
-
- @Override
- public boolean isShuttingDown() {
- return this.executor.isShuttingDown();
- }
-
- @Override
- public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) {
- return this.executor.shutdownGracefully(quietPeriod, timeout, unit);
- }
-
- @Override
- public Future<?> terminationFuture() {
- return this.executor.terminationFuture();
- }
-
- @Override
- public boolean isShutdown() {
- return this.executor.isShutdown();
- }
+ public static interface AutoCloseableEventExecutor extends EventExecutor, AutoCloseable {
- @Override
- public boolean isTerminated() {
- return this.executor.isTerminated();
- }
-
- @Override
- public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
- return this.executor.awaitTermination(timeout, unit);
- }
-
- @Override
- public void execute(Runnable command) {
- this.executor.execute(command);
- }
-
- @Override
- public void close() throws Exception {
- shutdownGracefully();
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public void shutdown() {
- this.executor.shutdown();
- }
-
- @Override
- public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
- return this.executor.scheduleWithFixedDelay(command, initialDelay, delay, unit);
- }
+ }
- @Override
- public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
- return this.executor.schedule(command, delay, unit);
- }
+ public static class CloseableGlobalEventExecutorMixin implements AutoCloseable {
+ private final GlobalEventExecutor eventExecutor;
- @Override
- public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
- return this.executor.schedule(callable, delay, unit);
+ public CloseableGlobalEventExecutorMixin(GlobalEventExecutor eventExecutor) {
+ this.eventExecutor = eventExecutor;
}
@Override
- public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
- return this.executor.scheduleAtFixedRate(command, initialDelay, period, unit);
+ public void close() {
+ eventExecutor.shutdownGracefully(0, 1, TimeUnit.SECONDS);
}
}
}
*/
/**
-* Generated file
-
-* Generated from: yang module name: netty-event-executor yang module local name: netty-global-event-executor
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Tue Nov 12 10:44:21 CET 2013
-*
-* Do not modify this file unless it is present under src/main directory
-*/
+ * Generated file
+
+ * Generated from: yang module name: netty-event-executor yang module local name: netty-global-event-executor
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Tue Nov 12 10:44:21 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
package org.opendaylight.controller.config.yang.netty.eventexecutor;
-/**
-*
-*/
-public class GlobalEventExecutorModuleFactory extends org.opendaylight.controller.config.yang.netty.eventexecutor.AbstractGlobalEventExecutorModuleFactory
-{
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+public class GlobalEventExecutorModuleFactory extends org.opendaylight.controller.config.yang.netty.eventexecutor.AbstractGlobalEventExecutorModuleFactory {
+ public static final String SINGLETON_NAME = "singleton";
+
+ @Override
+ public GlobalEventExecutorModule instantiateModule(String instanceName, DependencyResolver dependencyResolver, GlobalEventExecutorModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+ checkArgument(SINGLETON_NAME.equals(instanceName),"Illegal instance name '" + instanceName + "', only allowed name is " + SINGLETON_NAME);
+ return super.instantiateModule(instanceName, dependencyResolver, oldModule, oldInstance, bundleContext);
+ }
+ @Override
+ public GlobalEventExecutorModule instantiateModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
+ checkArgument(SINGLETON_NAME.equals(instanceName),"Illegal instance name '" + instanceName + "', only allowed name is " + SINGLETON_NAME);
+ return super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+ }
}
package org.opendaylight.controller.config.yang.netty.eventexecutor;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
public class GlobalEventExecutorModuleTest extends AbstractConfigTest {
private GlobalEventExecutorModuleFactory factory;
- private final String instanceName = "netty1";
+ private final String instanceName = GlobalEventExecutorModuleFactory.SINGLETON_NAME;
@Before
public void setUp() {
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
createInstance(transaction, instanceName);
- createInstance(transaction, instanceName + 2);
+
transaction.validateConfig();
CommitStatus status = transaction.commit();
- assertBeanCount(2, factory.getImplementationName());
- assertStatus(status, 2, 0, 0);
+ assertBeanCount(1, factory.getImplementationName());
+ assertStatus(status, 1, 0, 0);
+ }
+
+ @Test
+ public void testConflictingName() throws Exception {
+ ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+ try {
+ createInstance(transaction, instanceName + "x");
+ fail();
+ }catch(IllegalArgumentException e){
+ assertTrue(e.getMessage() + " failure", e.getMessage().contains("only allowed name is singleton"));
+ }
}
@Test
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import java.util.concurrent.TimeUnit;
+
/**
*
*/
@Override
public void close() throws Exception {
- shutdownGracefully();
+ shutdownGracefully(0, 1, TimeUnit.SECONDS);
}
}
}
class StopSystemBundleThread extends Thread {
private static final Logger logger = LoggerFactory.getLogger(StopSystemBundleThread.class);
+ public static final String CONFIG_MANAGER_SYMBOLIC_NAME = "org.opendaylight.controller.config-manager";
private final Bundle systemBundle;
StopSystemBundleThread(Bundle systemBundle) {
try {
// wait so that JMX response is received
Thread.sleep(1000);
+ // first try to stop config-manager
+ Bundle configManager = findConfigManager();
+ if (configManager != null){
+ logger.debug("Stopping config-manager");
+ configManager.stop();
+ Thread.sleep(1000);
+ }
+ logger.debug("Stopping system bundle");
systemBundle.stop();
} catch (BundleException e) {
logger.warn("Can not stop OSGi server", e);
logger.warn("Shutdown process interrupted", e);
}
}
+
+ private Bundle findConfigManager() {
+ for(Bundle bundle: systemBundle.getBundleContext().getBundles()){
+ if (CONFIG_MANAGER_SYMBOLIC_NAME.equals(bundle.getSymbolicName())) {
+ return bundle;
+ }
+ }
+ return null;
+ }
+
}
class CallSystemExitThread extends Thread {
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.osgi.framework.Bundle;
+import javax.management.InstanceNotFoundException;
import javax.management.JMX;
import javax.management.ObjectName;
import java.util.Collections;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.opendaylight.controller.config.yang.shutdown.impl.ShutdownModuleFactory.NAME;
public class ShutdownTest extends AbstractConfigTest {
private final ShutdownModuleFactory factory = new ShutdownModuleFactory();
@Mock
- private Bundle mockedSysBundle;
+ private Bundle mockedSysBundle, mockedConfigManager;
+
@Before
public void setUp() throws Exception {
doReturn(mockedSysBundle).when(mockedContext).getBundle(0);
mockedContext.getBundle(0);
doNothing().when(mockedSysBundle).stop();
+ doNothing().when(mockedConfigManager).stop();
+ doReturn(mockedContext).when(mockedSysBundle).getBundleContext();
+ doReturn(new Bundle[]{mockedSysBundle, mockedConfigManager}).when(mockedContext).getBundles();
+ doReturn("system bundle").when(mockedSysBundle).getSymbolicName();
+ doReturn(StopSystemBundleThread.CONFIG_MANAGER_SYMBOLIC_NAME).when(mockedConfigManager).getSymbolicName();
+
+
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
// initialize default instance
transaction.commit();
@Test
public void testWithSecret() throws Exception {
+ String secret = "secret";
+ setSecret(secret);
+ shutdownViaRuntimeJMX(secret);
+ }
+
+ private void setSecret(String secret) throws InstanceNotFoundException {
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
ObjectName on = transaction.lookupConfigBean(NAME, NAME);
ShutdownModuleMXBean proxy = transaction.newMXBeanProxy(on, ShutdownModuleMXBean.class);
- String secret = "secret";
proxy.setSecret(secret);
transaction.commit();
- shutdownViaRuntimeJMX(secret);
+ }
+
+ @Test
+ public void testWrongSecret() throws Exception {
+ setSecret("secret");
try {
ShutdownRuntimeMXBean runtime = JMX.newMXBeanProxy(platformMBeanServer, runtimeON, ShutdownRuntimeMXBean.class);
runtime.shutdown("foo", 60000L, null);
assertStopped();
}
-
private void assertStopped() throws Exception {
- Thread.sleep(2000); // happens on another thread
+ Thread.sleep(3000); // happens on another thread
+ verify(mockedConfigManager).stop();
verify(mockedSysBundle).stop();
- verifyNoMoreInteractions(mockedSysBundle);
- reset(mockedSysBundle);
- doNothing().when(mockedSysBundle).stop();
}
}
</Private-Package>
<Export-Package>
org.opendaylight.controller.config.threadpool.util,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.threadpool.impl.rev130405.*,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.threadpool.impl.*,
</Export-Package>
</instructions>
</configuration>
config:java-name-prefix IdentityTest;
}
- identity test-identity1 {
-
- }
-
- identity test-identity2 {
- base test-identity1;
- }
-
augment "/config:modules/config:module/config:configuration" {
case impl-identity-test {
when "/config:modules/config:module/config:type = 'impl-identity-test'";
leaf afi {
type identityref {
- base test-identity1;
+ base tt:test-identity1;
}
}
container identities-container {
leaf afi {
type identityref {
- base test-identity1;
+ base tt:test-identity1;
}
}
}
list identities {
leaf afi {
type identityref {
- base test-identity1;
+ base tt:test-identity1;
}
}
leaf safi {
type identityref {
- base test-identity1;
+ base tt:test-identity1;
}
}
container identities-inner {
leaf afi {
type identityref {
- base test-identity1;
+ base tt:test-identity1;
}
}
}
}
}
+
+
+ identity test-identity1 {
+
+ }
+
+ identity test-identity2 {
+ base test-identity1;
+ }
}
import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.test.impl.rev130403.TestIdentity1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.test.impl.rev130403.TestIdentity2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2;
import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec;
</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>
+ <name>singleton</name>
</module>
</modules>
<type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-event-executor</type>
<instance>
<name>global-event-executor</name>
- <provider>/modules/module[type='netty-global-event-executor'][name='global-event-executor']</provider>
+ <provider>/modules/module[type='netty-global-event-executor'][name='singleton']</provider>
</instance>
</service>
<service>
module flow-capable-transaction {
- namespace "urn:opendaylight:flow:transaction";
+ namespace "urn:opendaylight:flow:transaction";
prefix type;
import opendaylight-inventory {prefix inv; revision-date "2013-08-19";}
import ietf-inet-types {prefix inet; revision-date "2010-09-24";}
import yang-ext {prefix ext; revision-date "2013-07-09";}
-
+
revision "2013-11-03" {
description "Initial revision";
}
typedef transaction-id {
- type uint64;
+ type uint64;
}
// This refers to MD-SAL transaction reference.
grouping transaction-metadata {
type inet:uri;
}
}
-
+
grouping transaction-aware {
leaf transaction-id {
type transaction-id;
}
}
+ grouping multipart-transaction-aware {
+ uses transaction-aware;
+
+ leaf moreReplies {
+ type boolean;
+ default false;
+ }
+ }
+
rpc get-next-transaction-id {
input {
leaf node {
}
}
output {
- uses transaction-aware;
+ uses transaction-aware;
}
}
}
}
}
-}
\ No newline at end of file
+}
notification table-updated {
uses "inv:node-context-ref";
- uses tr:transaction-aware;
- leaf moreReplies {
- type boolean;
- }
+ uses tr:multipart-transaction-aware;
uses table-type:table-features;
}
}
import flow-node-inventory {prefix flow-node;revision-date "2013-08-19";}
import flow-capable-transaction {prefix tr;}
import ietf-inet-types {prefix inet; revision-date "2010-09-24";}
-
+
revision "2013-08-19" {
description "Initial revision of flow statistics service";
}
-
- //Augment flow statistics data to the flow-capable-node->table->flow
- augment "/inv:nodes/inv:node/flow-node:table/flow-node:flow" {
+
+ //Augment flow statistics data to the flow-capable-node->table->flow
+ augment "/inv:nodes/inv:node/flow-node:table/flow-node:flow" {
ext:augment-identifier "flow-statistics-data";
uses flow-statistics;
}
-
- grouping flow-statistics {
+
+ grouping flow-statistics {
container flow-statistics {
//config "false";
- uses flow-types:flow;
- uses stat-types:generic-statistics;
+ uses flow-types:flow;
+ uses stat-types:generic-statistics;
+ }
+ }
+
+ typedef flow-id {
+ description "flow id";
+ type inet:uri;
+ }
+
+ grouping flow-and-statistics-map-list {
+ description "List of flow and statistics map";
+ list flow-and-statistics-map-list {
+ key "flow-id";
+ leaf flow-id {
+ type flow-id;
+ }
+ uses flow-and-statistics-map;
}
- }
-
- typedef flow-id {
- description "flow id";
- type inet:uri;
- }
-
- grouping flow-and-statistics-map-list {
- description "List of flow and statistics map";
- list flow-and-statistics-map-list {
- key "flow-id";
- leaf flow-id {
- type flow-id;
- }
- uses flow-and-statistics-map;
- }
- }
-
- grouping flow-and-statistics-map{
- description "Mapping between flow and its statistics";
- uses flow-types:flow;
- uses stat-types:generic-statistics;
- }
-
+ }
+
+ grouping flow-and-statistics-map{
+ description "Mapping between flow and its statistics";
+ uses flow-types:flow;
+ uses stat-types:generic-statistics;
+ }
+
// RPC calls to fetch flow statistics
rpc get-all-flows-statistics-from-all-flow-tables {
- description "Fetch statistics of all the flow present in all the flow tables of the switch";
+ description "Fetch statistics of all the flow present in all the flow tables of the switch";
input {
uses inv:node-context-ref;
}
uses flow-and-statistics-map-list;
uses tr:transaction-aware;
}
-
+
}
rpc get-all-flow-statistics-from-flow-table {
- description "Fetch statistics of all the flow present in the specific flow table of the switch";
+ description "Fetch statistics of all the flow present in the specific flow table of the switch";
input {
uses inv:node-context-ref;
leaf table-id {
- type table-types:table-id;
+ type table-types:table-id;
}
}
output {
}
rpc get-flow-statistics-from-flow-table {
- description "Fetch statistics of the specific flow present in the specific flow table of the switch";
+ description "Fetch statistics of the specific flow present in the specific flow table of the switch";
input {
uses inv:node-context-ref;
uses flow-types:flow;
}
notification flows-statistics-update {
- description "Flows statistics sent by switch";
- leaf moreReplies {
+ description "Flows statistics sent by switch";
+ leaf moreReplies {
type boolean;
}
uses inv:node;
- uses flow-and-statistics-map-list;
- uses tr:transaction-aware;
+ uses flow-and-statistics-map-list;
+ uses tr:transaction-aware;
}
- //Models for aggregate flow statistics collection
- augment "/inv:nodes/inv:node/flow-node:table" {
+ //Models for aggregate flow statistics collection
+ augment "/inv:nodes/inv:node/flow-node:table" {
ext:augment-identifier "aggregate-flow-statistics-data";
uses aggregate-flow-statistics;
}
-
- grouping aggregate-flow-statistics {
+
+ grouping aggregate-flow-statistics {
container aggregate-flow-statistics {
//config "false";
- uses stat-types:aggregate-flow-statistics;
+ uses stat-types:aggregate-flow-statistics;
}
- }
-
+ }
+
// RPC calls to fetch aggregate flow statistics
rpc get-aggregate-flow-statistics-from-flow-table-for-all-flows {
- description "Fetch aggregate statistics for all the flows present in the specific flow table of the switch";
+ description "Fetch aggregate statistics for all the flows present in the specific flow table of the switch";
input {
uses inv:node-context-ref;
leaf table-id {
- type table-types:table-id;
+ type table-types:table-id;
}
}
output {
- uses stat-types:aggregate-flow-statistics;
+ uses stat-types:aggregate-flow-statistics;
uses tr:transaction-aware;
}
}
rpc get-aggregate-flow-statistics-from-flow-table-for-given-match {
- description "Fetch aggregate statistics for all the flow matches to the given match from the given table of the switch";
+ description "Fetch aggregate statistics for all the flow matches to the given match from the given table of the switch";
input {
uses inv:node-context-ref;
uses flow-types:flow;
}
output {
- uses stat-types:aggregate-flow-statistics;
+ uses stat-types:aggregate-flow-statistics;
uses tr:transaction-aware;
}
}
notification aggregate-flow-statistics-update {
- description "Aggregate flow statistics for a table, sent by switch";
- leaf moreReplies {
- type boolean;
- }
+ description "Aggregate flow statistics for a table, sent by switch";
uses inv:node;
- uses stat-types:aggregate-flow-statistics;
- uses tr:transaction-aware;
+ uses stat-types:aggregate-flow-statistics;
+ uses tr:multipart-transaction-aware;
}
}
namespace "urn:opendaylight:flow:table:statistics";
prefix flowtablestat;
- import flow-capable-transaction {prefix tr;}
+ import flow-capable-transaction {prefix tr;}
import yang-ext {prefix ext; revision-date "2013-07-09";}
import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
import flow-node-inventory {prefix flow-node;revision-date "2013-08-19";}
}
//Augment flow table statistics data to the table
- augment "/inv:nodes/inv:node/flow-node:table" {
+ augment "/inv:nodes/inv:node/flow-node:table" {
ext:augment-identifier "flow-table-statistics-data";
uses flow-table-statistics;
}
-
- grouping flow-table-statistics {
+
+ grouping flow-table-statistics {
container flow-table-statistics {
//config "false";
- uses stat-types:generic-table-statistics;
+ uses stat-types:generic-table-statistics;
}
- }
+ }
//RPC calls to fetch flow table statistics
grouping flow-table-and-statistics-map {
- list flow-table-and-statistics-map {
- key "table-id";
- leaf table-id {
- type table-types:table-id;
- }
- uses stat-types:generic-table-statistics;
- }
+ list flow-table-and-statistics-map {
+ key "table-id";
+ leaf table-id {
+ type table-types:table-id;
+ }
+ uses stat-types:generic-table-statistics;
+ }
}
rpc get-flow-tables-statistics {
- description "Fetch statistics of all the flow tables present on the tarnet node";
- input {
- uses inv:node-context-ref;
- }
- output {
- uses flow-table-and-statistics-map;
- uses tr:transaction-aware;
- }
+ description "Fetch statistics of all the flow tables present on the tarnet node";
+ input {
+ uses inv:node-context-ref;
+ }
+ output {
+ uses flow-table-and-statistics-map;
+ uses tr:transaction-aware;
+ }
}
//Notification to receive table statistics update
notification flow-table-statistics-update {
- description "Receive flow table statistics update";
-
- leaf moreReplies {
- type boolean;
- }
+ description "Receive flow table statistics update";
+
uses inv:node;
- uses flow-table-and-statistics-map;
- uses tr:transaction-aware;
+ uses flow-table-and-statistics-map;
+ uses tr:multipart-transaction-aware;
}
}
description "Initial revision of group statistics service";
}
- grouping group-statistics {
+ grouping group-statistics {
container group-statistics {
//config "false";
uses group-types:group-statistics;
}
- }
+ }
augment "/inv:nodes/inv:node/fni:group" {
ext:augment-identifier "node-group-statistics";
uses group-statistics;
}
- grouping group-desc {
+ grouping group-desc {
container group-desc {
//config "false";
uses group-types:group;
}
- }
+ }
augment "/inv:nodes/inv:node/fni:group" {
ext:augment-identifier "node-group-desc-stats";
uses group-desc;
}
- grouping group-features {
- container group-features {
+ grouping group-features {
+ container group-features {
//config "false";
uses group-types:group-features-reply;
}
}
-
+
augment "/inv:nodes/inv:node" {
ext:augment-identifier "node-group-features";
uses group-features;
//Notification calls
notification group-statistics-updated {
- leaf moreReplies {
- type boolean;
- }
uses inv:node;
uses group-types:group-statistics-reply;
- uses tr:transaction-aware;
+ uses tr:multipart-transaction-aware;
}
notification group-desc-stats-updated {
- leaf moreReplies {
- type boolean;
- }
uses inv:node;
uses group-types:group-desc-stats-reply;
- uses tr:transaction-aware;
+ uses tr:multipart-transaction-aware;
}
notification group-features-updated {
- leaf moreReplies {
- type boolean;
- }
uses inv:node;
uses group-types:group-features-reply;
- uses tr:transaction-aware;
+ uses tr:multipart-transaction-aware;
}
}
//Notification calls
notification meter-statistics-updated {
- leaf moreReplies {
- type boolean;
- }
-
uses inv:node;
uses meter-types:meter-statistics-reply;
- uses tr:transaction-aware;
+ uses tr:multipart-transaction-aware;
}
notification meter-config-stats-updated {
- leaf moreReplies {
- type boolean;
- }
-
uses inv:node;
uses meter-types:meter-config-stats-reply;
- uses tr:transaction-aware;
+ uses tr:multipart-transaction-aware;
}
notification meter-features-updated {
- leaf moreReplies {
- type boolean;
- }
-
uses inv:node;
uses meter-types:meter-features-reply;
- uses tr:transaction-aware;
+ uses tr:multipart-transaction-aware;
}
}
namespace "urn:opendaylight:port:statistics";
prefix portstat;
- import flow-capable-transaction {prefix tr;}
+ import flow-capable-transaction {prefix tr;}
import yang-ext {prefix ext; revision-date "2013-07-09";}
import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
import opendaylight-statistics-types {prefix stat-types;revision-date "2013-09-25";}
revision "2013-12-14" {
description "Initial revision of port statistics model";
}
-
+
//Augment port statistics data to the flow-capable-node-connector
- augment "/inv:nodes/inv:node/inv:node-connector" {
+ augment "/inv:nodes/inv:node/inv:node-connector" {
ext:augment-identifier "flow-capable-node-connector-statistics-data";
uses flow-capable-node-connector-statistics;
}
-
- grouping flow-capable-node-connector-statistics {
+
+ grouping flow-capable-node-connector-statistics {
container flow-capable-node-connector-statistics {
//config "false";
uses stat-types:node-connector-statistics;
}
- }
-
+ }
+
// RPC calls
rpc get-all-node-connectors-statistics {
- description "Get statistics for all node connectors from the node";
+ description "Get statistics for all node connectors from the node";
input {
uses inv:node-context-ref;
}
output {
- uses node-connector-statistics-and-port-number-map;
+ uses node-connector-statistics-and-port-number-map;
uses tr:transaction-aware;
}
}
-
+
rpc get-node-connector-statistics {
- description "Get statistics for given node connector from the node";
- input {
- uses inv:node-context-ref;
- leaf node-connector-id {
- type inv:node-connector-id;
- }
- }
- output {
+ description "Get statistics for given node connector from the node";
+ input {
+ uses inv:node-context-ref;
+ leaf node-connector-id {
+ type inv:node-connector-id;
+ }
+ }
+ output {
uses stat-types:node-connector-statistics;
uses tr:transaction-aware;
- }
+ }
}
-
- //Notification for node connector statistics update
- grouping node-connector-statistics-and-port-number-map {
- description "List of map - node connectors and their statistics";
- list node-connector-statistics-and-port-number-map {
- key "node-connector-id";
- leaf node-connector-id {
- type inv:node-connector-id;
- }
- uses stat-types:node-connector-statistics;
- }
- }
- notification node-connector-statistics-update {
- leaf moreReplies {
- type boolean;
+ //Notification for node connector statistics update
+ grouping node-connector-statistics-and-port-number-map {
+ description "List of map - node connectors and their statistics";
+ list node-connector-statistics-and-port-number-map {
+ key "node-connector-id";
+ leaf node-connector-id {
+ type inv:node-connector-id;
+ }
+ uses stat-types:node-connector-statistics;
}
+ }
+
+ notification node-connector-statistics-update {
uses inv:node;
- uses node-connector-statistics-and-port-number-map;
- uses tr:transaction-aware;
+ uses node-connector-statistics-and-port-number-map;
+ uses tr:multipart-transaction-aware;
}
}
namespace "urn:opendaylight:queue:statistics";
prefix queuestat;
- import flow-capable-transaction {prefix tr;}
+ import flow-capable-transaction {prefix tr;}
import yang-ext {prefix ext; revision-date "2013-07-09";}
import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
import flow-node-inventory {prefix flow-node;revision-date "2013-08-19";}
}
//Augment queue statistics data to the flow-capable-node-connector
- augment "/inv:nodes/inv:node/inv:node-connector/flow-node:queue" {
+ augment "/inv:nodes/inv:node/inv:node-connector/flow-node:queue" {
ext:augment-identifier "flow-capable-node-connector-queue-statistics-data";
uses flow-capable-node-connector-queue-statistics;
}
-
- grouping flow-capable-node-connector-queue-statistics {
+
+ grouping flow-capable-node-connector-queue-statistics {
container flow-capable-node-connector-queue-statistics {
//config "false";
uses stat-types:generic-queue-statistics;
}
- }
-
- //RPC calls to fetch queue statistics
+ }
+
+ //RPC calls to fetch queue statistics
grouping queue-id-and-statistics-map {
- list queue-id-and-statistics-map {
- key "queue-id node-connector-id";
- leaf queue-id {
- type queue-types:queue-id;
- }
- leaf node-connector-id {
- type inv:node-connector-id;
- }
-
+ list queue-id-and-statistics-map {
+ key "queue-id node-connector-id";
+ leaf queue-id {
+ type queue-types:queue-id;
+ }
+ leaf node-connector-id {
+ type inv:node-connector-id;
+ }
+
uses stat-types:generic-queue-statistics;
- }
+ }
}
rpc get-all-queues-statistics-from-all-ports {
- description "Get statistics for all the queues attached to all the ports from the node";
+ description "Get statistics for all the queues attached to all the ports from the node";
input {
uses inv:node-context-ref;
}
}
rpc get-all-queues-statistics-from-given-port {
- description "Get statistics for all queues for given port of the node";
- input {
- uses inv:node-context-ref;
- leaf node-connector-id {
- type inv:node-connector-id;
- }
- }
- output {
+ description "Get statistics for all queues for given port of the node";
+ input {
+ uses inv:node-context-ref;
+ leaf node-connector-id {
+ type inv:node-connector-id;
+ }
+ }
+ output {
uses queue-id-and-statistics-map;
uses tr:transaction-aware;
- }
+ }
}
rpc get-queue-statistics-from-given-port {
- description "Get statistics for given queues from given port of the node";
- input {
- uses inv:node-context-ref;
- leaf node-connector-id {
- type inv:node-connector-id;
- }
- leaf queue-id {
- type queue-types:queue-id;
- }
- }
- output {
+ description "Get statistics for given queues from given port of the node";
+ input {
+ uses inv:node-context-ref;
+ leaf node-connector-id {
+ type inv:node-connector-id;
+ }
+ leaf queue-id {
+ type queue-types:queue-id;
+ }
+ }
+ output {
uses queue-id-and-statistics-map;
uses tr:transaction-aware;
- }
+ }
}
//Notification for port statistics update
- notification queue-statistics-update {
- leaf moreReplies {
- type boolean;
- }
+ notification queue-statistics-update {
uses inv:node;
- uses queue-id-and-statistics-map;
- uses tr:transaction-aware;
+ uses queue-id-and-statistics-map;
+ uses tr:multipart-transaction-aware;
}
}
<configuration>
<instructions>
<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- <Bundle-Activator>org.opendaylight.controller.sal.binding.osgi.Activator</Bundle-Activator>
<Export-package>
org.opendaylight.controller.sal.binding.spi.*,
</Export-package>
public class SingletonHolder {
- public static final ClassPool CLASS_POOL = new ClassPool();
+ public static final ClassPool CLASS_POOL = ClassPool.getDefault();
public static final org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator RPC_GENERATOR_IMPL = new org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator(
CLASS_POOL);
public static final RuntimeCodeGenerator RPC_GENERATOR = RPC_GENERATOR_IMPL;
}
override onGlobalContextUpdated(SchemaContext context) {
- this.globalSchema = context;
- for (operation : context.operations) {
- val qname = operation.QName;
- qnameToRpc.put(qname, operation);
+ if (context !== null) {
+ qnameToRpc.clear
+ this.globalSchema = context;
+ for (operation : context.operations) {
+ val qname = operation.QName;
+ qnameToRpc.put(qname, operation);
+ }
}
}
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.test.impl.rev130403.TestIdentity1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.test.impl.rev130403.TestIdentity2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2;
import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec;
import org.opendaylight.yangtools.yang.model.api.Module;
import java.net.InetSocketAddress;
import java.util.Dictionary;
import java.util.Hashtable;
+import java.util.concurrent.TimeUnit;
public class NetconfImplActivator implements BundleActivator {
logger.info("Shutting down netconf because YangStoreService service was removed");
commitNot.close();
- eventLoopGroup.shutdownGracefully();
+ eventLoopGroup.shutdownGracefully(0, 1, TimeUnit.SECONDS);
timer.stop();
regMonitoring.unregister();
</type>
<name>id-test</name>
<identities>
- <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity1</afi>
- <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity2</safi>
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
+ <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</safi>
</identities>
<identities>
- <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity2</afi>
- <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity1</safi>
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
+ <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</safi>
</identities>
<identities-container>
- <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity2</afi>
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
</identities-container>
- <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:test-identity1</afi>
+ <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
</module>
</modules>