org.apache.hadoop.fs
Class TrashPolicy

java.lang.Object
  extended by org.apache.hadoop.conf.Configured
      extended by org.apache.hadoop.fs.TrashPolicy
All Implemented Interfaces:
Configurable

@InterfaceAudience.Public
@InterfaceStability.Evolving
public abstract class TrashPolicy
extends Configured

This interface is used for implementing different Trash policies. Provides factory method to create instances of the configured Trash policy.


Field Summary
protected  long deletionInterval
           
protected  FileSystem fs
           
protected  Path trash
           
 
Constructor Summary
TrashPolicy()
           
 
Method Summary
abstract  void createCheckpoint()
          Create a trash checkpoint.
abstract  void deleteCheckpoint()
          Delete old trash checkpoint(s).
abstract  Path getCurrentTrashDir()
          Get the current working directory of the Trash Policy
abstract  Runnable getEmptier()
          Return a Runnable that periodically empties the trash of all users, intended to be run by the superuser.
static TrashPolicy getInstance(Configuration conf, FileSystem fs, Path home)
          Get an instance of the configured TrashPolicy based on the value of the configuration parameter fs.trash.classname.
abstract  void initialize(Configuration conf, FileSystem fs, Path home)
          Used to setup the trash policy.
abstract  boolean isEnabled()
          Returns whether the Trash Policy is enabled for this filesystem
abstract  boolean moveToTrash(Path path)
          Move a file or directory to the current trash directory.
 
Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fs

protected FileSystem fs

trash

protected Path trash

deletionInterval

protected long deletionInterval
Constructor Detail

TrashPolicy

public TrashPolicy()
Method Detail

initialize

public abstract void initialize(Configuration conf,
                                FileSystem fs,
                                Path home)
Used to setup the trash policy. Must be implemented by all TrashPolicy implementations

Parameters:
conf - the configuration to be used
fs - the filesystem to be used
home - the home directory

isEnabled

public abstract boolean isEnabled()
Returns whether the Trash Policy is enabled for this filesystem


moveToTrash

public abstract boolean moveToTrash(Path path)
                             throws IOException
Move a file or directory to the current trash directory.

Returns:
false if the item is already in the trash or trash is disabled
Throws:
IOException

createCheckpoint

public abstract void createCheckpoint()
                               throws IOException
Create a trash checkpoint.

Throws:
IOException

deleteCheckpoint

public abstract void deleteCheckpoint()
                               throws IOException
Delete old trash checkpoint(s).

Throws:
IOException

getCurrentTrashDir

public abstract Path getCurrentTrashDir()
Get the current working directory of the Trash Policy


getEmptier

public abstract Runnable getEmptier()
                             throws IOException
Return a Runnable that periodically empties the trash of all users, intended to be run by the superuser.

Throws:
IOException

getInstance

public static TrashPolicy getInstance(Configuration conf,
                                      FileSystem fs,
                                      Path home)
Get an instance of the configured TrashPolicy based on the value of the configuration parameter fs.trash.classname.

Parameters:
conf - the configuration to be used
fs - the file system to be used
home - the home directory
Returns:
an instance of TrashPolicy


Copyright © 2014 Apache Software Foundation. All Rights Reserved.