use of org.apache.ignite.events.WalSegmentCompactedEvent in project ignite by apache.
the class WalCompactionAfterRestartTest method test.
/**
* @throws Exception If failed.
*/
@Test
public void test() throws Exception {
IgniteEx ig = startGrid(0);
ig.cluster().active(true);
doCachePuts(ig, 10_000);
ig.cluster().active(false);
stopGrid(0);
IgniteEx ig0 = startGrid(0);
ig0.cluster().active(true);
List<IgniteBiTuple<Long, Long>> discrepancies = Collections.synchronizedList(new ArrayList<>());
ig0.events().localListen(e -> {
long evtSegIdx = ((WalSegmentCompactedEvent) e).getAbsWalSegmentIdx();
long lastCompactedIdx = ig0.context().cache().context().wal().lastCompactedSegment();
if (lastCompactedIdx < 0 || lastCompactedIdx > evtSegIdx)
discrepancies.add(F.t(evtSegIdx, lastCompactedIdx));
return true;
}, EVT_WAL_SEGMENT_COMPACTED);
doCachePuts(ig0, 5_000);
stopGrid(0);
if (!discrepancies.isEmpty()) {
fail("Discrepancies (EVT_WAL_SEGMENT_COMPACTED index vs. lastCompactedSegment):" + System.lineSeparator() + discrepancies.stream().map(t -> String.format("%d <-> %d", t.get1(), t.get2())).collect(Collectors.joining(System.lineSeparator())));
}
}
Aggregations