Top Fields Methods
org.apache.derby.iapi.store.raw.log

public Interface LogFactory

extends Corruptable
Known Direct Implementers
org.apache.derby.impl.store.raw.log.LogToFile, org.apache.derby.impl.store.raw.log.ReadOnly
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.property.PersistentSet, org.apache.derby.iapi.store.replication.master.MasterFactory, org.apache.derby.iapi.store.raw.data.DataFactory, org.apache.derby.iapi.store.raw.Corruptable, .RawStoreFactory, .ScanHandle, org.apache.derby.iapi.store.raw.xact.TransactionFactory, org.apache.derby.io.StorageFile, org.apache.derby.iapi.store.access.DatabaseInstant, org.apache.derby.shared.common.reference.Property, java.io.File

Field Summary

Modifier and TypeField and Description
public static final String
LOG_DIRECTORY_NAME

The name of the default log directory.

public static final String
public static final String
RT_READONLY

An attribute that indicates the database is readonly

public static final 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

Modifier and TypeMethod and Description
public void
public boolean

Returns:

true if checkpoint is successful, Will return false if wait is false and the routine finds another thread executing a checkpoint.
checkpoint
(RawStoreFactory
- the raw store
rawStoreFactory
,
DataFactory
- the data factory
dataFactory
,
TransactionFactory
- the transaction factory
transactionFactory
,
boolean
- 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.
wait
)

Checkpoint the rawstore.

public void
checkpointInRFR(LogInstant
The LogInstant of the checkpoint
cinstant
,
long
Redo Low Water Mark in the check point record
redoLWM
,
long
Undo Low Water Mark in the checkpoint
undoLWM
,
DataFactory
- the data factory
df
)

redoing a checkpoint during rollforward recovery

public boolean

Returns:

true if the database has been upgraded to the required level, false otherwise.
checkVersion
(int
required database Engine major version
requiredMajorVersion
,
int
required database Engine minor version
requiredMinorVersion
,
String
Non-null to throw an exception, null to return the state of the version match.
feature
)

Check to see if a database has been upgraded to the required level in order to use a store feature.

public void
createDataWarningFile()

Create readme file in log directory warning users against touching any files in the directory

public void
public void
public void
public void
public void
public void
flush(LogInstant
flush log up to here
where
)

Flush all unwritten log record up to the log instance indicated to disk.

public void
freezePersistentStore()

Stop making any change to the persistent store

public String
getCanonicalLogPath()

Return the canonical directory of the PARENT of the log directory.

public LogInstant
getFirstUnflushedInstant()

Get the instant for the last record in the log.

public long

Returns:

the log instant long value of the first log record that has not been flushed
getFirstUnflushedInstantAsLong
()

Get the log instant long value of the first log record that has not been flushed.

public StorageFile
getLogDirectory()

Return the location of the log directory.

public void
getLogFactoryProperties(PersistentSet set)

Get JBMS properties relevant to the log factory

public Logger
public boolean

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.
inReplicationMasterMode
()

Used to determine if the replication master mode has been started, and the logging for unlogged operations needs to be enabled.

public boolean
public boolean
public boolean

Returns:

true if the log is being archived.
logArchived
()

checks whether is log archive mode is enabled or not.

public ScanHandle

Returns:

the LogScan.
openFlushedScan
(DatabaseInstant
- 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.
startAt
,
int
- log record groups the scanner wants.
groupsIWant
)

Get a ScanHandle to scan flushed records from the log.

public LogScan

Returns:

the LogScan.
openForwardsFlushedScan
(LogInstant
- 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.
startAt
)

Get a LogScan to scan flushed records from the log.

public LogScan

Returns:

the LogScan.
openForwardsScan
(LogInstant
- 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.
startAt
,
LogInstant
- 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.
stopAt
)

Get a LogScan to scan the log in a forward direction.

public void
recover(DataFactory
- the data factory
dataFactory
,
TransactionFactory
- the transaction factory
transactionFactory
)

Recover the database to a consistent state using the log.

public void
setDatabaseEncrypted(boolean
true if the database is encrypted, false if not
isEncrypted
,
boolean
true if log needs to be flushed, false otherwise
flushLog
)

Sets whether the database is encrypted, all the transaction log has to be encrypted, and flush the log if requested.

public void
setRawStoreFactory(RawStoreFactory rsf)

Make log factory aware of which raw store factory it belongs to

public void
public void
public void
startReplicationMasterRole(MasterFactory
The MasterFactory service responsible for controlling the master side replication behaviour.
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.

public 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.

public void
unfreezePersistentStore()

Can start making change to the persistent store again

Inherited from org.apache.derby.iapi.store.raw.Corruptable:
markCorrupt

Field Detail

LOG_DIRECTORY_NAMEback to summary
public static final String LOG_DIRECTORY_NAME

The name of the default log directory.

MODULEback to summary
public static final String MODULE
RT_READONLYback to summary
public static final String RT_READONLY

An attribute that indicates the database is readonly

RUNTIME_ATTRIBUTESback to summary
public static final 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.

Method Detail

abortLogBackupback to summary
public void abortLogBackup()
checkpointback to summary
public 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:RawStoreFactory

- the raw store

dataFactory:DataFactory

- the data factory

transactionFactory:TransactionFactory

- the transaction factory

wait:boolean

- 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:boolean

true if checkpoint is successful, Will return false if wait is false and the routine finds another thread executing a checkpoint.

Exceptions
StandardException:
- got exception while doing checkpoint.
checkpointInRFRback to summary
public void checkpointInRFR(LogInstant cinstant, long redoLWM, long undoLWM, DataFactory df) throws StandardException

redoing a checkpoint during rollforward recovery

Parameters
cinstant:LogInstant

The LogInstant of the checkpoint

redoLWM:long

Redo Low Water Mark in the check point record

undoLWM:long

Undo Low Water Mark in the checkpoint

df:DataFactory

- the data factory

Exceptions
StandardException:
- encounter exception during checkpoint
checkVersionback to summary
public 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:int

required database Engine major version

requiredMinorVersion:int

required database Engine minor version

feature:String

Non-null to throw an exception, null to return the state of the version match.

Returns:boolean

true if the database has been upgraded to the required level, false otherwise.

Exceptions
StandardException:
if the database is not at the require version when feature feature is not null .
createDataWarningFileback to summary
public void createDataWarningFile() throws StandardException

Create readme file in log directory warning users against touching any files in the directory

deleteLogFileAfterCheckpointLogFileback to summary
public void deleteLogFileAfterCheckpointLogFile() throws StandardException
deleteOnlineArchivedLogFilesback to summary
public void deleteOnlineArchivedLogFiles()
disableLogArchiveModeback to summary
public void disableLogArchiveMode() throws StandardException
enableLogArchiveModeback to summary
public void enableLogArchiveMode() throws StandardException
endLogBackupback to summary
public void endLogBackup(File toDir) throws StandardException
flushback to summary
public void flush(LogInstant where) throws StandardException

Flush all unwritten log record up to the log instance indicated to disk.

Parameters
where:LogInstant

flush log up to here

Exceptions
StandardException:
cannot flush log file due to sync error
freezePersistentStoreback to summary
public void freezePersistentStore() throws StandardException

Stop making any change to the persistent store

Exceptions
StandardException:
Standard Derby exception policy.
getCanonicalLogPathback to summary
public 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.

getFirstUnflushedInstantback to summary
public LogInstant getFirstUnflushedInstant()

Get the instant for the last record in the log.

getFirstUnflushedInstantAsLongback to summary
public 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:long

the log instant long value of the first log record that has not been flushed

getLogDirectoryback to summary
public StorageFile getLogDirectory() throws StandardException

Return the location of the log directory.

Exceptions
StandardException:
Standard Derby Error Policy
getLogFactoryPropertiesback to summary
public void getLogFactoryProperties(PersistentSet set) throws StandardException

Get JBMS properties relevant to the log factory

Exceptions
StandardException:
Standard Derby Error Policy
getLoggerback to summary
public Logger getLogger()
inReplicationMasterModeback to summary
public boolean inReplicationMasterMode()

Used to determine if the replication master mode has been started, and the logging for unlogged operations needs to be enabled.

Returns:boolean

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.

inRFRback to summary
public boolean inRFR()
isCheckpointInLastLogFileback to summary
public boolean isCheckpointInLastLogFile() throws StandardException
logArchivedback to summary
public boolean logArchived()

checks whether is log archive mode is enabled or not.

Returns:boolean

true if the log is being archived.

openFlushedScanback to summary
public ScanHandle openFlushedScan(DatabaseInstant startAt, int groupsIWant) throws StandardException

Get a ScanHandle to scan flushed records from the log.

MT- read only

Parameters
startAt:DatabaseInstant

- 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:int

- log record groups the scanner wants.

Returns:ScanHandle

the LogScan.

Exceptions
StandardException:
Standard Derby error policy
openForwardsFlushedScanback to summary
public LogScan openForwardsFlushedScan(LogInstant startAt) throws StandardException

Get a LogScan to scan flushed records from the log.

MT- read only

Parameters
startAt:LogInstant

- 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:LogScan

the LogScan.

Exceptions
StandardException:
Standard Derby error policy NOTE: This will be removed after the LogSniffer Rewrite.
openForwardsScanback to summary
public LogScan openForwardsScan(LogInstant startAt, LogInstant stopAt) throws StandardException

Get a LogScan to scan the log in a forward direction.

MT- read only

Parameters
startAt:LogInstant

- 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:LogInstant

- 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:LogScan

the LogScan.

Exceptions
StandardException:
Standard Derby error policy
recoverback to summary
public 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:DataFactory

- the data factory

transactionFactory:TransactionFactory

- the transaction factory

Exceptions
StandardException:
- encounter exception while recovering.
setDatabaseEncryptedback to summary
public 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:boolean

true if the database is encrypted, false if not

flushLog:boolean

true if log needs to be flushed, false otherwise

setRawStoreFactoryback to summary
public void setRawStoreFactory(RawStoreFactory rsf)

Make log factory aware of which raw store factory it belongs to

startLogBackupback to summary
public void startLogBackup(File toDir) throws StandardException
startNewLogFileback to summary
public void startNewLogFile() throws StandardException
startReplicationMasterRoleback to summary
public 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:MasterFactory

The MasterFactory service responsible for controlling the master side replication behaviour.

Exceptions
StandardException:
Standard Derby exception policy, thrown on replication startup error. Will only be thrown if replication is attempted started on a readonly database.
stopReplicationMasterRoleback to summary
public 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.

unfreezePersistentStoreback to summary
public void unfreezePersistentStore() throws StandardException

Can start making change to the persistent store again

Exceptions
StandardException:
Standard Derby exception policy.