Search in sources :

Example 1 with TestingFixedThreadPoolConfigMXBean

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());
}
Also used : TestingFixedThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean) Test(org.junit.Test)

Example 2 with TestingFixedThreadPoolConfigMXBean

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;
}
Also used : TestingFixedThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean) ObjectName(javax.management.ObjectName)

Example 3 with TestingFixedThreadPoolConfigMXBean

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);
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) TestingFixedThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean) CommitStatus(org.opendaylight.controller.config.api.jmx.CommitStatus) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest) Test(org.junit.Test)

Example 4 with TestingFixedThreadPoolConfigMXBean

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);
    }
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ReflectionException(javax.management.ReflectionException) InstanceNotFoundException(javax.management.InstanceNotFoundException) TestingFixedThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean) IntrospectionException(javax.management.IntrospectionException) ObjectName(javax.management.ObjectName) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest) Test(org.junit.Test)

Example 5 with TestingFixedThreadPoolConfigMXBean

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);
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) TestingFixedThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean) ObjectName(javax.management.ObjectName) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest) Test(org.junit.Test)

Aggregations

TestingFixedThreadPoolConfigMXBean (org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean)10 Test (org.junit.Test)7 ObjectName (javax.management.ObjectName)6 ConfigTransactionJMXClient (org.opendaylight.controller.config.util.ConfigTransactionJMXClient)5 AbstractConfigTest (org.opendaylight.controller.config.manager.impl.AbstractConfigTest)4 CommitStatus (org.opendaylight.controller.config.api.jmx.CommitStatus)2 Map (java.util.Map)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 IntrospectionException (javax.management.IntrospectionException)1 ReflectionException (javax.management.ReflectionException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 ValidationException (org.opendaylight.controller.config.api.ValidationException)1 ExceptionMessageWithStackTrace (org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace)1 AbstractLockedPlatformMBeanServerTest (org.opendaylight.controller.config.manager.impl.AbstractLockedPlatformMBeanServerTest)1 TestingParallelAPSPConfigMXBean (org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean)1