Class RecoveryInfo
- java.lang.Object
-
- edu.caltech.nanodb.storage.writeahead.RecoveryInfo
-
public class RecoveryInfo extends java.lang.Object
This class holds information necessary for theWALManager
to perform recovery processing, such as the LSNs to scan for redo/undo processing, and the set of incomplete transactions.
-
-
Field Summary
Fields Modifier and Type Field Description LogSequenceNumber
firstLSN
This is the log sequence number to start recovery processing from.java.util.HashMap<java.lang.Integer,LogSequenceNumber>
incompleteTxns
This is the set of incomplete transactions found during recovery processing, along with the last log sequence number seen for each transaction.int
maxTransactionID
This is the maximum transaction ID seen in the write-ahead logs.LogSequenceNumber
nextLSN
This is the "next LSN", one past the last valid log sequence number found in the write-ahead logs.
-
Constructor Summary
Constructors Constructor Description RecoveryInfo(LogSequenceNumber firstLSN, LogSequenceNumber nextLSN)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LogSequenceNumber
getLastLSN(int transactionID)
This helper method returns the last log sequence number seen for the specified transaction.boolean
hasIncompleteTxns()
Returns true if there are any incomplete transactions, or false if all transactions are completed.boolean
isTxnComplete(int transactionID)
Returns true if the specified transaction is complete, or false if it appears in the set of incomplete transactions.void
recordTxnCompleted(int transactionID)
This helper function records that the specified transaction is completed in the write-ahead log.void
updateInfo(int transactionID, LogSequenceNumber lsn)
This helper method updates the recovery information with the specified transaction ID and log sequence number.
-
-
-
Field Detail
-
firstLSN
public LogSequenceNumber firstLSN
This is the log sequence number to start recovery processing from.
-
nextLSN
public LogSequenceNumber nextLSN
This is the "next LSN", one past the last valid log sequence number found in the write-ahead logs.
-
maxTransactionID
public int maxTransactionID
This is the maximum transaction ID seen in the write-ahead logs. The next transaction ID used by the database system will be one more than this value.
-
incompleteTxns
public java.util.HashMap<java.lang.Integer,LogSequenceNumber> incompleteTxns
This is the set of incomplete transactions found during recovery processing, along with the last log sequence number seen for each transaction.
-
-
Constructor Detail
-
RecoveryInfo
public RecoveryInfo(LogSequenceNumber firstLSN, LogSequenceNumber nextLSN)
-
-
Method Detail
-
updateInfo
public void updateInfo(int transactionID, LogSequenceNumber lsn)
This helper method updates the recovery information with the specified transaction ID and log sequence number. The requirement is that this method is only used during redo processing; we expect that log sequence numbers are monotonically increasing.- Parameters:
transactionID
- the ID of the transaction that appears in the current write-ahead log recordlsn
- the log sequence number of the current write-ahead log record
-
getLastLSN
public LogSequenceNumber getLastLSN(int transactionID)
This helper method returns the last log sequence number seen for the specified transaction. It is used during undo processing to allow subsequent WAL records to refer to the earlier WAL records that appear for the transaction.- Parameters:
transactionID
- the ID of the transaction to get the most recent LSN for- Returns:
- the last log sequence number seen for the specified transaction
-
recordTxnCompleted
public void recordTxnCompleted(int transactionID)
This helper function records that the specified transaction is completed in the write-ahead log. Specifically, the transaction is removed from the set of incomplete transactions.- Parameters:
transactionID
- the transaction to record as completed
-
hasIncompleteTxns
public boolean hasIncompleteTxns()
Returns true if there are any incomplete transactions, or false if all transactions are completed.- Returns:
- true if there are any incomplete transactions, or false if all transactions are completed.
-
isTxnComplete
public boolean isTxnComplete(int transactionID)
Returns true if the specified transaction is complete, or false if it appears in the set of incomplete transactions.- Parameters:
transactionID
- the transaction to check for completion status- Returns:
- true if the transaction is complete, or false otherwise
-
-