Search in sources :

Example 36 with IgniteCacheDatabaseSharedManager

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

the class IgniteStatisticsRepositoryTest method parameters.

/**
 * Parameters: boolean, store.
 * boolean - is persistence store;
 * store - store instance.
 */
@Parameterized.Parameters(name = "persist={0}")
public static List<Object[]> parameters() throws IgniteCheckedException {
    ArrayList<Object[]> params = new ArrayList<>();
    // Without persistence
    IgniteStatisticsStore storeInMemory = new IgniteStatisticsInMemoryStoreImpl(IgniteStatisticsRepositoryTest::getLogger);
    GridSystemViewManager sysViewMgr = Mockito.mock(GridSystemViewManager.class);
    IgniteStatisticsRepository inMemRepo = new IgniteStatisticsRepository(storeInMemory, sysViewMgr, null, IgniteStatisticsRepositoryTest::getLogger);
    params.add(new Object[] { false, inMemRepo });
    // With persistence
    MetastorageLifecycleListener[] lsnr = new MetastorageLifecycleListener[1];
    GridInternalSubscriptionProcessor subscriptionProcessor = Mockito.mock(GridInternalSubscriptionProcessor.class);
    Mockito.doAnswer(invocation -> lsnr[0] = invocation.getArgument(0)).when(subscriptionProcessor).registerMetastorageListener(Mockito.any(MetastorageLifecycleListener.class));
    IgniteCacheDatabaseSharedManager db = Mockito.mock(IgniteCacheDatabaseSharedManager.class);
    IgniteStatisticsRepository[] statsRepos = new IgniteStatisticsRepository[1];
    IgniteStatisticsStore storePersistent = new IgniteStatisticsPersistenceStoreImpl(subscriptionProcessor, db, IgniteStatisticsRepositoryTest::getLogger);
    IgniteStatisticsHelper helper = Mockito.mock(IgniteStatisticsHelper.class);
    statsRepos[0] = new IgniteStatisticsRepository(storePersistent, sysViewMgr, helper, IgniteStatisticsRepositoryTest::getLogger);
    ReadWriteMetaStorageMock metastorage = new ReadWriteMetaStorageMock();
    lsnr[0].onReadyForReadWrite(metastorage);
    params.add(new Object[] { true, statsRepos[0] });
    return params;
}
Also used : MetastorageLifecycleListener(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) ArrayList(java.util.ArrayList) ReadWriteMetaStorageMock(org.apache.ignite.internal.processors.metastorage.persistence.ReadWriteMetaStorageMock) GridSystemViewManager(org.apache.ignite.internal.managers.systemview.GridSystemViewManager) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 37 with IgniteCacheDatabaseSharedManager

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

the class StatisticsStorageRestartTest method testRestart.

/**
 * Save statistics to metastore throw one statistics metastore and then attach new statistics store to the same
 * metastorage:
 *
 * 1) create metastorage mock and pass it to statistics storage.
 * 2) save partition level statistics.
 * 3) create new statistics storage on the top of the same metastorage mock
 * 4) check that statistics storage will call statistics repository to cache partition level statistics
 * 5) check that statistics storage will read the same partition statistics
 *
 * @throws IgniteCheckedException In case of errors.
 */
@Test
public void testRestart() throws IgniteCheckedException {
    statStore.onReadyForReadWrite(metastorage);
    statStore.saveLocalPartitionStatistics(k1, stat1_1);
    statStore.replaceLocalPartitionsStatistics(k2, Arrays.asList(stat2_2, stat2_3));
    assertEquals(1, statStore.getLocalPartitionsStatistics(k1).size());
    assertEquals(stat1_1, statStore.getLocalPartitionStatistics(k1, 1));
    assertEquals(2, statStore.getLocalPartitionsStatistics(k2).size());
    assertEquals(stat2_2, statStore.getLocalPartitionStatistics(k2, 2));
    assertEquals(stat2_3, statStore.getLocalPartitionStatistics(k2, 3));
    IgniteStatisticsPersistenceStoreImpl statStore2 = new IgniteStatisticsPersistenceStoreImpl(subscriptionProcessor, new IgniteCacheDatabaseSharedManager() {
    }, cls -> log);
    statStore2.onReadyForReadWrite(metastorage);
    assertEquals(1, statStore2.getLocalPartitionsStatistics(k1).size());
    assertEquals(stat1_1, statStore2.getLocalPartitionStatistics(k1, 1));
    assertEquals(2, statStore2.getLocalPartitionsStatistics(k2).size());
    assertEquals(stat2_2, statStore2.getLocalPartitionStatistics(k2, 2));
    assertEquals(stat2_3, statStore2.getLocalPartitionStatistics(k2, 3));
}
Also used : IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) Test(org.junit.Test)

Example 38 with IgniteCacheDatabaseSharedManager

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

the class StatisticsStorageRestartTest method beforeTest.

/**
 * {@inheritDoc}
 */
@Override
public void beforeTest() {
    subscriptionProcessor = Mockito.mock(GridInternalSubscriptionProcessor.class);
    metastorage = new ReadWriteMetaStorageMock();
    statStore = new IgniteStatisticsPersistenceStoreImpl(subscriptionProcessor, new IgniteCacheDatabaseSharedManager() {
    }, cls -> log);
}
Also used : IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) Mockito(org.mockito.Mockito) Arrays(java.util.Arrays) ReadWriteMetaStorageMock(org.apache.ignite.internal.processors.metastorage.persistence.ReadWriteMetaStorageMock) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Test(org.junit.Test) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) ReadWriteMetaStorageMock(org.apache.ignite.internal.processors.metastorage.persistence.ReadWriteMetaStorageMock) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 39 with IgniteCacheDatabaseSharedManager

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

the class StatisticsStorageUnitTest method parameters.

/**
 * @return Test parameters.
 */
@Parameterized.Parameters(name = "cacheMode={0}")
public static Collection<Object[]> parameters() throws IgniteCheckedException {
    MetastorageLifecycleListener[] lsnr = new MetastorageLifecycleListener[1];
    IgniteStatisticsHelper helper = Mockito.mock(IgniteStatisticsHelper.class);
    GridInternalSubscriptionProcessor subscriptionProcessor = Mockito.mock(GridInternalSubscriptionProcessor.class);
    Mockito.doAnswer(invocation -> lsnr[0] = invocation.getArgument(0)).when(subscriptionProcessor).registerMetastorageListener(Mockito.any(MetastorageLifecycleListener.class));
    IgniteStatisticsStore inMemoryStore = new IgniteStatisticsInMemoryStoreImpl(cls -> log);
    GridSystemViewManager sysViewMgr = Mockito.mock(GridSystemViewManager.class);
    IgniteStatisticsRepository statsRepos = new IgniteStatisticsRepository(inMemoryStore, sysViewMgr, helper, cls -> log);
    IgniteCacheDatabaseSharedManager dbMgr = new IgniteCacheDatabaseSharedManager();
    IgniteStatisticsPersistenceStoreImpl persStore = new IgniteStatisticsPersistenceStoreImpl(subscriptionProcessor, dbMgr, cls -> new GridTestLog4jLogger());
    ReadWriteMetaStorageMock metastorage = new ReadWriteMetaStorageMock();
    lsnr[0].onReadyForReadWrite(metastorage);
    return Arrays.asList(new Object[][] { { "IgniteStatisticsInMemoryStoreImpl", inMemoryStore }, { "IgniteStatisticsPersistenceStoreImpl", persStore } });
}
Also used : MetastorageLifecycleListener(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) GridSystemViewManager(org.apache.ignite.internal.managers.systemview.GridSystemViewManager) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) ReadWriteMetaStorageMock(org.apache.ignite.internal.processors.metastorage.persistence.ReadWriteMetaStorageMock)

Example 40 with IgniteCacheDatabaseSharedManager

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

the class StatisticsClearTest method testRestartVersion.

/**
 * Apply function to metastorage and restart node to verify that it will lead to metadata removal.
 *
 * @param verCorruptor statistics version corruptor.
 * @throws Exception In case of errors.
 */
private void testRestartVersion(Consumer<MetaStorage> verCorruptor) throws Exception {
    IgniteCacheDatabaseSharedManager db = grid(0).context().cache().context().database();
    checkStatisticsExist(db, TIMEOUT);
    db.checkpointReadLock();
    try {
        verCorruptor.accept(db.metaStorage());
    } finally {
        db.checkpointReadUnlock();
    }
    stopGrid(0);
    startGrid(0);
    grid(0).cluster().state(ClusterState.ACTIVE);
    db = grid(0).context().cache().context().database();
    db.checkpointReadLock();
    try {
        assertEquals(IgniteStatisticsPersistenceStoreImpl.VERSION, db.metaStorage().read("stats.version"));
    } finally {
        db.checkpointReadUnlock();
    }
    db = grid(0).context().cache().context().database();
    checkStatisticsExist(db, TIMEOUT);
}
Also used : 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