Class OpenFileEITransport

java.lang.Object
com.nt.udc.ndk.node.EITransport
com.nt.udc.ei.transport.OpenFileEITransport
All Implemented Interfaces:
DataProviderIfc, DCTransport, FileDataProviderIfc, Runnable

public class OpenFileEITransport extends EITransport
This class is used to represent a class that provides the processing "engine" for files that are sent from network elements ("push" mode only). This class provides a mechanism to monitor a directory for files to process via a standard File Object. The standard File object can be used when objects of this class monitor a directory themselves. The difference between FileEITransport class and this class is that this class will process either an open/active file or a closed file.
  • Field Details

    • POLLING_INTERVAL

      protected static String POLLING_INTERVAL
      Config string in the node's general config file:
    • TIME_AWAITING_DATA

      protected static String TIME_AWAITING_DATA
    • DELETE_SCRATCH_FILES

      protected static String DELETE_SCRATCH_FILES
    • DEFAULT_POLLING_INTERVAL

      protected static int DEFAULT_POLLING_INTERVAL
      Default polling interval if none is specified in config file:
    • DEFAULT_TIME_AWAITING_DATA

      protected static int DEFAULT_TIME_AWAITING_DATA
      Default time awaiting data if none is specified in config file:
    • m_logger

      protected LoggerIfc m_logger
      Represents the logging facility for the EI node using this object.
    • m_config

      protected ConfigIfc m_config
      to get information from the node GUI
    • m_localDir

      protected File m_localDir
      Represents the local directory from which this object gets files to process.
    • m_time_awaiting_data

      protected long m_time_awaiting_data
      Repensents the idle time in milliseconds that awaiting next set of billing records to be added to the active AMA DIRP file.
    • m_deleteScratchFiles

      protected boolean m_deleteScratchFiles
      Determines whether to delete the local files after processing them.
    • m_ioLock

      protected com.nt.common.util.SMGLock m_ioLock
      Used to synchronize the thread in which this object runs and the EI Node's main thread when shutting odwn. This "lock" object can be used to ensure that all underlying threads (like the one in which this guy runs) are finished with whatever they were in the middle of doing.
    • m_openFileSelector

      protected FileSelectorIfc m_openFileSelector
      Used to select the desired files from the given directory.
    • m_fileProcessor

      protected InputFileProcessorIfc m_fileProcessor
    • m_activefilter

      protected String m_activefilter
      Used as the key string for active file filter.
    • m_closedfilter

      protected String m_closedfilter
      Used as the key string for closed file filter.
    • m_activeScratchFile

      protected File m_activeScratchFile
      Active scratch file before becomming closed.
    • m_activeFileRenamed

      protected boolean m_activeFileRenamed
      True if an active file become a closed file.
  • Constructor Details

    • OpenFileEITransport

      public OpenFileEITransport()
      Constructor
    • OpenFileEITransport

      public OpenFileEITransport(EINode einode, File syncDirectory, String activeFilter, String closedFilter, com.nt.common.util.SMGLock lock, FileSelectorIfc fileSelector, InputFileProcessorIfc fileProcessor) throws NodeStartException
      Use this form when monitoring a local directory directly, as opposed to waiting to be notified when files are ready to process. (This is the form used by EI's that process local files.)
      Parameters:
      einode - specifies the EINode using this processing engine.
      activeFilter - specifies the prefix of the active files this node will process.
      closedFilter - specifies the prefix of the closed files this node will process.
      lock - used to properly shutdown the EI and all its threads.
      fileSelector - specifies the file selector.
      fileProcessor - specifies the AMA DIRP files processor.
      inputDirectory - specifies the directory from which this node gets files to process.
      Throws:
      NodeStartException
  • Method Details

    • shutdown

      public void shutdown()
      Specifies actions needed to shut down the thread in which this object runs.
      Specified by:
      shutdown in interface DCTransport
      Specified by:
      shutdown in class EITransport
    • getData

      public DCFieldContainer getData()
      Allows a DataReceiver to obtain the available data in a known format.
      Specified by:
      getData in interface DataProviderIfc
      Specified by:
      getData in class EITransport
      Returns:
      DCFieldContainer object containing the data that is available for processing
    • getBulkData

      public DCFieldContainer[] getBulkData()
      Allows a DataReceiver to obtain the available data in a known format.
      Specified by:
      getBulkData in interface DataProviderIfc
      Specified by:
      getBulkData in class EITransport
      Returns:
      DCFieldContainer objects containing the data that is available for processing
    • isDataAvailable

      public boolean isDataAvailable()
      Allows a DataReceiver to determine whether some data is available for processing
      Specified by:
      isDataAvailable in interface DataProviderIfc
      Specified by:
      isDataAvailable in class EITransport
      Returns:
      true, if data is available
    • run

      public void run()
      This is what gets executed as this object runs in its thread: Basically, wait for files that need to be processed and then process them. Continue until signalled to shut down.
      Specified by:
      run in interface Runnable
      Specified by:
      run in class EITransport
    • processFiles

      protected void processFiles(Vector filesToProcess)
      Here's where we actually parse the files and extract the data of interest. Make sure you handle shutting down the node correctly as well as synchronizing all necessary threads. The SynchronizedDirectory class provides a synchronizing capability for this class and the transport class. There is also an SMGLock object passed into the constructor of this class for synchronizing this thread with the parent EI node thread (when shutting down). The trick is to never let this method get wrapped up in a time-consuming processing loop (in case the user wants to shut down this node in the middle of such a loop).
      Parameters:
      filesToProcess - list of filenames that need to be processed
    • processFile

      protected void processFile(File fileToProcess)
      Logic of processing a file: Pre process this file if this file is a close file then process data of this file otherwise, while this active/open file exist do process data of this file sleep some time util timeout Post process this file Repeat the whole process if the active file has been closed
      Parameters:
      fileToProcess - A single file that need to be processed
    • deleteScratchFiles

      public boolean deleteScratchFiles()
      Returns "delete scratch files" flag:
      Returns:
      value of flag
    • isActive

      public boolean isActive(File file)
      Determines the given File object of the file is open/active.
      Parameters:
      file - The File object of the file.