Search in sources :

Example 16 with IteratorParametersBuilder

use of org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory.IteratorParametersBuilder in project ignite by apache.

the class IgniteWalReaderTest method testFillWalForExactSegmentsCount.

/**
 * Tests archive completed event is fired.
 *
 * @throws Exception if failed.
 */
@Test
public void testFillWalForExactSegmentsCount() throws Exception {
    customWalMode = WALMode.FSYNC;
    CountDownLatch reqSegments = new CountDownLatch(15);
    Ignite ignite = startGrid();
    ignite.cluster().active(true);
    final IgniteEvents evts = ignite.events();
    if (!evts.isEnabled(EVT_WAL_SEGMENT_ARCHIVED))
        fail("nothing to test");
    evts.localListen(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) {
        int write = 500;
        putAllDummyRecords(ignite, write);
        totalEntries += write;
        Assert.assertTrue("Too much entries generated, but segments was not become available", totalEntries < 10000);
    }
    String subfolderName = genDbSubfolderName(ignite, 0);
    stopGrid();
    String workDir = U.defaultWorkDirectory();
    IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(log);
    IteratorParametersBuilder iterParametersBuilder = createIteratorParametersBuilder(workDir, subfolderName);
    iterParametersBuilder.filesOrDirs(workDir);
    scanIterateAndCount(factory, iterParametersBuilder, totalEntries, 0, null, null);
}
Also used : IgniteWalIteratorFactory(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory) IgniteEvents(org.apache.ignite.IgniteEvents) IteratorParametersBuilder(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory.IteratorParametersBuilder) Ignite(org.apache.ignite.Ignite) CountDownLatch(java.util.concurrent.CountDownLatch) WalSegmentArchivedEvent(org.apache.ignite.events.WalSegmentArchivedEvent) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 17 with IteratorParametersBuilder

use of org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory.IteratorParametersBuilder in project ignite by apache.

the class IgniteWalReaderTest method testTxRecordsReadWoBinaryMeta.

/**
 * Tests transaction generation and WAL for putAll cache operation.
 *
 * @throws Exception if failed.
 */
@Test
public void testTxRecordsReadWoBinaryMeta() throws Exception {
    Ignite ignite = startGrid("node0");
    ignite.cluster().state(ClusterState.ACTIVE);
    Map<Object, IndexedObject> map = new TreeMap<>();
    for (int i = 0; i < 1000; i++) map.put(i, new IndexedObject(i));
    ignite.cache(CACHE_NAME).putAll(map);
    ignite.cluster().state(ClusterState.INACTIVE);
    String workDir = U.defaultWorkDirectory();
    String subfolderName = genDbSubfolderName(ignite, 0);
    stopAllGrids();
    IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(new NullLogger());
    IteratorParametersBuilder params = createIteratorParametersBuilder(workDir, subfolderName);
    scanIterateAndCount(factory, params.filesOrDirs(workDir), 1000, 1, null, null);
}
Also used : IgniteWalIteratorFactory(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory) NullLogger(org.apache.ignite.logger.NullLogger) IteratorParametersBuilder(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory.IteratorParametersBuilder) Ignite(org.apache.ignite.Ignite) BinaryObject(org.apache.ignite.binary.BinaryObject) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) TreeMap(java.util.TreeMap) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

IteratorParametersBuilder (org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory.IteratorParametersBuilder)17 IgniteWalIteratorFactory (org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory)13 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)11 Test (org.junit.Test)11 Ignite (org.apache.ignite.Ignite)10 WALIterator (org.apache.ignite.internal.pagemem.wal.WALIterator)8 WALRecord (org.apache.ignite.internal.pagemem.wal.record.WALRecord)8 WALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)8 File (java.io.File)7 IgniteEx (org.apache.ignite.internal.IgniteEx)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)5 Serializable (java.io.Serializable)4 ArrayList (java.util.ArrayList)4 EnumMap (java.util.EnumMap)4 HashMap (java.util.HashMap)4 DataEntry (org.apache.ignite.internal.pagemem.wal.record.DataEntry)4 GridCacheOperation (org.apache.ignite.internal.processors.cache.GridCacheOperation)4 Externalizable (java.io.Externalizable)3 IOException (java.io.IOException)3