Search in sources :

Example 6 with CommitStatus

use of org.opendaylight.controller.config.api.jmx.CommitStatus in project controller by opendaylight.

the class NettyThreadgroupModuleTest method testReconfigure.

@Test
public void testReconfigure() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException, InstanceNotFoundException {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    createInstance(transaction, instanceName, null);
    transaction.commit();
    transaction = configRegistryClient.createTransaction();
    assertBeanCount(1, factory.getImplementationName());
    NettyThreadgroupModuleMXBean mxBean = transaction.newMBeanProxy(transaction.lookupConfigBean(AbstractNettyThreadgroupModuleFactory.NAME, instanceName), NettyThreadgroupModuleMXBean.class);
    mxBean.setThreadCount(1);
    CommitStatus status = transaction.commit();
    assertBeanCount(1, factory.getImplementationName());
    assertStatus(status, 0, 1, 0);
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) CommitStatus(org.opendaylight.controller.config.api.jmx.CommitStatus) Test(org.junit.Test) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest)

Example 7 with CommitStatus

use of org.opendaylight.controller.config.api.jmx.CommitStatus in project controller by opendaylight.

the class BlankTransactionServiceTracker method blankTransactionSync.

void blankTransactionSync() {
    // race condition check: config-persister might push new configuration while
    // server is starting up.
    ConflictingVersionException lastException = null;
    for (int i = 0; i < maxAttempts; i++) {
        try {
            // create transaction
            CommitStatus commitStatus = blankTransaction.hit();
            LOG.debug("Committed blank transaction with status {}", commitStatus);
            return;
        } catch (final ConflictingVersionException e) {
            lastException = e;
            try {
                Thread.sleep(1000);
            } catch (final InterruptedException interruptedException) {
                Thread.currentThread().interrupt();
                LOG.debug("blankTransactionSync was interrupted");
                return;
            }
        } catch (final ValidationException e) {
            LOG.error("Validation exception while running blank transaction indicates programming error", e);
        }
    }
    LOG.error("Maximal number of attempts reached and still cannot get optimistic lock from config manager", lastException);
}
Also used : ConflictingVersionException(org.opendaylight.controller.config.api.ConflictingVersionException) ValidationException(org.opendaylight.controller.config.api.ValidationException) CommitStatus(org.opendaylight.controller.config.api.jmx.CommitStatus)

Example 8 with CommitStatus

use of org.opendaylight.controller.config.api.jmx.CommitStatus in project controller by opendaylight.

the class JMXNotifierConfigRegistry method commitConfig.

@Override
public CommitStatus commitConfig(final ObjectName transactionControllerON) throws ConflictingVersionException, ValidationException {
    final CommitStatus commitStatus = delegate.commitConfig(transactionControllerON);
    notifier.notifyCommit(ObjectNameUtil.getTransactionName(transactionControllerON));
    return commitStatus;
}
Also used : CommitStatus(org.opendaylight.controller.config.api.jmx.CommitStatus)

Example 9 with CommitStatus

use of org.opendaylight.controller.config.api.jmx.CommitStatus in project controller by opendaylight.

the class BlankTransactionServiceTrackerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    doReturn(new CommitStatus(Collections.<ObjectName>emptyList(), Collections.<ObjectName>emptyList(), Collections.<ObjectName>emptyList())).when(blankTx).hit();
    tracker = new BlankTransactionServiceTracker(blankTx, 10, MoreExecutors.newDirectExecutorService());
}
Also used : CommitStatus(org.opendaylight.controller.config.api.jmx.CommitStatus) ObjectName(javax.management.ObjectName) Before(org.junit.Before)

Example 10 with CommitStatus

use of org.opendaylight.controller.config.api.jmx.CommitStatus 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);
}
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)

Aggregations

CommitStatus (org.opendaylight.controller.config.api.jmx.CommitStatus)23 Test (org.junit.Test)15 ConfigTransactionJMXClient (org.opendaylight.controller.config.util.ConfigTransactionJMXClient)15 AbstractConfigTest (org.opendaylight.controller.config.manager.impl.AbstractConfigTest)13 ObjectName (javax.management.ObjectName)8 ConflictingVersionException (org.opendaylight.controller.config.api.ConflictingVersionException)2 ValidationException (org.opendaylight.controller.config.api.ValidationException)2 TestingFixedThreadPoolConfigMXBean (org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 GuardedBy (javax.annotation.concurrent.GuardedBy)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 Before (org.junit.Before)1 ModuleIdentifier (org.opendaylight.controller.config.api.ModuleIdentifier)1 RuntimeBeanRegistratorAwareModule (org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule)1 ServiceInterfaceAnnotation (org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation)1 DestroyedModule (org.opendaylight.controller.config.manager.impl.dependencyresolver.DestroyedModule)1 ModuleInternalTransactionalInfo (org.opendaylight.controller.config.manager.impl.dependencyresolver.ModuleInternalTransactionalInfo)1 DynamicReadableWrapper (org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper)1