use of org.apache.ignite.internal.processors.cache.CacheOperationContext in project ignite by apache.
the class IgniteDrDataStreamerCacheUpdater method receive.
/**
* {@inheritDoc}
*/
@Override
public void receive(IgniteCache<KeyCacheObject, CacheObject> cache0, Collection<Map.Entry<KeyCacheObject, CacheObject>> col) {
try {
String cacheName = cache0.getConfiguration(CacheConfiguration.class).getName();
GridKernalContext ctx = ((IgniteKernal) cache0.unwrap(Ignite.class)).context();
IgniteLogger log = ctx.log(IgniteDrDataStreamerCacheUpdater.class);
GridCacheAdapter internalCache = ctx.cache().internalCache(cacheName);
CacheOperationContext opCtx = ((IgniteCacheProxy) cache0).context().operationContextPerCall();
IgniteInternalCache cache = opCtx != null ? new GridCacheProxyImpl(internalCache.context(), internalCache, opCtx) : internalCache;
assert !F.isEmpty(col);
if (log.isDebugEnabled())
log.debug("Running DR put job [nodeId=" + ctx.localNodeId() + ", cacheName=" + cacheName + ']');
CacheObjectContext cacheObjCtx = cache.context().cacheObjectContext();
for (Map.Entry<KeyCacheObject, CacheObject> entry0 : col) {
GridCacheRawVersionedEntry entry = (GridCacheRawVersionedEntry) entry0;
entry.unmarshal(cacheObjCtx, ctx.config().getMarshaller());
KeyCacheObject key = entry.getKey();
// Ensure that receiver to not receive special-purpose values for TTL and expire time.
assert entry.ttl() != CU.TTL_NOT_CHANGED && entry.ttl() != CU.TTL_ZERO && entry.ttl() >= 0;
assert entry.expireTime() != CU.EXPIRE_TIME_CALCULATE && entry.expireTime() >= 0;
CacheObject cacheVal = entry.getValue();
GridCacheDrInfo val = cacheVal != null ? entry.ttl() != CU.TTL_ETERNAL ? new GridCacheDrExpirationInfo(cacheVal, entry.version(), entry.ttl(), entry.expireTime()) : new GridCacheDrInfo(cacheVal, entry.version()) : null;
if (val == null)
cache.removeAllConflict(Collections.singletonMap(key, entry.version()));
else
cache.putAllConflict(Collections.singletonMap(key, val));
}
if (log.isDebugEnabled())
log.debug("DR put job finished [nodeId=" + ctx.localNodeId() + ", cacheName=" + cacheName + ']');
} catch (IgniteCheckedException e) {
throw U.convertException(e);
}
}
use of org.apache.ignite.internal.processors.cache.CacheOperationContext in project ignite by apache.
the class GridCacheQueueAdapter method withKeepBinary.
/**
* {@inheritDoc}
*/
@Override
public <V1> IgniteQueue<V1> withKeepBinary() {
CacheOperationContext opCtx = cctx.operationContextPerCall();
if (opCtx != null && opCtx.isKeepBinary())
return (GridCacheQueueAdapter<V1>) this;
opCtx = opCtx == null ? new CacheOperationContext(false, true, null, false, null, false, null, DFLT_ALLOW_ATOMIC_OPS_IN_TX) : opCtx.keepBinary();
cctx.operationContextPerCall(opCtx);
return (GridCacheQueueAdapter<V1>) this;
}
use of org.apache.ignite.internal.processors.cache.CacheOperationContext in project ignite by apache.
the class GridLocalAtomicCache method remove0.
/**
* {@inheritDoc}
*/
@Override
public boolean remove0(K key, final CacheEntryPredicate filter) throws IgniteCheckedException {
CacheOperationContext opCtx = ctx.operationContextPerCall();
Boolean rmv = (Boolean) updateAllInternal(DELETE, Collections.singleton(key), null, null, expiryPerCall(), false, false, filter, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary());
assert rmv != null;
return rmv;
}
use of org.apache.ignite.internal.processors.cache.CacheOperationContext in project ignite by apache.
the class GridLocalAtomicCache method expiryPerCall.
/**
* @return Expiry policy.
*/
@Nullable
private ExpiryPolicy expiryPerCall() {
CacheOperationContext opCtx = ctx.operationContextPerCall();
ExpiryPolicy expiry = opCtx != null ? opCtx.expiry() : null;
if (expiry == null)
expiry = ctx.expiry();
return expiry;
}
use of org.apache.ignite.internal.processors.cache.CacheOperationContext 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 GridPlainCallable<Object>() {
@Override
public Object call() throws Exception {
return updateAllInternal(op, keys, vals, invokeArgs, expiry, retval, rawRetval, filter, writeThrough, readThrough, keepBinary);
}
});
}
Aggregations