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;
}
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;
}
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));
}
}
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);
}
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();
}
Aggregations