Class ReadOnly
- java.lang.Object
-
- org.apache.derby.impl.store.raw.log.ReadOnly
-
- All Implemented Interfaces:
ModuleSupportable,Corruptable,LogFactory
public class ReadOnly extends java.lang.Object implements LogFactory, ModuleSupportable
A read-only version of the log factory. It doesn't do anything, it doesn't check that the database needs recovery or not.It doesn't handle undo. No recovery.
Multithreading considerations:
This class must be MT-safe.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringlogArchiveDirectory-
Fields inherited from interface org.apache.derby.iapi.store.raw.log.LogFactory
LOG_DIRECTORY_NAME, MODULE, RT_READONLY, RUNTIME_ATTRIBUTES
-
-
Constructor Summary
Constructors Constructor Description ReadOnly()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabortLogBackup()booleancanSupport(java.util.Properties startParams)See if this implementation can support any attributes that are listed in properties.booleancheckpoint(RawStoreFactory rawStoreFactory, DataFactory dataFactory, TransactionFactory transactionFactory, boolean wait)MT - not needed, no work is donevoidcheckpointInRFR(LogInstant cinstant, long redoLWM, long undoLWM, DataFactory df)Perform a checkpoint during rollforward recovery.booleancheckVersion(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.voidcreateDataWarningFile()Not applicable in readonly databasesvoiddeleteLogFileAfterCheckpointLogFile()voiddeleteOnlineArchivedLogFiles()voiddisableLogArchiveMode()voidenableLogArchiveMode()voidendLogBackup(java.io.File toDir)voidflush(LogInstant where)Flush all unwritten log record up to the log instance indicated to disk.voidfreezePersistentStore()Backup restore - stop sending log record to the log streamjava.lang.StringgetCanonicalLogPath()Return the canonical directory of the PARENT of the log directory.LogInstantgetFirstUnflushedInstant()Get the instant for the last record in the log.longgetFirstUnflushedInstantAsLong()Get the log instant long value of the first log record that has not been flushed.StorageFilegetLogDirectory()Return the location of the log directory.voidgetLogFactoryProperties(PersistentSet set)Get JBMS properties relevant to the log factoryLoggergetLogger()LogInstantgetTruncationLWM(UUID name)booleaninReplicationMasterMode()Replication not applicable on readonly databases.booleaninRFR()booleanisCheckpointInLastLogFile()booleanlogArchived()Backup restore - is the log being archived to some directory?StandardExceptionmarkCorrupt(StandardException originalError)Mark the module as corrupt.ScanHandleopenFlushedScan(DatabaseInstant i, int groupsIWant)Get a ScanHandle to scan flushed records from the log.LogScanopenForwardsFlushedScan(LogInstant startAt)Get a LogScan to scan flushed records from the log.LogScanopenForwardsScan(LogInstant startAt, LogInstant stopAt)Get a LogScan to scan the log in a forward direction.voidrecover(DataFactory dataFactory, TransactionFactory transactionFactory)MT - not needed, no work is donevoidremoveTruncationLWM(UUID name)voidremoveTruncationLWM(UUID name, RawStoreFactory rawStoreFactory, TransactionFactory transFactory)voidsetDatabaseEncrypted(boolean isEncrypted, boolean flushLog)Sets whether the database is encrypted.voidsetRawStoreFactory(RawStoreFactory rsf)Not applicable in readonly databasesvoidsetTruncationLWM(UUID name, LogInstant instant)LogInstantsetTruncationLWM(UUID name, LogInstant instant, RawStoreFactory rawStoreFactory, TransactionFactory transFactory)voidstartLogBackup(java.io.File toDir)voidstartNewLogFile()voidstartReplicationMasterRole(MasterFactory masterFactory)Replication not applicable on readonly databasesvoidstopReplicationMasterRole()Replication not applicable on readonly databasesvoidunfreezePersistentStore()Backup restore - start sending log record to the log stream
-
-
-
Method Detail
-
getLogger
public Logger getLogger()
- Specified by:
getLoggerin interfaceLogFactory
-
createDataWarningFile
public void createDataWarningFile() throws StandardExceptionNot applicable in readonly databases- Specified by:
createDataWarningFilein interfaceLogFactory- Throws:
StandardException
-
setRawStoreFactory
public void setRawStoreFactory(RawStoreFactory rsf)
Not applicable in readonly databases- Specified by:
setRawStoreFactoryin interfaceLogFactory
-
recover
public void recover(DataFactory dataFactory, TransactionFactory transactionFactory) throws StandardException
MT - not needed, no work is done- Specified by:
recoverin interfaceLogFactory- Parameters:
dataFactory- - the data factorytransactionFactory- - the transaction factory- Throws:
StandardException- Standard Derby Error Policy
-
checkpoint
public boolean checkpoint(RawStoreFactory rawStoreFactory, DataFactory dataFactory, TransactionFactory transactionFactory, boolean wait)
MT - not needed, no work is done- Specified by:
checkpointin interfaceLogFactory- 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.
-
markCorrupt
public StandardException markCorrupt(StandardException originalError)
Description copied from interface:CorruptableMark the module as corrupt. It is safe to call this multiple times.- Specified by:
markCorruptin interfaceCorruptable- Returns:
- Must always return its parameter.
-
flush
public void flush(LogInstant where) throws StandardException
Description copied from interface:LogFactoryFlush all unwritten log record up to the log instance indicated to disk.- Specified by:
flushin interfaceLogFactory- Parameters:
where- flush log up to here- Throws:
StandardException- cannot flush log file due to sync error
-
canSupport
public boolean canSupport(java.util.Properties startParams)
Description copied from interface:ModuleSupportableSee if this implementation can support any attributes that are listed in properties. This call may be made on a newly created instance before the boot() method has been called, or after the boot method has been called for a running module.The module can check for attributes in the properties to see if it can fulfill the required behaviour. E.g. the raw store may define an attribute called RawStore.Recoverable. If a temporary raw store is required the property RawStore.recoverable=false would be added to the properties before calling bootServiceModule. If a raw store cannot support this attribute its canSupport method would return null. Also see the Monitor class's prologue to see how the identifier is used in looking up properties.
Actually a better way maybe to have properties of the form RawStore.Attributes.mandatory=recoverable,smallfootprint and RawStore.Attributes.requested=oltp,fast- Specified by:
canSupportin interfaceModuleSupportable- Returns:
- true if this instance can be used, false otherwise.
-
setTruncationLWM
public LogInstant setTruncationLWM(UUID name, LogInstant instant, RawStoreFactory rawStoreFactory, TransactionFactory transFactory) throws StandardException
- Throws:
StandardException
-
setTruncationLWM
public void setTruncationLWM(UUID name, LogInstant instant) throws StandardException
- Throws:
StandardException- functionality not implemented
-
removeTruncationLWM
public void removeTruncationLWM(UUID name, RawStoreFactory rawStoreFactory, TransactionFactory transFactory) throws StandardException
- Throws:
StandardException- functionality not implemented
-
getTruncationLWM
public LogInstant getTruncationLWM(UUID name) throws StandardException
- Throws:
StandardException- functionality not implemented
-
removeTruncationLWM
public void removeTruncationLWM(UUID name) throws StandardException
- Throws:
StandardException- functionality not implemented
-
openFlushedScan
public ScanHandle openFlushedScan(DatabaseInstant i, int groupsIWant) throws StandardException
Description copied from interface:LogFactoryGet a ScanHandle to scan flushed records from the log.MT- read only
- Specified by:
openFlushedScanin interfaceLogFactory- Parameters:
i- - 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- functionality not implemented
-
openForwardsScan
public LogScan openForwardsScan(LogInstant startAt, LogInstant stopAt) throws StandardException
Description copied from interface:LogFactoryGet a LogScan to scan the log in a forward direction.MT- read only
- Specified by:
openForwardsScanin interfaceLogFactory- 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- functionality not implemented
-
getFirstUnflushedInstant
public LogInstant getFirstUnflushedInstant()
Description copied from interface:LogFactoryGet the instant for the last record in the log.- Specified by:
getFirstUnflushedInstantin interfaceLogFactory
-
getFirstUnflushedInstantAsLong
public long getFirstUnflushedInstantAsLong()
Description copied from interface:LogFactoryGet 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.- Specified by:
getFirstUnflushedInstantAsLongin interfaceLogFactory- Returns:
- the log instant long value of the first log record that has not been flushed
-
openForwardsFlushedScan
public LogScan openForwardsFlushedScan(LogInstant startAt) throws StandardException
Description copied from interface:LogFactoryGet a LogScan to scan flushed records from the log.MT- read only
- Specified by:
openForwardsFlushedScanin interfaceLogFactory- 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- functionality not implemented
-
freezePersistentStore
public void freezePersistentStore() throws StandardExceptionBackup restore - stop sending log record to the log stream- Specified by:
freezePersistentStorein interfaceLogFactory- Throws:
StandardException- Standard Derby error policy
-
unfreezePersistentStore
public void unfreezePersistentStore() throws StandardExceptionBackup restore - start sending log record to the log stream- Specified by:
unfreezePersistentStorein interfaceLogFactory- Throws:
StandardException- Standard Derby error policy
-
logArchived
public boolean logArchived()
Backup restore - is the log being archived to some directory? if RawStore.LOG_ARCHIVAL_DIRECTORY is set to some value, that means the log is meant to be archived. Else, log not archived.- Specified by:
logArchivedin interfaceLogFactory- Returns:
- true if the log is being archived.
-
getLogFactoryProperties
public void getLogFactoryProperties(PersistentSet set)
Get JBMS properties relevant to the log factory- Specified by:
getLogFactoryPropertiesin interfaceLogFactory
-
getLogDirectory
public StorageFile getLogDirectory()
Description copied from interface:LogFactoryReturn the location of the log directory.- Specified by:
getLogDirectoryin interfaceLogFactory
-
getCanonicalLogPath
public java.lang.String getCanonicalLogPath()
Description copied from interface:LogFactoryReturn 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.- Specified by:
getCanonicalLogPathin interfaceLogFactory
-
enableLogArchiveMode
public void enableLogArchiveMode()
- Specified by:
enableLogArchiveModein interfaceLogFactory
-
disableLogArchiveMode
public void disableLogArchiveMode()
- Specified by:
disableLogArchiveModein interfaceLogFactory
-
deleteOnlineArchivedLogFiles
public void deleteOnlineArchivedLogFiles()
- Specified by:
deleteOnlineArchivedLogFilesin interfaceLogFactory
-
inRFR
public boolean inRFR()
- Specified by:
inRFRin interfaceLogFactory
-
checkpointInRFR
public void checkpointInRFR(LogInstant cinstant, long redoLWM, long undoLWM, DataFactory df) throws StandardException
Perform a checkpoint during rollforward recovery.- Specified by:
checkpointInRFRin interfaceLogFactory- 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
-
startLogBackup
public void startLogBackup(java.io.File toDir) throws StandardException- Specified by:
startLogBackupin interfaceLogFactory- Throws:
StandardException
-
endLogBackup
public void endLogBackup(java.io.File toDir) throws StandardException- Specified by:
endLogBackupin interfaceLogFactory- Throws:
StandardException
-
abortLogBackup
public void abortLogBackup()
- Specified by:
abortLogBackupin interfaceLogFactory
-
setDatabaseEncrypted
public void setDatabaseEncrypted(boolean isEncrypted, boolean flushLog)Sets whether the database is encrypted.Read-only database can not be re-encrypted, nothing to do in this case.
- Specified by:
setDatabaseEncryptedin interfaceLogFactory- Parameters:
isEncrypted-trueif the database is encrypted,falseif notflushLog-trueif log needs to be flushed,falseotherwise
-
startNewLogFile
public void startNewLogFile() throws StandardException- Specified by:
startNewLogFilein interfaceLogFactory- Throws:
StandardException
-
isCheckpointInLastLogFile
public boolean isCheckpointInLastLogFile() throws StandardException- Specified by:
isCheckpointInLastLogFilein interfaceLogFactory- Throws:
StandardException
-
deleteLogFileAfterCheckpointLogFile
public void deleteLogFileAfterCheckpointLogFile() throws StandardException- Specified by:
deleteLogFileAfterCheckpointLogFilein interfaceLogFactory- Throws:
StandardException
-
checkVersion
public boolean checkVersion(int requiredMajorVersion, int requiredMinorVersion, java.lang.String feature) throws StandardExceptionCheck to see if a database has been upgraded to the required level in order to use a store feature. This method is generally used to prevent writes to data/log file by a particular store feature until the database is upgraded to the required version. In read-only database writes are not allowed, so nothing to do for this method in this implementation of the log factory.- Specified by:
checkVersionin interfaceLogFactory- 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- not implemented exception is thrown
-
startReplicationMasterRole
public void startReplicationMasterRole(MasterFactory masterFactory) throws StandardException
Replication not applicable on readonly databases- Specified by:
startReplicationMasterRolein interfaceLogFactory- Parameters:
masterFactory- The MasterFactory service responsible for controlling the master side replication behaviour.- Throws:
StandardException- always thrown, indicating that ReadOnly databases can not be replicated
-
inReplicationMasterMode
public boolean inReplicationMasterMode()
Replication not applicable on readonly databases.- Specified by:
inReplicationMasterModein interfaceLogFactory- Returns:
- false always since replication is not applicable here.
-
stopReplicationMasterRole
public void stopReplicationMasterRole()
Replication not applicable on readonly databases- Specified by:
stopReplicationMasterRolein interfaceLogFactory
-
-