dbConfig.setAllowCreate(true);
db = env.openDatabase(null, "foo", dbConfig);
LogManager logManager = envImpl.getLogManager();
long lsn;
Txn userTxn = new Txn(envImpl, new TransactionConfig());
long txnId = userTxn.getId();
for (int i = 0; i < numIters; i++) {
/* Add a debug record just to be filler. */
Tracer rec = new Tracer("Hello there, rec " + (i+1));
logManager.log(rec);
/* Make a transactional LN, we expect it to be there. */
byte [] data = new byte[i+1];
Arrays.fill(data, (byte)(i+1));
LN ln = new LN(data);
byte [] key = new byte[i+1];
Arrays.fill(key, (byte)(i+10));
/*
* Log an LN. If we're tracking LNs add it to the verification
* list.
*/
userTxn.lock
(ln.getNodeId(), LockType.WRITE,
DbInternal.dbGetDatabaseImpl(db));
lsn = ln.log(envImpl,
DbInternal.dbGetDatabaseImpl(db).getId(),
key,
DbLsn.NULL_LSN,
userTxn);
if (trackLNs) {
checkList.add(new CheckInfo(lsn, ln, key,
ln.getData(), txnId));
}
/* Log a deleted duplicate LN. */
LN deleteLN = new LN(data);
byte[] dupKey = new byte[i+1];
Arrays.fill(dupKey, (byte)(i+2));
userTxn.lock
(deleteLN.getNodeId(), LockType.WRITE,
DbInternal.dbGetDatabaseImpl(db));
lsn = deleteLN.delete(DbInternal.dbGetDatabaseImpl(db),
key,
dupKey,
DbLsn.NULL_LSN,
userTxn);
if (trackLNs) {
checkList.add(new CheckInfo(lsn, deleteLN,
dupKey, key, txnId));
}
/*
* Make a non-transactional ln. Shouldn't get picked up by reader.
*/
LN nonTxnalLN = new LN(data);
nonTxnalLN.log(envImpl,
DbInternal.dbGetDatabaseImpl(db).getId(),
key, DbLsn.NULL_LSN, null);
/* Add a MapLN. */
MapLN mapLN = new MapLN(DbInternal.dbGetDatabaseImpl(db));
userTxn.lock
(mapLN.getNodeId(), LockType.WRITE,
DbInternal.dbGetDatabaseImpl(db));
lsn = mapLN.log(envImpl,
DbInternal.dbGetDatabaseImpl(db).getId(),
key, DbLsn.NULL_LSN, userTxn);
if (!trackLNs) {
checkList.add(new CheckInfo(lsn, mapLN, key,
mapLN.getData(),
txnId));
}
}
long commitLsn = userTxn.commit(Txn.TXN_SYNC);
/* We only expect checkpoint entries to be read in redo passes. */
if (!redo) {
checkList.add(new CheckInfo(commitLsn, null, null, null, txnId));
}