public class EngineWrapper extends 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
|
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(Runnable closeListener) |
void |
closeListenerUnregister(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.
|
public static final Engine CLOSED
protected EngineWrapper(Engine engine)
public long preallocate()
Engine
preallocate
in interface Engine
public void preallocate(long[] recids)
Engine
preallocate
in interface Engine
recids
- array to put result intopublic <A> long put(A value, Serializer<A> serializer)
Engine
public <A> A get(long recid, Serializer<A> serializer)
Engine
public <A> void update(long recid, A value, Serializer<A> serializer)
Engine
public <A> boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer)
Engine
oldValue==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 Engine
recid
- (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)
Engine
public void close()
Engine
NullPointerException
There is an configuration option DBMaker.closeOnJvmShutdown()
which uses shutdown hook to automatically
close Engine when JVM shutdowns.public boolean isClosed()
Engine
public void commit()
Engine
public void rollback()
Engine
UnsupportedOperationException
.public boolean isReadOnly()
Engine
isReadOnly
in interface Engine
public boolean canRollback()
canRollback
in interface Engine
public boolean canSnapshot()
canSnapshot
in interface Engine
public Engine snapshot() throws UnsupportedOperationException
Engine
snapshot
in interface Engine
UnsupportedOperationException
- if snapshots are not supported/enabledcanSnapshot()
public void clearCache()
Engine
clearCache
in interface Engine
public SerializerPojo getSerializerPojo()
Engine
getSerializerPojo
in interface Engine
public void closeListenerRegister(Runnable closeListener)
closeListenerRegister
in interface Engine
public void closeListenerUnregister(Runnable closeListener)
closeListenerUnregister
in interface Engine
public Engine getWrappedEngine()
protected static <V> V checkClosed(V v)
Copyright © 2018. All rights reserved.