Search in sources :

Example 6 with TestingFixedThreadPoolConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean in project controller by opendaylight.

the class SimpleConfigurationTest method testTriggerRecreatingInstance.

@Test
public void testTriggerRecreatingInstance() throws Exception {
    // 1, start transaction, create new fixed thread pool
    firstCommit();
    // switch boolean to create new instance
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    TestingFixedThreadPoolConfigMXBean fixedConfigProxy = startReconfiguringFixed1ThreadPool(transaction);
    fixedConfigProxy.setTriggerNewInstanceCreation(true);
    // commit
    CommitStatus commitStatus = transaction.commit();
    // check that new threadpool is created and old one is closed
    checkThreadPools(1, NUMBER_OF_THREADS);
    CommitStatus expected = new CommitStatus(EMPTYO_NS, EMPTYO_NS, FIXED1_LIST);
    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 7 with TestingFixedThreadPoolConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean in project controller by opendaylight.

the class SimpleConfigurationTest method startReconfiguringFixed1ThreadPool.

// return MBeanProxy for 'fixed1' and current transaction
private static TestingFixedThreadPoolConfigMXBean startReconfiguringFixed1ThreadPool(final ConfigTransactionJMXClient transaction) throws InstanceNotFoundException {
    ObjectName fixed1name = transaction.lookupConfigBean(TestingFixedThreadPoolModuleFactory.NAME, FIXED1);
    TestingFixedThreadPoolConfigMXBean fixedConfigProxy = transaction.newMXBeanProxy(fixed1name, TestingFixedThreadPoolConfigMXBean.class);
    return fixedConfigProxy;
}
Also used : TestingFixedThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean) ObjectName(javax.management.ObjectName)

Example 8 with TestingFixedThreadPoolConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean in project controller by opendaylight.

the class AbstractParallelAPSPTest method createFixed1.

protected ObjectName createFixed1(final ConfigTransactionJMXClient transaction, final int numberOfThreads) throws InstanceAlreadyExistsException {
    ObjectName name = transaction.createModule(getThreadPoolImplementationName(), fixed1);
    TestingFixedThreadPoolConfigMXBean fixedConfigProxy = transaction.newMXBeanProxy(name, TestingFixedThreadPoolConfigMXBean.class);
    fixedConfigProxy.setThreadCount(numberOfThreads);
    return name;
}
Also used : TestingFixedThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean) ObjectName(javax.management.ObjectName)

Example 9 with TestingFixedThreadPoolConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean in project controller by opendaylight.

the class AbstractDynamicWrapperTest method testGettersWithMXBeanProxy.

@Test
public void testGettersWithMXBeanProxy() {
    TestingFixedThreadPoolConfigMXBean proxy = JMX.newMXBeanProxy(platformMBeanServer, threadPoolDynamicWrapperON, TestingFixedThreadPoolConfigMXBean.class);
    assertEquals(threadCount, proxy.getThreadCount());
}
Also used : TestingFixedThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean) Test(org.junit.Test) AbstractLockedPlatformMBeanServerTest(org.opendaylight.controller.config.manager.impl.AbstractLockedPlatformMBeanServerTest)

Example 10 with TestingFixedThreadPoolConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean in project controller by opendaylight.

the class DependentWiringTest method testDependencies.

@Test
public void testDependencies() throws Exception {
    ObjectName apspON;
    {
        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
        // create fixed1
        ObjectName threadPoolTransactionON = createFixed1(transaction, TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS);
        // create apsp-parallel
        ObjectName apspNameTransactionON = createParallelAPSP(transaction, threadPoolTransactionON);
        TestingParallelAPSPConfigMXBean parallelAPSPConfigProxy = transaction.newMXBeanProxy(apspNameTransactionON, TestingParallelAPSPConfigMXBean.class);
        // trigger validation
        parallelAPSPConfigProxy.setSomeParam("");
        // failure
        try {
            transaction.validateConfig();
            fail();
        } catch (final ValidationException e) {
            for (Map.Entry<String, Map<String, ExceptionMessageWithStackTrace>> exception : e.getFailedValidations().entrySet()) {
                for (Map.Entry<String, ExceptionMessageWithStackTrace> entry : exception.getValue().entrySet()) {
                    assertThat(entry.getValue().getMessage(), containsString("Parameter 'SomeParam' is blank"));
                }
            }
        }
        // try committing (validation fails)
        try {
            transaction.commit();
            fail();
        } catch (final ValidationException e) {
            for (Map.Entry<String, Map<String, ExceptionMessageWithStackTrace>> exception : e.getFailedValidations().entrySet()) {
                for (Map.Entry<String, ExceptionMessageWithStackTrace> entry : exception.getValue().entrySet()) {
                    String err = entry.getValue().getMessage();
                    assertTrue("Unexpected error message: " + err, err.contains("Parameter 'SomeParam' is blank"));
                }
            }
        }
        // fix validation
        parallelAPSPConfigProxy.setSomeParam("abc");
        // failure
        transaction.commit();
        apspON = ObjectNameUtil.withoutTransactionName(apspNameTransactionON);
    }
    // test reported apsp number of threads
    TestingParallelAPSPConfigMXBean parallelAPSPRuntimeProxy = configRegistryClient.newMXBeanProxy(apspON, TestingParallelAPSPConfigMXBean.class);
    assertEquals((Integer) TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS, parallelAPSPRuntimeProxy.getMaxNumberOfThreads());
    // next transaction - recreate new thread pool
    int newNumberOfThreads = TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS * 2;
    {
        // start new transaction
        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
        ObjectName threadPoolNamesNewTx = transaction.lookupConfigBean(getThreadPoolImplementationName(), fixed1);
        TestingFixedThreadPoolConfigMXBean fixedConfigTransactionProxy = transaction.newMXBeanProxy(threadPoolNamesNewTx, TestingFixedThreadPoolConfigMXBean.class);
        fixedConfigTransactionProxy.setThreadCount(newNumberOfThreads);
        transaction.commit();
    }
    // new reference should be copied to apsp-parallel
    assertEquals((Integer) newNumberOfThreads, parallelAPSPRuntimeProxy.getMaxNumberOfThreads());
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ExceptionMessageWithStackTrace(org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace) ValidationException(org.opendaylight.controller.config.api.ValidationException) TestingFixedThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Map(java.util.Map) ObjectName(javax.management.ObjectName) TestingParallelAPSPConfigMXBean(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean) 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