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);
}
});
}
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);
}
});
}
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);
}
}
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);
}
});
}
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();
}
}
Aggregations