use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class IgniteWalIteratorSwitchSegmentTest method checkInvariantSwitchSegmentSize.
/**
* @param serVer WAL serializer version.
* @throws Exception If some thing failed.
*/
private void checkInvariantSwitchSegmentSize(int serVer) throws Exception {
GridKernalContext kctx = new StandaloneGridKernalContext(log, null, null) {
@Override
public IgniteCacheObjectProcessor cacheObjects() {
return new CacheObjectBinaryProcessorImpl(this);
}
};
RecordSerializer serializer = new RecordSerializerFactoryImpl(new GridCacheSharedContext<>(kctx, null, null, null, null, null, null, new IgniteCacheDatabaseSharedManager() {
@Override
public int pageSize() {
return DataStorageConfiguration.DFLT_PAGE_SIZE;
}
}, null, null, null, null, null, null, null, null, null, null, null, null, null)).createSerializer(serVer);
SwitchSegmentRecord switchSegmentRecord = new SwitchSegmentRecord();
int recordSize = serializer.size(switchSegmentRecord);
Assert.assertEquals(1, recordSize);
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class BPlusTreePageMemoryImplTest method createPageMemory.
/**
* {@inheritDoc}
*/
@Override
protected PageMemory createPageMemory() throws Exception {
long[] sizes = new long[CPUS + 1];
for (int i = 0; i < sizes.length; i++) sizes[i] = 1024 * MB / CPUS;
sizes[CPUS] = 10 * MB;
DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
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 = new IgniteOutClosure<CheckpointProgress>() {
@Override
public CheckpointProgress apply() {
return Mockito.mock(CheckpointProgressImpl.class);
}
};
PageMemory mem = new PageMemoryImpl(provider, sizes, sharedCtx, sharedCtx.pageStore(), PAGE_SIZE, (fullPageId, byteBuf, tag) -> {
assert false : "No page replacement should happen during the test";
}, new CIX3<Long, FullPageId, PageMemoryEx>() {
@Override
public void applyx(Long aLong, FullPageId fullPageId, PageMemoryEx ex) {
}
}, () -> true, new DataRegionMetricsImpl(new DataRegionConfiguration(), cctx), PageMemoryImpl.ThrottlingPolicy.DISABLED, clo);
mem.start();
return mem;
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class IgniteMetaStorageBasicTest method testDeletePartitionFromMetaStorageMigration.
/**
* Testing data migration between metastorage partitions (delete partition case)
*/
@Test
public void testDeletePartitionFromMetaStorageMigration() throws Exception {
final Map<String, byte[]> testData = new HashMap<>();
MetaStorage.PRESERVE_LEGACY_METASTORAGE_PARTITION_ID = true;
try {
IgniteEx ig = startGrid(0);
ig.cluster().active(true);
IgniteCacheDatabaseSharedManager db = ig.context().cache().context().database();
MetaStorage metaStorage = db.metaStorage();
assertNotNull(metaStorage);
db.checkpointReadLock();
try {
testData.putAll(putDataToMetaStorage(metaStorage, 1_000, 0));
} finally {
db.checkpointReadUnlock();
}
db.waitForCheckpoint("Test");
enableCheckpoints(ig, false);
db.checkpointReadLock();
try {
testData.putAll(putDataToMetaStorage(metaStorage, 1_000, 1_000));
} finally {
db.checkpointReadUnlock();
}
stopGrid(0);
MetaStorage.PRESERVE_LEGACY_METASTORAGE_PARTITION_ID = false;
IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(0));
cfg.getDataStorageConfiguration().setCheckpointFrequency(3600 * 1000L);
ig = (IgniteEx) startGrid(getTestIgniteInstanceName(0), optimize(cfg), null);
ig.cluster().active(true);
db = ig.context().cache().context().database();
metaStorage = db.metaStorage();
assertNotNull(metaStorage);
db.checkpointReadLock();
try {
testData.putAll(putDataToMetaStorage(metaStorage, 1_000, 2_000));
} finally {
db.checkpointReadUnlock();
}
db.waitForCheckpoint("Test");
stopGrid(0);
ig = startGrid(0);
ig.cluster().active(true);
db = ig.context().cache().context().database();
metaStorage = db.metaStorage();
assertNotNull(metaStorage);
db.checkpointReadLock();
try {
Collection<IgniteBiTuple<String, byte[]>> read = readTestData(testData, metaStorage);
int cnt = 0;
for (IgniteBiTuple<String, byte[]> r : read) {
byte[] test = testData.get(r.get1());
Assert.assertArrayEquals(r.get2(), test);
cnt++;
}
assertEquals(cnt, testData.size());
} finally {
db.checkpointReadUnlock();
}
} finally {
MetaStorage.PRESERVE_LEGACY_METASTORAGE_PARTITION_ID = false;
}
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class IgniteMetaStorageBasicTest method testMetaStorageMassivePutRandom.
/**
*/
@Test
public void testMetaStorageMassivePutRandom() throws Exception {
IgniteEx ig = startGrid(0);
ig.cluster().active(true);
IgniteCacheDatabaseSharedManager db = ig.context().cache().context().database();
MetaStorage metaStorage = db.metaStorage();
assertNotNull(metaStorage);
Random rnd = new Random();
db.checkpointReadLock();
int size;
try {
for (int i = 0; i < 50_000; i++) {
size = 100 + rnd.nextInt(9000);
String key = "TEST_KEY_" + (i % 2_000);
byte[] arr = new byte[size];
rnd.nextBytes(arr);
metaStorage.remove(key);
metaStorage.writeRaw(key, arr);
}
} finally {
db.checkpointReadUnlock();
}
stopGrid();
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class IgniteMetaStorageBasicTest method testMetaStorageMassivePutFixed.
/**
*/
@Test
public void testMetaStorageMassivePutFixed() throws Exception {
IgniteEx ig = startGrid(0);
ig.cluster().active(true);
IgniteCacheDatabaseSharedManager db = ig.context().cache().context().database();
MetaStorage metaStorage = db.metaStorage();
assertNotNull(metaStorage);
Random rnd = new Random();
db.checkpointReadLock();
int size;
try {
for (int i = 0; i < 10_000; i++) {
size = rnd.nextBoolean() ? 3500 : 2 * 3500;
String key = "TEST_KEY_" + (i % 1000);
byte[] arr = new byte[size];
rnd.nextBytes(arr);
metaStorage.remove(key);
metaStorage.writeRaw(key, arr);
}
} finally {
db.checkpointReadUnlock();
}
}
Aggregations