Search in sources :

Example 16 with IgniteCacheDatabaseSharedManager

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);
}
Also used : SwitchSegmentRecord(org.apache.ignite.internal.pagemem.wal.record.SwitchSegmentRecord) CacheObjectBinaryProcessorImpl(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl) RecordSerializerFactoryImpl(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl) GridKernalContext(org.apache.ignite.internal.GridKernalContext) StandaloneGridKernalContext(org.apache.ignite.internal.processors.cache.persistence.wal.reader.StandaloneGridKernalContext) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) RecordSerializer(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer) StandaloneGridKernalContext(org.apache.ignite.internal.processors.cache.persistence.wal.reader.StandaloneGridKernalContext) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 17 with IgniteCacheDatabaseSharedManager

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;
}
Also used : 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) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) 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) CacheDiagnosticManager(org.apache.ignite.internal.processors.cache.CacheDiagnosticManager) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) IgniteOutClosure(org.apache.ignite.lang.IgniteOutClosure) 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) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridSystemViewManager(org.apache.ignite.internal.managers.systemview.GridSystemViewManager) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 18 with IgniteCacheDatabaseSharedManager

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;
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) HashMap(java.util.HashMap) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 19 with IgniteCacheDatabaseSharedManager

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();
}
Also used : Random(java.util.Random) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 20 with IgniteCacheDatabaseSharedManager

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();
    }
}
Also used : Random(java.util.Random) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

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