Search in sources :

Example 46 with ExpiryPolicy

use of javax.cache.expiry.ExpiryPolicy in project ignite by apache.

the class GridLocalAtomicCache method updateAllAsync0.

/**
 * Entry point for public API update methods.
 *
 * @param map Put map. Either {@code map} or {@code invokeMap} should be passed.
 * @param invokeMap Transform map. Either {@code map} or {@code invokeMap} should be passed.
 * @param invokeArgs Optional arguments for EntryProcessor.
 * @param retval Return value required flag.
 * @param rawRetval Return {@code GridCacheReturn} instance.
 * @param filter Cache entry filter for atomic updates.
 * @return Completion future.
 */
private IgniteInternalFuture updateAllAsync0(@Nullable final Map<? extends K, ? extends V> map, @Nullable final Map<? extends K, ? extends EntryProcessor> invokeMap, @Nullable final Object[] invokeArgs, final boolean retval, final boolean rawRetval, @Nullable final CacheEntryPredicate filter) {
    final GridCacheOperation op = invokeMap != null ? TRANSFORM : UPDATE;
    final Collection<? extends K> keys = map != null ? map.keySet() : invokeMap != null ? invokeMap.keySet() : null;
    final Collection<?> vals = map != null ? map.values() : invokeMap != null ? invokeMap.values() : null;
    final boolean writeThrough = ctx.writeThrough();
    final boolean readThrough = ctx.readThrough();
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    final ExpiryPolicy expiry = expiryPerCall();
    final boolean keepBinary = opCtx != null && opCtx.isKeepBinary();
    return asyncOp(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            return updateAllInternal(op, keys, vals, invokeArgs, expiry, retval, rawRetval, filter, writeThrough, readThrough, keepBinary);
        }
    });
}
Also used : CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) ExpiryPolicy(javax.cache.expiry.ExpiryPolicy) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) GridCacheOperation(org.apache.ignite.internal.processors.cache.GridCacheOperation) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) CachePartialUpdateCheckedException(org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException) EntryProcessorException(javax.cache.processor.EntryProcessorException) CacheStorePartialUpdateException(org.apache.ignite.internal.processors.cache.CacheStorePartialUpdateException)

Example 47 with ExpiryPolicy

use of javax.cache.expiry.ExpiryPolicy in project ignite by apache.

the class GridDhtAtomicCache method getAsync.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteInternalFuture<V> getAsync(final K key, final boolean forcePrimary, final boolean skipTx, @Nullable UUID subjId, final String taskName, final boolean deserializeBinary, final boolean skipVals, final boolean needVer) {
    ctx.checkSecurity(SecurityPermission.CACHE_READ);
    if (keyCheck)
        validateCacheKey(key);
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    subjId = ctx.subjectIdPerCall(null, opCtx);
    final UUID subjId0 = subjId;
    final ExpiryPolicy expiryPlc = skipVals ? null : opCtx != null ? opCtx.expiry() : null;
    final boolean skipStore = opCtx != null && opCtx.skipStore();
    final boolean recovery = opCtx != null && opCtx.recovery();
    return asyncOp(new CO<IgniteInternalFuture<V>>() {

        @Override
        public IgniteInternalFuture<V> apply() {
            return getAsync0(ctx.toCacheKeyObject(key), forcePrimary, subjId0, taskName, deserializeBinary, recovery, expiryPlc, skipVals, skipStore, needVer);
        }
    });
}
Also used : CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) ExpiryPolicy(javax.cache.expiry.ExpiryPolicy) UUID(java.util.UUID) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture)

Example 48 with ExpiryPolicy

use of javax.cache.expiry.ExpiryPolicy in project ignite by apache.

the class GridDhtAtomicCache method getAllAsyncInternal.

/**
 * @param keys Keys.
 * @param forcePrimary Force primary flag.
 * @param subjId Subject ID.
 * @param taskName Task name.
 * @param deserializeBinary Deserialize binary flag.
 * @param skipVals Skip values flag.
 * @param needVer Need version flag.
 * @param asyncOp Async operation flag.
 * @return Future.
 */
private IgniteInternalFuture<Map<K, V>> getAllAsyncInternal(@Nullable final Collection<? extends K> keys, final boolean forcePrimary, @Nullable UUID subjId, final String taskName, final boolean deserializeBinary, final boolean recovery, final boolean skipVals, final boolean needVer, boolean asyncOp) {
    ctx.checkSecurity(SecurityPermission.CACHE_READ);
    if (F.isEmpty(keys))
        return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
    if (keyCheck)
        validateCacheKeys(keys);
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    subjId = ctx.subjectIdPerCall(subjId, opCtx);
    final UUID subjId0 = subjId;
    final ExpiryPolicy expiryPlc = skipVals ? null : opCtx != null ? opCtx.expiry() : null;
    final boolean skipStore = opCtx != null && opCtx.skipStore();
    if (asyncOp) {
        return asyncOp(new CO<IgniteInternalFuture<Map<K, V>>>() {

            @Override
            public IgniteInternalFuture<Map<K, V>> apply() {
                return getAllAsync0(ctx.cacheKeysView(keys), forcePrimary, subjId0, taskName, deserializeBinary, recovery, expiryPlc, skipVals, skipStore, needVer);
            }
        });
    } else {
        return getAllAsync0(ctx.cacheKeysView(keys), forcePrimary, subjId0, taskName, deserializeBinary, recovery, expiryPlc, skipVals, skipStore, needVer);
    }
}
Also used : CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) ExpiryPolicy(javax.cache.expiry.ExpiryPolicy) UUID(java.util.UUID) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture)

Example 49 with ExpiryPolicy

use of javax.cache.expiry.ExpiryPolicy in project ignite by apache.

the class GridDhtCacheAdapter method localLoad.

/**
 * {@inheritDoc}
 */
@Override
public void localLoad(Collection<? extends K> keys, final ExpiryPolicy plc, final boolean keepBinary) throws IgniteCheckedException {
    if (ctx.store().isLocal()) {
        super.localLoad(keys, plc, keepBinary);
        return;
    }
    // Version for all loaded entries.
    final AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
    final GridCacheVersion ver0 = ctx.shared().versions().nextForLoad(topVer);
    final boolean replicate = ctx.isDrEnabled();
    final ExpiryPolicy plc0 = plc != null ? plc : ctx.expiry();
    Collection<KeyCacheObject> keys0 = ctx.cacheKeysView(keys);
    ctx.store().loadAll(null, keys0, new CI2<KeyCacheObject, Object>() {

        @Override
        public void apply(KeyCacheObject key, Object val) {
            loadEntry(key, val, ver0, null, topVer, replicate, plc0);
        }
    });
}
Also used : GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) ExpiryPolicy(javax.cache.expiry.ExpiryPolicy) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Example 50 with ExpiryPolicy

use of javax.cache.expiry.ExpiryPolicy in project ignite by apache.

the class GridDhtCacheAdapter method localLoadCache.

/**
 * {@inheritDoc}
 */
@Override
public void localLoadCache(final IgniteBiPredicate<K, V> p, Object[] args) throws IgniteCheckedException {
    if (ctx.store().isLocal()) {
        super.localLoadCache(p, args);
        return;
    }
    final AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
    // Version for all loaded entries.
    final GridCacheVersion ver0 = ctx.shared().versions().nextForLoad(topVer);
    final boolean replicate = ctx.isDrEnabled();
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    ExpiryPolicy plc0 = opCtx != null ? opCtx.expiry() : null;
    final ExpiryPolicy plc = plc0 != null ? plc0 : ctx.expiry();
    if (p != null)
        ctx.kernalContext().resource().injectGeneric(p);
    try {
        ctx.store().loadCache(new CI3<KeyCacheObject, Object, GridCacheVersion>() {

            @Override
            public void apply(KeyCacheObject key, Object val, @Nullable GridCacheVersion ver) {
                assert ver == null;
                loadEntry(key, val, ver0, p, topVer, replicate, plc);
            }
        }, args);
    } finally {
        if (p instanceof PlatformCacheEntryFilter)
            ((PlatformCacheEntryFilter) p).onClose();
    }
}
Also used : PlatformCacheEntryFilter(org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilter) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) ExpiryPolicy(javax.cache.expiry.ExpiryPolicy) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Aggregations

ExpiryPolicy (javax.cache.expiry.ExpiryPolicy)54 Duration (javax.cache.expiry.Duration)23 TouchedExpiryPolicy (javax.cache.expiry.TouchedExpiryPolicy)15 IgniteCacheExpiryPolicy (org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)13 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)12 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)11 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)11 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)10 CacheOperationContext (org.apache.ignite.internal.processors.cache.CacheOperationContext)9 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)9 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)9 CacheOperationProvider (com.hazelcast.cache.impl.CacheOperationProvider)7 UUID (java.util.UUID)7 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)7 Transaction (org.apache.ignite.transactions.Transaction)7 Map (java.util.Map)5 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)5 GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)5 IgniteTxTimeoutCheckedException (org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException)5