Ejemplo n.º 1
0
  /** {@inheritDoc} */
  @Override
  protected void clone0(GridTcpCommunicationMessageAdapter _msg) {
    super.clone0(_msg);

    GridDhtUnlockRequest _clone = (GridDhtUnlockRequest) _msg;

    _clone.nearKeyBytes = nearKeyBytes;
    _clone.nearKeys = nearKeys;
  }
  /**
   * @param nodeId Node ID.
   * @param req Request.
   */
  @SuppressWarnings({"RedundantTypeArguments"})
  public void clearLocks(UUID nodeId, GridDhtUnlockRequest<K, V> req) {
    assert nodeId != null;

    GridCacheVersion obsoleteVer = ctx.versions().next();

    List<K> keys = req.nearKeys();

    if (keys != null) {
      for (K key : keys) {
        while (true) {
          GridDistributedCacheEntry<K, V> entry = peekExx(key);

          try {
            if (entry != null) {
              entry.doneRemote(
                  req.version(), req.version(), req.committedVersions(), req.rolledbackVersions());

              // Note that we don't reorder completed versions here,
              // as there is no point to reorder relative to the version
              // we are about to remove.
              if (entry.removeLock(req.version())) {
                if (log.isDebugEnabled())
                  log.debug("Removed lock [lockId=" + req.version() + ", key=" + key + ']');

                // Try to evict near entry dht-mapped locally.
                evictNearEntry(entry, obsoleteVer);
              } else {
                if (log.isDebugEnabled())
                  log.debug(
                      "Received unlock request for unknown candidate "
                          + "(added to cancelled locks set): "
                          + req);
              }
            } else if (log.isDebugEnabled())
              log.debug("Received unlock request for entry that could not be found: " + req);

            break;
          } catch (GridCacheEntryRemovedException ignored) {
            if (log.isDebugEnabled())
              log.debug(
                  "Received remove lock request for removed entry (will retry) [entry="
                      + entry
                      + ", req="
                      + req
                      + ']');
          }
        }
      }
    }
  }