use of org.apache.ignite.internal.processors.cache.distributed.near.CacheVersionedValue in project ignite by apache.
the class GridDhtCacheAdapter method processNearSingleGetRequest.
/**
* @param nodeId Node ID.
* @param req Get request.
*/
protected void processNearSingleGetRequest(final UUID nodeId, final GridNearSingleGetRequest req) {
assert ctx.affinityNode();
final CacheExpiryPolicy expiryPlc = CacheExpiryPolicy.fromRemote(req.createTtl(), req.accessTtl());
IgniteInternalFuture<GridCacheEntryInfo> fut = getDhtSingleAsync(nodeId, req.messageId(), req.key(), req.addReader(), req.readThrough(), req.topologyVersion(), req.subjectId(), req.taskNameHash(), expiryPlc, req.skipValues(), req.recovery());
fut.listen(new CI1<IgniteInternalFuture<GridCacheEntryInfo>>() {
@Override
public void apply(IgniteInternalFuture<GridCacheEntryInfo> f) {
GridNearSingleGetResponse res;
GridDhtFuture<GridCacheEntryInfo> fut = (GridDhtFuture<GridCacheEntryInfo>) f;
try {
GridCacheEntryInfo info = fut.get();
if (F.isEmpty(fut.invalidPartitions())) {
Message res0 = null;
if (info != null) {
if (req.needEntryInfo()) {
info.key(null);
res0 = info;
} else if (req.needVersion())
res0 = new CacheVersionedValue(info.value(), info.version());
else
res0 = info.value();
}
res = new GridNearSingleGetResponse(ctx.cacheId(), req.futureId(), req.topologyVersion(), res0, false, req.addDeploymentInfo());
if (info != null && req.skipValues())
res.setContainsValue();
} else {
AffinityTopologyVersion topVer = ctx.shared().exchange().readyAffinityVersion();
assert topVer.compareTo(req.topologyVersion()) >= 0 : "Wrong ready topology version for " + "invalid partitions response [topVer=" + topVer + ", req=" + req + ']';
res = new GridNearSingleGetResponse(ctx.cacheId(), req.futureId(), topVer, null, true, req.addDeploymentInfo());
}
} catch (NodeStoppingException ignored) {
return;
} catch (IgniteCheckedException e) {
U.error(log, "Failed processing get request: " + req, e);
res = new GridNearSingleGetResponse(ctx.cacheId(), req.futureId(), req.topologyVersion(), null, false, req.addDeploymentInfo());
res.error(e);
}
try {
ctx.io().send(nodeId, res, ctx.ioPolicy());
} catch (IgniteCheckedException e) {
U.error(log, "Failed to send get response to node (is node still alive?) [nodeId=" + nodeId + ",req=" + req + ", res=" + res + ']', e);
}
sendTtlUpdateRequest(expiryPlc);
}
});
}
Aggregations