Search in sources :

Example 1 with GridQueryNextPageRequest

use of org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest in project ignite by apache.

the class GridMapQueryExecutor method onMessage.

/**
     * @param nodeId Node ID.
     * @param msg Message.
     */
public void onMessage(UUID nodeId, Object msg) {
    try {
        assert msg != null;
        ClusterNode node = ctx.discovery().node(nodeId);
        if (node == null)
            // Node left, ignore.
            return;
        boolean processed = true;
        if (msg instanceof GridH2QueryRequest)
            onQueryRequest(node, (GridH2QueryRequest) msg);
        else if (msg instanceof GridQueryNextPageRequest)
            onNextPageRequest(node, (GridQueryNextPageRequest) msg);
        else if (msg instanceof GridQueryCancelRequest)
            onCancel(node, (GridQueryCancelRequest) msg);
        else
            processed = false;
        if (processed && log.isDebugEnabled())
            log.debug("Processed request: " + nodeId + "->" + ctx.localNodeId() + " " + msg);
    } catch (Throwable th) {
        U.error(log, "Failed to process message: " + msg, th);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridQueryCancelRequest(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest) GridQueryNextPageRequest(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest) GridH2QueryRequest(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest)

Example 2 with GridQueryNextPageRequest

use of org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest in project ignite by apache.

the class GridReduceQueryExecutor method onNextPage.

/**
     * @param node Node.
     * @param msg Message.
     */
private void onNextPage(final ClusterNode node, GridQueryNextPageResponse msg) {
    final long qryReqId = msg.queryRequestId();
    final int qry = msg.query();
    final int seg = msg.segmentId();
    final ReduceQueryRun r = runs.get(qryReqId);
    if (// Already finished with error or canceled.
    r == null)
        return;
    final int pageSize = r.pageSize();
    GridMergeIndex idx = r.indexes().get(msg.query());
    GridResultPage page;
    try {
        page = new GridResultPage(ctx, node.id(), msg) {

            @Override
            public void fetchNextPage() {
                Object errState = r.state();
                if (errState != null) {
                    CacheException err0 = errState instanceof CacheException ? (CacheException) errState : null;
                    if (err0 != null && err0.getCause() instanceof IgniteClientDisconnectedException)
                        throw err0;
                    CacheException e = new CacheException("Failed to fetch data from node: " + node.id());
                    if (err0 != null)
                        e.addSuppressed(err0);
                    throw e;
                }
                try {
                    GridQueryNextPageRequest msg0 = new GridQueryNextPageRequest(qryReqId, qry, seg, pageSize);
                    if (node.isLocal())
                        h2.mapQueryExecutor().onMessage(ctx.localNodeId(), msg0);
                    else
                        ctx.io().sendToGridTopic(node, GridTopic.TOPIC_QUERY, msg0, GridIoPolicy.QUERY_POOL);
                } catch (IgniteCheckedException e) {
                    throw new CacheException("Failed to fetch data from node: " + node.id(), e);
                }
            }
        };
    } catch (Exception e) {
        U.error(log, "Error in message.", e);
        fail(r, node.id(), "Error in message.", GridQueryFailResponse.GENERAL_ERROR);
        return;
    }
    idx.addPage(page);
    if (msg.retry() != null)
        retry(r, msg.retry(), node.id());
    else if (// Do count down on each first page received.
    msg.page() == 0)
        r.latch().countDown();
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheException(javax.cache.CacheException) GridQueryNextPageRequest(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) QueryCancelledException(org.apache.ignite.cache.query.QueryCancelledException) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) SQLException(java.sql.SQLException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) CacheException(javax.cache.CacheException)

Aggregations

GridQueryNextPageRequest (org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest)2 SQLException (java.sql.SQLException)1 CacheException (javax.cache.CacheException)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)1 IgniteException (org.apache.ignite.IgniteException)1 QueryCancelledException (org.apache.ignite.cache.query.QueryCancelledException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)1 GridQueryCancelRequest (org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest)1 GridH2QueryRequest (org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest)1