Search in sources :

Example 6 with GridCacheInternal

use of org.apache.ignite.internal.processors.cache.GridCacheInternal 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 7 with GridCacheInternal

use of org.apache.ignite.internal.processors.cache.GridCacheInternal in project ignite by apache.

the class GridCacheStoreManagerAdapter method remove.

/** {@inheritDoc} */
@Override
public final boolean remove(@Nullable IgniteInternalTx tx, KeyCacheObject key) throws IgniteCheckedException {
    if (store != null) {
        // Never remove internal key from store as it is never persisted.
        if (key instanceof GridCacheInternal)
            return false;
        Object key0 = cctx.unwrapBinaryIfNeeded(key, !convertBinary());
        if (log.isDebugEnabled())
            log.debug(S.toString("Removing value from cache store", "key", key0, true));
        sessionInit0(tx);
        boolean threwEx = true;
        try {
            store.delete(key0);
            threwEx = false;
        } catch (ClassCastException e) {
            handleClassCastException(e);
        } catch (CacheWriterException e) {
            throw new IgniteCheckedException(e);
        } catch (Exception e) {
            throw new IgniteCheckedException(new CacheWriterException(e));
        } finally {
            sessionEnd0(tx, threwEx);
        }
        if (log.isDebugEnabled())
            log.debug(S.toString("Removed value from cache store", "key", key0, true));
        return true;
    }
    return false;
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCacheInternal(org.apache.ignite.internal.processors.cache.GridCacheInternal) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) CacheWriterException(javax.cache.integration.CacheWriterException) CacheLoaderException(javax.cache.integration.CacheLoaderException) NoSuchElementException(java.util.NoSuchElementException) CacheStorePartialUpdateException(org.apache.ignite.internal.processors.cache.CacheStorePartialUpdateException) CacheWriterException(javax.cache.integration.CacheWriterException)

Aggregations

GridCacheInternal (org.apache.ignite.internal.processors.cache.GridCacheInternal)7 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)4 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 NoSuchElementException (java.util.NoSuchElementException)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 CacheLoaderException (javax.cache.integration.CacheLoaderException)2 CacheWriterException (javax.cache.integration.CacheWriterException)2 IgniteException (org.apache.ignite.IgniteException)2 CacheStorePartialUpdateException (org.apache.ignite.internal.processors.cache.CacheStorePartialUpdateException)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 IgniteCountDownLatch (org.apache.ignite.IgniteCountDownLatch)1 NodeStoppingException (org.apache.ignite.internal.NodeStoppingException)1 CacheObjectContext (org.apache.ignite.internal.processors.cache.CacheObjectContext)1 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1 GridNearTxLocal (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)1 IgniteChangeGlobalStateSupport (org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport)1