Search in sources :

Example 1 with GridH2DmlResponse

use of org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlResponse in project ignite by apache.

the class DistributedUpdateRun method handleResponse.

/**
 * Handle response from remote node.
 *
 * @param id Node id.
 * @param msg Response message.
 */
void handleResponse(UUID id, GridH2DmlResponse msg) {
    synchronized (this) {
        if (!rspNodes.add(id))
            // ignore duplicated messages
            return;
        String err = msg.error();
        if (err != null) {
            fut.onDone(new IgniteCheckedException("Update failed. " + (F.isEmpty(err) ? "" : err) + "[reqId=" + msg.requestId() + ", node=" + id + "]."));
            return;
        }
        if (!F.isEmpty(msg.errorKeys())) {
            List<Object> errList = Arrays.asList(msg.errorKeys());
            if (errorKeys == null)
                errorKeys = new HashSet<>(errList);
            else
                errorKeys.addAll(errList);
        }
        updCntr += msg.updateCounter();
        if (rspNodes.size() == nodeCount)
            fut.onDone(new UpdateResult(updCntr, errorKeys == null ? null : errorKeys.toArray()));
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) UpdateResult(org.apache.ignite.internal.processors.query.h2.UpdateResult) HashSet(java.util.HashSet)

Example 2 with GridH2DmlResponse

use of org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlResponse in project ignite by apache.

the class GridMapQueryExecutor method sendUpdateResponse.

/**
 * Sends update response for DML request.
 *
 * @param node Node.
 * @param reqId Request id.
 * @param updResult Update result.
 * @param error Error message.
 */
@SuppressWarnings("deprecation")
private void sendUpdateResponse(ClusterNode node, long reqId, UpdateResult updResult, String error) {
    try {
        GridH2DmlResponse rsp = new GridH2DmlResponse(reqId, updResult == null ? 0 : updResult.counter(), updResult == null ? null : updResult.errorKeys(), error);
        if (log.isDebugEnabled())
            log.debug("Sending: [localNodeId=" + ctx.localNodeId() + ", node=" + node.id() + ", msg=" + rsp + "]");
        if (node.isLocal())
            h2.reduceQueryExecutor().onMessage(ctx.localNodeId(), rsp);
        else {
            rsp.marshall(ctx.config().getMarshaller());
            ctx.io().sendToGridTopic(node, GridTopic.TOPIC_QUERY, rsp, QUERY_POOL);
        }
    } catch (Exception e) {
        U.error(log, "Failed to send message.", e);
    }
}
Also used : GridH2DmlResponse(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlResponse) QueryCancelledException(org.apache.ignite.cache.query.QueryCancelledException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) GridH2RetryException(org.apache.ignite.internal.processors.query.h2.opt.GridH2RetryException) CacheException(javax.cache.CacheException)

Example 3 with GridH2DmlResponse

use of org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlResponse in project ignite by apache.

the class GridReduceQueryExecutor method onMessage.

/**
 * @param nodeId Node ID.
 * @param msg Message.
 */
public void onMessage(UUID nodeId, Object msg) {
    try {
        assert msg != null;
        ClusterNode node = ctx.discovery().node(nodeId);
        if (node == null)
            // Node left, ignore.
            return;
        boolean processed = true;
        if (msg instanceof GridQueryNextPageResponse)
            onNextPage(node, (GridQueryNextPageResponse) msg);
        else if (msg instanceof GridQueryFailResponse)
            onFail(node, (GridQueryFailResponse) msg);
        else if (msg instanceof GridH2DmlResponse)
            onDmlResponse(node, (GridH2DmlResponse) msg);
        else
            processed = false;
        if (processed && log.isDebugEnabled())
            log.debug("Processed response: " + nodeId + "->" + ctx.localNodeId() + " " + msg);
    } catch (Throwable th) {
        U.error(log, "Failed to process message: " + msg, th);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridQueryFailResponse(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse) GridQueryNextPageResponse(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse) GridH2DmlResponse(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlResponse)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 GridH2DmlResponse (org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlResponse)2 HashSet (java.util.HashSet)1 CacheException (javax.cache.CacheException)1 IgniteException (org.apache.ignite.IgniteException)1 QueryCancelledException (org.apache.ignite.cache.query.QueryCancelledException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 UpdateResult (org.apache.ignite.internal.processors.query.h2.UpdateResult)1 GridH2RetryException (org.apache.ignite.internal.processors.query.h2.opt.GridH2RetryException)1 GridQueryFailResponse (org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse)1 GridQueryNextPageResponse (org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse)1