Package com.nt.udc.ei.transport
Class FileEITransport
java.lang.Object
com.nt.udc.ndk.node.EITransport
com.nt.udc.ei.transport.FileEITransport
- All Implemented Interfaces:
DataProviderIfc
,DCTransport
,FileDataProviderIfc
,Runnable
- Direct Known Subclasses:
GenericFlatFileProcessor
,NAREIFileProcessor
Used to represent a class that provides
the processing "engine" for files that
are retrieved or sent from network
elements. This class provides a mechanism
to monitor a directory for files to process
either via a "SynchronizedDirectory" object
or just a standard File Object. The
"SynchronizedDirectory" object is used when
objects of this class need to be informed
when files are available, and the standard
File object can be used when objects of this
class monitor a directory themselves.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static int
Default polling interval if none is specified in config file:protected static String
Config string in the node's general config file:protected boolean
Determines whether to delete the local files after processing them.protected boolean
protected FileEISequenceCheck
protected boolean
static final String
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 boolean
protected String
Specifies the suffix of the files this node will processprotected 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 boolean
static final String
static final String
protected static String
Config string in the node's general config file:protected SynchronizedDirectory
Represents the local directory from which this object gets files to process.protected boolean
Determines whether to use a SynchronizedDirectory or just a File object for monitoring for files to process.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
ConstructorsConstructorDescriptionFileEITransport
(DCNode node, SynchronizedDirectory sd, String suffix, com.nt.common.util.SMGLock lock) Use this form when you want to be notified when files are ready to be processed.FileEITransport
(DCNode node, File sd, String suffix, com.nt.common.util.SMGLock lock) 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 local files" flag:protected FilenameFilter
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.protected long
Returns the length stored in the scratch file.boolean
Allows a DataReceiver to determine whether some data is available for processingboolean
This method is used to check if the transport is fully functional.boolean
isLessThan
(String value1, String value2) void
moveCurrentFileToBackUp
(File currentFile, String newFilename) protected abstract void
processFiles
(Vector filesToProcess) Here's where we actually parse the files and extract the data of interest.protected long
readLength
(RandomAccessFile recoveryFile) This method is used to read the number of bytes already read and processed.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.protected void
setActFilter
(FilenameFilter newFilter) void
setDubCheckObj
(FileEIDuplicateCheck fileduplicateCheck) void
setDupCheckFlag
(boolean fdChecked) void
setSeqCheckFlag
(boolean fsChecked) void
setSeqCheckObj
(FileEISequenceCheck fileSeqCheck) void
shutdown()
Specifies actions needed to shut down the thread in which this object runs.String[]
protected void
writeLength
(File scratchfile, long len) Record a long in a file - used to write a length in a scratch file to keep track of how much of a file has been processed.protected void
writeLength
(RandomAccessFile recoveryFile, long len) This method is used to store the current input file's length in the recovery file.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, isProcessing, isProcessingData, isStartOfFile, 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: -
DELETE_LOCAL_FILES
Config string in the node's general config file: -
MULTI_THREADED
- See Also:
-
ORDER_REQUIRED
- See Also:
-
INPUT_BACKUP_DIR
- See Also:
-
DEFAULT_POLLING_INTERVAL
protected static int DEFAULT_POLLING_INTERVALDefault polling interval if none is specified in config file: -
deleteLocalFiles
protected boolean deleteLocalFilesDetermines whether to delete the local files after processing them. -
logger
Represents the logging facility for the EI node using this object. -
scratchDir
Represents the local directory from which this object gets files to process. -
localDir
Represents the local directory from which this object gets files to process. -
useSynchronizedDirectory
protected boolean useSynchronizedDirectoryDetermines whether to use a SynchronizedDirectory or just a File object for monitoring for files to process. -
itsFileSuffix
Specifies the suffix of the files this node will process -
ioLock
protected com.nt.common.util.SMGLock 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. -
mtChecked
protected boolean mtChecked -
isOrdered
protected boolean isOrdered -
fileLevelTransaction
protected boolean fileLevelTransaction -
fileSeqCheck
-
fsChecked
protected boolean fsChecked
-
-
Constructor Details
-
FileEITransport
public FileEITransport(DCNode node, File sd, String suffix, com.nt.common.util.SMGLock lock) 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:
node
- specifies the DCNode using this processing enginesd
- specifies the directory from which this node gets files to processsuffix
- specifies the suffix of the files this node will processlock
- used to properly shutdown the EI and all its threads- Throws:
NodeStartException
-
FileEITransport
public FileEITransport(DCNode node, SynchronizedDirectory sd, String suffix, com.nt.common.util.SMGLock lock) throws NodeStartException Use this form when you want to be notified when files are ready to be processed. (This is the form used by EI's that retrieve files via FTP.)- Parameters:
node
- specifies the DCNode using this processing enginesd
- specifies the directory from which this node gets files to processsuffix
- specifies the suffix of the files this node will processlock
- used to properly shutdown the EI and all its threads- 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
-
deleteLocalFiles
public boolean deleteLocalFiles()Returns "delete local files" flag:- Returns:
- value of flag
-
writeLength
Record a long in a file - used to write a length in a scratch file to keep track of how much of a file has been processed. Used for recovering when the node is shut down prematurely (or crashes or dies unexpectedly). To use this, call it from the appropriate place in your version of the "processFiles" method. -
getLength
Returns the length stored in the scratch file. Used to keep track of how much of a file has been processed.- Parameters:
file
- Specifies the scratch file.- Returns:
- number of bytes that have already been read and processed.
-
isHealthy
public boolean isHealthy()This method is used to check if the transport is fully functional.- Specified by:
isHealthy
in interfaceDCTransport
- Overrides:
isHealthy
in classEITransport
- Returns:
- true if the transport is healthy, false otherwise
-
writeLength
This method is used to store the current input file's length in the recovery file. Subclasses should call this method.- Parameters:
recoveryFile
- Specifies the recovery file.
-
readLength
This method is used to read the number of bytes already read and processed. Subclasses should call this method.- Parameters:
recoveryFile
- Specifies the recovery file.
-
getActFilter
-
setActFilter
-
sortFiles
-
isLessThan
-
setDupCheckFlag
public void setDupCheckFlag(boolean fdChecked) -
setSeqCheckFlag
public void setSeqCheckFlag(boolean fsChecked) -
setDubCheckObj
-
setSeqCheckObj
-
getInputBackupDir
-
moveCurrentFileToBackUp
- Overrides:
moveCurrentFileToBackUp
in classEITransport
- Throws:
IOException
-