use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean in project controller by opendaylight.
the class DynamicWritableWrapperTest method testSettersWithMXBeanProxy.
@Test
public void testSettersWithMXBeanProxy() {
TestingFixedThreadPoolConfigMXBean proxy = JMX.newMXBeanProxy(platformMBeanServer, threadPoolDynamicWrapperON, TestingFixedThreadPoolConfigMXBean.class);
proxy.setThreadCount(newThreadCount);
assertEquals(newThreadCount, threadPoolConfigBean.getThreadCount());
}
use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean in project controller by opendaylight.
the class SimpleConfigurationTest method createFixedThreadPool.
static ObjectName createFixedThreadPool(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException, InstanceNotFoundException {
transaction.assertVersion(0, 1);
ObjectName fixed1names = transaction.createModule(TestingFixedThreadPoolModuleFactory.NAME, FIXED1);
TestingFixedThreadPoolConfigMXBean fixedConfigProxy = transaction.newMXBeanProxy(fixed1names, TestingFixedThreadPoolConfigMXBean.class);
fixedConfigProxy.setThreadCount(NUMBER_OF_THREADS);
ObjectName retrievedNames = transaction.lookupConfigBean(TestingFixedThreadPoolModuleFactory.NAME, FIXED1);
assertEquals(fixed1names, retrievedNames);
return fixed1names;
}
use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean in project controller by opendaylight.
the class SimpleConfigurationTest method test_createThreadPool_changeNumberOfThreads.
@Test
public void test_createThreadPool_changeNumberOfThreads() throws Exception {
firstCommit();
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
TestingFixedThreadPoolConfigMXBean fixedConfigProxy = startReconfiguringFixed1ThreadPool(transaction);
assertEquals(NUMBER_OF_THREADS, fixedConfigProxy.getThreadCount());
fixedConfigProxy.setThreadCount(NUMBER_OF_THREADS2);
CommitStatus commitStatus = transaction.commit();
checkThreadPools(1, NUMBER_OF_THREADS2);
CommitStatus expected = new CommitStatus(EMPTYO_NS, FIXED1_LIST, EMPTYO_NS);
assertEquals(expected, commitStatus);
}
use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean in project controller by opendaylight.
the class SimpleConfigurationTest method test_createFixedThreadPool_destroyIt.
@Test
public void test_createFixedThreadPool_destroyIt() throws Exception {
// 1, start transaction, create new fixed thread pool
ObjectName fixed1name = firstCommit();
// 2, check that configuration was copied to platform
ObjectName on = ObjectNameUtil.withoutTransactionName(fixed1name);
platformMBeanServer.getMBeanInfo(on);
assertEquals(NUMBER_OF_THREADS, platformMBeanServer.getAttribute(on, "ThreadCount"));
// 3, shutdown fixed1 in new transaction
assertFalse(TestingFixedThreadPool.ALL_EXECUTORS.get(0).isShutdown());
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
// check versions
transaction.assertVersion(1, 2);
// test that it was copied to new transaction
ObjectName retrievedName = transaction.lookupConfigBean(TestingFixedThreadPoolModuleFactory.NAME, FIXED1);
assertNotNull(retrievedName);
// check that number of threads was copied from dynamic
TestingFixedThreadPoolConfigMXBean fixedConfigProxy = transaction.newMXBeanProxy(retrievedName, TestingFixedThreadPoolConfigMXBean.class);
assertEquals(NUMBER_OF_THREADS, fixedConfigProxy.getThreadCount());
// destroy
transaction.destroyModule(ObjectNameUtil.createTransactionModuleON(transaction.getTransactionName(), TestingFixedThreadPoolModuleFactory.NAME, FIXED1));
transaction.commit();
// 4, check
assertEquals(2, configRegistryClient.getVersion());
assertEquals(0, TestingFixedThreadPool.ALL_EXECUTORS.size());
// dynamic config should be removed from platform
try {
platformMBeanServer.getMBeanInfo(on);
fail();
} catch (final ReflectionException | InstanceNotFoundException | IntrospectionException e) {
assertTrue(e instanceof InstanceNotFoundException);
}
}
use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean in project controller by opendaylight.
the class SimpleConfigurationTest method testReplaceFixed1.
@Test
public void testReplaceFixed1() throws Exception {
// 1, start transaction, create new fixed thread pool
firstCommit();
// destroy and recreate with different # of threads
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
transaction.destroyModule(ObjectNameUtil.createTransactionModuleON(transaction.getTransactionName(), TestingFixedThreadPoolModuleFactory.NAME, FIXED1));
ObjectName fixed1name = transaction.createModule(TestingFixedThreadPoolModuleFactory.NAME, FIXED1);
TestingFixedThreadPoolConfigMXBean fixedConfigProxy = transaction.newMXBeanProxy(fixed1name, TestingFixedThreadPoolConfigMXBean.class);
fixedConfigProxy.setThreadCount(NUMBER_OF_THREADS2);
// commit
transaction.commit();
// check that first threadpool is closed
checkThreadPools(1, NUMBER_OF_THREADS2);
}
Aggregations