Esempio n. 1
0
  /**
   * Removes all candidates for node.
   *
   * @param nodeId Node ID.
   * @return Current owner.
   */
  @Nullable
  public CacheLockCandidates removeExplicitNodeCandidates(UUID nodeId) {
    if (rmts != null) {
      for (Iterator<GridCacheMvccCandidate> it = rmts.iterator(); it.hasNext(); ) {
        GridCacheMvccCandidate cand = it.next();

        if (!cand.tx() && (nodeId.equals(cand.nodeId()) || nodeId.equals(cand.otherNodeId()))) {
          cand.setUsed(); // Mark as used to be consistent.
          cand.setRemoved();

          it.remove();
        }
      }

      if (rmts.isEmpty()) rmts = null;
    }

    if (locs != null) {
      for (Iterator<GridCacheMvccCandidate> it = locs.iterator(); it.hasNext(); ) {
        GridCacheMvccCandidate cand = it.next();

        if (!cand.tx() && nodeId.equals(cand.otherNodeId()) && cand.dhtLocal()) {
          cand.setUsed(); // Mark as used to be consistent.
          cand.setRemoved();

          it.remove();
        }
      }

      if (locs.isEmpty()) locs = null;
    }

    reassign();

    return allOwners();
  }