From: Tom Pantelis Date: Wed, 5 Jul 2017 18:35:41 +0000 (-0400) Subject: Bug 6794: Remove threadpool config modules X-Git-Tag: release/nitrogen~55 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=c7e4aae58a1f4ce00e9ae06354290d1e5ceb0bab Bug 6794: Remove threadpool config modules With the removal of the CSS netconf connector, the threadpool config modules are no longer used so remove them. The *Wrapper classes are used via blueprint so they remain. Also removed the eventbus config modules which were deprecated in Carbon. Change-Id: Ic528e5817a9f5ccdb67ef41987128ead4db51cbd Signed-off-by: Tom Pantelis --- diff --git a/opendaylight/config/netty-timer-config/src/main/yang/netty-timer.yang b/opendaylight/config/netty-timer-config/src/main/yang/netty-timer.yang index c9ada0c3d9..69a7a5248f 100644 --- a/opendaylight/config/netty-timer-config/src/main/yang/netty-timer.yang +++ b/opendaylight/config/netty-timer-config/src/main/yang/netty-timer.yang @@ -6,7 +6,6 @@ module netty-timer { import config { prefix config; revision-date 2013-04-05; } import netty { prefix netty; revision-date 2013-11-19; } - import threadpool { prefix th; revision-date 2013-04-09; } organization "Cisco Systems, Inc."; @@ -48,16 +47,6 @@ module netty-timer { status deprecated; type uint16; } - - container thread-factory { - status deprecated; - uses config:service-ref { - refine type { - mandatory false; - config:required-identity th:threadfactory; - } - } - } } } -} \ No newline at end of file +} diff --git a/opendaylight/config/netty-timer-config/src/test/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerModuleTest.java b/opendaylight/config/netty-timer-config/src/test/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerModuleTest.java deleted file mode 100644 index 87d621f181..0000000000 --- a/opendaylight/config/netty-timer-config/src/test/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerModuleTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.timer; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import io.netty.util.Timer; -import javax.management.InstanceAlreadyExistsException; -import javax.management.InstanceNotFoundException; -import javax.management.ObjectName; -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 org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory; -import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean; -import org.osgi.framework.Filter; -import org.osgi.framework.ServiceListener; -import org.osgi.framework.ServiceReference; - -public class HashedWheelTimerModuleTest extends AbstractConfigTest { - - private HashedWheelTimerModuleFactory factory; - private NamingThreadFactoryModuleFactory threadFactory; - private final String instanceName = "hashed-wheel-timer1"; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Before - public void setUp() throws Exception { - factory = new HashedWheelTimerModuleFactory(); - threadFactory = new NamingThreadFactoryModuleFactory(); - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, factory, threadFactory)); - - Filter mockFilter = mock(Filter.class); - doReturn("mock").when(mockFilter).toString(); - doReturn(mockFilter).when(mockedContext).createFilter(anyString()); - doNothing().when(mockedContext).addServiceListener(any(ServiceListener.class), anyString()); - ServiceReference mockServiceRef = mock(ServiceReference.class); - doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext). - getServiceReferences(anyString(), anyString()); - doReturn(mock(Timer.class)).when(mockedContext).getService(mockServiceRef); - } - - public void testValidationExceptionTickDuration() throws InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - try { - createInstance(transaction, instanceName, 0L, 10, true); - transaction.validateConfig(); - fail(); - } catch (final ValidationException e) { - assertTrue(e.getMessage().contains("TickDuration value must be greater than 0")); - } - } - - public void testValidationExceptionTicksPerWheel() throws InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - try { - createInstance(transaction, instanceName, 500L, 0, true); - transaction.validateConfig(); - fail(); - } catch (final ValidationException e) { - assertTrue(e.getMessage().contains("TicksPerWheel value must be greater than 0")); - } - } - - @Test - public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException, - ConflictingVersionException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createInstance(transaction, instanceName, 500L, 10, true); - createInstance(transaction, instanceName + 1, null, null, false); - createInstance(transaction, instanceName + 2, 500L, 10, false); - createInstance(transaction, instanceName + 3, 500L, null, false); - transaction.validateConfig(); - CommitStatus status = transaction.commit(); - - assertBeanCount(4, factory.getImplementationName()); - assertStatus(status, 5, 0, 0); - } - - @Test - public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, - ValidationException { - - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createInstance(transaction, instanceName, 500L, 10, true); - - transaction.commit(); - - transaction = configRegistryClient.createTransaction(); - assertBeanCount(1, factory.getImplementationName()); - CommitStatus status = transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - assertStatus(status, 0, 0, 2); - } - - @Test - public void testReconfigure() throws InstanceAlreadyExistsException, ConflictingVersionException, - ValidationException, InstanceNotFoundException { - - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createInstance(transaction, instanceName, 500L, 10, true); - transaction.commit(); - - transaction = configRegistryClient.createTransaction(); - assertBeanCount(1, factory.getImplementationName()); - HashedWheelTimerModuleMXBean mxBean = transaction.newMBeanProxy( - transaction.lookupConfigBean(factory.getImplementationName(), instanceName), - HashedWheelTimerModuleMXBean.class); - mxBean.setTicksPerWheel(20); - CommitStatus status = transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - assertStatus(status, 0, 1, 1); - } - - private ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String instanceName, - final Long tickDuration, final Integer ticksPerWheel, final boolean hasThreadfactory) - throws InstanceAlreadyExistsException { - ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName); - HashedWheelTimerModuleMXBean mxBean = transaction - .newMBeanProxy(nameCreated, HashedWheelTimerModuleMXBean.class); - mxBean.setTickDuration(tickDuration); - mxBean.setTicksPerWheel(ticksPerWheel); - if (hasThreadfactory) { - mxBean.setThreadFactory(createThreadfactoryInstance(transaction, "thread-factory1", "th")); - } - return nameCreated; - } - - private ObjectName createThreadfactoryInstance(final ConfigTransactionJMXClient transaction, final String instanceName, - final String namePrefix) throws InstanceAlreadyExistsException { - ObjectName nameCreated = transaction.createModule(threadFactory.getImplementationName(), instanceName); - NamingThreadFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, - NamingThreadFactoryModuleMXBean.class); - mxBean.setNamePrefix(namePrefix); - return nameCreated; - } - -} diff --git a/opendaylight/config/threadpool-config-api/pom.xml b/opendaylight/config/threadpool-config-api/pom.xml index 86ba22605d..9a46d34bc8 100644 --- a/opendaylight/config/threadpool-config-api/pom.xml +++ b/opendaylight/config/threadpool-config-api/pom.xml @@ -4,9 +4,9 @@ 4.0.0 org.opendaylight.controller - config-plugin-parent + config-subsystem 0.7.0-SNAPSHOT - ../config-plugin-parent + ../ threadpool-config-api bundle @@ -17,10 +17,6 @@ com.google.guava guava - - org.opendaylight.controller - config-api - diff --git a/opendaylight/config/threadpool-config-api/src/main/yang/threadpool.yang b/opendaylight/config/threadpool-config-api/src/main/yang/threadpool.yang deleted file mode 100644 index 4c34513591..0000000000 --- a/opendaylight/config/threadpool-config-api/src/main/yang/threadpool.yang +++ /dev/null @@ -1,76 +0,0 @@ -// vi: set smarttab et sw=4 tabstop=4: -module threadpool { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool"; - prefix "th"; - - import config { prefix config; revision-date 2013-04-05; } - - organization "Cisco Systems, Inc."; - - contact "Robert Varga "; - - description - "This module contains the base YANG definitions for - 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 - http://www.eclipse.org/legal/epl-v10.html"; - - revision "2013-04-09" { - description - "Added eventbus service."; - } - - revision "2013-04-05" { - description - "Updated with YANG extension for Java class specification."; - } - - revision "2013-04-03" { - description - "Initial revision by Anton Tkacik, Tomas Olvecky and - Robert Varga."; - } - - identity eventbus { - description - "Service representing an event bus. The service acts as message - router between event producers and event consumers"; - - base "config:service-type"; - config:java-class "com.google.common.eventbus.EventBus"; - } - - identity threadfactory { - description - "Service representing a ThreadFactory instance. It is directly - useful in Java world, where various library pieces need to create - threads and you may want to inject a customized thread - implementation."; - - base "config:service-type"; - config:java-class "java.util.concurrent.ThreadFactory"; - } - - identity threadpool { - description - "A simple pool of threads able to execute work."; - - base "config:service-type"; - config:java-class "org.opendaylight.controller.config.threadpool.ThreadPool"; - } - - identity scheduled-threadpool { - description - "An extension of the simple pool of threads able to schedule - work to be executed at some point in time."; - - base "threadpool"; - config:java-class "org.opendaylight.controller.config.threadpool.ScheduledThreadPool"; - } -} diff --git a/opendaylight/config/threadpool-config-impl/pom.xml b/opendaylight/config/threadpool-config-impl/pom.xml index 99f43cfee0..d0313976e3 100644 --- a/opendaylight/config/threadpool-config-impl/pom.xml +++ b/opendaylight/config/threadpool-config-impl/pom.xml @@ -4,19 +4,15 @@ 4.0.0 org.opendaylight.controller - config-plugin-parent + config-subsystem 0.7.0-SNAPSHOT - ../config-plugin-parent + ../ threadpool-config-impl bundle ${project.artifactId} - - ${project.groupId} - config-api - ${project.groupId} threadpool-config-api @@ -33,24 +29,6 @@ org.slf4j slf4j-api - - - - org.opendaylight.controller - config-manager - test-jar - test - - - org.opendaylight.controller - config-manager - test - - - org.opendaylight.controller - config-util - test - diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableAsyncEventBus.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableAsyncEventBus.java deleted file mode 100644 index 0b8f48c2fe..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableAsyncEventBus.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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}. - */ -/** - * To be removed in Nitrogen - */ -@Deprecated -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(); - } - -} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableEventBus.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableEventBus.java deleted file mode 100644 index ab61bfe723..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableEventBus.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.DeadEvent; -import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; -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; - -/** - * Closeable {@link EventBus}. - */ -/** - * To be removed in Nitrogen - */ -@Deprecated -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(); - - } -} 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 index dcb121abfa..2dad26490b 100644 --- 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 @@ -19,10 +19,6 @@ import org.opendaylight.controller.config.threadpool.ThreadPool; * Implementation of {@link ThreadPool} using fixed number of threads wraps * {@link ExecutorService}. */ -/** - * To be removed in Nitrogen - */ -@Deprecated public class FixedThreadPoolWrapper implements ThreadPool, Closeable { private final ThreadPoolExecutor executor; diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModule.java deleted file mode 100644 index 5183015784..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModule.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 - */ - -/** - * 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; - -/** -* To be removed in Nitrogen -*/ -@Deprecated -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()); - } -} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModuleFactory.java deleted file mode 100644 index 23be62d4bf..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModuleFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 - */ - -/** - * 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; - -/** - * To be removed in Nitrogen - */ -@Deprecated -public class AsyncEventBusModuleFactory extends - org.opendaylight.controller.config.yang.threadpool.impl.AbstractAsyncEventBusModuleFactory { - -} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModule.java deleted file mode 100644 index 70b7a5f737..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModule.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 - */ - -/** - * 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; - -/** - * To be removed in Nitrogen - */ -@Deprecated -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()); - } -} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModuleFactory.java deleted file mode 100644 index 38ec21c809..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModuleFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 - */ - -/** - * 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; - -/** - * To be removed in Nitrogen - */ -@Deprecated -public class EventBusModuleFactory extends - org.opendaylight.controller.config.yang.threadpool.impl.AbstractEventBusModuleFactory { - -} 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 deleted file mode 100644 index 53320ae147..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModule.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 - */ - -/** - * 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 deleted file mode 100644 index ff81bc82ae..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/NamingThreadFactoryModuleFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - */ - -/** - * 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/fixed/FixedThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/fixed/FixedThreadPoolModule.java deleted file mode 100644 index 95e11b90be..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/fixed/FixedThreadPoolModule.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 - */ - -/** -* Generated file - -* Generated from: yang module name: threadpool-impl-fixed yang module local name: threadpool-fixed -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Sun Dec 01 17:13:32 CET 2013 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.threadpool.impl.fixed; - -import org.opendaylight.controller.config.api.JmxAttributeValidationException; -import org.opendaylight.controller.config.threadpool.util.FixedThreadPoolWrapper; - -/** - * To be removed in Nitrogen - */ -@Deprecated -public final class FixedThreadPoolModule extends org.opendaylight.controller.config.yang.threadpool.impl.fixed.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/fixed/FixedThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/fixed/FixedThreadPoolModuleFactory.java deleted file mode 100644 index 82117e374a..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/fixed/FixedThreadPoolModuleFactory.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - */ - -/** -* Generated file - -* Generated from: yang module name: threadpool-impl-fixed yang module local name: threadpool-fixed -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Sun Dec 01 17:13:32 CET 2013 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.threadpool.impl.fixed; - -/** - * To be removed in Nitrogen - */ -@Deprecated -public class FixedThreadPoolModuleFactory extends org.opendaylight.controller.config.yang.threadpool.impl.fixed.AbstractFixedThreadPoolModuleFactory -{ - - -} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/flexible/FlexibleThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/flexible/FlexibleThreadPoolModule.java deleted file mode 100644 index eb40073db6..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/flexible/FlexibleThreadPoolModule.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 - */ - -/** -* Generated file - -* Generated from: yang module name: threadpool-impl-flexible yang module local name: threadpool-flexible -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Sun Dec 01 17:13:32 CET 2013 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.threadpool.impl.flexible; - -import com.google.common.base.Optional; -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.flexible.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); - - if(getQueueCapacity() != null) { - JmxAttributeValidationException.checkCondition(getQueueCapacity() > 0, "Queue capacity cannot be < 1", queueCapacityJmxAttribute); - } - } - - @Override - public java.lang.AutoCloseable createInstance() { - return new FlexibleThreadPoolWrapper(getMinThreadCount(), getMaxThreadCount(), getKeepAliveMillis(), - TimeUnit.MILLISECONDS, getThreadFactoryDependency(), Optional.fromNullable(getQueueCapacity())); - } -} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/flexible/FlexibleThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/flexible/FlexibleThreadPoolModuleFactory.java deleted file mode 100644 index 64b2a07fff..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/flexible/FlexibleThreadPoolModuleFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 - */ - -/** -* Generated file - -* Generated from: yang module name: threadpool-impl-flexible yang module local name: threadpool-flexible -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Sun Dec 01 17:13:32 CET 2013 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.threadpool.impl.flexible; - -/** -* -*/ -public class FlexibleThreadPoolModuleFactory extends org.opendaylight.controller.config.yang.threadpool.impl.flexible.AbstractFlexibleThreadPoolModuleFactory -{ - - -} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModule.java deleted file mode 100644 index c6330e2e59..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModule.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 - */ - -/** -* Generated file - -* Generated from: yang module name: threadpool-impl-scheduled yang module local name: threadpool-scheduled -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Sun Dec 01 17:13:32 CET 2013 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.threadpool.impl.scheduled; - -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.scheduled.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/scheduled/ScheduledThreadPoolModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModuleFactory.java deleted file mode 100644 index 69f5b1f9ac..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/scheduled/ScheduledThreadPoolModuleFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 - */ - -/** -* Generated file - -* Generated from: yang module name: threadpool-impl-scheduled yang module local name: threadpool-scheduled -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Sun Dec 01 17:13:32 CET 2013 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.threadpool.impl.scheduled; - -/** -* -*/ -public class ScheduledThreadPoolModuleFactory extends org.opendaylight.controller.config.yang.threadpool.impl.scheduled.AbstractScheduledThreadPoolModuleFactory -{ - - -} diff --git a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-fixed.yang b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-fixed.yang deleted file mode 100644 index 85e4c92409..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-fixed.yang +++ /dev/null @@ -1,57 +0,0 @@ -module threadpool-impl-fixed { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:fixed"; - prefix "th-java-fixed"; - - 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 "; - - 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-12-01" { - description - "Initial revision"; - } - - - identity threadpool-fixed { - status deprecated; - base config:module-type; - config:provided-service th:threadpool; - config:java-name-prefix FixedThreadPool; - } - - augment "/config:modules/config:module/config:configuration" { - status deprecated; - 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; - } - } - } - } - } -} - diff --git a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-flexible.yang b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-flexible.yang deleted file mode 100644 index c124f6388f..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-flexible.yang +++ /dev/null @@ -1,65 +0,0 @@ -module threadpool-impl-flexible { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible"; - prefix "th-java-flexible"; - - 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 "; - - 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-12-01" { - description - "Initial revision"; - } - - 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; - } - - leaf queueCapacity { - type uint16; - mandatory false; - description "Capacity of queue that holds waiting tasks"; - } - - container threadFactory { - uses config:service-ref { - refine type { - // mandatory true; - config:required-identity th:threadfactory; - } - } - } - } - } -} diff --git a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-scheduled.yang b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-scheduled.yang deleted file mode 100644 index 5bf277b328..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl-scheduled.yang +++ /dev/null @@ -1,53 +0,0 @@ -module threadpool-impl-scheduled { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:scheduled"; - prefix "th-java-scheduled"; - - 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 "; - - 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-12-01" { - description - "Initial revision"; - } - - 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; - } - } - } - } - } -} 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 deleted file mode 100644 index 8ae7d88932..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang +++ /dev/null @@ -1,122 +0,0 @@ -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 "; - - 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; - status deprecated; - } - - augment "/config:modules/config:module/config:configuration" { - status deprecated; - case eventbus { - when "/config:modules/config:module/config:type = 'eventbus'"; - // No real configuration - } - } - - augment "/config:modules/config:module/config:state" { - status deprecated; - 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; - status deprecated; - } - - augment "/config:modules/config:module/config:configuration" { - status deprecated; - 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" { - status deprecated; - 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; - } - } - } - - 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; - } - } - } -} - diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/async/AsyncEventBusConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/async/AsyncEventBusConfigBeanTest.java deleted file mode 100644 index 89a0182d00..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/async/AsyncEventBusConfigBeanTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.async; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import javax.management.InstanceAlreadyExistsException; -import javax.management.ObjectName; -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.ClassBasedModuleFactory; -import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver; -import org.opendaylight.controller.config.threadpool.scheduled.TestingScheduledThreadPoolModule; -import org.opendaylight.controller.config.util.ConfigTransactionJMXClient; -import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusModuleFactory; -import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusModuleMXBean; - -public class AsyncEventBusConfigBeanTest extends AbstractConfigTest { - - private AsyncEventBusModuleFactory factory; - private final String instanceName = "async1"; - private final String poolImplName = "fixed1"; - - @Before - public void setUp() { - - ClassBasedModuleFactory scheduledThreadPoolConfigFactory = createClassBasedCBF( - TestingScheduledThreadPoolModule.class, poolImplName); - - factory = new AsyncEventBusModuleFactory(); - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory, - scheduledThreadPoolConfigFactory)); - } - - @Test - public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException, - ConflictingVersionException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createAsynced(transaction, instanceName, transaction.createModule(poolImplName, "pool-test")); - transaction.validateConfig(); - CommitStatus status = transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - assertStatus(status, 2, 0, 0); - } - - @Test - public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, - ValidationException { - - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createAsynced(transaction, instanceName, transaction.createModule(poolImplName, "pool-test")); - - transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - - transaction = configRegistryClient.createTransaction(); - CommitStatus status = transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - assertStatus(status, 0, 0, 2); - - } - - @Test - public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException, - InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - ObjectName poolCB = transaction.createModule(poolImplName, "pool-test"); - createAsynced(transaction, instanceName, poolCB); - transaction.commit(); - - transaction = configRegistryClient.createTransaction(); - try { - createAsynced(transaction, instanceName, poolCB); - fail(); - } catch (InstanceAlreadyExistsException e) { - assertThat( - e.getMessage(), - containsString("There is an instance registered with name ModuleIdentifier{factoryName='async-eventbus', instanceName='async1'}")); - } - } - - private ObjectName createAsynced(ConfigTransactionJMXClient transaction, String instanceName, ObjectName threadPool) - throws InstanceAlreadyExistsException { - ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName); - AsyncEventBusModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, AsyncEventBusModuleMXBean.class); - mxBean.setThreadpool(threadPool); - return nameCreated; - } - -} diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/SyncEventBusConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/SyncEventBusConfigBeanTest.java deleted file mode 100644 index ed3ede01c6..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/SyncEventBusConfigBeanTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.eventbus; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import javax.management.InstanceAlreadyExistsException; -import javax.management.ObjectName; -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 org.opendaylight.controller.config.yang.threadpool.impl.EventBusModuleFactory; - -public class SyncEventBusConfigBeanTest extends AbstractConfigTest { - - private EventBusModuleFactory factory; - private final String instanceName = "sync1"; - - @Before - public void setUp() { - - factory = new EventBusModuleFactory(); - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory)); - } - - @Test - public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException, - ConflictingVersionException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createSynced(transaction, instanceName); - transaction.validateConfig(); - CommitStatus status = transaction.commit(); - - assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size()); - assertEquals(1, status.getNewInstances().size()); - assertEquals(0, status.getRecreatedInstances().size()); - assertEquals(0, status.getReusedInstances().size()); - // TODO test dead event collector - } - - @Test - public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, - ValidationException { - - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createSynced(transaction, instanceName); - - transaction.commit(); - - assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size()); - - transaction = configRegistryClient.createTransaction(); - CommitStatus status = transaction.commit(); - - assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size()); - assertEquals(0, status.getNewInstances().size()); - assertEquals(0, status.getRecreatedInstances().size()); - assertEquals(1, status.getReusedInstances().size()); - - } - - @Test - public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - try { - createSynced(transaction, instanceName); - transaction.commit(); - } catch (InstanceAlreadyExistsException e1) { - fail(); - } - - transaction = configRegistryClient.createTransaction(); - try { - createSynced(transaction, instanceName); - fail(); - } catch (InstanceAlreadyExistsException e) { - assertThat( - e.getMessage(), - containsString("There is an instance registered with name ModuleIdentifier{factoryName='eventbus', instanceName='sync1'}")); - } - } - - private ObjectName createSynced(ConfigTransactionJMXClient transaction, String instanceName) - throws InstanceAlreadyExistsException { - ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName); - return nameCreated; - } -} diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/TestingEventBusModule.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/TestingEventBusModule.java deleted file mode 100644 index 4431f78edb..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/TestingEventBusModule.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.eventbus; - -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; - -import org.opendaylight.controller.config.api.DynamicMBeanWithInstance; -import org.opendaylight.controller.config.api.ModuleIdentifier; -import org.opendaylight.controller.config.manager.impl.AbstractMockedModule; -import org.opendaylight.controller.config.spi.Module; -import org.opendaylight.controller.config.threadpool.util.CloseableEventBus; -import org.opendaylight.controller.config.yang.threadpool.EventBusServiceInterface; -import org.opendaylight.controller.config.yang.threadpool.impl.EventBusModuleMXBean; - -public class TestingEventBusModule extends AbstractMockedModule implements Module, EventBusServiceInterface, - EventBusModuleMXBean { - - public TestingEventBusModule(DynamicMBeanWithInstance old, ModuleIdentifier id) { - super(old, id); - } - - @Override - protected AutoCloseable prepareMockedInstance() throws Exception { - CloseableEventBus bus = mock(CloseableEventBus.class); - doNothing().when(bus).close(); - return bus; - } - -} diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/FixedThreadPoolConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/FixedThreadPoolConfigBeanTest.java deleted file mode 100644 index 5bf4ac2d7b..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/FixedThreadPoolConfigBeanTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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.fixed; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.lang.management.ManagementFactory; -import java.lang.management.ThreadInfo; -import java.lang.management.ThreadMXBean; -import java.util.ArrayList; -import java.util.List; -import javax.management.InstanceAlreadyExistsException; -import javax.management.InstanceNotFoundException; -import javax.management.ObjectName; -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 org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory; -import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean; -import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleFactory; -import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleMXBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FixedThreadPoolConfigBeanTest extends AbstractConfigTest { - private static final Logger LOG = LoggerFactory.getLogger(FixedThreadPoolConfigBeanTest.class); - - private FixedThreadPoolModuleFactory factory; - private final String nameInstance = "fixedInstance"; - private ObjectName threadFactoryON; - - @Before - public void setUp() { - factory = new FixedThreadPoolModuleFactory(); - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, factory, - new NamingThreadFactoryModuleFactory())); - } - - @Test - public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException, - ConflictingVersionException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createFixed(transaction, nameInstance, 2, nameInstance); - - transaction.validateConfig(); - CommitStatus status = transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - assertStatus(status, 2, 0, 0); - } - - @Test - public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, - ValidationException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createFixed(transaction, nameInstance, 4, nameInstance); - - transaction.validateConfig(); - transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - - transaction = configRegistryClient.createTransaction(); - NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON, NamingThreadFactoryModuleMXBean.class); - namingThreadFactoryModuleMXBean.setNamePrefix("newPrefix"); - CommitStatus status = transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - assertStatus(status, 0, 2, 0); - } - - @Test - public void testNegative() throws ConflictingVersionException, ValidationException, InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createFixed(transaction, nameInstance, 5, nameInstance); - transaction.commit(); - - transaction = configRegistryClient.createTransaction(); - try { - createFixed(transaction, nameInstance, 0, nameInstance); - fail(); - } catch (InstanceAlreadyExistsException e) { - assertThat( - e.getMessage(), - containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-fixed', instanceName='fixedInstance'}")); - } - } - - private int countThreadsByPrefix(String prefix) { - ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); - int result = 0; - List names = new ArrayList<>(); - for (ThreadInfo threadInfo : threadMXBean.dumpAllThreads(false, false)) { - names.add(threadInfo.getThreadName()); - if (threadInfo.getThreadName().startsWith(prefix)) { - result++; - } - } - LOG.info("Current threads {}", names); - return result; - } - - @Test - public void testDestroy() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException, - InstanceNotFoundException, InterruptedException { - - String prefix = org.apache.commons.lang3.RandomStringUtils.randomAlphabetic(10); - - int numberOfThreads = 100; - int threadCount1 = countThreadsByPrefix(prefix); - assertEquals(0, threadCount1); - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createFixed(transaction, nameInstance, numberOfThreads, prefix); - transaction.commit(); - int threadCount2 = countThreadsByPrefix(prefix); - assertEquals(numberOfThreads, threadCount2); - - transaction = configRegistryClient.createTransaction(); - transaction.destroyModule(factory.getImplementationName(), nameInstance); - CommitStatus status = transaction.commit(); - - assertBeanCount(0, factory.getImplementationName()); - assertStatus(status, 0, 0, 1); - - for (int i = 0; i < 60; i++) { - if (countThreadsByPrefix(prefix) == 0) { - return; - } - Thread.sleep(1000); - } - assertEquals(0, countThreadsByPrefix(prefix)); - } - - @Test - public void testValidationException() throws InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createFixed(transaction, nameInstance, -1, nameInstance); - try { - transaction.validateConfig(); - fail(); - } catch (ValidationException e) { - assertThat(e.getMessage(), containsString("MaxThreadCount must be greater than zero")); - } - } - - private ObjectName createFixed(ConfigTransactionJMXClient transaction, String name, int numberOfThreads, String prefix) - throws InstanceAlreadyExistsException { - ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), name); - FixedThreadPoolModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, FixedThreadPoolModuleMXBean.class); - mxBean.setMaxThreadCount(numberOfThreads); - - threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, "naming"); - NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON, - NamingThreadFactoryModuleMXBean.class); - namingThreadFactoryModuleMXBean.setNamePrefix(prefix); - - mxBean.setThreadFactory(threadFactoryON); - - return nameCreated; - } - -} diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/TestingFixedThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/TestingFixedThreadPoolModule.java deleted file mode 100644 index bd57fe98f6..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/TestingFixedThreadPoolModule.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.fixed; - -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; - -import java.util.concurrent.ExecutorService; -import org.opendaylight.controller.config.api.DynamicMBeanWithInstance; -import org.opendaylight.controller.config.api.ModuleIdentifier; -import org.opendaylight.controller.config.manager.impl.AbstractMockedModule; -import org.opendaylight.controller.config.spi.Module; -import org.opendaylight.controller.config.threadpool.util.FixedThreadPoolWrapper; -import org.opendaylight.controller.config.yang.threadpool.ThreadPoolServiceInterface; - -public class TestingFixedThreadPoolModule extends AbstractMockedModule implements ThreadPoolServiceInterface, Module { - - public TestingFixedThreadPoolModule(DynamicMBeanWithInstance old, ModuleIdentifier id) { - super(old, id); - } - - @Override - protected AutoCloseable prepareMockedInstance() throws Exception { - FixedThreadPoolWrapper pool = mock(FixedThreadPoolWrapper.class); - doNothing().when(pool).close(); - doReturn(mock(ExecutorService.class)).when(pool).getExecutor(); - return pool; - } -} diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/flexible/FlexibleThreadPoolConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/flexible/FlexibleThreadPoolConfigBeanTest.java deleted file mode 100644 index e40a0cbe3c..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/flexible/FlexibleThreadPoolConfigBeanTest.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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.flexible; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import javax.management.InstanceAlreadyExistsException; -import javax.management.InstanceNotFoundException; -import javax.management.ObjectName; -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 org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory; -import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean; -import org.opendaylight.controller.config.yang.threadpool.impl.flexible.FlexibleThreadPoolModuleFactory; -import org.opendaylight.controller.config.yang.threadpool.impl.flexible.FlexibleThreadPoolModuleMXBean; - -public class FlexibleThreadPoolConfigBeanTest extends AbstractConfigTest { - - private FlexibleThreadPoolModuleFactory flexibleFactory; - private final String instanceName = "flexible1"; - private final String threadFactoryName = "threadFactoryName"; - - @Before - public void setUp() { - - flexibleFactory = new FlexibleThreadPoolModuleFactory(); - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,flexibleFactory, - new NamingThreadFactoryModuleFactory())); - } - - @Test - public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException, - ConflictingVersionException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createFlexible(transaction, instanceName, threadFactoryName, 1, 20, 20); - transaction.validateConfig(); - CommitStatus status = transaction.commit(); - - assertBeanCount(1, flexibleFactory.getImplementationName()); - assertStatus(status, 2, 0, 0); - } - - @Test - public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, - ValidationException { - - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createFlexible(transaction, instanceName, threadFactoryName, 1, 20, 10); - - transaction.commit(); - - assertBeanCount(1, flexibleFactory.getImplementationName()); - - transaction = configRegistryClient.createTransaction(); - CommitStatus status = transaction.commit(); - - assertBeanCount(1, flexibleFactory.getImplementationName()); - assertStatus(status, 0, 0, 2); - - } - - @Test - public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - try { - createFlexible(transaction, instanceName, threadFactoryName, 1, 1, 2); - transaction.commit(); - } catch (InstanceAlreadyExistsException e1) { - fail(); - } - - transaction = configRegistryClient.createTransaction(); - try { - createFlexible(transaction, instanceName, "threadFactoryName1", 2, 2, 2); - fail(); - } catch (InstanceAlreadyExistsException e) { - assertThat( - e.getMessage(), - containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-flexible', instanceName='flexible1'}")); - } - } - - @Test - public void testValidationException() throws InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createFlexible(transaction, instanceName, threadFactoryName, 0, 10, 10); - - try { - transaction.validateConfig(); - fail(); - } catch (ValidationException e) { - assertThat(e.getMessage(), containsString("MinThreadCount must be greater than zero")); - } - } - - @Test - public void testValidationException2() throws InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createFlexible(transaction, instanceName, threadFactoryName, 0, 0, 10); - - try { - transaction.validateConfig(); - fail(); - } catch (ValidationException e) { - assertThat(e.getMessage(), containsString("KeepAliveMillis must be greater than zero")); - } - } - - @Test - public void testValidationException3() throws InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createFlexible(transaction, instanceName, threadFactoryName, 10, 50, 0); - - try { - transaction.validateConfig(); - fail(); - } catch (ValidationException e) { - assertThat(e.getMessage(), containsString("MaxThreadCount must be greater than zero")); - } - } - - private ObjectName createFlexible(ConfigTransactionJMXClient transaction, String instanceName, - String threadFactoryName, int minThreadCount, long keepAliveMillis, int maxThreadCount) - throws InstanceAlreadyExistsException { - - ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, threadFactoryName); - NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON, - NamingThreadFactoryModuleMXBean.class); - namingThreadFactoryModuleMXBean.setNamePrefix("prefix"); - - ObjectName flexibleON = transaction.createModule(flexibleFactory.getImplementationName(), instanceName); - FlexibleThreadPoolModuleMXBean mxBean = transaction.newMBeanProxy(flexibleON, - FlexibleThreadPoolModuleMXBean.class); - mxBean.setKeepAliveMillis(keepAliveMillis); - mxBean.setMaxThreadCount(maxThreadCount); - mxBean.setMinThreadCount(minThreadCount); - mxBean.setThreadFactory(threadFactoryON); - return flexibleON; - } - - @Test - public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException, - ConflictingVersionException, InstanceNotFoundException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createFlexible(transaction, instanceName, threadFactoryName, 2, 2, 2); - - transaction.commit(); - - transaction = configRegistryClient.createTransaction(); - ObjectName databaseNew = transaction.lookupConfigBean(flexibleFactory.getImplementationName(), instanceName); - FlexibleThreadPoolModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew, - FlexibleThreadPoolModuleMXBean.class); - proxy.setMaxThreadCount(99); - - CommitStatus status = transaction.commit(); - - assertBeanCount(1, flexibleFactory.getImplementationName()); - assertStatus(status, 0, 1, 1); - } - -} diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/NamingThreadPoolFactoryConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/NamingThreadPoolFactoryConfigBeanTest.java deleted file mode 100644 index be3d59bf39..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/NamingThreadPoolFactoryConfigBeanTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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.naming; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import javax.management.InstanceAlreadyExistsException; -import javax.management.InstanceNotFoundException; -import javax.management.ObjectName; -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 org.opendaylight.controller.config.yang.threadpool.ThreadFactoryServiceInterface; -import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory; -import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean; - -public class NamingThreadPoolFactoryConfigBeanTest extends AbstractConfigTest { - - private NamingThreadFactoryModuleFactory factory; - private final String instanceName = "named"; - - @Before - public void setUp() { - - factory = new NamingThreadFactoryModuleFactory(); - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, factory)); - } - - @Test - public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException, - ConflictingVersionException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createNamed(transaction, instanceName, "prefixes"); - transaction.validateConfig(); - CommitStatus status = transaction.commit(); - - assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size()); - assertEquals(1, status.getNewInstances().size()); - assertEquals(0, status.getRecreatedInstances().size()); - assertEquals(0, status.getReusedInstances().size()); - } - - @Test - public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, - ValidationException { - - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createNamed(transaction, instanceName, "prefixes"); - - transaction.commit(); - - assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size()); - - transaction = configRegistryClient.createTransaction(); - CommitStatus status = transaction.commit(); - - assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size()); - assertEquals(0, status.getNewInstances().size()); - assertEquals(0, status.getRecreatedInstances().size()); - assertEquals(1, status.getReusedInstances().size()); - - } - - @Test - public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException, - InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createNamed(transaction, instanceName, "prefixes"); - transaction.commit(); - - transaction = configRegistryClient.createTransaction(); - try { - createNamed(transaction, instanceName, "prefixes1"); - fail(); - } catch (InstanceAlreadyExistsException e) { - assertThat( - e.getMessage(), - containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadfactory-naming', instanceName='named'}")); - } - } - - @Test - public void testValidationException() throws InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName); - transaction.newMXBeanProxy(nameCreated, ThreadFactoryServiceInterface.class); - try { - transaction.validateConfig(); - fail(); - } catch (ValidationException e) { - assertTrue(e.getFailedValidations().containsKey(factory.getImplementationName())); - assertEquals(1, e.getFailedValidations().get(factory.getImplementationName()).keySet().size()); - } - } - - @Test - public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException, - ConflictingVersionException, InstanceNotFoundException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createNamed(transaction, instanceName, "pref"); - - transaction.commit(); - - transaction = configRegistryClient.createTransaction(); - ObjectName databaseNew = transaction.lookupConfigBean(factory.getImplementationName(), instanceName); - NamingThreadFactoryModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew, - NamingThreadFactoryModuleMXBean.class); - proxy.setNamePrefix("pref1"); - - CommitStatus status = transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - assertStatus(status, 0, 1, 0); - } - - private ObjectName createNamed(ConfigTransactionJMXClient transaction, String instanceName, String prefixes) - throws InstanceAlreadyExistsException { - ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName); - NamingThreadFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, - NamingThreadFactoryModuleMXBean.class); - mxBean.setNamePrefix(prefixes); - return nameCreated; - } - -} diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/TestingNamingThreadPoolFactoryModule.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/TestingNamingThreadPoolFactoryModule.java deleted file mode 100644 index f91ec47ad9..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/TestingNamingThreadPoolFactoryModule.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.naming; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; - -import java.io.Closeable; -import java.io.IOException; -import org.opendaylight.controller.config.api.DynamicMBeanWithInstance; -import org.opendaylight.controller.config.api.ModuleIdentifier; -import org.opendaylight.controller.config.spi.Module; -import org.opendaylight.controller.config.threadpool.util.NamingThreadPoolFactory; -import org.opendaylight.controller.config.yang.threadpool.ThreadFactoryServiceInterface; -import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean; - -public class TestingNamingThreadPoolFactoryModule implements Module, ThreadFactoryServiceInterface, - NamingThreadFactoryModuleMXBean { - - private final NamingThreadPoolFactory fact; - - public TestingNamingThreadPoolFactoryModule() throws IOException { - fact = mock(NamingThreadPoolFactory.class); - Thread thread = mock(Thread.class); - doNothing().when(thread).start(); - doReturn(thread).when(fact).newThread(any(Runnable.class)); - doNothing().when(fact).close(); - } - - public TestingNamingThreadPoolFactoryModule(DynamicMBeanWithInstance old) { - fact = (NamingThreadPoolFactory) old.getInstance(); - } - - @Override - public ModuleIdentifier getIdentifier() { - return new ModuleIdentifier(TestingNamingThreadPoolFactoryModule.class.getCanonicalName(), "mock"); - } - - @Override - public String getNamePrefix() { - return null; - } - - @Override - public void setNamePrefix(String arg) { - throw new UnsupportedOperationException(); - } - - @Override - public void validate() { - } - - @Override - public Closeable getInstance() { - return fact; - } - - @Override - public boolean canReuse(Module oldModule) { - return false; - } - -} diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/ScheduledThreadPoolConfigBeanTest.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/ScheduledThreadPoolConfigBeanTest.java deleted file mode 100644 index 6482fe9c1b..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/ScheduledThreadPoolConfigBeanTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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.scheduled; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import javax.management.InstanceAlreadyExistsException; -import javax.management.InstanceNotFoundException; -import javax.management.ObjectName; -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 org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory; -import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean; -import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleFactory; -import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleMXBean; - -public class ScheduledThreadPoolConfigBeanTest extends AbstractConfigTest { - - private ScheduledThreadPoolModuleFactory factory; - private final String instanceName = "scheduled1"; - - @Before - public void setUp() { - - factory = new ScheduledThreadPoolModuleFactory(); - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, factory, - new NamingThreadFactoryModuleFactory())); - } - - @Test - public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException, - ConflictingVersionException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - - createScheduled(transaction, instanceName, 1); - transaction.validateConfig(); - CommitStatus status = transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - assertStatus(status, 2, 0, 0); - } - - @Test - public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, - ValidationException { - - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createScheduled(transaction, instanceName, 1); - - transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - - transaction = configRegistryClient.createTransaction(); - CommitStatus status = transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - assertStatus(status, 0, 0, 2); - } - - @Test - public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException, - ConflictingVersionException, InstanceNotFoundException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createScheduled(transaction, instanceName, 1); - - transaction.commit(); - - transaction = configRegistryClient.createTransaction(); - ObjectName databaseNew = transaction.lookupConfigBean(factory.getImplementationName(), instanceName); - ScheduledThreadPoolModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew, - ScheduledThreadPoolModuleMXBean.class); - proxy.setMaxThreadCount(99); - - CommitStatus status = transaction.commit(); - - assertBeanCount(1, factory.getImplementationName()); - assertStatus(status, 0, 1, 1); - } - - @Test - public void testDestroy() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException, - InstanceNotFoundException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createScheduled(transaction, instanceName, 1); - - transaction.commit(); - - transaction = configRegistryClient.createTransaction(); - transaction.destroyModule(factory.getImplementationName(), instanceName); - CommitStatus status = transaction.commit(); - - assertBeanCount(0, factory.getImplementationName()); - assertStatus(status, 0, 0, 1); - } - - @Test - public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException, - InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createScheduled(transaction, instanceName, 1); - transaction.commit(); - transaction = configRegistryClient.createTransaction(); - try { - createScheduled(transaction, instanceName, 2); - fail(); - } catch (InstanceAlreadyExistsException e) { - assertThat( - e.getMessage(), - containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-scheduled', instanceName='scheduled1'}")); - } - } - - @Test - public void testValidationException() throws InstanceAlreadyExistsException { - ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); - createScheduled(transaction, instanceName, 0); - - try { - transaction.validateConfig(); - fail(); - } catch (ValidationException e) { - assertTrue(e.getFailedValidations().containsKey(factory.getImplementationName())); - assertEquals(1, e.getFailedValidations().get(factory.getImplementationName()).keySet().size()); - } - } - - private ObjectName createScheduled(ConfigTransactionJMXClient transaction, String instanceName, int maxThreadCount) - throws InstanceAlreadyExistsException { - ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName); - ScheduledThreadPoolModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, - ScheduledThreadPoolModuleMXBean.class); - mxBean.setMaxThreadCount(maxThreadCount); - - ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, "naming"); - NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON, - NamingThreadFactoryModuleMXBean.class); - namingThreadFactoryModuleMXBean.setNamePrefix("prefix"); - - mxBean.setThreadFactory(threadFactoryON); - - return nameCreated; - } - -} diff --git a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/TestingScheduledThreadPoolModule.java b/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/TestingScheduledThreadPoolModule.java deleted file mode 100644 index 157380d483..0000000000 --- a/opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/TestingScheduledThreadPoolModule.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.scheduled; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; - -import com.google.common.util.concurrent.ListenableFutureTask; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import javax.management.ObjectName; -import org.opendaylight.controller.config.api.DynamicMBeanWithInstance; -import org.opendaylight.controller.config.api.ModuleIdentifier; -import org.opendaylight.controller.config.manager.impl.AbstractMockedModule; -import org.opendaylight.controller.config.spi.Module; -import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper; -import org.opendaylight.controller.config.yang.threadpool.ScheduledThreadPoolServiceInterface; -import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleMXBean; - -public class TestingScheduledThreadPoolModule extends AbstractMockedModule implements - ScheduledThreadPoolServiceInterface, Module, ScheduledThreadPoolModuleMXBean { - - public TestingScheduledThreadPoolModule(DynamicMBeanWithInstance old, ModuleIdentifier id) { - super(old, id); - } - - @Override - protected AutoCloseable prepareMockedInstance() throws Exception { - ScheduledThreadPoolWrapper instance = mock(ScheduledThreadPoolWrapper.class); - ScheduledExecutorService ses = mock(ScheduledExecutorService.class); - {// mockFuture - ScheduledFuture future = mock(ScheduledFuture.class); - doReturn(false).when(future).cancel(anyBoolean()); - try { - doReturn(mock(Object.class)).when(future).get(); - } catch (Exception e) { - throw new RuntimeException(e); - } - doReturn(future).when(ses).schedule(any(Runnable.class), any(Long.class), any(TimeUnit.class)); - doReturn(future).when(ses).scheduleWithFixedDelay(any(Runnable.class), anyLong(), anyLong(), - any(TimeUnit.class)); - - } - doNothing().when(ses).execute(any(Runnable.class)); - doNothing().when(ses).execute(any(ListenableFutureTask.class)); - doReturn(ses).when(instance).getExecutor(); - doNothing().when(instance).close(); - - doReturn(1).when(instance).getMaxThreadCount(); - return instance; - } - - @Override - public ObjectName getThreadFactory() { - return any(ObjectName.class); - } - - @Override - public void setThreadFactory(ObjectName threadFactory) { - } - - @Override - public Integer getMaxThreadCount() { - return 1; - } - - @Override - public void setMaxThreadCount(Integer maxThreadCount) { - } - -} diff --git a/opendaylight/md-sal/md-sal-config/src/main/resources/initial/01-md-sal.xml b/opendaylight/md-sal/md-sal-config/src/main/resources/initial/01-md-sal.xml index cde493f714..1464f8b0ab 100644 --- a/opendaylight/md-sal/md-sal-config/src/main/resources/initial/01-md-sal.xml +++ b/opendaylight/md-sal/md-sal-config/src/main/resources/initial/01-md-sal.xml @@ -329,7 +329,6 @@ urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12 - urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&revision=2013-04-09 urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28 urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28