Search in sources :

Example 16 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class SimpleConfigurationTest method firstCommit.

private ObjectName firstCommit() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName fixed1names = createFixedThreadPool(transaction);
    // commit
    assertEquals(1, configRegistryClient.getOpenConfigs().size());
    CommitStatus commitStatus = transaction.commit();
    assertEquals(0, configRegistryClient.getOpenConfigs().size());
    CommitStatus expected = new CommitStatus(Arrays.asList(ObjectNameUtil.withoutTransactionName(fixed1names)), EMPTYO_NS, EMPTYO_NS);
    assertEquals(expected, commitStatus);
    assertEquals(1, TestingFixedThreadPool.ALL_EXECUTORS.size());
    assertFalse(TestingFixedThreadPool.ALL_EXECUTORS.get(0).isShutdown());
    return fixed1names;
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) CommitStatus(org.opendaylight.controller.config.api.jmx.CommitStatus) ObjectName(javax.management.ObjectName)

Example 17 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient 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)

Example 18 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient 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 19 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class DependentWiringTest method testUsingServiceReferences.

@Test
public void testUsingServiceReferences() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName threadPoolON = createFixed1(transaction, 10);
    transaction.lookupConfigBean(getThreadPoolImplementationName(), fixed1);
    String refName = "ref";
    ObjectName serviceReferenceON = transaction.saveServiceReference(TestingThreadPoolServiceInterface.QNAME, refName, threadPoolON);
    createParallelAPSP(transaction, serviceReferenceON);
    transaction.commit();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 20 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class RuntimeBeanTest method createScheduled.

private ObjectName createScheduled() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    // create using TestingThreadPoolIfc:
    ObjectName createdConfigBean = transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
    // commit
    transaction.commit();
    return createdConfigBean;
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ObjectName(javax.management.ObjectName)

Aggregations

ConfigTransactionJMXClient (org.opendaylight.controller.config.util.ConfigTransactionJMXClient)43 Test (org.junit.Test)38 AbstractConfigTest (org.opendaylight.controller.config.manager.impl.AbstractConfigTest)26 ObjectName (javax.management.ObjectName)22 CommitStatus (org.opendaylight.controller.config.api.jmx.CommitStatus)15 TestingFixedThreadPoolConfigMXBean (org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 TestingParallelAPSPConfigMXBean (org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean)3 Map (java.util.Map)2 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 ConflictingVersionException (org.opendaylight.controller.config.api.ConflictingVersionException)2 ValidationException (org.opendaylight.controller.config.api.ValidationException)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Attribute (javax.management.Attribute)1 IntrospectionException (javax.management.IntrospectionException)1 ReflectionException (javax.management.ReflectionException)1 Before (org.junit.Before)1 IdentityAttributeRef (org.opendaylight.controller.config.api.IdentityAttributeRef)1 ExceptionMessageWithStackTrace (org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace)1