@Override public boolean apply(GridNode node) { return node.order() <= topVer; } });
/** * Gets the youngest node in given collection. * * @param nodes Nodes. * @return Youngest node or {@code null} if collection is empty. */ @Nullable private static GridNode youngest(Collection<GridNode> nodes) { long max = Long.MIN_VALUE; GridNode youngest = null; for (GridNode n : nodes) if (n.order() > max) { max = n.order(); youngest = n; } return youngest; }
/** * Gets the oldest node in given collection. * * @param nodes Nodes. * @return Oldest node or {@code null} if collection is empty. */ @Nullable private static GridNode oldest(Collection<GridNode> nodes) { long min = Long.MAX_VALUE; GridNode oldest = null; for (GridNode n : nodes) if (n.order() < min) { min = n.order(); oldest = n; } return oldest; }
/** * Gets oldest alive node for specified topology version. * * @param cctx Cache context. * @param topOrder Maximum allowed node order. * @return Oldest node for the given topology version. */ public static GridNode oldest(GridCacheContext cctx, long topOrder) { GridNode oldest = null; for (GridNode n : aliveNodes(cctx, topOrder)) if (oldest == null || n.order() < oldest.order()) oldest = n; assert oldest != null; return oldest; }
/** * Gets oldest node out of collection of nodes. * * @param c Collection of nodes. * @return Oldest node. */ public static GridNode oldest(Collection<GridNode> c, @Nullable GridPredicate<GridNode> p) { GridNode oldest = null; long minOrder = Long.MAX_VALUE; for (GridNode n : c) { if ((p == null || p.apply(n)) && n.order() < minOrder) { oldest = n; minOrder = n.order(); } } return oldest; }
/** * Gets youngest node out of collection of nodes. * * @param c Collection of nodes. * @return Youngest node. */ public static GridNode youngest(Collection<GridNode> c, @Nullable GridPredicate<GridNode> p) { GridNode youngest = null; long maxOrder = Long.MIN_VALUE; for (GridNode n : c) { if ((p == null || p.apply(n)) && n.order() > maxOrder) { youngest = n; maxOrder = n.order(); } } return youngest; }
/** * Removes left node from cached alives lists. * * @param leftNode Left node. */ void updateAlives(GridNode leftNode) { if (leftNode.order() > maxOrder) return; filterNodeMap(aliveCacheNodes, leftNode); filterNodeMap(aliveRmtCacheNodes, leftNode); }
/** * @param node Node. * @return Recovery receive data for given node. */ private GridNioRecoveryDescriptor recoveryDescriptor(GridNode node) { ClientKey id = new ClientKey(node.id(), node.order()); GridNioRecoveryDescriptor recovery = recoveryDescs.get(id); if (recovery == null) { int maxSize = Math.max(msgQueueLimit, ackSndThreshold); int queueLimit = unackedMsgsBufSize != 0 ? unackedMsgsBufSize : (maxSize * 5); GridNioRecoveryDescriptor old = recoveryDescs.putIfAbsent(id, recovery = new GridNioRecoveryDescriptor(queueLimit, node, log)); if (old != null) recovery = old; } return recovery; }
/** * @param node Node to get a short description for. * @return Short description for the node to be used in 'quiet' mode. */ private String quietNode(GridNode node) { assert node != null; return "nodeId8=" + node.id().toString().substring(0, 8) + ", " + "addrs=" + U.addressesAsString(node) + ", " + "order=" + node.order() + ", " + "CPUs=" + node.metrics().getTotalCpus(); }
/** {@inheritDoc} */ @Override public String toString() { GridNode oldestNode = this.oldestNode.get(); return S.toString(GridDhtPartitionsExchangeFuture.class, this, "oldest", oldestNode == null ? "null" : oldestNode.id(), "oldestOrder", oldestNode == null ? "null" : oldestNode.order(), "evtLatch", evtLatch == null ? "null" : evtLatch.getCount(), "remaining", remaining(), "super", super.toString()); } }
/** * Short node representation. * * @param n Grid node. * @return Short string representing the node. */ public static String toShortString(GridNode n) { return "GridNode [id=" + n.id() + ", order=" + n.order() + ", addr=" + n.addresses() + ", daemon=" + n.isDaemon() + ']'; }
/** * @return {@code True} if start version. */ protected boolean isStartVersion() { return ver.nodeOrder() == cctx.localNode().order() && ver.order() == startVer; }
GridNode n = cctx.discovery().node(id); if (n != null && (topVer < 0 || n.order() <= topVer)) nodes.add(n);
/** {@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(); } }
@Override public void onTimeout() { if (isDone()) return; if (!enterBusy()) return; try { U.warn(log, "Retrying preload partition exchange due to timeout [done=" + isDone() + ", dummy=" + dummy + ", exchId=" + exchId + ", rcvdIds=" + F.id8s(rcvdIds) + ", rmtIds=" + F.id8s(rmtIds) + ", remaining=" + F.id8s(remaining()) + ", init=" + init + ", initFut=" + initFut.isDone() + ", ready=" + ready + ", replied=" + replied + ", added=" + added + ", oldest=" + U.id8(oldestNode.get().id()) + ", oldestOrder=" + oldestNode.get().order() + ", evtLatch=" + evtLatch.getCount() + ", locNodeOrder=" + cctx.localNode().order() + ", locNodeId=" + cctx.localNode().id() + ']', "Retrying preload partition exchange due to timeout."); recheck(); } finally { leaveBusy(); } } };
updateSeq.setIfGreater(node2part.updateSequence()); node2part = new GridDhtPartitionFullMap(loc.id(), loc.order(), updateSeq.incrementAndGet(), node2part, false);