mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-28 20:47:49 +01:00
More lmdb logs
This commit is contained in:
@@ -67,12 +67,15 @@ public class LmdbObjectPersistentStore implements ObjectPersistentStore {
|
|||||||
Log.info("Initializing with root " + _root);
|
Log.info("Initializing with root " + _root);
|
||||||
_root.toFile().mkdirs();
|
_root.toFile().mkdirs();
|
||||||
}
|
}
|
||||||
|
Log.info("Opening LMDB with root " + _root);
|
||||||
_env = create()
|
_env = create()
|
||||||
.setMapSize(lmdbSize)
|
.setMapSize(lmdbSize)
|
||||||
.setMaxDbs(1)
|
.setMaxDbs(1)
|
||||||
.open(_root.toFile(), EnvFlags.MDB_NOTLS);
|
.open(_root.toFile(), EnvFlags.MDB_NOTLS);
|
||||||
_db = _env.openDbi(DB_NAME, MDB_CREATE);
|
_db = _env.openDbi(DB_NAME, MDB_CREATE);
|
||||||
|
|
||||||
|
Log.info("Opened LMDB with root " + _root);
|
||||||
|
|
||||||
try (Txn<ByteBuffer> txn = _env.txnWrite()) {
|
try (Txn<ByteBuffer> txn = _env.txnWrite()) {
|
||||||
var read = readTxId(txn);
|
var read = readTxId(txn);
|
||||||
if (read.isPresent()) {
|
if (read.isPresent()) {
|
||||||
@@ -87,6 +90,7 @@ public class LmdbObjectPersistentStore implements ObjectPersistentStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ready = true;
|
_ready = true;
|
||||||
|
Log.info("LMDB storage ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<Long> readTxId(Txn<ByteBuffer> txn) {
|
private Optional<Long> readTxId(Txn<ByteBuffer> txn) {
|
||||||
@@ -95,6 +99,9 @@ public class LmdbObjectPersistentStore implements ObjectPersistentStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void shutdown(@Observes @Priority(900) ShutdownEvent event) throws IOException {
|
void shutdown(@Observes @Priority(900) ShutdownEvent event) throws IOException {
|
||||||
|
if (!_ready) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_ready = false;
|
_ready = false;
|
||||||
_db.close();
|
_db.close();
|
||||||
_env.close();
|
_env.close();
|
||||||
@@ -112,6 +119,7 @@ public class LmdbObjectPersistentStore implements ObjectPersistentStore {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Snapshot<JObjectKey, ByteBuffer> getSnapshot() {
|
public Snapshot<JObjectKey, ByteBuffer> getSnapshot() {
|
||||||
|
verifyReady();
|
||||||
var txn = _env.txnRead();
|
var txn = _env.txnRead();
|
||||||
try {
|
try {
|
||||||
long commitId = readTxId(txn).orElseThrow();
|
long commitId = readTxId(txn).orElseThrow();
|
||||||
|
|||||||
Reference in New Issue
Block a user