use of org.apache.ignite.internal.processors.query.h2.sql.GridSqlOperationType.IN in project ignite by apache.
the class GridReduceQueryExecutor method onDmlResponse.
/**
* Process response for DML request.
*
* @param node Node.
* @param msg Message.
*/
public void onDmlResponse(final ClusterNode node, GridH2DmlResponse msg) {
try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_DML_QRY_RESP, MTC.span()))) {
long reqId = msg.requestId();
DmlDistributedUpdateRun r = updRuns.get(reqId);
if (r == null) {
U.warn(log, "Unexpected dml response (will ignore). [localNodeId=" + ctx.localNodeId() + ", nodeId=" + node.id() + ", msg=" + msg.toString() + ']');
return;
}
r.handleResponse(node.id(), msg);
} catch (Exception e) {
U.error(log, "Error in dml response processing. [localNodeId=" + ctx.localNodeId() + ", nodeId=" + node.id() + ", msg=" + msg.toString() + ']', e);
}
}
use of org.apache.ignite.internal.processors.query.h2.sql.GridSqlOperationType.IN in project ignite by apache.
the class GridMapQueryExecutor method onDmlRequest.
/**
* @param node Node.
* @param req DML request.
*/
public void onDmlRequest(final ClusterNode node, final GridH2DmlRequest req) {
int[] parts = req.queryPartitions();
List<Integer> cacheIds = req.caches();
long reqId = req.requestId();
AffinityTopologyVersion topVer = req.topologyVersion();
PartitionReservation reserved = null;
MapNodeResults nodeResults = resultsForNode(node.id());
// We don't use try with resources on purpose - the catch block must also be executed in the context of this span.
TraceSurroundings trace = MTC.support(ctx.tracing().create(SpanType.SQL_DML_QRY_EXEC_REQ, MTC.span()).addTag(SQL_QRY_TEXT, req::query));
try {
reserved = h2.partitionReservationManager().reservePartitions(cacheIds, topVer, parts, node.id(), reqId);
if (reserved.failed()) {
U.error(log, "Failed to reserve partitions for DML request. [localNodeId=" + ctx.localNodeId() + ", nodeId=" + node.id() + ", reqId=" + req.requestId() + ", cacheIds=" + cacheIds + ", topVer=" + topVer + ", parts=" + Arrays.toString(parts) + ']');
sendUpdateResponse(node, reqId, null, "Failed to reserve partitions for DML request. " + reserved.error());
return;
}
IndexingQueryFilter filter = h2.backupFilter(topVer, parts);
GridQueryCancel cancel = nodeResults.putUpdate(reqId);
SqlFieldsQuery fldsQry = new SqlFieldsQuery(req.query());
if (req.parameters() != null)
fldsQry.setArgs(req.parameters());
fldsQry.setEnforceJoinOrder(req.isFlagSet(GridH2QueryRequest.FLAG_ENFORCE_JOIN_ORDER));
fldsQry.setPageSize(req.pageSize());
fldsQry.setLocal(true);
if (req.timeout() > 0 || req.explicitTimeout())
fldsQry.setTimeout(req.timeout(), TimeUnit.MILLISECONDS);
boolean local = true;
final boolean replicated = req.isFlagSet(GridH2QueryRequest.FLAG_REPLICATED);
if (!replicated && !F.isEmpty(cacheIds) && CU.firstPartitioned(ctx.cache().context(), cacheIds).config().getQueryParallelism() > 1) {
fldsQry.setDistributedJoins(true);
local = false;
}
UpdateResult updRes = h2.executeUpdateOnDataNode(req.schemaName(), fldsQry, filter, cancel, local);
GridCacheContext<?, ?> mainCctx = !F.isEmpty(cacheIds) ? ctx.cache().context().cacheContext(cacheIds.get(0)) : null;
boolean evt = local && mainCctx != null && mainCctx.events().isRecordable(EVT_CACHE_QUERY_EXECUTED);
if (evt) {
ctx.event().record(new CacheQueryExecutedEvent<>(node, "SQL query executed.", EVT_CACHE_QUERY_EXECUTED, CacheQueryType.SQL.name(), mainCctx.name(), null, req.query(), null, null, req.parameters(), node.id(), null));
}
sendUpdateResponse(node, reqId, updRes, null);
} catch (Exception e) {
MTC.span().addTag(ERROR, e::getMessage);
U.error(log, "Error processing dml request. [localNodeId=" + ctx.localNodeId() + ", nodeId=" + node.id() + ", req=" + req + ']', e);
sendUpdateResponse(node, reqId, null, e.getMessage());
} finally {
if (reserved != null)
reserved.release();
nodeResults.removeUpdate(reqId);
if (trace != null)
trace.close();
}
}
Aggregations