예제 #1
0
  /**
   * @param part Partition.
   * @param topVer Topology version.
   * @return Primary node for given key.
   */
  @Nullable
  public GridNode primary(int part, long topVer) {
    Collection<GridNode> nodes = nodes(part, topVer);

    if (nodes.isEmpty()) return null;

    return nodes.iterator().next();
  }
예제 #2
0
  /**
   * @param part Partition.
   * @param topVer Topology version.
   * @return Backup nodes.
   */
  public Collection<GridNode> backups(int part, long topVer) {
    Collection<GridNode> nodes = nodes(part, topVer);

    assert !F.isEmpty(nodes);

    if (nodes.size() <= 1) return Collections.emptyList();

    return F.view(nodes, F.notEqualTo(nodes.iterator().next()));
  }