use of org.apache.ignite.internal.sql.engine.RunningQuery in project ignite-3 by apache.
the class ExecutionServiceImpl method onMessage.
@SuppressWarnings("unchecked")
private void onMessage(String nodeId, QueryStartRequest msg) {
assert nodeId != null && msg != null;
try {
Query<RowT> qry = (Query<RowT>) queryRegistry.register(new Query<>(msg.queryId(), nodeId, null, exchangeSrvc, (q) -> queryRegistry.unregister(q.id()), LOG));
QueryPlan qryPlan = qryPlanCache.queryPlan(new CacheKey(msg.schema(), msg.root()), () -> prepareFragment(msg.root()));
FragmentPlan plan = (FragmentPlan) qryPlan;
final BaseQueryContext qctx = createQueryContext(Contexts.empty(), msg.schema());
ExecutionContext<RowT> ectx = new ExecutionContext<>(qctx, taskExecutor, msg.queryId(), locNodeId, nodeId, msg.topologyVersion(), msg.fragmentDescription(), handler, Commons.parametersMap(msg.parameters()));
executeFragment(qry, plan, ectx);
} catch (Throwable ex) {
LOG.error("Failed to start query fragment", ex);
mailboxRegistry.outboxes(msg.queryId(), msg.fragmentId(), -1).forEach(Outbox::close);
mailboxRegistry.inboxes(msg.queryId(), msg.fragmentId(), -1).forEach(Inbox::close);
try {
msgSrvc.send(nodeId, FACTORY.queryStartResponse().queryId(msg.queryId()).fragmentId(msg.fragmentId()).error(ex).build());
} catch (Exception e) {
LOG.error("Error occurred during send error message", e);
IgniteInternalException wrpEx = new IgniteInternalException("Error occurred during send error message", e);
e.addSuppressed(ex);
RunningQuery qry = queryRegistry.query(msg.queryId());
qry.cancel();
throw wrpEx;
}
throw ex;
}
}
use of org.apache.ignite.internal.sql.engine.RunningQuery in project ignite-3 by apache.
the class ExecutionServiceImpl method onMessage.
private void onMessage(String nodeId, ErrorMessage msg) {
assert nodeId != null && msg != null;
RunningQuery qry = queryRegistry.query(msg.queryId());
if (qry != null && qry.state() != QueryState.CLOSED) {
assert qry instanceof RootQuery : "Unexpected query object: " + qry;
Exception e = new RemoteException(nodeId, msg.queryId(), msg.fragmentId(), msg.error());
((RootQuery<?>) qry).onError(e);
}
}
Aggregations