/** {@inheritDoc} */ @Override public <K> Map<GridNode, Collection<K>> mapKeysToNodes(String cacheName, @Nullable Collection<? extends K> keys) throws GridException { if (F.isEmpty(keys)) return Collections.emptyMap(); guard(); try { return ctx.affinity().mapKeysToNodes(cacheName, keys); } finally { unguard(); } }
/** {@inheritDoc} */ @Nullable @Override public <K> GridNode mapKeyToNode(String cacheName, K key) throws GridException { A.notNull(key, "key"); guard(); try { return ctx.affinity().mapKeyToNode(cacheName, key); } finally { unguard(); } }
node = ctx.affinity().mapKeyToNode(cacheName, key);
GridNode n = ctx.affinity().mapKeyToNode(cacheName, affKey, topVer);
/** * @param cacheName Cache name. * @param affKey Affinity key. * @param job Job. * @param nodes Grid nodes. * @return Job future. */ public GridFuture<?> affinityRun(@Nullable String cacheName, Object affKey, Runnable job, @Nullable Collection<GridNode> nodes) { enterBusy(); try { if (F.isEmpty(nodes)) return new GridFinishedFuture<>(ctx, U.emptyTopologyException()); // In case cache key is passed instead of affinity key. final Object affKey0 = ctx.affinity().affinityKey(cacheName, affKey); ctx.task().setThreadContext(TC_SUBGRID, nodes); return ctx.task().execute(new T4(cacheName, affKey0, job), null, false); } catch (GridException e) { return new GridFinishedFuture<>(ctx, e); } finally { leaveBusy(); } }
/** * @param cacheName Cache name. * @param affKey Affinity key. * @param job Job. * @param nodes Grid nodes. * @return Job future. */ public <R> GridFuture<R> affinityCall(@Nullable String cacheName, Object affKey, Callable<R> job, @Nullable Collection<GridNode> nodes) { enterBusy(); try { if (F.isEmpty(nodes)) return new GridFinishedFuture<>(ctx, U.emptyTopologyException()); // In case cache key is passed instead of affinity key. final Object affKey0 = ctx.affinity().affinityKey(cacheName, affKey); ctx.task().setThreadContext(TC_SUBGRID, nodes); return ctx.task().execute(new T5<>(cacheName, affKey0, job), null, false); } catch (GridException e) { return new GridFinishedFuture<>(ctx, e); } finally { leaveBusy(); } }
GridNode node = ctx.affinity().mapKeyToNode(cacheName, key);