public class NARFileManager extends NARStreamHandler implements DataReceiverIfc, DataProviderIfc
Modifier and Type | Field and Description |
---|---|
protected DataProviderIfc |
dataProvider
Reference to the object providing data to this NAR router.
|
protected DataReceiverIfc |
dataReceiver
Reference to the object receiving data from this NAR router.
|
protected FileDataProviderIfc |
fileDataProvider
Reference to the object providing file data to this NAR router.
|
protected FileDataReceiverIfc |
fileDataReceiver
Reference to the object receiving file data from this NAR router.
|
inputShutdown, narsIn, narsOut, np, outputShutdown
Constructor and Description |
---|
NARFileManager(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) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkInput()
This method invokes a NarReader method which will check for an
empty input directory.
|
boolean |
cleanup()
Deletes NARs files that have been processed
|
void |
createNewCacheFile() |
void |
dataIsAvailable()
When this method is called by the DataProvider, a return call is made
to the provider's
getData() method. |
void |
fileDataIsAvailable()
Allows a FileDataProvider to indicate that some data is
available for processing
|
DCFieldContainer[] |
getBulkData()
Allows a DataReceiver to obtain the available data in a
known format.
|
DCFieldContainer |
getData()
Allows a DataReceiver to obtain the available data in a
known format.
|
DataProviderIfc |
getDataProvider()
Returns the object from which this DataReceiver is receiving data.
|
DataReceiverIfc |
getDataReceiver()
Returns the object to which this DataProvider is sending data.
|
DCFieldContainer[] |
getFileBulkData()
Allows a FileDataReceiver to obtain the available data in a
known format.
|
DCFieldContainer |
getFileData()
Allows a FileDataReceiver to obtain the available data in a
known format.
|
FileDataProviderIfc |
getFileDataProvider()
Gets the object that is holding data for this FileDataReceiver
|
FileDataReceiverIfc |
getFileDataReceiver()
Gets the object that is retrieving data from this FileDataProvider
|
FilenameGenerator |
getFilenameGenerator()
Returns the current filename generator
|
java.lang.String |
getNodeID()
This method returns the node ID.
|
long |
getRealNarsIn()
This must return a count of how many records this node has read in,
since it started.
|
void |
handleRejectOfFile()
To handle the remaining input files when there is reject of a file
|
boolean |
isDataAvailable()
Allows a DataReceiver to determine whether some data is
available for processing
|
boolean |
isEndOfFile()
Determines if record received is an End of file indication
|
boolean |
isFileDataAvailable()
Allows a FileDataReceiver to determine whether some file is
available for processing
|
boolean |
isStartOfFile()
Determines if the record received is start of file indication
|
void |
moveToReadyToOut(boolean initNew)
Make cache file as ready to moveToOutput()
|
java.lang.String |
openInputFile() |
void |
processData(DCFieldContainer data)
Manipulates the data provided by its DataProvider.
|
void |
processData(DCFieldContainer[] data)
Manipulates the data provided by its DataProvider.
|
boolean |
processEndOfFileData(java.lang.String transactionID)
Allows FileDataProvider to indicate end of file record
|
boolean |
processFileData(DCFieldContainer data)
Manipulates the data provided by its DataProvider
|
boolean |
processFileData(DCFieldContainer[] data)
Manipulates the set of data provided by its DataProvider
|
boolean |
processRejectFile()
Allows FileDataProvider to indicate rejection of the file
|
boolean |
processStartOfFileData(java.lang.String fileName)
Allows FileDataProvider to indicate start of file
|
DCFieldContainer[] |
readBulkData()
Returns a set of DCFieldContainer objects from the data stream.
|
DCFieldContainer |
readData()
Return a DCFieldContainer object from the data stream.
|
NAR |
readNAR()
Return a NAR from the data stream.
|
NAR[] |
readNARs()
Return an array of NARs from the data stream.
|
NAR[] |
readNARsFromFile()
Return an array of NARs from the data stream.
|
boolean |
rejectFile()
Indicates data provider to stop reading from the input file and reject it
|
void |
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.
|
void |
setFilenameGenerator(FilenameGenerator filenameGen)
Sets a new FilenameGenerator
|
void |
setTransactionID(java.lang.String tID) |
void |
shutdown()
This method invokes the shutdown method of each NarWriter object.
|
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.
|
void |
shutdownOutput()
For this implementation of the StreamHandler, there is no reason to
stop the output stream without first stopping the input stream.
|
boolean |
storeNAR(NAR record)
Writes a single NAR to the appropriate cache file.
|
boolean |
storeNARs(NAR[] records)
Writes multiple NARs to the appropriate cache file
|
getPerformanceMetrics, writeData, writeData
protected DataProviderIfc dataProvider
protected DataReceiverIfc dataReceiver
protected FileDataProviderIfc fileDataProvider
protected FileDataReceiverIfc fileDataReceiver
public NARFileManager(DCNode dcNode)
dcNode
- Node to managepublic NARFileManager(DCNode dcNode, boolean isMultiThreaded, int threadCount, int currThread)
public NARFileManager(DCNode dcNode, boolean isMultiThreaded, int threadCount, int currThread, boolean isOrdered)
public NARFileManager(DCNode dcNode, boolean createWriter)
public NARFileManager(DCNode dcNode, boolean createWriter, boolean isMultiThreaded, int threadCount, int currThread, boolean isOrdered)
public void shutdown()
shutdown
in interface DCStreamHandler
shutdown
in class NARStreamHandler
public boolean storeNARs(NAR[] records)
storeNARs
in class NARStreamHandler
true
, if the write was successful.public boolean storeNAR(NAR record)
storeNAR
in class NARStreamHandler
true
, if the write was successful.public NAR readNAR()
readNAR
in class NARStreamHandler
public NAR[] readNARs()
readNARs
in class NARStreamHandler
public NAR[] readNARsFromFile() throws java.lang.Exception
java.lang.Exception
public boolean checkInput()
public java.lang.String getNodeID()
public final FilenameGenerator getFilenameGenerator()
public final void setFilenameGenerator(FilenameGenerator filenameGen)
public DCFieldContainer readData()
readData
in interface DCStreamHandler
readData
in class NARStreamHandler
public DCFieldContainer[] readBulkData()
readBulkData
in interface DCStreamHandler
public void shutdownInput()
shutdownInput
in interface DCStreamHandler
shutdownInput
in class NARStreamHandler
public boolean cleanup()
NARStreamHandler
cleanup
in interface DCStreamHandler
cleanup
in class NARStreamHandler
public void shutdownOutput()
shutdownOutput
in interface DCStreamHandler
shutdownOutput
in class NARStreamHandler
public boolean isDataAvailable()
isDataAvailable
in interface DataProviderIfc
true
, if data is availablepublic DCFieldContainer getData()
getData
in interface DataProviderIfc
public DCFieldContainer[] getBulkData()
getBulkData
in interface DataProviderIfc
public void setDataReceiver(DataReceiverIfc receiver)
setDataReceiver
in interface DataProviderIfc
receiver
- Object which will receive data from this providerpublic DataReceiverIfc getDataReceiver()
getDataReceiver
in interface DataProviderIfc
public void dataIsAvailable()
getData()
method. The resulting
DCFieldContainer
is then passed to this receiver's
processData()
method.dataIsAvailable
in interface DataReceiverIfc
public void processData(DCFieldContainer data) throws NodeProcessingException
processData
in interface DataReceiverIfc
data
- The DCFieldContainer (actually a NAR) received
from the DataProviderNodeProcessingException
public void processData(DCFieldContainer[] data) throws NodeProcessingException
processData
in interface DataReceiverIfc
data
- The DCFieldContainer array (actually a set of NARs)
received from the DataProviderNodeProcessingException
public void setDataProvider(DataProviderIfc provider)
setDataProvider
in interface DataReceiverIfc
provider
- DataProvider of this receiverpublic DataProviderIfc getDataProvider()
getDataProvider
in interface DataReceiverIfc
public long getRealNarsIn()
NARStreamHandler
getRealNarsIn
in class NARStreamHandler
public void moveToReadyToOut(boolean initNew)
DCStreamHandler
moveToReadyToOut
in interface DCStreamHandler
public void createNewCacheFile()
createNewCacheFile
in interface DCStreamHandler
public boolean isFileDataAvailable() throws java.lang.Exception
FileDataProviderIfc
isFileDataAvailable
in interface FileDataProviderIfc
true
, if data is availablejava.lang.Exception
public boolean isEndOfFile() throws java.lang.Exception
FileDataProviderIfc
isEndOfFile
in interface FileDataProviderIfc
true
, if data is availablejava.lang.Exception
public boolean isStartOfFile() throws java.lang.Exception
FileDataProviderIfc
isStartOfFile
in interface FileDataProviderIfc
java.lang.Exception
public DCFieldContainer getFileData() throws java.lang.Exception, FileRejectException, EndOfFileException
FileDataProviderIfc
getFileData
in interface FileDataProviderIfc
java.lang.Exception
FileRejectException
EndOfFileException
public DCFieldContainer[] getFileBulkData()
FileDataProviderIfc
getFileBulkData
in interface FileDataProviderIfc
public void setFileDataReceiver(FileDataReceiverIfc receiver)
FileDataProviderIfc
setFileDataReceiver
in interface FileDataProviderIfc
receiver
- Object which will obtain data from this
FileDataProviderpublic FileDataReceiverIfc getFileDataReceiver()
FileDataProviderIfc
getFileDataReceiver
in interface FileDataProviderIfc
public void fileDataIsAvailable()
FileDataReceiverIfc
fileDataIsAvailable
in interface FileDataReceiverIfc
public boolean processStartOfFileData(java.lang.String fileName) throws NodeProcessingException
FileDataReceiverIfc
processStartOfFileData
in interface FileDataReceiverIfc
true
, if data is availableNodeProcessingException
public boolean processFileData(DCFieldContainer data) throws NodeProcessingException
FileDataReceiverIfc
processFileData
in interface FileDataReceiverIfc
true
, if data is processed successfullyNodeProcessingException
public boolean processFileData(DCFieldContainer[] data) throws NodeProcessingException
FileDataReceiverIfc
processFileData
in interface FileDataReceiverIfc
true
, if data is processed successfullyNodeProcessingException
public boolean processEndOfFileData(java.lang.String transactionID) throws NodeProcessingException
FileDataReceiverIfc
processEndOfFileData
in interface FileDataReceiverIfc
true
, if processed successfullyNodeProcessingException
public boolean processRejectFile() throws NodeProcessingException
FileDataReceiverIfc
processRejectFile
in interface FileDataReceiverIfc
true
, if processed successfullyNodeProcessingException
public void setFileDataProvider(FileDataProviderIfc provider)
FileDataReceiverIfc
setFileDataProvider
in interface FileDataReceiverIfc
provider
- Object which has data that needs to be
retrieved by this DataReceiverpublic FileDataProviderIfc getFileDataProvider()
FileDataReceiverIfc
getFileDataProvider
in interface FileDataReceiverIfc
public boolean rejectFile() throws java.lang.Exception
FileDataProviderIfc
rejectFile
in interface FileDataProviderIfc
true for successful rejection of input file
java.lang.Exception
public java.lang.String openInputFile() throws java.lang.Exception
openInputFile
in interface FileDataProviderIfc
java.lang.Exception
public void handleRejectOfFile()
FileDataProviderIfc
handleRejectOfFile
in interface FileDataProviderIfc
public void setTransactionID(java.lang.String tID)
setTransactionID
in interface FileDataReceiverIfc