|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exist.storage.journal.Journal
Manages the journalling log. The database uses one central journal for all data files. If the journal exceeds the predefined maximum size, a new file is created. Every journal file has a unique number, which keeps growing during the lifetime of the db. The name of the file corresponds to the file number. The file with the highest number will be used for recovery. A buffer is used to temporarily buffer journal entries. To guarantee consistency, the buffer will be flushed and the journal is synched after every commit or whenever a db page is written to disk. Each entry has the structure:
[byte: entryType, long: transactionId, short length, byte[] data, short backLink]
LogEntryTypes
class.Loggable
object.
Field Summary | |
static java.lang.String |
BAK_FILE_SUFFIX
|
static int |
DEFAULT_MAX_SIZE
default maximum journal size |
static java.lang.String |
LCK_FILE
|
static int |
LOG_ENTRY_BASE_LEN
header length + trailing back link |
static int |
LOG_ENTRY_HEADER_LEN
the length of the header of each entry: entryType + transactionId + length |
static java.lang.String |
LOG_FILE_SUFFIX
|
Constructor Summary | |
Journal(BrokerPool pool,
java.io.File directory)
|
Method Summary | |
void |
checkpoint(long txnId,
boolean switchLogFiles)
Write a checkpoint record to the journal and flush it. |
void |
close()
|
static int |
findLastFile(java.io.File[] files)
Find the journal file with the highest file number. |
void |
flushToLog(boolean fsync)
Flush the current buffer to disk. |
void |
flushToLog(boolean fsync,
boolean forceSync)
Flush the current buffer to disk. |
java.io.File |
getFile(int fileNum)
Returns the file corresponding to the specified file number. |
java.io.File[] |
getFiles()
Returns all journal files found in the data directory. |
void |
initialize()
|
long |
lastWrittenLsn()
Returns the last LSN physically written to the journal. |
void |
setCurrentFileNum(int fileNum)
Set the file number of the last file used. |
void |
setInRecovery(boolean value)
Called to signal that the db is currently in recovery phase, so no output should be written. |
void |
shutdown(long txnId)
Shut down the journal. |
void |
switchFiles()
Create a new journal with a larger file number than the previous file. |
void |
writeToLog(Loggable loggable)
Write a log entry to the journalling log. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String LOG_FILE_SUFFIX
public static final java.lang.String BAK_FILE_SUFFIX
public static final java.lang.String LCK_FILE
public static final int LOG_ENTRY_HEADER_LEN
public static final int LOG_ENTRY_BASE_LEN
public static final int DEFAULT_MAX_SIZE
Constructor Detail |
public Journal(BrokerPool pool, java.io.File directory) throws EXistException
Method Detail |
public void initialize() throws EXistException, ReadOnlyException
EXistException
ReadOnlyException
public void writeToLog(Loggable loggable) throws TransactionException
loggable
-
TransactionException
public long lastWrittenLsn()
public void flushToLog(boolean fsync)
fsync
- forces all changes to disk if true and syncMode is set to SYNC_ON_COMMIT.
TransactionException
public void flushToLog(boolean fsync, boolean forceSync)
fsync
- forces all changes to disk if true and syncMode is set to SYNC_ON_COMMIT.forceSync
- force changes to disk even if syncMode doesn't require it.
TransactionException
public void checkpoint(long txnId, boolean switchLogFiles) throws TransactionException
#MIN_REPLACE
. The old log is removed.
txnId
- switchLogFiles
-
TransactionException
public void setCurrentFileNum(int fileNum)
fileNum
- the log file numberpublic void switchFiles() throws LogException
LogException
public void close()
public static final int findLastFile(java.io.File[] files)
files
- public java.io.File[] getFiles()
public java.io.File getFile(int fileNum)
fileNum
- public void shutdown(long txnId)
txnId
- public void setInRecovery(boolean value)
value
-
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |