java.lang.Object
org.apache.derbyTesting.functionTests.util.corruptio.CorruptBaseStorageFactory
org.apache.derbyTesting.functionTests.util.corruptio.CorruptDiskStorageFactory
- All Implemented Interfaces:
- org.apache.derby.io.StorageFactory, org.apache.derby.io.WritableStorageFactory
- public class CorruptDiskStorageFactory
- extends CorruptBaseStorageFactory
This class provides proxy implementation of the StorageFactory
interface for testing.
Storage Factory is used by the database engine to access
persistent data and transaction logs. By default all the method calls
delegate the work to the real disk storage factory
(org.apache.derby.impl.io.DirStorageFactory)
based on the classes in the java.io packgs. In some cases this factory
instruments some methods to corrupt the io to simulate disk corruptions for
testing. For example to simulate out of order partial writes to disk before
the crash.
Derby by default uses the storage factory implementation in
DirStorageFactory/DirStorageFactory4 when a database is accessed with
"jdbc:derby:". This factory can be specified instead using
derby.subSubProtocol. For example:
derby.subSubProtocol.csf=org.apache.derbyTesting.functionTests.
util.corruptio.CorruptDiskStorageFactory
database need to be accessed by specifying the subporotocol name like
'jdbc:derby:csf:wombat'.
Interaction between the tests that requires instrumenting the i/o and
this factory is through the flags in CorruptibleIo class. Tests should not
call the methods in this factory directly. Database engine invokes the
methods in this factory, so they can instrumented to do whatever is
required for testing.
- Version:
- 1.0
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
realStorageFactory
protected org.apache.derby.io.WritableStorageFactory realStorageFactory
CorruptDiskStorageFactory
public CorruptDiskStorageFactory()
getRealStorageFactory
org.apache.derby.io.WritableStorageFactory getRealStorageFactory()
- Description copied from class:
CorruptBaseStorageFactory
- get the real storage factory
- Specified by:
getRealStorageFactory in class CorruptBaseStorageFactory
init
public void init(java.lang.String home,
java.lang.String databaseName,
java.lang.String tempDirName,
java.lang.String uniqueName)
throws java.io.IOException
- Classes implementing the StorageFactory interface must have a null
constructor. This method is called when the database is booted up to
initialize the class. It should perform all actions necessary to start
the basic storage, such as creating a temporary file directory.
The init method will be called once, before any other method is called,
and will not be called again.
- Specified by:
init in interface org.apache.derby.io.StorageFactory
shutdown
public void shutdown()
- Description copied from interface:
org.apache.derby.io.StorageFactory
- The shutdown method is called during the normal shutdown of the database. However, the database
engine cannot guarantee that shutdown will be called. If the JVM terminates abnormally then it will
not be called.
- Specified by:
shutdown in interface org.apache.derby.io.StorageFactory
getCanonicalName
public java.lang.String getCanonicalName()
throws java.io.IOException
- Get the canonical name of the database.
This is a name that uniquely identifies it. It is system dependent.
The normal, disk based implementation uses method
java.io.File.getCanonicalPath on the directory holding the
database to construct the canonical name.
- Specified by:
getCanonicalName in interface org.apache.derby.io.StorageFactory
newStorageFile
public org.apache.derby.io.StorageFile newStorageFile(java.lang.String path)
- Construct a StorageFile from a path name.
- Specified by:
newStorageFile in interface org.apache.derby.io.StorageFactory
newStorageFile
public org.apache.derby.io.StorageFile newStorageFile(java.lang.String directoryName,
java.lang.String fileName)
- Construct a StorageFile from a directory and file name.
- Specified by:
newStorageFile in interface org.apache.derby.io.StorageFactory
newStorageFile
public org.apache.derby.io.StorageFile newStorageFile(org.apache.derby.io.StorageFile directoryName,
java.lang.String fileName)
- Construct a StorageFile from a directory and file name.
- Specified by:
newStorageFile in interface org.apache.derby.io.StorageFactory
getSeparator
public char getSeparator()
- Get the pathname separator character used by the StorageFile
implementation.
- Specified by:
getSeparator in interface org.apache.derby.io.StorageFactory
getTempDir
public org.apache.derby.io.StorageFile getTempDir()
- Get the abstract name of the directory that holds temporary files.
- Specified by:
getTempDir in interface org.apache.derby.io.StorageFactory
isFast
public boolean isFast()
- This method is used to determine whether the storage is fast
(RAM based) or slow (disk based).
It may be used by the database engine to determine the default size of
the page cache.
- Specified by:
isFast in interface org.apache.derby.io.StorageFactory
isReadOnlyDatabase
public boolean isReadOnlyDatabase()
- Description copied from interface:
org.apache.derby.io.StorageFactory
- Determine whether the database is read only. The database engine supports read-only databases, even
in file systems that are writable.
- Specified by:
isReadOnlyDatabase in interface org.apache.derby.io.StorageFactory
supportsRandomAccess
public boolean supportsRandomAccess()
- Determine whether the storage supports random access.
If random access is not supported then it will only be accessed using
InputStreams and OutputStreams (if the database is writable).
- Specified by:
supportsRandomAccess in interface org.apache.derby.io.StorageFactory
getStorageFactoryVersion
public int getStorageFactoryVersion()
- Specified by:
getStorageFactoryVersion in interface org.apache.derby.io.StorageFactory
sync
public void sync(java.io.OutputStream stream,
boolean metaData)
throws java.io.IOException,
java.io.SyncFailedException
- Force the data of an output stream out to the underlying storage.
That is, ensure that it has been made persistent. If the database is to
be transient, that is, if the database does not survive a restart, then
the sync method implementation need not do anything.
- Specified by:
sync in interface org.apache.derby.io.WritableStorageFactory
supportsRws
public boolean supportsRws()
- This method tests whether the "rws" and "rwd" modes are implemented.
If the "rws" method is supported then the database engine will conclude
that the write methods of "rws" mode StorageRandomAccessFiles are
slow but the sync method is fast and optimize accordingly.
- Specified by:
supportsRws in interface org.apache.derby.io.WritableStorageFactory