use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishFuture in project ignite by apache.
the class GridNearTxLocal method commitAsyncLocal.
/**
* Commits local part of colocated transaction.
*
* @return Commit future.
*/
public IgniteInternalFuture<IgniteInternalTx> commitAsyncLocal() {
if (log.isDebugEnabled())
log.debug("Committing colocated tx locally: " + this);
IgniteInternalFuture<?> prep = prepFut;
// Do not create finish future if there are no remote nodes.
if (F.isEmpty(dhtMap) && F.isEmpty(nearMap)) {
if (prep != null)
return (IgniteInternalFuture<IgniteInternalTx>) prep;
return new GridFinishedFuture<IgniteInternalTx>(this);
}
final GridDhtTxFinishFuture fut = new GridDhtTxFinishFuture<>(cctx, this, true);
cctx.mvcc().addFuture(fut, fut.futureId());
if (prep == null || prep.isDone()) {
assert prep != null || optimistic();
IgniteCheckedException err = null;
try {
if (prep != null)
// Check for errors of a parent future.
prep.get();
} catch (IgniteCheckedException e) {
err = e;
U.error(log, "Failed to prepare transaction: " + this, e);
}
if (err != null)
fut.rollbackOnError(err);
else
fut.finish(true);
} else
prep.listen(new CI1<IgniteInternalFuture<?>>() {
@Override
public void apply(IgniteInternalFuture<?> f) {
IgniteCheckedException err = null;
try {
// Check for errors of a parent future.
f.get();
} catch (IgniteCheckedException e) {
err = e;
U.error(log, "Failed to prepare transaction: " + this, e);
}
if (err != null)
fut.rollbackOnError(err);
else
fut.finish(true);
}
});
return fut;
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishFuture in project ignite by apache.
the class IgniteTxHandler method processDhtTxFinishResponse.
/**
* @param nodeId Node ID.
* @param res Response.
*/
private void processDhtTxFinishResponse(UUID nodeId, GridDhtTxFinishResponse res) {
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.cache.distributed.dht.GridDhtTxFinishFuture in project ignite by apache.
the class GridNearTxLocal method rollbackAsyncLocal.
/**
* Rolls back local part of colocated transaction.
*
* @return Commit future.
*/
public IgniteInternalFuture<IgniteInternalTx> rollbackAsyncLocal() {
if (log.isDebugEnabled())
log.debug("Rolling back colocated tx locally: " + this);
final GridDhtTxFinishFuture fut = new GridDhtTxFinishFuture<>(cctx, this, false);
cctx.mvcc().addFuture(fut, fut.futureId());
IgniteInternalFuture<?> prep = prepFut;
if (prep == null || prep.isDone()) {
try {
if (prep != null)
prep.get();
} catch (IgniteCheckedException e) {
if (log.isDebugEnabled())
log.debug("Failed to prepare transaction during rollback (will ignore) [tx=" + this + ", msg=" + e.getMessage() + ']');
}
fut.finish(false);
} else
prep.listen(new CI1<IgniteInternalFuture<?>>() {
@Override
public void apply(IgniteInternalFuture<?> f) {
try {
// Check for errors of a parent future.
f.get();
} catch (IgniteCheckedException e) {
log.debug("Failed to prepare transaction during rollback (will ignore) [tx=" + this + ", msg=" + e.getMessage() + ']');
}
fut.finish(false);
}
});
return fut;
}
Aggregations