Package org.apache.hadoop.fs
Class TrashPolicy
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.fs.TrashPolicy
- All Implemented Interfaces:
Configurable
This interface is used for implementing different Trash policies.
Provides factory method to create instances of the configured Trash policy.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidCreate a trash checkpoint.abstract voidDelete old trash checkpoint(s).abstract voidDelete all checkpoints immediately, ie empty trash.abstract PathGet 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 Policyabstract RunnableReturn aRunnablethat periodically empties the trash of all users, intended to be run by the superuser.static TrashPolicygetInstance(Configuration conf, FileSystem fs) Get an instance of the configured TrashPolicy based on the value of the configuration parameter fs.trash.classname.static TrashPolicygetInstance(Configuration conf, FileSystem fs, Path home) Deprecated.voidinitialize(Configuration conf, FileSystem fs) Used to setup the trash policy.abstract voidinitialize(Configuration conf, FileSystem fs, Path home) Deprecated.Useinitialize(Configuration, FileSystem)instead.abstract booleanReturns whether the Trash Policy is enabled for this filesystem.abstract booleanmoveToTrash(Path path) Move a file or directory to the current trash directory.Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
-
Field Details
-
fs
-
trash
-
deletionInterval
protected long deletionInterval
-
-
Constructor Details
-
TrashPolicy
public TrashPolicy()
-
-
Method Details
-
initialize
Deprecated.Useinitialize(Configuration, FileSystem)instead.Used to setup the trash policy. Must be implemented by all TrashPolicy implementations.- Parameters:
conf- the configuration to be usedfs- the filesystem to be usedhome- the home directory
-
initialize
Used 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.- Parameters:
conf- the configuration to be usedfs- the filesystem to be used
-
isEnabled
public abstract boolean isEnabled()Returns whether the Trash Policy is enabled for this filesystem.- Returns:
- if isEnabled true,not false.
-
moveToTrash
Move a file or directory to the current trash directory.- 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
Create a trash checkpoint.- Throws:
IOException- raised on errors performing I/O.
-
deleteCheckpoint
Delete old trash checkpoint(s).- Throws:
IOException- raised on errors performing I/O.
-
deleteCheckpointsImmediately
Delete all checkpoints immediately, ie empty trash.- Throws:
IOException- raised on errors performing I/O.
-
getCurrentTrashDir
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. 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.- Returns:
- the path.
-
getCurrentTrashDir
Get the current trash directory for path specified based on the Trash Policy- 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
Return aRunnablethat periodically empties the trash of all users, intended to be run by the superuser.- Returns:
- Runnable.
- Throws:
IOException- raised on errors performing I/O.
-
getInstance
Deprecated.UsegetInstance(Configuration, FileSystem)instead.Get an instance of the configured TrashPolicy based on the value of the configuration parameter fs.trash.classname.- Parameters:
conf- the configuration to be usedfs- the file system to be usedhome- the home directory- Returns:
- an instance of TrashPolicy
-
getInstance
Get an instance of the configured TrashPolicy based on the value of the configuration parameter fs.trash.classname.- Parameters:
conf- the configuration to be usedfs- the file system to be used- Returns:
- an instance of TrashPolicy
-
getInstance(Configuration, FileSystem)instead.