<module>yang-test</module>
<module>logback-config</module>
<module>threadpool-config-api</module>
+ <module>threadpool-config-impl</module>
</modules>
<profiles>
--- /dev/null
+<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>threadpool-config-impl</artifactId>
+ <name>${project.artifactId}</name>
+ <packaging>bundle</packaging>
+ <prerequisites>
+ <maven>3.0.4</maven>
+ </prerequisites>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>config-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>threadpool-config-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Private-Package>
+ org.opendaylight.controller.config.threadpool.util,
+ javax.annotation.*,
+ org.opendaylight.controller.config.yang.threadpool.impl,
+ </Private-Package>
+ <Import-Package>
+ org.opendaylight.controller.config.api.*,
+ org.opendaylight.controller.config.spi.*,
+ org.opendaylight.controller.config.threadpool,
+ org.opendaylight.controller.config.yang.threadpool,
+ javax.management,
+ org.osgi.framework,
+ org.slf4j,
+ com.google.common.*
+ </Import-Package>
+ <Export-Package>
+ org.opendaylight.controller.config.threadpool.util
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
--- /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.threadpool.util;
+
+import com.google.common.eventbus.AsyncEventBus;
+import com.google.common.eventbus.DeadEvent;
+import com.google.common.eventbus.Subscribe;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+import org.opendaylight.controller.config.threadpool.ThreadPool;
+import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusRuntimeMXBean;
+import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusRuntimeRegistration;
+import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusRuntimeRegistrator;
+
+/**
+ * Closeable version of {@link AsyncEventBus}.
+ */
+public class CloseableAsyncEventBus extends AsyncEventBus implements Closeable {
+ private final ThreadPool threadPool;
+ private final AsyncEventBusRuntimeRegistration rootRegistration;
+
+ public CloseableAsyncEventBus(String identifier, ThreadPool threadPool,
+ AsyncEventBusRuntimeRegistrator rootRegistrator) {
+ super(identifier, threadPool.getExecutor());
+ this.threadPool = threadPool;
+ rootRegistration = rootRegistrator.register(new AsyncEventBusRuntimeMXBean() {
+ private long deadEventsCounter = 0;
+
+ @Subscribe
+ public void increaseDeadEvents(DeadEvent deadEvent) {
+ deadEventsCounter++;
+ }
+
+ @Override
+ public Long countDeadEvents() {
+ return deadEventsCounter;
+ }
+
+ });
+ }
+
+ public ThreadPool getThreadPool() {
+ return threadPool;
+ }
+
+ @Override
+ public void close() throws IOException {
+ rootRegistration.close();
+ }
+
+}
--- /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.threadpool.util;
+
+import java.io.Closeable;
+
+import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeMXBean;
+import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeRegistration;
+import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeRegistrator;
+
+import com.google.common.eventbus.DeadEvent;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+/**
+ * Closeable {@link EventBus}.
+ */
+public class CloseableEventBus extends EventBus implements Closeable {
+
+ private final EventBusRuntimeRegistration rootRegistration;
+
+ public CloseableEventBus(String identifier, EventBusRuntimeRegistrator rootRegistrator) {
+ super(identifier);
+ rootRegistration = rootRegistrator.register(new EventBusRuntimeMXBean() {
+ private long deadEventsCounter = 0;
+
+ @Subscribe
+ public void increaseDeadEvents(DeadEvent deadEvent) {
+ deadEventsCounter++;
+ }
+
+ @Override
+ public Long countDeadEvents() {
+ return deadEventsCounter;
+ }
+ });
+
+ }
+
+ @Override
+ public void close() {
+ rootRegistration.close();
+
+ }
+}
--- /dev/null
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl yang module local name: async-eventbus
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Tue Nov 05 15:40:46 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.threadpool.util.CloseableAsyncEventBus;
+
+/**
+*
+*/
+public final class AsyncEventBusModule extends
+ org.opendaylight.controller.config.yang.threadpool.impl.AbstractAsyncEventBusModule {
+
+ public AsyncEventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public AsyncEventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ AsyncEventBusModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void validate() {
+ super.validate();
+ // Add custom validation for module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ return new CloseableAsyncEventBus(getIdentifier().toString(), getThreadpoolDependency(),
+ getRootRuntimeBeanRegistratorWrapper());
+ }
+}
--- /dev/null
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl yang module local name: async-eventbus
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Tue Nov 05 15:40:46 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 AsyncEventBusModuleFactory extends
+ org.opendaylight.controller.config.yang.threadpool.impl.AbstractAsyncEventBusModuleFactory {
+
+}
--- /dev/null
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl yang module local name: eventbus
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Tue Nov 05 15:40:46 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.threadpool.util.CloseableEventBus;
+
+/**
+*
+*/
+public final class EventBusModule extends
+ org.opendaylight.controller.config.yang.threadpool.impl.AbstractEventBusModule {
+
+ public EventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public EventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, EventBusModule oldModule,
+ java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void validate() {
+ super.validate();
+ // Add custom validation for module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ return new CloseableEventBus(getIdentifier().toString(), getRootRuntimeBeanRegistratorWrapper());
+ }
+}
--- /dev/null
+/**
+ * Generated file
+
+ * Generated from: yang module name: threadpool-impl yang module local name: eventbus
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Tue Nov 05 15:40:46 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 EventBusModuleFactory extends
+ org.opendaylight.controller.config.yang.threadpool.impl.AbstractEventBusModuleFactory {
+
+}
--- /dev/null
+// vi: set smarttab et sw=4 tabstop=4:
+module threadpool-impl {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl";
+ prefix "th-java";
+
+ import threadpool { prefix th; revision-date 2013-04-09; }
+ import config { prefix config; revision-date 2013-04-05; }
+ import rpc-context { prefix rpcx; revision-date 2013-06-17; }
+
+ organization "Cisco Systems, Inc.";
+
+ contact "Robert Varga <rovarga@cisco.com>";
+
+ description
+ "This module contains the base YANG definitions for
+ thread services pure Java implementation.
+
+ 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
+ http://www.eclipse.org/legal/epl-v10.html";
+
+ revision "2013-04-05" {
+ description
+ "Updated to work with new anchors.";
+ }
+
+ revision "2013-04-03" {
+ description
+ "Initial revision by Anton Tkacik, Tomas Olvecky and
+ Robert Varga.";
+ }
+
+ identity eventbus {
+ base config:module-type;
+ config:provided-service th:eventbus;
+ config:java-name-prefix EventBus;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case eventbus {
+ when "/config:modules/config:module/config:type = 'eventbus'";
+ // No real configuration
+ }
+ }
+
+ augment "/config:modules/config:module/config:state" {
+ case eventbus {
+ when "/config:modules/config:module/config:type = 'eventbus'";
+ rpcx:rpc-context-instance "event-bus-rpc";
+ }
+ }
+
+ identity event-bus-rpc;
+
+ identity async-eventbus {
+ base config:module-type;
+ config:provided-service th:eventbus;
+ config:java-name-prefix AsyncEventBus;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case async-eventbus {
+ when "/config:modules/config:module/config:type = 'async-eventbus'";
+ container threadpool {
+ uses config:service-ref {
+ refine type {
+ //mandatory true;
+ config:required-identity th:threadpool;
+ }
+ }
+ }
+ }
+ }
+
+ augment "/config:modules/config:module/config:state" {
+ case async-eventbus {
+ when "/config:modules/config:module/config:type = 'async-eventbus'";
+ rpcx:rpc-context-instance "event-bus-rpc";
+ }
+ }
+
+
+
+ rpc get-dead-events-count {
+ config:java-name-prefix countDeadEvents;
+ input {
+ uses rpcx:rpc-context-ref {
+ refine context-instance {
+ rpcx:rpc-context-instance event-bus-rpc;
+ }
+ }
+ }
+ output {
+ leaf result {
+ type uint32;
+ }
+ }
+ }
+}
+