use of org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException in project controller by opendaylight.
the class DistributedDataStoreRemotingIntegrationTest method testTransactionWithCreateTxFailureDueToNoLeader.
@Test
public void testTransactionWithCreateTxFailureDueToNoLeader() throws Exception {
followerDatastoreContextBuilder.frontendRequestTimeoutInSeconds(2);
initDatastoresWithCars("testTransactionWithCreateTxFailureDueToNoLeader");
// 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);
Cluster.get(followerSystem).leave(MEMBER_1_ADDRESS);
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
sendDatastoreContextUpdate(followerDistributedDataStore, followerDatastoreContextBuilder.operationTimeoutInMillis(10).shardElectionTimeoutFactor(1).customRaftPolicyImplementation(null));
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);
} else {
assertTrue(msg, Throwables.getRootCause(e) instanceof RequestTimeoutException);
}
}
}
use of org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException 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);
}
}
}
Aggregations