/** * Converts collection of nodes to collection of node IDs. * * @param nodes Nodes. * @return Node IDs. */ public static Collection<UUID> nodeIds(@Nullable Collection<? extends GridNode> nodes) { return F.viewReadOnly(nodes, F.node2id()); }
/** * @param nodeId Node ID. * @return {@code True} if node is in the ring and is not being removed from. */ private boolean nodeAlive(UUID nodeId) { // Is node alive or about to be removed from the ring? GridTcpDiscoveryNode node = ring.node(nodeId); boolean nodeAlive = node != null && node.visible(); if (nodeAlive) { synchronized (mux) { nodeAlive = !F.transform(failedNodes, F.node2id()).contains(nodeId) && !F.transform(leavingNodes, F.node2id()).contains(nodeId); } } return nodeAlive; }
/** {@inheritDoc} */ @Override public Collection<GridNode> nodes(int p, long topVer) { Collection<GridNode> affNodes = cctx.affinity().nodes(p, topVer); lock.readLock().lock(); try { assert node2part != null && node2part.valid() : "Invalid node-to-partitions map [topVer=" + topVer + ", node2part=" + node2part + ']'; Collection<GridNode> nodes = null; Collection<UUID> nodeIds = part2node.get(p); if (!F.isEmpty(nodeIds)) { Collection<UUID> affIds = new HashSet<>(F.viewReadOnly(affNodes, F.node2id())); for (UUID nodeId : nodeIds) { if (!affIds.contains(nodeId) && hasState(p, nodeId, OWNING, MOVING, RENTING)) { GridNode n = cctx.discovery().node(nodeId); if (n != null && (topVer < 0 || n.order() <= topVer)) { if (nodes == null) { nodes = new ArrayList<>(affNodes.size() + 2); nodes.addAll(affNodes); } nodes.add(n); } } } } return nodes != null ? nodes : affNodes; } finally { lock.readLock().unlock(); } }
/** * @param nodes Nodes. * @param id ID. * @param partMap Partition map. * @throws GridException If failed. */ private void sendAllPartitions(Collection<? extends GridNode> nodes, GridDhtPartitionExchangeId id, GridDhtPartitionFullMap partMap) throws GridException { GridDhtPartitionsFullMessage<K, V> m = new GridDhtPartitionsFullMessage<>(id, partMap, lastVer.get(), id.topologyVersion()); if (log.isDebugEnabled()) log.debug("Sending full partition map [nodeIds=" + F.viewReadOnly(nodes, F.node2id()) + ", exchId=" + exchId + ", msg=" + m + ']'); cctx.io().safeSend(nodes, m, null); }
/** * Cleans metrics store. */ private void cleanMetricsStore() { assert metricsStore != null; try { Collection<UUID> ids = F.view(metricsStore.allNodeIds(), F.notContains( F.viewReadOnly(ring.allNodes(), F.node2id()))); if (!ids.isEmpty()) metricsStore.removeMetrics(ids); } catch (GridSpiException e) { LT.error(log, e, "Failed to clean metrics store up."); } } }
waitForStopAck.put(routineId, new GridConcurrentHashSet<>(F.viewReadOnly(nodes, F.node2id())));
F.viewReadOnly( ggfsCtx.kernalContext().discovery().allNodes(), F.node2id(), new P1<GridNode>() { @Override public boolean apply(GridNode n) {
F.viewReadOnly( ggfsCtx.kernalContext().discovery().allNodes(), F.node2id(), new P1<GridNode>() { @Override public boolean apply(GridNode n) {
nodeIds = new GridConcurrentHashSet<>(F.viewReadOnly(nodes, F.node2id()));
if (last != null && equal(last.nodeIds(), F.viewReadOnly(affNodes, F.node2id()))) {
if (last != null && equal(last.nodeIds(), F.viewReadOnly(affNodes, F.node2id()))) {
", affNodes=" + F.nodeIds(affNodes) + ']'); if (last != null && equal(last.nodeIds(), F.viewReadOnly(affNodes, F.node2id()))) {
", affNodes=" + F.nodeIds(affNodes) + ']'); if (last != null && equal(last.nodeIds(), F.viewReadOnly(affNodes, F.node2id()))) {