|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.helidb.impl.AbstractDatabase<K,V,P>
org.helidb.impl.txn.AbstractTransactionalDatabase<K,V,P>
org.helidb.impl.txn.sc.ShadowCopyTransactionalDatabase<K,V,P>
K
- The type of the keys in the database.V
- The type of the values in the database.P
- The type of positions used by the
DatabaseBackend
to locate records.public class ShadowCopyTransactionalDatabase<K,V,P>
This transactional database frontend creates shadow copies of its database files for read/write transactions, and uses them to replace the original files when the transaction is committed. If the transaction is rolled back, the shadow copies are just deleted. In other words: joining a read/write transaction forces a copy of all database files.
The database implementation uses pessimistic read/write locking for preventing changes made in one transaction to disturb other transactions. This means that there can be several ongoing read only transactions against the same database at any time, but if a transaction wants to write to the database, it must have exclusive access to it and hold the database's write lock for the duration of the transaction.
ACID:ity is guaranteed in the following way:
In order to be able to create new DatabaseBackend
objects for the
shadow copy files, this class uses a DatabaseBackendFactory
instead
of just one DatabaseBackend
.
This database is thread safe.
The equals
and hashCode
methods are not implemented according
to the contract in Map
. See
AbstractTransactionalDatabase
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Constructor Summary | |
---|---|
ShadowCopyTransactionalDatabase(ShadowCopyTxnDatabaseFileManager fileManager,
DatabaseBackendFactory<K,V,P> dbf,
boolean autoCompact,
LogAdapterHolder lah)
Create a new database. |
Method Summary | |
---|---|
protected void |
cleanupBeforeReleasingReadLock()
This method is called to clean up the database state before releasing the read lock for a read only transaction. |
protected void |
closeBackend()
Subclasses implement this to call close on the backend. |
protected TransactionCollaborator<K,V,P> |
createReadOnlyCollaborator(Lock readLock)
Create a TransactionCollaborator for a read only transaction. |
protected TransactionCollaborator<K,V,P> |
createReadWriteCollaborator(Lock writeLock)
Create a TransactionCollaborator for a read/write transaction. |
Methods inherited from class org.helidb.impl.txn.AbstractTransactionalDatabase |
---|
close, closeWithWriteLockOnDb, equals, getBackendForReading, getBackendForWriting, getCloseObservable, getLock, hashCode, isClosed, joinTransaction |
Methods inherited from class org.helidb.impl.AbstractDatabase |
---|
assertNotClosed, clear, compact, containsKey, containsValue, delete, entrySet, fasterInsert, find, find, find, firstRecord, get, getLogAdapterHolder, insert, insertOrUpdate, isEmpty, iterator, keyIterator, keySet, lastRecord, put, putAll, remove, size, update, valueIterator, values |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.helidb.Database |
---|
compact, delete, fasterInsert, find, find, find, firstRecord, insert, insertOrUpdate, keyIterator, lastRecord, update, valueIterator |
Methods inherited from interface java.util.Map |
---|
clear, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from interface java.lang.Iterable |
---|
iterator |
Constructor Detail |
---|
public ShadowCopyTransactionalDatabase(ShadowCopyTxnDatabaseFileManager fileManager, DatabaseBackendFactory<K,V,P> dbf, boolean autoCompact, LogAdapterHolder lah)
fileManager
- A file manager for managing the database files. The
file manager must be one that works for the supplied
DatabaseBackendFactory
, for instance a
BPlusTreeIndexFileManager
for a
BPlusTreeIndexBackendFactory
.dbf
- A factory for creating
DatabaseBackend
objects.autoCompact
- Should the backend be compacted before every time that
a transaction is committed?lah
- A log adapter holder.Method Detail |
---|
protected void cleanupBeforeReleasingReadLock()
AbstractTransactionalDatabase
This method does nothing. Subclasses may override it.
cleanupBeforeReleasingReadLock
in class AbstractTransactionalDatabase<K,V,P>
protected TransactionCollaborator<K,V,P> createReadOnlyCollaborator(Lock readLock)
AbstractTransactionalDatabase
TransactionCollaborator
for a read only transaction.
createReadOnlyCollaborator
in class AbstractTransactionalDatabase<K,V,P>
readLock
- A locked, shared read lock for the database. The
collaborator is responsible for releasing this lock when it is committed
or rolled back.
protected TransactionCollaborator<K,V,P> createReadWriteCollaborator(Lock writeLock)
AbstractTransactionalDatabase
TransactionCollaborator
for a read/write transaction.
createReadWriteCollaborator
in class AbstractTransactionalDatabase<K,V,P>
writeLock
- A locked, exclusive write lock for the database. The
collaborator is responsible for releasing this lock when it is committed
or rolled back.
protected void closeBackend()
AbstractDatabase
close
on the backend. This is
called by AbstractDatabase.close()
.
closeBackend
in class AbstractDatabase<K,V,P>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |