use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.
the class GridNearAtomicSingleUpdateFuture method waitAndRemap.
/**
* @param remapTopVer New topology version.
*/
private void waitAndRemap(AffinityTopologyVersion remapTopVer) {
if (topLocked) {
CachePartialUpdateCheckedException e = new CachePartialUpdateCheckedException("Failed to update keys (retry update if possible).");
ClusterTopologyCheckedException cause = new ClusterTopologyCheckedException("Failed to update keys, topology changed while execute atomic update inside transaction.");
cause.retryReadyFuture(cctx.shared().exchange().affinityReadyFuture(remapTopVer));
e.add(Collections.singleton(cctx.toCacheKeyObject(key)), cause);
completeFuture(null, e, null);
return;
}
IgniteInternalFuture<AffinityTopologyVersion> fut = cctx.shared().exchange().affinityReadyFuture(remapTopVer);
if (fut == null)
fut = new GridFinishedFuture<>(remapTopVer);
fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
@Override
public void apply(final IgniteInternalFuture<AffinityTopologyVersion> fut) {
cctx.kernalContext().closure().runLocalSafe(new GridPlainRunnable() {
@Override
public void run() {
mapOnTopology();
}
});
}
});
}
use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.
the class GridNearAtomicSingleUpdateFuture method onPrimaryResponse.
/**
* {@inheritDoc}
*/
@Override
public void onPrimaryResponse(UUID nodeId, GridNearAtomicUpdateResponse res, boolean nodeErr) {
GridNearAtomicAbstractUpdateRequest req;
AffinityTopologyVersion remapTopVer0;
GridCacheReturn opRes0 = null;
CachePartialUpdateCheckedException err0 = null;
synchronized (this) {
if (!checkFutureId(res.futureId()))
return;
req = reqState.processPrimaryResponse(nodeId, res);
if (req == null)
return;
boolean remapKey = res.remapTopologyVersion() != null;
if (remapKey) {
assert !req.topologyVersion().equals(res.remapTopologyVersion());
assert remapTopVer == null : remapTopVer;
remapTopVer = res.remapTopologyVersion();
} else if (res.error() != null)
onPrimaryError(req, res);
else {
GridCacheReturn ret = res.returnValue();
if (op == TRANSFORM) {
if (ret != null) {
assert ret.value() == null || ret.value() instanceof Map : ret.value();
if (ret.value() != null) {
if (opRes != null)
opRes.mergeEntryProcessResults(ret);
else
opRes = ret;
}
}
} else
opRes = ret;
assert reqState != null;
if (!reqState.onPrimaryResponse(res, cctx))
return;
}
remapTopVer0 = onAllReceived();
if (remapTopVer0 == null) {
err0 = err;
opRes0 = opRes;
}
}
if (res.error() != null && res.failedKeys() == null) {
completeFuture(null, res.error(), res.futureId());
return;
}
if (remapTopVer0 != null) {
waitAndRemap(remapTopVer0);
return;
}
if (nearEnabled && !nodeErr)
updateNear(req, res);
completeFuture(opRes0, err0, res.futureId());
}
use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.
the class GridNearAtomicSingleUpdateFuture method onDhtResponse.
/**
* {@inheritDoc}
*/
@Override
public void onDhtResponse(UUID nodeId, GridDhtAtomicNearResponse res) {
GridCacheReturn opRes0;
CachePartialUpdateCheckedException err0;
AffinityTopologyVersion remapTopVer0;
synchronized (this) {
if (!checkFutureId(res.futureId()))
return;
assert reqState != null;
assert reqState.req.nodeId().equals(res.primaryId());
if (opRes == null && res.hasResult())
opRes = res.result();
if (reqState.onDhtResponse(nodeId, res)) {
opRes0 = opRes;
err0 = err;
remapTopVer0 = onAllReceived();
} else
return;
}
UpdateErrors errors = res.errors();
if (errors != null) {
assert errors.error() != null;
completeFuture(null, errors.error(), res.futureId());
return;
}
finishUpdateFuture(opRes0, err0, remapTopVer0, res.futureId());
}
use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.
the class GridNearAtomicSingleUpdateFuture method checkDhtNodes.
/**
* @param futId Future ID.
*/
private void checkDhtNodes(long futId) {
GridCacheReturn opRes0 = null;
CachePartialUpdateCheckedException err0 = null;
AffinityTopologyVersion remapTopVer0 = null;
GridNearAtomicCheckUpdateRequest checkReq = null;
synchronized (this) {
if (!checkFutureId(futId))
return;
assert reqState != null;
DhtLeftResult res = reqState.checkDhtNodes(cctx);
if (res == DhtLeftResult.DONE) {
opRes0 = opRes;
err0 = err;
remapTopVer0 = onAllReceived();
} else if (res == DhtLeftResult.ALL_RCVD_CHECK_PRIMARY)
checkReq = new GridNearAtomicCheckUpdateRequest(reqState.req);
else
return;
}
if (checkReq != null)
sendCheckUpdateRequest(checkReq);
else
finishUpdateFuture(opRes0, err0, remapTopVer0, futId);
}
use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.
the class GridNearAtomicUpdateFuture method onPrimaryResponse.
/**
* {@inheritDoc}
*/
@Override
public void onPrimaryResponse(UUID nodeId, GridNearAtomicUpdateResponse res, boolean nodeErr) {
GridNearAtomicAbstractUpdateRequest req;
AffinityTopologyVersion remapTopVer0 = null;
GridCacheReturn opRes0 = null;
CachePartialUpdateCheckedException err0 = null;
boolean rcvAll;
synchronized (this) {
if (!checkFutureId(res.futureId()))
return;
if (singleReq != null) {
req = singleReq.processPrimaryResponse(nodeId, res);
if (req == null)
return;
rcvAll = singleReq.onPrimaryResponse(res, cctx);
} else {
if (mappings == null)
return;
PrimaryRequestState reqState = mappings.get(nodeId);
if (reqState == null)
return;
req = reqState.processPrimaryResponse(nodeId, res);
if (req != null) {
if (reqState.onPrimaryResponse(res, cctx)) {
assert mappings.size() > resCnt : "[mappings=" + mappings.size() + ", cnt=" + resCnt + ']';
resCnt++;
rcvAll = mappings.size() == resCnt;
} else {
assert mappings.size() > resCnt : "[mappings=" + mappings.size() + ", cnt=" + resCnt + ']';
rcvAll = false;
}
} else
return;
}
assert req.topologyVersion().equals(topVer) : req;
if (res.remapTopologyVersion() != null) {
assert !req.topologyVersion().equals(res.remapTopologyVersion());
if (remapKeys == null)
remapKeys = U.newHashSet(req.size());
remapKeys.addAll(req.keys());
if (remapTopVer == null || remapTopVer.compareTo(res.remapTopologyVersion()) < 0)
remapTopVer = req.topologyVersion();
} else if (res.error() != null)
onPrimaryError(req, res);
else {
GridCacheReturn ret = res.returnValue();
if (op == TRANSFORM) {
if (ret != null) {
assert ret.value() == null || ret.value() instanceof Map : ret.value();
if (ret.value() != null) {
if (opRes != null)
opRes.mergeEntryProcessResults(ret);
else
opRes = ret;
}
}
} else
opRes = ret;
}
if (rcvAll) {
remapTopVer0 = onAllReceived();
if (remapTopVer0 == null) {
err0 = err;
opRes0 = opRes;
}
}
}
if (res.error() != null && res.failedKeys() == null) {
completeFuture(null, res.error(), res.futureId());
return;
}
if (rcvAll && nearEnabled) {
if (mappings != null) {
for (PrimaryRequestState reqState : mappings.values()) {
GridNearAtomicUpdateResponse res0 = reqState.req.response();
assert res0 != null : reqState;
updateNear(reqState.req, res0);
}
} else if (!nodeErr)
updateNear(req, res);
}
if (remapTopVer0 != null) {
waitAndRemap(remapTopVer0);
return;
}
if (rcvAll)
completeFuture(opRes0, err0, res.futureId());
}
Aggregations