Added configuration modules and closeable wrappers for FixedThreadPool, FlexibleThrea... 01/2501/1
authorMilos Fabian <milfabia@cisco.com>
Thu, 7 Nov 2013 08:41:42 +0000 (09:41 +0100)
committerMilos Fabian <milfabia@cisco.com>
Thu, 7 Nov 2013 11:46:49 +0000 (12:46 +0100)
Change-Id: I6d4b84662c4b6f418c84e0dd9f026f45ad2c8201
Signed-off-by: Milos Fabian <milfabia@cisco.com>
13 files changed:
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FixedThreadPoolWrapper.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/FlexibleThreadPoolWrapper.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/NamingThreadPoolFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/ScheduledThreadPoolWrapper.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FixedThreadPoolModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/FlexibleThreadPoolModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModule.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/ScheduledThreadPoolModuleFactory.java [new file with mode: 0644]
opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang

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 (file)
index 0000000..ca03443
--- /dev/null
@@ -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 (file)
index 0000000..3dfa6e2
--- /dev/null
@@ -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<Runnable>(), 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 (file)
index 0000000..2e27d6c
--- /dev/null
@@ -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 (file)
index 0000000..ee3399e
--- /dev/null
@@ -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 (file)
index 0000000..a0a9add
--- /dev/null
@@ -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 (file)
index 0000000..2803448
--- /dev/null
@@ -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 (file)
index 0000000..47b4eec
--- /dev/null
@@ -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 (file)
index 0000000..ef6ebd2
--- /dev/null
@@ -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 (file)
index 0000000..a761727
--- /dev/null
@@ -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 (file)
index 0000000..5e70afb
--- /dev/null
@@ -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 (file)
index 0000000..42739b4
--- /dev/null
@@ -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 (file)
index 0000000..489af82
--- /dev/null
@@ -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 {
+
+}
index 469556414492672784e67387a93ac577eb8c5076..a2366f285a0c0b8682b1093f18fb5ee184c9cde3 100644 (file)
@@ -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;
+                                       }
+                               }
+                       }
+               }
+       }
 }