Package org.apache.hadoop.fs
Class TrashPolicyDefault
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.fs.TrashPolicy
org.apache.hadoop.fs.TrashPolicyDefault
- All Implemented Interfaces:
Configurable
Provides a trash feature. Files are moved to a user's trash
directory, a subdirectory of their home directory named ".Trash". Files are
initially moved to a current sub-directory of the trash directory.
Within that sub-directory their original path is preserved. Periodically
one may checkpoint the current trash and remove older checkpoints. (This
design permits trash management without enumeration of the full trash
content, without date support in the filesystem, and without clock
synchronization.)
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.apache.hadoop.fs.TrashPolicy
deletionInterval, fs, trash -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCreate a trash checkpoint.voidcreateCheckpoint(Date date) voidDelete old trash checkpoint(s).voidDelete all checkpoints immediately, ie empty trash.Get the current working directory of the Trash Policy This API does not work with files deleted from encryption zone when HDFS data encryption at rest feature is enabled as rename file between encryption zones or encryption zone and non-encryption zone is not allowed.getCurrentTrashDir(Path path) Get the current trash directory for path specified based on the Trash PolicyReturn aRunnablethat periodically empties the trash of all users, intended to be run by the superuser.voidinitialize(Configuration conf, FileSystem fs) Used to setup the trash policy.voidinitialize(Configuration conf, FileSystem fs, Path home) Deprecated.booleanReturns whether the Trash Policy is enabled for this filesystem.booleanmoveToTrash(Path path) Move a file or directory to the current trash directory.Methods inherited from class org.apache.hadoop.fs.TrashPolicy
getInstance, getInstanceMethods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
-
Constructor Details
-
TrashPolicyDefault
public TrashPolicyDefault()
-
-
Method Details
-
initialize
Deprecated.Useinitialize(Configuration, FileSystem)instead.Description copied from class:TrashPolicyUsed to setup the trash policy. Must be implemented by all TrashPolicy implementations.- Specified by:
initializein classTrashPolicy- Parameters:
conf- the configuration to be usedfs- the filesystem to be usedhome- the home directory
-
initialize
Description copied from class:TrashPolicyUsed to setup the trash policy. Must be implemented by all TrashPolicy implementations. Different from initialize(conf, fs, home), this one does not assume trash always under /user/$USER due to HDFS encryption zone.- Overrides:
initializein classTrashPolicy- Parameters:
conf- the configuration to be usedfs- the filesystem to be used
-
isEnabled
public boolean isEnabled()Description copied from class:TrashPolicyReturns whether the Trash Policy is enabled for this filesystem.- Specified by:
isEnabledin classTrashPolicy- Returns:
- if isEnabled true,not false.
-
moveToTrash
Description copied from class:TrashPolicyMove a file or directory to the current trash directory.- Specified by:
moveToTrashin classTrashPolicy- Parameters:
path- the path.- Returns:
- false if the item is already in the trash or trash is disabled
- Throws:
IOException- raised on errors performing I/O.
-
createCheckpoint
Description copied from class:TrashPolicyCreate a trash checkpoint.- Specified by:
createCheckpointin classTrashPolicy- Throws:
IOException- raised on errors performing I/O.
-
createCheckpoint
- Throws:
IOException
-
deleteCheckpoint
Description copied from class:TrashPolicyDelete old trash checkpoint(s).- Specified by:
deleteCheckpointin classTrashPolicy- Throws:
IOException- raised on errors performing I/O.
-
deleteCheckpointsImmediately
Description copied from class:TrashPolicyDelete all checkpoints immediately, ie empty trash.- Specified by:
deleteCheckpointsImmediatelyin classTrashPolicy- Throws:
IOException- raised on errors performing I/O.
-
getCurrentTrashDir
Description copied from class:TrashPolicyGet the current working directory of the Trash Policy This API does not work with files deleted from encryption zone when HDFS data encryption at rest feature is enabled as rename file between encryption zones or encryption zone and non-encryption zone is not allowed. The caller is recommend to use the new API TrashPolicy#getCurrentTrashDir(Path path). It returns the trash location correctly for the path specified no matter the path is in encryption zone or not.- Specified by:
getCurrentTrashDirin classTrashPolicy- Returns:
- the path.
-
getCurrentTrashDir
Description copied from class:TrashPolicyGet the current trash directory for path specified based on the Trash Policy- Overrides:
getCurrentTrashDirin classTrashPolicy- Parameters:
path- path to be deleted- Returns:
- current trash directory for the path to be deleted
- Throws:
IOException- raised on errors performing I/O.
-
getEmptier
Description copied from class:TrashPolicyReturn aRunnablethat periodically empties the trash of all users, intended to be run by the superuser.- Specified by:
getEmptierin classTrashPolicy- Returns:
- Runnable.
- Throws:
IOException- raised on errors performing I/O.
-
initialize(Configuration, FileSystem)instead.