/** {@inheritDoc} */ @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Void arg) { return F.asMap(new ComputeJobAdapter() { @TaskSessionResource private ComputeTaskSession ses; @Override public Object execute() { return ses.getTaskName(); } }, F.rand(subgrid)); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { for (int i = 0; i < PERM_NODES_CNT; i++) { Ignite g = startGrid(gridCntr++); g.events().localListen(lsnr, EventType.EVT_NODE_LEFT, EventType.EVT_NODE_FAILED); alive.add(g); } for (int i = 0; i < PERM_NODES_CNT + TMP_NODES_CNT; i++) F.rand(alive).cache(DEFAULT_CACHE_NAME).put(i, String.valueOf(i)); }
/** * @return Nodes to execute on. */ private Collection<ClusterNode> nodes() throws IgniteCheckedException { CacheMode cacheMode = cctx.config().getCacheMode(); Integer part = partition(); switch (cacheMode) { case LOCAL: if (prj != null) U.warn(log, "Ignoring query projection because it's executed over LOCAL cache " + "(only local node will be queried): " + this); if (type == SCAN && cctx.config().getCacheMode() == LOCAL && part != null && part >= cctx.affinity().partitions()) throw new IgniteCheckedException("Invalid partition number: " + part); return Collections.singletonList(cctx.localNode()); case REPLICATED: if (prj != null || part != null) return nodes(cctx, prj, part); if (cctx.affinityNode()) return Collections.singletonList(cctx.localNode()); Collection<ClusterNode> affNodes = nodes(cctx, null, null); return affNodes.isEmpty() ? affNodes : Collections.singletonList(F.rand(affNodes)); case PARTITIONED: return nodes(cctx, prj, part); default: throw new IllegalStateException("Unknown cache distribution mode: " + cacheMode); } }
nodes = singletonList(locNode); else nodes = singletonList(F.rand(nodes));
ClusterNode n = pl.size() == 1 ? F.first(pl) : F.rand(pl);
keys.add(i); Ignite g = F.rand(ignites);
/** * @return Nodes to execute on. */ private Collection<ClusterNode> nodes() throws IgniteCheckedException { CacheMode cacheMode = cctx.config().getCacheMode(); Integer part = partition(); switch (cacheMode) { case LOCAL: if (prj != null) U.warn(log, "Ignoring query projection because it's executed over LOCAL cache " + "(only local node will be queried): " + this); if (type == SCAN && cctx.config().getCacheMode() == LOCAL && part != null && part >= cctx.affinity().partitions()) throw new IgniteCheckedException("Invalid partition number: " + part); return Collections.singletonList(cctx.localNode()); case REPLICATED: if (prj != null || part != null) return nodes(cctx, prj, part); if (cctx.affinityNode()) return Collections.singletonList(cctx.localNode()); Collection<ClusterNode> affNodes = nodes(cctx, null, null); return affNodes.isEmpty() ? affNodes : Collections.singletonList(F.rand(affNodes)); case PARTITIONED: return nodes(cctx, prj, part); default: throw new IllegalStateException("Unknown cache distribution mode: " + cacheMode); } }
nodes = singletonList(locNode); else nodes = singletonList(F.rand(nodes));
ClusterNode n = pl.size() == 1 ? F.first(pl) : F.rand(pl);