When files/directories are deleted, Hadoop moves files to .Trash directory if “TrashPolicyDefault: Namenode trash configuration: Deletion interval ” enabled and interval is set.
hadoop fs -rm -r -f /user/root/employee
15/07/26 05:12:14 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 360 minutes, Emptier interval = 0 minutes.
Moved: ‘hdfs://sandbox.hortonworks.com:8020/user/root/employee’ to trash at: hdfs://sandbox.hortonworks.com:8020/user/root/.Trash/Current
# hadoop fs -ls /user/root/employee
ls: `/user/root/employee’: No such file or directory
Notes on .Trash:
The Hadoop trash feature helps prevent accidental deletion of files and directories. If trash is enabled and a file or directory is deleted using the Hadoop shell, the file is moved to the .Trash directory in the user’s home directory instead of being deleted. Deleted files are initially moved to the Current sub-directory of the .Trash directory, and their original path is preserved. Files in .Trash are permanently removed after a user-configurable time interval. The interval setting also enables trash checkpointing, where the Current directory is periodically renamed using a timestamp. Files and directories in the trash can be restored simply by moving them to a location outside the .Trash directory.
Where is the configuration located ?
# grep -ri -a1 trash /etc/hadoop/conf/
in CDS you can enable/disable and configure interval:
From AMBARI you can change the settings using below path:
HDFS==>Configs==>Advanced Core Site ==>fs.trash.interval