コード例 #1
0
  /** {@inheritDoc} */
  @Override
  public void loadPage(
      long id, GridCacheQueryAdapter<?> qry, Collection<ClusterNode> nodes, boolean all) {
    assert cctx.config().getCacheMode() != LOCAL;
    assert qry != null;
    assert nodes != null;

    GridCacheDistributedQueryFuture<?, ?, ?> fut = futs.get(id);

    assert fut != null;

    try {
      GridCacheQueryRequest req =
          new GridCacheQueryRequest(
              cctx.cacheId(),
              id,
              cctx.name(),
              qry.pageSize(),
              qry.includeBackups(),
              fut.fields(),
              all,
              qry.keepPortable(),
              qry.subjectId(),
              qry.taskHash());

      sendRequest(fut, req, nodes);
    } catch (IgniteCheckedException e) {
      fut.onDone(e);
    }
  }
コード例 #2
0
  /** {@inheritDoc} */
  @SuppressWarnings("unchecked")
  @Override
  public CacheQueryFuture<?> queryDistributed(
      GridCacheQueryBean qry, Collection<ClusterNode> nodes) {
    assert cctx.config().getCacheMode() != LOCAL;

    if (log.isDebugEnabled()) log.debug("Executing distributed query: " + qry);

    long reqId = cctx.io().nextIoId();

    final GridCacheDistributedQueryFuture<K, V, ?> fut =
        new GridCacheDistributedQueryFuture<>(cctx, reqId, qry, nodes);

    try {
      qry.query().validate();

      String clsName = qry.query().queryClassName();

      GridCacheQueryRequest req =
          new GridCacheQueryRequest(
              cctx.cacheId(),
              reqId,
              cctx.name(),
              qry.query().type(),
              false,
              qry.query().clause(),
              clsName,
              qry.query().scanFilter(),
              qry.query().partition(),
              qry.reducer(),
              qry.transform(),
              qry.query().pageSize(),
              qry.query().includeBackups(),
              qry.arguments(),
              false,
              qry.query().keepPortable(),
              qry.query().subjectId(),
              qry.query().taskHash());

      addQueryFuture(req.id(), fut);

      final Object topic = topic(cctx.nodeId(), req.id());

      cctx.io().addOrderedHandler(topic, resHnd);

      fut.listen(
          new CI1<IgniteInternalFuture<?>>() {
            @Override
            public void apply(IgniteInternalFuture<?> fut) {
              cctx.io().removeOrderedHandler(topic);
            }
          });

      sendRequest(fut, req, nodes);
    } catch (IgniteCheckedException e) {
      fut.onDone(e);
    }

    return fut;
  }