use of org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer in project ignite by apache.
the class PageMemoryTracker method createWalManager.
/**
* Creates WAL manager.
*/
IgniteWriteAheadLogManager createWalManager() {
if (isEnabled()) {
return new FileWriteAheadLogManager(gridCtx) {
@Override
public WALPointer log(WALRecord record) throws IgniteCheckedException {
WALPointer res = super.log(record);
applyWalRecord(record);
return res;
}
@Override
public void resumeLogging(WALPointer lastPtr) throws IgniteCheckedException {
super.resumeLogging(lastPtr);
if (lastPtr == null)
emptyPds = true;
}
};
}
return null;
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer in project ignite by apache.
the class StandaloneWalRecordsIteratorTest method testNoNextIfLowBoundInTheEnd.
/**
*/
@Test
public void testNoNextIfLowBoundInTheEnd() throws Exception {
String dir = createWalFiles(3);
WALIterator iter = createWalIterator(dir, null, null, false);
assertFalse(iter.lastRead().isPresent());
assertTrue(iter.hasNext());
while (iter.hasNext()) {
IgniteBiTuple<WALPointer, WALRecord> curr = iter.next();
assertEquals("Last read should point to the current record", curr.get1(), iter.lastRead().get());
}
iter.close();
iter = createWalIterator(dir, iter.lastRead().get().next(), null, false);
assertFalse(iter.lastRead().isPresent());
assertFalse(iter.hasNext());
iter.close();
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer in project ignite by apache.
the class StandaloneWalRecordsIteratorTest method testNextRecordReturnedForLowBounds.
/**
*/
@Test
public void testNextRecordReturnedForLowBounds() throws Exception {
String dir = createWalFiles(3);
WALIterator iter = createWalIterator(dir, null, null, false);
IgniteBiTuple<WALPointer, WALRecord> prev = iter.next();
assertEquals("Last read should point to the current record", prev.get1(), iter.lastRead().get());
iter.close();
iter = createWalIterator(dir, iter.lastRead().get().next(), null, false);
assertFalse(iter.lastRead().isPresent());
assertTrue(iter.hasNext());
while (iter.hasNext()) {
IgniteBiTuple<WALPointer, WALRecord> cur = iter.next();
assertEquals("Last read should point to the current record", cur.get1(), iter.lastRead().get());
assertFalse("Should read next record[prev=" + prev.get1() + ", cur=" + cur.get1() + ']', prev.get1().equals(cur.get1()));
prev = cur;
iter.close();
iter = createWalIterator(dir, iter.lastRead().get().next(), null, false);
assertFalse(iter.lastRead().isPresent());
}
iter.close();
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer in project ignite by apache.
the class StandaloneWalRecordsIteratorTest method testLastRecordFiltered.
/**
*/
@Test
public void testLastRecordFiltered() throws Exception {
String dir = createWalFiles();
WALIterator iter = createWalIterator(dir, null, null, false);
IgniteBiTuple<WALPointer, WALRecord> lastRec = null;
// Search for the last record.
while (iter.hasNext()) lastRec = iter.next();
iter.close();
assertNotNull(lastRec);
WALPointer lastPointer = iter.lastRead().get();
WALRecord.RecordType lastRecType = lastRec.get2().type();
// Iterating and filter out last record.
iter = createWalIterator(dir, null, null, false, (type, ptr) -> type != lastRecType);
assertTrue(iter.hasNext());
while (iter.hasNext()) {
lastRec = iter.next();
// Type is null for filtered records.
assertNotNull(lastRec.get2().type());
assertTrue(lastRec.get2().type() != lastRecType);
}
iter.close();
assertNotNull(lastRec);
assertEquals("LastRead should point to the last WAL Record even it filtered", lastPointer, iter.lastRead().get());
// Record on `lastPointer` is filtered so.
assertEquals("Last returned record should be before lastPointer", -1, lastRec.get1().compareTo(lastPointer));
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer in project ignite by apache.
the class StandaloneWalRecordsIteratorTest method testStrictBounds.
/**
* Check correct check bounds.
*
* @throws Exception if test failed.
*/
@Test
public void testStrictBounds() throws Exception {
String dir = createWalFiles();
WALPointer lowBound = null, highBound = null;
for (IgniteBiTuple<WALPointer, WALRecord> p : createWalIterator(dir, null, null, false)) {
if (lowBound == null)
lowBound = p.get1();
highBound = p.get1();
}
assertNotNull(lowBound);
assertNotNull(highBound);
createWalIterator(dir, lowBound, highBound, true);
final WALPointer lBound = lowBound;
final WALPointer hBound = highBound;
// noinspection ThrowableNotThrown
GridTestUtils.assertThrows(log, () -> {
createWalIterator(dir, new WALPointer(lBound.index() - 1, 0, 0), hBound, true);
return 0;
}, IgniteCheckedException.class, null);
// noinspection ThrowableNotThrown
GridTestUtils.assertThrows(log, () -> {
createWalIterator(dir, lBound, new WALPointer(hBound.index() + 1, 0, 0), true);
return 0;
}, IgniteCheckedException.class, null);
List<FileDescriptor> walFiles = listWalFiles(dir);
assertNotNull(walFiles);
assertTrue(!walFiles.isEmpty());
assertTrue(walFiles.get(new Random().nextInt(walFiles.size())).file().delete());
// noinspection ThrowableNotThrown
GridTestUtils.assertThrows(log, () -> {
createWalIterator(dir, lBound, hBound, true);
return 0;
}, IgniteCheckedException.class, null);
}
Aggregations