use of org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse 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();
}
Aggregations