use of org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse in project ignite by apache.
the class GridMapQueryExecutor method sendNextPage.
/**
* @param nodeRess Results.
* @param node Node.
* @param qr Query results.
* @param qry Query.
* @param segmentId Index segment ID.
* @param pageSize Page size.
*/
private void sendNextPage(NodeResults nodeRess, ClusterNode node, QueryResults qr, int qry, int segmentId, int pageSize) {
QueryResult res = qr.result(qry);
assert res != null;
if (res.closed)
return;
int page = res.page;
List<Value[]> rows = new ArrayList<>(Math.min(64, pageSize));
boolean last = res.fetchNextPage(rows, pageSize);
if (last) {
res.close();
if (qr.isAllClosed())
nodeRess.remove(qr.qryReqId, segmentId, qr);
}
try {
boolean loc = node.isLocal();
GridQueryNextPageResponse msg = new GridQueryNextPageResponse(qr.qryReqId, segmentId, qry, page, page == 0 ? res.rowCnt : -1, res.cols, loc ? null : toMessages(rows, new ArrayList<Message>(res.cols)), loc ? rows : null);
if (loc)
h2.reduceQueryExecutor().onMessage(ctx.localNodeId(), msg);
else
ctx.io().sendToGridTopic(node, GridTopic.TOPIC_QUERY, msg, QUERY_POOL);
} catch (IgniteCheckedException e) {
log.error("Failed to send message.", e);
throw new IgniteException(e);
}
}
use of org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse in project ignite by apache.
the class GridMapQueryExecutor method sendNextPage.
/**
* @param nodeRess Results.
* @param node Node.
* @param qr Query results.
* @param qry Query.
* @param segmentId Index segment ID.
* @param pageSize Page size.
*/
private void sendNextPage(MapNodeResults nodeRess, ClusterNode node, MapQueryResults qr, int qry, int segmentId, int pageSize) {
MapQueryResult res = qr.result(qry);
assert res != null;
if (res.closed())
return;
int page = res.page();
List<Value[]> rows = new ArrayList<>(Math.min(64, pageSize));
boolean last = res.fetchNextPage(rows, pageSize);
if (last) {
res.close();
if (qr.isAllClosed()) {
nodeRess.remove(qr.queryRequestId(), segmentId, qr);
// Release reservations if the last page fetched, all requests are closed and this is a lazy worker.
if (MapQueryLazyWorker.currentWorker() != null)
releaseReservations();
}
}
try {
boolean loc = node.isLocal();
GridQueryNextPageResponse msg = new GridQueryNextPageResponse(qr.queryRequestId(), segmentId, qry, page, page == 0 ? res.rowCount() : -1, res.columnCount(), loc ? null : toMessages(rows, new ArrayList<Message>(res.columnCount())), loc ? rows : null, last);
if (loc)
h2.reduceQueryExecutor().onMessage(ctx.localNodeId(), msg);
else
ctx.io().sendToGridTopic(node, GridTopic.TOPIC_QUERY, msg, QUERY_POOL);
} catch (IgniteCheckedException e) {
U.error(log, "Failed to send message.", e);
throw new IgniteException(e);
}
}
use of org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse in project ignite by apache.
the class GridMapQueryExecutor method sendRetry.
/**
* @param node Node.
* @param reqId Request ID.
* @param segmentId Index segment ID.
*/
private void sendRetry(ClusterNode node, long reqId, int segmentId) {
try {
boolean loc = node.isLocal();
GridQueryNextPageResponse msg = new GridQueryNextPageResponse(reqId, segmentId, /*qry*/
0, /*page*/
0, /*allRows*/
0, /*cols*/
1, loc ? null : Collections.<Message>emptyList(), loc ? Collections.<Value[]>emptyList() : null, false);
msg.retry(h2.readyTopologyVersion());
if (loc)
h2.reduceQueryExecutor().onMessage(ctx.localNodeId(), msg);
else
ctx.io().sendToGridTopic(node, GridTopic.TOPIC_QUERY, msg, QUERY_POOL);
} catch (Exception e) {
U.warn(log, "Failed to send retry message: " + e.getMessage());
}
}
use of org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse in project ignite by apache.
the class GridMergeIndex method markLastPage.
/**
* @param page Page.
*/
private void markLastPage(GridResultPage page) {
GridQueryNextPageResponse res = page.response();
if (!res.last()) {
UUID nodeId = page.source();
initLastPages(nodeId, res);
ConcurrentMap<SourceKey, Integer> lp = lastPages;
if (lp == null)
// It was not initialized --> wait for last page flag.
return;
Integer lastPage = lp.get(new SourceKey(nodeId, res.segmentId()));
if (lastPage == null)
// This node may use the new protocol --> wait for last page flag.
return;
if (lastPage != res.page()) {
assert lastPage > res.page();
// This is not the last page.
return;
}
}
page.setLast(true);
}
use of org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse in project ignite by apache.
the class GridReduceQueryExecutor 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 GridQueryNextPageResponse)
onNextPage(node, (GridQueryNextPageResponse) msg);
else if (msg instanceof GridQueryFailResponse)
onFail(node, (GridQueryFailResponse) msg);
else if (msg instanceof GridH2DmlResponse)
onDmlResponse(node, (GridH2DmlResponse) msg);
else
processed = false;
if (processed && log.isDebugEnabled())
log.debug("Processed response: " + nodeId + "->" + ctx.localNodeId() + " " + msg);
} catch (Throwable th) {
U.error(log, "Failed to process message: " + msg, th);
}
}
Aggregations