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 Details

    • NARREAD

      public static final String NARREAD
    • NARDELETE

      public static final String NARDELETE
    • InputFileProp

      public static final String InputFileProp
    • NAROffsetProp

      public static final String NAROffsetProp
    • NARsInFileProp

      public static final String NARsInFileProp
  • Constructor Details

    • NarReader

      public NarReader(File inputdir, LoggerIfc inLogger)
      Creates a NarReader without backup capabilities.
      Parameters:
      inputdir - Node input directory
      inLogger - Node logger
    • NarReader

      public NarReader(File inputdir, LoggerIfc inLogger, File backupdir)
      Creates a NarReader with backup capabilities.
      Parameters:
      inputdir - Node input directory
      inLogger - Node logger
      backupdir - Node backup directory
    • NarReader

      public NarReader(File inputdir, LoggerIfc inLogger, DCNode node)
      Creates a NarReader with state recovery capabilities, but without backup capabilities.
      Parameters:
      inputdir - Node input directory
      inLogger - Node logger
      node - 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 directory
      inLogger - Node logger
      backupdir - Node backup directory
      node - 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 directory
      inLogger - Node logger
      backupdir - Node backup directory
      node - 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

      public void signalBatchCompletion(String batch)
    • readNAR

      public NAR readNAR()
      Returns the next NAR. Will automatically go to the next file if necessary.
      Returns:
    • persistInCorrelationMap

      public void persistInCorrelationMap(String batch)
    • readNAR

      public NAR readNAR(String batch)
      Returns the next NAR. Will automatically go to the next file if necessary.
      Returns:
    • readNARs

      public NAR[] readNARs()
    • handleRejectOfFile

      public void handleRejectOfFile()
    • accept

      public boolean accept(Path entry, boolean checkArchExtension) throws IOException
      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.
      Specified by:
      callback in interface Callback
    • saveState

      public void saveState(StateBuffer buffer)
      Saves the state of the NarReader to a buffer.
      Specified by:
      saveState in interface StateBufferSaveable
      Parameters:
      buffer - Buffer containing state data
    • restoreState

      public void restoreState(StateBuffer buffer) throws StateException
      Restores the runtime state of the Reader from a StateBuffer.
      Specified by:
      restoreState in interface StateBufferSaveable
      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

      public boolean isFileOpen() throws Exception
      Method indicates if the file is opened for file level transaction
      Returns:
      Throws:
      Exception
    • isStartOfFile

      public boolean isStartOfFile() throws Exception
      Method indicates if the file is opened for file level transaction
      Returns:
      Throws:
      Exception
    • rejectFile

      public boolean rejectFile() throws Exception
      Method to reject input file
      Returns:
      Throws:
      Exception
    • isEndOfFile

      public boolean isEndOfFile() throws Exception
      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

      public boolean isFileDataAvailable() throws Exception
      Throws:
      Exception
    • openInputFile

      public String openInputFile() throws Exception
      Throws:
      Exception
    • isBulkDataAvailable

      public boolean isBulkDataAvailable()
      Returns whether there are more files available for processing.
      Returns:
      true, if data is available
    • readAllNARs

      public NAR[] readAllNARs()
    • getIdentifier

      public String getIdentifier()
      Specified by:
      getIdentifier in interface CheckpointUserIfc
    • generateEmptyCheckpointData

      public BaseCheckpointData generateEmptyCheckpointData()
      Specified by:
      generateEmptyCheckpointData in interface CheckpointUserIfc
    • pauseForCheckpoint

      public void pauseForCheckpoint()
      Specified by:
      pauseForCheckpoint in interface CheckpointUserSourceIfc
    • getCheckpointData

      public BaseCheckpointData getCheckpointData()
      Specified by:
      getCheckpointData in interface CheckpointUserIfc
    • clearCheckpointData

      public void clearCheckpointData()
      Specified by:
      clearCheckpointData in interface CheckpointUserIfc
    • continueFromCheckpoint

      public void continueFromCheckpoint()
      Specified by:
      continueFromCheckpoint in interface CheckpointUserSourceIfc
    • flushCheckpoint

      public void flushCheckpoint(BaseCheckpointData cp)
      Specified by:
      flushCheckpoint in interface CheckpointUserIfc
    • restoreCheckpoint

      public void restoreCheckpoint(BaseCheckpointData bcp)
      Specified by:
      restoreCheckpoint in interface CheckpointUserIfc
    • 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

      public File getCurrArchFile()
    • getProcessedFileMap

      public Map getProcessedFileMap()
    • removeProcessedFile

      public void removeProcessedFile(File delFile)
    • getProcessedArchFile

      public String getProcessedArchFile()
    • setProcessedArchFile

      public void setProcessedArchFile(String file)
    • getDisasterRecoveryFlag

      public boolean getDisasterRecoveryFlag()
    • checkDisasterRecovery

      public boolean checkDisasterRecovery()
    • validOIMinorType

      public boolean validOIMinorType()
    • validEPMinorType

      public boolean validEPMinorType()