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 TypeMethodDescriptionbooleanvoidcallback()This callback is made when the NarReader's call to saveState() has successfully saved the state of the system to disk.booleanbooleanThis method checks for an empty input directory.voidvoidvoidbooleanprotected voidCheck and get the private checkpoint data.voidbooleanReturns whether there are more files available for processing.booleanReturns whether there are more records available for processing.booleanMethod indicates if the file is opened for file level transactionbooleanbooleanMethod indicates if the file is opened for file level transactionbooleanMethod indicates if the file is opened for file level transactionvoidvoidpersistInCorrelationMap(String batch) NAR[]readNAR()Returns the next NAR.Returns the next NAR.NAR[]readNARs()booleanMethod to reject input filevoidremoveProcessedFile(File delFile) voidvoidrestoreState(StateBuffer buffer) Restores the runtime state of the Reader from a StateBuffer.protected voidRe-save checkpoint data into private file in scratch directory, for proper recovery at next startup.voidsaveState(StateBuffer buffer) Saves the state of the NarReader to a buffer.booleanvoidsetProcessedArchFile(String file) voidshutdown()Tells the NarReader it is time to shut down.voidsignalBatchCompletion(String batch) booleanboolean
-
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:
saveStatein interfaceStateBufferSaveable- Parameters:
buffer- Buffer containing state data
-
restoreState
Restores the runtime state of the Reader from a StateBuffer.- Specified by:
restoreStatein 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:
getIdentifierin interfaceCheckpointUserIfc
-
generateEmptyCheckpointData
- Specified by:
generateEmptyCheckpointDatain interfaceCheckpointUserIfc
-
pauseForCheckpoint
public void pauseForCheckpoint()- Specified by:
pauseForCheckpointin interfaceCheckpointUserSourceIfc
-
getCheckpointData
- Specified by:
getCheckpointDatain interfaceCheckpointUserIfc
-
clearCheckpointData
public void clearCheckpointData()- Specified by:
clearCheckpointDatain interfaceCheckpointUserIfc
-
continueFromCheckpoint
public void continueFromCheckpoint()- Specified by:
continueFromCheckpointin interfaceCheckpointUserSourceIfc
-
flushCheckpoint
- Specified by:
flushCheckpointin interfaceCheckpointUserIfc
-
restoreCheckpoint
- Specified by:
restoreCheckpointin 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()
-