Interface LogFactory
-
- All Superinterfaces:
Corruptable
public interface LogFactory extends Corruptable
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
LOG_DIRECTORY_NAME
The name of the default log directory.static java.lang.String
MODULE
static java.lang.String
RT_READONLY
An attribute that indicates the database is readonlystatic java.lang.String
RUNTIME_ATTRIBUTES
The name of a runtime property in the service set that defines any runtime attributes a log factory should have.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
abortLogBackup()
boolean
checkpoint(RawStoreFactory rawStoreFactory, DataFactory dataFactory, TransactionFactory transactionFactory, boolean wait)
Checkpoint the rawstore.void
checkpointInRFR(LogInstant cinstant, long redoLWM, long undoLWM, DataFactory df)
redoing a checkpoint during rollforward recoveryboolean
checkVersion(int requiredMajorVersion, int requiredMinorVersion, java.lang.String feature)
Check to see if a database has been upgraded to the required level in order to use a store feature.void
createDataWarningFile()
Create readme file in log directory warning users against touching any files in the directoryvoid
deleteLogFileAfterCheckpointLogFile()
void
deleteOnlineArchivedLogFiles()
void
disableLogArchiveMode()
void
enableLogArchiveMode()
void
endLogBackup(java.io.File toDir)
void
flush(LogInstant where)
Flush all unwritten log record up to the log instance indicated to disk.void
freezePersistentStore()
Stop making any change to the persistent storejava.lang.String
getCanonicalLogPath()
Return the canonical directory of the PARENT of the log directory.LogInstant
getFirstUnflushedInstant()
Get the instant for the last record in the log.long
getFirstUnflushedInstantAsLong()
Get the log instant long value of the first log record that has not been flushed.StorageFile
getLogDirectory()
Return the location of the log directory.void
getLogFactoryProperties(PersistentSet set)
Get JBMS properties relevant to the log factoryLogger
getLogger()
boolean
inReplicationMasterMode()
Used to determine if the replication master mode has been started, and the logging for unlogged operations needs to be enabled.boolean
inRFR()
boolean
isCheckpointInLastLogFile()
boolean
logArchived()
checks whether is log archive mode is enabled or not.ScanHandle
openFlushedScan(DatabaseInstant startAt, int groupsIWant)
Get a ScanHandle to scan flushed records from the log.LogScan
openForwardsFlushedScan(LogInstant startAt)
Get a LogScan to scan flushed records from the log.LogScan
openForwardsScan(LogInstant startAt, LogInstant stopAt)
Get a LogScan to scan the log in a forward direction.void
recover(DataFactory dataFactory, TransactionFactory transactionFactory)
Recover the database to a consistent state using the log.void
setDatabaseEncrypted(boolean isEncrypted, boolean flushLog)
Sets whether the database is encrypted, all the transaction log has to be encrypted, and flush the log if requested.void
setRawStoreFactory(RawStoreFactory rsf)
Make log factory aware of which raw store factory it belongs tovoid
startLogBackup(java.io.File toDir)
void
startNewLogFile()
void
startReplicationMasterRole(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.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.void
unfreezePersistentStore()
Can start making change to the persistent store again-
Methods inherited from interface org.apache.derby.iapi.store.raw.Corruptable
markCorrupt
-
-
-
-
Field Detail
-
RUNTIME_ATTRIBUTES
static final java.lang.String 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:
- Constant Field Values
-
RT_READONLY
static final java.lang.String RT_READONLY
An attribute that indicates the database is readonly- See Also:
- Constant Field Values
-
LOG_DIRECTORY_NAME
static final java.lang.String LOG_DIRECTORY_NAME
The name of the default log directory.- See Also:
- Constant Field Values
-
MODULE
static final java.lang.String MODULE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getLogger
Logger getLogger()
-
createDataWarningFile
void createDataWarningFile() throws StandardException
Create readme file in log directory warning users against touching any files in the directory- Throws:
StandardException
-
setRawStoreFactory
void setRawStoreFactory(RawStoreFactory rsf)
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
void flush(LogInstant where) throws StandardException
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
LogScan openForwardsFlushedScan(LogInstant startAt) throws StandardException
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
ScanHandle openFlushedScan(DatabaseInstant startAt, int groupsIWant) throws StandardException
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
LogScan openForwardsScan(LogInstant startAt, LogInstant stopAt) throws StandardException
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
void freezePersistentStore() throws StandardException
Stop making any change to the persistent store- Throws:
StandardException
- Standard Derby exception policy.
-
unfreezePersistentStore
void unfreezePersistentStore() throws StandardException
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
void getLogFactoryProperties(PersistentSet set) throws StandardException
Get JBMS properties relevant to the log factory- Throws:
StandardException
- Standard Derby Error Policy
-
getLogDirectory
StorageFile getLogDirectory() throws StandardException
Return the location of the log directory.- Throws:
StandardException
- Standard Derby Error Policy
-
getCanonicalLogPath
java.lang.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
void enableLogArchiveMode() throws StandardException
- Throws:
StandardException
-
disableLogArchiveMode
void disableLogArchiveMode() throws StandardException
- 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
void startLogBackup(java.io.File toDir) throws StandardException
- Throws:
StandardException
-
endLogBackup
void endLogBackup(java.io.File toDir) throws StandardException
- Throws:
StandardException
-
abortLogBackup
void abortLogBackup()
-
setDatabaseEncrypted
void setDatabaseEncrypted(boolean isEncrypted, boolean flushLog) throws StandardException
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
-true
if the database is encrypted,false
if notflushLog
-true
if log needs to be flushed,false
otherwise- Throws:
StandardException
-
startNewLogFile
void startNewLogFile() throws StandardException
- Throws:
StandardException
-
isCheckpointInLastLogFile
boolean isCheckpointInLastLogFile() throws StandardException
- Throws:
StandardException
-
deleteLogFileAfterCheckpointLogFile
void deleteLogFileAfterCheckpointLogFile() throws StandardException
- Throws:
StandardException
-
checkVersion
boolean checkVersion(int requiredMajorVersion, int requiredMinorVersion, java.lang.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:
true
if the database has been upgraded to the required level,false
otherwise.- Throws:
StandardException
- if the database is not at the require version whenfeature
feature is notnull
.
-
startReplicationMasterRole
void startReplicationMasterRole(MasterFactory masterFactory) throws StandardException
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.
-
-