|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mapdb.EngineWrapper
org.mapdb.TxEngine
public class TxEngine
Naive implementation of Snapshots on top of StorageEngine. On update it takes old value and stores it aside.
TODO merge snapshots down with Storage for best performance
| Nested Class Summary | |
|---|---|
class |
TxEngine.Tx
|
| Nested classes/interfaces inherited from class org.mapdb.EngineWrapper |
|---|
EngineWrapper.CloseOnJVMShutdown, EngineWrapper.ImmutabilityCheckEngine, EngineWrapper.ReadOnlyEngine, EngineWrapper.SerializerCheckEngineWrapper, EngineWrapper.SynchronizedEngineWrapper |
| Field Summary | |
|---|---|
protected ReentrantReadWriteLock |
commitLock
|
protected boolean |
fullTx
|
protected ReentrantReadWriteLock[] |
locks
|
protected int |
PREALLOC_RECID_SIZE
|
protected Queue<Long> |
preallocRecids
|
protected static Object |
TOMBSTONE
|
protected ReferenceQueue<TxEngine.Tx> |
txQueue
|
protected Set<Reference<TxEngine.Tx>> |
txs
|
protected boolean |
uncommitedData
|
| Fields inherited from class org.mapdb.EngineWrapper |
|---|
CLOSED |
| Fields inherited from interface org.mapdb.Engine |
|---|
CATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID |
| Constructor Summary | |
|---|---|
protected |
TxEngine(Engine engine,
boolean fullTx)
|
| Method Summary | ||
|---|---|---|
boolean |
canSnapshot()
|
|
protected void |
cleanTxQueue()
|
|
void |
close()
Close store/cache. |
|
void |
commit()
Makes all changes made since the previous commit/rollback permanent. |
|
|
compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
Updates existing record in atomic (Compare And Swap) manner. |
|
static Engine |
createSnapshotFor(Engine engine)
|
|
|
delete(long recid,
Serializer<A> serializer)
Remove existing record from store/cache Recid must be a number returned by 'put' method. |
|
|
get(long recid,
Serializer<A> serializer)
Get existing record. |
|
long |
preallocate()
Preallocates recid for not yet created record. |
|
void |
preallocate(long[] recids)
Preallocates recids for not yet created record. |
|
protected Long |
preallocRecidTake()
|
|
|
put(A value,
Serializer<A> serializer)
Insert new record. |
|
void |
rollback()
Undoes all changes made in the current transaction. |
|
Engine |
snapshot()
Returns read-only snapshot of data in Engine. |
|
protected void |
superCommit()
|
|
protected
|
superDelete(long recid,
Serializer<A> serializer)
|
|
protected
|
superGet(long recid,
Serializer<A> serializer)
|
|
protected
|
superUpdate(long recid,
A value,
Serializer<A> serializer)
|
|
|
update(long recid,
A value,
Serializer<A> serializer)
Update existing record with new value. |
|
| Methods inherited from class org.mapdb.EngineWrapper |
|---|
canRollback, checkClosed, clearCache, closeListenerRegister, closeListenerUnregister, compact, getSerializerPojo, getWrappedEngine, isClosed, isReadOnly |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Object TOMBSTONE
protected final ReentrantReadWriteLock commitLock
protected final ReentrantReadWriteLock[] locks
protected volatile boolean uncommitedData
protected Set<Reference<TxEngine.Tx>> txs
protected ReferenceQueue<TxEngine.Tx> txQueue
protected final boolean fullTx
protected final Queue<Long> preallocRecids
protected final int PREALLOC_RECID_SIZE
| Constructor Detail |
|---|
protected TxEngine(Engine engine,
boolean fullTx)
| Method Detail |
|---|
protected Long preallocRecidTake()
public static Engine createSnapshotFor(Engine engine)
public boolean canSnapshot()
canSnapshot in interface EnginecanSnapshot in class EngineWrapperpublic Engine snapshot()
Engine
snapshot in interface Enginesnapshot in class EngineWrapperEngineWrapper.canSnapshot()protected void cleanTxQueue()
public long preallocate()
Engine
preallocate in interface Enginepreallocate in class EngineWrapperpublic void preallocate(long[] recids)
Engine
preallocate in interface Enginepreallocate in class EngineWrapperrecids - array to put result into
public <A> long put(A value,
Serializer<A> serializer)
Engine
put in interface Engineput in class EngineWrappervalue - records to be addedserializer - used to convert record into/from binary form
public <A> A get(long recid,
Serializer<A> serializer)
Engine
get in interface Engineget in class EngineWrapperrecid - (record identifier) under which record was persistedserializer - used to deserialize record from binary form
public <A> void update(long recid,
A value,
Serializer<A> serializer)
Engine
update in interface Engineupdate in class EngineWrapperrecid - (record identifier) under which record was persisted.value - new record value to be storedserializer - used to serialize record into binary form
public <A> boolean compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
EngineoldValue==expectedOldValue when old value is found in instance cacheoldValue using serializer and checking oldValue.equals(expectedOldValue)expectedOldValue using serializer and comparing binary array with already serialized oldValue
compareAndSwap in interface EnginecompareAndSwap in class EngineWrapperrecid - (record identifier) under which record was persisted.expectedOldValue - old value to be compared with existing recordnewValue - to be written if values are matchingserializer - used to serialize record into binary form
public <A> void delete(long recid,
Serializer<A> serializer)
Engine
delete in interface Enginedelete in class EngineWrapperrecid - (record identifier) under which was record persistedserializer - which may be used in some circumstances to deserialize and store old objectpublic void close()
EngineNullPointerException
There is an configuration option DBMaker.closeOnJvmShutdown() which uses shutdown hook to automatically
close Engine when JVM shutdowns.
close in interface Engineclose in class EngineWrapperpublic void commit()
Engine
commit in interface Enginecommit in class EngineWrapperpublic void rollback()
EngineUnsupportedOperationException.
rollback in interface Enginerollback in class EngineWrapperprotected void superCommit()
protected <A> void superUpdate(long recid,
A value,
Serializer<A> serializer)
protected <A> void superDelete(long recid,
Serializer<A> serializer)
protected <A> A superGet(long recid,
Serializer<A> serializer)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||