c5b726cd3c6bdc7bbb8a22dac88ab303449106b9
[controller.git] / opendaylight / config / netty-threadgroup-config / src / main / java / org / opendaylight / controller / config / yang / netty / threadgroup / NettyThreadgroupModule.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 /**
10 * Generated file
11
12 * Generated from: yang module name: nsos-threadpool  yang module local name: netty-threadgroup-fixed
13 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
14 * Generated at: Fri Nov 08 08:31:45 CET 2013
15 *
16 * Do not modify this file unless it is present under src/main directory
17 */
18 package org.opendaylight.controller.config.yang.netty.threadgroup;
19
20 import io.netty.channel.nio.NioEventLoopGroup;
21 import java.util.concurrent.TimeUnit;
22 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
23
24 /**
25 *
26 */
27 public final class NettyThreadgroupModule extends org.opendaylight.controller.config.yang.netty.threadgroup.AbstractNettyThreadgroupModule
28 {
29     public NettyThreadgroupModule(org.opendaylight.controller.config.api.ModuleIdentifier name, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
30         super(name, dependencyResolver);
31     }
32
33     public NettyThreadgroupModule(org.opendaylight.controller.config.api.ModuleIdentifier name, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, NettyThreadgroupModule oldModule, java.lang.AutoCloseable oldInstance) {
34         super(name, dependencyResolver, oldModule, oldInstance);
35     }
36
37     @Override
38     public void validate(){
39         if(getThreadCount()!=null) {
40             JmxAttributeValidationException.checkCondition(getThreadCount() > 0, "value must be greater than 0",
41                     threadCountJmxAttribute);
42         }
43     }
44
45     @Override
46     public java.lang.AutoCloseable createInstance() {
47         return getThreadCount()==null ? new NioEventLoopGroupCloseable() : new NioEventLoopGroupCloseable(getThreadCount());
48     }
49
50
51     private class NioEventLoopGroupCloseable extends NioEventLoopGroup implements AutoCloseable {
52
53
54         public NioEventLoopGroupCloseable(int threadCount) {
55             super(threadCount);
56         }
57
58         public NioEventLoopGroupCloseable() {
59             super();
60         }
61
62         @Override
63         public void close() throws Exception {
64             shutdownGracefully(0, 1, TimeUnit.SECONDS);
65         }
66     }
67 }