use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.
the class RegisteredQueryCursor method close.
/**
* {@inheritDoc}
*/
@Override
public void close() {
Span span = MTC.span();
try (TraceSurroundings ignored = MTC.support(tracing.create(SQL_CURSOR_CLOSE, span != NoopSpan.INSTANCE ? span : qrySpan))) {
super.close();
unregisterQuery();
} catch (Throwable th) {
qrySpan.addTag(ERROR, th::getMessage);
throw th;
}
}
use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.
the class GridDhtTxFinishFuture method onDone.
/**
* {@inheritDoc}
*/
@Override
public boolean onDone(IgniteInternalTx tx, Throwable err) {
try (TraceSurroundings ignored = MTC.support(span)) {
if (initialized() || err != null) {
Throwable e = this.err;
if (this.tx.onePhaseCommit() && (this.tx.state() == COMMITTING)) {
try {
boolean nodeStopping = X.hasCause(err, NodeStoppingException.class);
this.tx.tmFinish(err == null, nodeStopping || cctx.kernalContext().failure().nodeStopping(), false);
} catch (IgniteCheckedException finishErr) {
U.error(log, "Failed to finish tx: " + tx, e);
if (e == null)
e = finishErr;
}
}
if (commit && e == null)
e = this.tx.commitError();
Throwable finishErr = e != null ? e : err;
if (super.onDone(tx, finishErr)) {
cctx.tm().mvccFinish(this.tx);
if (finishErr == null)
finishErr = this.tx.commitError();
if (this.tx.syncMode() != PRIMARY_SYNC)
this.tx.sendFinishReply(finishErr);
if (!this.tx.txState().mvccEnabled() && !commit && shouldApplyCountersOnRollbackError(finishErr)) {
TxCounters txCounters = this.tx.txCounters(false);
if (txCounters != null) {
try {
cctx.tm().txHandler().applyPartitionsUpdatesCounters(txCounters.updateCounters(), true, true);
} catch (IgniteCheckedException e0) {
throw new IgniteException(e0);
}
}
}
// Don't forget to clean up.
cctx.mvcc().removeFuture(futId);
return true;
}
}
return false;
}
}
use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.
the class GridNearTxFinishFuture method finish.
/**
* {@inheritDoc}
*/
@Override
public void finish(final boolean commit, final boolean clearThreadMap, final boolean onTimeout) {
try (TraceSurroundings ignored = MTC.supportContinual(span = cctx.kernalContext().tracing().create(TX_NEAR_FINISH, MTC.span()))) {
if (!cctx.mvcc().addFuture(this, futureId()))
return;
if (tx.onNeedCheckBackup()) {
assert tx.onePhaseCommit();
checkBackup();
// If checkBackup is set, it means that primary node has crashed and we will not need to send
// finish request to it, so we can mark future as initialized.
markInitialized();
return;
}
if (!commit && !clearThreadMap)
rollbackAsyncSafe(onTimeout);
else
doFinish(commit, clearThreadMap);
}
}
use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.
the class GridNearTxLocal method enlistWrite.
/**
* @param cacheCtx Cache context.
* @param cacheKey Key to enlist.
* @param val Value.
* @param expiryPlc Explicitly specified expiry policy for entry.
* @param entryProcessor Entry processor (for invoke operation).
* @param invokeArgs Optional arguments for EntryProcessor.
* @param retval Flag indicating whether a value should be returned.
* @param lockOnly If {@code true}, then entry will be enlisted as noop.
* @param filter User filters.
* @param ret Return value.
* @param skipStore Skip store flag.
* @param singleRmv {@code True} for single key remove operation ({@link Cache#remove(Object)}.
* @param recovery Recovery flag.
* @param dataCenterId Optional data center Id.
* @return Future for entry values loading.
*/
private <K, V> IgniteInternalFuture<Void> enlistWrite(final GridCacheContext cacheCtx, @Nullable AffinityTopologyVersion entryTopVer, KeyCacheObject cacheKey, Object val, @Nullable ExpiryPolicy expiryPlc, @Nullable EntryProcessor<K, V, Object> entryProcessor, @Nullable Object[] invokeArgs, final boolean retval, boolean lockOnly, final CacheEntryPredicate[] filter, final GridCacheReturn ret, boolean skipStore, final boolean singleRmv, boolean keepBinary, boolean recovery, Byte dataCenterId) {
try (TraceSurroundings ignored2 = MTC.support(context().kernalContext().tracing().create(TX_NEAR_ENLIST_WRITE, MTC.span()))) {
GridFutureAdapter<Void> enlistFut = new GridFutureAdapter<>();
try {
if (!updateLockFuture(null, enlistFut))
return finishFuture(enlistFut, timedOut() ? timeoutException() : rollbackException(), false);
addActiveCache(cacheCtx, recovery);
final boolean hasFilters = !F.isEmptyOrNulls(filter) && !F.isAlwaysTrue(filter);
final boolean needVal = singleRmv || retval || hasFilters;
final boolean needReadVer = needVal && (serializable() && optimistic());
if (entryProcessor != null)
transform = true;
GridCacheVersion drVer = dataCenterId != null ? cacheCtx.cache().nextVersion(dataCenterId) : null;
boolean loadMissed = enlistWriteEntry(cacheCtx, entryTopVer, cacheKey, val, entryProcessor, invokeArgs, expiryPlc, retval, lockOnly, filter, /*drVer*/
drVer, /*drTtl*/
-1L, /*drExpireTime*/
-1L, ret, /*enlisted*/
null, skipStore, singleRmv, hasFilters, needVal, needReadVer, keepBinary, recovery);
if (loadMissed) {
AffinityTopologyVersion topVer = topologyVersionSnapshot();
if (topVer == null)
topVer = entryTopVer;
IgniteInternalFuture<Void> loadFut = loadMissing(cacheCtx, topVer != null ? topVer : topologyVersion(), Collections.singleton(cacheKey), filter, ret, needReadVer, singleRmv, hasFilters, /*read through*/
(entryProcessor != null || cacheCtx.config().isLoadPreviousValue()) && !skipStore, retval, keepBinary, recovery, expiryPlc);
loadFut.listen(new IgniteInClosure<IgniteInternalFuture<Void>>() {
@Override
public void apply(IgniteInternalFuture<Void> fut) {
try {
fut.get();
finishFuture(enlistFut, null, true);
} catch (IgniteCheckedException e) {
finishFuture(enlistFut, e, true);
}
}
});
return enlistFut;
}
finishFuture(enlistFut, null, true);
return enlistFut;
} catch (IgniteCheckedException e) {
return finishFuture(enlistFut, e, true);
}
}
}
use of org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings in project ignite by apache.
the class IgniteTxHandler method processDhtTxPrepareResponse.
/**
* @param nodeId Node ID.
* @param res Response.
*/
private void processDhtTxPrepareResponse(UUID nodeId, GridDhtTxPrepareResponse res) {
try (TraceSurroundings ignored = MTC.support(ctx.kernalContext().tracing().create(TX_PROCESS_DHT_PREPARE_RESP, MTC.span()))) {
GridDhtTxPrepareFuture fut = (GridDhtTxPrepareFuture) ctx.mvcc().versionedFuture(res.version(), res.futureId());
if (fut == null) {
if (txPrepareMsgLog.isDebugEnabled()) {
txPrepareMsgLog.debug("Failed to find future for dht prepare response [txId=null" + ", dhtTxId=" + res.version() + ", node=" + nodeId + ", res=" + res + ']');
}
return;
} else if (txPrepareMsgLog.isDebugEnabled())
txPrepareMsgLog.debug("Received dht prepare response [txId=" + fut.tx().nearXidVersion() + ", node=" + nodeId + ']');
IgniteInternalTx tx = fut.tx();
assert tx != null;
res.txState(tx.txState());
fut.onResult(nodeId, res);
}
}
Aggregations