Search in sources :

Example 16 with DOMStoreThreePhaseCommitCohort

use of org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort 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 17 with DOMStoreThreePhaseCommitCohort

use of org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort 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)

Example 18 with DOMStoreThreePhaseCommitCohort

use of org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort in project controller by opendaylight.

the class InMemoryDataStoreTest method testExistsForExistingData.

@Test
public void testExistsForExistingData() throws Exception {
    DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
    assertNotNull(writeTx);
    ContainerNode containerNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build()).build();
    writeTx.merge(TestModel.TEST_PATH, containerNode);
    CheckedFuture<Boolean, ReadFailedException> exists = writeTx.exists(TestModel.TEST_PATH);
    assertEquals(true, exists.checkedGet());
    DOMStoreThreePhaseCommitCohort ready = writeTx.ready();
    ready.preCommit().get();
    ready.commit().get();
    DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
    assertNotNull(readTx);
    exists = readTx.exists(TestModel.TEST_PATH);
    assertEquals(true, exists.checkedGet());
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) DOMStoreReadTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) DOMStoreReadWriteTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) DOMStoreThreePhaseCommitCohort(org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort) Test(org.junit.Test)

Example 19 with DOMStoreThreePhaseCommitCohort

use of org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort in project controller by opendaylight.

the class InMemoryDataStoreTest method testTransactionChain.

@Test
public void testTransactionChain() throws InterruptedException, ExecutionException {
    DOMStoreTransactionChain txChain = domStore.createTransactionChain();
    assertNotNull(txChain);
    /*
         * We alocate new read-write transaction and write /test
         */
    DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction();
    assertTestContainerWrite(firstTx);
    /*
         * First transaction is marked as ready, we are able to allocate chained
         * transactions
         */
    final DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready();
    /*
         * We alocate chained transaction - read transaction, note first one is
         * still not commited to datastore.
         */
    DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
    /*
         * We test if we are able to read data from tx, read should not fail
         * since we are using chained transaction.
         */
    assertTestContainerExists(secondReadTx);
    /*
         * We alocate next transaction, which is still based on first one, but
         * is read-write.
         */
    DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction();
    /*
         * We test existence of /test in third transaction container should
         * still be visible from first one (which is still uncommmited).
         */
    assertTestContainerExists(thirdDeleteTx);
    /*
         * We delete node in third transaction
         */
    thirdDeleteTx.delete(TestModel.TEST_PATH);
    /*
         * third transaction is sealed.
         */
    DOMStoreThreePhaseCommitCohort thirdDeleteTxCohort = thirdDeleteTx.ready();
    /*
         * We commit first transaction
         */
    assertThreePhaseCommit(firstWriteTxCohort);
    // Alocates store transacion
    DOMStoreReadTransaction storeReadTx = domStore.newReadOnlyTransaction();
    /*
         * We verify transaction is commited to store, container should exists
         * in datastore.
         */
    assertTestContainerExists(storeReadTx);
    /*
         * We commit third transaction
         */
    assertThreePhaseCommit(thirdDeleteTxCohort);
}
Also used : DOMStoreReadTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction) DOMStoreTransactionChain(org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain) DOMStoreReadWriteTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction) DOMStoreThreePhaseCommitCohort(org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort) Test(org.junit.Test)

Aggregations

DOMStoreThreePhaseCommitCohort (org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort)19 DOMStoreReadWriteTransaction (org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction)12 Benchmark (org.openjdk.jmh.annotations.Benchmark)6 Measurement (org.openjdk.jmh.annotations.Measurement)6 Warmup (org.openjdk.jmh.annotations.Warmup)6 Test (org.junit.Test)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 DOMStoreReadTransaction (org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction)2 DOMStoreWriteTransaction (org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction)2 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)2 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)2 Optional (com.google.common.base.Optional)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 DOMStoreTransactionChain (org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1