org.mapdb
Class EngineWrapper.CloseOnJVMShutdown
java.lang.Object
org.mapdb.EngineWrapper
org.mapdb.EngineWrapper.CloseOnJVMShutdown
- All Implemented Interfaces:
- Engine
- Enclosing class:
- EngineWrapper
public static class EngineWrapper.CloseOnJVMShutdown
- extends EngineWrapper
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.
|
Method Summary |
void |
close()
Close store/cache. |
| Methods inherited from class org.mapdb.EngineWrapper |
canRollback, canSnapshot, checkClosed, clearCache, closeListenerRegister, closeListenerUnregister, commit, compact, compareAndSwap, delete, get, getSerializerPojo, getWrappedEngine, isClosed, isReadOnly, preallocate, preallocate, put, rollback, snapshot, update |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
shutdownHappened
protected final AtomicBoolean shutdownHappened
EngineWrapper.CloseOnJVMShutdown
public EngineWrapper.CloseOnJVMShutdown(Engine engine)
close
public void close()
- Description copied from interface:
Engine
- Close store/cache. This method must be called before JVM exits to flush all caches and prevent store corruption.
Also it releases resources used by MapDB (disk, memory..).
Engine can no longer be used after this method was called. If Engine is used after closing, it may
throw any exception including
NullPointerException
There is an configuration option DBMaker.closeOnJvmShutdown() which uses shutdown hook to automatically
close Engine when JVM shutdowns.
- Specified by:
close in interface Engine- Overrides:
close in class EngineWrapper
Copyright © 2014. All Rights Reserved.