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 DataProviderIfcReference to the object providing data to this NAR router.protected DataReceiverIfcReference to the object receiving data from this NAR router.protected FileDataProviderIfcReference to the object providing file data to this NAR router.protected FileDataReceiverIfcReference 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 TypeMethodDescriptionvoidbooleanThis method invokes a NarReader method which will check for an empty input directory.booleancleanup()Deletes NARs files that have been processedvoidvoidWhen this method is called by the DataProvider, a return call is made to the provider'sgetData()method.voidAllows 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 FilenameGeneratorReturns the current filename generatorThis method returns the node ID.Allows a DataReceiver to obtain the last processed .arch filelongThis must return a count of how many records this node has read in, since it started.voidTo handle the remaining input files when there is reject of a filebooleanAllows a DataReceiver to determine whether some data is available for processingbooleanDetermines if record received is an End of file indicationbooleanAllows a FileDataReceiver to determine whether some file is available for processingbooleanDetermines if the record received is start of file indicationvoidmoveToReadyToOut(boolean initNew) Make cache file as ready to moveToOutput()voidprocessData(DCFieldContainer data) Manipulates the data provided by its DataProvider.voidprocessData(DCFieldContainer[] data) Manipulates the data provided by its DataProvider.booleanprocessEndOfFileData(String transactionID) Allows FileDataProvider to indicate end of file recordbooleanManipulates the data provided by its DataProviderbooleanprocessFileData(DCFieldContainer[] data) Manipulates the set of data provided by its DataProviderbooleanAllows FileDataProvider to indicate rejection of the filebooleanprocessStartOfFileData(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.booleanIndicates data provider to stop reading from the input file and reject itvoidremoveProcessedFile(File currArchFile) Allows a DataReceiver to remove .arch file once processed currArchFile - processed .arch filevoidsetDataProvider(DataProviderIfc provider) Sets the object from which this DataReceiver will obtain its data.voidsetDataReceiver(DataReceiverIfc receiver) Sets the object to which this DataProvider will send its data.voidsetFileDataProvider(FileDataProviderIfc provider) Sets the object from which this FileDataReceiver will obtain its data.voidsetFileDataReceiver(FileDataReceiverIfc receiver) Sets the object to which this FileDataProvider will send its data.final voidsetFilenameGenerator(FilenameGenerator filenameGen) Sets a new FilenameGeneratorvoidsetProcessedArchFile(String processedArchFile) Sets the processed .arch file absolute pathvoidsetTransactionID(String tID) voidshutdown()This method invokes the shutdown method of each NarWriter object.voidFor this implementation of the StreamHandler, simply set the flag that will prevent the input methods from allowing any more data into the node.voidFor this implementation of the StreamHandler, there is no reason to stop the output stream without first stopping the input stream.voidsignalBatchCompletion(String batch) Allows a DataReceiver to know that the nars under the specified batch are completed and handed over to the Data receiverbooleanWrites a single NAR to the appropriate cache file.booleanWrites multiple NARs to the appropriate cache filebooleanAllows 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:
shutdownin interfaceDCStreamHandler- Overrides:
shutdownin classNARStreamHandler
-
storeNARs
Writes multiple NARs to the appropriate cache file- Specified by:
storeNARsin classNARStreamHandler- Returns:
true, if the write was successful.
-
storeNAR
Writes a single NAR to the appropriate cache file.- Specified by:
storeNARin classNARStreamHandler- Returns:
true, if the write was successful.
-
readNAR
Return a NAR from the data stream.- Specified by:
readNARin 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:
readNARsin 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:
readDatain interfaceDCStreamHandler- Overrides:
readDatain classNARStreamHandler- Returns:
- Returns a single DCFieldContainer.
-
readBulkData
Returns a set of DCFieldContainer objects from the data stream.- Specified by:
readBulkDatain 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:
shutdownInputin interfaceDCStreamHandler- Overrides:
shutdownInputin classNARStreamHandler
-
cleanup
public boolean cleanup()Description copied from class:NARStreamHandlerDeletes NARs files that have been processed- Specified by:
cleanupin interfaceDCStreamHandler- Specified by:
cleanupin 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:
shutdownOutputin interfaceDCStreamHandler- Overrides:
shutdownOutputin classNARStreamHandler
-
isDataAvailable
public boolean isDataAvailable()Allows a DataReceiver to determine whether some data is available for processing- Specified by:
isDataAvailablein interfaceDataProviderIfc- Returns:
true, if data is available
-
getData
Allows a DataReceiver to obtain the available data in a known format.- Specified by:
getDatain 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:
getDatain 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:
getBulkDatain 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:
setDataReceiverin interfaceDataProviderIfc- Parameters:
receiver- Object which will receive data from this provider
-
getDataReceiver
Returns the object to which this DataProvider is sending data.- Specified by:
getDataReceiverin 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 resultingDCFieldContaineris then passed to this receiver'sprocessData()method.- Specified by:
dataIsAvailablein 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:
processDatain 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:
processDatain 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:
setDataProviderin interfaceDataReceiverIfc- Parameters:
provider- DataProvider of this receiver
-
getDataProvider
Returns the object from which this DataReceiver is receiving data.- Specified by:
getDataProviderin interfaceDataReceiverIfc- Returns:
- Returns the DataProvider of this receiver.
-
getRealNarsIn
public long getRealNarsIn()Description copied from class:NARStreamHandlerThis 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:
getRealNarsInin classNARStreamHandler- Returns:
-
moveToReadyToOut
public void moveToReadyToOut(boolean initNew) Description copied from interface:DCStreamHandlerMake cache file as ready to moveToOutput()- Specified by:
moveToReadyToOutin interfaceDCStreamHandler
-
createNewCacheFile
public void createNewCacheFile()- Specified by:
createNewCacheFilein interfaceDCStreamHandler
-
isFileDataAvailable
Description copied from interface:FileDataProviderIfcAllows a FileDataReceiver to determine whether some file is available for processing- Specified by:
isFileDataAvailablein interfaceFileDataProviderIfc- Returns:
true, if data is available- Throws:
Exception
-
isEndOfFile
Description copied from interface:FileDataProviderIfcDetermines if record received is an End of file indication- Specified by:
isEndOfFilein interfaceFileDataProviderIfc- Returns:
true, if data is available- Throws:
Exception
-
isStartOfFile
Description copied from interface:FileDataProviderIfcDetermines if the record received is start of file indication- Specified by:
isStartOfFilein interfaceFileDataProviderIfc- Returns:
- Throws:
Exception
-
getFileData
Description copied from interface:FileDataProviderIfcAllows a FileDataReceiver to obtain the available data in a known format.- Specified by:
getFileDatain interfaceFileDataProviderIfc- Returns:
- DCFieldContainer object containing the data that is available for processing
- Throws:
ExceptionFileRejectExceptionEndOfFileException
-
getFileBulkData
Description copied from interface:FileDataProviderIfcAllows a FileDataReceiver to obtain the available data in a known format.- Specified by:
getFileBulkDatain interfaceFileDataProviderIfc- Returns:
- DCFieldContainer object array, containing the data that is for processing
-
setFileDataReceiver
Description copied from interface:FileDataProviderIfcSets the object to which this FileDataProvider will send its data.- Specified by:
setFileDataReceiverin interfaceFileDataProviderIfc- Parameters:
receiver- Object which will obtain data from this FileDataProvider
-
getFileDataReceiver
Description copied from interface:FileDataProviderIfcGets the object that is retrieving data from this FileDataProvider- Specified by:
getFileDataReceiverin interfaceFileDataProviderIfc- Returns:
- Object to which this FileDataProvider is sending data
-
fileDataIsAvailable
public void fileDataIsAvailable()Description copied from interface:FileDataReceiverIfcAllows a FileDataProvider to indicate that some data is available for processing- Specified by:
fileDataIsAvailablein interfaceFileDataReceiverIfc
-
processStartOfFileData
Description copied from interface:FileDataReceiverIfcAllows FileDataProvider to indicate start of file- Specified by:
processStartOfFileDatain interfaceFileDataReceiverIfc- Returns:
true, if data is available- Throws:
NodeProcessingException
-
processFileData
Description copied from interface:FileDataReceiverIfcManipulates the data provided by its DataProvider- Specified by:
processFileDatain interfaceFileDataReceiverIfc- Returns:
true, if data is processed successfully- Throws:
NodeProcessingException
-
processFileData
Description copied from interface:FileDataReceiverIfcManipulates the set of data provided by its DataProvider- Specified by:
processFileDatain interfaceFileDataReceiverIfc- Returns:
true, if data is processed successfully- Throws:
NodeProcessingException
-
processEndOfFileData
Description copied from interface:FileDataReceiverIfcAllows FileDataProvider to indicate end of file record- Specified by:
processEndOfFileDatain interfaceFileDataReceiverIfc- Returns:
true, if processed successfully- Throws:
NodeProcessingException
-
processRejectFile
Description copied from interface:FileDataReceiverIfcAllows FileDataProvider to indicate rejection of the file- Specified by:
processRejectFilein interfaceFileDataReceiverIfc- Returns:
true, if processed successfully- Throws:
NodeProcessingException
-
setFileDataProvider
Description copied from interface:FileDataReceiverIfcSets the object from which this FileDataReceiver will obtain its data.- Specified by:
setFileDataProviderin interfaceFileDataReceiverIfc- Parameters:
provider- Object which has data that needs to be retrieved by this DataReceiver
-
getFileDataProvider
Description copied from interface:FileDataReceiverIfcGets the object that is holding data for this FileDataReceiver- Specified by:
getFileDataProviderin interfaceFileDataReceiverIfc- Returns:
- Object from which this DataReceiver is retrieving data
-
rejectFile
Description copied from interface:FileDataProviderIfcIndicates data provider to stop reading from the input file and reject it- Specified by:
rejectFilein interfaceFileDataProviderIfc- Returns:
truefor successful rejection of input file- Throws:
Exception
-
openInputFile
- Specified by:
openInputFilein interfaceFileDataProviderIfc- Returns:
- Throws:
Exception
-
handleRejectOfFile
public void handleRejectOfFile()Description copied from interface:FileDataProviderIfcTo handle the remaining input files when there is reject of a file- Specified by:
handleRejectOfFilein interfaceFileDataProviderIfc
-
setTransactionID
- Specified by:
setTransactionIDin interfaceFileDataReceiverIfc
-
signalBatchCompletion
Description copied from interface:DataProviderIfcAllows a DataReceiver to know that the nars under the specified batch are completed and handed over to the Data receiver- Specified by:
signalBatchCompletionin interfaceDataProviderIfc
-
removeProcessedFile
Description copied from interface:DataProviderIfcAllows a DataReceiver to remove .arch file once processed currArchFile - processed .arch file- Specified by:
removeProcessedFilein interfaceDataProviderIfc
-
getCurrArchFile
Description copied from interface:DataProviderIfcAllows a DataReceiver to obtain the currently processing .arch file- Specified by:
getCurrArchFilein interfaceDataProviderIfc- Returns:
- currently processing .arch file
-
getProcessedFileList
-
getProcessedArchFile
Description copied from interface:DataProviderIfcAllows a DataReceiver to obtain the last processed .arch file- Specified by:
getProcessedArchFilein interfaceDataProviderIfc- Returns:
- currently processing .arch file absolute path
-
setProcessedArchFile
Description copied from interface:DataProviderIfcSets the processed .arch file absolute path- Specified by:
setProcessedArchFilein interfaceDataProviderIfc- Parameters:
processedArchFile- absolute path of processed .arch file
-
validOIMinorType
public boolean validOIMinorType()Description copied from interface:DataProviderIfcAllows a DataReceiver to check if Minor Type supported for disaster recovery- Specified by:
validOIMinorTypein interfaceDataProviderIfc- Returns:
- true if valid
-
addProcessedFileInWriterMap
public void addProcessedFileInWriterMap()
-