Search in sources :

Example 6 with OPERATIONAL

use of org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL in project genius by opendaylight.

the class RetryingManagedNewTransactionRunnerTest method testCallWithNewTypedReadWriteTransactionReadFailedException.

@Test
public void testCallWithNewTypedReadWriteTransactionReadFailedException() throws Exception {
    testableDataBroker.failReads(2, new ReadFailedException("bada boum bam!"));
    TopLevelList data = newTestDataObject();
    managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(Datastore.OPERATIONAL, tx -> {
        tx.put(TEST_PATH, data);
        assertEquals(data, tx.read(TEST_PATH).get().get());
    }).get();
    assertEquals(data, singleTransactionDataBroker.syncRead(OPERATIONAL, TEST_PATH));
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) OPERATIONAL(org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Test(org.junit.Test) Datastore(org.opendaylight.genius.infra.Datastore) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) RetryingManagedNewTransactionRunner(org.opendaylight.genius.infra.RetryingManagedNewTransactionRunner) Assert.assertEquals(org.junit.Assert.assertEquals) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) Test(org.junit.Test)

Example 7 with OPERATIONAL

use of org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL in project genius by opendaylight.

the class RetryingManagedNewTransactionRunnerTest method testCallWithNewWriteOnlyTransactionOptimisticLockFailedException.

@Override
public void testCallWithNewWriteOnlyTransactionOptimisticLockFailedException() throws Exception {
    // contrary to the super() test implementation for (just) ManagedNewTransactionRunnerImpl, in the parent class
    // here we expect the x2 OptimisticLockFailedException to be retried, and then eventually succeed:
    testableDataBroker.failSubmits(2, new OptimisticLockFailedException("bada boum bam!"));
    TopLevelList data = newTestDataObject();
    managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(writeTx -> writeTx.put(LogicalDatastoreType.OPERATIONAL, TEST_PATH, data)).get();
    assertEquals(data, singleTransactionDataBroker.syncRead(OPERATIONAL, TEST_PATH));
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) OPERATIONAL(org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Test(org.junit.Test) Datastore(org.opendaylight.genius.infra.Datastore) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) RetryingManagedNewTransactionRunner(org.opendaylight.genius.infra.RetryingManagedNewTransactionRunner) Assert.assertEquals(org.junit.Assert.assertEquals) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException)

Example 8 with OPERATIONAL

use of org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL in project genius by opendaylight.

the class RetryingManagedNewTransactionRunnerTest method testCallWithNewTypedWriteOnlyTransactionOptimisticLockFailedException.

@Override
public void testCallWithNewTypedWriteOnlyTransactionOptimisticLockFailedException() throws Exception {
    // contrary to the super() test implementation for (just) ManagedNewTransactionRunnerImpl, in the parent class
    // here we expect the x2 OptimisticLockFailedException to be retried, and then eventually succeed:
    testableDataBroker.failSubmits(2, new OptimisticLockFailedException("bada boum bam!"));
    TopLevelList data = newTestDataObject();
    managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.OPERATIONAL, writeTx -> writeTx.put(TEST_PATH, data)).get();
    assertEquals(data, singleTransactionDataBroker.syncRead(OPERATIONAL, TEST_PATH));
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) OPERATIONAL(org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Test(org.junit.Test) Datastore(org.opendaylight.genius.infra.Datastore) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) RetryingManagedNewTransactionRunner(org.opendaylight.genius.infra.RetryingManagedNewTransactionRunner) Assert.assertEquals(org.junit.Assert.assertEquals) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException)

Aggregations

Test (org.junit.Test)8 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)8 OPERATIONAL (org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL)8 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList)8 Assert.assertEquals (org.junit.Assert.assertEquals)7 Datastore (org.opendaylight.genius.infra.Datastore)7 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)7 RetryingManagedNewTransactionRunner (org.opendaylight.genius.infra.RetryingManagedNewTransactionRunner)7 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)7 OptimisticLockFailedException (org.opendaylight.mdsal.common.api.OptimisticLockFailedException)7 ReadFailedException (org.opendaylight.mdsal.common.api.ReadFailedException)7 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 ListeningScheduledExecutorService (com.google.common.util.concurrent.ListeningScheduledExecutorService)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)1 Duration (java.time.Duration)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 TimeUnit (java.util.concurrent.TimeUnit)1