Search in sources :

Example 1 with AbstractTestPluginProvider

use of org.apache.ignite.plugin.AbstractTestPluginProvider in project ignite by apache.

the class CdcCacheVersionTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setDataStorageConfiguration(new DataStorageConfiguration().setCdcEnabled(true).setWalForceArchiveTimeout(WAL_ARCHIVE_TIMEOUT).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
    cfg.setPluginProviders(new AbstractTestPluginProvider() {

        @Override
        public String name() {
            return "ConflictResolverProvider";
        }

        @Override
        public CachePluginProvider createCacheProvider(CachePluginContext ctx) {
            if (!ctx.igniteCacheConfiguration().getName().equals(DEFAULT_CACHE_NAME))
                return null;
            return new AbstractCachePluginProvider() {

                @Override
                @Nullable
                public Object createComponent(Class cls) {
                    if (cls != CacheConflictResolutionManager.class || conflictResolutionMgrSupplier == null)
                        return null;
                    return new TestCacheConflictResolutionManager<>();
                }
            };
        }

        @Override
        @Nullable
        public <T> T createComponent(PluginContext ctx, Class<T> cls) {
            if (IgniteWriteAheadLogManager.class.equals(cls))
                return (T) walProvider.apply(((IgniteEx) ctx.grid()).context());
            return null;
        }
    });
    return cfg;
}
Also used : CachePluginContext(org.apache.ignite.plugin.CachePluginContext) PluginContext(org.apache.ignite.plugin.PluginContext) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) CachePluginContext(org.apache.ignite.plugin.CachePluginContext) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) AbstractTestPluginProvider(org.apache.ignite.plugin.AbstractTestPluginProvider) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AbstractCachePluginProvider(org.apache.ignite.plugin.AbstractCachePluginProvider) CachePluginProvider(org.apache.ignite.plugin.CachePluginProvider) IgniteEx(org.apache.ignite.internal.IgniteEx) AbstractCachePluginProvider(org.apache.ignite.plugin.AbstractCachePluginProvider) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with AbstractTestPluginProvider

use of org.apache.ignite.plugin.AbstractTestPluginProvider in project ignite by apache.

the class IgnitePdsCheckpointMapSnapshotTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String name) throws Exception {
    IgniteConfiguration configuration = super.getConfiguration(name);
    configuration.setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)).setCheckpointFrequency(TimeUnit.HOURS.toMillis(1)));
    // Plugin that creates a WAL manager that counts replays
    configuration.setPluginProviders(new AbstractTestPluginProvider() {

        /**
         * {@inheritDoc}
         */
        @Override
        public String name() {
            return "testPlugin";
        }

        /**
         * {@inheritDoc}
         */
        @Override
        @Nullable
        public <T> T createComponent(PluginContext ctx, Class<T> cls) {
            if (IgniteWriteAheadLogManager.class.equals(cls))
                return (T) new TestFileWriteAheadLogManager(((IgniteEx) ctx.grid()).context());
            return null;
        }
    });
    return configuration;
}
Also used : PluginContext(org.apache.ignite.plugin.PluginContext) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) AbstractTestPluginProvider(org.apache.ignite.plugin.AbstractTestPluginProvider) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)2 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)2 AbstractTestPluginProvider (org.apache.ignite.plugin.AbstractTestPluginProvider)2 PluginContext (org.apache.ignite.plugin.PluginContext)2 Nullable (org.jetbrains.annotations.Nullable)2 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)1 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)1 AbstractCachePluginProvider (org.apache.ignite.plugin.AbstractCachePluginProvider)1 CachePluginContext (org.apache.ignite.plugin.CachePluginContext)1 CachePluginProvider (org.apache.ignite.plugin.CachePluginProvider)1