Interface LogFactory
- All Superinterfaces:
Corruptable
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the default log directory.static final Stringstatic final StringAn attribute that indicates the database is readonlystatic final StringThe name of a runtime property in the service set that defines any runtime attributes a log factory should have. -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleancheckpoint(RawStoreFactory rawStoreFactory, DataFactory dataFactory, TransactionFactory transactionFactory, boolean wait) Checkpoint the rawstore.voidcheckpointInRFR(LogInstant cinstant, long redoLWM, long undoLWM, DataFactory df) redoing a checkpoint during rollforward recoverybooleancheckVersion(int requiredMajorVersion, int requiredMinorVersion, String feature) Check to see if a database has been upgraded to the required level in order to use a store feature.voidCreate readme file in log directory warning users against touching any files in the directoryvoidvoidvoidvoidvoidendLogBackup(File toDir) voidflush(LogInstant where) Flush all unwritten log record up to the log instance indicated to disk.voidStop making any change to the persistent storeReturn the canonical directory of the PARENT of the log directory.Get the instant for the last record in the log.longGet the log instant long value of the first log record that has not been flushed.Return the location of the log directory.voidGet JBMS properties relevant to the log factorybooleanUsed to determine if the replication master mode has been started, and the logging for unlogged operations needs to be enabled.booleaninRFR()booleanbooleanchecks whether is log archive mode is enabled or not.openFlushedScan(DatabaseInstant startAt, int groupsIWant) Get a ScanHandle to scan flushed records from the log.openForwardsFlushedScan(LogInstant startAt) Get a LogScan to scan flushed records from the log.openForwardsScan(LogInstant startAt, LogInstant stopAt) Get a LogScan to scan the log in a forward direction.voidrecover(DataFactory dataFactory, TransactionFactory transactionFactory) Recover the database to a consistent state using the log.voidsetDatabaseEncrypted(boolean isEncrypted, boolean flushLog) Sets whether the database is encrypted, all the transaction log has to be encrypted, and flush the log if requested.voidMake log factory aware of which raw store factory it belongs tovoidstartLogBackup(File toDir) voidvoidstartReplicationMasterRole(MasterFactory masterFactory) Make this LogFactory pass log records to the MasterFactory every time a log record is appended to the log on disk, and notify the MasterFactory when a log disk flush has taken place.voidStop this LogFactory from passing log records to the MasterFactory and from notifying the MasterFactory when a log disk flush has taken place.voidCan start making change to the persistent store againMethods inherited from interface Corruptable
markCorrupt
-
Field Details
-
RUNTIME_ATTRIBUTES
The name of a runtime property in the service set that defines any runtime attributes a log factory should have. It is (or will be) a comma separated list of attributes. At the moment only one attribute is known and checked for.- See Also:
-
RT_READONLY
-
LOG_DIRECTORY_NAME
-
MODULE
- See Also:
-
-
Method Details
-
getLogger
Logger getLogger() -
createDataWarningFile
Create readme file in log directory warning users against touching any files in the directory- Throws:
StandardException
-
setRawStoreFactory
Make log factory aware of which raw store factory it belongs to -
recover
void recover(DataFactory dataFactory, TransactionFactory transactionFactory) throws StandardException Recover the database to a consistent state using the log. Each implementation of the log factory has its own recovery algorithm, please see the implementation for a description of the specific recovery algorithm it uses.- Parameters:
dataFactory- - the data factorytransactionFactory- - the transaction factory- Throws:
StandardException- - encounter exception while recovering.
-
checkpoint
boolean checkpoint(RawStoreFactory rawStoreFactory, DataFactory dataFactory, TransactionFactory transactionFactory, boolean wait) throws StandardException Checkpoint the rawstore. The frequency of checkpoint is determined by 2 persistent service properties, RawStore.LOG_SWITCH_INTERVAL and RawStore.CHECKPOINT_INTERVAL. By default, LOG_SWITCH_INTERVAL is every 1M bytes of log record written. User can change this value by setting the property to some other values during boot time. The legal range of LOG_SWITCH_INTERVAL is from 100K to 128M. By default, CHECKPOINT_INTERVAL equals 10M, but user can set it to less if more frequent checkpoint is desired. The legal range of CHECKPOINT_INTERVAL is from 100K to 128M.- Parameters:
rawStoreFactory- - the raw storedataFactory- - the data factorytransactionFactory- - the transaction factorywait- - if true waits for any existing checkpoint to complete and then executes and waits for another checkpoint. if false if another thead is executing a checkpoint routine will return immediately.- Returns:
- true if checkpoint is successful, Will return false if wait is false and the routine finds another thread executing a checkpoint.
- Throws:
StandardException- - got exception while doing checkpoint.
-
flush
Flush all unwritten log record up to the log instance indicated to disk.- Parameters:
where- flush log up to here- Throws:
StandardException- cannot flush log file due to sync error
-
openForwardsFlushedScan
Get a LogScan to scan flushed records from the log.MT- read only
- Parameters:
startAt- - the LogInstant where we start our scan. null means start at the beginning of the log. This function raises an error if startAt is a LogInstant which is not in the log.- Returns:
- the LogScan.
- Throws:
StandardException- Standard Derby error policy NOTE: This will be removed after the LogSniffer Rewrite.
-
openFlushedScan
Get a ScanHandle to scan flushed records from the log.MT- read only
- Parameters:
startAt- - the LogInstant where we start our scan. null means start at the beginning of the log. This function raises an error if startAt is a LogInstant which is not in the log.groupsIWant- - log record groups the scanner wants.- Returns:
- the LogScan.
- Throws:
StandardException- Standard Derby error policy
-
openForwardsScan
Get a LogScan to scan the log in a forward direction.MT- read only
- Parameters:
startAt- - the LogInstant where we start our scan. null means start at the beginning of the log. This function raises an error if startAt is a LogInstant which is not in the log.stopAt- - the LogInstant where we stop our scan. null means stop at the end of the log. This function raises an error if stopAt is a LogInstant which is not in the log.- Returns:
- the LogScan.
- Throws:
StandardException- Standard Derby error policy
-
getFirstUnflushedInstant
LogInstant getFirstUnflushedInstant()Get the instant for the last record in the log. -
getFirstUnflushedInstantAsLong
long getFirstUnflushedInstantAsLong()Get the log instant long value of the first log record that has not been flushed. Only works after recover() has finished, or (if in slave replication mode) after calling initializeReplicationSlaveRole.- Returns:
- the log instant long value of the first log record that has not been flushed
-
freezePersistentStore
Stop making any change to the persistent store- Throws:
StandardException- Standard Derby exception policy.
-
unfreezePersistentStore
Can start making change to the persistent store again- Throws:
StandardException- Standard Derby exception policy.
-
logArchived
boolean logArchived()checks whether is log archive mode is enabled or not.- Returns:
- true if the log is being archived.
-
inReplicationMasterMode
boolean inReplicationMasterMode()Used to determine if the replication master mode has been started, and the logging for unlogged operations needs to be enabled.- Returns:
- true If the master replication mode is turned on and the unlogged operations need to be logged. false If the master replication mode is turned off and the unlogged operations need not be logged.
-
getLogFactoryProperties
Get JBMS properties relevant to the log factory- Throws:
StandardException- Standard Derby Error Policy
-
getLogDirectory
Return the location of the log directory.- Throws:
StandardException- Standard Derby Error Policy
-
getCanonicalLogPath
String getCanonicalLogPath()Return the canonical directory of the PARENT of the log directory. The log directory live in the "log" subdirectory of this path. If the log is at the default location (underneath the database directory), this returns null. Should only be called after the log factory is booted. -
enableLogArchiveMode
- Throws:
StandardException
-
disableLogArchiveMode
- Throws:
StandardException
-
deleteOnlineArchivedLogFiles
void deleteOnlineArchivedLogFiles() -
inRFR
boolean inRFR() -
checkpointInRFR
void checkpointInRFR(LogInstant cinstant, long redoLWM, long undoLWM, DataFactory df) throws StandardException redoing a checkpoint during rollforward recovery- Parameters:
cinstant- The LogInstant of the checkpointredoLWM- Redo Low Water Mark in the check point recordundoLWM- Undo Low Water Mark in the checkpointdf- - the data factory- Throws:
StandardException- - encounter exception during checkpoint
-
startLogBackup
- Throws:
StandardException
-
endLogBackup
- Throws:
StandardException
-
abortLogBackup
void abortLogBackup() -
setDatabaseEncrypted
Sets whether the database is encrypted, all the transaction log has to be encrypted, and flush the log if requested.Log needs to be flushed first if the cryptographic state of the database changes (for instance re-encryption with a new key).
- Parameters:
isEncrypted-trueif the database is encrypted,falseif notflushLog-trueif log needs to be flushed,falseotherwise- Throws:
StandardException
-
startNewLogFile
- Throws:
StandardException
-
isCheckpointInLastLogFile
- Throws:
StandardException
-
deleteLogFileAfterCheckpointLogFile
- Throws:
StandardException
-
checkVersion
boolean checkVersion(int requiredMajorVersion, int requiredMinorVersion, String feature) throws StandardException Check to see if a database has been upgraded to the required level in order to use a store feature.- Parameters:
requiredMajorVersion- required database Engine major versionrequiredMinorVersion- required database Engine minor versionfeature- Non-null to throw an exception, null to return the state of the version match.- Returns:
trueif the database has been upgraded to the required level,falseotherwise.- Throws:
StandardException- if the database is not at the require version whenfeaturefeature is notnull.
-
startReplicationMasterRole
Make this LogFactory pass log records to the MasterFactory every time a log record is appended to the log on disk, and notify the MasterFactory when a log disk flush has taken place. Not implemented by ReadOnly.- Parameters:
masterFactory- The MasterFactory service responsible for controlling the master side replication behaviour.- Throws:
StandardException- Standard Derby exception policy, thrown on replication startup error. Will only be thrown if replication is attempted started on a readonly database.
-
stopReplicationMasterRole
void stopReplicationMasterRole()Stop this LogFactory from passing log records to the MasterFactory and from notifying the MasterFactory when a log disk flush has taken place. Not implemented by ReadOnly.
-