use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class TwoInterfacesExportTest method testRegisteringAllIfcNames.
// --
@Test
public void testRegisteringAllIfcNames() throws Exception {
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
transaction.commit();
assertExists(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
// another transaction
transaction = configRegistryClient.createTransaction();
assertExists(transaction, TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class TwoInterfacesExportTest method tryToRegisterThreadPoolWithSameName.
@Test
public void tryToRegisterThreadPoolWithSameName() throws InstanceAlreadyExistsException {
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
try {
transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
fail();
} catch (final InstanceAlreadyExistsException e) {
assertThat(e.getMessage(), containsString("There is an instance registered with name " + "ModuleIdentifier{factoryName='scheduled', instanceName='scheduled1'}"));
}
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient 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());
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class MockedDependenciesTest method testDependencies.
@Test
public void testDependencies() throws Exception {
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
// create fixed1
ObjectName threadPoolTransactionON = createFixed1(transaction, TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS);
// create apsp-parallel
createParallelAPSP(transaction, threadPoolTransactionON);
transaction.commit();
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class SimpleConfigurationTest method testOptimisticLock_ConfigRegistry.
@Test
public void testOptimisticLock_ConfigRegistry() throws Exception {
ConfigTransactionJMXClient transaction1 = configRegistryClient.createTransaction();
ConfigTransactionJMXClient transaction2 = configRegistryClient.createTransaction();
transaction2.assertVersion(0, 2);
transaction2.commit();
try {
configRegistryClient.commitConfig(transaction1.getObjectName());
fail();
} catch (final ConflictingVersionException e) {
assertEquals("Optimistic lock failed. Expected parent version 2, was 0", e.getMessage());
}
}
Aggregations