Class RawStore

java.lang.Object
org.apache.derby.impl.store.raw.RawStore
All Implemented Interfaces:
PrivilegedExceptionAction<Object>, ModuleControl, ModuleSupportable, Corruptable, RawStoreFactory

public final class RawStore extends Object implements RawStoreFactory, ModuleControl, ModuleSupportable, PrivilegedExceptionAction<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 Details

    • BACKUP_HISTORY

      private static final String BACKUP_HISTORY
      See Also:
    • xactFactory

      protected TransactionFactory xactFactory
    • dataFactory

      protected DataFactory dataFactory
    • logFactory

      protected LogFactory logFactory
    • slaveFactory

      private SlaveFactory slaveFactory
    • storageFactory

      private StorageFactory storageFactory
    • random

      private SecureRandom random
    • isEncryptedDatabase

      private boolean isEncryptedDatabase
    • encryptionEngine

      private CipherProvider encryptionEngine
    • decryptionEngine

      private CipherProvider decryptionEngine
    • newEncryptionEngine

      private CipherProvider newEncryptionEngine
    • newDecryptionEngine

      private CipherProvider newDecryptionEngine
    • currentCipherFactory

      private CipherFactory currentCipherFactory
    • newCipherFactory

      private CipherFactory newCipherFactory
    • counter_encrypt

      private int counter_encrypt
    • counter_decrypt

      private int counter_decrypt
    • encryptionBlockSize

      private int encryptionBlockSize
    • rawStoreDaemon

      protected DaemonService rawStoreDaemon
    • actionCode

      private int actionCode
    • FILE_WRITER_ACTION

      private static final int FILE_WRITER_ACTION
      See Also:
    • 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:
    • actionRegularFile

      private File actionRegularFile
    • STORAGE_FILE_EXISTS_ACTION

      private static final int STORAGE_FILE_EXISTS_ACTION
      See Also:
    • REGULAR_FILE_DELETE_ACTION

      private static final int REGULAR_FILE_DELETE_ACTION
      See Also:
    • REGULAR_FILE_MKDIRS_ACTION

      private static final int REGULAR_FILE_MKDIRS_ACTION
      See Also:
    • REGULAR_FILE_IS_DIRECTORY_ACTION

      private static final int REGULAR_FILE_IS_DIRECTORY_ACTION
      See Also:
    • REGULAR_FILE_REMOVE_DIRECTORY_ACTION

      private static final int REGULAR_FILE_REMOVE_DIRECTORY_ACTION
      See Also:
    • REGULAR_FILE_RENAME_TO_ACTION

      private static final int REGULAR_FILE_RENAME_TO_ACTION
      See Also:
    • actionRegularFile2

      private File actionRegularFile2
    • COPY_STORAGE_DIRECTORY_TO_REGULAR_ACTION

      private static final int COPY_STORAGE_DIRECTORY_TO_REGULAR_ACTION
      See Also:
    • actionBuffer

      private byte[] actionBuffer
    • actionFilter

      private String[] actionFilter
    • actionCopySubDirs

      private boolean actionCopySubDirs
    • COPY_REGULAR_DIRECTORY_TO_STORAGE_ACTION

      private static final int COPY_REGULAR_DIRECTORY_TO_STORAGE_ACTION
      See Also:
    • COPY_REGULAR_FILE_TO_STORAGE_ACTION

      private static final int COPY_REGULAR_FILE_TO_STORAGE_ACTION
      See Also:
    • REGULAR_FILE_LIST_DIRECTORY_ACTION

      private static final int REGULAR_FILE_LIST_DIRECTORY_ACTION
      See Also:
    • STORAGE_FILE_LIST_DIRECTORY_ACTION

      private static final int STORAGE_FILE_LIST_DIRECTORY_ACTION
      See Also:
    • COPY_STORAGE_FILE_TO_REGULAR_ACTION

      private static final int COPY_STORAGE_FILE_TO_REGULAR_ACTION
      See Also:
    • REGULAR_FILE_GET_CANONICALPATH_ACTION

      private static final int REGULAR_FILE_GET_CANONICALPATH_ACTION
      See Also:
    • STORAGE_FILE_GET_CANONICALPATH_ACTION

      private static final int STORAGE_FILE_GET_CANONICALPATH_ACTION
      See Also:
    • COPY_STORAGE_FILE_TO_STORAGE_ACTION

      private static final int COPY_STORAGE_FILE_TO_STORAGE_ACTION
      See Also:
    • STORAGE_FILE_DELETE_ACTION

      private static final int STORAGE_FILE_DELETE_ACTION
      See Also:
    • README_FILE_OUTPUTSTREAM_WRITER_ACTION

      private static final int README_FILE_OUTPUTSTREAM_WRITER_ACTION
      See Also:
    • TEST_REENCRYPT_CRASH_BEFORE_COMMT

      public static final 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 String TEST_REENCRYPT_CRASH_AFTER_COMMT
    • TEST_REENCRYPT_CRASH_AFTER_SWITCH_TO_NEWKEY

      public static final String TEST_REENCRYPT_CRASH_AFTER_SWITCH_TO_NEWKEY
    • TEST_REENCRYPT_CRASH_AFTER_CHECKPOINT

      public static final String TEST_REENCRYPT_CRASH_AFTER_CHECKPOINT
    • TEST_REENCRYPT_CRASH_AFTER_RECOVERY_UNDO_LOGFILE_DELETE

      public static final String TEST_REENCRYPT_CRASH_AFTER_RECOVERY_UNDO_LOGFILE_DELETE
    • TEST_REENCRYPT_CRASH_AFTER_RECOVERY_UNDO_REVERTING_KEY

      public static final String TEST_REENCRYPT_CRASH_AFTER_RECOVERY_UNDO_REVERTING_KEY
    • TEST_REENCRYPT_CRASH_BEFORE_RECOVERY_FINAL_CLEANUP

      public static final String TEST_REENCRYPT_CRASH_BEFORE_RECOVERY_FINAL_CLEANUP
  • Constructor Details

    • RawStore

      public RawStore()
  • Method Details

    • canSupport

      public boolean canSupport(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, 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:
    • 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:
    • isReadOnly

      public boolean isReadOnly()
      Is the store read-only.
      Specified by:
      isReadOnly in interface RawStoreFactory
      See Also:
    • getLockFactory

      public LockFactory getLockFactory()
      Description copied from interface: RawStoreFactory
      Get the LockFactory to use with this store.
      Specified by:
      getLockFactory in interface RawStoreFactory
    • getXactFactory

      public TransactionFactory getXactFactory()
      Get the Transaction Factory to use with this store.
      Specified by:
      getXactFactory in interface RawStoreFactory
    • 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.
    • getXAResourceManager

      public Object getXAResourceManager() throws StandardException
      Specified by:
      getXAResourceManager in interface RawStoreFactory
      Throws:
      StandardException
    • 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.