/** * @return Cache atomicity mode. */ public CacheAtomicityMode atomicityMode() { CacheAtomicityMode atomicityMode = ccfg.getAtomicityMode(); return atomicityMode != null ? atomicityMode : DFLT_CACHE_ATOMICITY_MODE; }
/** * @return {@code True} if atomic. */ public boolean atomic() { return cacheCfg.getAtomicityMode() == ATOMIC; }
/** * @return {@code True} if transactional. */ public boolean transactional() { return cacheCfg.getAtomicityMode() == TRANSACTIONAL || cacheCfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT; }
/** * @return {@code True} if transactional snapshot. */ public boolean transactionalSnapshot() { return cacheCfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT; }
/** {@inheritDoc} */ @Override public void validateCacheConfiguration(CacheConfiguration ccfg) { if (ccfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) { if (!mvccSupported) throw new IgniteException("Cannot start MVCC transactional cache. " + "MVCC is unsupported by the cluster."); mvccEnabled = true; } }
/** {@inheritDoc} */ @Override public void afterBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr, GridCacheDatabaseSharedManager.RestoreBinaryState restoreState) throws IgniteCheckedException { boolean hasMvccCaches = ctx.cache().persistentCaches().stream() .anyMatch(c -> c.cacheConfiguration().getAtomicityMode() == TRANSACTIONAL_SNAPSHOT); if (hasMvccCaches) { txLog = new TxLog(ctx, mgr); mvccEnabled = true; } }
/** * Throws atomicity modes compatibility validation exception. * * @param ctx1 Cache context. * @param ctx2 Another cache context. */ public static void throwAtomicityModesMismatchException(GridCacheContext ctx1, GridCacheContext ctx2) { throw new IgniteException("Caches with transactional_snapshot atomicity mode cannot participate in the same" + " transaction with caches having another atomicity mode. [cacheName=" + ctx1.name() + ", cacheMode=" + ctx1.config().getAtomicityMode() + ", anotherCacheName=" + ctx2.name() + " anotherCacheMode=" + ctx2.config().getAtomicityMode() + ']'); }
/** * @param cache Cache. * @return Access strategy implementation. */ HibernateAccessStrategyAdapter createReadWriteStrategy(HibernateCacheProxy cache) { if (verifyAtomicity) { if (cache.configuration().getAtomicityMode() != TRANSACTIONAL) { throw new IllegalArgumentException("Hibernate READ-WRITE access strategy must have Ignite cache with " + "'TRANSACTIONAL' atomicity mode: " + cache.name()); } } return new HibernateReadWriteAccessStrategy(ignite, cache, threadLoc, eConverter); }
/** * @return Cache atomicity mode. */ protected CacheAtomicityMode atomicityMode() { return cacheConfiguration().getAtomicityMode(); }
/** * @param cache Ignite cache. * @return CacheAtomicityMode for given cache. */ public static CacheAtomicityMode atomicityMode(IgniteCache cache) { return ((CacheConfiguration)cache.getConfiguration(CacheConfiguration.class)).getAtomicityMode(); }
/** * Checks if cache configurations are alike for warmup. * * @param ccfg0 First configuration. * @param ccfg1 Second configuration. * @return {@code True} if configurations match. */ private boolean matches(CacheConfiguration ccfg0, CacheConfiguration ccfg1) { return F.eq(ccfg0.getCacheMode(), ccfg1.getCacheMode()) && F.eq(ccfg0.getBackups(), ccfg1.getBackups()) && F.eq(ccfg0.getAtomicityMode(), ccfg1.getAtomicityMode()); }
/** */ protected boolean isLocalAtomic() { CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class); return cfg.getCacheMode() == CacheMode.LOCAL && cfg.getAtomicityMode() == CacheAtomicityMode.ATOMIC; }
/** * @param cache Cache. */ public void cache(GridCacheAdapter<K, V> cache) { this.cache = cache; deferredDel = cache.isDht() || cache.isDhtAtomic() || cache.isColocated() || (cache.isNear() && cache.configuration().getAtomicityMode() == ATOMIC); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration igniteConfiguration = super.getConfiguration(igniteInstanceName); CacheConfiguration[] ccfgs = igniteConfiguration.getCacheConfiguration(); if (ccfgs != null) { for (CacheConfiguration ccfg : ccfgs) ccfg.setNearConfiguration(null); } assert ccfgs == null || ccfgs.length == 0 || (ccfgs.length == 1 && ccfgs[0].getAtomicityMode() == TRANSACTIONAL_SNAPSHOT); return igniteConfiguration; }
/** */ private void executeWithAllTxCaches(final TestClosure clo) throws Exception { for (CacheConfiguration ccfg : cacheConfigurations()) { if (ccfg.getAtomicityMode() == CacheAtomicityMode.TRANSACTIONAL) { for (TransactionConcurrency con : TransactionConcurrency.values()) { for (TransactionIsolation iso : TransactionIsolation.values()) executeForCache(ccfg, clo, con, iso); } } } }
/** * @throws Exception If failed. */ @Test public void testNonTxEvictions() throws Exception { if (grid(0).cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getAtomicityMode() == CacheAtomicityMode.ATOMIC) checkTtl(false); }
/** * @param ignite Ignite. * @param cacheName Cache name. */ private void checkDefaultTemplate(final Ignite ignite, final String cacheName) { checkGetOrCreate(ignite, cacheName, 0); IgniteCache cache = ignite.getOrCreateCache(cacheName); assertNotNull(cache); CacheConfiguration cfg = (CacheConfiguration)cache.getConfiguration(CacheConfiguration.class); assertEquals(CacheConfiguration.DFLT_CACHE_ATOMICITY_MODE, cfg.getAtomicityMode()); }
/** * @throws Exception If failed. */ @Test public void testTxEvictions() throws Exception { if (grid(0).cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getAtomicityMode() != CacheAtomicityMode.ATOMIC) checkTtl(true); }
/** */ private static IgniteCache<?, ?> table(IgniteEx ignite) { assert ignite.cachex("person").configuration().getAtomicityMode() == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; assert ignite.cachex("person").configuration().getCacheMode() == CacheMode.REPLICATED; return ignite.cache("person"); }
/** {@inheritDoc} */ @Override protected void createCache(Ignite node, CacheConfiguration ccfg) throws IgniteCheckedException { String template = ccfg.getCacheMode() == CacheMode.PARTITIONED ? QueryUtils.TEMPLATE_PARTITIONED : QueryUtils.TEMPLATE_REPLICATED; String cmd = "CREATE TABLE IF NOT EXISTS " + ccfg.getName() + " (k BIGINT PRIMARY KEY, v BIGINT) WITH \"" + "TEMPLATE=" + template + ", " + "CACHE_NAME=" + ccfg.getName() + ", " + "ATOMICITY=" + ccfg.getAtomicityMode() + (ccfg.getGroupName() != null ? ", CACHE_GROUP=" + ccfg.getGroupName() : "") + (ccfg.getDataRegionName() != null ? ", DATA_REGION=" + ccfg.getDataRegionName() : "") + "\""; execute(node, cmd); alignCacheTopologyVersion(node); }