public class EngineWrapper extends java.lang.Object implements Engine
| Modifier and Type | Class and Description |
|---|---|
static class |
EngineWrapper.CloseOnJVMShutdown
Closes Engine on JVM shutdown using shutdown hook:
Runtime.addShutdownHook(Thread)
If engine was closed by user before JVM shutdown, hook is removed to save memory. |
static class |
EngineWrapper.ImmutabilityCheckEngine
check if Record Instances were not modified while in cache.
|
static class |
EngineWrapper.ReadOnlyEngine
Wraps an
Engine and throws
UnsupportedOperationException("Read-only")
on any modification attempt. |
static class |
EngineWrapper.SerializerCheckEngineWrapper
Checks that Serializer used to serialize item is the same as Serializer used to deserialize it
|
static class |
EngineWrapper.SynchronizedEngineWrapper
Engine wrapper with all methods synchronized on global lock, useful to diagnose concurrency issues.
|
| Modifier and Type | Field and Description |
|---|---|
static Engine |
CLOSED
throws `IllegalArgumentError("already closed)` on all access
|
private Engine |
engine |
CATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID| Modifier | Constructor and Description |
|---|---|
protected |
EngineWrapper(Engine engine) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRollback() |
boolean |
canSnapshot() |
protected static <V> V |
checkClosed(V v) |
void |
clearCache()
clears any underlying cache
|
void |
close()
Close store/cache.
|
void |
closeListenerRegister(java.lang.Runnable closeListener) |
void |
closeListenerUnregister(java.lang.Runnable closeListener) |
void |
commit()
Makes all changes made since the previous commit/rollback permanent.
|
void |
compact() |
<A> boolean |
compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
Updates existing record in atomic (Compare And Swap) manner.
|
<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.
|
SerializerPojo |
getSerializerPojo()
Returns default serializer associated with this engine.
|
Engine |
getWrappedEngine() |
boolean |
isClosed()
Checks whether Engine was closed.
|
boolean |
isReadOnly()
Check if you can write into this Engine.
|
long |
preallocate()
Preallocates recid for not yet created record.
|
void |
preallocate(long[] recids)
Preallocates recids for not yet created record.
|
<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.
|
<A> void |
update(long recid,
A value,
Serializer<A> serializer)
Update existing record with new value.
|
private Engine engine
public static final Engine CLOSED
protected EngineWrapper(Engine engine)
public long preallocate()
Enginepreallocate in interface Enginepublic void preallocate(long[] recids)
Enginepreallocate in interface Enginerecids - array to put result intopublic <A> long put(A value,
Serializer<A> serializer)
Enginepublic <A> A get(long recid,
Serializer<A> serializer)
Enginepublic <A> void update(long recid,
A value,
Serializer<A> serializer)
Enginepublic <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 Enginerecid - (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)
Enginepublic void close()
EngineNullPointerException
There is an configuration option DBMaker.closeOnJvmShutdown() which uses shutdown hook to automatically
close Engine when JVM shutdowns.public boolean isClosed()
Enginepublic void commit()
Enginepublic void rollback()
EngineUnsupportedOperationException.public boolean isReadOnly()
EngineisReadOnly in interface Enginepublic boolean canRollback()
canRollback in interface Enginepublic boolean canSnapshot()
canSnapshot in interface Enginepublic Engine snapshot() throws java.lang.UnsupportedOperationException
Enginesnapshot in interface Enginejava.lang.UnsupportedOperationException - if snapshots are not supported/enabledcanSnapshot()public void clearCache()
EngineclearCache in interface Enginepublic SerializerPojo getSerializerPojo()
EnginegetSerializerPojo in interface Enginepublic void closeListenerRegister(java.lang.Runnable closeListener)
closeListenerRegister in interface Enginepublic void closeListenerUnregister(java.lang.Runnable closeListener)
closeListenerUnregister in interface Enginepublic Engine getWrappedEngine()
protected static <V> V checkClosed(V v)