Return-Path: X-Original-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 14D1711DBD for ; Thu, 10 Jul 2014 17:52:09 +0000 (UTC) Received: (qmail 49638 invoked by uid 500); 10 Jul 2014 17:52:07 -0000 Delivered-To: apmail-hadoop-common-issues-archive@hadoop.apache.org Received: (qmail 49545 invoked by uid 500); 10 Jul 2014 17:52:06 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-issues@hadoop.apache.org Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 49224 invoked by uid 99); 10 Jul 2014 17:52:06 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jul 2014 17:52:06 +0000 Date: Thu, 10 Jul 2014 17:52:06 +0000 (UTC) From: "Chris Nauroth (JIRA)" To: common-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HADOOP-10792) Add FileSystem#closeIfNotReferred method MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HADOOP-10792?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14057736#comment-14057736 ] Chris Nauroth commented on HADOOP-10792: ---------------------------------------- bq. If I use FileSystem, using newInstance method and not invoke FileSystem#close makes sense right? This might not be a good idea depending on exactly how you use the {{FileSystem}}. For example: * If you rely on delete-on-exit (see method {{FileSystem#deleteOnExit}}), then never calling {{FileSystem#close}} means those files might not get deleted in a timely fashion. They'd still get deleted on JVM process shutdown thanks to a shutdown hook, but that might not clean up the files quickly enough if you have a long-running process. * If this is HDFS, then closing the {{DistributedFileSystem}} instance also implicitly closes any files that are still held open for write. If your application was dependent on this behavior, then skipping the close might cause problems. * If this is a custom {{FileSystem}}, then the subclass implementors could have overridden {{close}} and coded any arbitrary cleanup logic that they saw necessary. It's hard to predict what would happen if you refuse to close when you consider custom implementations. In general, I prefer Steve's earlier recommendation. > Add FileSystem#closeIfNotReferred method > ---------------------------------------- > > Key: HADOOP-10792 > URL: https://issues.apache.org/jira/browse/HADOOP-10792 > Project: Hadoop Common > Issue Type: Improvement > Components: fs > Reporter: Kousuke Saruta > > FileSystem#close closes FileSystem even if the same instance of FileSystem is referred by someone. > For instance, a library using FileSystem calls FileSystem.get, and a program using the library calls FileSystem.get, both of instances of FileSystem is same. > When the library and the program is implemented as different threads and one calls FileSystem.close, another fails most of operations of FileSystem. > So, we need the method like cloesIfNotReferred, which closes FileSystem only if a instance of FileSystem is not referred by anyone. -- This message was sent by Atlassian JIRA (v6.2#6252)