|
|||||||||
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.log.LoggingTransactionalDatabase<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 LoggingTransactionalDatabase<K,V,P>
This Database
implementation keeps a rollback log for
read/write transactions. If the transaction is rolled back the rollback log
is replayed to restore the database state. The rollback log is also used for
restoring the database state when a new database object is created after the
old one has crashed.
Read/write transactions hold an exclusive write lock on the entire database. Read only transactions hold a shared read lock that can be shared with other read only transactions.
Since the database uses its own locking, the database and log files should not be in a locking file system.
ACID:ity is guaranteed in the following way:
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 | |
---|---|
LoggingTransactionalDatabase(DatabaseBackend<K,V,P> backend,
ReadWritableFile logFile,
Serializer<K> keySerializer,
Serializer<V> valueSerializer,
LogAdapterHolder lah)
Constructor. |
Method Summary | |
---|---|
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 |
---|
cleanupBeforeReleasingReadLock, 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 LoggingTransactionalDatabase(DatabaseBackend<K,V,P> backend, ReadWritableFile logFile, Serializer<K> keySerializer, Serializer<V> valueSerializer, LogAdapterHolder lah)
The LoggingTransactionalDatabaseBuilder
may be more convenient to
use than this constructor.
backend
- The database backend.logFile
- The rollback log file. If it is not empty, it is replayed
to restore the database state.keySerializer
- Serializer for database keys.valueSerializer
- Serializer for database values.lah
- A log adapter holder.Method Detail |
---|
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 |