use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.
the class IgnitePdsDiskErrorsRecoveringTest method emulateRecoveringOnWALWritingError.
/**
*/
private void emulateRecoveringOnWALWritingError() throws Exception {
final IgniteEx grid = startGrid(0);
FileWriteAheadLogManager wal = (FileWriteAheadLogManager) grid.context().cache().context().wal();
wal.setFileIOFactory(new LimitedSizeFileIOFactory(new RandomAccessFileIOFactory(), diskSpaceBytes));
grid.active(true);
int failedPosition = -1;
for (int i = 0; i < 1000; i++) {
byte payload = (byte) i;
byte[] data = new byte[2048];
Arrays.fill(data, payload);
try {
grid.cache(CACHE_NAME).put(i, data);
} catch (Exception e) {
failedPosition = i;
break;
}
}
// We must be able to put something into cache before fail.
Assert.assertTrue(failedPosition > 0);
// Grid should be automatically stopped after WAL fail.
awaitStop(grid);
// Grid should be successfully recovered after stopping.
IgniteEx recoveredGrid = startGrid(0);
recoveredGrid.active(true);
for (int i = 0; i < failedPosition; i++) {
byte payload = (byte) i;
byte[] data = new byte[2048];
Arrays.fill(data, payload);
byte[] actualData = (byte[]) recoveredGrid.cache(CACHE_NAME).get(i);
Assert.assertArrayEquals(data, actualData);
}
}
use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.
the class CacheGroupReencryptionTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String name) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(name);
cfg.setConsistentId(name);
cfg.setIncludeEventTypes(EventType.EVT_CACHE_REBALANCE_STOPPED);
EncryptionConfiguration encCfg = new EncryptionConfiguration().setReencryptionBatchSize(pageScanBatchSize).setReencryptionRateLimit(pageScanRate);
DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(1024 * 1024 * 1024L).setPersistenceEnabled(true)).setPageSize(4 * 1024).setWalSegmentSize(10 * 1024 * 1024).setWalSegments(4).setMaxWalArchiveSize(100 * 1024 * 1024L).setCheckpointFrequency(TimeUnit.SECONDS.toMillis(checkpointFreq)).setWalMode(LOG_ONLY).setFileIOFactory(new FailingFileIOFactory(new RandomAccessFileIOFactory(), failFileIO)).setEncryptionConfiguration(encCfg);
cfg.setDataStorageConfiguration(memCfg);
return cfg;
}
use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.
the class IgnitePdsCorruptedIndexTest 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(256 * 1024 * 1024).setPersistenceEnabled(true));
if (haltFileIO)
dsCfg.setFileIOFactory(new HaltOnTruncateFileIOFactory(new RandomAccessFileIOFactory()));
cfg.setDataStorageConfiguration(dsCfg);
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(CACHE).setBackups(1).setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC).setIndexedTypes(Integer.class, IndexedObject.class, Long.class, IndexedObject.class).setAffinity(new RendezvousAffinityFunction(false, 32));
cfg.setCacheConfiguration(ccfg);
return cfg;
}
use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.
the class IgniteClusterSnapshotSelfTest method testRecoveryClusterSnapshotJvmHalted.
/**
* @throws Exception If fails.
*/
@Test
public void testRecoveryClusterSnapshotJvmHalted() throws Exception {
IgniteEx ignite = startGridsWithCache(2, dfltCacheCfg, CACHE_KEYS_RANGE);
String grid0Dir = folderName(ignite);
String grid1Dir = folderName(grid(1));
File locSnpDir = snp(ignite).snapshotLocalDir(SNAPSHOT_NAME);
jvm = true;
IgniteConfiguration cfg2 = optimize(getConfiguration(getTestIgniteInstanceName(2)));
cfg2.getDataStorageConfiguration().setFileIOFactory(new HaltJvmFileIOFactory(new RandomAccessFileIOFactory(), (Predicate<File> & Serializable) file -> {
return file.getAbsolutePath().contains(SNAPSHOT_NAME);
}));
startGrid(cfg2);
String grid2Dir = U.maskForFileName(cfg2.getConsistentId().toString());
jvm = false;
ignite.cluster().setBaselineTopology(ignite.cluster().topologyVersion());
awaitPartitionMapExchange();
assertThrowsAnyCause(log, () -> ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get(), ClusterTopologyException.class, "Snapshot operation interrupted, because baseline node left the cluster");
assertTrue("Snapshot directory must be empty: " + grid0Dir, !searchDirectoryRecursively(locSnpDir.toPath(), grid0Dir).isPresent());
assertTrue("Snapshot directory must be empty: " + grid1Dir, !searchDirectoryRecursively(locSnpDir.toPath(), grid1Dir).isPresent());
assertTrue("Snapshot directory must exist due to grid2 has been halted and cleanup not fully performed: " + grid2Dir, searchDirectoryRecursively(locSnpDir.toPath(), grid2Dir).isPresent());
IgniteEx grid2 = startGrid(2);
assertTrue("Snapshot directory must be empty after recovery: " + grid2Dir, !searchDirectoryRecursively(locSnpDir.toPath(), grid2Dir).isPresent());
awaitPartitionMapExchange();
assertTrue("Snapshot directory must be empty", grid2.context().cache().context().snapshotMgr().localSnapshotNames().isEmpty());
ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();
stopAllGrids();
IgniteEx snp = startGridsFromSnapshot(2, SNAPSHOT_NAME);
assertSnapshotCacheKeys(snp.cache(dfltCacheCfg.getName()));
}
use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.
the class IgnitePdsDiskErrorsRecoveringTest method testRecoveringOnWALWritingFail1.
/**
* Test node stopping & recovering on WAL writing fail with enabled MMAP (Batch allocation for WAL segments).
*/
@Test
public void testRecoveringOnWALWritingFail1() throws Exception {
// Allow to allocate only 1 wal segment, fail on write to second.
ioFactory = new FilteringFileIOFactory(".wal", new LimitedSizeFileIOFactory(new RandomAccessFileIOFactory(), WAL_SEGMENT_SIZE));
System.setProperty(IGNITE_WAL_MMAP, "true");
doTestRecoveringOnWALWritingFail();
}
Aggregations