Package com.nt.udc.nar
Class NarReader
java.lang.Object
com.nt.udc.nar.NarReader
- All Implemented Interfaces:
CheckpointUserIfc
,CheckpointUserSourceIfc
,Callback
,StateBufferSaveable
public class NarReader
extends Object
implements StateBufferSaveable, Callback, CheckpointUserSourceIfc
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a NarReader without backup capabilities.Creates a NarReader with state recovery capabilities, but without backup capabilities.Creates a NarReader with backup capabilities.NarReader
(File inputdir, LoggerIfc inLogger, File backupdir, DCNode node, CheckpointManager cpm, InputStatisticsMonitorIfc inCount, boolean fileLevelTrans) Creates a NarReader with backup capabilities, and state recovery capabilities.NarReader
(File inputdir, LoggerIfc inLogger, File backupdir, DCNode node, CheckpointManager cpm, InputStatisticsMonitorIfc inCount, boolean isMultiThreaded, int threadCount, boolean mtOrderChecked, int currThread, boolean fileLevelTrans) Creates a NarReader with backup capabilities, and state recovery capabilities. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
callback()
This callback is made when the NarReader's call to saveState() has successfully saved the state of the system to disk.boolean
boolean
This method checks for an empty input directory.void
void
void
boolean
protected void
Check and get the private checkpoint data.void
boolean
Returns whether there are more files available for processing.boolean
Returns whether there are more records available for processing.boolean
Method indicates if the file is opened for file level transactionboolean
boolean
Method indicates if the file is opened for file level transactionboolean
Method indicates if the file is opened for file level transactionvoid
void
persistInCorrelationMap
(String batch) NAR[]
readNAR()
Returns the next NAR.Returns the next NAR.NAR[]
readNARs()
boolean
Method to reject input filevoid
removeProcessedFile
(File delFile) void
void
restoreState
(StateBuffer buffer) Restores the runtime state of the Reader from a StateBuffer.protected void
Re-save checkpoint data into private file in scratch directory, for proper recovery at next startup.void
saveState
(StateBuffer buffer) Saves the state of the NarReader to a buffer.boolean
void
setProcessedArchFile
(String file) void
shutdown()
Tells the NarReader it is time to shut down.void
signalBatchCompletion
(String batch) boolean
boolean
-
Field Details
-
NARREAD
-
NARDELETE
-
InputFileProp
-
NAROffsetProp
-
NARsInFileProp
-
-
Constructor Details
-
NarReader
Creates a NarReader without backup capabilities.- Parameters:
inputdir
- Node input directoryinLogger
- Node logger
-
NarReader
Creates a NarReader with backup capabilities.- Parameters:
inputdir
- Node input directoryinLogger
- Node loggerbackupdir
- Node backup directory
-
NarReader
Creates a NarReader with state recovery capabilities, but without backup capabilities.- Parameters:
inputdir
- Node input directoryinLogger
- Node loggernode
- Used to signal state backups.
-
NarReader
public NarReader(File inputdir, LoggerIfc inLogger, File backupdir, DCNode node, CheckpointManager cpm, InputStatisticsMonitorIfc inCount, boolean fileLevelTrans) Creates a NarReader with backup capabilities, and state recovery capabilities.- Parameters:
inputdir
- Node input directoryinLogger
- Node loggerbackupdir
- Node backup directorynode
- Used to signal state backups.
-
NarReader
public NarReader(File inputdir, LoggerIfc inLogger, File backupdir, DCNode node, CheckpointManager cpm, InputStatisticsMonitorIfc inCount, boolean isMultiThreaded, int threadCount, boolean mtOrderChecked, int currThread, boolean fileLevelTrans) Creates a NarReader with backup capabilities, and state recovery capabilities.- Parameters:
inputdir
- Node input directoryinLogger
- Node loggerbackupdir
- Node backup directorynode
- Used to signal state backups.isMultiThreaded
- Used to signal multi threaded node.threadCount
- Total number of threads.currThread
- Current thread.
-
-
Method Details
-
shutdown
public void shutdown()Tells the NarReader it is time to shut down. Don't forget to remember which file and which offset we were working on... -
signalBatchCompletion
-
readNAR
Returns the next NAR. Will automatically go to the next file if necessary.- Returns:
-
persistInCorrelationMap
-
readNAR
Returns the next NAR. Will automatically go to the next file if necessary.- Returns:
-
readNARs
-
handleRejectOfFile
public void handleRejectOfFile() -
accept
- Throws:
IOException
-
setFilesForFileLevelTransaction
public boolean setFilesForFileLevelTransaction() -
callback
public void callback()This callback is made when the NarReader's call to saveState() has successfully saved the state of the system to disk. This method can then clean up the input files. -
saveState
Saves the state of the NarReader to a buffer.- Specified by:
saveState
in interfaceStateBufferSaveable
- Parameters:
buffer
- Buffer containing state data
-
restoreState
Restores the runtime state of the Reader from a StateBuffer.- Specified by:
restoreState
in interfaceStateBufferSaveable
- Parameters:
buffer
- Buffer, holding the Reader data- Throws:
StateException
-
checkInput
public boolean checkInput()This method checks for an empty input directory.- Returns:
- true, if directory contains files
-
isFileOpen
Method indicates if the file is opened for file level transaction- Returns:
- Throws:
Exception
-
isStartOfFile
Method indicates if the file is opened for file level transaction- Returns:
- Throws:
Exception
-
rejectFile
Method to reject input file- Returns:
- Throws:
Exception
-
isEndOfFile
Method indicates if the file is opened for file level transaction- Returns:
- Throws:
Exception
-
isDataAvailable
public boolean isDataAvailable()Returns whether there are more records available for processing.- Returns:
true
, if data is available
-
isFileDataAvailable
- Throws:
Exception
-
openInputFile
- Throws:
Exception
-
isBulkDataAvailable
public boolean isBulkDataAvailable()Returns whether there are more files available for processing.- Returns:
true
, if data is available
-
readAllNARs
-
getIdentifier
- Specified by:
getIdentifier
in interfaceCheckpointUserIfc
-
generateEmptyCheckpointData
- Specified by:
generateEmptyCheckpointData
in interfaceCheckpointUserIfc
-
pauseForCheckpoint
public void pauseForCheckpoint()- Specified by:
pauseForCheckpoint
in interfaceCheckpointUserSourceIfc
-
getCheckpointData
- Specified by:
getCheckpointData
in interfaceCheckpointUserIfc
-
clearCheckpointData
public void clearCheckpointData()- Specified by:
clearCheckpointData
in interfaceCheckpointUserIfc
-
continueFromCheckpoint
public void continueFromCheckpoint()- Specified by:
continueFromCheckpoint
in interfaceCheckpointUserSourceIfc
-
flushCheckpoint
- Specified by:
flushCheckpoint
in interfaceCheckpointUserIfc
-
restoreCheckpoint
- Specified by:
restoreCheckpoint
in interfaceCheckpointUserIfc
-
saveCurrentInputInfo
protected void saveCurrentInputInfo()Re-save checkpoint data into private file in scratch directory, for proper recovery at next startup. This is useful for non-PartitionedDCNode. Note that if there is no current arch file, then there will be no checkpoint file either. -
getLastInputInfo
protected void getLastInputInfo()Check and get the private checkpoint data. Checkpoint Manager will overwrite this data later, at restoreCheckpoint(). But if there is no checkpoint manager, then the data in this file will be used. Note: At the end of this method, it will leave an empty private checkpoint file behind, so that an improper shutdown can be detected. -
getCurrArchFile
-
getProcessedFileMap
-
removeProcessedFile
-
getProcessedArchFile
-
setProcessedArchFile
-
getDisasterRecoveryFlag
public boolean getDisasterRecoveryFlag() -
checkDisasterRecovery
public boolean checkDisasterRecovery() -
validOIMinorType
public boolean validOIMinorType() -
validEPMinorType
public boolean validEPMinorType()
-