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;
}
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();
}
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;
}
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();
}
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();
}
}
Aggregations