Class FtpFileTracker

java.lang.Object
com.metasolv.nm.collector.file.FtpFileTracker

public class FtpFileTracker extends Object
Used to keep track of files that have been retrieved from a specific FTP server. This will ensure that a file is not retrieved more than once. This class is based on the SmdrFtpFileTracker class that was designed for the SMDR cartridge.
  • Field Details

    • DEFAULT_DAYS_TO_TRACK

      public static final int DEFAULT_DAYS_TO_TRACK
      See Also:
    • sortedFilenameSet

      protected TreeSet sortedFilenameSet
    • trackerFilePrefix

      protected String trackerFilePrefix
    • dateFmt

      protected ThreadLocal<SimpleDateFormat> dateFmt
    • trackerFileList

      protected ArrayList trackerFileList
    • currentWriter

      protected PrintWriter currentWriter
    • scratchDirectory

      protected File scratchDirectory
    • oldTrackerFileRemoverThread

      protected Thread oldTrackerFileRemoverThread
    • keepRunning

      protected boolean keepRunning
    • daysToTrack

      protected int daysToTrack
  • Constructor Details

    • FtpFileTracker

      public FtpFileTracker(String filePrefix, File scratchDirectory, int days)
  • Method Details

    • shutdown

      public void shutdown()
    • track

      public boolean track(String ipAddress, String filename)
      Adds the specified IP address and file name to this tracker if it is not already present. The information will be saved to file.
      Parameters:
      ipAddress - IP address to be added to this tracker.
      filename - file name to be added to this tracker.
      Returns:
      true if the tracker did not already contain the specified file name.
    • contains

      public boolean contains(String ipAddress, String filename)
      Search this tracker for the given IP address + file name combination.
      Parameters:
      ipAddress - IP address to be checked within this tracker.
      filename - file name to be checked within this tracker.
      Returns:
      true if the tracker contains this file name.
    • flushOldRecords

      public void flushOldRecords() throws IOException
      Throws:
      IOException
    • makeTodayTrackerFilename

      protected String makeTodayTrackerFilename()
    • makeTrackerFilename

      protected String makeTrackerFilename(Date date)
    • readTrackerFile

      protected void readTrackerFile(File inputTrackerFile, TreeSet filenameSet)
    • init

      public void init() throws IOException
      Throws:
      IOException
    • initTrackerFileList

      protected void initTrackerFileList(Calendar cal, int daysToTrack)
    • removeOutdatedTrackerFiles

      protected void removeOutdatedTrackerFiles()
    • initSortedFilenameSet

      protected void initSortedFilenameSet()