Collection<ClusterNode> nodes = CU.affinityNodes(cctx, AffinityTopologyVersion.NONE);
/** * @param cctx Cache context. * @param prj Projection (optional). * @return Collection of data nodes in provided projection (if any). * @throws IgniteCheckedException If partition number is invalid. */ private static Collection<ClusterNode> nodes(final GridCacheContext<?, ?> cctx, @Nullable final ClusterGroup prj, @Nullable final Integer part) throws IgniteCheckedException { assert cctx != null; final AffinityTopologyVersion topVer = cctx.affinity().affinityTopologyVersion(); Collection<ClusterNode> affNodes = CU.affinityNodes(cctx, topVer); if (prj == null && part == null) return affNodes; if (part != null && part >= cctx.affinity().partitions()) throw new IgniteCheckedException("Invalid partition number: " + part); final Set<ClusterNode> owners = part == null ? Collections.<ClusterNode>emptySet() : new HashSet<>(cctx.topology().owners(part, topVer)); return F.view(affNodes, new P1<ClusterNode>() { @Override public boolean apply(ClusterNode n) { return cctx.discovery().cacheAffinityNode(n, cctx.name()) && (prj == null || prj.node(n.id()) != null) && (part == null || owners.contains(n)); } }); }
Collection<ClusterNode> nodes = CU.affinityNodes(cctx, AffinityTopologyVersion.NONE);
nodes = new ArrayList<>(CU.affinityNodes(cctx, qctx.topologyVersion())); else { nodes = new ArrayList<>(partMap.size());
if (CU.affinityNodes(cacheCtx, topFut.topologyVersion()).isEmpty()) { return new ClusterTopologyServerNotFoundException("Failed to map keys for cache (all " + "partition nodes left the grid): " + cacheCtx.name());
/** * @param topVer Topology version. * @return Nodes where set data request should be sent. * @throws IgniteCheckedException If all cache nodes left grid. */ private Collection<ClusterNode> dataNodes(AffinityTopologyVersion topVer) throws IgniteCheckedException { assert ctx.isPartitioned() || collocated : "Non-collocated mode is supported only for PARTITIONED caches."; if (ctx.isLocal() || (ctx.isReplicated() && ctx.affinityNode())) return Collections.singleton(ctx.localNode()); Collection<ClusterNode> nodes; if (collocated) { List<ClusterNode> nodes0 = ctx.affinity().nodesByPartition(hdrPart, topVer); nodes = !nodes0.isEmpty() ? Collections.singleton(nodes0.contains(ctx.localNode()) ? ctx.localNode() : F.first(nodes0)) : nodes0; } else nodes = CU.affinityNodes(ctx, topVer); if (nodes.isEmpty()) throw new IgniteCheckedException("Failed to get set data, all cache nodes left grid."); return nodes; }
/** {@inheritDoc} */ @Override public IgniteCheckedException validateTopology( GridCacheSharedContext cctx, boolean read, GridDhtTopologyFuture topFut ) { if (cacheCtx == null) return null; Throwable err = topFut.validateCache(cacheCtx, recovery, read, null, entry); if (err != null) { return new IgniteCheckedException( "Failed to perform cache operation (cache topology is not valid): " + U.maskName(cacheCtx.name()), err); } if (CU.affinityNodes(cacheCtx, topFut.topologyVersion()).isEmpty()) { return new ClusterTopologyServerNotFoundException("Failed to map keys for cache (all " + "partition nodes left the grid): " + cacheCtx.name()); } return null; }
Collection<ClusterNode> affNodes = CU.affinityNodes(ctx, topVer);
Collection<ClusterNode> affNodes = CU.affinityNodes(ctx, topVer);
Collection<ClusterNode> affNodes = CU.affinityNodes(ctx, cand.topologyVersion());
AffinityTopologyVersion topVer ) { Collection<ClusterNode> affNodes = CU.affinityNodes(cctx, topVer);
AffinityTopologyVersion topVer ) { Collection<ClusterNode> cacheNodes = CU.affinityNodes(cctx, topVer);
Collection<ClusterNode> affNodes = CU.affinityNodes(ctx, cand.topologyVersion());
Collection<ClusterNode> topNodes = CU.affinityNodes(cctx, topVer);
if (CU.affinityNodes(cctx, topVer).isEmpty()) { onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for cache " + "(all partition nodes left the grid): " + cctx.name()));
if (CU.affinityNodes(cctx, topVer).isEmpty()) { onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for near-only cache (all " + "partition nodes left the grid)."));
Collection<ClusterNode> affNodes = CU.affinityNodes(cctx, topVer);
/** * @param topVer Topology version. * @return Nodes where set data request should be sent. * @throws IgniteCheckedException If all cache nodes left grid. */ @SuppressWarnings("unchecked") private Collection<ClusterNode> dataNodes(AffinityTopologyVersion topVer) throws IgniteCheckedException { if (ctx.isLocal() || ctx.isReplicated()) return Collections.singleton(ctx.localNode()); Collection<ClusterNode> nodes; if (collocated) { List<ClusterNode> nodes0 = ctx.affinity().nodesByPartition(hdrPart, topVer); nodes = !nodes0.isEmpty() ? Collections.singleton(nodes0.contains(ctx.localNode()) ? ctx.localNode() : F.first(nodes0)) : nodes0; } else nodes = CU.affinityNodes(ctx, topVer); if (nodes.isEmpty()) throw new IgniteCheckedException("Failed to get set data, all cache nodes left grid."); return nodes; }
/** * @param cctx Cache context. * @param prj Projection (optional). * @return Collection of data nodes in provided projection (if any). * @throws IgniteCheckedException If partition number is invalid. */ private static Collection<ClusterNode> nodes(final GridCacheContext<?, ?> cctx, @Nullable final ClusterGroup prj, @Nullable final Integer part) throws IgniteCheckedException { assert cctx != null; final AffinityTopologyVersion topVer = cctx.affinity().affinityTopologyVersion(); Collection<ClusterNode> affNodes = CU.affinityNodes(cctx, topVer); if (prj == null && part == null) return affNodes; if (part != null && part >= cctx.affinity().partitions()) throw new IgniteCheckedException("Invalid partition number: " + part); final Set<ClusterNode> owners = part == null ? Collections.<ClusterNode>emptySet() : new HashSet<>(cctx.topology().owners(part, topVer)); return F.view(affNodes, new P1<ClusterNode>() { @Override public boolean apply(ClusterNode n) { return cctx.discovery().cacheAffinityNode(n, cctx.name()) && (prj == null || prj.node(n.id()) != null) && (part == null || owners.contains(n)); } }); }
/** {@inheritDoc} */ @Override public IgniteCheckedException validateTopology( GridCacheSharedContext cctx, boolean read, GridDhtTopologyFuture topFut ) { if (cacheCtx == null) return null; Throwable err = topFut.validateCache(cacheCtx, recovery, read, null, entry); if (err != null) { return new IgniteCheckedException( "Failed to perform cache operation (cache topology is not valid): " + U.maskName(cacheCtx.name()), err); } if (CU.affinityNodes(cacheCtx, topFut.topologyVersion()).isEmpty()) { return new ClusterTopologyServerNotFoundException("Failed to map keys for cache (all " + "partition nodes left the grid): " + cacheCtx.name()); } return null; }