You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/01/09 03:20:57 UTC

[GitHub] [flink] gaoyunhaii commented on a change in pull request #10736: [FLINK-15010][Network] Add shutdown hook to ensure cleanup netty shuffle directories

gaoyunhaii 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_r364544133
 
 

 ##########
 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:
   This is due to in this PR I think it should be better to not affect the current behaviors of `IOManager`.  Although `IOManager` also have the problem that register shutdown hook after the directories are created, I think it might be better to fix it in separate PR if we agree with how to deal with it. Since `IOManager` already has a shutdown hook, for `IOManager` we also need to allow the `FileChannelManagerImpl#close` be closed for multiple times (i.e., using `closed` flag to skip cleanup in repeat `close` calls). 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services