Java Code Examples for org.apache.ignite.cache.CacheAtomicityMode#TRANSACTIONAL_SNAPSHOT
The following examples show how to use
org.apache.ignite.cache.CacheAtomicityMode#TRANSACTIONAL_SNAPSHOT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MvccUpdateContentionBenchmark.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { ThreadLocalRandom rnd = ThreadLocalRandom.current(); long start = rnd.nextLong(args.mvccContentionRange() - (args.sqlRange() - 1)) + 1; long end = start + (args.sqlRange() - 1); try { execute(new SqlFieldsQuery(UPDATE_QRY).setArgs(start, end)); } catch (IgniteSQLException exc) { if ((args.atomicMode() == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT && !exc.getMessage().startsWith(MVCC_EXC_MSG)) || (args.atomicMode() != CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT && !exc.getMessage().startsWith(NO_MVCC_EXC_MSG_PREFIX))) throw new RuntimeException("Exception with unexpected message is thrown.", exc); failsCnt.incrementAndGet(); } catch (Exception e) { throw new RuntimeException("Could not perform update.", e); } return true; }
Example 2
Source File: NotMappedPartitionInTxTest.java From ignite with Apache License 2.0 | 6 votes |
/** * */ @Test public void testOneServerMvcc() throws Exception { try { atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; startGrid(0); final IgniteEx client = startClientGrid(1); checkNotMapped(client, PESSIMISTIC, REPEATABLE_READ); } finally { stopAllGrids(); } }
Example 3
Source File: DynamicEnableIndexingConcurrentSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** Test parameters. */ @Parameters(name = "cacheMode={0},atomicityMode={1}") public static Iterable<Object[]> params() { CacheMode[] cacheModes = new CacheMode[] {CacheMode.PARTITIONED, CacheMode.REPLICATED}; CacheAtomicityMode[] atomicityModes = new CacheAtomicityMode[] { CacheAtomicityMode.ATOMIC, CacheAtomicityMode.TRANSACTIONAL, CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT }; List<Object[]> res = new ArrayList<>(); for (CacheMode cacheMode : cacheModes) { for (CacheAtomicityMode atomicityMode : atomicityModes) res.add(new Object[] {cacheMode, atomicityMode}); } return res; }
Example 4
Source File: CacheGroupsPreloadTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") @Test public void testCachePreloadMvcc2() throws Exception { atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; cachePreloadTest(); }
Example 5
Source File: CacheGroupsPreloadTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Test public void testCachePreloadMvcc4() throws Exception { cacheMode = CacheMode.REPLICATED; atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; cachePreloadTest(); }
Example 6
Source File: CacheGroupsPreloadTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Test public void testCachePreloadMvcc8() throws Exception { sameGrp = false; cacheMode = CacheMode.REPLICATED; atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; cachePreloadTest(); }
Example 7
Source File: CacheGroupsPreloadTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") @Test public void testCachePreloadMvcc6() throws Exception { sameGrp = false; atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; cachePreloadTest(); }
Example 8
Source File: DynamicEnableIndexingBasicSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); CacheConfiguration<?, ?> ccfg = testCacheConfiguration(POI_CACHE_NAME, cacheMode, atomicityMode); if (hasNear && atomicityMode != CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) ccfg.setNearConfiguration(new NearCacheConfiguration<>()); node().getOrCreateCache(ccfg); if (atomicityMode != CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) grid(IDX_CLI_NEAR_ONLY).getOrCreateNearCache(POI_CACHE_NAME, new NearCacheConfiguration<>()); }
Example 9
Source File: LocalWalModeNoChangeDuringRebalanceOnNonNodeAssignTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Test public void testMvcc() throws Exception { atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; check(); }
Example 10
Source File: GridCacheMvccMultiThreadedUpdateSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; }
Example 11
Source File: GridCacheRebalancingPartitionCountersMvccTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; }
Example 12
Source File: IgniteCacheTxIteratorSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @throws Exception If failed. */ private void checkTxCache( CacheMode mode, CacheAtomicityMode atomMode, boolean nearEnabled, boolean useEvicPlc ) throws Exception { if (atomMode == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) { if (!MvccFeatureChecker.isSupported(mode) || (nearEnabled && !MvccFeatureChecker.isSupported(Feature.NEAR_CACHE)) || (useEvicPlc && !MvccFeatureChecker.isSupported(Feature.EVICTION))) return; // Nothing to do. Mode is not supported. } final Ignite ignite = grid(0); final CacheConfiguration<String, TestClass> ccfg = cacheConfiguration( mode, atomMode, nearEnabled, useEvicPlc); final IgniteCache<String, TestClass> cache = ignite.createCache(ccfg).withAllowAtomicOpsInTx(); info("Checking cache [mode=" + mode + ", atomMode=" + atomMode + ", near=" + nearEnabled + ", evict=" + useEvicPlc + ']'); try { for (int i = 0; i < 30; i++) { final TestClass val = new TestClass("data"); final String key = "key-" + i; cache.put(key, val); assertEquals(i + 1, cache.size()); for (TransactionIsolation iso : TransactionIsolation.values()) { for (TransactionConcurrency con : TransactionConcurrency.values()) { if (atomMode == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT && !MvccFeatureChecker.isSupported(con, iso)) continue; // Mode not supported. try (Transaction transaction = ignite.transactions().txStart(con, iso)) { assertEquals(val, cache.get(key)); transaction.commit(); } int cnt = iterateOverKeys(cache); assertEquals("Failed [con=" + con + ", iso=" + iso + ']', i + 1, cnt); assertEquals("Failed [con=" + con + ", iso=" + iso + ']', i + 1, cache.size()); } } } } finally { grid(0).destroyCache(CACHE_NAME); } }
Example 13
Source File: CacheMvccContinuousQueryReplicatedTxOneNodeTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicMode() { return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; }
Example 14
Source File: CacheMvccContinuousQueryMultiNodesFilteringTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; }
Example 15
Source File: CacheMvccContinuousWithTransformerReplicatedSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; }
Example 16
Source File: CacheMvccContinuousQueryBackupQueueTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; }
Example 17
Source File: GridCacheOffheapUpdateSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @throws Exception If failed. */ @Test public void testReadEvictedPartition() throws Exception { try { Ignite grid = startGrid(0); IgniteCache<Object, Object> cache = grid.cache(DEFAULT_CACHE_NAME); for (int i = 0; i < 30; i++) cache.put(i, 0); startGrid(1); awaitPartitionMapExchange(); for (int i = 0; i < 30; i++) grid(1).cache(DEFAULT_CACHE_NAME).put(i, 10); // Find a key that does not belong to started node anymore. int key = 0; ClusterNode locNode = grid.cluster().localNode(); for (;key < 30; key++) { if (!grid.affinity(DEFAULT_CACHE_NAME).isPrimary(locNode, key) && !grid.affinity(DEFAULT_CACHE_NAME).isBackup(locNode, key)) break; } assertEquals(10, cache.get(key)); if (((IgniteCacheProxy)cache).context().config().getAtomicityMode() != CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) { try (Transaction ignored = grid.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { assertEquals(10, cache.get(key)); } try (Transaction ignored = grid.transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { assertEquals(10, cache.get(key)); } } else { try (Transaction ignored = grid.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { assertEquals(10, cache.get(key)); } } } finally { stopAllGrids(); } }
Example 18
Source File: CacheMvccContinuousQueryClientTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; }
Example 19
Source File: CacheMvccContinuousQueryPartitionedTxOneNodeTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicMode() { return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; }
Example 20
Source File: GridCacheRebalancingWithAsyncClearingMvccTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; }