Interface LogFactory

All Superinterfaces:
Corruptable
All Known Implementing Classes:
LogToFile, ReadOnly

public interface LogFactory extends Corruptable
  • Field Details

    • RUNTIME_ATTRIBUTES

      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.
      See Also:
    • RT_READONLY

      static final String RT_READONLY
      An attribute that indicates the database is readonly
      See Also:
    • LOG_DIRECTORY_NAME

      static final String LOG_DIRECTORY_NAME
      The name of the default log directory.
      See Also:
    • MODULE

      static final String MODULE
      See Also:
  • Method Details

    • 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 factory
      transactionFactory - - 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 store
      dataFactory - - the data factory
      transactionFactory - - the transaction factory
      wait - - 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

      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 checkpoint
      redoLWM - Redo Low Water Mark in the check point record
      undoLWM - Undo Low Water Mark in the checkpoint
      df - - the data factory
      Throws:
      StandardException - - encounter exception during checkpoint
    • startLogBackup

      void startLogBackup(File toDir) throws StandardException
      Throws:
      StandardException
    • endLogBackup

      void endLogBackup(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 not
      flushLog - 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, 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 version
      requiredMinorVersion - required database Engine minor version
      feature - 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 when feature feature is not null .
    • 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.