use of org.apache.ignite.internal.processors.cache.CacheOperationContext in project ignite by apache.
the class GridLocalAtomicCache method removeAllAsync0.
/**
* Entry point for public API remove methods.
*
* @param keys Keys to remove.
* @param retval Return value required flag.
* @param rawRetval Return {@code GridCacheReturn} instance.
* @param filter Cache entry filter.
* @return Completion future.
*/
private IgniteInternalFuture removeAllAsync0(@Nullable final Collection<? extends K> keys, final boolean retval, final boolean rawRetval, @Nullable final CacheEntryPredicate filter) {
final boolean writeThrough = ctx.writeThrough();
final boolean readThrough = ctx.readThrough();
final ExpiryPolicy expiryPlc = expiryPerCall();
CacheOperationContext opCtx = ctx.operationContextPerCall();
final boolean keepBinary = opCtx != null && opCtx.isKeepBinary();
return asyncOp(new GridPlainCallable<Object>() {
@Override
public Object call() throws Exception {
return updateAllInternal(DELETE, keys, null, null, expiryPlc, retval, rawRetval, filter, writeThrough, readThrough, keepBinary);
}
});
}
use of org.apache.ignite.internal.processors.cache.CacheOperationContext in project ignite by apache.
the class GridLocalAtomicCache method put0.
/**
* {@inheritDoc}
*/
@Override
protected boolean put0(K key, V val, CacheEntryPredicate filter) throws IgniteCheckedException {
CacheOperationContext opCtx = ctx.operationContextPerCall();
Boolean res = (Boolean) updateAllInternal(UPDATE, Collections.singleton(key), Collections.singleton(val), null, expiryPerCall(), false, false, filter, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary());
assert res != null;
return res;
}
use of org.apache.ignite.internal.processors.cache.CacheOperationContext in project ignite by apache.
the class GridLocalAtomicCache method removeAll0.
/**
* {@inheritDoc}
*/
@Override
public void removeAll0(Collection<? extends K> keys) throws IgniteCheckedException {
CacheOperationContext opCtx = ctx.operationContextPerCall();
updateAllInternal(DELETE, keys, null, null, expiryPerCall(), false, false, null, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary());
}
use of org.apache.ignite.internal.processors.cache.CacheOperationContext in project ignite by apache.
the class GridLocalAtomicCache method getAllInternal.
/**
* Entry point to all public API get methods.
*
* @param keys Keys to remove.
* @param storeEnabled Store enabled flag.
* @param taskName Task name.
* @param deserializeBinary Deserialize binary .
* @param skipVals Skip value flag.
* @param needVer Need version.
* @return Key-value map.
* @throws IgniteCheckedException If failed.
*/
@SuppressWarnings("ConstantConditions")
private Map<K, V> getAllInternal(@Nullable Collection<? extends K> keys, boolean storeEnabled, String taskName, boolean deserializeBinary, boolean skipVals, boolean needVer) throws IgniteCheckedException {
ctx.checkSecurity(SecurityPermission.CACHE_READ);
if (F.isEmpty(keys))
return Collections.emptyMap();
CacheOperationContext opCtx = ctx.operationContextPerCall();
Map<K, V> vals = U.newHashMap(keys.size());
warnIfUnordered(keys, BulkOperation.GET);
final IgniteCacheExpiryPolicy expiry = expiryPolicy(opCtx != null ? opCtx.expiry() : null);
boolean success = true;
boolean readNoEntry = ctx.readNoEntry(expiry, false);
final boolean evt = !skipVals;
ctx.shared().database().checkpointReadLock();
try {
for (K key : keys) {
if (key == null)
throw new NullPointerException("Null key.");
KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
boolean skipEntry = readNoEntry;
if (readNoEntry) {
CacheDataRow row = ctx.offheap().read(ctx, cacheKey);
if (row != null) {
long expireTime = row.expireTime();
if (expireTime == 0 || expireTime > U.currentTimeMillis()) {
ctx.addResult(vals, cacheKey, row.value(), skipVals, false, deserializeBinary, true, null, row.version(), 0, 0, needVer, null);
if (ctx.statisticsEnabled() && !skipVals)
metrics0().onRead(true);
if (evt) {
ctx.events().readEvent(cacheKey, null, null, row.value(), taskName, !deserializeBinary);
}
} else
skipEntry = false;
} else
success = false;
}
if (!skipEntry) {
GridCacheEntryEx entry = null;
while (true) {
try {
entry = entryEx(cacheKey);
if (entry != null) {
CacheObject v;
if (needVer) {
EntryGetResult res = entry.innerGetVersioned(null, null, /*update-metrics*/
false, /*event*/
evt, null, taskName, expiry, !deserializeBinary, null);
if (res != null) {
ctx.addResult(vals, cacheKey, res, skipVals, false, deserializeBinary, true, needVer);
} else
success = false;
} else {
v = entry.innerGet(null, null, /*read-through*/
false, /*update-metrics*/
true, /*event*/
evt, null, taskName, expiry, !deserializeBinary);
if (v != null) {
ctx.addResult(vals, cacheKey, v, skipVals, false, deserializeBinary, true, null, 0, 0, null);
} else
success = false;
}
}
// While.
break;
} catch (GridCacheEntryRemovedException ignored) {
// No-op, retry.
} finally {
if (entry != null)
entry.touch();
}
if (!success && storeEnabled)
break;
}
}
if (!success) {
if (!storeEnabled && ctx.statisticsEnabled() && !skipVals)
metrics0().onRead(false);
}
}
} finally {
ctx.shared().database().checkpointReadUnlock();
}
if (success || !storeEnabled)
return vals;
return getAllAsync(keys, null, opCtx == null || !opCtx.skipStore(), false, taskName, deserializeBinary, opCtx != null && opCtx.recovery(), null, /*force primary*/
false, expiry, skipVals, needVer).get();
}
use of org.apache.ignite.internal.processors.cache.CacheOperationContext in project ignite by apache.
the class GridLocalAtomicCache method putAll0.
/**
* {@inheritDoc}
*/
@Override
protected void putAll0(Map<? extends K, ? extends V> m) throws IgniteCheckedException {
CacheOperationContext opCtx = ctx.operationContextPerCall();
updateAllInternal(UPDATE, m.keySet(), m.values(), null, expiryPerCall(), false, false, null, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary());
}
Aggregations