--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-subsystem</artifactId>
+ <version>0.2.2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>netty-threadgroup-config</artifactId>
+ <description>Configuration Wrapper around netty's event group</description>
+ <packaging>bundle</packaging>
+ <name>${project.artifactId}</name>
+ <prerequisites>
+ <maven>3.0.4</maven>
+ </prerequisites>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>threadpool-config-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <!--test dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-manager</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-manager</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-util</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.bgpcep</groupId>
+ <artifactId>mockito-configuration</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ </plugin>
+
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.7</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+ <Export-Package>
+ </Export-Package>
+ <Import-Package>
+ com.google.common.base,
+ io.netty.channel.nio,
+ org.opendaylight.controller.config.yang.threadpool,
+ io.netty.util.concurrent,
+ org.opendaylight.controller.config.api,
+ org.opendaylight.controller.config.api.annotations,
+ org.opendaylight.controller.config.api.runtime,
+ org.opendaylight.controller.config.spi,
+ org.slf4j,
+ org.osgi.framework
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <distributionManagement>
+ <site>
+ <id>${project.artifactId}</id>
+ <name>NETTY-THREADGROUP-CONFIG Module site</name>
+ <url>${basedir}/target/site/${project.artifactId}</url>
+ </site>
+ </distributionManagement>
+
+</project>
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: nsos-threadpool yang module local name: netty-threadgroup-fixed
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Fri Nov 08 08:31:45 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.netty.threadgroup;
+
+import com.google.common.base.Preconditions;
+import io.netty.channel.nio.NioEventLoopGroup;
+
+/**
+*
+*/
+public final class NettyThreadgroupModule extends org.opendaylight.controller.config.yang.netty.threadgroup.AbstractNettyThreadgroupModule
+{
+ public NettyThreadgroupModule(org.opendaylight.controller.config.api.ModuleIdentifier name, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(name, dependencyResolver);
+ }
+
+ public NettyThreadgroupModule(org.opendaylight.controller.config.api.ModuleIdentifier name, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, NettyThreadgroupModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(name, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void validate(){
+ if(getThreadCount()!=null) {
+ Preconditions.checkArgument(getThreadCount() > 0, "Thread count cannot be < 0");
+ }
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ return getThreadCount()==null ? new NioEventLoopGroupCloseable() : new NioEventLoopGroupCloseable(getThreadCount());
+ }
+
+
+ private class NioEventLoopGroupCloseable extends NioEventLoopGroup implements AutoCloseable {
+
+
+ public NioEventLoopGroupCloseable(int threadCount) {
+ super(threadCount);
+ }
+
+ public NioEventLoopGroupCloseable() {
+ super();
+ }
+
+ @Override
+ public void close() throws Exception {
+ shutdownGracefully();
+ }
+ }
+}
--- /dev/null
+/**
+* Generated file
+
+* Generated from: yang module name: nsos-threadpool yang module local name: netty-threadgroup-fixed
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Fri Nov 08 08:31:45 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.netty.threadgroup;
+
+/**
+*
+*/
+public class NettyThreadgroupModuleFactory extends org.opendaylight.controller.config.yang.netty.threadgroup.AbstractNettyThreadgroupModuleFactory
+{
+
+
+}
--- /dev/null
+// vi: set smarttab et sw=4 tabstop=4:
+module nsos-threadpool {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup";
+ prefix "netty-t";
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import threadpool { prefix th; revision-date 2013-04-09; }
+
+ organization "Cisco Systems, Inc.";
+
+ contact "Robert Varga <rovarga@cisco.com>";
+
+ description
+ "This module contains the base YANG definitions for NS-OS
+ thread-related services.
+
+ Copyright (c)2013 Cisco Systems, Inc. All rights reserved.";
+
+ revision "2013-11-07" {
+ description
+ "Initial revision";
+ }
+
+ identity netty-threadgroup-fixed {
+ base config:module-type;
+ config:provided-service th:netty-threadgroup;
+ config:java-name-prefix NettyThreadgroup;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case netty-threadgroup-fixed {
+ when "/config:modules/config:module/config:type = 'netty-threadgroup-fixed'";
+
+ leaf thread-count {
+ type uint16;
+
+ description "Number of threads to be used by NioEventLoopGroup. This attribute is optional and default value will be 2* Number of CPUs";
+ }
+
+ // TODO add optional thread factory dependency
+
+ }
+ }
+
+ augment "/config:modules/config:module/config:state" {
+ case netty-threadgroup-fixed {
+ when "/config:modules/config:module/config:type = 'netty-threadgroup-fixed'";
+ }
+ }
+
+
+}
--- /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.yang.netty.threadgroup;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+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 javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
+
+public class NettyThreadgroupModuleTest extends AbstractConfigTest {
+
+ private NettyThreadgroupModuleFactory factory;
+ private final String instanceName = "netty1";
+
+ @Before
+ public void setUp() {
+ factory = new NettyThreadgroupModuleFactory();
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+ }
+
+ @Test
+ public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException {
+ ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+ createInstance(transaction, instanceName, 2);
+ createInstance(transaction, instanceName + 2, null);
+ transaction.validateConfig();
+ CommitStatus status = transaction.commit();
+
+ assertBeanCount(2, factory.getImplementationName());
+ assertStatus(status, 2, 0, 0);
+ }
+
+ @Test
+ public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
+
+ ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+ createInstance(transaction, instanceName, null);
+
+ transaction.commit();
+
+ transaction = configRegistryClient.createTransaction();
+ assertBeanCount(1, factory.getImplementationName());
+ CommitStatus status = transaction.commit();
+
+ assertBeanCount(1, factory.getImplementationName());
+ assertStatus(status, 0, 0, 1);
+ }
+
+ @Test
+ public void testReconfigure() throws InstanceAlreadyExistsException, ConflictingVersionException,
+ ValidationException, InstanceNotFoundException {
+
+ ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+ createInstance(transaction, instanceName, null);
+
+ transaction.commit();
+
+ transaction = configRegistryClient.createTransaction();
+ assertBeanCount(1, factory.getImplementationName());
+ NettyThreadgroupModuleMXBean mxBean = transaction.newMBeanProxy(
+ transaction.lookupConfigBean(AbstractNettyThreadgroupModuleFactory.NAME, instanceName),
+ NettyThreadgroupModuleMXBean.class);
+ mxBean.setThreadCount(1);
+ CommitStatus status = transaction.commit();
+
+ assertBeanCount(1, factory.getImplementationName());
+ assertStatus(status, 0, 1, 0);
+ }
+
+ private ObjectName createInstance(ConfigTransactionJMXClient transaction, String instanceName, Integer threads)
+ throws InstanceAlreadyExistsException {
+ ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
+ NettyThreadgroupModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, NettyThreadgroupModuleMXBean.class);
+ mxBean.setThreadCount(threads);
+ return nameCreated;
+ }
+}
<module>logback-config</module>
<module>threadpool-config-api</module>
<module>threadpool-config-impl</module>
+ <module>netty-threadgroup-config</module>
</modules>
<profiles>
<maven>3.0.4</maven>
</prerequisites>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-api</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-transport</artifactId>
+ </dependency>
+ </dependencies>
<build>
<plugins>
<Import-Package>
org.opendaylight.controller.config.api.*,
com.google.common.eventbus,
+ io.netty.channel,
</Import-Package>
<Export-Package>
org.opendaylight.controller.config.threadpool,
thread-related services.
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
config:java-class "org.opendaylight.controller.config.threadpool.ScheduledThreadPool";
}
+
+ identity netty-threadgroup {
+ description
+ "Configuration wrapper around netty's threadgroup";
+
+ base "config:service-type";
+ config:java-class "io.netty.channel.EventLoopGroup";
+ }
+
+
}