it.geosolutions.tools.io.file
Class FileRemover

java.lang.Object
  extended by java.lang.Thread
      extended by it.geosolutions.tools.io.file.FileRemover
All Implemented Interfaces:
Runnable

Deprecated. Use FileGarbageCollector instead

public final class FileRemover
extends Thread

Simple class implementing a Thread that periodically tries to delete the files that were provided to him.

It tries to delete each file at most maxAttempts number of times. If this number is exceeded it simply throws the file away notifying the users with a warning message.

Author:
Simone Giannecchini, GeoSolutions.

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FileRemover()
          Deprecated. Default constructor for a FileRemover.
FileRemover(long period, int priority, int maxattempts)
          Deprecated. Constructor for a FileRemover.
 
Method Summary
 void addFile(File fileToDelete)
          Deprecated. Asks this FileRemover to clean up this file.
static List<File> collectOlder(long time, int daysAgo, File root)
          Deprecated.  
 int getMaxAttempts()
          Deprecated. Retrieves the maximum number of times we try to delete a file before giving up.
 long getPeriod()
          Deprecated. Retrieves the period in seconds for this FileRemover .
 void run()
          Deprecated. This method does the magic: iterate over all the files try to delete it if successful drop the file references if not successful increase the attempts count for the file and call the gc.
 void setMaxAttempts(int maxAttempts)
          Deprecated. Sets the maximum number of times we try to delete a file before giving up.
 void setPeriod(long period)
          Deprecated. Sets the period in seconds for this FileRemover .
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileRemover

public FileRemover()
Deprecated. 
Default constructor for a FileRemover.


FileRemover

public FileRemover(long period,
                   int priority,
                   int maxattempts)
Deprecated. 
Constructor for a FileRemover.

Parameters:
period - default time period between two cycles.
priority - is the priority for the cleaner thread.
maxattempts - maximum number of time the cleaner thread tries to delete a file.
Method Detail

collectOlder

public static List<File> collectOlder(long time,
                                      int daysAgo,
                                      File root)
Deprecated. 

addFile

public void addFile(File fileToDelete)
Deprecated. 
Asks this FileRemover to clean up this file.

Parameters:
fileToDelete - File that we want to permanently delete.

run

public void run()
Deprecated. 
This method does the magic:
  1. iterate over all the files
  2. try to delete it
  3. if successful drop the file references
  4. if not successful increase the attempts count for the file and call the gc. If the maximum number was exceeded drop the file and warn the user
  5. Specified by:
    run in interface Runnable
    Overrides:
    run in class Thread

getMaxAttempts

public int getMaxAttempts()
Deprecated. 
Retrieves the maximum number of times we try to delete a file before giving up.

Returns:
the maximum number of times we try to delete a file before giving up.

setMaxAttempts

public void setMaxAttempts(int maxAttempts)
Deprecated. 
Sets the maximum number of times we try to delete a file before giving up.

Parameters:
maxAttempts - the maximum number of times we try to delete a file before giving up.

getPeriod

public long getPeriod()
Deprecated. 
Retrieves the period in seconds for this FileRemover .

Returns:
the period in seconds for this FileRemover .

setPeriod

public void setPeriod(long period)
Deprecated. 
Sets the period in seconds for this FileRemover .

Parameters:
period - the new period for this FileRemover .


Copyright © 2011-2012 GeoSolutions. All Rights Reserved.