/** {@inheritDoc} */ @Override protected void operation(int key) throws Exception { cache.getAndPut(key, key); } }
/** {@inheritDoc} */ @Override public V getAndPut(K key, V val) { IgniteInternalCache<K, V> delegate = getDelegateSafe(); try { if (isAsync()) { setFuture(delegate.getAndPutAsync(key, val)); return null; } else return delegate.getAndPut(key, val); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** * @throws Exception If failed. */ @Test public void testSystemTxInsideUserTx() throws Exception { Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10473", MvccFeatureChecker.forcedMvcc()); IgniteKernal ignite = (IgniteKernal)grid(0); IgniteCache<Object, Object> jcache = ignite.cache(DEFAULT_CACHE_NAME); try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { jcache.get("1"); jcache.put("1", "11"); IgniteInternalCache<Object, Object> utilityCache = ignite.context().cache().utilityCache(); utilityCache.getAndPutIfAbsent("2", "2"); try (GridNearTxLocal itx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { assertEquals(null, utilityCache.get("1")); assertEquals("2", utilityCache.get("2")); assertEquals(null, utilityCache.get("3")); utilityCache.getAndPut("3", "3"); itx.commit(); } jcache.put("2", "22"); tx.commit(); } checkTransactionsCommitted(); checkEntries(DEFAULT_CACHE_NAME, "1", "11", "2", "22", "3", null); checkEntries(CU.UTILITY_CACHE_NAME, "1", null, "2", "2", "3", "3"); }
/** {@inheritDoc} */ @Nullable @Override public Object getAndPut(Object key, Object val) throws IgniteCheckedException { return delegate.get().getAndPut(keyTransformer.transform(key), val); }
/** {@inheritDoc} */ @Override public V getAndPut(K key, V val) { try { if (isAsync()) { setFuture(delegate.getAndPutAsync(key, val)); return null; } else return delegate.getAndPut(key, val); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Nullable @Override public V getAndPut(K key, V val) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { return delegate.getAndPut(key, val); } finally { gate.leave(prev); } }
/** * Set sampling flag. * * @param val Sampling flag state or {@code null} to clear sampling state and mark it as "not set". * @return {@code True} if sampling mode was actually changed by this call. * @throws IgniteCheckedException If failed. */ public boolean sampling(Boolean val) throws IgniteCheckedException { if (busyLock.enterBusy()) { try { validTxState(false); try (GridNearTxLocal tx = startTx()) { Object prev = val != null ? metaCache.getAndPut(sampling, val) : metaCache.getAndRemove(sampling); tx.commit(); return !F.eq(prev, val); } } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to set sampling flag because Grid is stopping."); }
((IgniteKernal)grid(0)).getCache(cacheName).getAndPut(new GridCacheInternalKeyImpl("LONG", ""), new GridCacheAtomicLongValue(0));
/** {@inheritDoc} */ @Override protected void operation(int key) throws Exception { cache.getAndPut(key, key); } }
/** {@inheritDoc} */ @Nullable @Override public V getAndPut(K key, V val) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { return delegate.getAndPut(key, val); } finally { gate.leave(prev); } }
/** * Set sampling flag. * * @param val Sampling flag state or {@code null} to clear sampling state and mark it as "not set". * @return {@code True} if sampling mode was actually changed by this call. * @throws IgniteCheckedException If failed. */ public boolean sampling(Boolean val) throws IgniteCheckedException { if (busyLock.enterBusy()) { try { validTxState(false); try (GridNearTxLocal tx = startTx()) { Object prev = val != null ? metaCache.getAndPut(sampling, val) : metaCache.getAndRemove(sampling); tx.commit(); return !F.eq(prev, val); } } finally { busyLock.leaveBusy(); } } else throw new IllegalStateException("Failed to set sampling flag because Grid is stopping."); }