Search in sources :

Example 6 with CacheStoreManager

use of org.apache.ignite.internal.processors.cache.store.CacheStoreManager in project ignite by apache.

the class GridCacheProcessor method createCacheContext.

/**
 * @param cfg Cache configuration to use to create cache.
 * @param grp Cache group.
 * @param pluginMgr Cache plugin manager.
 * @param desc Cache descriptor.
 * @param locStartTopVer Current topology version.
 * @param cacheObjCtx Cache object context.
 * @param affNode {@code True} if local node affinity node.
 * @param updatesAllowed Updates allowed flag.
 * @param disabledAfterStart If true, then we will discard restarting state from proxies. If false then we will
 * change state of proxies to restarting
 * @return Cache context.
 * @throws IgniteCheckedException If failed to create cache.
 */
private GridCacheContext<?, ?> createCacheContext(CacheConfiguration<?, ?> cfg, CacheGroupContext grp, @Nullable CachePluginManager pluginMgr, DynamicCacheDescriptor desc, AffinityTopologyVersion locStartTopVer, CacheObjectContext cacheObjCtx, boolean affNode, boolean updatesAllowed, boolean disabledAfterStart, boolean recoveryMode) throws IgniteCheckedException {
    assert cfg != null;
    if (cfg.getCacheStoreFactory() instanceof GridCacheLoaderWriterStoreFactory) {
        GridCacheLoaderWriterStoreFactory factory = (GridCacheLoaderWriterStoreFactory) cfg.getCacheStoreFactory();
        prepare(cfg, factory.loaderFactory(), false);
        prepare(cfg, factory.writerFactory(), false);
    } else
        prepare(cfg, cfg.getCacheStoreFactory(), false);
    CacheStore cfgStore = cfg.getCacheStoreFactory() != null ? cfg.getCacheStoreFactory().create() : null;
    ValidationOnNodeJoinUtils.validate(ctx.config(), cfg, desc.cacheType(), cfgStore, ctx, log, (x, y) -> {
        try {
            assertParameter(x, y);
        } catch (IgniteCheckedException ex) {
            return ex;
        }
        return null;
    });
    if (pluginMgr == null)
        pluginMgr = new CachePluginManager(ctx, cfg);
    pluginMgr.validate();
    if (!recoveryMode && cfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT && grp.affinityNode())
        sharedCtx.coordinators().ensureStarted();
    sharedCtx.jta().registerCache(cfg);
    // Skip suggestions for internal caches.
    if (desc.cacheType().userCache())
        suggestOptimizations(cfg, cfgStore != null);
    Collection<Object> toPrepare = new ArrayList<>();
    if (cfgStore instanceof GridCacheLoaderWriterStore) {
        toPrepare.add(((GridCacheLoaderWriterStore) cfgStore).loader());
        toPrepare.add(((GridCacheLoaderWriterStore) cfgStore).writer());
    } else
        toPrepare.add(cfgStore);
    prepare(cfg, toPrepare);
    U.startLifecycleAware(lifecycleAwares(grp, cfg, cfgStore));
    boolean nearEnabled = GridCacheUtils.isNearEnabled(cfg);
    CacheCompressionManager compressMgr = new CacheCompressionManager();
    GridCacheAffinityManager affMgr = new GridCacheAffinityManager();
    GridCacheEventManager evtMgr = new GridCacheEventManager();
    CacheEvictionManager evictMgr = (nearEnabled || cfg.isOnheapCacheEnabled()) ? new GridCacheEvictionManager() : new CacheOffheapEvictionManager();
    GridCacheQueryManager qryMgr = cfg.getCacheMode() == LOCAL ? new GridCacheLocalQueryManager() : new GridCacheDistributedQueryManager();
    CacheContinuousQueryManager contQryMgr = new CacheContinuousQueryManager();
    CacheDataStructuresManager dataStructuresMgr = new CacheDataStructuresManager();
    GridCacheTtlManager ttlMgr = new GridCacheTtlManager();
    CacheConflictResolutionManager rslvrMgr = pluginMgr.createComponent(CacheConflictResolutionManager.class);
    GridCacheDrManager drMgr = pluginMgr.createComponent(GridCacheDrManager.class);
    CacheStoreManager storeMgr = pluginMgr.createComponent(CacheStoreManager.class);
    PlatformCacheManager platformMgr = ctx.platform().cacheManager();
    if (cfgStore == null)
        storeMgr.initialize(cfgStore, sesHolders);
    else
        initializationProtector.protect(cfgStore, () -> storeMgr.initialize(cfgStore, sesHolders));
    GridCacheContext<?, ?> cacheCtx = new GridCacheContext(ctx, sharedCtx, cfg, grp, desc.cacheType(), locStartTopVer, desc.deploymentId(), affNode, updatesAllowed, desc.cacheConfiguration().isStatisticsEnabled(), recoveryMode, /*
             * Managers in starting order!
             * ===========================
             */
    compressMgr, evtMgr, storeMgr, evictMgr, qryMgr, contQryMgr, dataStructuresMgr, ttlMgr, drMgr, rslvrMgr, pluginMgr, affMgr, platformMgr);
    cacheCtx.cacheObjectContext(cacheObjCtx);
    GridCacheAdapter cache = null;
    switch(cfg.getCacheMode()) {
        case LOCAL:
            {
                switch(cfg.getAtomicityMode()) {
                    case TRANSACTIONAL:
                    case TRANSACTIONAL_SNAPSHOT:
                        {
                            cache = new GridLocalCache(cacheCtx);
                            break;
                        }
                    case ATOMIC:
                        {
                            cache = new GridLocalAtomicCache(cacheCtx);
                            break;
                        }
                    default:
                        {
                            assert false : "Invalid cache atomicity mode: " + cfg.getAtomicityMode();
                        }
                }
                break;
            }
        case PARTITIONED:
        case REPLICATED:
            {
                if (nearEnabled) {
                    switch(cfg.getAtomicityMode()) {
                        case TRANSACTIONAL:
                        case TRANSACTIONAL_SNAPSHOT:
                            {
                                cache = new GridNearTransactionalCache(cacheCtx);
                                break;
                            }
                        case ATOMIC:
                            {
                                cache = new GridNearAtomicCache(cacheCtx);
                                break;
                            }
                        default:
                            {
                                assert false : "Invalid cache atomicity mode: " + cfg.getAtomicityMode();
                            }
                    }
                } else {
                    switch(cfg.getAtomicityMode()) {
                        case TRANSACTIONAL:
                        case TRANSACTIONAL_SNAPSHOT:
                            {
                                cache = cacheCtx.affinityNode() ? new GridDhtColocatedCache(cacheCtx) : new GridDhtColocatedCache(cacheCtx, new GridNoStorageCacheMap());
                                break;
                            }
                        case ATOMIC:
                            {
                                cache = cacheCtx.affinityNode() ? new GridDhtAtomicCache(cacheCtx) : new GridDhtAtomicCache(cacheCtx, new GridNoStorageCacheMap());
                                break;
                            }
                        default:
                            {
                                assert false : "Invalid cache atomicity mode: " + cfg.getAtomicityMode();
                            }
                    }
                }
                break;
            }
        default:
            {
                assert false : "Invalid cache mode: " + cfg.getCacheMode();
            }
    }
    cache.active(!disabledAfterStart);
    cacheCtx.cache(cache);
    GridCacheContext<?, ?> ret = cacheCtx;
    /*
         * Create DHT cache.
         * ================
         */
    if (cfg.getCacheMode() != LOCAL && nearEnabled) {
        /*
             * Specifically don't create the following managers
             * here and reuse the one from Near cache:
             * 1. GridCacheVersionManager
             * 2. GridCacheIoManager
             * 3. GridCacheDeploymentManager
             * 4. GridCacheQueryManager (note, that we start it for DHT cache though).
             * 5. CacheContinuousQueryManager (note, that we start it for DHT cache though).
             * 6. GridCacheDgcManager
             * 7. GridCacheTtlManager.
             * 8. PlatformCacheManager.
             * ===============================================
             */
        evictMgr = cfg.isOnheapCacheEnabled() ? new GridCacheEvictionManager() : new CacheOffheapEvictionManager();
        evtMgr = new GridCacheEventManager();
        pluginMgr = new CachePluginManager(ctx, cfg);
        drMgr = pluginMgr.createComponent(GridCacheDrManager.class);
        cacheCtx = new GridCacheContext(ctx, sharedCtx, cfg, grp, desc.cacheType(), locStartTopVer, desc.deploymentId(), affNode, true, desc.cacheConfiguration().isStatisticsEnabled(), recoveryMode, /*
                 * Managers in starting order!
                 * ===========================
                 */
        compressMgr, evtMgr, storeMgr, evictMgr, qryMgr, contQryMgr, dataStructuresMgr, ttlMgr, drMgr, rslvrMgr, pluginMgr, affMgr, platformMgr);
        cacheCtx.cacheObjectContext(cacheObjCtx);
        GridDhtCacheAdapter dht = null;
        switch(cfg.getAtomicityMode()) {
            case TRANSACTIONAL:
            case TRANSACTIONAL_SNAPSHOT:
                {
                    assert cache instanceof GridNearTransactionalCache;
                    GridNearTransactionalCache near = (GridNearTransactionalCache) cache;
                    GridDhtCache dhtCache = cacheCtx.affinityNode() ? new GridDhtCache(cacheCtx) : new GridDhtCache(cacheCtx, new GridNoStorageCacheMap());
                    dhtCache.near(near);
                    near.dht(dhtCache);
                    dht = dhtCache;
                    break;
                }
            case ATOMIC:
                {
                    assert cache instanceof GridNearAtomicCache;
                    GridNearAtomicCache near = (GridNearAtomicCache) cache;
                    GridDhtAtomicCache dhtCache = cacheCtx.affinityNode() ? new GridDhtAtomicCache(cacheCtx) : new GridDhtAtomicCache(cacheCtx, new GridNoStorageCacheMap());
                    dhtCache.near(near);
                    near.dht(dhtCache);
                    dht = dhtCache;
                    break;
                }
            default:
                {
                    assert false : "Invalid cache atomicity mode: " + cfg.getAtomicityMode();
                }
        }
        cacheCtx.cache(dht);
    }
    if (!CU.isUtilityCache(cache.name()) && !CU.isSystemCache(cache.name())) {
        registerMbean(cache.localMxBean(), cache.name(), false);
        registerMbean(cache.clusterMxBean(), cache.name(), false);
    }
    return ret;
}
Also used : GridDhtCacheAdapter(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter) ArrayList(java.util.ArrayList) PlatformCacheManager(org.apache.ignite.internal.processors.platform.cache.PlatformCacheManager) CacheDataStructuresManager(org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager) CacheStoreManager(org.apache.ignite.internal.processors.cache.store.CacheStoreManager) CacheContinuousQueryManager(org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager) GridLocalAtomicCache(org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache) GridNearAtomicCache(org.apache.ignite.internal.processors.cache.distributed.near.GridNearAtomicCache) GridDhtColocatedCache(org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCacheDistributedQueryManager(org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager) CachePluginManager(org.apache.ignite.internal.processors.plugin.CachePluginManager) GridLocalCache(org.apache.ignite.internal.processors.cache.local.GridLocalCache) GridCacheLocalQueryManager(org.apache.ignite.internal.processors.cache.query.GridCacheLocalQueryManager) GridDhtCache(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCache) GridDhtAtomicCache(org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache) GridNearTransactionalCache(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache) GridCacheQueryManager(org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager) CacheStore(org.apache.ignite.cache.store.CacheStore) GridCacheDrManager(org.apache.ignite.internal.processors.cache.dr.GridCacheDrManager)

Example 7 with CacheStoreManager

use of org.apache.ignite.internal.processors.cache.store.CacheStoreManager in project ignite by apache.

the class GridCacheSharedContext method removeCacheContext.

/**
 * @param cacheCtx Cache context to remove.
 */
void removeCacheContext(GridCacheContext cacheCtx) {
    int cacheId = cacheCtx.cacheId();
    ctxMap.remove(cacheId, cacheCtx);
    CacheStoreManager mgr = cacheCtx.store();
    if (mgr.configured() && mgr.isLocal())
        locStoreCnt.decrementAndGet();
    // Safely clean up the message listeners.
    ioMgr.removeCacheHandlers(cacheId);
}
Also used : CacheStoreManager(org.apache.ignite.internal.processors.cache.store.CacheStoreManager)

Example 8 with CacheStoreManager

use of org.apache.ignite.internal.processors.cache.store.CacheStoreManager in project ignite by apache.

the class GridCacheProcessor method createCache.

/**
 * @param cfg Cache configuration to use to create cache.
 * @param grp Cache group.
 * @param pluginMgr Cache plugin manager.
 * @param desc Cache descriptor.
 * @param locStartTopVer Current topology version.
 * @param cacheObjCtx Cache object context.
 * @param affNode {@code True} if local node affinity node.
 * @param updatesAllowed Updates allowed flag.
 * @param disabledAfterStart If true, then we will discard restarting state from proxies. If false then we will
 * change state of proxies to restarting
 * @return Cache context.
 * @throws IgniteCheckedException If failed to create cache.
 */
private GridCacheContext createCache(CacheConfiguration<?, ?> cfg, CacheGroupContext grp, @Nullable CachePluginManager pluginMgr, DynamicCacheDescriptor desc, AffinityTopologyVersion locStartTopVer, CacheObjectContext cacheObjCtx, boolean affNode, boolean updatesAllowed, boolean disabledAfterStart) throws IgniteCheckedException {
    assert cfg != null;
    if (cfg.getCacheStoreFactory() instanceof GridCacheLoaderWriterStoreFactory) {
        GridCacheLoaderWriterStoreFactory factory = (GridCacheLoaderWriterStoreFactory) cfg.getCacheStoreFactory();
        prepare(cfg, factory.loaderFactory(), false);
        prepare(cfg, factory.writerFactory(), false);
    } else
        prepare(cfg, cfg.getCacheStoreFactory(), false);
    CacheStore cfgStore = cfg.getCacheStoreFactory() != null ? cfg.getCacheStoreFactory().create() : null;
    validate(ctx.config(), cfg, desc.cacheType(), cfgStore);
    if (pluginMgr == null)
        pluginMgr = new CachePluginManager(ctx, cfg);
    pluginMgr.validate();
    sharedCtx.jta().registerCache(cfg);
    // Skip suggestions for internal caches.
    if (desc.cacheType().userCache())
        suggestOptimizations(cfg, cfgStore != null);
    Collection<Object> toPrepare = new ArrayList<>();
    if (cfgStore instanceof GridCacheLoaderWriterStore) {
        toPrepare.add(((GridCacheLoaderWriterStore) cfgStore).loader());
        toPrepare.add(((GridCacheLoaderWriterStore) cfgStore).writer());
    } else
        toPrepare.add(cfgStore);
    prepare(cfg, toPrepare);
    U.startLifecycleAware(lifecycleAwares(grp, cfg, cfgStore));
    boolean nearEnabled = GridCacheUtils.isNearEnabled(cfg);
    GridCacheAffinityManager affMgr = new GridCacheAffinityManager();
    GridCacheEventManager evtMgr = new GridCacheEventManager();
    CacheEvictionManager evictMgr = (nearEnabled || cfg.isOnheapCacheEnabled()) ? new GridCacheEvictionManager() : new CacheOffheapEvictionManager();
    GridCacheQueryManager qryMgr = queryManager(cfg);
    CacheContinuousQueryManager contQryMgr = new CacheContinuousQueryManager();
    CacheDataStructuresManager dataStructuresMgr = new CacheDataStructuresManager();
    GridCacheTtlManager ttlMgr = new GridCacheTtlManager();
    CacheConflictResolutionManager rslvrMgr = pluginMgr.createComponent(CacheConflictResolutionManager.class);
    GridCacheDrManager drMgr = pluginMgr.createComponent(GridCacheDrManager.class);
    CacheStoreManager storeMgr = pluginMgr.createComponent(CacheStoreManager.class);
    storeMgr.initialize(cfgStore, sesHolders);
    GridCacheContext<?, ?> cacheCtx = new GridCacheContext(ctx, sharedCtx, cfg, grp, desc.cacheType(), locStartTopVer, affNode, updatesAllowed, /*
             * Managers in starting order!
             * ===========================
             */
    evtMgr, storeMgr, evictMgr, qryMgr, contQryMgr, dataStructuresMgr, ttlMgr, drMgr, rslvrMgr, pluginMgr, affMgr);
    cacheCtx.statisticsEnabled(desc.cacheConfiguration().isStatisticsEnabled());
    cacheCtx.cacheObjectContext(cacheObjCtx);
    GridCacheAdapter cache = null;
    switch(cfg.getCacheMode()) {
        case LOCAL:
            {
                switch(cfg.getAtomicityMode()) {
                    case TRANSACTIONAL:
                        {
                            cache = new GridLocalCache(cacheCtx);
                            break;
                        }
                    case ATOMIC:
                        {
                            cache = new GridLocalAtomicCache(cacheCtx);
                            break;
                        }
                    default:
                        {
                            assert false : "Invalid cache atomicity mode: " + cfg.getAtomicityMode();
                        }
                }
                break;
            }
        case PARTITIONED:
        case REPLICATED:
            {
                if (nearEnabled) {
                    switch(cfg.getAtomicityMode()) {
                        case TRANSACTIONAL:
                            {
                                cache = new GridNearTransactionalCache(cacheCtx);
                                break;
                            }
                        case ATOMIC:
                            {
                                cache = new GridNearAtomicCache(cacheCtx);
                                break;
                            }
                        default:
                            {
                                assert false : "Invalid cache atomicity mode: " + cfg.getAtomicityMode();
                            }
                    }
                } else {
                    switch(cfg.getAtomicityMode()) {
                        case TRANSACTIONAL:
                            {
                                cache = cacheCtx.affinityNode() ? new GridDhtColocatedCache(cacheCtx) : new GridDhtColocatedCache(cacheCtx, new GridNoStorageCacheMap());
                                break;
                            }
                        case ATOMIC:
                            {
                                cache = cacheCtx.affinityNode() ? new GridDhtAtomicCache(cacheCtx) : new GridDhtAtomicCache(cacheCtx, new GridNoStorageCacheMap());
                                break;
                            }
                        default:
                            {
                                assert false : "Invalid cache atomicity mode: " + cfg.getAtomicityMode();
                            }
                    }
                }
                break;
            }
        default:
            {
                assert false : "Invalid cache mode: " + cfg.getCacheMode();
            }
    }
    cache.active(!disabledAfterStart);
    cacheCtx.cache(cache);
    GridCacheContext<?, ?> ret = cacheCtx;
    /*
         * Create DHT cache.
         * ================
         */
    if (cfg.getCacheMode() != LOCAL && nearEnabled) {
        /*
             * Specifically don't create the following managers
             * here and reuse the one from Near cache:
             * 1. GridCacheVersionManager
             * 2. GridCacheIoManager
             * 3. GridCacheDeploymentManager
             * 4. GridCacheQueryManager (note, that we start it for DHT cache though).
             * 5. CacheContinuousQueryManager (note, that we start it for DHT cache though).
             * 6. GridCacheDgcManager
             * 7. GridCacheTtlManager.
             * ===============================================
             */
        evictMgr = cfg.isOnheapCacheEnabled() ? new GridCacheEvictionManager() : new CacheOffheapEvictionManager();
        evtMgr = new GridCacheEventManager();
        pluginMgr = new CachePluginManager(ctx, cfg);
        drMgr = pluginMgr.createComponent(GridCacheDrManager.class);
        cacheCtx = new GridCacheContext(ctx, sharedCtx, cfg, grp, desc.cacheType(), locStartTopVer, affNode, true, /*
                 * Managers in starting order!
                 * ===========================
                 */
        evtMgr, storeMgr, evictMgr, qryMgr, contQryMgr, dataStructuresMgr, ttlMgr, drMgr, rslvrMgr, pluginMgr, affMgr);
        cacheCtx.statisticsEnabled(desc.cacheConfiguration().isStatisticsEnabled());
        cacheCtx.cacheObjectContext(cacheObjCtx);
        GridDhtCacheAdapter dht = null;
        switch(cfg.getAtomicityMode()) {
            case TRANSACTIONAL:
                {
                    assert cache instanceof GridNearTransactionalCache;
                    GridNearTransactionalCache near = (GridNearTransactionalCache) cache;
                    GridDhtCache dhtCache = cacheCtx.affinityNode() ? new GridDhtCache(cacheCtx) : new GridDhtCache(cacheCtx, new GridNoStorageCacheMap());
                    dhtCache.near(near);
                    near.dht(dhtCache);
                    dht = dhtCache;
                    break;
                }
            case ATOMIC:
                {
                    assert cache instanceof GridNearAtomicCache;
                    GridNearAtomicCache near = (GridNearAtomicCache) cache;
                    GridDhtAtomicCache dhtCache = cacheCtx.affinityNode() ? new GridDhtAtomicCache(cacheCtx) : new GridDhtAtomicCache(cacheCtx, new GridNoStorageCacheMap());
                    dhtCache.near(near);
                    near.dht(dhtCache);
                    dht = dhtCache;
                    break;
                }
            default:
                {
                    assert false : "Invalid cache atomicity mode: " + cfg.getAtomicityMode();
                }
        }
        cacheCtx.cache(dht);
    }
    if (!CU.isUtilityCache(cache.name()) && !CU.isSystemCache(cache.name())) {
        registerMbean(cache.localMxBean(), cache.name(), false);
        registerMbean(cache.clusterMxBean(), cache.name(), false);
    }
    return ret;
}
Also used : GridDhtCacheAdapter(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter) ArrayList(java.util.ArrayList) CacheDataStructuresManager(org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager) CacheStoreManager(org.apache.ignite.internal.processors.cache.store.CacheStoreManager) CacheContinuousQueryManager(org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager) GridLocalAtomicCache(org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache) GridNearAtomicCache(org.apache.ignite.internal.processors.cache.distributed.near.GridNearAtomicCache) GridDhtColocatedCache(org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache) CachePluginManager(org.apache.ignite.internal.processors.plugin.CachePluginManager) GridLocalCache(org.apache.ignite.internal.processors.cache.local.GridLocalCache) GridDhtCache(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCache) GridDhtAtomicCache(org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache) GridNearTransactionalCache(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache) GridCacheQueryManager(org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) CacheStore(org.apache.ignite.cache.store.CacheStore) GridCacheDrManager(org.apache.ignite.internal.processors.cache.dr.GridCacheDrManager)

Example 9 with CacheStoreManager

use of org.apache.ignite.internal.processors.cache.store.CacheStoreManager in project ignite by apache.

the class GridCacheSharedContext method addCacheContext.

/**
 * Adds cache context to shared cache context.
 *
 * @param cacheCtx Cache context to add.
 * @throws IgniteCheckedException If cache ID conflict detected.
 */
@SuppressWarnings("unchecked")
public void addCacheContext(GridCacheContext cacheCtx) throws IgniteCheckedException {
    if (ctxMap.containsKey(cacheCtx.cacheId())) {
        GridCacheContext<K, V> existing = ctxMap.get(cacheCtx.cacheId());
        throw new IgniteCheckedException("Failed to start cache due to conflicting cache ID " + "(change cache name and restart grid) [cacheName=" + cacheCtx.name() + ", conflictingCacheName=" + existing.name() + ']');
    }
    CacheStoreManager mgr = cacheCtx.store();
    if (mgr.configured() && mgr.isLocal())
        locStoreCnt.incrementAndGet();
    ctxMap.put(cacheCtx.cacheId(), cacheCtx);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) MARKED_ROLLBACK(org.apache.ignite.transactions.TransactionState.MARKED_ROLLBACK) CacheStoreManager(org.apache.ignite.internal.processors.cache.store.CacheStoreManager)

Example 10 with CacheStoreManager

use of org.apache.ignite.internal.processors.cache.store.CacheStoreManager in project ignite by apache.

the class GridCacheSharedContext method verifyTxCompatibility.

/**
 * @param tx Transaction to check.
 * @param activeCacheIds Active cache IDs.
 * @param cacheCtx Cache context.
 * @return Error message if transactions are incompatible.
 */
@Nullable
public String verifyTxCompatibility(IgniteInternalTx tx, GridIntList activeCacheIds, GridCacheContext<K, V> cacheCtx) {
    if (cacheCtx.systemTx() && !tx.system())
        return "system cache can be enlisted only in system transaction";
    if (!cacheCtx.systemTx() && tx.system())
        return "non-system cache can't be enlisted in system transaction";
    for (int i = 0; i < activeCacheIds.size(); i++) {
        int cacheId = activeCacheIds.get(i);
        GridCacheContext<K, V> activeCacheCtx = cacheContext(cacheId);
        if (cacheCtx.systemTx()) {
            if (activeCacheCtx.cacheId() != cacheCtx.cacheId())
                return "system transaction can include only one cache";
        }
        CacheStoreManager store = cacheCtx.store();
        CacheStoreManager activeStore = activeCacheCtx.store();
        if (store.isLocal() != activeStore.isLocal())
            return "caches with local and non-local stores can't be enlisted in one transaction";
        if (store.isWriteBehind() != activeStore.isWriteBehind())
            return "caches with different write-behind setting can't be enlisted in one transaction";
        if (activeCacheCtx.deploymentEnabled() != cacheCtx.deploymentEnabled())
            return "caches with enabled and disabled deployment modes can't be enlisted in one transaction";
        // If local and write-behind validations passed, this must be true.
        assert store.isWriteToStoreFromDht() == activeStore.isWriteToStoreFromDht();
    }
    return null;
}
Also used : MARKED_ROLLBACK(org.apache.ignite.transactions.TransactionState.MARKED_ROLLBACK) CacheStoreManager(org.apache.ignite.internal.processors.cache.store.CacheStoreManager) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

CacheStoreManager (org.apache.ignite.internal.processors.cache.store.CacheStoreManager)11 ArrayList (java.util.ArrayList)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 CacheStore (org.apache.ignite.cache.store.CacheStore)4 CacheDataStructuresManager (org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager)3 GridDhtCache (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCache)3 GridDhtCacheAdapter (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter)3 GridDhtAtomicCache (org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache)3 GridDhtColocatedCache (org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache)3 GridNearAtomicCache (org.apache.ignite.internal.processors.cache.distributed.near.GridNearAtomicCache)3 GridNearTransactionalCache (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache)3 GridCacheDrManager (org.apache.ignite.internal.processors.cache.dr.GridCacheDrManager)3 GridLocalCache (org.apache.ignite.internal.processors.cache.local.GridLocalCache)3 GridLocalAtomicCache (org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache)3 GridCacheQueryManager (org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager)3 CacheContinuousQueryManager (org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager)3 CachePluginManager (org.apache.ignite.internal.processors.plugin.CachePluginManager)3 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)2 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)2 GridTimeoutObject (org.apache.ignite.internal.processors.timeout.GridTimeoutObject)2