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);
}
}
}
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);
}
Aggregations