use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointStatus.NULL_PTR in project ignite by apache.
the class WalScannerTest method shouldFindCorrectRecordsForMoreThanOnePages.
/**
* @throws Exception If failed.
*/
@Test
public void shouldFindCorrectRecordsForMoreThanOnePages() throws Exception {
// given: Iterator with random value and value which should be find by scanner with several ids.
long expPageId1 = 984;
long expPageId2 = 9584;
long expPageId3 = 98344;
int grpId = 123;
PageSnapshot expPageSnapshot = new PageSnapshot(new FullPageId(expPageId1, grpId), dummyPage(1024, expPageId1), 1024);
CheckpointRecord expCheckpoint = new CheckpointRecord(new WALPointer(5738, 0, 0));
FixCountRecord expDeltaPage1 = new FixCountRecord(grpId, expPageId2, 4);
FixCountRecord expDeltaPage2 = new FixCountRecord(grpId, expPageId3, 4);
WALIterator mockedIter = mockWalIterator(new IgniteBiTuple<>(NULL_PTR, expPageSnapshot), new IgniteBiTuple<>(NULL_PTR, new PageSnapshot(new FullPageId(455, grpId), dummyPage(1024, 455), 1024)), new IgniteBiTuple<>(NULL_PTR, expCheckpoint), new IgniteBiTuple<>(NULL_PTR, new MetastoreDataRecord("key", new byte[0])), new IgniteBiTuple<>(NULL_PTR, new PartitionMetaStateRecord(grpId, 1, OWNING, 1)), new IgniteBiTuple<>(NULL_PTR, expDeltaPage1), new IgniteBiTuple<>(NULL_PTR, new FixCountRecord(grpId, 98348, 4)), new IgniteBiTuple<>(NULL_PTR, new PartitionMetaStateRecord(grpId, 1, OWNING, 1)), new IgniteBiTuple<>(NULL_PTR, expDeltaPage2));
IgniteWalIteratorFactory mockedFactory = mock(IgniteWalIteratorFactory.class);
when(mockedFactory.iterator(any(IteratorParametersBuilder.class))).thenReturn(mockedIter);
List<WALRecord> holder = new ArrayList<>();
ScannerHandler recordCaptor = (rec) -> holder.add(rec.get2());
Set<T2<Integer, Long>> groupAndPageIds = new HashSet<>();
groupAndPageIds.add(new T2<>(grpId, expPageId1));
groupAndPageIds.add(new T2<>(grpId, expPageId2));
groupAndPageIds.add(new T2<>(grpId, expPageId3));
// when: Scanning WAL for searching expected page.
buildWalScanner(withIteratorParameters(), mockedFactory).findAllRecordsFor(groupAndPageIds).forEach(recordCaptor);
// then: Should be find only expected value.
assertEquals(4, holder.size());
assertEquals(expPageSnapshot, holder.get(0));
assertEquals(expCheckpoint, holder.get(1));
assertEquals(expDeltaPage1, holder.get(2));
assertEquals(expDeltaPage2, holder.get(3));
}
use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointStatus.NULL_PTR in project ignite by apache.
the class WalScannerTest method shouldFindCorrectRecords.
/**
* @throws Exception If failed.
*/
@Test
public void shouldFindCorrectRecords() throws Exception {
// given: Iterator with random value and value which should be find by scanner.
long expPageId = 984;
int grpId = 123;
PageSnapshot expPageSnapshot = new PageSnapshot(new FullPageId(expPageId, grpId), dummyPage(1024, expPageId), 1024);
CheckpointRecord expCheckpoint = new CheckpointRecord(new WALPointer(5738, 0, 0));
FixCountRecord expDeltaPage = new FixCountRecord(grpId, expPageId, 4);
WALIterator mockedIter = mockWalIterator(new IgniteBiTuple<>(NULL_PTR, expPageSnapshot), new IgniteBiTuple<>(NULL_PTR, new PageSnapshot(new FullPageId(455, grpId), dummyPage(4096, 455), 1024)), new IgniteBiTuple<>(NULL_PTR, expCheckpoint), new IgniteBiTuple<>(NULL_PTR, new MetastoreDataRecord("key", new byte[0])), new IgniteBiTuple<>(NULL_PTR, new PartitionMetaStateRecord(grpId, 1, OWNING, 1)), new IgniteBiTuple<>(NULL_PTR, expDeltaPage), new IgniteBiTuple<>(NULL_PTR, new FixCountRecord(grpId, 98348, 4)));
IgniteWalIteratorFactory mockedFactory = mock(IgniteWalIteratorFactory.class);
when(mockedFactory.iterator(any(IteratorParametersBuilder.class))).thenReturn(mockedIter);
// Test scanner handler for holding found value instead of printing its.
List<WALRecord> holder = new ArrayList<>();
ScannerHandler recordCaptor = (rec) -> holder.add(rec.get2());
Set<T2<Integer, Long>> groupAndPageIds = new HashSet<>();
groupAndPageIds.add(new T2<>(grpId, expPageId));
// when: Scanning WAL for searching expected page.
buildWalScanner(withIteratorParameters(), mockedFactory).findAllRecordsFor(groupAndPageIds).forEach(recordCaptor);
// then: Should be find only expected value.
assertEquals(holder.size(), 3);
assertEquals(expPageSnapshot, holder.get(0));
assertEquals(expCheckpoint, holder.get(1));
assertEquals(expDeltaPage, holder.get(2));
}
Aggregations