Tabnine Logo
IgniteInternalCache.getAndPutIfAbsent
Code IndexAdd Tabnine to your IDE (free)

How to use
getAndPutIfAbsent
method
in
org.apache.ignite.internal.processors.cache.IgniteInternalCache

Best Java code snippets using org.apache.ignite.internal.processors.cache.IgniteInternalCache.getAndPutIfAbsent (Showing top 20 results out of 315)

origin: apache/ignite

  /** {@inheritDoc} */
  @Override protected void operation(int key) throws Exception {
    cache.getAndPutIfAbsent(key, key);
  }
}
origin: apache/ignite

/** {@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);
  }
}
origin: apache/ignite

/** {@inheritDoc} */
@Nullable @Override public Object getAndPutIfAbsent(Object key, Object val) throws IgniteCheckedException {
  return delegate.get().getAndPutIfAbsent(keyTransformer.transform(key), val);
}
origin: org.apache.ignite/ignite-core

/** {@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);
  }
}
origin: apache/ignite

/** {@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);
  }
}
origin: apache/ignite

/**
 * 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;
}
origin: apache/ignite

/**
 * 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 + ']');
}
origin: apache/ignite

hdr = new GridCacheSetHeader(IgniteUuid.randomUuid(), collocated, separated);
GridCacheSetHeader old = (GridCacheSetHeader)cache.getAndPutIfAbsent(key, hdr);
origin: apache/ignite

GridServiceDeployment dep = (GridServiceDeployment)serviceCache().getAndPutIfAbsent(key,
  new GridServiceDeployment(ctx.localNodeId(), cfg));
origin: apache/ignite

hdr = new GridCacheQueueHeader(IgniteUuid.randomUuid(), cap, colloc, 0, 0, null);
GridCacheQueueHeader old = queueHdrView.withNoRetries().getAndPutIfAbsent(key, hdr);
origin: apache/ignite

oldVal = metaCache.getAndPutIfAbsent(new GridCacheInternalKeyImpl(name, grpName), newVal);
origin: apache/ignite

perfCntr.onJobStart(jobStart);
if (jobMetaCache().getAndPutIfAbsent(jobId, meta) != null)
  throw new IgniteCheckedException("Failed to submit job. Job with the same ID already exists: " + jobId);
origin: apache/ignite

/**
 * @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");
}
origin: org.apache.ignite/ignite-core

  /** {@inheritDoc} */
  @Override protected void operation(int key) throws Exception {
    cache.getAndPutIfAbsent(key, key);
  }
}
origin: org.apache.ignite/ignite-core

/** {@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);
  }
}
origin: org.apache.ignite/ignite-core

/**
 * 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;
}
origin: org.apache.ignite/ignite-core

/**
 * 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 + ']');
}
origin: org.apache.ignite/ignite-core

hdr = new GridCacheSetHeader(IgniteUuid.randomUuid(), collocated, separated);
GridCacheSetHeader old = (GridCacheSetHeader)cache.getAndPutIfAbsent(key, hdr);
origin: org.apache.ignite/ignite-core

GridServiceDeployment dep = (GridServiceDeployment)serviceCache().getAndPutIfAbsent(key,
  new GridServiceDeployment(ctx.localNodeId(), cfg));
origin: org.apache.ignite/ignite-core

oldVal = metaCache.getAndPutIfAbsent(new GridCacheInternalKeyImpl(name, grpName), newVal);
org.apache.ignite.internal.processors.cacheIgniteInternalCachegetAndPutIfAbsent

Javadoc

Stores given key-value pair in cache only if cache had no previous mapping for it. If cache previously contained value for the given key, then this value is returned. In case of CacheMode#PARTITIONED or CacheMode#REPLICATED caches, the value will be loaded from the primary node, which in its turn may load the value from the swap storage, and consecutively, if it's not in swap, from the underlying persistent storage. If value has to be loaded from persistent storage, CacheStore#load(Transaction, Object) method will be used.

If the returned value is not needed, method #putIfAbsent(Object,Object) should always be used instead of this one to avoid the overhead associated with returning of the previous value.

If write-through is enabled, the stored value will be persisted to CacheStorevia CacheStore#put(Transaction, Object, Object) method.

Transactions This method is transactional and will enlist the entry into ongoing transaction if there is one.

Popular methods of IgniteInternalCache

  • context
  • get
    Retrieves value mapped to the specified key from cache. Value will only be returned if its entry pas
  • affinity
    Gets affinity service to provide information about data partitioning and distribution.
  • configuration
    Gets configuration bean for this cache.
  • containsKey
  • getAndPut
    Stores given key-value pair in cache. If filters are provided, then entries will be stored in cache
  • invoke
  • invokeAsync
  • put
    Stores given key-value pair in cache. If filters are provided, then entries will be stored in cache
  • size
  • cache
    Gets base cache for this projection.
  • clear
    Clears key on all nodes that store it's data. That is, caches are cleared on remote nodes and local
  • cache,
  • clear,
  • clearLocallyAll,
  • isEmpty,
  • isIgfsDataCache,
  • keySet,
  • localEntries,
  • localPeek,
  • lock

Popular in Java

  • Reading from database using SQL prepared statement
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSharedPreferences (Context)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • BoxLayout (javax.swing)
  • JFileChooser (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now