Integer.toString(N_ENTRIES));
CheckpointConfig forceCheckpoint = new CheckpointConfig();
forceCheckpoint.setForce(true);
XAEnvironment env = new XAEnvironment(homeDir, envConfig);
for (int i = 0; i < 2; i += 1) {
boolean transactional = (i == 0);
String dbName = transactional ? Utils.DB1_NAME : Utils.DB2_NAME;
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setTransactional(transactional);
dbConfig.setSortedDuplicates(true);
Database db = env.openDatabase(null, dbName, dbConfig);
Transaction txn = null;
if (transactional) {
txn = env.beginTransaction(null, null);
}
/* Write: {0, 0}, {0, 1}, {1, 0}, {2, 0}, {3, 0} */
for (int j = 0; j < N_ENTRIES; j += 1) {
db.put(txn, Utils.entry(j), Utils.entry(0));
}
db.put(txn, Utils.entry(0), Utils.entry(1));
/* Must checkpoint to generate BINDeltas. */
env.checkpoint(forceCheckpoint);
/* Delete everything but the last LN to cause IN deletion. */
for (int j = 0; j < N_ENTRIES - 1; j += 1) {
db.delete(txn, Utils.entry(j));
}
if (transactional) {
txn.abort();
}
db.close();
}
/* Compress to delete DBIN, DIN, BIN, IN. */
env.compress();
/* DB2 was not aborted and will contain: {3, 0} */
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(false);
dbConfig.setReadOnly(true);
dbConfig.setSortedDuplicates(true);
Database db = env.openDatabase(null, Utils.DB2_NAME, dbConfig);
Cursor cursor = db.openCursor(null, null);
try {
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
OperationStatus status = cursor.getFirst(key, data, null);
if (status != OperationStatus.SUCCESS) {
throw new Exception("Expected SUCCESS but got: " + status);
}
if (Utils.value(key) != 3 || Utils.value(data) != 0) {
throw new Exception("Expected {3,0} but got: {" +
Utils.value(key) + ',' +
Utils.value(data) + '}');
}
} finally {
cursor.close();
}
db.close();
XidImpl xid =
new XidImpl(1, "MakeLogEntryVersionData".getBytes(), null);
env.start(xid, XAResource.TMNOFLAGS);
env.prepare(xid);
env.rollback(xid);
env.close();
/*
* Get the set of all log entry types we expect to output. We punt on
* one type -- MapLN -- because it is only a slight variant of the
* transactional version and because cleaning would be necessary to