use of org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse in project ignite by apache.
the class GridDhtAtomicCache method start.
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "IfMayBeConditional", "SimplifiableIfStatement" })
@Override
public void start() throws IgniteCheckedException {
super.start();
CacheMetricsImpl m = new CacheMetricsImpl(ctx);
if (ctx.dht().near() != null)
m.delegate(ctx.dht().near().metrics0());
metrics = m;
ctx.io().addCacheHandler(ctx.cacheId(), GridNearGetRequest.class, new CI2<UUID, GridNearGetRequest>() {
@Override
public void apply(UUID nodeId, GridNearGetRequest req) {
processNearGetRequest(nodeId, req);
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridNearSingleGetRequest.class, new CI2<UUID, GridNearSingleGetRequest>() {
@Override
public void apply(UUID nodeId, GridNearSingleGetRequest req) {
processNearSingleGetRequest(nodeId, req);
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridNearAtomicAbstractUpdateRequest.class, new CI2<UUID, GridNearAtomicAbstractUpdateRequest>() {
@Override
public void apply(UUID nodeId, GridNearAtomicAbstractUpdateRequest req) {
processNearAtomicUpdateRequest(nodeId, req);
}
@Override
public String toString() {
return "GridNearAtomicAbstractUpdateRequest handler " + "[msgIdx=" + GridNearAtomicAbstractUpdateRequest.CACHE_MSG_IDX + ']';
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridNearAtomicUpdateResponse.class, new CI2<UUID, GridNearAtomicUpdateResponse>() {
@Override
public void apply(UUID nodeId, GridNearAtomicUpdateResponse res) {
processNearAtomicUpdateResponse(nodeId, res);
}
@Override
public String toString() {
return "GridNearAtomicUpdateResponse handler " + "[msgIdx=" + GridNearAtomicUpdateResponse.CACHE_MSG_IDX + ']';
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridDhtAtomicAbstractUpdateRequest.class, new CI2<UUID, GridDhtAtomicAbstractUpdateRequest>() {
@Override
public void apply(UUID nodeId, GridDhtAtomicAbstractUpdateRequest req) {
processDhtAtomicUpdateRequest(nodeId, req);
}
@Override
public String toString() {
return "GridDhtAtomicUpdateRequest handler " + "[msgIdx=" + GridDhtAtomicUpdateRequest.CACHE_MSG_IDX + ']';
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridDhtAtomicUpdateResponse.class, new CI2<UUID, GridDhtAtomicUpdateResponse>() {
@Override
public void apply(UUID nodeId, GridDhtAtomicUpdateResponse res) {
processDhtAtomicUpdateResponse(nodeId, res);
}
@Override
public String toString() {
return "GridDhtAtomicUpdateResponse handler " + "[msgIdx=" + GridDhtAtomicUpdateResponse.CACHE_MSG_IDX + ']';
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridDhtAtomicDeferredUpdateResponse.class, new CI2<UUID, GridDhtAtomicDeferredUpdateResponse>() {
@Override
public void apply(UUID nodeId, GridDhtAtomicDeferredUpdateResponse res) {
processDhtAtomicDeferredUpdateResponse(nodeId, res);
}
@Override
public String toString() {
return "GridDhtAtomicDeferredUpdateResponse handler " + "[msgIdx=" + GridDhtAtomicDeferredUpdateResponse.CACHE_MSG_IDX + ']';
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridDhtAtomicNearResponse.class, new CI2<UUID, GridDhtAtomicNearResponse>() {
@Override
public void apply(UUID uuid, GridDhtAtomicNearResponse msg) {
processDhtAtomicNearResponse(uuid, msg);
}
@Override
public String toString() {
return "GridDhtAtomicNearResponse handler " + "[msgIdx=" + GridDhtAtomicNearResponse.CACHE_MSG_IDX + ']';
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridNearAtomicCheckUpdateRequest.class, new CI2<UUID, GridNearAtomicCheckUpdateRequest>() {
@Override
public void apply(UUID uuid, GridNearAtomicCheckUpdateRequest msg) {
processCheckUpdateRequest(uuid, msg);
}
@Override
public String toString() {
return "GridNearAtomicCheckUpdateRequest handler " + "[msgIdx=" + GridNearAtomicCheckUpdateRequest.CACHE_MSG_IDX + ']';
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridDhtForceKeysRequest.class, new MessageHandler<GridDhtForceKeysRequest>() {
@Override
public void onMessage(ClusterNode node, GridDhtForceKeysRequest msg) {
processForceKeysRequest(node, msg);
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridDhtForceKeysResponse.class, new MessageHandler<GridDhtForceKeysResponse>() {
@Override
public void onMessage(ClusterNode node, GridDhtForceKeysResponse msg) {
processForceKeyResponse(node, msg);
}
});
if (near == null) {
ctx.io().addCacheHandler(ctx.cacheId(), GridNearGetResponse.class, new CI2<UUID, GridNearGetResponse>() {
@Override
public void apply(UUID nodeId, GridNearGetResponse res) {
processNearGetResponse(nodeId, res);
}
});
ctx.io().addCacheHandler(ctx.cacheId(), GridNearSingleGetResponse.class, new CI2<UUID, GridNearSingleGetResponse>() {
@Override
public void apply(UUID nodeId, GridNearSingleGetResponse res) {
processNearSingleGetResponse(nodeId, res);
}
});
}
}
use of org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse 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.taskNameHash(), expiryPlc, req.skipValues(), req.recovery(), req.txLabel(), req.mvccSnapshot());
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(), null, res0, false, req.addDeploymentInfo());
if (info != null && req.skipValues())
res.setContainsValue();
} else {
AffinityTopologyVersion topVer = ctx.shared().exchange().lastTopologyFuture().initialVersion();
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 (ClusterTopologyCheckedException e) {
if (log.isDebugEnabled())
log.debug("Failed to send get response to node, node failed: " + nodeId);
} 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