Search in sources :

Example 1 with BaseQueryContext

use of org.apache.ignite.internal.sql.engine.util.BaseQueryContext 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;
    }
}
Also used : FragmentPlan(org.apache.ignite.internal.sql.engine.prepare.FragmentPlan) RootQuery(org.apache.ignite.internal.sql.engine.RootQuery) RunningQuery(org.apache.ignite.internal.sql.engine.RunningQuery) Query(org.apache.ignite.internal.sql.engine.Query) BaseQueryContext(org.apache.ignite.internal.sql.engine.util.BaseQueryContext) IgniteInternalException(org.apache.ignite.lang.IgniteInternalException) QueryPlan(org.apache.ignite.internal.sql.engine.prepare.QueryPlan) IgniteInternalCheckedException(org.apache.ignite.lang.IgniteInternalCheckedException) IgniteInternalException(org.apache.ignite.lang.IgniteInternalException) RemoteException(org.apache.ignite.internal.sql.engine.metadata.RemoteException) RunningQuery(org.apache.ignite.internal.sql.engine.RunningQuery) CacheKey(org.apache.ignite.internal.sql.engine.prepare.CacheKey)

Aggregations

Query (org.apache.ignite.internal.sql.engine.Query)1 RootQuery (org.apache.ignite.internal.sql.engine.RootQuery)1 RunningQuery (org.apache.ignite.internal.sql.engine.RunningQuery)1 RemoteException (org.apache.ignite.internal.sql.engine.metadata.RemoteException)1 CacheKey (org.apache.ignite.internal.sql.engine.prepare.CacheKey)1 FragmentPlan (org.apache.ignite.internal.sql.engine.prepare.FragmentPlan)1 QueryPlan (org.apache.ignite.internal.sql.engine.prepare.QueryPlan)1 BaseQueryContext (org.apache.ignite.internal.sql.engine.util.BaseQueryContext)1 IgniteInternalCheckedException (org.apache.ignite.lang.IgniteInternalCheckedException)1 IgniteInternalException (org.apache.ignite.lang.IgniteInternalException)1