Search in sources :

Example 1 with CachePluginProvider

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

the class ClusterCachesInfo method onKernalStart.

/**
 * @param checkConsistency {@code True} if need check cache configurations consistency.
 * @throws IgniteCheckedException If failed.
 */
public void onKernalStart(boolean checkConsistency) throws IgniteCheckedException {
    if (gridData != null && gridData.conflictErr != null)
        throw new IgniteCheckedException(gridData.conflictErr);
    if (gridData != null && gridData.joinDiscoData != null) {
        CacheJoinNodeDiscoveryData joinDiscoData = gridData.joinDiscoData;
        for (CacheJoinNodeDiscoveryData.CacheInfo locCacheInfo : joinDiscoData.caches().values()) {
            CacheConfiguration locCfg = locCacheInfo.cacheData().config();
            CacheData cacheData = gridData.gridData.caches().get(locCfg.getName());
            if (cacheData != null) {
                if (!F.eq(cacheData.sql(), locCacheInfo.sql())) {
                    throw new IgniteCheckedException("Cache configuration mismatch (local cache was created " + "via " + (locCacheInfo.sql() ? "CREATE TABLE" : "Ignite API") + ", while remote cache " + "was created via " + (cacheData.sql() ? "CREATE TABLE" : "Ignite API") + "): " + locCacheInfo.cacheData().config().getName());
                }
                if (checkConsistency) {
                    checkCache(locCacheInfo, cacheData, cacheData.receivedFrom());
                    ClusterNode rmt = ctx.discovery().node(cacheData.receivedFrom());
                    if (rmt == null) {
                        for (ClusterNode node : ctx.discovery().localJoin().discoCache().serverNodes()) {
                            if (!node.isLocal() && ctx.discovery().cacheAffinityNode(node, locCfg.getName())) {
                                rmt = node;
                                break;
                            }
                        }
                    }
                    if (rmt != null) {
                        for (PluginProvider p : ctx.plugins().allProviders()) {
                            CachePluginContext pluginCtx = new GridCachePluginContext(ctx, locCfg);
                            CachePluginProvider provider = p.createCacheProvider(pluginCtx);
                            if (provider != null)
                                provider.validateRemote(locCfg, cacheData.cacheConfiguration(), rmt);
                        }
                    }
                }
            }
            if (checkConsistency)
                validateStartCacheConfiguration(locCfg);
        }
    }
    gridData = null;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCachePluginContext(org.apache.ignite.internal.GridCachePluginContext) CachePluginProvider(org.apache.ignite.plugin.CachePluginProvider) GridCachePluginContext(org.apache.ignite.internal.GridCachePluginContext) CachePluginContext(org.apache.ignite.plugin.CachePluginContext) CachePluginProvider(org.apache.ignite.plugin.CachePluginProvider) PluginProvider(org.apache.ignite.plugin.PluginProvider) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 2 with CachePluginProvider

use of org.apache.ignite.plugin.CachePluginProvider 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 3 with CachePluginProvider

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

the class CachePluginManager method validateRemotes.

/**
 * Checks that remote caches has configuration compatible with the local.
 *
 * @param rmtCfg Remote cache configuration.
 * @param rmtNode Remote rmtNode.
 * @throws IgniteCheckedException If failed.
 */
public void validateRemotes(CacheConfiguration rmtCfg, ClusterNode rmtNode) throws IgniteCheckedException {
    for (Map.Entry<CachePluginContext, CachePluginProvider> entry : providersMap.entrySet()) {
        CachePluginContext cctx = entry.getKey();
        CachePluginProvider provider = entry.getValue();
        provider.validateRemote(cctx.igniteCacheConfiguration(), rmtCfg, rmtNode);
    }
}
Also used : CachePluginProvider(org.apache.ignite.plugin.CachePluginProvider) GridCachePluginContext(org.apache.ignite.internal.GridCachePluginContext) CachePluginContext(org.apache.ignite.plugin.CachePluginContext) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

CachePluginContext (org.apache.ignite.plugin.CachePluginContext)3 CachePluginProvider (org.apache.ignite.plugin.CachePluginProvider)3 GridCachePluginContext (org.apache.ignite.internal.GridCachePluginContext)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)1 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 AbstractTestPluginProvider (org.apache.ignite.plugin.AbstractTestPluginProvider)1 PluginContext (org.apache.ignite.plugin.PluginContext)1 PluginProvider (org.apache.ignite.plugin.PluginProvider)1