public class LogFile
extends java.lang.Object
The format of the log file is as follows:
Modifier and Type | Field and Description |
---|---|
(package private) static int |
ABORT_RECORD |
(package private) static int |
BEGIN_RECORD |
(package private) static int |
CHECKPOINT_RECORD |
(package private) static int |
COMMIT_RECORD |
(package private) long |
currentOffset |
(package private) static int |
INT_SIZE |
(package private) java.io.File |
logFile |
(package private) static int |
LONG_SIZE |
(package private) static long |
NO_CHECKPOINT_ID |
private java.io.RandomAccessFile |
raf |
(package private) java.lang.Boolean |
recoveryUndecided |
(package private) java.util.HashMap<java.lang.Long,java.lang.Long> |
tidToFirstLogRecord |
(package private) int |
totalRecords |
(package private) static int |
UPDATE_RECORD |
Constructor and Description |
---|
LogFile(java.io.File f)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
force() |
int |
getTotalRecords() |
void |
logAbort(TransactionId tid)
Write an abort record to the log for the specified tid, force
the log to disk, and perform a rollback
|
void |
logCheckpoint()
Checkpoint the log and write a checkpoint record.
|
void |
logCommit(TransactionId tid)
Write a commit record to disk for the specified tid,
and force the log to disk.
|
void |
logTruncate()
Truncate any unneeded portion of the log to reduce its space
consumption
|
void |
logWrite(TransactionId tid,
Page before,
Page after)
Write an UPDATE record to disk for the specified tid and page
(with provided before and after images.)
|
void |
logXactionBegin(TransactionId tid)
Write a BEGIN record for the specified transaction
|
(package private) void |
preAppend() |
void |
print()
Print out a human readable represenation of the log
|
(package private) Page |
readPageData(java.io.RandomAccessFile raf) |
void |
recover()
Recover the database system by ensuring that the updates of
committed transactions are installed and that the
updates of uncommitted transactions are not installed.
|
void |
rollback(TransactionId tid)
Rollback the specified transaction, setting the state of any
of pages it updated to their pre-updated state.
|
void |
shutdown()
Shutdown the logging system, writing out whatever state
is necessary so that start up can happen quickly (without
extensive recovery.)
|
(package private) void |
writePageData(java.io.RandomAccessFile raf,
Page p) |
final java.io.File logFile
private java.io.RandomAccessFile raf
java.lang.Boolean recoveryUndecided
static final int ABORT_RECORD
static final int COMMIT_RECORD
static final int UPDATE_RECORD
static final int BEGIN_RECORD
static final int CHECKPOINT_RECORD
static final long NO_CHECKPOINT_ID
static final int INT_SIZE
static final int LONG_SIZE
long currentOffset
int totalRecords
java.util.HashMap<java.lang.Long,java.lang.Long> tidToFirstLogRecord
public LogFile(java.io.File f) throws java.io.IOException
f
- The log file's namejava.io.IOException
void preAppend() throws java.io.IOException
java.io.IOException
public int getTotalRecords()
public void logAbort(TransactionId tid) throws java.io.IOException
tid
- The aborting transaction.java.io.IOException
public void logCommit(TransactionId tid) throws java.io.IOException
tid
- The committing transaction.java.io.IOException
public void logWrite(TransactionId tid, Page before, Page after) throws java.io.IOException
tid
- The transaction performing the writebefore
- The before image of the pageafter
- The after image of the pagejava.io.IOException
Page.getBeforeImage()
void writePageData(java.io.RandomAccessFile raf, Page p) throws java.io.IOException
java.io.IOException
Page readPageData(java.io.RandomAccessFile raf) throws java.io.IOException
java.io.IOException
public void logXactionBegin(TransactionId tid) throws java.io.IOException
tid
- The transaction that is beginningjava.io.IOException
public void logCheckpoint() throws java.io.IOException
java.io.IOException
public void logTruncate() throws java.io.IOException
java.io.IOException
public void rollback(TransactionId tid) throws java.util.NoSuchElementException, java.io.IOException
tid
- The transaction to rollbackjava.util.NoSuchElementException
java.io.IOException
public void shutdown()
public void recover() throws java.io.IOException
java.io.IOException
public void print() throws java.io.IOException
java.io.IOException
public void force() throws java.io.IOException
java.io.IOException