use of org.apache.ignite.internal.processors.cache.GridCacheUtils.BackupPostProcessingClosure in project ignite by apache.
the class GridPartitionedSingleGetFuture method map.
/**
* @param topVer Topology version.
*/
@SuppressWarnings("unchecked")
private void map(final AffinityTopologyVersion topVer) {
ClusterNode node = mapKeyToNode(topVer);
if (node == null) {
assert isDone() : this;
return;
}
if (isDone())
return;
if (node.isLocal()) {
final GridDhtFuture<GridCacheEntryInfo> fut = cctx.dht().getDhtSingleAsync(node.id(), -1, key, false, readThrough, topVer, subjId, taskName == null ? 0 : taskName.hashCode(), expiryPlc, skipVals, recovery);
final Collection<Integer> invalidParts = fut.invalidPartitions();
if (!F.isEmpty(invalidParts)) {
AffinityTopologyVersion updTopVer = cctx.shared().exchange().readyAffinityVersion();
assert updTopVer.compareTo(topVer) > 0 : "Got invalid partitions for local node but topology " + "version did not change [topVer=" + topVer + ", updTopVer=" + updTopVer + ", invalidParts=" + invalidParts + ']';
// Remap recursively.
map(updTopVer);
} else {
fut.listen(new CI1<IgniteInternalFuture<GridCacheEntryInfo>>() {
@Override
public void apply(IgniteInternalFuture<GridCacheEntryInfo> fut) {
try {
GridCacheEntryInfo info = fut.get();
setResult(info);
} catch (Exception e) {
U.error(log, "Failed to get values from dht cache [fut=" + fut + "]", e);
onDone(e);
}
}
});
}
} else {
synchronized (this) {
assert this.node == null;
this.topVer = topVer;
this.node = node;
}
if (!trackable) {
trackable = true;
cctx.mvcc().addFuture(this, futId);
}
boolean needVer = this.needVer;
final BackupPostProcessingClosure postClos = CU.createBackupPostProcessingClosure(topVer, log, cctx, key, expiryPlc, readThrough, skipVals);
if (postClos != null) {
// Need version to correctly store value.
needVer = true;
postProcessingClos = postClos;
}
GridCacheMessage req = new GridNearSingleGetRequest(cctx.cacheId(), futId.localId(), key, readThrough, topVer, subjId, taskName == null ? 0 : taskName.hashCode(), expiryPlc != null ? expiryPlc.forCreate() : -1L, expiryPlc != null ? expiryPlc.forAccess() : -1L, skipVals, /*add reader*/
false, needVer, cctx.deploymentEnabled(), recovery);
try {
cctx.io().send(node, req, cctx.ioPolicy());
} catch (IgniteCheckedException e) {
if (e instanceof ClusterTopologyCheckedException)
onNodeLeft(node.id());
else
onDone(e);
}
}
}
Aggregations