zhijiangW commented on a change in pull request #10736: [FLINK-15010][Network] Add shutdown hook to ensure cleanup netty shuffle directories URL: https://github.com/apache/flink/pull/10736#discussion_r365642499
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/disk/FileChannelManagerImpl.java ########## @@ -51,12 +52,30 @@ /** The number of the next path to use. */ private volatile int nextPath; + private final String prefix; + + private final Thread shutdownHook; + public FileChannelManagerImpl(String[] tempDirs, String prefix) { + this(tempDirs, prefix, false); + } + + public FileChannelManagerImpl(String[] tempDirs, String prefix, boolean deleteOnShutdown) { checkNotNull(tempDirs, "The temporary directories must not be null."); checkArgument(tempDirs.length > 0, "The temporary directories must not be empty."); this.random = new Random(); this.nextPath = 0; + this.prefix = prefix; + + if (deleteOnShutdown) { + shutdownHook = ShutdownHookUtil.addShutdownHook(this, String.format("%s-%s", getClass().getSimpleName(), prefix), LOG); Review comment: I got the point now. I think it is better to make `FileChannelManagerImpl` always have the `shutdownHook`, and then it does not need judge whether it is `null` in other usages. Also it does not need to care about this argument `deleteOnShutdown` to true or false for upper component. In order to avoid repeated `close` calling by `IOManager` usage, we can add the atomic boolean var in `FileChannelManagerImpl` and check this state in other usages as well. ---------------------------------------------------------------- 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 With regards, Apache Git Services