public class TxEngine extends EngineWrapper
| Modifier and Type | Class and Description |
|---|---|
class |
TxEngine.Tx |
EngineWrapper.CloseOnJVMShutdown, EngineWrapper.ImmutabilityCheckEngine, EngineWrapper.ReadOnlyEngine, EngineWrapper.SerializerCheckEngineWrapper, EngineWrapper.SynchronizedEngineWrapper| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.locks.ReentrantReadWriteLock |
commitLock |
protected boolean |
fullTx |
protected java.util.concurrent.locks.ReentrantReadWriteLock[] |
locks |
protected int |
PREALLOC_RECID_SIZE |
protected java.util.Queue<java.lang.Long> |
preallocRecids |
protected static java.lang.Object |
TOMBSTONE |
protected java.lang.ref.ReferenceQueue<TxEngine.Tx> |
txQueue |
protected java.util.Set<java.lang.ref.Reference<TxEngine.Tx>> |
txs |
protected boolean |
uncommitedData |
CLOSEDCATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID| Modifier | Constructor and Description |
|---|---|
protected |
TxEngine(Engine engine,
boolean fullTx) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canSnapshot() |
protected void |
cleanTxQueue() |
void |
close()
Close store/cache.
|
void |
commit()
Makes all changes made since the previous commit/rollback permanent.
|
<A> boolean |
compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
Updates existing record in atomic (Compare And Swap) manner.
|
static Engine |
createSnapshotFor(Engine engine) |
<A> void |
delete(long recid,
Serializer<A> serializer)
Remove existing record from store/cache
Recid must be a number returned by 'put' method.
|
<A> A |
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 java.lang.Long |
preallocRecidTake() |
<A> long |
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 <A> void |
superDelete(long recid,
Serializer<A> serializer) |
protected <A> A |
superGet(long recid,
Serializer<A> serializer) |
protected <A> void |
superUpdate(long recid,
A value,
Serializer<A> serializer) |
<A> void |
update(long recid,
A value,
Serializer<A> serializer)
Update existing record with new value.
|
canRollback, checkClosed, clearCache, closeListenerRegister, closeListenerUnregister, compact, getSerializerPojo, getWrappedEngine, isClosed, isReadOnlyprotected static final java.lang.Object TOMBSTONE
protected final java.util.concurrent.locks.ReentrantReadWriteLock commitLock
protected final java.util.concurrent.locks.ReentrantReadWriteLock[] locks
protected volatile boolean uncommitedData
protected java.util.Set<java.lang.ref.Reference<TxEngine.Tx>> txs
protected java.lang.ref.ReferenceQueue<TxEngine.Tx> txQueue
protected final boolean fullTx
protected final java.util.Queue<java.lang.Long> preallocRecids
protected final int PREALLOC_RECID_SIZE
protected TxEngine(Engine engine, boolean fullTx)
protected java.lang.Long preallocRecidTake()
public boolean canSnapshot()
canSnapshot in interface EnginecanSnapshot in class EngineWrapperpublic Engine snapshot()
Enginesnapshot in interface Enginesnapshot in class EngineWrapperEngineWrapper.canSnapshot()protected void cleanTxQueue()
public long preallocate()
Enginepreallocate in interface Enginepreallocate in class EngineWrapperpublic void preallocate(long[] recids)
Enginepreallocate in interface Enginepreallocate in class EngineWrapperrecids - array to put result intopublic <A> long put(A value,
Serializer<A> serializer)
Engineput in interface Engineput in class EngineWrappervalue - records to be addedserializer - used to convert record into/from binary formpublic <A> A get(long recid,
Serializer<A> serializer)
Engineget in interface Engineget in class EngineWrapperrecid - (record identifier) under which record was persistedserializer - used to deserialize record from binary formpublic <A> void update(long recid,
A value,
Serializer<A> serializer)
Engineupdate 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 formpublic <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 formpublic <A> void delete(long recid,
Serializer<A> serializer)
Enginedelete 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()
Enginecommit 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)