Search in sources :

Example 1 with BackupPostProcessingClosure

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);
        }
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridCacheEntryInfo(org.apache.ignite.internal.processors.cache.GridCacheEntryInfo) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) ClusterTopologyServerNotFoundException(org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) BackupPostProcessingClosure(org.apache.ignite.internal.processors.cache.GridCacheUtils.BackupPostProcessingClosure) GridCacheMessage(org.apache.ignite.internal.processors.cache.GridCacheMessage) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridNearSingleGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)1 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)1 ClusterTopologyServerNotFoundException (org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException)1 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)1 GridCacheEntryInfo (org.apache.ignite.internal.processors.cache.GridCacheEntryInfo)1 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)1 GridCacheMessage (org.apache.ignite.internal.processors.cache.GridCacheMessage)1 BackupPostProcessingClosure (org.apache.ignite.internal.processors.cache.GridCacheUtils.BackupPostProcessingClosure)1 GridNearSingleGetRequest (org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest)1