Class RawStore

  • All Implemented Interfaces:
    java.security.PrivilegedExceptionAction<java.lang.Object>, ModuleControl, ModuleSupportable, Corruptable, RawStoreFactory

    public final class RawStore
    extends java.lang.Object
    implements RawStoreFactory, ModuleControl, ModuleSupportable, java.security.PrivilegedExceptionAction<java.lang.Object>
    A Raw store that implements the RawStoreFactory module by delegating all the work to the lower modules TransactionFactory, LogFactory and DataFactory.
            String TransactionFactoryId=
            

    Class is final as it has methods with privilege blocks and implements PrivilegedExceptionAction.

    • Field Detail

      • random

        private java.security.SecureRandom random
      • isEncryptedDatabase

        private boolean isEncryptedDatabase
      • currentCipherFactory

        private CipherFactory currentCipherFactory
      • counter_encrypt

        private int counter_encrypt
      • counter_decrypt

        private int counter_decrypt
      • encryptionBlockSize

        private int encryptionBlockSize
      • actionCode

        private int actionCode
      • actionStorageFile

        private StorageFile actionStorageFile
      • actionToStorageFile

        private StorageFile actionToStorageFile
      • actionAppend

        private boolean actionAppend
      • REGULAR_FILE_EXISTS_ACTION

        private static final int REGULAR_FILE_EXISTS_ACTION
        See Also:
        Constant Field Values
      • actionRegularFile

        private java.io.File actionRegularFile
      • STORAGE_FILE_EXISTS_ACTION

        private static final int STORAGE_FILE_EXISTS_ACTION
        See Also:
        Constant Field Values
      • REGULAR_FILE_DELETE_ACTION

        private static final int REGULAR_FILE_DELETE_ACTION
        See Also:
        Constant Field Values
      • REGULAR_FILE_MKDIRS_ACTION

        private static final int REGULAR_FILE_MKDIRS_ACTION
        See Also:
        Constant Field Values
      • REGULAR_FILE_IS_DIRECTORY_ACTION

        private static final int REGULAR_FILE_IS_DIRECTORY_ACTION
        See Also:
        Constant Field Values
      • REGULAR_FILE_REMOVE_DIRECTORY_ACTION

        private static final int REGULAR_FILE_REMOVE_DIRECTORY_ACTION
        See Also:
        Constant Field Values
      • REGULAR_FILE_RENAME_TO_ACTION

        private static final int REGULAR_FILE_RENAME_TO_ACTION
        See Also:
        Constant Field Values
      • actionRegularFile2

        private java.io.File actionRegularFile2
      • COPY_STORAGE_DIRECTORY_TO_REGULAR_ACTION

        private static final int COPY_STORAGE_DIRECTORY_TO_REGULAR_ACTION
        See Also:
        Constant Field Values
      • actionBuffer

        private byte[] actionBuffer
      • actionFilter

        private java.lang.String[] actionFilter
      • actionCopySubDirs

        private boolean actionCopySubDirs
      • COPY_REGULAR_DIRECTORY_TO_STORAGE_ACTION

        private static final int COPY_REGULAR_DIRECTORY_TO_STORAGE_ACTION
        See Also:
        Constant Field Values
      • COPY_REGULAR_FILE_TO_STORAGE_ACTION

        private static final int COPY_REGULAR_FILE_TO_STORAGE_ACTION
        See Also:
        Constant Field Values
      • REGULAR_FILE_LIST_DIRECTORY_ACTION

        private static final int REGULAR_FILE_LIST_DIRECTORY_ACTION
        See Also:
        Constant Field Values
      • STORAGE_FILE_LIST_DIRECTORY_ACTION

        private static final int STORAGE_FILE_LIST_DIRECTORY_ACTION
        See Also:
        Constant Field Values
      • COPY_STORAGE_FILE_TO_REGULAR_ACTION

        private static final int COPY_STORAGE_FILE_TO_REGULAR_ACTION
        See Also:
        Constant Field Values
      • REGULAR_FILE_GET_CANONICALPATH_ACTION

        private static final int REGULAR_FILE_GET_CANONICALPATH_ACTION
        See Also:
        Constant Field Values
      • STORAGE_FILE_GET_CANONICALPATH_ACTION

        private static final int STORAGE_FILE_GET_CANONICALPATH_ACTION
        See Also:
        Constant Field Values
      • COPY_STORAGE_FILE_TO_STORAGE_ACTION

        private static final int COPY_STORAGE_FILE_TO_STORAGE_ACTION
        See Also:
        Constant Field Values
      • STORAGE_FILE_DELETE_ACTION

        private static final int STORAGE_FILE_DELETE_ACTION
        See Also:
        Constant Field Values
      • README_FILE_OUTPUTSTREAM_WRITER_ACTION

        private static final int README_FILE_OUTPUTSTREAM_WRITER_ACTION
        See Also:
        Constant Field Values
      • TEST_REENCRYPT_CRASH_BEFORE_COMMT

        public static final java.lang.String TEST_REENCRYPT_CRASH_BEFORE_COMMT
        (re) encryption testing debug flags that are used to simulate error/crash conditions for testing purposes. When any one of the following flags are set to true in the debug mode, re-encryption will fail at that point.
      • TEST_REENCRYPT_CRASH_AFTER_COMMT

        public static final java.lang.String TEST_REENCRYPT_CRASH_AFTER_COMMT
      • TEST_REENCRYPT_CRASH_AFTER_SWITCH_TO_NEWKEY

        public static final java.lang.String TEST_REENCRYPT_CRASH_AFTER_SWITCH_TO_NEWKEY
      • TEST_REENCRYPT_CRASH_AFTER_CHECKPOINT

        public static final java.lang.String TEST_REENCRYPT_CRASH_AFTER_CHECKPOINT
      • TEST_REENCRYPT_CRASH_AFTER_RECOVERY_UNDO_LOGFILE_DELETE

        public static final java.lang.String TEST_REENCRYPT_CRASH_AFTER_RECOVERY_UNDO_LOGFILE_DELETE
      • TEST_REENCRYPT_CRASH_AFTER_RECOVERY_UNDO_REVERTING_KEY

        public static final java.lang.String TEST_REENCRYPT_CRASH_AFTER_RECOVERY_UNDO_REVERTING_KEY
      • TEST_REENCRYPT_CRASH_BEFORE_RECOVERY_FINAL_CLEANUP

        public static final java.lang.String TEST_REENCRYPT_CRASH_BEFORE_RECOVERY_FINAL_CLEANUP
    • Constructor Detail

      • RawStore

        public RawStore()
    • Method Detail

      • canSupport

        public boolean canSupport​(java.util.Properties startParams)
        We use this RawStore for all databases.
        Specified by:
        canSupport in interface ModuleSupportable
        Returns:
        true if this instance can be used, false otherwise.
      • boot

        public void boot​(boolean create,
                         java.util.Properties properties)
                  throws StandardException
        Description copied from interface: ModuleControl
        Boot this module with the given properties. Creates a module instance that can be found using the findModule() methods of Monitor. The module can only be found using one of these findModule() methods once this method has returned.

        An implementation's boot method can throw StandardException. If it is thrown the module is not registered by the monitor and therefore cannot be found through a findModule(). In this case the module's stop() method is not called, thus throwing this exception must free up any resources.

        When create is true the contents of the properties object will be written to the service.properties of the persistent service. Thus any code that requires an entry in service.properties must explicitly place the value in this properties set using the put method.
        Typically the properties object contains one or more default properties sets, which are not written out to service.properties. These default sets are how callers modify the create process. In a JDBC connection database create the first set of defaults is a properties object that contains the attributes that were set on the jdbc:derby: URL. This attributes properties set has the second default properties set as its default. This set (which could be null) contains the properties that the user set on their DriverManager.getConnection() call, and are thus not owned by Derby code, and thus must not be modified by Derby code.

        When create is false the properties object contains all the properties set in the service.properties file plus a limited number of attributes from the JDBC URL attributes or connection properties set. This avoids properties set by the user compromising the boot process. An example of a property passed in from the JDBC world is the bootPassword for encrypted databases.

        Code should not hold onto the passed in properties reference after boot time as its contents may change underneath it. At least after the complete boot is completed, the links to all the default sets will be removed.

        Specified by:
        boot in interface ModuleControl
        Throws:
        StandardException - Module cannot be started.
        See Also:
        Monitor, ModuleFactory
      • stop

        public void stop()
        Description copied from interface: ModuleControl
        Stop the module. The module may be found via a findModule() method until some time after this method returns. Therefore the factory must be prepared to reject requests to it once it has been stopped. In addition other modules may cache a reference to the module and make requests of it after it has been stopped, these requests should be rejected as well.
        Specified by:
        stop in interface ModuleControl
        See Also:
        Monitor, ModuleFactory
      • setUndoInsertEventHandler

        public void setUndoInsertEventHandler​(UndoHandler input_undo_handle)
                                       throws StandardException
        Register a handler class for insert undo events.

        Register a class to be called when an undo of an insert is executed. When an undo of an event is executed by the raw store UndoHandler.insertUndoNotify() will be called, allowing upper level callers to execute code as necessary. The initial need is for the access layer to be able to queue post commit reclaim space in the case of inserts which are aborted (including the normal case of inserts failed for duplicate key violations) (see DERBY-4057)

        Specified by:
        setUndoInsertEventHandler in interface RawStoreFactory
        Parameters:
        input_undo_handle - Class to use to notify callers of an undo of an insert.
        Throws:
        StandardException - Standard exception policy.
      • startGlobalTransaction

        public Transaction startGlobalTransaction​(ContextManager contextMgr,
                                                  int format_id,
                                                  byte[] global_id,
                                                  byte[] branch_id)
                                           throws StandardException
        Description copied from interface: RawStoreFactory
        Create a global user transaction, almost all work within the raw store is performed in the context of a transaction.

        The (format_id, global_id, branch_id) triplet is meant to come exactly from a javax.transaction.xa.Xid. We don't use Xid so that the system can be delivered on a non-1.2 vm system and not require the javax classes in the path.

        Starting a transaction always performs the following steps.

        1. Create an raw store transaction context
        2. Create a new idle transaction and then link it to the context.
      Only one user transaction can be active in a context at any one time. After a commit the transaction may be re-used.

      Raw Store Transaction Context Behaviour
      The cleanupOnError() method of this context behaves as follows:

      • If error is an instance of StandardException that has a severity less than ExceptionSeverity.TRANSACTION_SEVERITY then no action is taken.
      • If error is an instance of StandardException that has a severity equal to ExceptionSeverity.TRANSACTION_SEVERITY then the context's transaction is aborted, and the transaction returned to the idle state.
      • If error is an instance of StandardException that has a severity greater than ExceptionSeverity.TRANSACTION_SEVERITY then the context's transaction is aborted, the transaction closed, and the context is popped off the stack.
      • If error is not an instance of StandardException then the context's transaction is aborted, the transaction closed, and the context is popped off the stack.
Specified by:
startGlobalTransaction in interface RawStoreFactory
Parameters:
contextMgr - is the context manager to use. An exception will be thrown if context is not the current context.
format_id - the format id part of the Xid - ie. Xid.getFormatId().
global_id - the global transaction identifier part of XID - ie. Xid.getGlobalTransactionId().
branch_id - The branch qualifier of the Xid - ie. Xid.getBranchQaulifier()
Throws:
StandardException - Standard Derby error policy
See Also:
Transaction, Context, StandardException
Only one user transaction and one nested user transaction can be active in a context at any one time. After a commit the transaction may be re-used.

Raw Store Transaction Context Behaviour
The cleanupOnError() method of this context behaves as follows:

Specified by:
startTransaction in interface RawStoreFactory
Parameters:
contextMgr - is the context manager to use. An exception will be thrown if context is not the current context.
transName - is the name of the transaction. Thsi name will be displayed by the transactiontable VTI.
Throws:
StandardException - Standard Derby error policy
See Also:
Transaction, Context, StandardException
Only one user transaction and one nested user transaction can be active in a context at any one time. After a commit the transaction may be re-used.

Raw Store Transaction Context Behaviour
The cleanupOnError() method of this context behaves as follows:

Specified by:
startNestedReadOnlyUserTransaction in interface RawStoreFactory
Parameters:
parentTransaction - parent transaction
compatibilitySpace - compatibility space to use for locks.
contextMgr - is the context manager to use. An exception will be thrown if context is not the current context.
transName - is the name of the transaction. This name will be displayed by the transactiontable VTI.
Throws:
StandardException - Standard Derby error policy
See Also:
Transaction, Context, StandardException
Only one user transaction and one nested user transaction can be active in a context at any one time. After a commit the transaction may be re-used.

Raw Store Transaction Context Behaviour
The cleanupOnError() method of this context behaves as follows:

Specified by:
startNestedUpdateUserTransaction in interface RawStoreFactory
Parameters:
parentTransaction - parent transaction
contextMgr - is the context manager to use. An exception will be thrown if context is not the current context.
transName - is the name of the transaction. This name will be displayed by the transactiontable VTI.
flush_log_on_xact_end - By default should the transaction commit and abort be synced to the log. Normal usage should pick true, unless there is specific performance need and usage works correctly if a commit can be lost on system crash.
Throws:
StandardException - Standard Derby error policy
See Also:
Transaction, Context, StandardException

AN internal transaction is identical to a user transaction with the exception that

Only one internal transaction can be active in a context at any one time. After a commit the transaction may be re-used.

Raw Store Internal Transaction Context Behaviour
The cleanupOnError() method of this context behaves as follows:

Specified by:
startInternalTransaction in interface RawStoreFactory
Throws:
StandardException - Standard Derby error policy
See Also:
Transaction, Context, StandardException