Interface DataFactory
- All Superinterfaces:
Corruptable
- All Known Implementing Classes:
BaseDataFileFactory
,BaseDataFileFactoryJ4
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionlong
addAndLoadStreamContainer
(RawTransaction t, long segmentId, Properties tableProperties, RowSource rowSource) Create and load a stream container.long
addContainer
(RawTransaction t, long segmentId, long containerid, int mode, Properties tableProperties, int temporaryFlag) Add a container.void
backupDataFiles
(Transaction rt, File backupDir) Back up the data segment of the database.void
void
Database creation finishedboolean
Returns if data base is in encrypted mode.int
decrypt
(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset) Decrypt cleartext from ciphertext.void
Decrypts all the containers in the data segment.void
dropContainer
(RawTransaction t, ContainerKey containerId) void
dropStreamContainer
(RawTransaction t, long segmentId, long containerId) Drop and remove a stream container.int
encrypt
(byte[] cleartext, int offset, int length, byte[] ciphertext, int outputOffset, boolean newEngine) Encrypt cleartext into ciphertext.void
Encrypt all the containers in the data segment.void
Backup restore - stop writing dirty pages or container to diskint
Return the encryption block size used by the algorithm at time of encrypted database creationGet an object to handle non-transactional files.Return the identifier that uniquely identifies this raw store at runtime.long
Return an id which can be used to create a container.Get the root directory of the data storage area.void
idle()
boolean
Is the store read-only.openContainer
(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode) Open a container that is not droped.openDroppedContainer
(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode) Open a container that may have been dropped.openStreamContainer
(RawTransaction t, long segmentId, long containerId, boolean hold) Open a stream container.void
Called after recovery is performed.int
reclaimSpace
(Serviceable work, ContextManager contextMgr) Reclaim space used by this factory.void
reCreateContainerForRedoRecovery
(RawTransaction t, long segmentId, long containerId, ByteArray containerInfo) re-Create a container during redo recovery.void
This function is called after a checkpoint to remove the stub files thar are not required during recovery.void
Removes old versions of the containers after a cryptographic operation on the database.void
Tell the data factory it is OK to remove committed deleted containers when the data factory shuts down.void
setDatabaseEncrypted
(boolean isEncrypted) Sets whether the database is encrypted.void
setRawStoreFactory
(RawStoreFactory rsf, boolean create, Properties properties) make data factory aware of which raw store factory it belongs to Also need to boot the LogFactoryvoid
setUndoInsertEventHandler
(UndoHandler undo_handle) Register a handler class for insert undo events.void
setupCacheCleaner
(DaemonService daemon) Set up the data factory's caches to use the specified daemon service for background cleaning.void
stop()
void
Backup restore - start writing dirty pages or container to diskvoid
Backup restore - write finished, if this is the last writer, allow the persistent store to proceed.void
Backup restore - don't allow the persistent store to be frozen - or if it is already frozen, block.Methods inherited from interface org.apache.derby.iapi.store.raw.Corruptable
markCorrupt
-
Field Details
-
MODULE
- See Also:
-
TEMP_SEGMENT_NAME
The temporary segment is called "tmp"- See Also:
-
DB_LOCKFILE_NAME
The database lock- See Also:
-
DB_EX_LOCKFILE_NAME
file name that is used to acquire exclusive lock on DB.- See Also:
-
-
Method Details
-
isReadOnly
boolean isReadOnly()Is the store read-only. -
openContainer
ContainerHandle openContainer(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode) throws StandardException Open a container that is not droped.- Parameters:
t
- the raw transaction that is opening the containercontainerId
- the container's identitylocking
- the locking policymode
- see the different mode in @see ContainerHandle then will return a null handle if the container is dropped.- Returns:
- the handle to the opened container
- Throws:
StandardException
- Standard Derby error policy
-
openDroppedContainer
RawContainerHandle openDroppedContainer(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode) throws StandardException Open a container that may have been dropped. Only internal raw store code should call this, e.g. recovery.- Throws:
StandardException
- Standard Derby error policy- See Also:
-
addContainer
long addContainer(RawTransaction t, long segmentId, long containerid, int mode, Properties tableProperties, int temporaryFlag) throws StandardException Add a container.- Parameters:
t
- the transaction that is creating the containersegmentId
- the segment where the container is to gomode
- whether or not to LOGGED or not. The effect of this mode is only for this addContainer call, not persisently stored throughout the lifetime of the containertableProperties
- properties of the container that is persistently stored throughout the lifetime of the container- Returns:
- the containerId of the newly created container
- Throws:
StandardException
- Standard Derby Error policy
-
addAndLoadStreamContainer
long addAndLoadStreamContainer(RawTransaction t, long segmentId, Properties tableProperties, RowSource rowSource) throws StandardException Create and load a stream container.- Parameters:
t
- the transaction that is creating the containersegmentId
- the segment where the container is to gotableProperties
- properties of the container that is persistently stored throughout the lifetime of the containerrowSource
- the data to load the container with- Returns:
- the containerId of the newly created stream container
- Throws:
StandardException
- Standard Derby Error policy
-
openStreamContainer
StreamContainerHandle openStreamContainer(RawTransaction t, long segmentId, long containerId, boolean hold) throws StandardException Open a stream container.- Returns:
- a valid StreamContainerHandle or null if the container does not exist.
- Throws:
StandardException
- Standard Derby exception policy
-
dropStreamContainer
void dropStreamContainer(RawTransaction t, long segmentId, long containerId) throws StandardException Drop and remove a stream container.- Throws:
StandardException
- Standard Derby exception policy
-
reCreateContainerForRedoRecovery
void reCreateContainerForRedoRecovery(RawTransaction t, long segmentId, long containerId, ByteArray containerInfo) throws StandardException re-Create a container during redo recovery. Used if container is found to not exist during redo recovery of log records creating the container.- Throws:
StandardException
- Standard Derby Error policy
-
dropContainer
- Throws:
StandardException
-
checkpoint
- Throws:
StandardException
-
idle
- Throws:
StandardException
-
getIdentifier
UUID getIdentifier()Return the identifier that uniquely identifies this raw store at runtime. This identifier is to be used as part of the lokcing key for objects locked in the raw store by value (e.g. Containers). -
setRawStoreFactory
void setRawStoreFactory(RawStoreFactory rsf, boolean create, Properties properties) throws StandardException make data factory aware of which raw store factory it belongs to Also need to boot the LogFactory- Throws:
StandardException
- cannot boot the log factory
-
createFinished
Database creation finished- Throws:
StandardException
- Standard Derby exception policy.
-
getFileHandler
FileResource getFileHandler()Get an object to handle non-transactional files. -
removeStubsOK
void removeStubsOK()Tell the data factory it is OK to remove committed deleted containers when the data factory shuts down. -
reclaimSpace
Reclaim space used by this factory. Called by post commit daemon.- Throws:
StandardException
- Standard Derby exception policy
-
postRecovery
Called after recovery is performed.- Throws:
StandardException
- Standard Derby Error Policy
-
setupCacheCleaner
Set up the data factory's caches to use the specified daemon service for background cleaning.- Parameters:
daemon
- daemon service to use for background cleaning
-
encrypt
int encrypt(byte[] cleartext, int offset, int length, byte[] ciphertext, int outputOffset, boolean newEngine) throws StandardException Encrypt cleartext into ciphertext.- Throws:
StandardException
- Standard Derby Error Policy- See Also:
-
decrypt
int decrypt(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset) throws StandardException Decrypt cleartext from ciphertext.- Throws:
StandardException
- Standard Derby Error Policy- See Also:
-
decryptAllContainers
Decrypts all the containers in the data segment.- Parameters:
t
- the transaction that is decrypting the container- Throws:
StandardException
- Standard Derby Error Policy
-
encryptAllContainers
Encrypt all the containers in the data segment.- Parameters:
t
- the transaction that is encrypting the containers.- Throws:
StandardException
- Standard Derby Error Policy
-
removeOldVersionOfContainers
Removes old versions of the containers after a cryptographic operation on the database.- Throws:
StandardException
-
setDatabaseEncrypted
void setDatabaseEncrypted(boolean isEncrypted) Sets whether the database is encrypted.- Parameters:
isEncrypted
-true
if the database is encrypted,false
otherwise
-
getEncryptionBlockSize
int getEncryptionBlockSize()Return the encryption block size used by the algorithm at time of encrypted database creation -
freezePersistentStore
Backup restore - stop writing dirty pages or container to disk- Throws:
StandardException
- Standard Derby error policy
-
unfreezePersistentStore
void unfreezePersistentStore()Backup restore - start writing dirty pages or container to disk -
writeInProgress
Backup restore - don't allow the persistent store to be frozen - or if it is already frozen, block. A write is about to commence.- Throws:
StandardException
- Standard Derby error policy
-
writeFinished
void writeFinished()Backup restore - write finished, if this is the last writer, allow the persistent store to proceed. -
backupDataFiles
Back up the data segment of the database.- Throws:
StandardException
-
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.
- Returns:
- The an id which can be used to create a container.
- Throws:
StandardException
- Standard exception policy.
-
removeDroppedContainerFileStubs
This function is called after a checkpoint to remove the stub files thar are not required during recovery. Crash recovery uses these files to identify the dropped containers. Stub files(d*.dat) gets creates when a table/index(containers) dropped.- Throws:
StandardException
- Standard Derby error policy
-
getStorageFactory
StorageFactory getStorageFactory()- Returns:
- The StorageFactory used by this dataFactory
-
getRootDirectory
String getRootDirectory()Get the root directory of the data storage area. It is always guaranteed to be an absolute path, and it is prefixed with the JDBC sub-sub-protocol if it is not a directory database. Examples:
/path/to/database
- in case of a directory database
memory:/path/to/database
- in case of a memory database
- Returns:
- the root directory of the data storage area
-
stop
void stop() -
databaseEncrypted
boolean databaseEncrypted()Returns if data base is in encrypted mode.- Returns:
- true if database encrypted false otherwise
-
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)
Currently the handler is only called on abort of inserts on non-overflow pages that meet either of the following 2 requirements: 1) the row has either overflow columns (long columns) or the row columns span multiple pages (long rows). 2) after the action all user rows on the page are marked deleted.
- Parameters:
undo_handle
- client code supplied undo_handle.
-