Package com.nt.udc.ei.transport
Class OpenFileEITransport
java.lang.Object
com.nt.udc.ndk.node.EITransport
com.nt.udc.ei.transport.OpenFileEITransport
- All Implemented Interfaces:
DataProviderIfc
,DCTransport
,FileDataProviderIfc
,Runnable
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 Summary
FieldsModifier and TypeFieldDescriptionprotected static int
Default polling interval if none is specified in config file:protected static int
Default time awaiting data if none is specified in config file:protected static String
protected boolean
True if an active file become a closed file.protected String
Used as the key string for active file filter.protected File
Active scratch file before becomming closed.protected String
Used as the key string for closed file filter.protected ConfigIfc
to get information from the node GUIprotected boolean
Determines whether to delete the local files after processing them.protected InputFileProcessorIfc
protected com.nt.common.util.SMGLock
Used to synchronize the thread in which this object runs and the EI Node's main thread when shutting odwn.protected File
Represents the local directory from which this object gets files to process.protected LoggerIfc
Represents the logging facility for the EI node using this object.protected FileSelectorIfc
Used to select the desired files from the given directory.protected long
Repensents the idle time in milliseconds that awaiting next set of billing records to be added to the active AMA DIRP file.protected static String
Config string in the node's general config file:protected static String
Fields inherited from class com.nt.udc.ndk.node.EITransport
dataReceiver, fdChecked, filedataReceiver, fileduplicateCheck, fileToProcess, inputCount, lockFile, movedFile, node, pollingInterval, processing, processingData, running
-
Constructor Summary
ConstructorsConstructorDescriptionConstructorOpenFileEITransport
(EINode einode, File syncDirectory, String activeFilter, String closedFilter, com.nt.common.util.SMGLock lock, FileSelectorIfc fileSelector, InputFileProcessorIfc fileProcessor) Use this form when monitoring a local directory directly, as opposed to waiting to be notified when files are ready to process. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns "delete scratch files" flag:Allows a DataReceiver to obtain the available data in a known format.getData()
Allows a DataReceiver to obtain the available data in a known format.boolean
Determines the given File object of the file is open/active.boolean
Allows a DataReceiver to determine whether some data is available for processingprotected 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 closedprotected void
processFiles
(Vector filesToProcess) Here's where we actually parse the files and extract the data of interest.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.void
shutdown()
Specifies actions needed to shut down the thread in which this object runs.Methods inherited from class com.nt.udc.ndk.node.EITransport
getCurrArchFile, getData, getDataReceiver, getDubCheckObj, getDupCheckFlag, getFileBulkData, getFileData, getFileDataReceiver, getFileList, getMovedFileStatus, getNode, getPollingInterval, getProcessedArchFile, handleRejectOfFile, incrementIn, incrementIn, isEndOfFile, isFileDataAvailable, isHealthy, isProcessing, isProcessingData, isStartOfFile, moveCurrentFileToBackUp, openInputFile, rejectFile, removeProcessedFile, setCountsSuspect, setDataReceiver, setFileDataReceiver, setFileToProcess, setMovedFileStatus, setNode, setPollingInterval, setProcessedArchFile, setProcessing, signalBatchCompletion, validOIMinorType
-
Field Details
-
POLLING_INTERVAL
Config string in the node's general config file: -
TIME_AWAITING_DATA
-
DELETE_SCRATCH_FILES
-
DEFAULT_POLLING_INTERVAL
protected static int DEFAULT_POLLING_INTERVALDefault polling interval if none is specified in config file: -
DEFAULT_TIME_AWAITING_DATA
protected static int DEFAULT_TIME_AWAITING_DATADefault time awaiting data if none is specified in config file: -
m_logger
Represents the logging facility for the EI node using this object. -
m_config
to get information from the node GUI -
m_localDir
Represents the local directory from which this object gets files to process. -
m_time_awaiting_data
protected long m_time_awaiting_dataRepensents 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_deleteScratchFilesDetermines whether to delete the local files after processing them. -
m_ioLock
protected com.nt.common.util.SMGLock m_ioLockUsed 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
Used to select the desired files from the given directory. -
m_fileProcessor
-
m_activefilter
Used as the key string for active file filter. -
m_closedfilter
Used as the key string for closed file filter. -
m_activeScratchFile
Active scratch file before becomming closed. -
m_activeFileRenamed
protected boolean m_activeFileRenamedTrue 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 interfaceDCTransport
- Specified by:
shutdown
in classEITransport
-
getData
Allows a DataReceiver to obtain the available data in a known format.- Specified by:
getData
in interfaceDataProviderIfc
- Specified by:
getData
in classEITransport
- Returns:
- DCFieldContainer object containing the data that is available for processing
-
getBulkData
Allows a DataReceiver to obtain the available data in a known format.- Specified by:
getBulkData
in interfaceDataProviderIfc
- Specified by:
getBulkData
in classEITransport
- 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 interfaceDataProviderIfc
- Specified by:
isDataAvailable
in classEITransport
- 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 interfaceRunnable
- Specified by:
run
in classEITransport
-
processFiles
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
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
Determines the given File object of the file is open/active.- Parameters:
file
- The File object of the file.
-