Search in sources :

Example 11 with DOMStoreReadWriteTransaction

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());
}
Also used : DOMStoreReadWriteTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 12 with DOMStoreReadWriteTransaction

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());
}
Also used : DOMStoreReadWriteTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 13 with DOMStoreReadWriteTransaction

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();
}
Also used : DOMStoreReadWriteTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction) DOMStoreThreePhaseCommitCohort(org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 14 with DOMStoreReadWriteTransaction

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();
    }
}
Also used : DOMStoreReadWriteTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction) DOMStoreThreePhaseCommitCohort(org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 15 with DOMStoreReadWriteTransaction

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();
}
Also used : DOMStoreReadWriteTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction) DOMStoreThreePhaseCommitCohort(org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort)

Aggregations

DOMStoreReadWriteTransaction (org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction)20 Test (org.junit.Test)12 DOMStoreThreePhaseCommitCohort (org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort)12 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)6 Benchmark (org.openjdk.jmh.annotations.Benchmark)6 Measurement (org.openjdk.jmh.annotations.Measurement)6 Warmup (org.openjdk.jmh.annotations.Warmup)6 DOMStoreReadTransaction (org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction)4 Optional (com.google.common.base.Optional)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 Ignore (org.junit.Ignore)1 DOMStoreTransactionChain (org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain)1 DOMStoreWriteTransaction (org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1