guanziyue commented on a change in pull request #4264:
URL: https://github.com/apache/hudi/pull/4264#discussion_r830581348
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/util/queue/BoundedInMemoryExecutor.java
##########
@@ -168,6 +169,35 @@ public boolean isRemaining() {
public void shutdownNow() {
producerExecutorService.shutdownNow();
consumerExecutorService.shutdownNow();
+ // close queue to force producer stop
+ queue.close();
+ }
+
+ public boolean awaitTermination() {
+ boolean interruptedBefore = Thread.currentThread().isInterrupted();
+ boolean producerTerminated = false;
+ boolean consumerTerminated = false;
+ try {
+ producerTerminated =
producerExecutorService.awaitTermination(TERMINATE_WAITING_TIME_SECS,
TimeUnit.SECONDS);
+ consumerTerminated =
consumerExecutorService.awaitTermination(TERMINATE_WAITING_TIME_SECS,
TimeUnit.SECONDS);
+ return producerTerminated && consumerTerminated;
+ } catch (InterruptedException ie) {
+ if (!interruptedBefore) {
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ // if current thread has been interrupted before awaitTermination was
called.
Review comment:
Thanks for your suggestion. Refine the code and make the comment more
clear.
--
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]