use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.
the class PlatformCache method convertException.
/** {@inheritDoc} */
@Override
public Exception convertException(Exception e) {
if (e instanceof CachePartialUpdateException)
return new PlatformCachePartialUpdateException((CachePartialUpdateCheckedException) e.getCause(), platformCtx, keepBinary);
if (e instanceof CachePartialUpdateCheckedException)
return new PlatformCachePartialUpdateException((CachePartialUpdateCheckedException) e, platformCtx, keepBinary);
if (e.getCause() instanceof EntryProcessorException)
return (Exception) e.getCause();
TransactionDeadlockException deadlockException = X.cause(e, TransactionDeadlockException.class);
if (deadlockException != null)
return deadlockException;
TransactionTimeoutException timeoutException = X.cause(e, TransactionTimeoutException.class);
if (timeoutException != null)
return timeoutException;
return super.convertException(e);
}
use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.
the class GridNearAtomicUpdateFuture method onAllReceived.
/**
* @return Non null topology version if update should be remapped.
*/
@Nullable
private AffinityTopologyVersion onAllReceived() {
assert Thread.holdsLock(this);
assert futureMapped() : this;
AffinityTopologyVersion remapTopVer0 = null;
if (remapKeys != null) {
assert remapTopVer != null;
remapTopVer0 = remapTopVer;
} else {
if (err != null && X.hasCause(err, CachePartialUpdateCheckedException.class) && X.hasCause(err, ClusterTopologyCheckedException.class) && storeFuture() && --remapCnt > 0) {
ClusterTopologyCheckedException topErr = X.cause(err, ClusterTopologyCheckedException.class);
if (!(topErr instanceof ClusterTopologyServerNotFoundException)) {
CachePartialUpdateCheckedException cause = X.cause(err, CachePartialUpdateCheckedException.class);
assert cause != null && cause.topologyVersion() != null : err;
assert remapKeys == null;
assert remapTopVer == null;
remapTopVer = remapTopVer0 = new AffinityTopologyVersion(cause.topologyVersion().topologyVersion() + 1);
err = null;
Collection<Object> failedKeys = cause.failedKeys();
remapKeys = new ArrayList<>(failedKeys.size());
for (Object key : failedKeys) remapKeys.add(cctx.toCacheKeyObject(key));
}
}
}
if (remapTopVer0 != null) {
cctx.mvcc().removeAtomicFuture(futId);
topVer = AffinityTopologyVersion.ZERO;
futId = 0;
remapTopVer = null;
}
return remapTopVer0;
}
use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.
the class GridNearAtomicUpdateFuture method waitAndRemap.
private void waitAndRemap(AffinityTopologyVersion remapTopVer) {
assert remapTopVer != null;
if (topLocked) {
assert !F.isEmpty(remapKeys) : remapKeys;
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.affinity().affinityReadyFuture(remapTopVer));
e.add(remapKeys, 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 Runnable() {
@Override
public void run() {
mapOnTopology();
}
});
}
});
}
use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.
the class GridNearAtomicUpdateFuture method onNodeLeft.
/** {@inheritDoc} */
@Override
public boolean onNodeLeft(UUID nodeId) {
GridCacheReturn opRes0 = null;
CachePartialUpdateCheckedException err0 = null;
AffinityTopologyVersion remapTopVer0 = null;
boolean rcvAll = false;
List<GridNearAtomicCheckUpdateRequest> checkReqs = null;
long futId;
synchronized (this) {
if (!futureMapped())
return false;
futId = this.futId;
if (singleReq != null) {
if (singleReq.req.nodeId.equals(nodeId)) {
GridNearAtomicAbstractUpdateRequest req = singleReq.onPrimaryFail();
if (req != null) {
rcvAll = true;
GridNearAtomicUpdateResponse res = primaryFailedResponse(req);
singleReq.onPrimaryResponse(res, cctx);
onPrimaryError(req, res);
}
} else {
DhtLeftResult res = singleReq.onDhtNodeLeft(nodeId);
if (res == DhtLeftResult.DONE)
rcvAll = true;
else if (res == DhtLeftResult.ALL_RCVD_CHECK_PRIMARY)
checkReqs = Collections.singletonList(new GridNearAtomicCheckUpdateRequest(singleReq.req));
}
if (rcvAll) {
opRes0 = opRes;
err0 = err;
remapTopVer0 = onAllReceived();
}
} else {
if (mappings == null)
return false;
for (Map.Entry<UUID, PrimaryRequestState> e : mappings.entrySet()) {
assert e.getKey().equals(e.getValue().req.nodeId());
PrimaryRequestState reqState = e.getValue();
boolean reqDone = false;
if (e.getKey().equals(nodeId)) {
GridNearAtomicAbstractUpdateRequest req = reqState.onPrimaryFail();
if (req != null) {
reqDone = true;
GridNearAtomicUpdateResponse res = primaryFailedResponse(req);
reqState.onPrimaryResponse(res, cctx);
onPrimaryError(req, res);
}
} else {
DhtLeftResult res = reqState.onDhtNodeLeft(nodeId);
if (res == DhtLeftResult.DONE)
reqDone = true;
else if (res == DhtLeftResult.ALL_RCVD_CHECK_PRIMARY) {
if (checkReqs == null)
checkReqs = new ArrayList<>();
checkReqs.add(new GridNearAtomicCheckUpdateRequest(reqState.req));
}
}
if (reqDone) {
assert mappings.size() > resCnt : "[mappings=" + mappings.size() + ", cnt=" + resCnt + ']';
resCnt++;
if (mappings.size() == resCnt) {
rcvAll = true;
opRes0 = opRes;
err0 = err;
remapTopVer0 = onAllReceived();
break;
}
}
}
}
}
if (checkReqs != null) {
assert !rcvAll;
for (int i = 0; i < checkReqs.size(); i++) sendCheckUpdateRequest(checkReqs.get(i));
} else if (rcvAll)
finishUpdateFuture(opRes0, err0, remapTopVer0, futId);
return false;
}
use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.
the class GridNearAtomicUpdateFuture method checkDhtNodes.
private void checkDhtNodes(long futId) {
GridCacheReturn opRes0 = null;
CachePartialUpdateCheckedException err0 = null;
AffinityTopologyVersion remapTopVer0 = null;
List<GridNearAtomicCheckUpdateRequest> checkReqs = null;
boolean rcvAll = false;
synchronized (this) {
if (!checkFutureId(futId))
return;
if (singleReq != null) {
if (!singleReq.req.initMappingLocally())
return;
DhtLeftResult res = singleReq.checkDhtNodes(cctx);
if (res == DhtLeftResult.DONE) {
opRes0 = opRes;
err0 = err;
remapTopVer0 = onAllReceived();
} else if (res == DhtLeftResult.ALL_RCVD_CHECK_PRIMARY)
checkReqs = Collections.singletonList(new GridNearAtomicCheckUpdateRequest(singleReq.req));
else
return;
} else {
if (mappings != null) {
for (PrimaryRequestState reqState : mappings.values()) {
if (!reqState.req.initMappingLocally())
continue;
DhtLeftResult res = reqState.checkDhtNodes(cctx);
if (res == DhtLeftResult.DONE) {
assert mappings.size() > resCnt : "[mappings=" + mappings.size() + ", cnt=" + resCnt + ']';
resCnt++;
if (mappings.size() == resCnt) {
rcvAll = true;
opRes0 = opRes;
err0 = err;
remapTopVer0 = onAllReceived();
break;
}
} else if (res == DhtLeftResult.ALL_RCVD_CHECK_PRIMARY) {
if (checkReqs == null)
checkReqs = new ArrayList<>(mappings.size());
checkReqs.add(new GridNearAtomicCheckUpdateRequest(reqState.req));
}
}
} else
return;
}
}
if (checkReqs != null) {
assert !rcvAll;
for (int i = 0; i < checkReqs.size(); i++) sendCheckUpdateRequest(checkReqs.get(i));
} else if (rcvAll)
finishUpdateFuture(opRes0, err0, remapTopVer0, futId);
}
Aggregations