Search in sources :

Example 6 with IgniteCacheDatabaseSharedManager

use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.

the class PageMemoryImplTest method createPageMemory.

/**
 * @param throttlingPlc Throttling Policy.
 * @throws Exception If creating mock failed.
 */
private PageMemoryImpl createPageMemory(int maxSize, PageMemoryImpl.ThrottlingPolicy throttlingPlc, IgnitePageStoreManager mgr, PageStoreWriter replaceWriter, @Nullable IgniteInClosure<FullPageId> cpBufChecker) throws Exception {
    long[] sizes = new long[5];
    for (int i = 0; i < sizes.length; i++) sizes[i] = maxSize * MB / 4;
    sizes[4] = maxSize * MB / 4;
    DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
    IgniteConfiguration igniteCfg = new IgniteConfiguration();
    igniteCfg.setDataStorageConfiguration(new DataStorageConfiguration());
    igniteCfg.setFailureHandler(new NoOpFailureHandler());
    igniteCfg.setEncryptionSpi(new NoopEncryptionSpi());
    igniteCfg.setMetricExporterSpi(new NoopMetricExporterSpi());
    igniteCfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());
    igniteCfg.setEventStorageSpi(new NoopEventStorageSpi());
    GridTestKernalContext kernalCtx = new GridTestKernalContext(new GridTestLog4jLogger(), igniteCfg);
    kernalCtx.add(new IgnitePluginProcessor(kernalCtx, igniteCfg, Collections.<PluginProvider>emptyList()));
    kernalCtx.add(new GridInternalSubscriptionProcessor(kernalCtx));
    kernalCtx.add(new PerformanceStatisticsProcessor(kernalCtx));
    kernalCtx.add(new GridEncryptionManager(kernalCtx));
    kernalCtx.add(new GridMetricManager(kernalCtx));
    kernalCtx.add(new GridSystemViewManager(kernalCtx));
    kernalCtx.add(new GridEventStorageManager(kernalCtx));
    FailureProcessor failureProc = new FailureProcessor(kernalCtx);
    failureProc.start();
    kernalCtx.add(failureProc);
    GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(kernalCtx, null, null, null, mgr, new NoOpWALManager(), null, new IgniteCacheDatabaseSharedManager(), null, null, null, null, null, null, null, null, null, null, null, null, null);
    CheckpointProgressImpl cl0 = Mockito.mock(CheckpointProgressImpl.class);
    IgniteOutClosure<CheckpointProgress> noThrottle = Mockito.mock(IgniteOutClosure.class);
    Mockito.when(noThrottle.apply()).thenReturn(cl0);
    Mockito.when(cl0.currentCheckpointPagesCount()).thenReturn(1_000_000);
    Mockito.when(cl0.evictedPagesCounter()).thenReturn(new AtomicInteger(0));
    Mockito.when(cl0.syncedPagesCounter()).thenReturn(new AtomicInteger(1_000_000));
    Mockito.when(cl0.writtenPagesCounter()).thenReturn(new AtomicInteger(1_000_000));
    PageMemoryImpl mem = cpBufChecker == null ? new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, replaceWriter, new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {

        @Override
        public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
        }
    }, () -> true, new DataRegionMetricsImpl(igniteCfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration(), kernalCtx), throttlingPlc, noThrottle) : new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, replaceWriter, new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {

        @Override
        public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
        }
    }, () -> true, new DataRegionMetricsImpl(igniteCfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration(), kernalCtx), throttlingPlc, noThrottle) {

        @Override
        public FullPageId pullPageFromCpBuffer() {
            FullPageId pageId = super.pullPageFromCpBuffer();
            cpBufChecker.apply(pageId);
            return pageId;
        }
    };
    mem.metrics().enableMetrics();
    mem.start();
    return mem;
}
Also used : GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) NoOpFailureHandler(org.apache.ignite.failure.NoOpFailureHandler) IgnitePluginProcessor(org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor) CheckpointProgress(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointProgress) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) NoopEventStorageSpi(org.apache.ignite.spi.eventstorage.NoopEventStorageSpi) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) CheckpointProgressImpl(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointProgressImpl) DirectMemoryProvider(org.apache.ignite.internal.mem.DirectMemoryProvider) FullPageId(org.apache.ignite.internal.pagemem.FullPageId) GridEncryptionManager(org.apache.ignite.internal.managers.encryption.GridEncryptionManager) NoopEncryptionSpi(org.apache.ignite.spi.encryption.noop.NoopEncryptionSpi) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) PluginProvider(org.apache.ignite.plugin.PluginProvider) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) JmxSystemViewExporterSpi(org.apache.ignite.internal.managers.systemview.JmxSystemViewExporterSpi) PerformanceStatisticsProcessor(org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsProcessor) GridInClosure3X(org.apache.ignite.internal.util.lang.GridInClosure3X) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridSystemViewManager(org.apache.ignite.internal.managers.systemview.GridSystemViewManager) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) FailureProcessor(org.apache.ignite.internal.processors.failure.FailureProcessor) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 7 with IgniteCacheDatabaseSharedManager

use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.

the class SwapPathConstructionSelfTest method extractDefaultPageMemoryAllocPath.

/**
 * @param context Context.
 */
private String extractDefaultPageMemoryAllocPath(GridKernalContext context) {
    IgniteCacheDatabaseSharedManager dbMgr = context.cache().context().database();
    Map<String, DataRegion> memPlcMap = U.field(dbMgr, "dataRegionMap");
    PageMemory pageMem = memPlcMap.get("default").pageMemory();
    Object memProvider = U.field(pageMem, "directMemoryProvider");
    Object memProvider0 = U.field(memProvider, "memProvider");
    return ((File) U.field(memProvider0, "allocationPath")).getAbsolutePath();
}
Also used : PageMemory(org.apache.ignite.internal.pagemem.PageMemory) File(java.io.File) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) DataRegion(org.apache.ignite.internal.processors.cache.persistence.DataRegion)

Example 8 with IgniteCacheDatabaseSharedManager

use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.

the class ValidateIndexesClosure method integrityCheckIndexesPartitions.

/**
 * @param grpIds Group ids.
 * @param idleChecker Idle check closure.
 */
private Map<Integer, IndexIntegrityCheckIssue> integrityCheckIndexesPartitions(Set<Integer> grpIds, IgniteInClosure<Integer> idleChecker) {
    if (!checkCrc)
        return Collections.emptyMap();
    List<Future<T2<Integer, IndexIntegrityCheckIssue>>> integrityCheckFutures = new ArrayList<>(grpIds.size());
    Map<Integer, IndexIntegrityCheckIssue> integrityCheckResults = new HashMap<>();
    int curFut = 0;
    IgniteCacheDatabaseSharedManager db = ignite.context().cache().context().database();
    try {
        for (Integer grpId : grpIds) {
            final CacheGroupContext grpCtx = ignite.context().cache().cacheGroup(grpId);
            if (grpCtx == null || !grpCtx.persistenceEnabled()) {
                integrityCheckedIndexes.incrementAndGet();
                continue;
            }
            Future<T2<Integer, IndexIntegrityCheckIssue>> checkFut = calcExecutor.submit(new Callable<T2<Integer, IndexIntegrityCheckIssue>>() {

                @Override
                public T2<Integer, IndexIntegrityCheckIssue> call() {
                    IndexIntegrityCheckIssue issue = integrityCheckIndexPartition(grpCtx, idleChecker);
                    return new T2<>(grpCtx.groupId(), issue);
                }
            });
            integrityCheckFutures.add(checkFut);
        }
        for (Future<T2<Integer, IndexIntegrityCheckIssue>> fut : integrityCheckFutures) {
            T2<Integer, IndexIntegrityCheckIssue> res = fut.get();
            if (res.getValue() != null)
                integrityCheckResults.put(res.getKey(), res.getValue());
        }
    } catch (InterruptedException | ExecutionException e) {
        for (int j = curFut; j < integrityCheckFutures.size(); j++) integrityCheckFutures.get(j).cancel(false);
        throw unwrapFutureException(e);
    }
    return integrityCheckResults;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Future(java.util.concurrent.Future) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext) ExecutionException(java.util.concurrent.ExecutionException) T2(org.apache.ignite.internal.util.typedef.T2) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 9 with IgniteCacheDatabaseSharedManager

use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.

the class GridCommonAbstractTest method enableCheckpoints.

/**
 * Enable checkpoints on a specific nodes.
 *
 * @param nodes Ignite nodes.
 * @param enable {@code True} For checkpoint enabling.
 * @throws IgniteCheckedException If failed.
 */
protected void enableCheckpoints(Collection<Ignite> nodes, boolean enable) throws IgniteCheckedException {
    GridCompoundFuture<Void, Void> fut = new GridCompoundFuture<>();
    for (Ignite node : nodes) {
        assert !node.cluster().localNode().isClient();
        IgniteCacheDatabaseSharedManager dbMgr = (((IgniteEx) node).context().cache().context().database());
        assert dbMgr instanceof GridCacheDatabaseSharedManager;
        GridCacheDatabaseSharedManager dbMgr0 = (GridCacheDatabaseSharedManager) dbMgr;
        fut.add(dbMgr0.enableCheckpoints(enable));
    }
    fut.markInitialized();
    fut.get();
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 10 with IgniteCacheDatabaseSharedManager

use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.

the class TestStorageUtils method corruptDataEntry.

/**
 * Corrupts data entry.
 *
 * @param ctx Context.
 * @param key Key.
 * @param breakCntr Break counter.
 * @param breakData Break data.
 */
public static void corruptDataEntry(GridCacheContext<?, ?> ctx, Object key, boolean breakCntr, boolean breakData) throws IgniteCheckedException {
    assert !ctx.isLocal();
    int partId = ctx.affinity().partition(key);
    GridDhtLocalPartition locPart = ctx.topology().localPartition(partId);
    CacheEntry<Object, Object> e = ctx.cache().keepBinary().getEntry(key);
    KeyCacheObject keyCacheObj = e.getKey() instanceof BinaryObject ? (KeyCacheObject) e.getKey() : new KeyCacheObjectImpl(e.getKey(), null, partId);
    DataEntry dataEntry = new DataEntry(ctx.cacheId(), keyCacheObj, new CacheObjectImpl(breakData ? e.getValue().toString() + "brokenValPostfix" : e.getValue(), null), GridCacheOperation.UPDATE, new GridCacheVersion(), new GridCacheVersion(), 0L, partId, breakCntr ? locPart.updateCounter() + 1 : locPart.updateCounter(), DataEntry.EMPTY_FLAGS);
    IgniteCacheDatabaseSharedManager db = ctx.shared().database();
    db.checkpointReadLock();
    try {
        assert dataEntry.op() == GridCacheOperation.UPDATE;
        ctx.offheap().update(ctx, dataEntry.key(), dataEntry.value(), dataEntry.writeVersion(), dataEntry.expireTime(), locPart, null);
        ctx.offheap().dataStore(locPart).updateInitialCounter(dataEntry.partitionCounter() - 1, 1);
    } finally {
        db.checkpointReadUnlock();
    }
}
Also used : DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObject(org.apache.ignite.binary.BinaryObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CacheObjectImpl(org.apache.ignite.internal.processors.cache.CacheObjectImpl) KeyCacheObjectImpl(org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition) KeyCacheObjectImpl(org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Aggregations

IgniteCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)58 Test (org.junit.Test)27 IgniteEx (org.apache.ignite.internal.IgniteEx)24 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)20 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)11 GridCacheSharedContext (org.apache.ignite.internal.processors.cache.GridCacheSharedContext)10 GridInternalSubscriptionProcessor (org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor)9 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)8 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)8 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)8 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)7 GridSystemViewManager (org.apache.ignite.internal.managers.systemview.GridSystemViewManager)7 DirectMemoryProvider (org.apache.ignite.internal.mem.DirectMemoryProvider)7 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)7 DataRegionMetricsImpl (org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)7 IgnitePluginProcessor (org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor)6 GridTestKernalContext (org.apache.ignite.testframework.junits.GridTestKernalContext)6 HashMap (java.util.HashMap)5 GridEncryptionManager (org.apache.ignite.internal.managers.encryption.GridEncryptionManager)5 JmxSystemViewExporterSpi (org.apache.ignite.internal.managers.systemview.JmxSystemViewExporterSpi)5