Class 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 Detail

      • logArchiveDirectory

        private java.lang.String logArchiveDirectory
    • Constructor Detail

      • ReadOnly

        public ReadOnly()
    • Method Detail

      • checkpoint

        public boolean checkpoint​(RawStoreFactory rawStoreFactory,
                                  DataFactory dataFactory,
                                  TransactionFactory transactionFactory,
                                  boolean wait)
        MT - not needed, no work is done
        Specified by:
        checkpoint in interface LogFactory
        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.
      • flush

        public void flush​(LogInstant where)
                   throws StandardException
        Description copied from interface: LogFactory
        Flush all unwritten log record up to the log instance indicated to disk.
        Specified by:
        flush in interface LogFactory
        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: ModuleSupportable
        See 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:
        canSupport in interface ModuleSupportable
        Returns:
        true if this instance can be used, false otherwise.
      • openFlushedScan

        public ScanHandle openFlushedScan​(DatabaseInstant i,
                                          int groupsIWant)
                                   throws StandardException
        Description copied from interface: LogFactory
        Get a ScanHandle to scan flushed records from the log.

        MT- read only

        Specified by:
        openFlushedScan in interface LogFactory
        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: LogFactory
        Get a LogScan to scan the log in a forward direction.

        MT- read only

        Specified by:
        openForwardsScan in interface LogFactory
        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
      • getFirstUnflushedInstantAsLong

        public long getFirstUnflushedInstantAsLong()
        Description copied from interface: LogFactory
        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.
        Specified by:
        getFirstUnflushedInstantAsLong in interface LogFactory
        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: LogFactory
        Get a LogScan to scan flushed records from the log.

        MT- read only

        Specified by:
        openForwardsFlushedScan in interface LogFactory
        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
      • 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:
        logArchived in interface LogFactory
        Returns:
        true if the log is being archived.
      • getCanonicalLogPath

        public java.lang.String getCanonicalLogPath()
        Description copied from interface: LogFactory
        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.
        Specified by:
        getCanonicalLogPath in interface LogFactory
      • inRFR

        public boolean inRFR()
        Specified by:
        inRFR in interface LogFactory
      • checkpointInRFR

        public void checkpointInRFR​(LogInstant cinstant,
                                    long redoLWM,
                                    long undoLWM,
                                    DataFactory df)
                             throws StandardException
        Perform a checkpoint during rollforward recovery.
        Specified by:
        checkpointInRFR in interface LogFactory
        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
      • 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:
        setDatabaseEncrypted in interface LogFactory
        Parameters:
        isEncrypted - true if the database is encrypted, false if not
        flushLog - true if log needs to be flushed, false otherwise
      • checkVersion

        public 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. 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:
        checkVersion in interface LogFactory
        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 - not implemented exception is thrown
      • startReplicationMasterRole

        public void startReplicationMasterRole​(MasterFactory masterFactory)
                                        throws StandardException
        Replication not applicable on readonly databases
        Specified by:
        startReplicationMasterRole in interface LogFactory
        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:
        inReplicationMasterMode in interface LogFactory
        Returns:
        false always since replication is not applicable here.
      • stopReplicationMasterRole

        public void stopReplicationMasterRole()
        Replication not applicable on readonly databases
        Specified by:
        stopReplicationMasterRole in interface LogFactory