Search in sources :

Example 1 with GridCachePluginContext

use of org.apache.ignite.internal.GridCachePluginContext 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)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)1 GridCachePluginContext (org.apache.ignite.internal.GridCachePluginContext)1 CachePluginContext (org.apache.ignite.plugin.CachePluginContext)1 CachePluginProvider (org.apache.ignite.plugin.CachePluginProvider)1 PluginProvider (org.apache.ignite.plugin.PluginProvider)1