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_r363711985
##########
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:
Can we always add the shutdown hook to remove the argument
`deleteOnShutdown`?
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services