Search in sources :

Example 1 with GridNearGetResponse

use of org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse 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;
    preldr = new GridDhtPreloader(ctx);
    preldr.start();
    ctx.io().addHandler(ctx.cacheId(), GridNearGetRequest.class, new CI2<UUID, GridNearGetRequest>() {

        @Override
        public void apply(UUID nodeId, GridNearGetRequest req) {
            processNearGetRequest(nodeId, req);
        }
    });
    ctx.io().addHandler(ctx.cacheId(), GridNearSingleGetRequest.class, new CI2<UUID, GridNearSingleGetRequest>() {

        @Override
        public void apply(UUID nodeId, GridNearSingleGetRequest req) {
            processNearSingleGetRequest(nodeId, req);
        }
    });
    ctx.io().addHandler(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().addHandler(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().addHandler(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().addHandler(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().addHandler(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().addHandler(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().addHandler(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 + ']';
        }
    });
    if (near == null) {
        ctx.io().addHandler(ctx.cacheId(), GridNearGetResponse.class, new CI2<UUID, GridNearGetResponse>() {

            @Override
            public void apply(UUID nodeId, GridNearGetResponse res) {
                processNearGetResponse(nodeId, res);
            }
        });
        ctx.io().addHandler(ctx.cacheId(), GridNearSingleGetResponse.class, new CI2<UUID, GridNearSingleGetResponse>() {

            @Override
            public void apply(UUID nodeId, GridNearSingleGetResponse res) {
                processNearSingleGetResponse(nodeId, res);
            }
        });
    }
}
Also used : CacheMetricsImpl(org.apache.ignite.internal.processors.cache.CacheMetricsImpl) GridNearGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest) UUID(java.util.UUID) GridNearGetResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse) GridNearSingleGetResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse) GridDhtPreloader(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader) GridNearSingleGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest)

Example 2 with GridNearGetResponse

use of org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse in project ignite by apache.

the class GridDhtCacheAdapter method processNearGetRequest.

/**
     * @param nodeId Node ID.
     * @param req Get request.
     */
protected void processNearGetRequest(final UUID nodeId, final GridNearGetRequest req) {
    assert ctx.affinityNode();
    assert !req.reload() : req;
    final CacheExpiryPolicy expiryPlc = CacheExpiryPolicy.fromRemote(req.createTtl(), req.accessTtl());
    IgniteInternalFuture<Collection<GridCacheEntryInfo>> fut = getDhtAsync(nodeId, req.messageId(), req.keys(), req.readThrough(), req.topologyVersion(), req.subjectId(), req.taskNameHash(), expiryPlc, req.skipValues(), req.recovery());
    fut.listen(new CI1<IgniteInternalFuture<Collection<GridCacheEntryInfo>>>() {

        @Override
        public void apply(IgniteInternalFuture<Collection<GridCacheEntryInfo>> f) {
            GridNearGetResponse res = new GridNearGetResponse(ctx.cacheId(), req.futureId(), req.miniId(), req.version(), req.deployInfo() != null);
            GridDhtFuture<Collection<GridCacheEntryInfo>> fut = (GridDhtFuture<Collection<GridCacheEntryInfo>>) f;
            try {
                Collection<GridCacheEntryInfo> entries = fut.get();
                res.entries(entries);
            } catch (NodeStoppingException ignored) {
                return;
            } catch (IgniteCheckedException e) {
                U.error(log, "Failed processing get request: " + req, e);
                res.error(e);
            }
            if (!F.isEmpty(fut.invalidPartitions()))
                res.invalidPartitions(fut.invalidPartitions(), ctx.shared().exchange().readyAffinityVersion());
            else
                res.invalidPartitions(fut.invalidPartitions(), req.topologyVersion());
            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);
        }
    });
}
Also used : GridCacheEntryInfo(org.apache.ignite.internal.processors.cache.GridCacheEntryInfo) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) Collection(java.util.Collection) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridNearGetResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse)

Aggregations

GridNearGetResponse (org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse)2 Collection (java.util.Collection)1 UUID (java.util.UUID)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)1 NodeStoppingException (org.apache.ignite.internal.NodeStoppingException)1 CacheMetricsImpl (org.apache.ignite.internal.processors.cache.CacheMetricsImpl)1 GridCacheEntryInfo (org.apache.ignite.internal.processors.cache.GridCacheEntryInfo)1 IgniteCacheExpiryPolicy (org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)1 GridDhtPreloader (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader)1 GridNearGetRequest (org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest)1 GridNearSingleGetRequest (org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest)1 GridNearSingleGetResponse (org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse)1