From 353b76bddbe7a939a4a8ed54a3b794e6866660d7 Mon Sep 17 00:00:00 2001 From: Milos Fabian Date: Thu, 7 Nov 2013 09:41:42 +0100 Subject: [PATCH] Added configuration modules and closeable wrappers for FixedThreadPool, FlexibleThreadPool, NamingThreadPool, ScheduledThreadPool and NamingThreadFactory. Change-Id: I6d4b84662c4b6f418c84e0dd9f026f45ad2c8201 Signed-off-by: Milos Fabian --- .../util/FixedThreadPoolWrapper.java | 51 ++++++++++ .../util/FlexibleThreadPoolWrapper.java | 80 ++++++++++++++++ .../util/NamingThreadPoolFactory.java | 49 ++++++++++ .../util/ScheduledThreadPoolWrapper.java | 49 ++++++++++ .../impl/FixedThreadPoolModule.java | 45 +++++++++ .../impl/FixedThreadPoolModuleFactory.java | 18 ++++ .../impl/FlexibleThreadPoolModule.java | 55 +++++++++++ .../impl/FlexibleThreadPoolModuleFactory.java | 18 ++++ .../impl/NamingThreadFactoryModule.java | 42 ++++++++ .../NamingThreadFactoryModuleFactory.java | 18 ++++ .../impl/ScheduledThreadPoolModule.java | 44 +++++++++ .../ScheduledThreadPoolModuleFactory.java | 18 ++++ .../src/main/yang/threadpool-impl.yang | 95 ++++++++++++++++++- 13 files changed, 580 insertions(+), 2 deletions(-) create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FixedThreadPoolWrapper.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FlexibleThreadPoolWrapper.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/NamingThreadPoolFactory.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/ScheduledThreadPoolWrapper.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModule.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModule.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModule.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModuleFactory.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java create mode 100644 opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FixedThreadPoolWrapper.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FixedThreadPoolWrapper.java new file mode 100644 index 0000000000..ca034434d5 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FixedThreadPoolWrapper.java @@ -0,0 +1,51 @@ +/* + * 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.threadpool.util; + +import java.io.Closeable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; + +import org.opendaylight.controller.config.threadpool.ThreadPool; + +/** + * Implementation of {@link ThreadPool} using fixed number of threads wraps + * {@link ExecutorService}. + */ +public class FixedThreadPoolWrapper implements ThreadPool, Closeable { + + private final ThreadPoolExecutor executor; + + public FixedThreadPoolWrapper(int threadCount, ThreadFactory factory) { + this.executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(threadCount, factory); + executor.prestartAllCoreThreads(); + } + + @Override + public ExecutorService getExecutor() { + return Executors.unconfigurableExecutorService(executor); + } + + @Override + public void close() { + executor.shutdown(); + } + + @Override + public int getMaxThreadCount() { + return executor.getMaximumPoolSize(); + } + + public void setMaxThreadCount(int maxThreadCount) { + executor.setCorePoolSize(maxThreadCount); + executor.setMaximumPoolSize(maxThreadCount); + } +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FlexibleThreadPoolWrapper.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FlexibleThreadPoolWrapper.java new file mode 100644 index 0000000000..3dfa6e2bc7 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FlexibleThreadPoolWrapper.java @@ -0,0 +1,80 @@ +/* + * 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.threadpool.util; + +import java.io.Closeable; +import java.io.IOException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.opendaylight.controller.config.threadpool.ThreadPool; + +/** + * Implementation of {@link ThreadPool} using flexible number of threads wraps + * {@link ExecutorService}. + */ +public class FlexibleThreadPoolWrapper implements ThreadPool, Closeable { + private final ThreadPoolExecutor executor; + + public FlexibleThreadPoolWrapper(int minThreadCount, int maxThreadCount, long keepAlive, TimeUnit timeUnit, + ThreadFactory threadFactory) { + + executor = new ThreadPoolExecutor(minThreadCount, maxThreadCount, keepAlive, timeUnit, + new SynchronousQueue(), threadFactory); + executor.prestartAllCoreThreads(); + } + + @Override + public ExecutorService getExecutor() { + return Executors.unconfigurableExecutorService(executor); + } + + public int getMinThreadCount() { + return executor.getCorePoolSize(); + } + + public void setMinThreadCount(int minThreadCount) { + executor.setCorePoolSize(minThreadCount); + } + + @Override + public int getMaxThreadCount() { + return executor.getMaximumPoolSize(); + } + + public void setMaxThreadCount(int maxThreadCount) { + executor.setMaximumPoolSize(maxThreadCount); + } + + public long getKeepAliveMillis() { + return executor.getKeepAliveTime(TimeUnit.MILLISECONDS); + } + + public void setKeepAliveMillis(long keepAliveMillis) { + executor.setKeepAliveTime(keepAliveMillis, TimeUnit.MILLISECONDS); + } + + public void setThreadFactory(ThreadFactory threadFactory) { + executor.setThreadFactory(threadFactory); + } + + public void prestartAllCoreThreads() { + executor.prestartAllCoreThreads(); + } + + @Override + public void close() throws IOException { + executor.shutdown(); + } + +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/NamingThreadPoolFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/NamingThreadPoolFactory.java new file mode 100644 index 0000000000..2e27d6cce8 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/NamingThreadPoolFactory.java @@ -0,0 +1,49 @@ +/* + * 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.threadpool.util; + +import java.io.Closeable; +import java.io.IOException; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicLong; + +import javax.annotation.concurrent.ThreadSafe; + +import com.google.common.base.Preconditions; + +/** + * Implementation of {@link ThreadFactory}. + */ +@ThreadSafe +public class NamingThreadPoolFactory implements ThreadFactory, Closeable { + + private final ThreadGroup group; + private final String namePrefix; + private final AtomicLong threadName = new AtomicLong(); + + public NamingThreadPoolFactory(String namePrefix) { + Preconditions.checkNotNull(namePrefix); + this.group = new ThreadGroup(namePrefix); + this.namePrefix = namePrefix; + } + + @Override + public Thread newThread(Runnable r) { + return new Thread(group, r, String.format("%s-%d", group.getName(), threadName.incrementAndGet())); + } + + @Override + public void close() throws IOException { + } + + public String getNamePrefix() { + return namePrefix; + } + +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/ScheduledThreadPoolWrapper.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/ScheduledThreadPoolWrapper.java new file mode 100644 index 0000000000..ee3399e1b2 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/ScheduledThreadPoolWrapper.java @@ -0,0 +1,49 @@ +/* + * 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.threadpool.util; + +import java.io.Closeable; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadFactory; + +import org.opendaylight.controller.config.threadpool.ScheduledThreadPool; + +/** + * Implementation of {@link ScheduledThreadPool} wraps + * {@link ScheduledExecutorService}. + */ +public class ScheduledThreadPoolWrapper implements ScheduledThreadPool, Closeable { + + private final ScheduledThreadPoolExecutor executor; + private final int threadCount; + + public ScheduledThreadPoolWrapper(int threadCount, ThreadFactory factory) { + this.threadCount = threadCount; + this.executor = new ScheduledThreadPoolExecutor(threadCount, factory); + executor.prestartAllCoreThreads(); + } + + @Override + public ScheduledExecutorService getExecutor() { + return Executors.unconfigurableScheduledExecutorService(executor); + } + + @Override + public void close() { + executor.shutdown(); + } + + @Override + public int getMaxThreadCount() { + return threadCount; + } + +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModule.java new file mode 100644 index 0000000000..a0a9addf03 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModule.java @@ -0,0 +1,45 @@ +/** + * 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; + +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 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) { + 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 FixedThreadPoolWrapper(getMaxThreadCount(), getThreadFactoryDependency()); + } +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java new file mode 100644 index 0000000000..2803448fd2 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java @@ -0,0 +1,18 @@ +/** + * Generated file + + * Generated from: yang module name: threadpool-impl yang module local name: threadpool-fixed + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 16:19:33 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.threadpool.impl; + +/** +* +*/ +public class FixedThreadPoolModuleFactory extends + org.opendaylight.controller.config.yang.threadpool.impl.AbstractFixedThreadPoolModuleFactory { + +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModule.java new file mode 100644 index 0000000000..47b4eec689 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModule.java @@ -0,0 +1,55 @@ +/** + * 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; + +import java.util.concurrent.TimeUnit; + +import org.opendaylight.controller.config.api.JmxAttributeValidationException; +import org.opendaylight.controller.config.threadpool.util.FlexibleThreadPoolWrapper; + +/** +* +*/ +public final class FlexibleThreadPoolModule extends + org.opendaylight.controller.config.yang.threadpool.impl.AbstractFlexibleThreadPoolModule { + + 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) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + JmxAttributeValidationException.checkNotNull(getKeepAliveMillis(), keepAliveMillisJmxAttribute); + JmxAttributeValidationException.checkCondition(getKeepAliveMillis() > 0, "must be greater than zero", + keepAliveMillisJmxAttribute); + + JmxAttributeValidationException.checkNotNull(getMinThreadCount(), minThreadCountJmxAttribute); + JmxAttributeValidationException.checkCondition(getMinThreadCount() > 0, "must be greater than zero", + minThreadCountJmxAttribute); + + JmxAttributeValidationException.checkNotNull(getMaxThreadCount(), maxThreadCountJmxAttribute); + JmxAttributeValidationException.checkCondition(getMaxThreadCount() > 0, "must be greater than zero", + maxThreadCountJmxAttribute); + } + + @Override + public java.lang.AutoCloseable createInstance() { + return new FlexibleThreadPoolWrapper(getMinThreadCount(), getMaxThreadCount(), getKeepAliveMillis(), + TimeUnit.MILLISECONDS, getThreadFactoryDependency()); + } +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java new file mode 100644 index 0000000000..ef6ebd25e2 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java @@ -0,0 +1,18 @@ +/** + * Generated file + + * Generated from: yang module name: threadpool-impl yang module local name: threadpool-flexible + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 16:19:33 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.threadpool.impl; + +/** +* +*/ +public class FlexibleThreadPoolModuleFactory extends + org.opendaylight.controller.config.yang.threadpool.impl.AbstractFlexibleThreadPoolModuleFactory { + +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModule.java new file mode 100644 index 0000000000..a761727e5c --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModule.java @@ -0,0 +1,42 @@ +/** + * Generated file + + * Generated from: yang module name: threadpool-impl yang module local name: threadfactory-naming + * 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.NamingThreadPoolFactory; + +/** +* +*/ +public final class NamingThreadFactoryModule extends + org.opendaylight.controller.config.yang.threadpool.impl.AbstractNamingThreadFactoryModule { + + public NamingThreadFactoryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public NamingThreadFactoryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + NamingThreadFactoryModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + JmxAttributeValidationException.checkNotNull(getNamePrefix(), namePrefixJmxAttribute); + } + + @Override + public java.lang.AutoCloseable createInstance() { + return new NamingThreadPoolFactory(getNamePrefix()); + } +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModuleFactory.java new file mode 100644 index 0000000000..5e70afb93e --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModuleFactory.java @@ -0,0 +1,18 @@ +/** + * Generated file + + * Generated from: yang module name: threadpool-impl yang module local name: threadfactory-naming + * 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 NamingThreadFactoryModuleFactory extends + org.opendaylight.controller.config.yang.threadpool.impl.AbstractNamingThreadFactoryModuleFactory { + +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java new file mode 100644 index 0000000000..42739b4b32 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java @@ -0,0 +1,44 @@ +/** + * Generated file + + * Generated from: yang module name: threadpool-impl yang module local name: threadpool-scheduled + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 16:19:33 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.threadpool.impl; + +import org.opendaylight.controller.config.api.JmxAttributeValidationException; +import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper; + +/** +* +*/ +public final class ScheduledThreadPoolModule extends + org.opendaylight.controller.config.yang.threadpool.impl.AbstractScheduledThreadPoolModule { + + public ScheduledThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public ScheduledThreadPoolModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + ScheduledThreadPoolModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + JmxAttributeValidationException.checkNotNull(getMaxThreadCount(), maxThreadCountJmxAttribute); + JmxAttributeValidationException.checkCondition(getMaxThreadCount() > 0, "must be greater than zero", + maxThreadCountJmxAttribute); + } + + @Override + public java.lang.AutoCloseable createInstance() { + return new ScheduledThreadPoolWrapper(getMaxThreadCount(), getThreadFactoryDependency()); + } +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java new file mode 100644 index 0000000000..489af822e2 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java @@ -0,0 +1,18 @@ +/** + * 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 { + +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang index 4695564144..a2366f285a 100644 --- a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang +++ b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang @@ -83,8 +83,6 @@ module threadpool-impl { } } - - rpc get-dead-events-count { config:java-name-prefix countDeadEvents; input { @@ -100,5 +98,98 @@ module threadpool-impl { } } } + + 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 threadfactory-naming { + when "/config:modules/config:module/config:type = 'threadfactory-naming'"; + leaf name-prefix { + type string; + } + } + } + + 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; + } + } + } + } + } + + 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; + } + } + } + } + } } -- 2.36.6