Search in sources :

Example 1 with RunningQuery

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

Example 2 with RunningQuery

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);
    }
}
Also used : RunningQuery(org.apache.ignite.internal.sql.engine.RunningQuery) RootQuery(org.apache.ignite.internal.sql.engine.RootQuery) RemoteException(org.apache.ignite.internal.sql.engine.metadata.RemoteException) IgniteInternalCheckedException(org.apache.ignite.lang.IgniteInternalCheckedException) IgniteInternalException(org.apache.ignite.lang.IgniteInternalException) RemoteException(org.apache.ignite.internal.sql.engine.metadata.RemoteException)

Aggregations

RootQuery (org.apache.ignite.internal.sql.engine.RootQuery)2 RunningQuery (org.apache.ignite.internal.sql.engine.RunningQuery)2 RemoteException (org.apache.ignite.internal.sql.engine.metadata.RemoteException)2 IgniteInternalCheckedException (org.apache.ignite.lang.IgniteInternalCheckedException)2 IgniteInternalException (org.apache.ignite.lang.IgniteInternalException)2 Query (org.apache.ignite.internal.sql.engine.Query)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