Apache9 commented on code in PR #5507:
URL: https://github.com/apache/hbase/pull/5507#discussion_r1413023292
##########
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRolling.java:
##########
@@ -51,6 +60,64 @@ public static void setUpBeforeClass() throws Exception {
AbstractTestLogRolling.setUpBeforeClass();
}
+ public static class SlowSyncLogWriter extends AsyncProtobufLogWriter {
+
+ public SlowSyncLogWriter(EventLoopGroup eventLoopGroup, Class<? extends
Channel> channelClass) {
+ super(eventLoopGroup, channelClass);
+ }
+
+ @Override
+ public CompletableFuture<Long> sync(boolean forceSync) {
+ CompletableFuture<Long> future = new CompletableFuture<>();
+ super.sync(forceSync).whenCompleteAsync((lengthAfterFlush, error) -> {
+ if (error != null) {
+ future.completeExceptionally(error);
+ } else {
+ try {
+ Thread.sleep(syncLatencyMillis);
Review Comment:
Let's introduce a ScheduledExecutorService and schedule a delayed task for
completing the future? Sleeping in a callback is still not a good behavior...
And even if there is an error, we still need to delay the completing?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]