org.apache.derby.iapi.store.raw.log
Interface LogFactory

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

public interface LogFactory
extends Corruptable


Field Summary
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 readonly
static 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
 boolean checkpoint(RawStoreFactory rawStoreFactory, DataFactory dataFactory, TransactionFactory transactionFactory, boolean wait)
          Checkpoint the rawstore.
 void checkpointInRFR(LogInstant cinstant, long redoLWM, DataFactory df)
          redoing a checkpoint during rollforward recovery
 boolean copyActiveLogFiles(java.io.File toDir)
           
 void deleteOnlineArchivedLogFiles()
           
 void disableLogArchiveMode()
           
 void enableLogArchiveMode()
           
 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 store
 java.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.
 StorageFile getLogDirectory()
          Return the location of the log directory.
 void getLogFactoryProperties(PersistentSet set)
          Get JBMS properties relavent to the log factory
 Logger getLogger()
           
 boolean inRFR()
           
 boolean logArchived()
          checks whether is log archive mode is enabled or not.
 ScanHandle openFlushedScan(DatabaseInstant start, 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(RawStoreFactory rawStoreFactory, DataFactory dataFactory, TransactionFactory transactionFactory)
          Recover the database to a consistent state using the log.
 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

public 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

public static final java.lang.String RT_READONLY
An attribute that indicates the database is readonly

See Also:
Constant Field Values

LOG_DIRECTORY_NAME

public static final java.lang.String LOG_DIRECTORY_NAME
The name of the default log directory.

See Also:
Constant Field Values

MODULE

public static final java.lang.String MODULE
See Also:
Constant Field Values
Method Detail

getLogger

public Logger getLogger()

recover

public void recover(RawStoreFactory rawStoreFactory,
                    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:
rawStoreFactory - - the raw store
dataFactory - - the data factory
transactionFactory - - the transaction factory
Throws:
StandardException - - encounter exception while recovering.

checkpoint

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 100K 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 LOG_SWITCH_INTERVAL, but user can set it to less if more frequent checkpoint is desired. The legal range of CHECKPOINT_INTERVAL is from 100K to LOG_SWITCH_INTERVAL.

Parameters:
rawStoreFactory - - the raw store
dataFactory - - the data factory
transactionFactory - - the transaction factory
wait - - if true; waits for the checkpoint to completed even if it is being done my an another thread.
Returns:
true if checkpoint is successful
Throws:
StandardException - - encounter exception while doing checkpoint.

flush

public 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

public 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 - StandardCloudscape error policy NOTE: This will be removed after the LogSniffer Rewrite.

openFlushedScan

public ScanHandle openFlushedScan(DatabaseInstant start,
                                  int groupsIWant)
                           throws StandardException
Get a ScanHandle to scan flushed records from the log.

MT- read only

Parameters:
groupsIWant - - log record groups the scanner wants.
Returns:
the LogScan.
Throws:
StandardException - StandardCloudscape error policy

openForwardsScan

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 - - 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 - StandardCloudscape error policy

getFirstUnflushedInstant

public LogInstant getFirstUnflushedInstant()
Get the instant for the last record in the log.


freezePersistentStore

public void freezePersistentStore()
                           throws StandardException
Stop making any change to the persistent store

Throws:
StandardException - Standard cloudscape exception policy.

unfreezePersistentStore

public void unfreezePersistentStore()
                             throws StandardException
Can start making change to the persistent store again

Throws:
StandardException - Standard cloudscape exception policy.

logArchived

public boolean logArchived()
checks whether is log archive mode is enabled or not.

Returns:
true if the log is being archived.

getLogFactoryProperties

public void getLogFactoryProperties(PersistentSet set)
                             throws StandardException
Get JBMS properties relavent to the log factory

Throws:
StandardException - Standard Cloudscape Error Policy

getLogDirectory

public StorageFile getLogDirectory()
                            throws StandardException
Return the location of the log directory.

Throws:
StandardException - Standard Cloudscape Error Policy

getCanonicalLogPath

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


copyActiveLogFiles

public boolean copyActiveLogFiles(java.io.File toDir)
                           throws StandardException
Throws:
StandardException

enableLogArchiveMode

public void enableLogArchiveMode()
                          throws StandardException
Throws:
StandardException

disableLogArchiveMode

public void disableLogArchiveMode()
                           throws StandardException
Throws:
StandardException

deleteOnlineArchivedLogFiles

public void deleteOnlineArchivedLogFiles()

inRFR

public boolean inRFR()

checkpointInRFR

public void checkpointInRFR(LogInstant cinstant,
                            long redoLWM,
                            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
Throws:
StandardException - - encounter exception during checkpoint


Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.