Top Fields Methods
org.apache.derby.iapi.store.raw.data

public Interface DataFactory

extends Corruptable
Known Direct Implementers
org.apache.derby.impl.store.raw.data.BaseDataFileFactory
Imports
org.apache.derby.iapi.store.raw.ContainerKey, .ContainerHandle, .Corruptable, .LockingPolicy, .RawStoreFactory, .StreamContainerHandle, .Transaction, .UndoHandler, org.apache.derby.iapi.services.daemon.DaemonService, .Serviceable, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.store.raw.xact.RawTransaction, org.apache.derby.io.StorageFactory, org.apache.derby.iapi.store.access.FileResource, .RowSource, org.apache.derby.iapi.store.raw.log.LogInstant, org.apache.derby.iapi.util.ByteArray, org.apache.derby.catalog.UUID, java.util.Properties, java.io.File

Field Summary

Modifier and TypeField and Description
public static final String
DB_EX_LOCKFILE_NAME

file name that is used to acquire exclusive lock on DB.

public static final String
DB_LOCKFILE_NAME

The database lock

public static final String
public static final String
TEMP_SEGMENT_NAME

The temporary segment is called "tmp"

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the containerId of the newly created stream container
addAndLoadStreamContainer
(RawTransaction
the transaction that is creating the container
t
,
long
the segment where the container is to go
segmentId
,
Properties
properties of the container that is persistently stored throughout the lifetime of the container
tableProperties
,
RowSource
the data to load the container with
rowSource
)

Create and load a stream container.

public long

Returns:

the containerId of the newly created container
addContainer
(RawTransaction
the transaction that is creating the container
t
,
long
the segment where the container is to go
segmentId
,
long containerid, int
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 container
mode
,
Properties
properties of the container that is persistently stored throughout the lifetime of the container
tableProperties
,
int temporaryFlag)

Add a container.

public void
backupDataFiles(Transaction rt, File backupDir)

Back up the data segment of the database.

public void
public void
createFinished()

Database creation finished

public boolean

Returns:

true if database encrypted false otherwise
databaseEncrypted
()

Returns if data base is in encrypted mode.

public int
decrypt(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset)

Decrypt cleartext from ciphertext.

public void
decryptAllContainers(RawTransaction
the transaction that is decrypting the container
t
)

Decrypts all the containers in the data segment.

public void
public void
dropStreamContainer(RawTransaction t, long segmentId, long containerId)

Drop and remove a stream container.

public int
encrypt(byte[] cleartext, int offset, int length, byte[] ciphertext, int outputOffset, boolean newEngine)

Encrypt cleartext into ciphertext.

public void
encryptAllContainers(RawTransaction
the transaction that is encrypting the containers.
t
)

Encrypt all the containers in the data segment.

public void
freezePersistentStore()

Backup restore - stop writing dirty pages or container to disk

public int
getEncryptionBlockSize()

Return the encryption block size used by the algorithm at time of encrypted database creation

public FileResource
getFileHandler()

Get an object to handle non-transactional files.

public UUID
getIdentifier()

Return the identifier that uniquely identifies this raw store at runtime.

public long

Returns:

The an id which can be used to create a container.
getMaxContainerId
()

Return an id which can be used to create a container.

public String

Returns:

the root directory of the data storage area
getRootDirectory
()

Get the root directory of the data storage area.

public StorageFactory

Returns:

The StorageFactory used by this dataFactory
getStorageFactory
()

public void
idle()

public boolean
isReadOnly()

Is the store read-only.

public ContainerHandle

Returns:

the handle to the opened container
openContainer
(RawTransaction
the raw transaction that is opening the container
t
,
ContainerKey
the container's identity
containerId
,
LockingPolicy
the locking policy
locking
,
int
see the different mode in @see ContainerHandle then will return a null handle if the container is dropped.
mode
)

Open a container that is not droped.

public RawContainerHandle
openDroppedContainer(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode)

Open a container that may have been dropped.

public StreamContainerHandle

Returns:

a valid StreamContainerHandle or null if the container does not exist.
openStreamContainer
(RawTransaction t, long segmentId, long containerId, boolean hold)

Open a stream container.

public void
postRecovery()

Called after recovery is performed.

public int
reclaimSpace(Serviceable work, ContextManager contextMgr)

Reclaim space used by this factory.

public void
reCreateContainerForRedoRecovery(RawTransaction t, long segmentId, long containerId, ByteArray containerInfo)

re-Create a container during redo recovery.

public void
removeDroppedContainerFileStubs(LogInstant redoLWM)

This function is called after a checkpoint to remove the stub files thar are not required during recovery.

public void
removeOldVersionOfContainers()

Removes old versions of the containers after a cryptographic operation on the database.

public void
removeStubsOK()

Tell the data factory it is OK to remove committed deleted containers when the data factory shuts down.

public void
setDatabaseEncrypted(boolean
true if the database is encrypted, false otherwise
isEncrypted
)

Sets whether the database is encrypted.

public 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 LogFactory

public void
setUndoInsertEventHandler(UndoHandler
client code supplied undo_handle.
undo_handle
)

Register a handler class for insert undo events.

public void
setupCacheCleaner(DaemonService
daemon service to use for background cleaning
daemon
)

Set up the data factory's caches to use the specified daemon service for background cleaning.

public void
stop()

public void
unfreezePersistentStore()

Backup restore - start writing dirty pages or container to disk

public void
writeFinished()

Backup restore - write finished, if this is the last writer, allow the persistent store to proceed.

public void
writeInProgress()

Backup restore - don't allow the persistent store to be frozen - or if it is already frozen, block.

Inherited from org.apache.derby.iapi.store.raw.Corruptable:
markCorrupt

Field Detail

DB_EX_LOCKFILE_NAMEback to summary
public static final String DB_EX_LOCKFILE_NAME

file name that is used to acquire exclusive lock on DB.

DB_LOCKFILE_NAMEback to summary
public static final String DB_LOCKFILE_NAME

The database lock

MODULEback to summary
public static final String MODULE
TEMP_SEGMENT_NAMEback to summary
public static final String TEMP_SEGMENT_NAME

The temporary segment is called "tmp"

Method Detail

addAndLoadStreamContainerback to summary
public long addAndLoadStreamContainer(RawTransaction t, long segmentId, Properties tableProperties, RowSource rowSource) throws StandardException

Create and load a stream container.

Parameters
t:RawTransaction

the transaction that is creating the container

segmentId:long

the segment where the container is to go

tableProperties:Properties

properties of the container that is persistently stored throughout the lifetime of the container

rowSource:RowSource

the data to load the container with

Returns:long

the containerId of the newly created stream container

Exceptions
StandardException:
Standard Derby Error policy
addContainerback to summary
public long addContainer(RawTransaction t, long segmentId, long containerid, int mode, Properties tableProperties, int temporaryFlag) throws StandardException

Add a container.

Parameters
t:RawTransaction

the transaction that is creating the container

segmentId:long

the segment where the container is to go

mode:int

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 container

tableProperties:Properties

properties of the container that is persistently stored throughout the lifetime of the container

Returns:long

the containerId of the newly created container

Exceptions
StandardException:
Standard Derby Error policy
backupDataFilesback to summary
public void backupDataFiles(Transaction rt, File backupDir) throws StandardException

Back up the data segment of the database.

checkpointback to summary
public void checkpoint() throws StandardException
createFinishedback to summary
public void createFinished() throws StandardException

Database creation finished

Exceptions
StandardException:
Standard Derby exception policy.
databaseEncryptedback to summary
public boolean databaseEncrypted()

Returns if data base is in encrypted mode.

Returns:boolean

true if database encrypted false otherwise

decryptback to summary
public int decrypt(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset) throws StandardException

Decrypt cleartext from ciphertext.

Exceptions
StandardException:
Standard Derby Error Policy
See Also
org.apache.derby.iapi.services.crypto.CipherProvider#decrypt
decryptAllContainersback to summary
public void decryptAllContainers(RawTransaction t) throws StandardException

Decrypts all the containers in the data segment.

Parameters
t:RawTransaction

the transaction that is decrypting the container

Exceptions
StandardException:
Standard Derby Error Policy
dropContainerback to summary
public void dropContainer(RawTransaction t, ContainerKey containerId) throws StandardException
dropStreamContainerback to summary
public void dropStreamContainer(RawTransaction t, long segmentId, long containerId) throws StandardException

Drop and remove a stream container.

Exceptions
StandardException:
Standard Derby exception policy
encryptback to summary
public int encrypt(byte[] cleartext, int offset, int length, byte[] ciphertext, int outputOffset, boolean newEngine) throws StandardException

Encrypt cleartext into ciphertext.

Exceptions
StandardException:
Standard Derby Error Policy
See Also
org.apache.derby.iapi.services.crypto.CipherProvider#encrypt
encryptAllContainersback to summary
public void encryptAllContainers(RawTransaction t) throws StandardException

Encrypt all the containers in the data segment.

Parameters
t:RawTransaction

the transaction that is encrypting the containers.

Exceptions
StandardException:
Standard Derby Error Policy
freezePersistentStoreback to summary
public void freezePersistentStore() throws StandardException

Backup restore - stop writing dirty pages or container to disk

Exceptions
StandardException:
Standard Derby error policy
getEncryptionBlockSizeback to summary
public int getEncryptionBlockSize()

Return the encryption block size used by the algorithm at time of encrypted database creation

getFileHandlerback to summary
public FileResource getFileHandler()

Get an object to handle non-transactional files.

getIdentifierback to summary
public 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).

getMaxContainerIdback to summary
public long getMaxContainerId() throws StandardException

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:long

The an id which can be used to create a container.

Exceptions
StandardException:
Standard exception policy.
getRootDirectoryback to summary
public 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:String

the root directory of the data storage area

getStorageFactoryback to summary
public StorageFactory getStorageFactory()
Returns:StorageFactory

The StorageFactory used by this dataFactory

idleback to summary
public void idle() throws StandardException
isReadOnlyback to summary
public boolean isReadOnly()

Is the store read-only.

openContainerback to summary
public ContainerHandle openContainer(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode) throws StandardException

Open a container that is not droped.

Parameters
t:RawTransaction

the raw transaction that is opening the container

containerId:ContainerKey

the container's identity

locking:LockingPolicy

the locking policy

mode:int

see the different mode in @see ContainerHandle then will return a null handle if the container is dropped.

Returns:ContainerHandle

the handle to the opened container

Exceptions
StandardException:
Standard Derby error policy
openDroppedContainerback to summary
public 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.

Exceptions
StandardException:
Standard Derby error policy
See Also
openContainer
openStreamContainerback to summary
public StreamContainerHandle openStreamContainer(RawTransaction t, long segmentId, long containerId, boolean hold) throws StandardException

Open a stream container.

Returns:StreamContainerHandle

a valid StreamContainerHandle or null if the container does not exist.

Exceptions
StandardException:
Standard Derby exception policy
postRecoveryback to summary
public void postRecovery() throws StandardException

Called after recovery is performed.

Exceptions
StandardException:
Standard Derby Error Policy
reclaimSpaceback to summary
public int reclaimSpace(Serviceable work, ContextManager contextMgr) throws StandardException

Reclaim space used by this factory. Called by post commit daemon.

Exceptions
StandardException:
Standard Derby exception policy
reCreateContainerForRedoRecoveryback to summary
public 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.

Exceptions
StandardException:
Standard Derby Error policy
removeDroppedContainerFileStubsback to summary
public void removeDroppedContainerFileStubs(LogInstant redoLWM) throws StandardException

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.

Exceptions
StandardException:
Standard Derby error policy
removeOldVersionOfContainersback to summary
public void removeOldVersionOfContainers() throws StandardException

Removes old versions of the containers after a cryptographic operation on the database.

removeStubsOKback to summary
public void removeStubsOK()

Tell the data factory it is OK to remove committed deleted containers when the data factory shuts down.

setDatabaseEncryptedback to summary
public void setDatabaseEncrypted(boolean isEncrypted)

Sets whether the database is encrypted.

Parameters
isEncrypted:boolean

true if the database is encrypted, false otherwise

setRawStoreFactoryback to summary
public 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

Exceptions
StandardException:
cannot boot the log factory
setUndoInsertEventHandlerback to summary
public void setUndoInsertEventHandler(UndoHandler undo_handle)

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:UndoHandler

client code supplied undo_handle.

setupCacheCleanerback to summary
public void setupCacheCleaner(DaemonService daemon)

Set up the data factory's caches to use the specified daemon service for background cleaning.

Parameters
daemon:DaemonService

daemon service to use for background cleaning

stopback to summary
public void stop()
unfreezePersistentStoreback to summary
public void unfreezePersistentStore()

Backup restore - start writing dirty pages or container to disk

writeFinishedback to summary
public void writeFinished()

Backup restore - write finished, if this is the last writer, allow the persistent store to proceed.

writeInProgressback to summary
public void writeInProgress() throws StandardException

Backup restore - don't allow the persistent store to be frozen - or if it is already frozen, block. A write is about to commence.

Exceptions
StandardException:
Standard Derby error policy