Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw

public final Class RawStore

extends Object
implements RawStoreFactory, ModuleControl, ModuleSupportable
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.monitor.ModuleSupportable, org.apache.derby.iapi.services.monitor.ModuleControl, org.apache.derby.iapi.store.raw.RawStoreFactory, org.apache.derby.iapi.store.raw.Corruptable
Imports
org.apache.derby.iapi.services.daemon.DaemonFactory, .DaemonService, org.apache.derby.iapi.services.context.ContextManager, .Context, .ContextService, org.apache.derby.iapi.services.crypto.CipherFactoryBuilder, .CipherFactory, .CipherProvider, org.apache.derby.iapi.services.locks.CompatibilitySpace, .LockFactory, org.apache.derby.iapi.services.monitor.Monitor, .ModuleControl, .ModuleFactory, .ModuleSupportable, .PersistentService, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.services.property.PersistentSet, org.apache.derby.iapi.store.access.TransactionInfo, .AccessFactoryGlobals, .FileResource, .DatabaseInstant, org.apache.derby.iapi.store.raw.ScanHandle, .RawStoreFactory, .Transaction, .UndoHandler, org.apache.derby.iapi.store.raw.xact.RawTransaction, .TransactionFactory, org.apache.derby.iapi.store.raw.data.DataFactory, org.apache.derby.iapi.store.raw.log.LogFactory, .LogInstant, org.apache.derby.iapi.util.StringUtil, org.apache.derby.impl.services.monitor.UpdateServiceProperties, org.apache.derby.io.StorageFactory, .WritableStorageFactory, .StorageFile, org.apache.derby.iapi.services.io.FileUtil, org.apache.derby.shared.common.reference.Attribute, .SQLState, .MessageId, .Property, java.util.Date, .Properties, java.io.Serializable, .File, .IOException, .OutputStreamWriter, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, java.security.SecureRandom, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.dictionary.DataDictionary, org.apache.derby.iapi.store.replication.master.MasterFactory, org.apache.derby.iapi.store.replication.slave.SlaveFactory

A Raw store that implements the RawStoreFactory module by delegating all the work to the lower modules TransactionFactory, LogFactory and DataFactory.
String TransactionFactoryId=

Class is final because it used to have methods with privilege blocks. See DERBY-7138.

Field Summary

Modifier and TypeField and Description
private 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
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
TEST_REENCRYPT_CRASH_BEFORE_COMMT

(re) encryption testing debug flags that are used to simulate error/crash conditions for testing purposes.

public static final String
protected TransactionFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
applyBulkCryptoOperation(Properties properties, CipherFactory newCipherFactory)

public void
backup(String
the name of the directory where the backup should be stored. This directory will be created if it does not exist.
backupDir
,
boolean
if true, waits for all the backup blocking operations in progress to finish.
wait
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.backup.

Backup the database to a backup directory.

public synchronized void
backup(Transaction t, File backupDir)

public void
backupAndEnableLogArchiveMode(String
the name of the directory where the backup should be stored. This directory will be created if it does not exist.
backupDir
,
boolean
If true deletes online archived log files that exist before this backup, delete will occur only after the backup is complete.
deleteOnlineArchivedLogFiles
,
boolean
if true, waits for all the backup blocking operations in progress to finish.
wait
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.backupAndEnableLogArchiveMode.

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.

public void
boot(boolean
True if the database should be created
create
,
Properties
Configuration properties
properties
)

Implements org.apache.derby.iapi.services.monitor.ModuleControl.boot.

Boot this module with the given properties.

private static Object
bootServiceModule(final boolean create, final Object serviceModule, final String factoryInterface, final Properties properties)

Must be private so that user code can't call this entry point.

public boolean
canSupport(Properties startParams)

Implements org.apache.derby.iapi.services.monitor.ModuleSupportable.canSupport.

We use this RawStore for all databases.

public Serializable
public void
public boolean

Returns:

true if the database has been upgraded to the required level, false otherwise.
checkVersion
(int
required database Engine major version
requiredMajorVersion
,
int
required database Engine minor version
requiredMinorVersion
,
String
Non-null to throw an exception, null to return the state of the version match.
feature
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.checkVersion.

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
createBackupDirectory(File
the directory to create
dir
)

Create a directory for backup.

public void
createDataWarningFile()

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.createDataWarningFile.

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.

public void
private void
cryptoOperationAllowed(boolean
true if the database is getting encrypted with a new password/key
reEncrypt
,
boolean
true if the database is getting decrypted
decrypt
)

checks if the database is in the right state to (re)encrypt it.

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

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.decrypt.

Decrypt cleartext from ciphertext.

public void
disableLogArchiveMode(boolean
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.
deleteOnlineArchivedLogFiles
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.disableLogArchiveMode.

disables the log archival process, i.e No old log files will be kept around for a roll-forward recovery.

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

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.encrypt.

Encrypt cleartext into ciphertext.

public void
failover(String
the replication database that is being failed over.
dbname
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.failover.

Start failover for this database.

private static Object
findServiceModule(final Object serviceModule, final String factoryInterface)

Must be private so that user code can't call this entry point.

public Transaction
findUserTransaction(ContextManager
the context manager to use. An exception will be thrown if context is not the current context.
contextMgr
,
String
If a new transaction is started, it will be given this name. The name is displayed in the transactiontable VTI.
transName
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.findUserTransaction.

Find a user transaction in the context manager, which must be the current context manager.

public void
freeze()

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.freeze.

Freeze the database temporarily so a backup can be taken.

public void
private static Context
getContextOrNull(final String contextID)

Must be private so that user code can't call this entry point.

private static ContextService
getContextService()

Private so that user code can't call this entry point.

public DaemonService
getDaemon()

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.getDaemon.

If this raw store has a daemon that services its need, return the daemon.

public String
public int
getEncryptionBlockSize()

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.getEncryptionBlockSize.

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

private String
private String
public LockFactory
getLockFactory()

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.getLockFactory.

Get the LockFactory to use with this store.

public String
public String
public long

Returns:

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

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.getMaxContainerId.

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

private static ModuleFactory
getMonitor()

Must be private so that user code can't call this entry point.

public void
private static String
getServiceName(final Object serviceModule)

Must be private so that user code can't call this entry point.

public String
public String
public TransactionInfo[]
public TransactionFactory
getXactFactory()

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.getXactFactory.

Get the Transaction Factory to use with this store.

public Object
public void
handleIncompleteDbCryptoOperation(Properties
properties related to this database.
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.

public void
idle()

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.idle.

Idle the raw store as much as possible.

public boolean
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 to true.

private void
public StandardException
markCorrupt(StandardException originalError)

Implements org.apache.derby.iapi.store.raw.Corruptable.markCorrupt.

Mark the module as corrupt.

public ScanHandle
openFlushedScan(DatabaseInstant
The instant for the beginning of the scan.
start
,
int
log record groups the caller wants to scan.
groupsIWant
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.openFlushedScan.

Get a flushed scan.

protected boolean
protected boolean
private synchronized boolean
privCopyDirectory(StorageFile from, File to, byte[] buffer, String[] filter, boolean copySubdirs)

private synchronized boolean
privCopyDirectory(File from, StorageFile to, byte[] buffer, String[] filter)

private synchronized boolean
private synchronized boolean
private synchronized boolean
private synchronized boolean
private synchronized boolean
private synchronized boolean
private synchronized boolean
privExists(final StorageFile file)

private synchronized OutputStreamWriter
privFileWriter(StorageFile fileName, boolean append)

private synchronized String
private synchronized String
private synchronized OutputStreamWriter
private synchronized boolean
private synchronized String[]
privList(final StorageFile file)

private synchronized boolean
private synchronized boolean
private synchronized boolean
privRenameTo(File file1, File file2)

public int
random()

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.random.

Returns a secure random number for this raw store - if database is not encrypted, returns 0.

private void
removeCryptoProperties(Properties
property set to remove from
properties
)

Removes properties related to encrypted databases.

private void
public final Object
run()

public void
setUndoInsertEventHandler(UndoHandler
Class to use to notify callers of an undo of an insert.
input_undo_handle
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.setUndoInsertEventHandler.

Register a handler class for insert undo events.

private boolean

Returns:

true if the existing data in the database should be transformed by applying a cryptographic operation.
setupEncryptionEngines
(boolean
whether a new database is being created, or if this is an existing database
create
,
Properties
database properties, including connection attributes
properties
)

Setup encryption engines according to the user properties and the current database state.

public Transaction
startGlobalTransaction(ContextManager
is the context manager to use. An exception will be thrown if context is not the current context.
contextMgr
,
int
the format id part of the Xid - ie. Xid.getFormatId().
format_id
,
byte[]
the global transaction identifier part of XID - ie. Xid.getGlobalTransactionId().
global_id
,
byte[]
The branch qualifier of the Xid - ie. Xid.getBranchQaulifier()
branch_id
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.startGlobalTransaction.

Create a global user transaction, almost all work within the raw store is performed in the context of a transaction.

public Transaction
public Transaction
startNestedReadOnlyUserTransaction(Transaction
parent transaction
parentTransaction
,
CompatibilitySpace
compatibility space to use for locks.
compatibilitySpace
,
ContextManager
is the context manager to use. An exception will be thrown if context is not the current context.
contextMgr
,
String
is the name of the transaction. This name will be displayed by the transactiontable VTI.
transName
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.startNestedReadOnlyUserTransaction.

Create a nested user transaction, almost all work within the raw store is performed in the context of a transaction.

public Transaction
startNestedUpdateUserTransaction(Transaction
parent transaction
parentTransaction
,
ContextManager
is the context manager to use. An exception will be thrown if context is not the current context.
contextMgr
,
String
is the name of the transaction. This name will be displayed by the transactiontable VTI.
transName
,
boolean
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.
flush_log_on_xact_end
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.startNestedUpdateUserTransaction.

Create a nested user transaction, almost all work within the raw store is performed in the context of a transaction.

public void
startReplicationMaster(String
The master database that is being replicated.
dbmaster
,
String
The hostname for the slave
host
,
int
The port the slave is listening on
port
,
String
The type of replication contract. Currently only asynchronous replication is supported, but 1-safe/2-safe/very-safe modes may be added later.
replicationMode
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.startReplicationMaster.

Start the replication master role for this database

private static Object
startSystemModule(final String factoryInterface)

Must be private so that user code can't call this entry point.

public Transaction
startTransaction(ContextManager
is the context manager to use. An exception will be thrown if context is not the current context.
contextMgr
,
String
is the name of the transaction. Thsi name will be displayed by the transactiontable VTI.
transName
)

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.startTransaction.

Create a user transaction, almost all work within the raw store is performed in the context of a transaction.

public void
public void
stopReplicationMaster()

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.stopReplicationMaster.

Stop the replication master role for this database.

public void
unfreeze()

Implements org.apache.derby.iapi.store.raw.RawStoreFactory.unfreeze.

Unfreeze the database after a backup has been taken.

public void
private IOException
wrapSE(Exception se)

Wrap a StandardException in an IOException to handle the signature of run()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait