/** {@inheritDoc} */ @Override protected void operation(int key) throws Exception { cache.getAndPutIfAbsent(key, key); } }
/** {@inheritDoc} */ @Nullable @Override public V getAndPutIfAbsent(K key, V val) throws CacheException { IgniteInternalCache<K, V> delegate = getDelegateSafe(); try { if (isAsync()) { setFuture(delegate.getAndPutIfAbsentAsync(key, val)); return null; } else return delegate.getAndPutIfAbsent(key, val); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Nullable @Override public Object getAndPutIfAbsent(Object key, Object val) throws IgniteCheckedException { return delegate.get().getAndPutIfAbsent(keyTransformer.transform(key), val); }
/** {@inheritDoc} */ @Nullable @Override public V getAndPutIfAbsent(K key, V val) throws CacheException { try { if (isAsync()) { setFuture(delegate.getAndPutIfAbsentAsync(key, val)); return null; } else return delegate.getAndPutIfAbsent(key, val); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Nullable @Override public V getAndPutIfAbsent(K key, V val) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { return delegate.getAndPutIfAbsent(key, val); } finally { gate.leave(prev); } }
/** * create system entry if it is absent. * * @param id System entry ID. * @return Value of created or existing system entry. * @throws IgniteCheckedException On error. */ private IgfsEntryInfo createSystemDirectoryIfAbsent(IgniteUuid id) throws IgniteCheckedException { assert IgfsUtils.isRootOrTrashId(id); IgfsEntryInfo info = IgfsUtils.createDirectory(id); IgfsEntryInfo oldInfo = id2InfoPrj.getAndPutIfAbsent(id, info); if (oldInfo != null) info = oldInfo; return info; }
/** * Saves task name metadata to utility cache. * * @param taskName Task name. * @throws IgniteCheckedException If failed. */ private void saveTaskMetadata(String taskName) throws IgniteCheckedException { if (ctx.isDaemon()) return; assert ctx.security().enabled(); int nameHash = taskName.hashCode(); // 0 is reserved for no task. if (nameHash == 0) nameHash = 1; GridTaskNameHashKey key = new GridTaskNameHashKey(nameHash); IgniteInternalCache<GridTaskNameHashKey, String> tasksMetaCache = taskMetaCache(); String existingName = tasksMetaCache.get(key); if (existingName == null) existingName = tasksMetaCache.getAndPutIfAbsent(key, taskName); if (existingName != null && !F.eq(existingName, taskName)) throw new IgniteCheckedException("Task name hash collision for security-enabled node " + "[taskName=" + taskName + ", existing taskName=" + existingName + ']'); }
hdr = new GridCacheSetHeader(IgniteUuid.randomUuid(), collocated, separated); GridCacheSetHeader old = (GridCacheSetHeader)cache.getAndPutIfAbsent(key, hdr);
GridServiceDeployment dep = (GridServiceDeployment)serviceCache().getAndPutIfAbsent(key, new GridServiceDeployment(ctx.localNodeId(), cfg));
hdr = new GridCacheQueueHeader(IgniteUuid.randomUuid(), cap, colloc, 0, 0, null); GridCacheQueueHeader old = queueHdrView.withNoRetries().getAndPutIfAbsent(key, hdr);
oldVal = metaCache.getAndPutIfAbsent(new GridCacheInternalKeyImpl(name, grpName), newVal);
perfCntr.onJobStart(jobStart); if (jobMetaCache().getAndPutIfAbsent(jobId, meta) != null) throw new IgniteCheckedException("Failed to submit job. Job with the same ID already exists: " + jobId);
/** * @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} */ @Override protected void operation(int key) throws Exception { cache.getAndPutIfAbsent(key, key); } }
/** {@inheritDoc} */ @Nullable @Override public V getAndPutIfAbsent(K key, V val) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { return delegate.getAndPutIfAbsent(key, val); } finally { gate.leave(prev); } }
/** * create system entry if it is absent. * * @param id System entry ID. * @return Value of created or existing system entry. * @throws IgniteCheckedException On error. */ private IgfsEntryInfo createSystemDirectoryIfAbsent(IgniteUuid id) throws IgniteCheckedException { assert IgfsUtils.isRootOrTrashId(id); IgfsEntryInfo info = IgfsUtils.createDirectory(id); IgfsEntryInfo oldInfo = id2InfoPrj.getAndPutIfAbsent(id, info); if (oldInfo != null) info = oldInfo; return info; }
/** * Saves task name metadata to utility cache. * * @param taskName Task name. * @throws IgniteCheckedException If failed. */ private void saveTaskMetadata(String taskName) throws IgniteCheckedException { if (ctx.isDaemon()) return; assert ctx.security().enabled(); int nameHash = taskName.hashCode(); // 0 is reserved for no task. if (nameHash == 0) nameHash = 1; GridTaskNameHashKey key = new GridTaskNameHashKey(nameHash); IgniteInternalCache<GridTaskNameHashKey, String> tasksMetaCache = taskMetaCache(); String existingName = tasksMetaCache.get(key); if (existingName == null) existingName = tasksMetaCache.getAndPutIfAbsent(key, taskName); if (existingName != null && !F.eq(existingName, taskName)) throw new IgniteCheckedException("Task name hash collision for security-enabled node " + "[taskName=" + taskName + ", existing taskName=" + existingName + ']'); }
hdr = new GridCacheSetHeader(IgniteUuid.randomUuid(), collocated, separated); GridCacheSetHeader old = (GridCacheSetHeader)cache.getAndPutIfAbsent(key, hdr);
GridServiceDeployment dep = (GridServiceDeployment)serviceCache().getAndPutIfAbsent(key, new GridServiceDeployment(ctx.localNodeId(), cfg));
oldVal = metaCache.getAndPutIfAbsent(new GridCacheInternalKeyImpl(name, grpName), newVal);