use of org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.CompoundKey in project qpid-broker-j by apache.
the class UpgradeFrom5To6Test method corruptDatabase.
/**
* modify the chunk offset of a message to be wrong, so we can test logic
* that preserves incomplete messages
*/
private void corruptDatabase() {
CursorOperation cursorOperation = new CursorOperation() {
@Override
public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
CompoundKeyBinding binding = new CompoundKeyBinding();
CompoundKey originalCompoundKey = binding.entryToObject(key);
int corruptedOffset = originalCompoundKey.getOffset() + 2;
CompoundKey corruptedCompoundKey = new CompoundKey(originalCompoundKey.getMessageId(), corruptedOffset);
DatabaseEntry newKey = new DatabaseEntry();
binding.objectToEntry(corruptedCompoundKey, newKey);
LOGGER.info("Deliberately corrupted message id " + originalCompoundKey.getMessageId() + ", changed offset from " + originalCompoundKey.getOffset() + " to " + corruptedCompoundKey.getOffset());
deleteCurrent();
sourceDatabase.put(transaction, newKey, value);
abort();
}
};
Transaction transaction = _environment.beginTransaction(null, null);
new DatabaseTemplate(_environment, OLD_CONTENT_DB_NAME, transaction).run(cursorOperation);
transaction.commit();
}
Aggregations