/** {@inheritDoc} */
    @Override
    public String reduce(List<GridComputeJobResult> results) throws GridException {
      int sum = 0;

      String locNodeId = null;

      for (GridComputeJobResult res : results) {
        GridBiTuple<String, Integer> part = res.getData();

        if (locNodeId == null) locNodeId = part.get1();

        Integer i = part.get2();

        if (i != null) sum += i;
      }

      assert gridSize == sum;

      return locNodeId;
    }
  /**
   * Default implementation which will wait for all jobs to complete before calling {@link
   * #reduce(List)} method.
   *
   * <p>If remote job resulted in exception ({@link GridComputeJobResult#getException()} is not
   * {@code null}), then {@link GridComputeJobResultPolicy#FAILOVER} policy will be returned if the
   * exception is instance of {@link GridTopologyException} or {@link
   * GridComputeExecutionRejectedException}, which means that remote node either failed or job
   * execution was rejected before it got a chance to start. In all other cases the exception will
   * be rethrown which will ultimately cause task to fail.
   *
   * @param res Received remote grid executable result.
   * @param rcvd All previously received results.
   * @return Result policy that dictates how to process further upcoming job results.
   * @throws GridException If handling a job result caused an error effectively rejecting a
   *     failover. This exception will be thrown out of {@link GridComputeTaskFuture#get()} method.
   */
  @Override
  public GridComputeJobResultPolicy result(
      GridComputeJobResult res, List<GridComputeJobResult> rcvd) throws GridException {
    GridException e = res.getException();

    // Try to failover if result is failed.
    if (e != null) {
      // Don't failover user's code errors.
      if (e instanceof GridComputeExecutionRejectedException
          || e instanceof GridTopologyException
          ||
          // Failover exception is always wrapped.
          e.hasCause(GridComputeJobFailoverException.class)) return FAILOVER;

      throw new GridException(
          "Remote job threw user exception (override or implement GridComputeTask.result(..) "
              + "method if you would like to have automatic failover for this exception).",
          e);
    }

    // Wait for all job responses.
    return WAIT;
  }