flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From StephanEwen <...@git.apache.org>
Subject [GitHub] flink pull request #2691: [FLINK-4910] Introduce safety net for closing file...
Date Thu, 27 Oct 2016 13:29:27 GMT
Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2691#discussion_r85334057
  
    --- Diff: flink-core/src/main/java/org/apache/flink/core/fs/FileSystem.java ---
    @@ -55,6 +60,40 @@
     
     	private static final String HADOOP_WRAPPER_SCHEME = "hdwrapper";
     
    +	private static final Logger LOG = LoggerFactory.getLogger(FileSystem.class);
    +
    +	/**
    +	 * Create a SafetyNetCloseableRegistry for a Task. This method should be called at the
beginning of the task's
    +	 * main thread.
    +	 */
    +	public static void createFileSystemCloseableRegistryForTask() {
    +		SafetyNetCloseableRegistry current = REGISTRIES.get();
    +		if (null != current) {
    +			if (!current.isClosed()) {
    +				IOUtils.closeQuietly(current);
    +				LOG.warn("Found open SafetyNetCloseableRegistry. Closed and replaced it.");
    +			}
    +		}
    +		REGISTRIES.set(new SafetyNetCloseableRegistry());
    +	}
    +
    +	/**
    +	 * Create a SafetyNetCloseableRegistry for a Task. This method should be called at the
end of the task's
    +	 * main thread or when the task should be canceled.
    +	 */
    +	public static void disposeFileSystemCloseableRegistryForTask() {
    +		SafetyNetCloseableRegistry ret = REGISTRIES.get();
    +		if (null != ret) {
    +			LOG.info("Closing SafetyNetCloseableRegistry.");
    --- End diff --
    
    Let's log something like "Ensuring all FileSystem streams are closed". Users will understand
that better ;-)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message