use of org.apache.ignite.events.WalSegmentArchivedEvent in project ignite by apache.
the class IgniteWalReaderTest method testArchiveIncompleteSegmentAfterInactivity.
/**
* Tests time out based WAL segment archiving.
*
* @throws Exception if failure occurs.
*/
public void testArchiveIncompleteSegmentAfterInactivity() throws Exception {
final AtomicBoolean waitingForEvt = new AtomicBoolean();
final CountDownLatch archiveSegmentForInactivity = new CountDownLatch(1);
archiveIncompleteSegmentAfterInactivityMs = 1000;
final Ignite ignite = startGrid("node0");
ignite.active(true);
final IgniteEvents evts = ignite.events();
evts.localListen(new IgnitePredicate<Event>() {
@Override
public boolean apply(Event e) {
WalSegmentArchivedEvent archComplEvt = (WalSegmentArchivedEvent) e;
long idx = archComplEvt.getAbsWalSegmentIdx();
log.info("Finished archive for segment [" + idx + ", " + archComplEvt.getArchiveFile() + "]: [" + e + "]");
if (waitingForEvt.get())
archiveSegmentForInactivity.countDown();
return true;
}
}, EVT_WAL_SEGMENT_ARCHIVED);
putDummyRecords(ignite, 100);
// flag for skipping regular log() and rollOver()
waitingForEvt.set(true);
log.info("Wait for archiving segment for inactive grid started");
boolean recordedAfterSleep = archiveSegmentForInactivity.await(archiveIncompleteSegmentAfterInactivityMs + 1001, TimeUnit.MILLISECONDS);
stopGrid("node0");
assertTrue(recordedAfterSleep);
}
use of org.apache.ignite.events.WalSegmentArchivedEvent in project ignite by apache.
the class IgniteWalReaderTest method testArchiveCompletedEventFired.
/**
* Tests archive completed event is fired.
*
* @throws Exception if failed.
*/
public void testArchiveCompletedEventFired() throws Exception {
final AtomicBoolean evtRecorded = new AtomicBoolean();
final Ignite ignite = startGrid("node0");
ignite.active(true);
final IgniteEvents evts = ignite.events();
if (!evts.isEnabled(EVT_WAL_SEGMENT_ARCHIVED))
assertTrue("nothing to test", false);
evts.localListen(new IgnitePredicate<Event>() {
@Override
public boolean apply(Event e) {
WalSegmentArchivedEvent archComplEvt = (WalSegmentArchivedEvent) e;
long idx = archComplEvt.getAbsWalSegmentIdx();
log.info("Finished archive for segment [" + idx + ", " + archComplEvt.getArchiveFile() + "]: [" + e + "]");
evtRecorded.set(true);
return true;
}
}, EVT_WAL_SEGMENT_ARCHIVED);
putDummyRecords(ignite, 500);
stopGrid("node0");
assertTrue(evtRecorded.get());
}
use of org.apache.ignite.events.WalSegmentArchivedEvent in project ignite by apache.
the class IgniteWalReaderTest method testFillWalForExactSegmentsCount.
/**
* Tests archive completed event is fired.
*
* @throws Exception if failed.
*/
public void testFillWalForExactSegmentsCount() throws Exception {
customWalMode = WALMode.FSYNC;
final CountDownLatch reqSegments = new CountDownLatch(15);
final Ignite ignite = startGrid("node0");
ignite.active(true);
final IgniteEvents evts = ignite.events();
if (!evts.isEnabled(EVT_WAL_SEGMENT_ARCHIVED))
assertTrue("nothing to test", false);
evts.localListen(new IgnitePredicate<Event>() {
@Override
public boolean apply(Event e) {
WalSegmentArchivedEvent archComplEvt = (WalSegmentArchivedEvent) e;
long idx = archComplEvt.getAbsWalSegmentIdx();
log.info("Finished archive for segment [" + idx + ", " + archComplEvt.getArchiveFile() + "]: [" + e + "]");
reqSegments.countDown();
return true;
}
}, EVT_WAL_SEGMENT_ARCHIVED);
int totalEntries = 0;
while (reqSegments.getCount() > 0) {
final int write = 500;
putAllDummyRecords(ignite, write);
totalEntries += write;
Assert.assertTrue("Too much entries generated, but segments was not become available", totalEntries < 10000);
}
final String subfolderName = genDbSubfolderName(ignite, 0);
stopGrid("node0");
final String workDir = U.defaultWorkDirectory();
final IgniteWalIteratorFactory factory = createWalIteratorFactory(workDir, subfolderName);
scanIterateAndCount(factory, workDir, subfolderName, totalEntries, 0, null, null);
}
Aggregations