Package com.nt.udc.ei.transport
Class RecoveryInformation
java.lang.Object
com.nt.udc.ei.transport.RecoveryInformation
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
-
Constructor Summary
ConstructorsConstructorDescriptionRecoveryInformation
(File recoveryFile1) Construct a new RecoveryInformation object -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the recovery filevoid
Delete the recovery filevoid
Desactivate all readings and writings to/from the recovery file.Get the DIRP file nameint
Get the number of the last record processedint
getMode()
Get the mode usedlong
Get the offset of the DIRP block being processedint
Get the read status of the last recovery information readvoid
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.void
setMode
(int mode1) Set the recovery file mode : read or write mode.void
setProcessedFile
(File dirpFileName1) Set the file name of the AMA DIRP processed file.void
setRecoveryInformation
(long offsetStartOfBlock1, int lastRecordProcessed1) set the recovery informationtoString()
Get a String representation of the objectvoid
Write the recovering information to a file
-
Field Details
-
READ_MODE
public static final int READ_MODE- See Also:
-
WRITE_MODE
public static final int WRITE_MODE- See Also:
-
REC_INFO_READ
public static final int REC_INFO_READ- See Also:
-
PREV_REC_INFO_READ
public static final int PREV_REC_INFO_READ- See Also:
-
REC_INFO_FAILED
public static final int REC_INFO_FAILED- See Also:
-
-
Constructor Details
-
RecoveryInformation
Construct a new RecoveryInformation object- Parameters:
recoveryFile1
- the file in which the object is gonna be stored
-
-
Method Details
-
setMode
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
Close the recovery file- Throws:
Exception
- unable if unable to close the file
-
deleteFile
Delete the recovery file- Throws:
Exception
- if unable to delete the file
-
setProcessedFile
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 processedlastRecordProcessed1
- number of the last record processed
-
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
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
Write the recovering information to a file- Throws:
Exception
- if unable to write the file
-
toString
Get a String representation of the object
-