use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class IndexStoragePageMemoryImplTest method memory.
/**
* @param clean Clean flag. If {@code true}, will clean previous memory state and allocate
* new empty page memory.
* @return Page memory instance.
*/
@Override
protected PageMemory memory(boolean clean) throws Exception {
long[] sizes = new long[10];
for (int i = 0; i < sizes.length; i++) sizes[i] = 1024 * 1024;
DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), allocationPath);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setEncryptionSpi(new NoopEncryptionSpi());
cfg.setMetricExporterSpi(new NoopMetricExporterSpi());
cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());
cfg.setDataStorageConfiguration(new DataStorageConfiguration());
GridTestKernalContext cctx = new GridTestKernalContext(log, cfg);
cctx.add(new IgnitePluginProcessor(cctx, cfg, Collections.emptyList()));
cctx.add(new GridInternalSubscriptionProcessor(cctx));
cctx.add(new PerformanceStatisticsProcessor(cctx));
cctx.add(new GridEncryptionManager(cctx));
cctx.add(new GridMetricManager(cctx));
cctx.add(new GridSystemViewManager(cctx));
GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(cctx, null, null, null, new NoOpPageStoreManager(), new NoOpWALManager(), null, new IgniteCacheDatabaseSharedManager(), null, null, null, null, null, null, null, null, null, null, null, null, new CacheDiagnosticManager());
IgniteOutClosure<CheckpointProgress> clo = () -> Mockito.mock(CheckpointProgressImpl.class);
return new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, (fullPageId, byteBuf, tag) -> {
assert false : "No page replacement (rotation with disk) should happen during the test";
}, new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
@Override
public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
}
}, () -> true, new DataRegionMetricsImpl(new DataRegionConfiguration(), cctx), PageMemoryImpl.ThrottlingPolicy.DISABLED, clo);
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class PageMemoryImplNoLoadTest method memory.
/**
* @return Page memory implementation.
*/
@Override
protected PageMemory memory() throws Exception {
File memDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false);
long[] sizes = new long[10];
for (int i = 0; i < sizes.length; i++) sizes[i] = 5 * 1024 * 1024;
DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), memDir);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setEncryptionSpi(new NoopEncryptionSpi());
cfg.setMetricExporterSpi(new NoopMetricExporterSpi());
cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());
cfg.setDataStorageConfiguration(new DataStorageConfiguration());
GridTestKernalContext cctx = new GridTestKernalContext(log, cfg);
cctx.add(new IgnitePluginProcessor(cctx, cfg, Collections.emptyList()));
cctx.add(new GridInternalSubscriptionProcessor(cctx));
cctx.add(new PerformanceStatisticsProcessor(cctx));
cctx.add(new GridEncryptionManager(cctx));
cctx.add(new GridMetricManager(cctx));
cctx.add(new GridSystemViewManager(cctx));
GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(cctx, null, null, null, new NoOpPageStoreManager(), new NoOpWALManager(), null, new IgniteCacheDatabaseSharedManager(), null, null, null, null, null, null, null, null, null, null, null, null, null);
IgniteOutClosure<CheckpointProgress> clo = () -> Mockito.mock(CheckpointProgressImpl.class);
return new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, (fullPageId, byteBuf, tag) -> {
assert false : "No page replacement (rotation with disk) should happen during the test";
}, new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
@Override
public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
}
}, () -> true, new DataRegionMetricsImpl(new DataRegionConfiguration(), cctx), PageMemoryImpl.ThrottlingPolicy.DISABLED, clo);
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class PageMemoryLazyAllocationTest method testStopNotAllocatedRegions.
/**
* @throws Exception If failed.
*/
@Test
public void testStopNotAllocatedRegions() throws Exception {
IgniteEx srv = startSrv()[0];
IgniteCacheDatabaseSharedManager srvDb = srv.context().cache().context().database();
checkMemoryAllocated(srvDb.dataRegion(EAGER_REGION).pageMemory());
checkMemoryNotAllocated(srvDb.dataRegion(LAZY_REGION).pageMemory());
stopGrid(0);
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class PageMemoryLazyAllocationTest method testEagerMemoryAllocationOnServer.
/**
* @throws Exception If failed.
*/
@Test
public void testEagerMemoryAllocationOnServer() throws Exception {
lazyAllocation = false;
IgniteEx g = startSrv()[0];
IgniteCacheDatabaseSharedManager db = g.context().cache().context().database();
checkMemoryAllocated(db.dataRegion(EAGER_REGION).pageMemory());
checkMemoryAllocated(db.dataRegion(LAZY_REGION).pageMemory());
createCacheAndPut(g);
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class WalCompactionTest method testOptimizedWalSegments.
/**
*/
@Test
public void testOptimizedWalSegments() throws Exception {
IgniteConfiguration icfg = getConfiguration(getTestIgniteInstanceName(0));
icfg.getDataStorageConfiguration().setWalSegmentSize(300_000_000);
icfg.getDataStorageConfiguration().setWalSegments(2);
IgniteEx ig = (IgniteEx) startGrid(getTestIgniteInstanceName(0), optimize(icfg), null);
ig.cluster().active(true);
IgniteCache<Integer, byte[]> cache = ig.cache(CACHE_NAME);
for (int i = 0; i < 2500; i++) {
// At least 50MB of raw data in total.
final byte[] val = new byte[20000];
val[i] = 1;
cache.put(i, val);
}
IgniteWriteAheadLogManager walMgr = ig.context().cache().context().wal();
IgniteCacheDatabaseSharedManager dbMgr = ig.context().cache().context().database();
RolloverRecord rec = new RolloverRecord();
try {
dbMgr.checkpointReadLock();
try {
walMgr.log(rec, RolloverType.NEXT_SEGMENT);
} finally {
dbMgr.checkpointReadUnlock();
}
} catch (IgniteCheckedException e) {
log.error(e.getMessage(), e);
}
long start = System.currentTimeMillis();
do {
Thread.yield();
} while (walMgr.lastArchivedSegment() < 0 && (System.currentTimeMillis() - start < 15_000));
assertTrue(System.currentTimeMillis() - start < 15_000);
String nodeFolderName = ig.context().pdsFolderResolver().resolveFolders().folderName();
stopAllGrids();
File dbDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false);
File walDir = new File(dbDir, "wal");
File archiveDir = new File(walDir, "archive");
File nodeArchiveDir = new File(archiveDir, nodeFolderName);
File walSegment = new File(nodeArchiveDir, FileDescriptor.fileName(0));
assertTrue("" + walSegment.length(), walSegment.length() < 200_000_000);
}
Aggregations