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 intDefault polling interval if none is specified in config file:protected static StringConfig string in the node's general config file:protected booleanDetermines whether to delete the local files after processing them.protected booleanprotected FileEISequenceCheckprotected booleanstatic final Stringprotected com.nt.common.util.SMGLockUsed to synchronize the thread in which this object runs and the EI Node's main thread when shutting odwn.protected booleanprotected StringSpecifies the suffix of the files this node will processprotected FileRepresents the local directory from which this object gets files to process.protected LoggerIfcRepresents the logging facility for the EI node using this object.protected booleanstatic final Stringstatic final Stringprotected static StringConfig string in the node's general config file:protected SynchronizedDirectoryRepresents the local directory from which this object gets files to process.protected booleanDetermines 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 TypeMethodDescriptionbooleanReturns "delete local files" flag:protected FilenameFilterAllows 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 longReturns the length stored in the scratch file.booleanAllows a DataReceiver to determine whether some data is available for processingbooleanThis method is used to check if the transport is fully functional.booleanisLessThan(String value1, String value2) voidmoveCurrentFileToBackUp(File currentFile, String newFilename) protected abstract voidprocessFiles(Vector filesToProcess) Here's where we actually parse the files and extract the data of interest.protected longreadLength(RandomAccessFile recoveryFile) This method is used to read the number of bytes already read and processed.voidrun()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 voidsetActFilter(FilenameFilter newFilter) voidsetDubCheckObj(FileEIDuplicateCheck fileduplicateCheck) voidsetDupCheckFlag(boolean fdChecked) voidsetSeqCheckFlag(boolean fsChecked) voidsetSeqCheckObj(FileEISequenceCheck fileSeqCheck) voidshutdown()Specifies actions needed to shut down the thread in which this object runs.String[]protected voidwriteLength(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 voidwriteLength(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:
shutdownin interfaceDCTransport- Specified by:
shutdownin classEITransport
-
getData
Allows a DataReceiver to obtain the available data in a known format.- Specified by:
getDatain interfaceDataProviderIfc- Specified by:
getDatain 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:
getBulkDatain interfaceDataProviderIfc- Specified by:
getBulkDatain 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:
isDataAvailablein interfaceDataProviderIfc- Specified by:
isDataAvailablein 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:
runin interfaceRunnable- Specified by:
runin 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:
isHealthyin interfaceDCTransport- Overrides:
isHealthyin 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:
moveCurrentFileToBackUpin classEITransport- Throws:
IOException
-