Search in sources :

Example 6 with NodeStoppingException

use of org.apache.ignite.internal.NodeStoppingException 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);
        }
    });
}
Also used : GridCacheEntryInfo(org.apache.ignite.internal.processors.cache.GridCacheEntryInfo) CacheVersionedValue(org.apache.ignite.internal.processors.cache.distributed.near.CacheVersionedValue) Message(org.apache.ignite.plugin.extensions.communication.Message) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) GridNearSingleGetResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)

Example 7 with NodeStoppingException

use of org.apache.ignite.internal.NodeStoppingException in project ignite by apache.

the class GridCacheQueryManager method store.

/**
     * Writes key-value pair to index.
     *
     * @param key Key.
     * @param partId Partition.
     * @param prevVal Previous value.
     * @param prevVer Previous version.
     * @param val Value.
     * @param ver Cache entry version.
     * @param expirationTime Expiration time or 0 if never expires.
     * @param link Link.
     * @throws IgniteCheckedException In case of error.
     */
public void store(KeyCacheObject key, int partId, @Nullable CacheObject prevVal, @Nullable GridCacheVersion prevVer, CacheObject val, GridCacheVersion ver, long expirationTime, long link) throws IgniteCheckedException {
    assert key != null;
    assert val != null;
    assert enabled();
    if (key instanceof GridCacheInternal)
        // No-op.
        return;
    if (!enterBusy())
        throw new NodeStoppingException("Operation has been cancelled (node is stopping).");
    try {
        if (isIndexingSpiEnabled()) {
            CacheObjectContext coctx = cctx.cacheObjectContext();
            Object key0 = unwrapIfNeeded(key, coctx);
            Object val0 = unwrapIfNeeded(val, coctx);
            cctx.kernalContext().indexing().store(cacheName, key0, val0, expirationTime);
        }
        if (qryProcEnabled)
            qryProc.store(cacheName, key, partId, prevVal, prevVer, val, ver, expirationTime, link);
    } finally {
        invalidateResultCache();
        leaveBusy();
    }
}
Also used : NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) GridCacheInternal(org.apache.ignite.internal.processors.cache.GridCacheInternal) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext)

Example 8 with NodeStoppingException

use of org.apache.ignite.internal.NodeStoppingException in project ignite by apache.

the class GridQueryProcessor method store.

/**
     * Writes key-value pair to index.
     *
     * @param cacheName Cache name.
     * @param key Key.
     * @param val Value.
     * @param ver Cache entry version.
     * @param expirationTime Expiration time or 0 if never expires.
     * @throws IgniteCheckedException In case of error.
     */
@SuppressWarnings({ "unchecked", "ConstantConditions" })
public void store(final String cacheName, final KeyCacheObject key, int partId, @Nullable CacheObject prevVal, @Nullable GridCacheVersion prevVer, final CacheObject val, GridCacheVersion ver, long expirationTime, long link) throws IgniteCheckedException {
    assert key != null;
    assert val != null;
    if (log.isDebugEnabled())
        log.debug("Store [cache=" + cacheName + ", key=" + key + ", val=" + val + "]");
    if (idx == null)
        return;
    if (!busyLock.enterBusy())
        throw new NodeStoppingException("Operation has been cancelled (node is stopping).");
    try {
        CacheObjectContext coctx = cacheObjectContext(cacheName);
        QueryTypeDescriptorImpl desc = typeByValue(cacheName, coctx, key, val, true);
        if (prevVal != null) {
            QueryTypeDescriptorImpl prevValDesc = typeByValue(cacheName, coctx, key, prevVal, false);
            if (prevValDesc != null && prevValDesc != desc)
                idx.remove(cacheName, prevValDesc, key, partId, prevVal, prevVer);
        }
        if (desc == null)
            return;
        idx.store(cacheName, desc, key, partId, val, ver, expirationTime, link);
    } finally {
        busyLock.leaveBusy();
    }
}
Also used : NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext)

Aggregations

NodeStoppingException (org.apache.ignite.internal.NodeStoppingException)8 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)3 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)3 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)3 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)2 CacheObjectContext (org.apache.ignite.internal.processors.cache.CacheObjectContext)2 GridCacheEntryInfo (org.apache.ignite.internal.processors.cache.GridCacheEntryInfo)2 IgniteCacheExpiryPolicy (org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)2 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 StorageException (org.apache.ignite.internal.pagemem.wal.StorageException)1 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1 GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)1 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)1 GridCacheInternal (org.apache.ignite.internal.processors.cache.GridCacheInternal)1 GridCacheMapEntry (org.apache.ignite.internal.processors.cache.GridCacheMapEntry)1