コード例 #1
0
  /**
   * @param nodeId Sender.
   * @param res Result.
   */
  void onResult(UUID nodeId, GridNearTxFinishResponse<K, V> res) {
    if (!isDone())
      for (GridFuture<GridCacheTx> fut : futures()) {
        if (isMini(fut)) {
          MiniFuture f = (MiniFuture) fut;

          if (f.futureId().equals(res.miniId())) {
            assert f.node().id().equals(nodeId);

            f.onResult(res);
          }
        }
      }
  }
コード例 #2
0
  /** {@inheritDoc} */
  @Override
  public boolean onNodeLeft(UUID nodeId) {
    for (GridFuture<?> fut : futures())
      if (isMini(fut)) {
        MiniFuture f = (MiniFuture) fut;

        if (f.node().id().equals(nodeId)) {
          // Remove previous mapping.
          mappings.remove(nodeId);

          f.onResult(new GridTopologyException("Remote node left grid (will fail): " + nodeId));

          return true;
        }
      }

    return false;
  }
コード例 #3
0
  /** @param m Mapping. */
  private void finish(GridDistributedTxMapping<K, V> m) {
    GridNode n = m.node();

    assert !m.empty();

    GridNearTxFinishRequest<K, V> req =
        new GridNearTxFinishRequest<>(
            futId,
            tx.xidVersion(),
            tx.threadId(),
            commit,
            tx.isInvalidate(),
            m.explicitLock(),
            tx.topologyVersion(),
            null,
            null,
            null,
            tx.size(),
            commit && tx.pessimistic() ? m.writes() : null,
            commit && tx.pessimistic() ? tx.writeEntries() : null,
            commit ? tx.syncCommit() : tx.syncRollback(),
            tx.subjectId(),
            tx.taskNameHash());

    // If this is the primary node for the keys.
    if (n.isLocal()) {
      req.miniId(GridUuid.randomUuid());

      if (CU.DHT_ENABLED) {
        GridFuture<GridCacheTx> fut =
            commit ? dht().commitTx(n.id(), req) : dht().rollbackTx(n.id(), req);

        // Add new future.
        add(fut);
      } else
        // Add done future for testing.
        add(new GridFinishedFuture<GridCacheTx>(ctx));
    } else {
      MiniFuture fut = new MiniFuture(m);

      req.miniId(fut.futureId());

      add(fut); // Append new future.

      if (tx.pessimistic()) cctx.tm().beforeFinishRemote(n.id(), tx.threadId());

      try {
        cctx.io().send(n, req);

        // If we don't wait for result, then mark future as done.
        if (!isSync() && !m.explicitLock()) fut.onDone();
      } catch (GridTopologyException e) {
        // Remove previous mapping.
        mappings.remove(m.node().id());

        fut.onResult(e);
      } catch (GridException e) {
        // Fail the whole thing.
        fut.onResult(e);
      }
    }
  }