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);
}
}
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();
}
Aggregations