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

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

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

origin: apache/ignite

/** {@inheritDoc} */
@Override public Affinity affinity() {
  return delegate.get().affinity();
}
origin: apache/ignite

/**
 * Maps affinity key to node.
 *
 * @param affinityKey Affinity key to map.
 * @return Primary node for this key.
 */
public Collection<ClusterNode> affinityNodes(Object affinityKey) {
  return dataCache.affinity().mapKeyToPrimaryAndBackups(affinityKey);
}
origin: apache/ignite

/**
 * Maps affinity key to node.
 *
 * @param affinityKey Affinity key to map.
 * @return Primary node for this key.
 */
public ClusterNode affinityNode(Object affinityKey) {
  return dataCache.affinity().mapKeyToNode(affinityKey);
}
origin: apache/ignite

@Override public int partition(String cacheName, Object key) {
  return ctx.cache().cache(cacheName).affinity().partition(key);
}
origin: apache/ignite

/**
 * Generates next affinity key for local node based on current topology. If previous affinity key maps
 * on local node, return previous affinity key to prevent unnecessary file map growth.
 *
 * @param prevAffKey Affinity key of previous block.
 * @return Affinity key.
 */
@SuppressWarnings("ConstantConditions")
public IgniteUuid nextAffinityKey(@Nullable IgniteUuid prevAffKey) {
  // Do not generate affinity key for non-affinity nodes.
  if (!dataCache.context().affinityNode())
    return null;
  UUID nodeId = igfsCtx.kernalContext().localNodeId();
  if (prevAffKey != null && dataCache.affinity().mapKeyToNode(prevAffKey).isLocal())
    return prevAffKey;
  while (true) {
    IgniteUuid key = new IgniteUuid(nodeId, affKeyGen.getAndIncrement());
    if (dataCache.affinity().mapKeyToNode(key).isLocal())
      return key;
  }
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public Map<UUID, Integer> serviceTopology(String name, long timeout) throws IgniteCheckedException {
  IgniteInternalCache<Object, Object> cache = serviceCache();
  ClusterNode node = cache.affinity().mapKeyToNode(name);
  final ServiceTopologyCallable call = new ServiceTopologyCallable(name);
  return ctx.closure().callAsyncNoFailover(
    GridClosureCallMode.BROADCAST,
    call,
    Collections.singletonList(node),
    false,
    timeout,
    true).get();
}
origin: apache/ignite

  @Override public GridRestResponse applyx(IgniteInternalFuture<?> f) throws IgniteCheckedException {
    GridCacheRestResponse resp = new GridCacheRestResponse();
    resp.setResponse(f.get());
    if (key != null)
      resp.setAffinityNodeId(c.cache().affinity().mapKeyToNode(key).id().toString());
    return resp;
  }
};
origin: apache/ignite

/**
 * Check if there is missed keys.
 *
 * @throws IgniteCheckedException if failed.
 */
private static void checkForMissedKeys(IgniteEx ignite, Collection<Integer> exp,
  List<Cache.Entry<Integer, ?>> all) throws IgniteCheckedException {
  if (exp.size() == 0)
    return;
  IgniteInternalCache<Integer, Person> cache = ignite.cachex(PERSON_CACHE);
  assertNotNull(cache);
  StringBuilder sb = new StringBuilder();
  Affinity<Integer> aff = cache.affinity();
  for (Integer key : exp) {
    Integer part = aff.partition(key);
    sb.append(
      String.format("Query did not return expected key '%d' (exists: %s), partition '%d', partition nodes: ",
        key, cache.get(key) != null, part));
    Collection<ClusterNode> partNodes = aff.mapPartitionToPrimaryAndBackups(part);
    for (ClusterNode node : partNodes)
      sb.append(node).append("  ");
    sb.append(";\n");
  }
  sb.append("Returned keys: ");
  for (Cache.Entry e : all)
    sb.append(e.getKey()).append(" ");
  sb.append(";\n");
  fail(sb.toString());
}
origin: apache/ignite

  @Override public void run() {
    assertTrue(ignite.cachex(cctx(queue2).cache().name()).affinity().isPrimaryOrBackup(
      ignite.cluster().localNode(), "Queue2"));
    assertEquals(100, queue2.take().intValue());
  }
});
origin: apache/ignite

ClusterNode primaryNode = dataCachePrj.cache().affinity().mapKeyToNode(key);
origin: apache/ignite

/**
 * Fill cache.
 *
 * @throws IgniteCheckedException if failed.
 */
private static Set<Integer> populateCache(IgniteEx ignite, boolean loc, int cnt,
  IgnitePredicate<Integer> expectedEntryFilter) throws IgniteCheckedException {
  IgniteInternalCache<Integer, Person> cache = ignite.cachex(PERSON_CACHE);
  assertNotNull(cache);
  Random rand = new Random();
  HashSet<Integer> exp = new HashSet<>();
  Affinity<Integer> aff = cache.affinity();
  ClusterNode localNode = cache.context().localNode();
  for (int i = 0; i < cnt; i++) {
    int val = rand.nextInt(cnt);
    cache.put(val, new Person(String.valueOf(val), val));
    if (expectedEntryFilter.apply(val) && (!loc || aff.isPrimary(localNode, val)))
      exp.add(val);
  }
  return exp;
}
origin: apache/ignite

  @Override public Integer call() {
    assertTrue(ignite.cachex(cctx(queue2).cache().name()).affinity().isPrimaryOrBackup(
      ignite.cluster().localNode(), "Queue2"));
    return queue2.take();
  }
});
origin: apache/ignite

dataCache.affinity().isPrimaryOrBackup(igfsCtx.kernalContext().discovery().localNode(), key)) {
log.debug("Reading non-local data block [path=" + path + ", fileInfo=" + fileInfo +
  ", blockIdx=" + blockIdx + ']');
origin: apache/ignite

Collection<IgfsBlockLocation> res = new LinkedList<>();
splitBlocks(start, len, maxLen, dataCache.affinity().mapKeyToPrimaryAndBackups(
  new IgfsBlockKey(info.id(), info.affinityKey(), info.evictExclude(), 0)), res);
  long partEnd = Math.min(range.endOffset() + 1, end);
  Collection<ClusterNode> affNodes = dataCache.affinity().mapKeyToPrimaryAndBackups(
    range.affinityKey());
origin: apache/ignite

  grpIdx * grpSize);
Collection<ClusterNode> affNodes = dataCache.affinity().mapKeyToPrimaryAndBackups(key);
origin: apache/ignite

if (cache.cache().affinity().isPrimary(ctx.discovery().localNode(), key)) {
  try {
    cache.getAndRemove(key);
origin: apache/ignite

/**
 * Test node invalidation when cache meta is corrupted.
 */
@Test
public void testCacheMetaCorruption() throws Exception {
  IgniteEx ignite = startGrid(0);
  ignite.cluster().active(true);
  IgniteInternalCache cache = ignite.cachex(CACHE_NAME1);
  cache.put(1, 1);
  int partId = cache.affinity().partition(1);
  int grpId = cache.context().group().groupId();
  corruptTreeRoot(ignite, (PageMemoryEx)cache.context().dataRegion().pageMemory(), grpId, partId);
  ignite.cluster().active(false);
  stopGrid(0);
  try {
    startGrid(0);
    ignite.cluster().active(true);
    cache.put(1, 1);
  }
  catch (Exception e) {
    // No-op.
  }
  waitFailure(StorageException.class);
}
origin: org.apache.ignite/ignite-core

/**
 * Maps affinity key to node.
 *
 * @param affinityKey Affinity key to map.
 * @return Primary node for this key.
 */
public Collection<ClusterNode> affinityNodes(Object affinityKey) {
  return dataCache.affinity().mapKeyToPrimaryAndBackups(affinityKey);
}
origin: org.apache.ignite/ignite-core

/**
 * Maps affinity key to node.
 *
 * @param affinityKey Affinity key to map.
 * @return Primary node for this key.
 */
public ClusterNode affinityNode(Object affinityKey) {
  return dataCache.affinity().mapKeyToNode(affinityKey);
}
origin: org.apache.ignite/ignite-core

  @Override public GridRestResponse applyx(IgniteInternalFuture<?> f) throws IgniteCheckedException {
    GridCacheRestResponse resp = new GridCacheRestResponse();
    resp.setResponse(f.get());
    if (key != null)
      resp.setAffinityNodeId(c.cache().affinity().mapKeyToNode(key).id().toString());
    return resp;
  }
};
org.apache.ignite.internal.processors.cacheIgniteInternalCacheaffinity

Javadoc

Gets affinity service to provide information about data partitioning and distribution.

Popular methods of IgniteInternalCache

  • context
  • get
    Retrieves value mapped to the specified key from cache. Value will only be returned if its entry pas
  • 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
  • getAndPutIfAbsent
    Stores given key-value pair in cache only if cache had no previous mapping for it. If cache previous
  • 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

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • startActivity (Activity)
  • onRequestPermissionsResult (Fragment)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • JCheckBox (javax.swing)
  • Table (org.hibernate.mapping)
    A relational table
  • Top Vim plugins
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