Class RecoveryInformation

java.lang.Object
com.nt.udc.ei.transport.RecoveryInformation
All Implemented Interfaces:
Serializable

public class RecoveryInformation extends Object implements Serializable
Stores information about the currently processed DIRP file to be able to start again if the node crashes. This object is saved into a binary file before starting to process a record. Note : the file is opened only once when setMode () is called to improve performance.
See Also:
  • Field Details

  • Constructor Details

    • RecoveryInformation

      public RecoveryInformation(File recoveryFile1)
      Construct a new RecoveryInformation object
      Parameters:
      recoveryFile1 - the file in which the object is gonna be stored
  • Method Details

    • setMode

      public void setMode(int mode1) throws Exception
      Set the recovery file mode : read or write mode.
      Parameters:
      mode1 - READ_MODE or WRITE_MODE
      Throws:
      Exception - if unable to open the file (read mode) or to create it (write mode)
    • getMode

      public int getMode()
      Get the mode used
      Returns:
      WRITE_MODE or READ_MODE
    • getReadStatus

      public int getReadStatus()
      Get the read status of the last recovery information read
      Returns:
      REC_INFO_READ : last rec. info read successfully PREV_REC_INFO_READ : unable to read the last rec. info, the previous rec. info has been read instead REC_INFO_FAILED : unable to read the last rec. info
    • desactivate

      public void desactivate()
      Desactivate all readings and writings to/from the recovery file. This method has to be used if it's not possible to open/create the rec. file
    • close

      public void close() throws Exception
      Close the recovery file
      Throws:
      Exception - unable if unable to close the file
    • deleteFile

      public void deleteFile() throws Exception
      Delete the recovery file
      Throws:
      Exception - if unable to delete the file
    • setProcessedFile

      public void setProcessedFile(File dirpFileName1) throws Exception
      Set the file name of the AMA DIRP processed file.
      Parameters:
      dirpFileName1 - AMA DIRP file being processed
      Throws:
      Exception - if the filename excess 30 characters
    • setRecoveryInformation

      public void setRecoveryInformation(long offsetStartOfBlock1, int lastRecordProcessed1)
      set the recovery information
      Parameters:
      offsetStartOfBlock1 - offset of the DIRP block being processed
      lastRecordProcessed1 - number of the last record processed
    • getDirpFileName

      public String getDirpFileName()
      Get the DIRP file name
      Returns:
      DIRP file name
    • getOffsetStartOfBlock

      public long getOffsetStartOfBlock()
      Get the offset of the DIRP block being processed
      Returns:
      offset
    • getLastRecordProcessed

      public int getLastRecordProcessed()
      Get the number of the last record processed
      Returns:
      last record
    • readFromFile

      public void readFromFile() throws Exception
      Reads the recovering information from a file If the method is not able to read the last information (it can happen is the node has crashed when writting these...), it tries to read the previous one. Use getReadStatus () to know if the file has been read correctly
      Throws:
      Exception - if unable to read the recovery file
    • writeToFile

      public void writeToFile() throws Exception
      Write the recovering information to a file
      Throws:
      Exception - if unable to write the file
    • toString

      public String toString()
      Get a String representation of the object
      Overrides:
      toString in class Object
      Returns:
      string