Search in sources :

Example 41 with TraceSurroundings

use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.

the class RegisteredQueryCursor method cancel.

/**
 * Cancels query.
 */
public void cancel() {
    try (TraceSurroundings ignored = MTC.support(tracing.create(SQL_CURSOR_CANCEL, qrySpan))) {
        if (failReason == null)
            failReason = new QueryCancelledException();
        qrySpan.addTag(ERROR, failReason::getMessage);
        close();
    }
}
Also used : QueryCancelledException(org.apache.ignite.cache.query.QueryCancelledException) TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings)

Example 42 with TraceSurroundings

use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.

the class QueryParser method parse.

/**
 * Parse the query.
 *
 * @param schemaName schema name.
 * @param qry query to parse.
 * @param remainingAllowed Whether multiple statements are allowed.
 * @return Parsing result that contains Parsed leading query and remaining sql script.
 */
public QueryParserResult parse(String schemaName, SqlFieldsQuery qry, boolean remainingAllowed) {
    try (TraceSurroundings ignored = MTC.support(idx.kernalContext().tracing().create(SQL_QRY_PARSE, MTC.span()))) {
        QueryParserResult res = parse0(schemaName, qry, remainingAllowed);
        checkQueryType(qry, res.isSelect());
        return res;
    }
}
Also used : TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings)

Example 43 with TraceSurroundings

use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.

the class GridReduceQueryExecutor method onNextPage.

/**
 * @param node Node.
 * @param msg Message.
 */
public void onNextPage(final ClusterNode node, final GridQueryNextPageResponse msg) {
    try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_PAGE_RESP, MTC.span()))) {
        final long qryReqId = msg.queryRequestId();
        final int qry = msg.query();
        final int seg = msg.segmentId();
        final ReduceQueryRun r = runs.get(qryReqId);
        if (// Already finished with error or canceled.
        r == null)
            return;
        final int pageSize = r.pageSize();
        Reducer idx = r.reducers().get(msg.query());
        ReduceResultPage page;
        try {
            page = new ReduceResultPage(ctx, node.id(), msg) {

                @Override
                public void fetchNextPage() {
                    if (r.hasErrorOrRetry()) {
                        if (r.exception() != null)
                            throw r.exception();
                        assert r.retryCause() != null;
                        throw new CacheException(r.retryCause());
                    }
                    try {
                        GridQueryNextPageRequest msg0 = new GridQueryNextPageRequest(qryReqId, qry, seg, pageSize, (byte) GridH2QueryRequest.setDataPageScanEnabled(0, r.isDataPageScanEnabled()));
                        if (node.isLocal())
                            h2.mapQueryExecutor().onNextPageRequest(node, msg0);
                        else
                            ctx.io().sendToGridTopic(node, GridTopic.TOPIC_QUERY, msg0, GridIoPolicy.QUERY_POOL);
                    } catch (IgniteCheckedException e) {
                        throw new CacheException("Failed to fetch data from node: " + node.id(), e);
                    }
                }
            };
        } catch (Exception e) {
            U.error(log, "Error in message.", e);
            MTC.span().addTag(ERROR, e::getMessage);
            fail(r, node.id(), "Error in message.", GridQueryFailResponse.GENERAL_ERROR);
            return;
        }
        idx.addPage(page);
        if (msg.retry() != null)
            r.setStateOnRetry(node.id(), msg.retry(), msg.retryCause());
        else if (// Count down only on each first page received.
        msg.page() == 0)
            r.onFirstPage();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheException(javax.cache.CacheException) GridQueryNextPageRequest(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest) TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings) QueryCancelledException(org.apache.ignite.cache.query.QueryCancelledException) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) TransactionAlreadyCompletedException(org.apache.ignite.transactions.TransactionAlreadyCompletedException) IgniteTxAlreadyCompletedCheckedException(org.apache.ignite.internal.transactions.IgniteTxAlreadyCompletedCheckedException) QueryRetryException(org.apache.ignite.cache.query.QueryRetryException) SQLException(java.sql.SQLException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) CacheException(javax.cache.CacheException) TransactionException(org.apache.ignite.transactions.TransactionException)

Example 44 with TraceSurroundings

use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.

the class GridReduceQueryExecutor method onFail.

/**
 * @param node Node.
 * @param msg Message.
 */
public void onFail(ClusterNode node, GridQueryFailResponse msg) {
    try (TraceSurroundings ignored = MTC.support(ctx.tracing().create(SQL_FAIL_RESP, MTC.span()))) {
        ReduceQueryRun r = runs.get(msg.queryRequestId());
        fail(r, node.id(), msg.error(), msg.failCode());
    }
}
Also used : TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings)

Example 45 with TraceSurroundings

use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings 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);
    }
}
Also used : DmlDistributedUpdateRun(org.apache.ignite.internal.processors.query.h2.dml.DmlDistributedUpdateRun) TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings) QueryCancelledException(org.apache.ignite.cache.query.QueryCancelledException) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) TransactionAlreadyCompletedException(org.apache.ignite.transactions.TransactionAlreadyCompletedException) IgniteTxAlreadyCompletedCheckedException(org.apache.ignite.internal.transactions.IgniteTxAlreadyCompletedCheckedException) QueryRetryException(org.apache.ignite.cache.query.QueryRetryException) SQLException(java.sql.SQLException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) CacheException(javax.cache.CacheException) TransactionException(org.apache.ignite.transactions.TransactionException)

Aggregations

TraceSurroundings (org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings)49 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)18 QueryCancelledException (org.apache.ignite.cache.query.QueryCancelledException)11 SQLException (java.sql.SQLException)10 IgniteException (org.apache.ignite.IgniteException)10 ArrayList (java.util.ArrayList)9 CacheException (javax.cache.CacheException)8 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)7 List (java.util.List)6 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)6 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)6 Collections.singletonList (java.util.Collections.singletonList)5 ClusterTopologyServerNotFoundException (org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException)5 BatchUpdateException (java.sql.BatchUpdateException)4 CacheServerNotFoundException (org.apache.ignite.cache.CacheServerNotFoundException)4 QueryRetryException (org.apache.ignite.cache.query.QueryRetryException)4 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)4 IgniteClusterReadOnlyException (org.apache.ignite.internal.processors.cache.distributed.dht.IgniteClusterReadOnlyException)4 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)4 QueryContext (org.apache.ignite.internal.processors.query.h2.opt.QueryContext)4