Class RawStore
- All Implemented Interfaces:
PrivilegedExceptionAction<Object>
,ModuleControl
,ModuleSupportable
,Corruptable
,RawStoreFactory
String TransactionFactoryId=
Class is final as it has methods with privilege blocks and implements PrivilegedExceptionAction.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private byte[]
private int
private boolean
private String[]
private File
private File
private StorageFile
private StorageFile
private static final String
private static final int
private static final int
private static final int
private static final int
private static final int
private int
private int
private CipherFactory
protected DataFactory
private CipherProvider
private int
private CipherProvider
private static final int
private boolean
protected LogFactory
private CipherFactory
private CipherProvider
private CipherProvider
private SecureRandom
protected DaemonService
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private SlaveFactory
private static final int
private static final int
private static final int
private static final int
private StorageFactory
static final String
static final String
static final String
static final String
static final String
static final String
(re) encryption testing debug flags that are used to simulate error/crash conditions for testing purposes.static final String
protected TransactionFactory
Fields inherited from interface org.apache.derby.iapi.store.raw.RawStoreFactory
CONTAINER_CACHE_SIZE_DEFAULT, CONTAINER_CACHE_SIZE_MAXIMUM, CONTAINER_CACHE_SIZE_MINIMUM, CONTAINER_CACHE_SIZE_PARAMETER, CONTAINER_INITIAL_PAGES, CRYPTO_OLD_EXTERNAL_KEY_VERIFY_FILE, DATA_ENCRYPT_ALGORITHM_VERSION, DB_ENCRYPTION_IN_CLEANUP, DB_ENCRYPTION_IN_PROGRESS, DB_ENCRYPTION_IN_UNDO, DB_ENCRYPTION_STATUS, DEFAULT_ENCRYPTION_BLOCKSIZE, DERBY_STORE_MAJOR_VERSION_10, DERBY_STORE_MINOR_VERSION_1, DERBY_STORE_MINOR_VERSION_10, DERBY_STORE_MINOR_VERSION_2, DERBY_STORE_MINOR_VERSION_3, DERBY_STORE_MINOR_VERSION_4, ENCRYPTED_KEY, ENCRYPTION_ALIGNMENT, ENCRYPTION_BLOCKSIZE, KEEP_TRANSACTION_LOG, LOG_ENCRYPT_ALGORITHM_VERSION, MAX_CONTAINER_INITIAL_PAGES, MINIMUM_RECORD_SIZE_DEFAULT, MINIMUM_RECORD_SIZE_MINIMUM, MINIMUM_RECORD_SIZE_PARAMETER, MODULE, OLD_ENCRYPTED_KEY, PAGE_CACHE_SIZE_DEFAULT, PAGE_CACHE_SIZE_MAXIMUM, PAGE_CACHE_SIZE_MINIMUM, PAGE_CACHE_SIZE_PARAMETER, PAGE_RESERVED_SPACE_PARAMETER, PAGE_RESERVED_ZERO_SPACE_STRING, PAGE_REUSABLE_RECORD_ID, PAGE_SIZE_DEFAULT, PAGE_SIZE_MINIMUM, PAGE_SIZE_STRING, PATCH_INITPAGE_RECOVER_ERROR, PRE_ALLOCATE_PAGE, STREAM_FILE_BUFFER_SIZE_DEFAULT, STREAM_FILE_BUFFER_SIZE_MAXIMUM, STREAM_FILE_BUFFER_SIZE_MINIMUM, STREAM_FILE_BUFFER_SIZE_PARAMETER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
applyBulkCryptoOperation
(Properties properties, CipherFactory newCipherFactory) void
Backup the database to a backup directory.void
backup
(Transaction t, File backupDir) void
backupAndEnableLogArchiveMode
(String backupDir, boolean deleteOnlineArchivedLogFiles, boolean wait) Backup the database to a backup directory and enable the log archive mode that will keep the archived log files required for roll-forward from this version backup.void
boot
(boolean create, Properties properties) Boot this module with the given properties.private static Object
bootServiceModule
(boolean create, Object serviceModule, String factoryInterface, Properties properties) Privileged startup.boolean
canSupport
(Properties startParams) We use this RawStore for all databases.changeBootPassword
(Properties properties, Serializable changePassword) Change the boot password.void
Checkpoint the database.boolean
checkVersion
(int requiredMajorVersion, int requiredMinorVersion, String feature) Check to see if a database has been upgraded to the required level in order to use a store feature.private void
crashOnDebugFlag
(String debugFlag, boolean reEncrypt) when the input debug flag is set, an expception is throw when run in the debug mode.private void
Create a directory for backup.void
Use the available storage factory handle to create a readme file in "seg0" directory warning users to not edit/delete any files in the directory to avoid database corruption.void
private void
cryptoOperationAllowed
(boolean reEncrypt, boolean decrypt) checks if the database is in the right state to (re)encrypt it.int
decrypt
(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset) Decrypt cleartext from ciphertext.void
disableLogArchiveMode
(boolean deleteOnlineArchivedLogFiles) disables the log archival process, i.e No old log files will be kept around for a roll-forward recovery.int
encrypt
(byte[] cleartext, int offset, int length, byte[] ciphertext, int outputOffset, boolean newEngine) Encrypt cleartext into ciphertext.void
Start failover for this database.private static Object
findServiceModule
(Object serviceModule, String factoryInterface) Privileged startup.findUserTransaction
(ContextManager contextMgr, String transName) Find a user transaction in the context manager, which must be the current context manager.void
freeze()
Freeze the database temporarily so a backup can be taken.void
Freeze persistent store.private static Context
getContextOrNull
(String contextID) Privileged lookup of a Context.private static ContextService
Privileged lookup of the ContextService.If this raw store has a daemon that services its need, return the daemon.int
Returns the encryption block size used by the algorithm at time of creation of an encrypted databaseprivate String
getFilePath
(File file) private String
getFilePath
(StorageFile file) Get the LockFactory to use with this store.long
Return an id which can be used to create a container.private static ModuleFactory
Privileged Monitor lookup.void
Get JBMS properties relevant to raw storeprivate static String
getServiceName
(Object serviceModule) Privileged service name lookup.Get the Transaction Factory to use with this store.void
handleIncompleteDbCryptoOperation
(Properties properties) Engine might have crashed during encryption of un-encrypted datbase or while re-encryptin an already encrypted database with a new key after all the containers or (re) encrypted.void
idle()
Idle the raw store as much as possible.boolean
Is the store read-only.private static boolean
isSet
(Properties p, String attribute) Tells if the attribute/property has been specified.private static boolean
isTrue
(Properties p, String attribute) Tells if the attribute/property has been set totrue
.private void
logHistory
(OutputStreamWriter historyFile, String msg) markCorrupt
(StandardException originalError) Mark the module as corrupt.openFlushedScan
(DatabaseInstant start, int groupsIWant) Get a flushed scan.protected boolean
privCopyDirectory
(File from, StorageFile to) private boolean
privCopyDirectory
(File from, StorageFile to, byte[] buffer, String[] filter) protected boolean
privCopyDirectory
(StorageFile from, File to) private boolean
privCopyDirectory
(StorageFile from, File to, byte[] buffer, String[] filter, boolean copySubdirs) private boolean
privCopyFile
(File from, StorageFile to) private boolean
privCopyFile
(StorageFile from, File to) private boolean
privCopyFile
(StorageFile from, StorageFile to) private boolean
privDelete
(File file) private boolean
privDelete
(StorageFile file) private boolean
privExists
(File file) private boolean
privExists
(StorageFile file) private OutputStreamWriter
privFileWriter
(StorageFile fileName, boolean append) private String
privGetCanonicalPath
(File file) private String
private OutputStreamWriter
private boolean
privIsDirectory
(File file) private String[]
privList
(StorageFile file) private boolean
privMkdirs
(File file) private boolean
privRemoveDirectory
(File file) private boolean
privRenameTo
(File file1, File file2) int
random()
Returns a secure random number for this raw store - if database is not encrypted, returns 0.private void
removeCryptoProperties
(Properties properties) Removes properties related to encrypted databases.private void
restoreRemainingFromBackup
(String backupPath) final Object
run()
void
setUndoInsertEventHandler
(UndoHandler input_undo_handle) Register a handler class for insert undo events.private boolean
setupEncryptionEngines
(boolean create, Properties properties) Setup encryption engines according to the user properties and the current database state.startGlobalTransaction
(ContextManager contextMgr, int format_id, byte[] global_id, byte[] branch_id) Create a global user transaction, almost all work within the raw store is performed in the context of a transaction.startInternalTransaction
(ContextManager contextMgr) Create an internal transaction.startNestedReadOnlyUserTransaction
(Transaction parentTransaction, CompatibilitySpace compatibilitySpace, ContextManager contextMgr, String transName) Create a nested user transaction, almost all work within the raw store is performed in the context of a transaction.startNestedUpdateUserTransaction
(Transaction parentTransaction, ContextManager contextMgr, String transName, boolean flush_log_on_xact_end) Create a nested user transaction, almost all work within the raw store is performed in the context of a transaction.void
startReplicationMaster
(String dbmaster, String host, int port, String replicationMode) Start the replication master role for this databaseprivate static Object
startSystemModule
(String factoryInterface) Privileged startup.startTransaction
(ContextManager contextMgr, String transName) Create a user transaction, almost all work within the raw store is performed in the context of a transaction.void
stop()
Stop the module.void
Stop the replication master role for this database.void
unfreeze()
Unfreeze the database after a backup has been taken.void
Freeze persistent store.
-
Field Details
-
BACKUP_HISTORY
- See Also:
-
xactFactory
-
dataFactory
-
logFactory
-
slaveFactory
-
storageFactory
-
random
-
isEncryptedDatabase
private boolean isEncryptedDatabase -
encryptionEngine
-
decryptionEngine
-
newEncryptionEngine
-
newDecryptionEngine
-
currentCipherFactory
-
newCipherFactory
-
counter_encrypt
private int counter_encrypt -
counter_decrypt
private int counter_decrypt -
encryptionBlockSize
private int encryptionBlockSize -
rawStoreDaemon
-
actionCode
private int actionCode -
FILE_WRITER_ACTION
private static final int FILE_WRITER_ACTION- See Also:
-
actionStorageFile
-
actionToStorageFile
-
actionAppend
private boolean actionAppend -
REGULAR_FILE_EXISTS_ACTION
private static final int REGULAR_FILE_EXISTS_ACTION- See Also:
-
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
-
COPY_STORAGE_DIRECTORY_TO_REGULAR_ACTION
private static final int COPY_STORAGE_DIRECTORY_TO_REGULAR_ACTION- See Also:
-
actionBuffer
private byte[] actionBuffer -
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
(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
-
TEST_REENCRYPT_CRASH_AFTER_SWITCH_TO_NEWKEY
-
TEST_REENCRYPT_CRASH_AFTER_CHECKPOINT
-
TEST_REENCRYPT_CRASH_AFTER_RECOVERY_UNDO_LOGFILE_DELETE
-
TEST_REENCRYPT_CRASH_AFTER_RECOVERY_UNDO_REVERTING_KEY
-
TEST_REENCRYPT_CRASH_BEFORE_RECOVERY_FINAL_CLEANUP
-
-
Constructor Details
-
RawStore
public RawStore()
-
-
Method Details
-
canSupport
We use this RawStore for all databases.- Specified by:
canSupport
in interfaceModuleSupportable
- Returns:
- true if this instance can be used, false otherwise.
-
boot
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 interfaceModuleControl
- 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 interfaceModuleControl
- See Also:
-
isReadOnly
public boolean isReadOnly()Is the store read-only.- Specified by:
isReadOnly
in interfaceRawStoreFactory
- See Also:
-
getLockFactory
Description copied from interface:RawStoreFactory
Get the LockFactory to use with this store.- Specified by:
getLockFactory
in interfaceRawStoreFactory
-
getXactFactory
Get the Transaction Factory to use with this store.- Specified by:
getXactFactory
in interfaceRawStoreFactory
-
setUndoInsertEventHandler
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 interfaceRawStoreFactory
- Parameters:
input_undo_handle
- Class to use to notify callers of an undo of an insert.- Throws:
StandardException
- Standard exception policy.
-
getXAResourceManager
- Specified by:
getXAResourceManager
in interfaceRawStoreFactory
- 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.
- Create an raw store transaction context
- 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 interfaceRawStoreFactory
- 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:
-
startTransaction
public Transaction startTransaction(ContextManager contextMgr, String transName) throws StandardException Description copied from interface:RawStoreFactory
Create a user transaction, almost all work within the raw store is performed in the context of a transaction.Starting a transaction always performs the following steps.
- Create an raw store transaction context
- Create a new idle transaction and then link it to the context.
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:- 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:
startTransaction
in interfaceRawStoreFactory
- 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:
-
startNestedReadOnlyUserTransaction
public Transaction startNestedReadOnlyUserTransaction(Transaction parentTransaction, CompatibilitySpace compatibilitySpace, ContextManager contextMgr, String transName) throws StandardException Description copied from interface:RawStoreFactory
Create a nested user transaction, almost all work within the raw store is performed in the context of a transaction.A nested user transaction is exactly the same as a user transaction, except that one can specify a compatibility space to associate with the transaction. Starting a transaction always performs the following steps.
- Create an raw store transaction context
- Create a new idle transaction and then link it to the context.
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:- 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 a user transaction exists on the context stack then that transaction is aborted also.
- 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:
startNestedReadOnlyUserTransaction
in interfaceRawStoreFactory
- Parameters:
parentTransaction
- parent transactioncompatibilitySpace
- 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:
-
startNestedUpdateUserTransaction
public Transaction startNestedUpdateUserTransaction(Transaction parentTransaction, ContextManager contextMgr, String transName, boolean flush_log_on_xact_end) throws StandardException Description copied from interface:RawStoreFactory
Create a nested user transaction, almost all work within the raw store is performed in the context of a transaction.A nested user transaction is exactly the same as a user transaction, except that one can specify a compatibility space to associate with the transaction. Starting a transaction always performs the following steps.
- Create an raw store transaction context
- Create a new idle transaction and then link it to the context.
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:- 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 a user transaction exists on the context stack then that transaction is aborted also.
- 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:
startNestedUpdateUserTransaction
in interfaceRawStoreFactory
- Parameters:
parentTransaction
- parent transactioncontextMgr
- 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:
-
findUserTransaction
public Transaction findUserTransaction(ContextManager contextMgr, String transName) throws StandardException Description copied from interface:RawStoreFactory
Find a user transaction in the context manager, which must be the current context manager. If a user transaction does not already exist, then create one @see #startTransaction- Specified by:
findUserTransaction
in interfaceRawStoreFactory
- Parameters:
contextMgr
- the context manager to use. An exception will be thrown if context is not the current context.transName
- If a new transaction is started, it will be given this name. The name is displayed in the transactiontable VTI.- Throws:
StandardException
- Standard Derby error policy- See Also:
-
startInternalTransaction
Description copied from interface:RawStoreFactory
Create an internal transaction.Starting an internal transaction always performs the following steps.
- Create an raw store internal transaction context
- Create a new idle internal transaction and then link it to the
context.
AN internal transaction is identical to a user transaction with the exception that
- Logical operations are not supported
- Savepoints are not supported
- Containers are not closed when commit() is called.
- Pages are not unlatched (since containers are not closed) when commit() is called.
- During recovery time internal transactions are rolled back before user transactions.
Raw Store Internal 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 the internal transaction is aborted, the internal transaction is closed, the context is popped off the stack, and an exception of severity Transaction exception is re-thrown.
- If error is an instance of StandardException that has a severity greater than or equal to ExceptionSeverity.TRANSACTION_SEVERITY then the context's internal transaction is aborted, the internal transaction is closed and the context is popped off the stack.
- If error is not an instance of StandardException then the context's internal transaction is aborted, the internal transaction is closed and the context is popped off the stack.
- Specified by:
startInternalTransaction
in interfaceRawStoreFactory
- Throws:
StandardException
- Standard Derby error policy- See Also:
-
checkpoint
Description copied from interface:RawStoreFactory
Checkpoint the database. The raw store will wait for any current checkpoints to complete. It will start a new checkpoint and not return until that checkpoint completes.- Specified by:
checkpoint
in interfaceRawStoreFactory
- Throws:
StandardException
- Standard Derby error policy
-
startReplicationMaster
public void startReplicationMaster(String dbmaster, String host, int port, String replicationMode) throws StandardException Start the replication master role for this database- Specified by:
startReplicationMaster
in interfaceRawStoreFactory
- Parameters:
dbmaster
- The master database that is being replicated.host
- The hostname for the slaveport
- The port the slave is listening onreplicationMode
- The type of replication contract. Currently only asynchronous replication is supported, but 1-safe/2-safe/very-safe modes may be added later.- Throws:
StandardException
- 1) If replication is started on a read-only database 2) If replication is started when unlogged operations are running 3) If an error occurs while trying to boot the master.
-
stopReplicationMaster
Stop the replication master role for this database.- Specified by:
stopReplicationMaster
in interfaceRawStoreFactory
- Throws:
StandardException
- Standard Derby exception policy, thrown on error.
-
failover
Description copied from interface:RawStoreFactory
Start failover for this database.- Specified by:
failover
in interfaceRawStoreFactory
- Parameters:
dbname
- the replication database that is being failed over.- Throws:
StandardException
- Standard Derby exception policy, 1) If the failover succeeds, an exception is thrown to indicate that the master database was shutdown after a successful failover 2) If a failure occurs during network communication with slave.
-
freeze
Description copied from interface:RawStoreFactory
Freeze the database temporarily so a backup can be taken.Please see Derby on line documentation on backup and restore.
- Specified by:
freeze
in interfaceRawStoreFactory
- Throws:
StandardException
- Thrown on error
-
unfreeze
Description copied from interface:RawStoreFactory
Unfreeze the database after a backup has been taken.Please see Derby on line documentation on backup and restore.
- Specified by:
unfreeze
in interfaceRawStoreFactory
- Throws:
StandardException
- Thrown on error
-
backup
Backup the database to a backup directory.- Specified by:
backup
in interfaceRawStoreFactory
- Parameters:
backupDir
- the name of the directory where the backup should be stored. This directory will be created if it does not exist.wait
- if true, waits for all the backup blocking operations in progress to finish.- Throws:
StandardException
- thrown on error
-
backup
- Throws:
StandardException
-
createBackupDirectory
Create a directory for backup.- Parameters:
dir
- the directory to create- Throws:
StandardException
- if the directory could not be created
-
backupAndEnableLogArchiveMode
public void backupAndEnableLogArchiveMode(String backupDir, boolean deleteOnlineArchivedLogFiles, boolean wait) throws StandardException Backup the database to a backup directory and enable the log archive mode that will keep the archived log files required for roll-forward from this version backup.- Specified by:
backupAndEnableLogArchiveMode
in interfaceRawStoreFactory
- Parameters:
backupDir
- the name of the directory where the backup should be stored. This directory will be created if it does not exist.deleteOnlineArchivedLogFiles
- If true deletes online archived log files that exist before this backup, delete will occur only after the backup is complete.wait
- if true, waits for all the backup blocking operations in progress to finish.- Throws:
StandardException
- thrown on error.
-
disableLogArchiveMode
Description copied from interface:RawStoreFactory
disables the log archival process, i.e No old log files will be kept around for a roll-forward recovery.- Specified by:
disableLogArchiveMode
in interfaceRawStoreFactory
- Parameters:
deleteOnlineArchivedLogFiles
- If true deletes all online archived log files that exist before this call immediately; Only restore that can be performed after disabling log archive mode is version recovery.- Throws:
StandardException
- Thrown on error
-
restoreRemainingFromBackup
- Throws:
StandardException
-
idle
Description copied from interface:RawStoreFactory
Idle the raw store as much as possible.- Specified by:
idle
in interfaceRawStoreFactory
- Throws:
StandardException
- Standard Derby error policy
-
getTransactionInfo
- Specified by:
getTransactionInfo
in interfaceRawStoreFactory
- See Also:
-
openFlushedScan
Description copied from interface:RawStoreFactory
Get a flushed scan.- Specified by:
openFlushedScan
in interfaceRawStoreFactory
- Parameters:
start
- The instant for the beginning of the scan.groupsIWant
- log record groups the caller wants to scan.- Throws:
StandardException
- StandardDerby error policy
-
getDaemon
Description copied from interface:RawStoreFactory
If this raw store has a daemon that services its need, return the daemon. If not, return null- Specified by:
getDaemon
in interfaceRawStoreFactory
-
createFinished
- Specified by:
createFinished
in interfaceRawStoreFactory
- Throws:
StandardException
-
getRawStoreProperties
Get JBMS properties relevant to raw store- Specified by:
getRawStoreProperties
in interfaceRawStoreFactory
- Throws:
StandardException
- Standard Derby Error Policy
-
freezePersistentStore
Freeze persistent store. Reads can still happen, only cannot write.- Specified by:
freezePersistentStore
in interfaceRawStoreFactory
- Throws:
StandardException
- Standard Derby Error Policy
-
unfreezePersistentStore
Freeze persistent store. Reads can still happen, only cannot write.- Specified by:
unfreezePersistentStore
in interfaceRawStoreFactory
- Throws:
StandardException
- Standard Derby Error Policy
-
setupEncryptionEngines
private boolean setupEncryptionEngines(boolean create, Properties properties) throws StandardException Setup encryption engines according to the user properties and the current database state.- Parameters:
create
- whether a new database is being created, or if this is an existing databaseproperties
- database properties, including connection attributes- Returns:
true
if the existing data in the database should be transformed by applying a cryptographic operation.- Throws:
StandardException
- if the properties are conflicting, if the requested configuration is denied, or if something else goes wrong
-
encrypt
public int encrypt(byte[] cleartext, int offset, int length, byte[] ciphertext, int outputOffset, boolean newEngine) throws StandardException Encrypt cleartext into ciphertext.- Specified by:
encrypt
in interfaceRawStoreFactory
- Throws:
StandardException
- Standard Derby Error Policy- See Also:
-
decrypt
public int decrypt(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset) throws StandardException Decrypt cleartext from ciphertext.- Specified by:
decrypt
in interfaceRawStoreFactory
- Throws:
StandardException
- Standard Derby Error Policy- See Also:
-
getEncryptionBlockSize
public int getEncryptionBlockSize()Returns the encryption block size used by the algorithm at time of creation of an encrypted database- Specified by:
getEncryptionBlockSize
in interfaceRawStoreFactory
-
random
public int random()Description copied from interface:RawStoreFactory
Returns a secure random number for this raw store - if database is not encrypted, returns 0.- Specified by:
random
in interfaceRawStoreFactory
-
changeBootPassword
public Serializable changeBootPassword(Properties properties, Serializable changePassword) throws StandardException Description copied from interface:RawStoreFactory
Change the boot password. Return the encrypted form of the secret key. The new value must be a String of the form: oldBootPassword, newBootPassword- Specified by:
changeBootPassword
in interfaceRawStoreFactory
- Throws:
StandardException
- Standard Derby Error Policy
-
crashOnDebugFlag
when the input debug flag is set, an expception is throw when run in the debug mode.- Throws:
StandardException
-
applyBulkCryptoOperation
private void applyBulkCryptoOperation(Properties properties, CipherFactory newCipherFactory) throws StandardException - Throws:
StandardException
-
handleIncompleteDbCryptoOperation
Engine might have crashed during encryption of un-encrypted datbase or while re-encryptin an already encrypted database with a new key after all the containers or (re) encrypted. If crash has occured before all containers are encrypted, recovery wil un-do re-encryption using the transaction log, nothing to be done here. If crash has occured after database encryption status flag (RawStoreFactory.DB_ENCRYPTION_STATUS) is set, this method will do any cleanup necessary for the recovery to correctly perform the rollback if required.- Parameters:
properties
- properties related to this database.- Throws:
StandardException
- Standard Derby Error Policy
-
cryptoOperationAllowed
checks if the database is in the right state to (re)encrypt it.- Parameters:
reEncrypt
-true
if the database is getting encrypted with a new password/keydecrypt
-true
if the database is getting decrypted- Throws:
StandardException
- if there is global transaction in the prepared state or if the database is not at the required version or above, this feature is not supported or if the log is archived for the database.
-
markCorrupt
Description copied from interface:Corruptable
Mark the module as corrupt. It is safe to call this multiple times.- Specified by:
markCorrupt
in interfaceCorruptable
- Returns:
- Must always return its parameter.
-
getTransactionFactoryModule
- Specified by:
getTransactionFactoryModule
in interfaceRawStoreFactory
-
getSlaveFactoryModule
-
getMasterFactoryModule
-
getDataFactoryModule
- Specified by:
getDataFactoryModule
in interfaceRawStoreFactory
-
getLogFactoryModule
- Specified by:
getLogFactoryModule
in interfaceRawStoreFactory
-
logHistory
- Throws:
IOException
-
getFilePath
-
getFilePath
-
privCopyDirectory
- Throws:
StandardException
-
privCopyDirectory
-
getMaxContainerId
Return an id which can be used to create a container.Return an id number with is greater than any existing container in the current database. Caller will use this to allocate future container numbers - most likely caching the value and then incrementing it as it is used.
- Specified by:
getMaxContainerId
in interfaceRawStoreFactory
- Returns:
- The an id which can be used to create a container.
- Throws:
StandardException
- Standard exception policy.
-
checkVersion
public 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.- Specified by:
checkVersion
in interfaceRawStoreFactory
- Parameters:
requiredMajorVersion
- required database Engine major versionrequiredMinorVersion
- required database Engine minor versionfeature
- 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 whenfeature
feature is notnull
.
-
removeCryptoProperties
Removes properties related to encrypted databases.- Parameters:
properties
- property set to remove from
-
privFileWriter
- Throws:
IOException
-
privExists
-
privExists
-
privGetOutputStreamWriter
- Throws:
IOException
-
privDelete
-
privDelete
-
privMkdirs
- Throws:
IOException
-
privIsDirectory
-
privRemoveDirectory
-
privRenameTo
-
privCopyDirectory
private boolean privCopyDirectory(StorageFile from, File to, byte[] buffer, String[] filter, boolean copySubdirs) throws StandardException - Throws:
StandardException
-
privCopyDirectory
-
privCopyFile
-
privCopyFile
- Throws:
StandardException
-
privCopyFile
-
privList
-
privGetCanonicalPath
-
privGetCanonicalPath
-
run
- Specified by:
run
in interfacePrivilegedExceptionAction<Object>
- Throws:
IOException
StandardException
-
isSet
Tells if the attribute/property has been specified. -
isTrue
Tells if the attribute/property has been set totrue
. -
createDataWarningFile
Description copied from interface:RawStoreFactory
Use the available storage factory handle to create a readme file in "seg0" directory warning users to not edit/delete any files in the directory to avoid database corruption.- Specified by:
createDataWarningFile
in interfaceRawStoreFactory
- Throws:
StandardException
- See Also:
-
getContextService
Privileged lookup of the ContextService. Private so that user code can't call this entry point. -
getContextOrNull
Privileged lookup of a Context. Must be private so that user code can't call this entry point. -
getMonitor
Privileged Monitor lookup. Must be private so that user code can't call this entry point. -
getServiceName
Privileged service name lookup. Must be private so that user code can't call this entry point. -
startSystemModule
Privileged startup. Must be private so that user code can't call this entry point.- Throws:
StandardException
-
bootServiceModule
private static Object bootServiceModule(boolean create, Object serviceModule, String factoryInterface, Properties properties) throws StandardException Privileged startup. Must be private so that user code can't call this entry point.- Throws:
StandardException
-
findServiceModule
private static Object findServiceModule(Object serviceModule, String factoryInterface) throws StandardException Privileged startup. Must be private so that user code can't call this entry point.- Throws:
StandardException
-