use of org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction in project controller by opendaylight.
the class MergeModificationTest method testApply.
@Test
public void testApply() throws Exception {
// TODO : Need to write a better test for this
// Write something into the datastore
DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
MergeModification writeModification = new MergeModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
writeModification.apply(writeTransaction);
commitTransaction(writeTransaction);
// Check if it's in the datastore
Optional<NormalizedNode<?, ?>> data = readData(TestModel.TEST_PATH);
Assert.assertTrue(data.isPresent());
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction in project controller by opendaylight.
the class MutableCompositeModificationTest method testApply.
@Test
public void testApply() throws Exception {
MutableCompositeModification compositeModification = new MutableCompositeModification();
compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)));
DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction();
compositeModification.apply(transaction);
commitTransaction(transaction);
Optional<NormalizedNode<?, ?>> data = readData(TestModel.TEST_PATH);
assertNotNull(data.get());
assertEquals(TestModel.TEST_QNAME, data.get().getNodeType());
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction in project controller by opendaylight.
the class AbstractInMemoryDatastoreWriteTransactionBenchmark method write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark.
@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception {
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
writeTx.write(OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
}
DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
cohort.canCommit().get();
cohort.preCommit().get();
cohort.commit().get();
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction in project controller by opendaylight.
the class AbstractInMemoryDatastoreWriteTransactionBenchmark method write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark.
@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception {
for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
writeTx.write(OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
cohort.canCommit().get();
cohort.preCommit().get();
cohort.commit().get();
}
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction in project controller by opendaylight.
the class DatastoreTestTask method execute.
private void execute(final WriteTransactionCustomizer writeCustomizer) throws InterruptedException, ExecutionException {
DOMStoreReadWriteTransaction tx = store.newReadWriteTransaction();
writeCustomizer.customize(tx);
DOMStoreThreePhaseCommitCohort cohort = tx.ready();
assertTrue(cohort.canCommit().get());
cohort.preCommit().get();
cohort.commit().get();
}
Aggregations