lokeshj1703 commented on a change in pull request #154: URL: https://github.com/apache/incubator-ratis/pull/154#discussion_r459999990
########## File path: ratis-test/src/test/java/org/apache/ratis/server/raftlog/segmented/TestSegmentedRaftLog.java ########## @@ -522,19 +522,20 @@ public void testSegmentedRaftLogStateMachineData() throws Exception { sm.blockFlushStateMachineData(); raftLog.appendEntry(entries.get(next++)); - { - sm.blockWriteStateMachineData(); - final Thread t = startAppendEntryThread(raftLog, entries.get(next++)); - TimeUnit.SECONDS.sleep(1); - Assert.assertTrue(t.isAlive()); - sm.unblockWriteStateMachineData(); - t.join(); - } + + sm.blockWriteStateMachineData(); + final Thread t = startAppendEntryThread(raftLog, entries.get(next++)); + TimeUnit.SECONDS.sleep(1); + Assert.assertTrue(t.isAlive()); + sm.unblockWriteStateMachineData(); + assertIndices(raftLog, flush, next); TimeUnit.SECONDS.sleep(1); assertIndices(raftLog, flush, next); sm.unblockFlushStateMachineData(); assertIndicesMultipleAttempts(raftLog, flush + 2, next); + + t.join(); Review comment: Why do we need this change? ########## File path: ratis-server/src/test/java/org/apache/ratis/statemachine/SimpleStateMachine4Testing.java ########## @@ -358,20 +361,26 @@ public TransactionContext startTransaction(RaftClientRequest request) { @Override public CompletableFuture<Void> write(LogEntryProto entry) { - blocking.await(Blocking.Type.WRITE_STATE_MACHINE_DATA); - return CompletableFuture.completedFuture(null); + return CompletableFuture.supplyAsync(() -> { + blocking.await(Blocking.Type.WRITE_STATE_MACHINE_DATA); + return null; + }, executor); Review comment: I think we can use another api in SimpleStateMachine4Testing#Blocking class which just returns a future which is not yet completed. This api would be called here to return a future for write(LogEntryProto entry) call. unblockWriteStateMachineData can then complete that future. This would avoid a blocking call. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org