void testCdbLocking() {
Iterator readIterator;
Iterator writeIterator;
StoredKeySet set = (StoredKeySet) map.keySet();
// can open two CDB read cursors
readIterator = set.storedIterator(false);
try {
Iterator readIterator2 = set.storedIterator(false);
StoredIterator.close(readIterator2);
} finally {
StoredIterator.close(readIterator);
}
// can open two CDB write cursors
writeIterator = set.storedIterator(true);
try {
Iterator writeIterator2 = set.storedIterator(true);
StoredIterator.close(writeIterator2);
} finally {
StoredIterator.close(writeIterator);
}
// cannot open CDB write cursor when read cursor is open,
readIterator = set.storedIterator(false);
try {
writeIterator = set.storedIterator(true);
fail();
StoredIterator.close(writeIterator);
} catch (IllegalStateException e) {
} finally {
StoredIterator.close(readIterator);
}
if (index == null) {
// cannot put() with read cursor open
readIterator = set.storedIterator(false);
try {
map.put(makeKey(1), makeVal(1));
fail();
} catch (IllegalStateException e) {
} finally {
StoredIterator.close(readIterator);
}
// cannot append() with write cursor open with RECNO/QUEUE only
writeIterator = set.storedIterator(true);
try {
if (testStore.isQueueOrRecno()) {
try {
map.append(makeVal(1));
fail();