Package com.nt.udc.nar
Class NARFileManager
java.lang.Object
com.nt.udc.nar.NARStreamHandler
com.nt.udc.nar.NARFileManager
- All Implemented Interfaces:
DataProviderIfc
,DataReceiverIfc
,DCStreamHandler
,FileDataProviderIfc
,FileDataReceiverIfc
- Direct Known Subclasses:
NARFileManagerMT
Manages a node's NAR input files and NAR output files. This class
is also responsible for routing to specific NAR output files, if
desired.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DataProviderIfc
Reference to the object providing data to this NAR router.protected DataReceiverIfc
Reference to the object receiving data from this NAR router.protected FileDataProviderIfc
Reference to the object providing file data to this NAR router.protected FileDataReceiverIfc
Reference to the object receiving file data from this NAR router.Fields inherited from class com.nt.udc.nar.NARStreamHandler
inputShutdown, narsIn, narsOut, np, outputShutdown
-
Constructor Summary
ConstructorsConstructorDescriptionNARFileManager
(DCNode dcNode) Constructs a NARFileManager with the given node.NARFileManager
(DCNode dcNode, boolean createWriter) NARFileManager
(DCNode dcNode, boolean createWriter, boolean isMultiThreaded, int threadCount, int currThread, boolean isOrdered) NARFileManager
(DCNode dcNode, boolean isMultiThreaded, int threadCount, int currThread) NARFileManager
(DCNode dcNode, boolean isMultiThreaded, int threadCount, int currThread, boolean isOrdered) -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
This method invokes a NarReader method which will check for an empty input directory.boolean
cleanup()
Deletes NARs files that have been processedvoid
void
When this method is called by the DataProvider, a return call is made to the provider'sgetData()
method.void
Allows a FileDataProvider to indicate that some data is available for processingAllows a DataReceiver to obtain the available data in a known format.Allows a DataReceiver to obtain the currently processing .arch filegetData()
Allows a DataReceiver to obtain the available data in a known format.Allows a DataReceiver to obtain the available data in a known format.Returns the object from which this DataReceiver is receiving data.Returns the object to which this DataProvider is sending data.Allows a FileDataReceiver to obtain the available data in a known format.Allows a FileDataReceiver to obtain the available data in a known format.Gets the object that is holding data for this FileDataReceiverGets the object that is retrieving data from this FileDataProviderfinal FilenameGenerator
Returns the current filename generatorThis method returns the node ID.Allows a DataReceiver to obtain the last processed .arch filelong
This must return a count of how many records this node has read in, since it started.void
To handle the remaining input files when there is reject of a fileboolean
Allows a DataReceiver to determine whether some data is available for processingboolean
Determines if record received is an End of file indicationboolean
Allows a FileDataReceiver to determine whether some file is available for processingboolean
Determines if the record received is start of file indicationvoid
moveToReadyToOut
(boolean initNew) Make cache file as ready to moveToOutput()void
processData
(DCFieldContainer data) Manipulates the data provided by its DataProvider.void
processData
(DCFieldContainer[] data) Manipulates the data provided by its DataProvider.boolean
processEndOfFileData
(String transactionID) Allows FileDataProvider to indicate end of file recordboolean
Manipulates the data provided by its DataProviderboolean
processFileData
(DCFieldContainer[] data) Manipulates the set of data provided by its DataProviderboolean
Allows FileDataProvider to indicate rejection of the fileboolean
processStartOfFileData
(String fileName) Allows FileDataProvider to indicate start of fileReturns a set of DCFieldContainer objects from the data stream.readData()
Return a DCFieldContainer object from the data stream.readNAR()
Return a NAR from the data stream.Return a NAR from the data stream.NAR[]
readNARs()
Return an array of NARs from the data stream.NAR[]
Return an array of NARs from the data stream.boolean
Indicates data provider to stop reading from the input file and reject itvoid
removeProcessedFile
(File currArchFile) Allows a DataReceiver to remove .arch file once processed currArchFile - processed .arch filevoid
setDataProvider
(DataProviderIfc provider) Sets the object from which this DataReceiver will obtain its data.void
setDataReceiver
(DataReceiverIfc receiver) Sets the object to which this DataProvider will send its data.void
setFileDataProvider
(FileDataProviderIfc provider) Sets the object from which this FileDataReceiver will obtain its data.void
setFileDataReceiver
(FileDataReceiverIfc receiver) Sets the object to which this FileDataProvider will send its data.final void
setFilenameGenerator
(FilenameGenerator filenameGen) Sets a new FilenameGeneratorvoid
setProcessedArchFile
(String processedArchFile) Sets the processed .arch file absolute pathvoid
setTransactionID
(String tID) void
shutdown()
This method invokes the shutdown method of each NarWriter object.void
For this implementation of the StreamHandler, simply set the flag that will prevent the input methods from allowing any more data into the node.void
For this implementation of the StreamHandler, there is no reason to stop the output stream without first stopping the input stream.void
signalBatchCompletion
(String batch) Allows a DataReceiver to know that the nars under the specified batch are completed and handed over to the Data receiverboolean
Writes a single NAR to the appropriate cache file.boolean
Writes multiple NARs to the appropriate cache fileboolean
Allows a DataReceiver to check if Minor Type supported for disaster recoveryMethods inherited from class com.nt.udc.nar.NARStreamHandler
getPerformanceMetrics, writeData, writeData
-
Field Details
-
dataProvider
Reference to the object providing data to this NAR router. -
dataReceiver
Reference to the object receiving data from this NAR router. -
fileDataProvider
Reference to the object providing file data to this NAR router. -
fileDataReceiver
Reference to the object receiving file data from this NAR router.
-
-
Constructor Details
-
NARFileManager
Constructs a NARFileManager with the given node. This NARFileManager will monitor the node's input/output directories (where appropriate), provide NAR input objects, and provide the mechanisms to send a processed NAR to the next node in the chain, possibly through routing.- Parameters:
dcNode
- Node to manage
-
NARFileManager
-
NARFileManager
public NARFileManager(DCNode dcNode, boolean isMultiThreaded, int threadCount, int currThread, boolean isOrdered) -
NARFileManager
-
NARFileManager
public NARFileManager(DCNode dcNode, boolean createWriter, boolean isMultiThreaded, int threadCount, int currThread, boolean isOrdered)
-
-
Method Details
-
shutdown
public void shutdown()This method invokes the shutdown method of each NarWriter object.- Specified by:
shutdown
in interfaceDCStreamHandler
- Overrides:
shutdown
in classNARStreamHandler
-
storeNARs
Writes multiple NARs to the appropriate cache file- Specified by:
storeNARs
in classNARStreamHandler
- Returns:
true
, if the write was successful.
-
storeNAR
Writes a single NAR to the appropriate cache file.- Specified by:
storeNAR
in classNARStreamHandler
- Returns:
true
, if the write was successful.
-
readNAR
Return a NAR from the data stream.- Specified by:
readNAR
in classNARStreamHandler
- Returns:
- Returns a single NAR.
-
readNAR
Return a NAR from the data stream.- Returns:
- Returns a single NAR.
-
readNARs
Return an array of NARs from the data stream.- Specified by:
readNARs
in classNARStreamHandler
- Returns:
- Returns an array of NARs.
-
readNARsFromFile
Return an array of NARs from the data stream.- Returns:
- Returns an array of NARs.
- Throws:
Exception
-
checkInput
public boolean checkInput()This method invokes a NarReader method which will check for an empty input directory.- Returns:
- true, if input directory contains files
-
getNodeID
This method returns the node ID.- Returns:
- node ID
-
getFilenameGenerator
Returns the current filename generator- Returns:
- current FilenameGenerator
-
setFilenameGenerator
Sets a new FilenameGenerator -
readData
Return a DCFieldContainer object from the data stream.- Specified by:
readData
in interfaceDCStreamHandler
- Overrides:
readData
in classNARStreamHandler
- Returns:
- Returns a single DCFieldContainer.
-
readBulkData
Returns a set of DCFieldContainer objects from the data stream.- Specified by:
readBulkData
in interfaceDCStreamHandler
- Returns:
- Returns an array of DCFieldContainer objects.
-
shutdownInput
public void shutdownInput()For this implementation of the StreamHandler, simply set the flag that will prevent the input methods from allowing any more data into the node. The NARFileManager will still be capable of processing any data that has already been queued and writing data to the 'output stream', as necessary.- Specified by:
shutdownInput
in interfaceDCStreamHandler
- Overrides:
shutdownInput
in classNARStreamHandler
-
cleanup
public boolean cleanup()Description copied from class:NARStreamHandler
Deletes NARs files that have been processed- Specified by:
cleanup
in interfaceDCStreamHandler
- Specified by:
cleanup
in classNARStreamHandler
-
shutdownOutput
public void shutdownOutput()For this implementation of the StreamHandler, there is no reason to stop the output stream without first stopping the input stream. Stop both the input and output capabilities of the NARFileManager.- Specified by:
shutdownOutput
in interfaceDCStreamHandler
- Overrides:
shutdownOutput
in classNARStreamHandler
-
isDataAvailable
public boolean isDataAvailable()Allows a DataReceiver to determine whether some data is available for processing- Specified by:
isDataAvailable
in interfaceDataProviderIfc
- Returns:
true
, if data is available
-
getData
Allows a DataReceiver to obtain the available data in a known format.- Specified by:
getData
in interfaceDataProviderIfc
- Returns:
- DCFieldContainer object containing the data that is available for processing
-
getData
Allows a DataReceiver to obtain the available data in a known format.- Specified by:
getData
in interfaceDataProviderIfc
- 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
- Returns:
- DCFieldContainer[] object containing the data that is available for processing
-
setDataReceiver
Sets the object to which this DataProvider will send its data.- Specified by:
setDataReceiver
in interfaceDataProviderIfc
- Parameters:
receiver
- Object which will receive data from this provider
-
getDataReceiver
Returns the object to which this DataProvider is sending data.- Specified by:
getDataReceiver
in interfaceDataProviderIfc
- Returns:
- Returns the DataReceiver of this provider.
-
dataIsAvailable
public void dataIsAvailable()When this method is called by the DataProvider, a return call is made to the provider'sgetData()
method. The resultingDCFieldContainer
is then passed to this receiver'sprocessData()
method.- Specified by:
dataIsAvailable
in interfaceDataReceiverIfc
-
processData
Manipulates the data provided by its DataProvider. In this case, the 'processing' is to simply write the NAR to the cache file.- Specified by:
processData
in interfaceDataReceiverIfc
- Parameters:
data
- The DCFieldContainer (actually a NAR) received from the DataProvider- Throws:
NodeProcessingException
-
processData
Manipulates the data provided by its DataProvider. In this case, the 'processing' is to simply write the NAR to the cache file.- Specified by:
processData
in interfaceDataReceiverIfc
- Parameters:
data
- The DCFieldContainer array (actually a set of NARs) received from the DataProvider- Throws:
NodeProcessingException
-
setDataProvider
Sets the object from which this DataReceiver will obtain its data.- Specified by:
setDataProvider
in interfaceDataReceiverIfc
- Parameters:
provider
- DataProvider of this receiver
-
getDataProvider
Returns the object from which this DataReceiver is receiving data.- Specified by:
getDataProvider
in interfaceDataReceiverIfc
- Returns:
- Returns the DataProvider of this receiver.
-
getRealNarsIn
public long getRealNarsIn()Description copied from class:NARStreamHandler
This must return a count of how many records this node has read in, since it started. The counts should be accurate, even if this node is an EI/CC. (as opposed to the narsIN counter, which won't count any input records if the node is an EI.)- Specified by:
getRealNarsIn
in classNARStreamHandler
- Returns:
-
moveToReadyToOut
public void moveToReadyToOut(boolean initNew) Description copied from interface:DCStreamHandler
Make cache file as ready to moveToOutput()- Specified by:
moveToReadyToOut
in interfaceDCStreamHandler
-
createNewCacheFile
public void createNewCacheFile()- Specified by:
createNewCacheFile
in interfaceDCStreamHandler
-
isFileDataAvailable
Description copied from interface:FileDataProviderIfc
Allows a FileDataReceiver to determine whether some file is available for processing- Specified by:
isFileDataAvailable
in interfaceFileDataProviderIfc
- Returns:
true
, if data is available- Throws:
Exception
-
isEndOfFile
Description copied from interface:FileDataProviderIfc
Determines if record received is an End of file indication- Specified by:
isEndOfFile
in interfaceFileDataProviderIfc
- Returns:
true
, if data is available- Throws:
Exception
-
isStartOfFile
Description copied from interface:FileDataProviderIfc
Determines if the record received is start of file indication- Specified by:
isStartOfFile
in interfaceFileDataProviderIfc
- Returns:
- Throws:
Exception
-
getFileData
Description copied from interface:FileDataProviderIfc
Allows a FileDataReceiver to obtain the available data in a known format.- Specified by:
getFileData
in interfaceFileDataProviderIfc
- Returns:
- DCFieldContainer object containing the data that is available for processing
- Throws:
Exception
FileRejectException
EndOfFileException
-
getFileBulkData
Description copied from interface:FileDataProviderIfc
Allows a FileDataReceiver to obtain the available data in a known format.- Specified by:
getFileBulkData
in interfaceFileDataProviderIfc
- Returns:
- DCFieldContainer object array, containing the data that is for processing
-
setFileDataReceiver
Description copied from interface:FileDataProviderIfc
Sets the object to which this FileDataProvider will send its data.- Specified by:
setFileDataReceiver
in interfaceFileDataProviderIfc
- Parameters:
receiver
- Object which will obtain data from this FileDataProvider
-
getFileDataReceiver
Description copied from interface:FileDataProviderIfc
Gets the object that is retrieving data from this FileDataProvider- Specified by:
getFileDataReceiver
in interfaceFileDataProviderIfc
- Returns:
- Object to which this FileDataProvider is sending data
-
fileDataIsAvailable
public void fileDataIsAvailable()Description copied from interface:FileDataReceiverIfc
Allows a FileDataProvider to indicate that some data is available for processing- Specified by:
fileDataIsAvailable
in interfaceFileDataReceiverIfc
-
processStartOfFileData
Description copied from interface:FileDataReceiverIfc
Allows FileDataProvider to indicate start of file- Specified by:
processStartOfFileData
in interfaceFileDataReceiverIfc
- Returns:
true
, if data is available- Throws:
NodeProcessingException
-
processFileData
Description copied from interface:FileDataReceiverIfc
Manipulates the data provided by its DataProvider- Specified by:
processFileData
in interfaceFileDataReceiverIfc
- Returns:
true
, if data is processed successfully- Throws:
NodeProcessingException
-
processFileData
Description copied from interface:FileDataReceiverIfc
Manipulates the set of data provided by its DataProvider- Specified by:
processFileData
in interfaceFileDataReceiverIfc
- Returns:
true
, if data is processed successfully- Throws:
NodeProcessingException
-
processEndOfFileData
Description copied from interface:FileDataReceiverIfc
Allows FileDataProvider to indicate end of file record- Specified by:
processEndOfFileData
in interfaceFileDataReceiverIfc
- Returns:
true
, if processed successfully- Throws:
NodeProcessingException
-
processRejectFile
Description copied from interface:FileDataReceiverIfc
Allows FileDataProvider to indicate rejection of the file- Specified by:
processRejectFile
in interfaceFileDataReceiverIfc
- Returns:
true
, if processed successfully- Throws:
NodeProcessingException
-
setFileDataProvider
Description copied from interface:FileDataReceiverIfc
Sets the object from which this FileDataReceiver will obtain its data.- Specified by:
setFileDataProvider
in interfaceFileDataReceiverIfc
- Parameters:
provider
- Object which has data that needs to be retrieved by this DataReceiver
-
getFileDataProvider
Description copied from interface:FileDataReceiverIfc
Gets the object that is holding data for this FileDataReceiver- Specified by:
getFileDataProvider
in interfaceFileDataReceiverIfc
- Returns:
- Object from which this DataReceiver is retrieving data
-
rejectFile
Description copied from interface:FileDataProviderIfc
Indicates data provider to stop reading from the input file and reject it- Specified by:
rejectFile
in interfaceFileDataProviderIfc
- Returns:
true
for successful rejection of input file
- Throws:
Exception
-
openInputFile
- Specified by:
openInputFile
in interfaceFileDataProviderIfc
- Returns:
- Throws:
Exception
-
handleRejectOfFile
public void handleRejectOfFile()Description copied from interface:FileDataProviderIfc
To handle the remaining input files when there is reject of a file- Specified by:
handleRejectOfFile
in interfaceFileDataProviderIfc
-
setTransactionID
- Specified by:
setTransactionID
in interfaceFileDataReceiverIfc
-
signalBatchCompletion
Description copied from interface:DataProviderIfc
Allows a DataReceiver to know that the nars under the specified batch are completed and handed over to the Data receiver- Specified by:
signalBatchCompletion
in interfaceDataProviderIfc
-
removeProcessedFile
Description copied from interface:DataProviderIfc
Allows a DataReceiver to remove .arch file once processed currArchFile - processed .arch file- Specified by:
removeProcessedFile
in interfaceDataProviderIfc
-
getCurrArchFile
Description copied from interface:DataProviderIfc
Allows a DataReceiver to obtain the currently processing .arch file- Specified by:
getCurrArchFile
in interfaceDataProviderIfc
- Returns:
- currently processing .arch file
-
getProcessedFileList
-
getProcessedArchFile
Description copied from interface:DataProviderIfc
Allows a DataReceiver to obtain the last processed .arch file- Specified by:
getProcessedArchFile
in interfaceDataProviderIfc
- Returns:
- currently processing .arch file absolute path
-
setProcessedArchFile
Description copied from interface:DataProviderIfc
Sets the processed .arch file absolute path- Specified by:
setProcessedArchFile
in interfaceDataProviderIfc
- Parameters:
processedArchFile
- absolute path of processed .arch file
-
validOIMinorType
public boolean validOIMinorType()Description copied from interface:DataProviderIfc
Allows a DataReceiver to check if Minor Type supported for disaster recovery- Specified by:
validOIMinorType
in interfaceDataProviderIfc
- Returns:
- true if valid
-
addProcessedFileInWriterMap
public void addProcessedFileInWriterMap()
-