use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class AbstractConfigTest method destroyAllConfigBeans.
/**
* Can be called in @After of tests if some other cleanup is needed that would
* be discarded by closing config beans in this method.
*/
protected void destroyAllConfigBeans() throws Exception {
final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
Set<ObjectName> all = transaction.lookupConfigBeans();
// workaround for getting same Module more times
while (all.size() > 0) {
transaction.destroyModule(all.iterator().next());
all = transaction.lookupConfigBeans();
}
transaction.commit();
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class ConfigTransactionManagerImplTest method testRemoteCallsUsingJMX.
@Test
public void testRemoteCallsUsingJMX() throws Exception {
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
transaction.commit();
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class ServiceReferenceRegistryImplTest method test.
@Test
public void test() throws Exception {
ConfigTransactionJMXClient transaction1 = configRegistryClient.createTransaction();
// create fixed1
int fixedNrOfThreads = 20;
int scheduledNrOfThreads = 30;
ObjectName fixedTPTransactionON = transaction1.createModule(getThreadPoolImplementationName(), fixed1);
platformMBeanServer.setAttribute(fixedTPTransactionON, new Attribute("ThreadCount", fixedNrOfThreads));
ObjectName scheduledTPTransactionON = transaction1.createModule(TestingScheduledThreadPoolModuleFactory.NAME, "scheduled1");
platformMBeanServer.setAttribute(scheduledTPTransactionON, new Attribute("ThreadCount", scheduledNrOfThreads));
String refName = "ref";
ObjectName serviceReference = transaction1.saveServiceReference(TestingThreadPoolServiceInterface.QNAME, refName, fixedTPTransactionON);
// create apsp-parallel
createParallelAPSP(transaction1, serviceReference);
transaction1.commit();
// check fixed1 is used
ServiceReferenceMXBean serviceReferenceMXBean = JMX.newMXBeanProxy(platformMBeanServer, withoutTransactionName(serviceReference), ServiceReferenceMXBean.class);
assertEquals(withoutTransactionName(fixedTPTransactionON), serviceReferenceMXBean.getCurrentImplementation());
checkApspThreadCount(fixedNrOfThreads);
// check OSGi SR
List<RegistrationHolder> registrations = ((RecordingBundleContextServiceRegistrationHandler) currentBundleContextServiceRegistrationHandler).getRegistrations();
assertEquals(1, registrations.size());
RegistrationHolder record = registrations.get(0);
assertEquals(TestingThreadPoolIfc.class, record.clazz);
assertEquals(ImmutableMap.of("name", "ref"), record.props);
// switch reference to scheduled
ConfigTransactionJMXClient transaction2 = configRegistryClient.createTransaction();
transaction2.saveServiceReference(TestingThreadPoolServiceInterface.QNAME, refName, ObjectNameUtil.withTransactionName(scheduledTPTransactionON, transaction2.getTransactionName()));
transaction2.commit();
// check scheduled is used
checkApspThreadCount(scheduledNrOfThreads);
// check that dummy MXBean points to scheduled
assertEquals(withoutTransactionName(scheduledTPTransactionON), serviceReferenceMXBean.getCurrentImplementation());
// empty transaction
configRegistryClient.createTransaction().commit();
// get service mapping
Map<String, Map<String, ObjectName>> serviceMapping = configRegistryClient.getServiceMapping();
Map<String, Map<String, ObjectName>> expectedMapping = ImmutableMap.of(TestingThreadPoolServiceInterface.QNAME, (Map<String, ObjectName>) ImmutableMap.of(refName, withoutTransactionName(scheduledTPTransactionON)));
assertEquals(expectedMapping, serviceMapping);
// destroy all
ConfigTransactionJMXClient transaction4 = configRegistryClient.createTransaction();
Set<ObjectName> objectNames = transaction4.lookupConfigBeans();
for (ObjectName on : objectNames) {
transaction4.destroyModule(on);
}
transaction4.commit();
serviceMapping = configRegistryClient.getServiceMapping();
assertTrue(serviceMapping.isEmpty());
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient 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.util.ConfigTransactionJMXClient 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);
}
}
Aggregations