use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.
the class IgniteTxHandler method processDhtTxFinishRequest.
/**
* @param nodeId Node ID.
* @param req Request.
*/
@SuppressWarnings({ "unchecked" })
private void processDhtTxFinishRequest(final UUID nodeId, final GridDhtTxFinishRequest req) {
try (TraceSurroundings ignored = MTC.support(ctx.kernalContext().tracing().create(TX_PROCESS_DHT_FINISH_REQ, MTC.span()))) {
assert nodeId != null;
assert req != null;
if (req.checkCommitted()) {
boolean committed = req.waitRemoteTransactions() || !ctx.tm().addRolledbackTx(null, req.version());
if (!committed || req.syncMode() != FULL_SYNC)
sendReply(nodeId, req, committed, null);
else {
IgniteInternalFuture<?> fut = ctx.tm().remoteTxFinishFuture(req.version());
fut.listen(new CI1<IgniteInternalFuture<?>>() {
@Override
public void apply(IgniteInternalFuture<?> fut) {
sendReply(nodeId, req, true, null);
}
});
}
return;
}
// Always add version to rollback history to prevent races with rollbacks.
if (!req.commit())
ctx.tm().addRolledbackTx(null, req.version());
GridDhtTxRemote dhtTx = ctx.tm().tx(req.version());
GridNearTxRemote nearTx = ctx.tm().nearTx(req.version());
IgniteInternalTx anyTx = U.<IgniteInternalTx>firstNotNull(dhtTx, nearTx);
final GridCacheVersion nearTxId = anyTx != null ? anyTx.nearXidVersion() : null;
if (txFinishMsgLog.isDebugEnabled())
txFinishMsgLog.debug("Received dht finish request [txId=" + nearTxId + ", dhtTxId=" + req.version() + ", node=" + nodeId + ']');
if (anyTx == null && req.commit())
ctx.tm().addCommittedTx(null, req.version(), null);
if (dhtTx != null)
finish(nodeId, dhtTx, req);
else {
try {
applyPartitionsUpdatesCounters(req.updateCounters(), !req.commit(), false);
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
}
if (nearTx != null)
finish(nodeId, nearTx, req);
if (req.replyRequired()) {
IgniteInternalFuture completeFut;
IgniteInternalFuture<IgniteInternalTx> dhtFin = dhtTx == null ? null : dhtTx.done() ? null : dhtTx.finishFuture();
final IgniteInternalFuture<IgniteInternalTx> nearFin = nearTx == null ? null : nearTx.done() ? null : nearTx.finishFuture();
if (dhtFin != null && nearFin != null) {
GridCompoundFuture fut = new GridCompoundFuture();
fut.add(dhtFin);
fut.add(nearFin);
fut.markInitialized();
completeFut = fut;
} else
completeFut = dhtFin != null ? dhtFin : nearFin;
if (completeFut != null) {
completeFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
@Override
public void apply(IgniteInternalFuture<IgniteInternalTx> fut) {
sendReply(nodeId, req, true, nearTxId);
}
});
} else
sendReply(nodeId, req, true, nearTxId);
} else
sendReply(nodeId, req, true, null);
assert req.txState() != null || (dhtTx == null && nearTx == null) : req + " tx=" + dhtTx + " nearTx=" + nearTx;
}
}
use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.
the class IgniteTxHandler method processDhtTxFinishResponse.
/**
* @param nodeId Node ID.
* @param res Response.
*/
private void processDhtTxFinishResponse(UUID nodeId, GridDhtTxFinishResponse res) {
try (TraceSurroundings ignored = MTC.support(ctx.kernalContext().tracing().create(TX_PROCESS_DHT_FINISH_RESP, MTC.span()))) {
assert nodeId != null;
assert res != null;
if (res.checkCommitted()) {
GridNearTxFinishFuture fut = (GridNearTxFinishFuture) ctx.mvcc().<IgniteInternalTx>future(res.futureId());
if (fut == null) {
if (txFinishMsgLog.isDebugEnabled()) {
txFinishMsgLog.debug("Failed to find future for dht finish check committed response [txId=null" + ", dhtTxId=" + res.xid() + ", node=" + nodeId + ", res=" + res + ']');
}
return;
} else if (txFinishMsgLog.isDebugEnabled()) {
txFinishMsgLog.debug("Received dht finish check committed response [txId=" + fut.tx().nearXidVersion() + ", dhtTxId=" + res.xid() + ", node=" + nodeId + ']');
}
fut.onResult(nodeId, res);
} else {
GridDhtTxFinishFuture fut = (GridDhtTxFinishFuture) ctx.mvcc().<IgniteInternalTx>future(res.futureId());
if (fut == null) {
if (txFinishMsgLog.isDebugEnabled()) {
txFinishMsgLog.debug("Failed to find future for dht finish response [txId=null" + ", dhtTxId=" + res.xid() + ", node=" + nodeId + ", res=" + res);
}
return;
} else if (txFinishMsgLog.isDebugEnabled()) {
txFinishMsgLog.debug("Received dht finish response [txId=" + fut.tx().nearXidVersion() + ", dhtTxId=" + res.xid() + ", node=" + nodeId + ']');
}
fut.onResult(nodeId, res);
}
}
}
use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.
the class IgniteTxHandler method processNearTxFinishResponse.
/**
* @param nodeId Node ID.
* @param res Response.
*/
private void processNearTxFinishResponse(UUID nodeId, GridNearTxFinishResponse res) {
try (TraceSurroundings ignored = MTC.support(ctx.kernalContext().tracing().create(TX_NEAR_FINISH_RESP, MTC.span()))) {
if (txFinishMsgLog.isDebugEnabled())
txFinishMsgLog.debug("Received near finish response [txId=" + res.xid() + ", node=" + nodeId + ']');
GridNearTxFinishFuture fut = (GridNearTxFinishFuture) ctx.mvcc().<IgniteInternalTx>future(res.futureId());
if (fut == null) {
if (txFinishMsgLog.isDebugEnabled()) {
txFinishMsgLog.debug("Failed to find future for near finish response [txId=" + res.xid() + ", node=" + nodeId + ", res=" + res + ']');
}
return;
}
fut.onResult(nodeId, res);
}
}
use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.
the class TestRecordingCommunicationSpi method stopBlock.
/**
* Stops block messages and sends all already blocked messages if sndMsgs is 'true' optionally filtered by
* unblockPred.
*
* @param sndMsgs If {@code true} sends blocked messages.
* @param unblockPred If not null unblocks only messages allowed by predicate.
* @param clearFilters {@code true} to clear filters.
* @param rmvBlockedMsgs {@code true} to remove blocked messages. Sometimes useful in conjunction with {@code
* sndMsgs=false}.
*/
public void stopBlock(boolean sndMsgs, @Nullable IgnitePredicate<BlockedMessageDescriptor> unblockPred, boolean clearFilters, boolean rmvBlockedMsgs) {
synchronized (this) {
if (clearFilters) {
blockCls.clear();
blockP = null;
}
Iterator<BlockedMessageDescriptor> iter = blockedMsgs.iterator();
while (iter.hasNext()) {
BlockedMessageDescriptor blockedMsg = iter.next();
// It is important what predicate if called only once for each message.
if (unblockPred != null && !unblockPred.apply(blockedMsg))
continue;
if (sndMsgs) {
try (TraceSurroundings ignored = MTC.supportContinual(blockedMsg.span())) {
ignite.log().info("Send blocked message " + blockedMsg);
super.sendMessage(blockedMsg.destinationNode(), blockedMsg.ioMessage());
} catch (Throwable e) {
U.error(ignite.log(), "Failed to send blocked message: " + blockedMsg, e);
}
}
if (rmvBlockedMsgs)
iter.remove();
}
}
}
use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.
the class DmlBatchSender method sendBatch.
/**
* Send the batch.
*
* @param batch Batch.
*/
private void sendBatch(Batch batch) {
try (TraceSurroundings ignored = MTC.support(cctx.kernalContext().tracing().create(SQL_CACHE_UPDATE, MTC.span()).addTag(SQL_CACHE_UPDATES, () -> Integer.toString(batch.size())))) {
DmlPageProcessingResult pageRes = processPage(cctx, batch);
batch.clear();
updateCnt += pageRes.count();
if (failedKeys == null)
failedKeys = new ArrayList<>();
failedKeys.addAll(F.asList(pageRes.errorKeys()));
if (pageRes.error() != null) {
MTC.span().addTag(ERROR, pageRes.error()::getMessage);
if (err == null)
err = pageRes.error();
else
err.setNextException(pageRes.error());
}
}
}
Aggregations