Search in sources :

Example 16 with RandomAccessFileIOFactory

use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.

the class IgnitePdsBinaryMetadataAsyncWritingTest method initSlowFileIOFactory.

/**
 * Initializes special FileIOFactory emulating slow write to disk.
 *
 * @return Latch to release write operation.
 */
private CountDownLatch initSlowFileIOFactory() {
    CountDownLatch cdl = new CountDownLatch(1);
    specialFileIOFactory = new SlowFileIOFactory(new RandomAccessFileIOFactory());
    fileWriteLatchRef.set(cdl);
    return cdl;
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory)

Example 17 with RandomAccessFileIOFactory

use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.

the class IgnitePdsPartitionFilesDestroyTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setConsistentId(igniteInstanceName);
    DataStorageConfiguration dsCfg = new DataStorageConfiguration().setWalMode(WALMode.LOG_ONLY).setCheckpointFrequency(10 * 60 * 1000).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(512 * 1024 * 1024).setPersistenceEnabled(true));
    if (failFileIo)
        dsCfg.setFileIOFactory(new FailingFileIOFactory(new RandomAccessFileIOFactory()));
    cfg.setDataStorageConfiguration(dsCfg);
    CacheConfiguration ccfg = defaultCacheConfiguration().setBackups(1).setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC).setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT));
    cfg.setCacheConfiguration(ccfg);
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory)

Example 18 with RandomAccessFileIOFactory

use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.

the class DiagnosticProcessorTest method testCorruptedPagesFile.

/**
 * Checks the correctness of the {@link DiagnosticProcessor#corruptedPagesFile}.
 *
 * @throws Exception If failed.
 */
@Test
public void testCorruptedPagesFile() throws Exception {
    File tmpDir = new File(System.getProperty("java.io.tmpdir"), getName());
    try {
        int grpId = 10;
        long[] pageIds = { 20, 40 };
        File f = corruptedPagesFile(tmpDir.toPath(), new RandomAccessFileIOFactory(), grpId, pageIds);
        assertTrue(f.exists());
        assertTrue(f.isFile());
        assertTrue(f.length() > 0);
        assertTrue(Arrays.asList(tmpDir.listFiles()).contains(f));
        assertTrue(corruptedPagesFileNamePattern().matcher(f.getName()).matches());
        try (BufferedReader br = new BufferedReader(new FileReader(f))) {
            List<String> lines = br.lines().collect(toList());
            List<String> pageStrs = LongStream.of(pageIds).mapToObj(pageId -> grpId + ":" + pageId).collect(toList());
            assertEqualsCollections(lines, pageStrs);
        }
    } finally {
        if (tmpDir.exists())
            assertTrue(U.delete(tmpDir));
    }
}
Also used : FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) Arrays(java.util.Arrays) DiagnosticProcessor.walDirs(org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.walDirs) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteEx(org.apache.ignite.internal.IgniteEx) CorruptedTreeException(org.apache.ignite.internal.processors.cache.persistence.tree.CorruptedTreeException) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) FailureContext(org.apache.ignite.failure.FailureContext) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) Path(java.nio.file.Path) DiagnosticProcessor.corruptedPagesFile(org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.corruptedPagesFile) SegmentRouter(org.apache.ignite.internal.processors.cache.persistence.wal.SegmentRouter) DFLT_WAL_PATH(org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH) F(org.apache.ignite.internal.util.typedef.F) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) LongStream(java.util.stream.LongStream) FailureType(org.apache.ignite.failure.FailureType) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) DEFAULT_TARGET_FOLDER(org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.DEFAULT_TARGET_FOLDER) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) Test(org.junit.Test) File(java.io.File) T2(org.apache.ignite.internal.util.typedef.T2) Consumer(java.util.function.Consumer) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Collectors.toList(java.util.stream.Collectors.toList) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridTestUtils.getFieldValue(org.apache.ignite.testframework.GridTestUtils.getFieldValue) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) Pattern(java.util.regex.Pattern) PageSnapshot(org.apache.ignite.internal.pagemem.wal.record.PageSnapshot) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) DiagnosticProcessor.corruptedPagesFile(org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.corruptedPagesFile) File(java.io.File) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 19 with RandomAccessFileIOFactory

use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.

the class IgnitePdsDiskErrorsRecoveringTest method testRecoveringOnCacheInitFail.

/**
 * Test node stopping & recovering on cache initialization fail.
 */
@Test
public void testRecoveringOnCacheInitFail() throws Exception {
    // Fail to initialize page store. 2 extra pages is needed for MetaStorage.
    ioFactory = new FilteringFileIOFactory(".bin", new LimitedSizeFileIOFactory(new RandomAccessFileIOFactory(), 2 * PAGE_SIZE));
    boolean failed = false;
    IgniteInternalFuture startGridFut = GridTestUtils.runAsync(() -> {
        try {
            IgniteEx grid = startGrid(0);
            grid.cluster().active(true);
        } catch (Exception e) {
            throw new RuntimeException("Failed to start node.", e);
        }
    });
    try {
        startGridFut.get();
    } catch (Exception e) {
        Assert.assertTrue(e.getMessage().contains("Failed to start node."));
        failed = true;
    }
    Assert.assertTrue("Cache initialization must failed", failed);
    // Grid should be successfully recovered after stopping.
    ioFactory = null;
    IgniteEx grid = startGrid(0);
    grid.cluster().active(true);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IOException(java.io.IOException) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 20 with RandomAccessFileIOFactory

use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.

the class IgnitePdsDiskErrorsRecoveringTest method testRecoveringOnWALWritingFail2.

/**
 * Test node stopping & recovering on WAL writing fail with disabled MMAP.
 */
@Test
public void testRecoveringOnWALWritingFail2() throws Exception {
    // Fail somewhere on the second wal segment.
    ioFactory = new FilteringFileIOFactory(".wal", new LimitedSizeFileIOFactory(new RandomAccessFileIOFactory(), (long) (1.5 * WAL_SEGMENT_SIZE)));
    System.setProperty(IGNITE_WAL_MMAP, "false");
    doTestRecoveringOnWALWritingFail();
}
Also used : RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

RandomAccessFileIOFactory (org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory)28 Test (org.junit.Test)13 File (java.io.File)10 IgniteEx (org.apache.ignite.internal.IgniteEx)10 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)9 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)8 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)7 FileIOFactory (org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory)7 FileIO (org.apache.ignite.internal.processors.cache.persistence.file.FileIO)6 IOException (java.io.IOException)5 ByteBuffer (java.nio.ByteBuffer)5 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)5 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)5 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)4 FileWriteAheadLogManager (org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager)4 WALIterator (org.apache.ignite.internal.pagemem.wal.WALIterator)3 WALRecord (org.apache.ignite.internal.pagemem.wal.record.WALRecord)3 WALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)3 IteratorParametersBuilder (org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory.IteratorParametersBuilder)3