Search in sources :

Example 1 with MetastorageLifecycleListener

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

the class DistributedMetaStorageImpl method start.

/**
 * {@inheritDoc}
 * <br/>
 * Create all required listeners.
 */
@Override
public void start() throws IgniteCheckedException {
    if (!isPersistenceEnabled)
        ver = INITIAL_VERSION;
    else {
        isp.registerMetastorageListener(new MetastorageLifecycleListener() {

            /**
             * {@inheritDoc}
             */
            @Override
            public void onReadyForRead(ReadOnlyMetastorage metastorage) throws IgniteCheckedException {
                onMetaStorageReadyForRead(metastorage);
            }

            /**
             * {@inheritDoc}
             */
            @Override
            public void onReadyForReadWrite(ReadWriteMetastorage metastorage) {
                onMetaStorageReadyForWrite(metastorage);
            }
        });
    }
    GridDiscoveryManager discovery = ctx.discovery();
    discovery.setCustomEventListener(DistributedMetaStorageUpdateMessage.class, this::onUpdateMessage);
    discovery.setCustomEventListener(DistributedMetaStorageUpdateAckMessage.class, this::onAckMessage);
}
Also used : ReadWriteMetastorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadWriteMetastorage) MetastorageLifecycleListener(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener) DistributedMetastorageLifecycleListener(org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ReadOnlyMetastorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadOnlyMetastorage)

Example 2 with MetastorageLifecycleListener

use of org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener 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 3 with MetastorageLifecycleListener

use of org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener 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)

Aggregations

MetastorageLifecycleListener (org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener)3 GridSystemViewManager (org.apache.ignite.internal.managers.systemview.GridSystemViewManager)2 IgniteCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)2 ReadWriteMetaStorageMock (org.apache.ignite.internal.processors.metastorage.persistence.ReadWriteMetaStorageMock)2 GridInternalSubscriptionProcessor (org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor)2 ArrayList (java.util.ArrayList)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 GridDiscoveryManager (org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)1 ReadOnlyMetastorage (org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadOnlyMetastorage)1 ReadWriteMetastorage (org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadWriteMetastorage)1 DistributedMetastorageLifecycleListener (org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener)1 GridTestLog4jLogger (org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger)1