| java.lang.Object org.apache.derby.impl.store.raw.data.BaseDataFileFactory
BaseDataFileFactory | final public class BaseDataFileFactory implements DataFactory,CacheableFactory,ModuleControl,ModuleSupportable,PrivilegedExceptionAction(Code) | | Provides the abstract class with most of the implementation of DataFactory and
ModuleControl shared by all the different filesystem implementations.
RESOLVE (mikem - 2/19/98) -
Currently only getContainerClass() is abstract, there are probably more
routines which should be abstract. Also the other implementations should
probably inherit from the abstract class, rather than from the DataFileFactory
class. Also there probably should be a generic directory and the rest of the
filesystem implementations parallel to it.
I wanted to limit the changes going into the branch and then fix
inheritance stuff in main.
The code in this class was moved over from DataFileFactory.java and then
that file was made to inherit from this one.
|
Method Summary | |
public long | addAndLoadStreamContainer(RawTransaction t, long segmentId, Properties tableProperties, RowSource rowSource) | public long | addContainer(RawTransaction t, long segmentId, long input_containerid, int mode, Properties tableProperties, int temporaryFlag) Add a container with a specified page size to a segment. | public void | backupDataFiles(Transaction rt, File backupDir) | public void | boot(boolean create, Properties startParams) | public boolean | canSupport(Properties startParams) | public void | checkpoint() Implement checkpoint operation, write/sync all pages in cache.
The derby write ahead log algorithm uses checkpoint of the data
cache to determine points of the log no longer required by
restart recovery. | public void | createFinished() | final public boolean | databaseEncrypted() | public int | decrypt(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset) | public void | dropContainer(RawTransaction t, ContainerKey ckey) Drop a container.
Synchronisation
This call will mark the container as dropped and then obtain an CX lock
(table level exclusive lock) on the container. | public void | dropStreamContainer(RawTransaction t, long segmentId, long containerId) Drop a stream container. | public int | encrypt(byte[] cleartext, int offset, int length, byte[] ciphertext, int outputOffset, boolean newEngine) | public void | encryptAllContainers(RawTransaction t) | void | fileToRemove(StorageFile file, boolean remove) Add a file to the list of files to be removed post recovery. | void | flush(LogInstant instant) Ask the log factory to flush up to this log instant. | public void | freezePersistentStore() | public StorageFile | getAlternateContainerPath(ContainerKey containerId, boolean stub) Return an alternate path to container file relative to the root directory. | public long[] | getCacheStats(String cacheName) | CacheManager | getContainerCache() | synchronized String[] | getContainerNames() get all the names of the files in seg 0. | public StorageFile | getContainerPath(ContainerKey containerId, boolean stub) Return the path to a container file. | public int | getEncryptionBlockSize() | public FileResource | getFileHandler() | public UUID | getIdentifier() | public int | getIntParameter(String parameterName, Properties properties, int defaultValue, int minimumValue, int maximumValue) | LogFactory | getLogFactory() | public long | 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. | synchronized long | getNextId() | CacheManager | getPageCache() | RawStoreFactory | getRawStoreFactory() | public String | getRootDirectory() Get the root directory of the data storage area. | public StorageFactory | getStorageFactory() | synchronized StorageFile | getTempDirectory() | public String | getVersionedName(String name, long generationId) | public void | idle() | public boolean | isReadOnly() Is the store read-only. | public StandardException | markCorrupt(StandardException originalError) Really this is just a convience routine for callers that might not
have access to a log factory. | public Cacheable | newCacheable(CacheManager cm) | Cacheable | newContainerObject() Return the Class of the Containers to be produced by this factory.
Concrete implementations of a DataFactory must implement this routine
to indicate what kind of containers are produced. | public ContainerHandle | openContainer(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode) | public RawContainerHandle | openDroppedContainer(RawTransaction t, ContainerKey containerId, LockingPolicy locking, int mode) | public StreamContainerHandle | openStreamContainer(RawTransaction t, long segmentId, long containerId, boolean hold) | public void | postRecovery() Called after recovery is performed. | int | random() | public void | reCreateContainerForRedoRecovery(RawTransaction t, long segmentId, long containerId, ByteArray containerInfo) re-Create a container during redo recovery. | public int | reclaimSpace(Serviceable work, ContextManager contextMgr) | public void | removeDroppedContainerFileStubs(LogInstant redoLWM) Delete the stub files that are not required for recovery. | public void | removeOldVersionOfContainers(boolean inRecovery) | public void | removeStubsOK() | public void | resetCacheStats(String cacheName) | final public Object | run() | public void | setDatabaseEncrypted() | public void | setRawStoreFactory(RawStoreFactory rsf, boolean create, Properties startParams) | public void | stop() | public void | stubFileToRemoveAfterCheckPoint(StorageFile file, LogInstant logInstant, Object identity) keeps track of information about the stub files of the committed deleted
containers. | public void | unfreezePersistentStore() | public void | writeFinished() | public void | writeInProgress() |
dataNotSyncedAtAllocation | boolean dataNotSyncedAtAllocation(Code) | | |
dataNotSyncedAtCheckpoint | boolean dataNotSyncedAtCheckpoint(Code) | | |
BaseDataFileFactory | public BaseDataFileFactory()(Code) | | |
checkpoint | public void checkpoint() throws StandardException(Code) | | Implement checkpoint operation, write/sync all pages in cache.
The derby write ahead log algorithm uses checkpoint of the data
cache to determine points of the log no longer required by
restart recovery.
This implementation uses the 2 cache interfaces to force all dirty
pages to disk:
WRITE DIRTY PAGES TO OS:
In the first step all pages in the page cache
are written, but not synced (pagecache.cleanAll). The cachemanager
cleanAll() interface guarantees that every dirty page that exists
when this call is first made will have it's clean() method called.
The data cache (CachedPage.clean()), will call writePage but not
sync the page.
By using the java write then sync, the checkpoint is
usually doing async I/O, allowing the OS to schedule multiple I/O's
to the file as efficiently as it can.
Note that it has been observed that checkpoints
can flood the I/O system because these writes are not synced, see
DERBY-799 - checkpoint should probably somehow restrict the rate
it sends out those I/O's - it was observed a simple sleep every
N writes fixed most of the problem.
FORCE THOSE DIRTY WRITES TO DISK:
To force the I/O's to disk, the system calls each open dirty file
and uses the java interface to sync any outstanding dirty pages to
disk (containerCache.cleanAll()). The open container cache does
this work in RAFContainer.clean() by writing it's header out and
syncing the file. (Note if any change is made to checkpoint to
sync the writes vs. syncing the file, one probably still needs to
write the container header out and sync it).
exception: StandardException - Standard exception policy. |
databaseEncrypted | final public boolean databaseEncrypted()(Code) | | |
decrypt | public int decrypt(byte[] ciphertext, int offset, int length, byte[] cleartext, int outputOffset) throws StandardException(Code) | | |
dropContainer | public void dropContainer(RawTransaction t, ContainerKey ckey) throws StandardException(Code) | | Drop a container.
Synchronisation
This call will mark the container as dropped and then obtain an CX lock
(table level exclusive lock) on the container. Once a container has
been marked as dropped it cannot be retrieved by an openContainer()
call unless explicitly with droppedOK.
Once the exclusive lock has been obtained the container is removed
and all its pages deallocated. The container will be fully removed
at the commit time of the transaction.
exception: StandardException - Standard Cloudscape error policy |
dropStreamContainer | public void dropStreamContainer(RawTransaction t, long segmentId, long containerId) throws StandardException(Code) | | Drop a stream container.
Synchronisation
This call will remove the container.
exception: StandardException - Standard Cloudscape error policy |
encrypt | public int encrypt(byte[] cleartext, int offset, int length, byte[] ciphertext, int outputOffset, boolean newEngine) throws StandardException(Code) | | |
fileToRemove | void fileToRemove(StorageFile file, boolean remove)(Code) | | Add a file to the list of files to be removed post recovery.
|
getAlternateContainerPath | public StorageFile getAlternateContainerPath(ContainerKey containerId, boolean stub)(Code) | | Return an alternate path to container file relative to the root directory.
The alternate path uses upper case 'C','D', and 'DAT' instead of
lower case - there have been cases of people copying the database and
somehow upper casing all the file names.
The intended use is as a bug fix for track 3444.
Parameters: containerId - The container being opened/created Parameters: stub - True if the file name for the stub is requested, otherwise the file name for the data file |
getCacheStats | public long[] getCacheStats(String cacheName)(Code) | | |
getContainerNames | synchronized String[] getContainerNames()(Code) | | get all the names of the files in seg 0.
MT - This method needs to be synchronized to avoid conflicts
with other privileged actions execution in this class.
An array of all the file names in seg0. |
getContainerPath | public StorageFile getContainerPath(ContainerKey containerId, boolean stub)(Code) | | Return the path to a container file.
Return the path to a container file that is relative to the root
directory.
The format of the name of an existing container file is:
segNNN/cXXX.dat
The format of the name of a stub describing a dropped container file is:
segNNN/dXXX.dat
NNN = segment number, currently 0 is where normal db files are found.
XXX = The hex representation of the container number
The store will always create containers with this format name, but
the store will also recognize the following two formats when attempting
to open files - as some copy tools have uppercased our filesnames when
moving across operating systems:
The format of the name of an existing container file is:
segNNN/CXXX.DAT
The format of the name of a stub describing a dropped container file is:
segNNN/DXXX.DAT
Parameters: containerId - The container being opened/created Parameters: stub - True if the file name for the stub is requested, otherwise the file name for the data file The StorageFile representing path to container relative to root. |
getEncryptionBlockSize | public int getEncryptionBlockSize()(Code) | | Returns the encryption block size used by the algorithm at time of
creation of an encrypted database
|
getIntParameter | public int getIntParameter(String parameterName, Properties properties, int defaultValue, int minimumValue, int maximumValue)(Code) | | |
getMaxContainerId | public long getMaxContainerId() throws StandardException(Code) | | 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.
The an id which can be used to create a container. exception: StandardException - Standard exception policy. |
getNextId | synchronized long getNextId()(Code) | | |
getRootDirectory | public String getRootDirectory()(Code) | | Get the root directory of the data storage area. Is always guaranteed
to be an absolute path.
|
getStorageFactory | public StorageFactory getStorageFactory()(Code) | | The StorageFactory used by this dataFactory |
isReadOnly | public boolean isReadOnly()(Code) | | Is the store read-only.
|
newContainerObject | Cacheable newContainerObject()(Code) | | Return the Class of the Containers to be produced by this factory.
Concrete implementations of a DataFactory must implement this routine
to indicate what kind of containers are produced. For instance
the DataFileFactory produce RAFContainer's.
It is expected that this class is called only once, and thus does
not worry about the overhead of repeated Class.forName() lookups.
The Class object for the Container class. |
random | int random()(Code) | | return a secure random number
|
reCreateContainerForRedoRecovery | public void reCreateContainerForRedoRecovery(RawTransaction t, long segmentId, long containerId, ByteArray containerInfo) throws StandardException(Code) | | re-Create a container during redo recovery.
called ONLY during recovery load tran.
exception: StandardException - Standard Cloudscape Error policy |
removeDroppedContainerFileStubs | public void removeDroppedContainerFileStubs(LogInstant redoLWM) throws StandardException(Code) | | Delete the stub files that are not required for recovery. A stub file
is not required to be around if the recovery is not going to see
any log record that belongs to that container. Since the stub files
are created as a post commit operation, they are not necessary during
undo operation of the recovery.
To remove a stub file we have to be sure that it was created before the
redoLWM in the check point record. We can be sure that the stub is not
required if the log instant when it was created is less than the redoLWM.
|
removeOldVersionOfContainers | public void removeOldVersionOfContainers(boolean inRecovery) throws StandardException(Code) | | |
removeStubsOK | public void removeStubsOK()(Code) | | |
resetCacheStats | public void resetCacheStats(String cacheName)(Code) | | |
setDatabaseEncrypted | public void setDatabaseEncrypted()(Code) | | |
stubFileToRemoveAfterCheckPoint | public void stubFileToRemoveAfterCheckPoint(StorageFile file, LogInstant logInstant, Object identity)(Code) | | keeps track of information about the stub files of the committed deleted
containers. We use the info to delete them at checkpoints.
In addition to the file info , we also keep track of the identity of the
container; which helps to remove entry in the cache and the log instant
when the stub was created, which helps us to figure out whether we
require the stub file for the crash recovery.
We maintain the information in a hashtable:
key(LOG INSTANT) Values: File handle , and ContainerIdentity.
|
unfreezePersistentStore | public void unfreezePersistentStore()(Code) | | |
writeFinished | public void writeFinished()(Code) | | |
|
|