On 08/17/2011 12:57 PM, Adam Shook wrote:
Hello All,
Is there any clean way to tell from the API (v0.20.2) that a file in HDFS is
currently being written to? I've seen some exceptions before related to it,
but I was hoping there is a clean way and Google isn't turning anything up for
me.
Thanks!
-- Adam
You might be able to do it to some extent using
FileStatus.getModificationTime()
(http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/fs/FileStatus.html#getModificationTime()),
but this would really be a hack, IMO, and not something you should rely on.
I think you'd be better off either a) writing the file to a temp
directory, or b) writing it with a .tmp extension, and then moving or
renaming it once the file write is complete.
HTH,
DR