Search in sources :

Example 1 with CheckpointManager

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);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CheckpointManager(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointManager) IgniteEx(org.apache.ignite.internal.IgniteEx) TreeMap(java.util.TreeMap) ReentrantReadWriteLockWithTracking(org.apache.ignite.internal.util.ReentrantReadWriteLockWithTracking) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with CheckpointManager

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());
    }
}
Also used : IgnitePageStoreManager(org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager) GridKernalContext(org.apache.ignite.internal.GridKernalContext) LightweightCheckpointManager(org.apache.ignite.internal.processors.cache.persistence.checkpoint.LightweightCheckpointManager) CheckpointManager(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointManager) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager)

Aggregations

CheckpointManager (org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointManager)2 TreeMap (java.util.TreeMap)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 GridKernalContext (org.apache.ignite.internal.GridKernalContext)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 IgnitePageStoreManager (org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager)1 LightweightCheckpointManager (org.apache.ignite.internal.processors.cache.persistence.checkpoint.LightweightCheckpointManager)1 FilePageStoreManager (org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager)1 ReentrantReadWriteLockWithTracking (org.apache.ignite.internal.util.ReentrantReadWriteLockWithTracking)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1 Test (org.junit.Test)1