broker.sync(Sync.MAJOR_SYNC);
Txn txn = mgr.beginTransaction();
System.out.println("Transaction started ...");
BFile collectionsDb = (BFile) ((NativeBroker)broker).getStorage(NativeBroker.COLLECTIONS_DBX_ID);
BrokerPool.FORCE_CORRUPTION = true;
Value key = new Value("test".getBytes());
byte[] data = "_HELLO_YOU_".getBytes();
collectionsDb.put(txn, key, new FixedByteArray(data, 0, data.length), true);
for (int i = 1; i < 101; i++) {
String value = "_HELLO_" + i;
data = value.getBytes(UTF_8);
collectionsDb.append(txn, key, new FixedByteArray(data, 0, data.length));
}
mgr.commit(txn);
// start a new transaction that will not be committed and thus undone
txn = mgr.beginTransaction();
for (int i = 1001; i < 2001; i++) {
String value = "_HELLO_" + i;
data = value.getBytes(UTF_8);
collectionsDb.append(txn, key, new FixedByteArray(data, 0, data.length));
}
collectionsDb.remove(txn, key);
mgr.getJournal().flushToLog(true);
} catch (Exception e) {
fail(e.getMessage());