use of org.opendaylight.controller.config.api.jmx.CommitStatus in project controller by opendaylight.
the class TransactionProvider method commitTransaction.
/**
* Commit and notification send must be atomic.
*/
public synchronized CommitStatus commitTransaction(final ConfigRegistryClient client) throws ValidationException, ConflictingVersionException {
if (!getTransaction().isPresent()) {
// making empty commit without prior opened transaction, just return commit
// status with empty lists
LOG.debug("Making commit without open candidate transaction for session {}", sessionIdForReporting);
return new CommitStatus(Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
}
final Optional<ObjectName> maybeTaON = getTransaction();
ObjectName taON = maybeTaON.get();
try {
CommitStatus status = client.commitConfig(taON);
// clean up
allOpenedTransactions.remove(candidateTx);
candidateTx = null;
return status;
} catch (final ValidationException validationException) {
// no clean up: user can reconfigure and recover this transaction
LOG.warn("Transaction {} failed on {}", taON, validationException.toString());
throw validationException;
} catch (final ConflictingVersionException e) {
LOG.debug("Exception while commit of {}, aborting transaction", taON, e);
// clean up
abortTransaction();
throw e;
}
}
use of org.opendaylight.controller.config.api.jmx.CommitStatus in project controller by opendaylight.
the class RuntimeBeanTest method testRecreate.
@Test
public void testRecreate() throws Exception {
ObjectName createdConfigBean = createScheduled();
// empty transaction
ConfigTransactionJMXClient configTransaction = configRegistryClient.createTransaction();
ObjectName scheduledWritableON = configTransaction.lookupConfigBean(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
TestingScheduledThreadPoolConfigBeanMXBean scheduledWritableProxy = configTransaction.newMXBeanProxy(scheduledWritableON, TestingScheduledThreadPoolConfigBeanMXBean.class);
scheduledWritableProxy.setRecreate(true);
CommitStatus commitInfo = configTransaction.commit();
// check that it was recreated
ObjectName readableConfigBean = ObjectNameUtil.withoutTransactionName(createdConfigBean);
List<ObjectName> newInstances = Collections.<ObjectName>emptyList();
List<ObjectName> reusedInstances = Collections.<ObjectName>emptyList();
List<ObjectName> recreatedInstaces = Lists.newArrayList(readableConfigBean);
assertEquals(new CommitStatus(newInstances, reusedInstances, recreatedInstaces), commitInfo);
checkRuntimeBeans();
}
use of org.opendaylight.controller.config.api.jmx.CommitStatus in project controller by opendaylight.
the class SimpleConfigurationTest method testCreateAndDestroyBeanInSameTransaction.
@Test
public void testCreateAndDestroyBeanInSameTransaction() throws Exception {
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
ObjectName fixed1names = createFixedThreadPool(transaction);
transaction.destroyModule(fixed1names);
CommitStatus commitStatus = transaction.commit();
assertStatus(commitStatus, 0, 0, 0);
}
Aggregations