use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointManager in project ignite by apache.
the class IgnitePdsWithTtlTest method testPutOpsIntoCacheWithExpirationConcurrentlyWithCheckpointCompleteSuccessfully.
/**
* @throws Exception if failed.
*/
@Test
public void testPutOpsIntoCacheWithExpirationConcurrentlyWithCheckpointCompleteSuccessfully() throws Exception {
IgniteEx ig0 = startGrid(0);
ig0.cluster().state(ACTIVE);
IgniteCache<Object, Object> cache = ig0.getOrCreateCache(CACHE_NAME_ATOMIC);
AtomicBoolean timeoutReached = new AtomicBoolean(false);
CheckpointManager checkpointManager = U.field(ig0.context().cache().context().database(), "checkpointManager");
IgniteInternalFuture<?> ldrFut = runMultiThreadedAsync(() -> {
while (!timeoutReached.get()) {
Map<Object, Object> map = new TreeMap<>();
for (int i = 0; i < ENTRIES; i++) map.put(i, i);
cache.putAll(map);
}
}, WORKLOAD_THREADS_CNT, "loader");
IgniteInternalFuture<?> updaterFut = runMultiThreadedAsync(() -> {
while (!timeoutReached.get()) {
for (int i = 0; i < SMALL_ENTRIES; i++) cache.put(i, i * 10);
}
}, WORKLOAD_THREADS_CNT, "updater");
IgniteInternalFuture<?> cpWriteLockUnlockFut = runAsync(() -> {
Object checkpointReadWriteLock = U.field(checkpointManager.checkpointTimeoutLock(), "checkpointReadWriteLock");
ReentrantReadWriteLockWithTracking lock = U.field(checkpointReadWriteLock, "checkpointLock");
while (!timeoutReached.get()) {
try {
lock.writeLock().lockInterruptibly();
doSleep(30);
} catch (InterruptedException ignored) {
break;
} finally {
lock.writeLock().unlock();
}
doSleep(30);
}
}, "cp-write-lock-holder");
doSleep(10_000);
timeoutReached.set(true);
waitForAllFutures(cpWriteLockUnlockFut, ldrFut, updaterFut);
}
use of org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointManager in project ignite by apache.
the class GridCacheDatabaseSharedManager method start0.
/**
* {@inheritDoc}
*/
@Override
protected void start0() throws IgniteCheckedException {
super.start0();
snapshotMgr = cctx.snapshot();
IgnitePageStoreManager store = cctx.pageStore();
assert store instanceof FilePageStoreManager : "Invalid page store manager was created: " + store;
storeMgr = (FilePageStoreManager) store;
final GridKernalContext kernalCtx = cctx.kernalContext();
assert !kernalCtx.clientNode();
initWalRebalanceThreshold();
if (!kernalCtx.clientNode()) {
kernalCtx.internalSubscriptionProcessor().registerDatabaseListener(new MetastorageRecoveryLifecycle());
cpFreqDeviation = new SimpleDistributedProperty<>("checkpoint.deviation", Integer::parseInt);
kernalCtx.internalSubscriptionProcessor().registerDistributedConfigurationListener(dispatcher -> {
cpFreqDeviation.addListener((name, oldVal, newVal) -> U.log(log, "Checkpoint frequency deviation changed [oldVal=" + oldVal + ", newVal=" + newVal + "]"));
dispatcher.registerProperty(cpFreqDeviation);
});
checkpointManager = new CheckpointManager(kernalCtx::log, cctx.igniteInstanceName(), "db-checkpoint-thread", cctx.wal(), kernalCtx.workersRegistry(), persistenceCfg, storeMgr, this::isCheckpointInapplicableForWalRebalance, this::checkpointedDataRegions, this::cacheGroupContexts, this::getPageMemoryForCacheGroup, resolveThrottlingPolicy(), snapshotMgr, persistentStoreMetricsImpl(), kernalCtx.longJvmPauseDetector(), kernalCtx.failure(), kernalCtx.cache(), () -> cpFreqDeviation.getOrDefault(DEFAULT_CHECKPOINT_DEVIATION), kernalCtx.pools().getSystemExecutorService());
final NodeFileLockHolder preLocked = kernalCtx.pdsFolderResolver().resolveFolders().getLockedFileLockHolder();
acquireFileLock(preLocked);
cleanupTempCheckpointDirectory();
persStoreMetrics.wal(cctx.wal());
}
}
Aggregations