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