Search in sources :

Example 21 with DOMStoreReadWriteTransaction

use of org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction in project controller by opendaylight.

the class DistributedDataStoreRemotingIntegrationTest method testTransactionWithShardLeaderNotResponding.

@Test
public void testTransactionWithShardLeaderNotResponding() throws Exception {
    followerDatastoreContextBuilder.frontendRequestTimeoutInSeconds(2);
    followerDatastoreContextBuilder.shardElectionTimeoutFactor(50);
    initDatastoresWithCars("testTransactionWithShardLeaderNotResponding");
    // Do an initial read to get the primary shard info cached.
    final DOMStoreReadTransaction readTx = followerDistributedDataStore.newReadOnlyTransaction();
    readTx.read(CarsModel.BASE_PATH).checkedGet(5, TimeUnit.SECONDS);
    // Shutdown the leader and try to create a new tx.
    TestKit.shutdownActorSystem(leaderSystem, true);
    followerDatastoreContextBuilder.operationTimeoutInMillis(50).shardElectionTimeoutFactor(1);
    sendDatastoreContextUpdate(followerDistributedDataStore, followerDatastoreContextBuilder);
    final DOMStoreReadWriteTransaction rwTx = followerDistributedDataStore.newReadWriteTransaction();
    rwTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());
    try {
        followerTestKit.doCommit(rwTx.ready());
        fail("Exception expected");
    } catch (final ExecutionException e) {
        final String msg = "Unexpected exception: " + Throwables.getStackTraceAsString(e.getCause());
        if (DistributedDataStore.class.equals(testParameter)) {
            assertTrue(msg, Throwables.getRootCause(e) instanceof NoShardLeaderException || e.getCause() instanceof ShardLeaderNotRespondingException);
        } else {
            assertTrue(msg, Throwables.getRootCause(e) instanceof RequestTimeoutException);
        }
    }
}
Also used : RequestTimeoutException(org.opendaylight.controller.cluster.access.client.RequestTimeoutException) ShardLeaderNotRespondingException(org.opendaylight.controller.cluster.datastore.exceptions.ShardLeaderNotRespondingException) DOMStoreReadTransaction(org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction) DOMStoreReadWriteTransaction(org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction) AddressFromURIString(akka.actor.AddressFromURIString) ExecutionException(java.util.concurrent.ExecutionException) NoShardLeaderException(org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException) Test(org.junit.Test)

Example 22 with DOMStoreReadWriteTransaction

use of org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction in project controller by opendaylight.

the class TransactionChainProxyTest method testNewReadWriteTransaction.

@SuppressWarnings("resource")
@Test
public void testNewReadWriteTransaction() {
    DOMStoreTransaction dst = new TransactionChainProxy(mockComponentFactory, historyId).newReadWriteTransaction();
    Assert.assertTrue(dst instanceof DOMStoreReadWriteTransaction);
}
Also used : DOMStoreTransaction(org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction) DOMStoreReadWriteTransaction(org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)22 DOMStoreReadWriteTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction)22 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)11 DOMStoreReadTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction)10 DOMStoreThreePhaseCommitCohort (org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort)8 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)7 DOMStoreTransactionChain (org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain)6 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)6 AddressFromURIString (akka.actor.AddressFromURIString)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 ExecutionException (java.util.concurrent.ExecutionException)5 RequestTimeoutException (org.opendaylight.controller.cluster.access.client.RequestTimeoutException)5 NoShardLeaderException (org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException)5 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)5 DOMStoreWriteTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction)5 DOMStore (org.opendaylight.mdsal.dom.spi.store.DOMStore)4 IOException (java.io.IOException)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 NotInitializedException (org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException)3 ReadFailedException (org.opendaylight.mdsal.common.api.ReadFailedException)3