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);
}
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;
}
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;
}
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());
}
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());
}
Aggregations