We have an HDFS setup (v2.0.0) managed by Cloudera. I'm having trouble
getting the FileStatus of a symlink or deleting it.
According to the documentation, FileContext#getFileLinkStatus() or
FileContext#delete() should operate on the symlink itself if the provided
path is a symlink.
However, what happens instead is, FileContext#getFileLinkStatus() or
delete() resolve the symlink and act on the target path. So, for example,
if "/tmp/symlink.file" points to "/tmp/target.file", doing this:
Path path = new Path("hdfs://nameservice1:8020/tmp/symlink.file");
returns a path of:
Similarly, fileContext.delete(path, true) deletes the target file
("/tmp/target.file") instead of the symlink itself. So, this behavior does
not match with the documentation.
What's interesting is, locally in pseudo-mode, the above works as expected.
Any ideas or pointers as to why FileContext#delete and
FileContext#getFileLinkStatus() are not operating correctly on the symlinks?