private boolean writeOnlyTransactionOptimizationsEnabled = true;
private long shardCommitQueueExpiryTimeoutInMillis = DEFAULT_SHARD_COMMIT_QUEUE_EXPIRY_TIMEOUT_IN_MS;
private boolean transactionDebugContextEnabled = false;
- private String customRaftPolicyImplementation = "";
public static Set<String> getGlobalDatastoreTypes() {
return globalDatastoreTypes;
this.writeOnlyTransactionOptimizationsEnabled = other.writeOnlyTransactionOptimizationsEnabled;
this.shardCommitQueueExpiryTimeoutInMillis = other.shardCommitQueueExpiryTimeoutInMillis;
this.transactionDebugContextEnabled = other.transactionDebugContextEnabled;
- this.customRaftPolicyImplementation = other.customRaftPolicyImplementation;
setShardJournalRecoveryLogBatchSize(other.raftConfig.getJournalRecoveryLogBatchSize());
setSnapshotBatchCount(other.raftConfig.getSnapshotBatchCount());
setIsolatedLeaderCheckInterval(other.raftConfig.getIsolatedCheckIntervalInMillis());
setSnapshotDataThresholdPercentage(other.raftConfig.getSnapshotDataThresholdPercentage());
setElectionTimeoutFactor(other.raftConfig.getElectionTimeoutFactor());
- setCustomRaftPolicyImplementation(other.customRaftPolicyImplementation);
+ setCustomRaftPolicyImplementation(other.raftConfig.getCustomRaftPolicyImplementationClass());
setShardSnapshotChunkSize(other.raftConfig.getSnapshotChunkSize());
setPeerAddressResolver(other.raftConfig.getPeerAddressResolver());
}
}};
}
- private void testTransactionCommitFailureWithNoShardLeader(final boolean writeOnly) throws Throwable {
+ private void testTransactionCommitFailureWithNoShardLeader(final boolean writeOnly, final String testName) throws Throwable {
new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
- String testName = "testTransactionCommitFailureWithNoShardLeader";
String shardName = "default";
- // We don't want the shard to become the leader so prevent shard election from completing
- // by setting the election timeout, which is based on the heartbeat interval, really high.
+ // We don't want the shard to become the leader so prevent shard elections.
+ datastoreContextBuilder.customRaftPolicyImplementation(
+ "org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy");
- datastoreContextBuilder.shardHeartbeatIntervalInMillis(30000);
+ // The ShardManager uses the election timeout for FindPrimary so reset it low so it will timeout quickly.
+ datastoreContextBuilder.shardHeartbeatIntervalInMillis(100).shardElectionTimeoutFactor(1).
+ shardInitializationTimeout(200, TimeUnit.MILLISECONDS);
DistributedDataStore dataStore = setupDistributedDataStore(testName, false, shardName);
new FindLocalShard(shardName, true));
assertTrue("Expected LocalShardFound. Actual: " + result, result instanceof LocalShardFound);
- // The ShardManager uses the election timeout for FindPrimary so reset it low so it will timeout quickly.
-
- datastoreContextBuilder.shardHeartbeatIntervalInMillis(100).shardElectionTimeoutFactor(1);
- dataStore.onDatastoreContextUpdated(datastoreContextBuilder.build());
-
// Create the write Tx.
final DOMStoreWriteTransaction writeTx = writeOnly ? dataStore.newWriteOnlyTransaction() :
@Test(expected=NoShardLeaderException.class)
public void testWriteOnlyTransactionCommitFailureWithNoShardLeader() throws Throwable {
datastoreContextBuilder.writeOnlyTransactionOptimizationsEnabled(true);
- testTransactionCommitFailureWithNoShardLeader(true);
+ testTransactionCommitFailureWithNoShardLeader(true, "testWriteOnlyTransactionCommitFailureWithNoShardLeader");
}
@Test(expected=NoShardLeaderException.class)
public void testReadWriteTransactionCommitFailureWithNoShardLeader() throws Throwable {
- testTransactionCommitFailureWithNoShardLeader(false);
+ testTransactionCommitFailureWithNoShardLeader(false, "testReadWriteTransactionCommitFailureWithNoShardLeader");
}
@Test