use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.
the class IgnitePdsBinaryMetadataAsyncWritingTest method testNodeIsStoppedOnExceptionDuringStoringMetadata.
/**
* @throws Exception If failed.
*/
@Test
public void testNodeIsStoppedOnExceptionDuringStoringMetadata() throws Exception {
IgniteEx ig0 = startGrid(0);
specialFileIOFactory = new FailingFileIOFactory(new RandomAccessFileIOFactory());
setRootLoggerDebugLevel();
IgniteEx ig1 = startGrid(1);
ig0.cluster().active(true);
int ig1Key = findAffinityKeyForNode(ig0.affinity(DEFAULT_CACHE_NAME), ig1.localNode());
IgniteCache<Object, Object> cache = ig0.cache(DEFAULT_CACHE_NAME);
cache.put(ig1Key, new TestAddress(0, "USA", "NYC", "6th Ave"));
waitForTopology(1);
}
use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.
the class IgnitePdsBinaryMetadataAsyncWritingTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
if (igniteInstanceName.contains("client")) {
cfg.setClientMode(true);
return cfg;
}
cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(50 * 1024 * 1024).setPersistenceEnabled(true)).setFileIOFactory(specialFileIOFactory != null ? specialFileIOFactory : new RandomAccessFileIOFactory()));
cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME).setBackups(1).setAffinity(new RendezvousAffinityFunction(false, 16)));
cfg.setFailureHandler(new StopNodeFailureHandler());
return cfg;
}
use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.
the class WalTestUtils method corruptWalSegmentFile.
/**
* Put zero CRC in one of records for the specified segment.
*
* @param desc WAL segment descriptor.
* @param pointer WAL pointer.
*/
public static void corruptWalSegmentFile(FileDescriptor desc, WALPointer pointer) throws IOException {
int crc32Off = pointer.fileOffset() + pointer.length() - CRC_SIZE;
// Has 0 value by default.
ByteBuffer zeroCrc32 = allocate(CRC_SIZE);
FileIOFactory ioFactory = new RandomAccessFileIOFactory();
try (FileIO io = ioFactory.create(desc.file(), WRITE)) {
io.write(zeroCrc32, crc32Off);
io.force(true);
}
}
use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.
the class IgniteClusterSnapshotRestoreSelfTest method testNodeFailDuringFilesCopy.
/**
* @throws Exception If failed.
*/
@Test
public void testNodeFailDuringFilesCopy() throws Exception {
dfltCacheCfg.setCacheMode(CacheMode.REPLICATED).setAffinity(new RendezvousAffinityFunction());
startGridsWithSnapshot(3, CACHE_KEYS_RANGE);
TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(grid(2));
CountDownLatch stopLatch = new CountDownLatch(1);
spi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage && ((SingleNodeMessage<?>) msg).type() == RESTORE_CACHE_GROUP_SNAPSHOT_PRELOAD.ordinal());
String failingFilePath = Paths.get(CACHE_DIR_PREFIX + DEFAULT_CACHE_NAME, PART_FILE_PREFIX + (dfltCacheCfg.getAffinity().partitions() / 2) + FILE_SUFFIX).toString();
grid(2).context().cache().context().snapshotMgr().ioFactory(new CustomFileIOFactory(new RandomAccessFileIOFactory(), file -> {
if (file.getPath().endsWith(failingFilePath)) {
stopLatch.countDown();
throw new RuntimeException("Test exception");
}
}));
File node2dbDir = ((FilePageStoreManager) grid(2).context().cache().context().pageStore()).cacheWorkDir(dfltCacheCfg).getParentFile();
IgniteInternalFuture<Object> stopFut = runAsync(() -> {
U.await(stopLatch, TIMEOUT, TimeUnit.MILLISECONDS);
stopGrid(2, true);
return null;
});
IgniteFuture<Void> fut = grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME));
stopFut.get(TIMEOUT);
GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), ClusterTopologyCheckedException.class, null);
File[] files = node2dbDir.listFiles(file -> file.getName().startsWith(TMP_CACHE_DIR_PREFIX));
assertEquals("A temp directory with potentially corrupted files must exist.", 1, files.length);
ensureCacheAbsent(dfltCacheCfg);
dfltCacheCfg = null;
startGrid(2);
files = node2dbDir.listFiles(file -> file.getName().startsWith(TMP_CACHE_DIR_PREFIX));
assertEquals("A temp directory should be removed at node startup", 0, files.length);
waitForEvents(EVT_CLUSTER_SNAPSHOT_RESTORE_STARTED, EVT_CLUSTER_SNAPSHOT_RESTORE_FAILED);
}
use of org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory in project ignite by apache.
the class ForwardReadTest method createStatistics.
/**
* Creates test performance statistics file.
*/
private Map<String, Integer> createStatistics(File dir) throws Exception {
Map<String, Integer> expTasks;
File file = new File(dir, "node-" + randomUUID() + ".prf");
try (FileIO fileIo = new RandomAccessFileIOFactory().create(file)) {
ByteBuffer buf = ByteBuffer.allocate(10 * 1024).order(ByteOrder.nativeOrder());
expTasks = writeData(buf);
buf.flip();
fileIo.write(buf);
fileIo.force();
}
return expTasks;
}
Aggregations