use of org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager in project ignite by apache.
the class IgniteWalIteratorSwitchSegmentTest method initiate.
/**
* Initiate WAL manager.
*
* @param serVer WAL serializer version.
* @param workDir Work directory path.
* @return Tuple of WAL manager and WAL record serializer.
* @throws IgniteCheckedException If some think failed.
*/
private T2<IgniteWriteAheadLogManager, RecordSerializer> initiate(int serVer, String workDir) throws IgniteCheckedException {
GridKernalContext kctx = new StandaloneGridKernalContext(log, null, null) {
@Override
protected IgniteConfiguration prepareIgniteConfiguration() {
IgniteConfiguration cfg = super.prepareIgniteConfiguration();
cfg.setDataStorageConfiguration(new DataStorageConfiguration().setWalSegmentSize(SEGMENT_SIZE).setWalRecordIteratorBufferSize(SEGMENT_SIZE / 2).setWalMode(WALMode.FSYNC).setWalPath(workDir + WORK_SUB_DIR).setWalArchivePath(workDir + ARCHIVE_SUB_DIR).setFileIOFactory(new RandomAccessFileIOFactory()));
cfg.setEventStorageSpi(new NoopEventStorageSpi());
return cfg;
}
@Override
public GridInternalSubscriptionProcessor internalSubscriptionProcessor() {
return new GridInternalSubscriptionProcessor(this);
}
@Override
public GridEventStorageManager event() {
return new GridEventStorageManager(this);
}
};
IgniteWriteAheadLogManager walMgr = new FileWriteAheadLogManager(kctx);
GridTestUtils.setFieldValue(walMgr, "serializerVer", serVer);
GridCacheSharedContext<?, ?> ctx = new GridCacheSharedContext<>(kctx, null, null, null, null, walMgr, new WalStateManager(kctx), new GridCacheDatabaseSharedManager(kctx), null, null, null, null, null, new GridCacheIoManager(), null, null, null, null, null, null, null);
walMgr.start(ctx);
walMgr.onActivate(kctx);
walMgr.resumeLogging(null);
RecordSerializer recordSerializer = new RecordSerializerFactoryImpl(ctx).createSerializer(walMgr.serializerVersion());
return new T2<>(walMgr, recordSerializer);
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager in project ignite by apache.
the class WalDeletionArchiveAbstractTest method testCorrectDeletedCheckpointHistoryButKeepWalFiles.
/**
* Correct delete checkpoint history from memory depends on IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE.
* WAL files doesn't delete because deleting was disabled.
*/
@Test
@WithSystemProperty(key = IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, value = "2")
public void testCorrectDeletedCheckpointHistoryButKeepWalFiles() throws Exception {
// given: configured grid with disabled WAL removing.
Ignite ignite = startGrid(dbCfg -> dbCfg.setMaxWalArchiveSize(DataStorageConfiguration.UNLIMITED_WAL_ARCHIVE));
GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite);
CheckpointHistory hist = dbMgr.checkpointHistory();
assertNotNull(hist);
IgniteCache<Integer, Object> cache = ignite.getOrCreateCache(cacheConfiguration());
// when: put to cache
for (int i = 0; i < 500; i++) {
cache.put(i, i);
if (i % 10 == 0)
forceCheckpoint();
}
forceCheckpoint();
// then: WAL files was not deleted but some of checkpoint history was deleted.
FileWriteAheadLogManager wal = wal(ignite);
assertNull(getFieldValueHierarchy(wal, "cleaner"));
FileDescriptor[] files = wal.walArchiveFiles();
assertTrue(Stream.of(files).anyMatch(desc -> desc.file().getName().endsWith("0001.wal")));
assertTrue(hist.checkpoints().size() == 2);
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager in project ignite by apache.
the class WalDeletionArchiveAbstractTest method testCorrectDeletedArchivedWalFiles.
/**
* Correct delete archived wal files.
*/
@Test
public void testCorrectDeletedArchivedWalFiles() throws Exception {
// given: configured grid with setted max wal archive size
long maxWalArchiveSize = 2 * 1024 * 1024;
Ignite ignite = startGrid(dbCfg -> dbCfg.setMaxWalArchiveSize(maxWalArchiveSize));
GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite);
CheckpointHistory hist = dbMgr.checkpointHistory();
assertNotNull(hist);
IgniteCache<Integer, Object> cache = ignite.getOrCreateCache(cacheConfiguration());
// when: put to cache more than 2 MB
for (int i = 0; i < 500; i++) {
if (i % 100 == 0)
forceCheckpoint();
cache.put(i, i);
}
// then: total archive size less than of maxWalArchiveSize(by current logic)
FileWriteAheadLogManager wal = wal(ignite);
assertTrue(waitForCondition(() -> wal.lastTruncatedSegment() >= 0, 10_000));
FileDescriptor[] files = wal.walArchiveFiles();
long totalSize = wal.totalSize(files);
assertTrue(files.length >= 1);
assertTrue(totalSize < maxWalArchiveSize);
assertFalse(Stream.of(files).anyMatch(desc -> desc.file().getName().endsWith("00001.wal")));
assertTrue(!hist.checkpoints().isEmpty());
}
Aggregations