コード例 #1
0
  /** {@inheritDoc} */
  @Override
  protected boolean onPageReady(
      boolean loc, GridCacheQueryInfo qryInfo, Collection<?> data, boolean finished, Throwable e) {
    GridCacheLocalQueryFuture<?, ?, ?> fut = qryInfo.localQueryFuture();

    if (loc) assert fut != null;

    if (e != null) {
      if (loc) fut.onPage(null, null, e, true);
      else
        sendQueryResponse(
            qryInfo.senderId(),
            new GridCacheQueryResponse(cctx.cacheId(), qryInfo.requestId(), e),
            qryInfo.query().timeout());

      return true;
    }

    if (loc) fut.onPage(null, data, null, finished);
    else {
      GridCacheQueryResponse res =
          new GridCacheQueryResponse(
              cctx.cacheId(), qryInfo.requestId(), /*finished*/ false, /*fields*/ false);

      res.data(data);
      res.finished(finished);

      if (!sendQueryResponse(qryInfo.senderId(), res, qryInfo.query().timeout())) return false;
    }

    return true;
  }
コード例 #2
0
  /** {@inheritDoc} */
  @SuppressWarnings("ConstantConditions")
  @Override
  protected boolean onFieldsPageReady(
      boolean loc,
      GridCacheQueryInfo qryInfo,
      @Nullable List<GridQueryFieldMetadata> metadata,
      @Nullable Collection<?> entities,
      @Nullable Collection<?> data,
      boolean finished,
      @Nullable Throwable e) {
    assert qryInfo != null;

    if (e != null) {
      if (loc) {
        GridCacheLocalFieldsQueryFuture fut =
            (GridCacheLocalFieldsQueryFuture) qryInfo.localQueryFuture();

        fut.onPage(null, null, null, e, true);
      } else
        sendQueryResponse(
            qryInfo.senderId(),
            new GridCacheQueryResponse(cctx.cacheId(), qryInfo.requestId(), e),
            qryInfo.query().timeout());

      return true;
    }

    if (loc) {
      GridCacheLocalFieldsQueryFuture fut =
          (GridCacheLocalFieldsQueryFuture) qryInfo.localQueryFuture();

      fut.onPage(null, metadata, data, null, finished);
    } else {
      GridCacheQueryResponse res =
          new GridCacheQueryResponse(
              cctx.cacheId(), qryInfo.requestId(), finished, qryInfo.reducer() == null);

      res.metadata(metadata);
      res.data(entities != null ? entities : data);

      if (!sendQueryResponse(qryInfo.senderId(), res, qryInfo.query().timeout())) return false;
    }

    return true;
  }