|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exist.storage.journal.Journal
public class 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 String |
BAK_FILE_SUFFIX
|
static int |
DEFAULT_MAX_SIZE
default maximum journal size |
static 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 String |
LOG_FILE_SUFFIX
|
static String |
PROPERTY_RECOVERY_JOURNAL_DIR
|
static String |
PROPERTY_RECOVERY_SIZE_LIMIT
|
static String |
PROPERTY_RECOVERY_SYNC_ON_COMMIT
|
static String |
RECOVERY_JOURNAL_DIR_ATTRIBUTE
|
static String |
RECOVERY_SIZE_LIMIT_ATTRIBUTE
|
static String |
RECOVERY_SYNC_ON_COMMIT_ATTRIBUTE
|
Constructor Summary | |
---|---|
Journal(BrokerPool pool,
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(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. |
File |
getFile(int fileNum)
Returns the file corresponding to the specified file number. |
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,
boolean checkpoint)
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 String RECOVERY_SYNC_ON_COMMIT_ATTRIBUTE
public static final String RECOVERY_JOURNAL_DIR_ATTRIBUTE
public static final String RECOVERY_SIZE_LIMIT_ATTRIBUTE
public static final String PROPERTY_RECOVERY_SIZE_LIMIT
public static final String PROPERTY_RECOVERY_JOURNAL_DIR
public static final String PROPERTY_RECOVERY_SYNC_ON_COMMIT
public static final String LOG_FILE_SUFFIX
public static final String BAK_FILE_SUFFIX
public static final 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, File directory) throws EXistException
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.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.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(File[] files)
files
- public File[] getFiles()
public File getFile(int fileNum)
fileNum
- public void shutdown(long txnId, boolean checkpoint)
txnId
- public void setInRecovery(boolean value)
value
-
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |