/** * @return Keep binary flag. */ public boolean keepBinary() { CacheOperationContext opCtx = operationContextPerCall(); return opCtx != null && opCtx.isKeepBinary(); }
/** {@inheritDoc} */ @Override protected V getAndPut0(K key, V val, @Nullable CacheEntryPredicate filter) throws IgniteCheckedException { CacheOperationContext opCtx = ctx.operationContextPerCall(); return (V)updateAllInternal(UPDATE, Collections.singleton(key), Collections.singleton(val), null, expiryPerCall(), true, false, filter, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary()); }
/** {@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()); }
/** {@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; }
/** {@inheritDoc} */ @Override public <K1, V1> GridCacheProxyImpl<K1, V1> keepBinary() { if (opCtx != null && opCtx.isKeepBinary()) return (GridCacheProxyImpl<K1, V1>)this; return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx, (GridCacheAdapter<K1, V1>)delegate, opCtx != null ? opCtx.keepBinary() : new CacheOperationContext(false, null, true, null, false, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX)); }
/** {@inheritDoc} */ @Override protected V getAndRemove0(K key) throws IgniteCheckedException { CacheOperationContext opCtx = ctx.operationContextPerCall(); return (V)updateAllInternal(DELETE, Collections.singleton(key), null, null, expiryPerCall(), true, false, null, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary()); }
/** {@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; }
/** {@inheritDoc} */ @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) { GridCacheContext<K, V> ctx = getContextSafe(); try { CacheOperationContext opCtx = ctx.operationContextPerCall(); ctx.continuousQueries().executeJCacheQuery(lsnrCfg, false, opCtx != null && opCtx.isKeepBinary()); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** {@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, null, true, null, false, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX) : opCtx.keepBinary(); cctx.operationContextPerCall(opCtx); return (GridCacheQueueAdapter<V1>)this; }
/** {@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()); }
/** {@inheritDoc} */ @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll( Map<? extends K, ? extends EntryProcessor<K, V, T>> map, Object... args) throws IgniteCheckedException { A.notNull(map, "map"); if (keyCheck) validateCacheKeys(map.keySet()); final boolean statsEnabled = ctx.statisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; CacheOperationContext opCtx = ctx.operationContextPerCall(); Map<K, EntryProcessorResult<T>> entryProcessorResult = (Map<K, EntryProcessorResult<T>>) updateAllInternal( TRANSFORM, map.keySet(), map.values(), args, expiryPerCall(), false, false, null, ctx.writeThrough(), ctx.readThrough(), opCtx != null && opCtx.isKeepBinary()); if (statsEnabled) metrics0().addInvokeTimeNanos(System.nanoTime() - start); return entryProcessorResult; }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> removeAllAsync() { GridFutureAdapter<Void> opFut = new GridFutureAdapter<>(); AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); CacheOperationContext opCtx = ctx.operationContextPerCall(); removeAllAsync(opFut, topVer, opCtx != null && opCtx.skipStore(), opCtx != null && opCtx.isKeepBinary()); return opFut; }
/** * Makes current operation context as keepBinary. * * @param cctx Cache context. * @return Old operation context. */ private CacheOperationContext setKeepBinaryContext(GridCacheContext<?, ?> cctx) { CacheOperationContext opCtx = cctx.operationContextPerCall(); // Force keepBinary for operation context to avoid binary deserialization inside entry processor if (cctx.binaryMarshaller()) { CacheOperationContext newOpCtx = null; if (opCtx == null) // Mimics behavior of GridCacheAdapter#keepBinary and GridCacheProxyImpl#keepBinary newOpCtx = new CacheOperationContext(false, null, true, null, false, null, false, true); else if (!opCtx.isKeepBinary()) newOpCtx = opCtx.keepBinary(); if (newOpCtx != null) cctx.operationContextPerCall(newOpCtx); } return opCtx; }
/** {@inheritDoc} */ @Override public final IgniteInternalFuture<Map<K, V>> getAllOutTxAsync(Set<? extends K> keys) { String taskName = ctx.kernalContext().job().currentTaskName(); CacheOperationContext opCtx = ctx.operationContextPerCall(); return getAllAsync(keys, !ctx.config().isReadFromBackup(), /*skip tx*/true, null, taskName, !(opCtx != null && opCtx.isKeepBinary()), opCtx != null && opCtx.recovery(), /*skip values*/false, /*need ver*/false); }
/** {@inheritDoc} */ @Override protected IgniteInternalFuture<Boolean> lockAllAsync( Collection<KeyCacheObject> keys, long timeout, IgniteTxLocalEx tx, boolean isInvalidate, boolean isRead, boolean retval, TransactionIsolation isolation, long createTtl, long accessTtl ) { CacheOperationContext opCtx = ctx.operationContextPerCall(); GridNearLockFuture fut = new GridNearLockFuture(ctx, keys, (GridNearTxLocal)tx, isRead, retval, timeout, createTtl, accessTtl, CU.empty0(), opCtx != null && opCtx.skipStore(), opCtx != null && opCtx.isKeepBinary(), opCtx != null && opCtx.recovery()); fut.map(); return fut; }
/** * @param p Predicate. * @param args Arguments. * @return Load cache future. * @throws IgniteCheckedException If failed. */ IgniteInternalFuture<?> globalLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws IgniteCheckedException { ctx.kernalContext().task().setThreadContext(TC_NO_FAILOVER, true); CacheOperationContext opCtx = ctx.operationContextPerCall(); ExpiryPolicy plc = opCtx != null ? opCtx.expiry() : null; Collection<ClusterNode> nodes = ctx.kernalContext().grid().cluster().forDataNodes(ctx.name()).nodes(); assert !F.isEmpty(nodes) : "There are not datanodes fo cache: " + ctx.name(); //TODO IGNITE-7954 MvccUtils.verifyMvccOperationSupport(ctx, "Load"); final boolean keepBinary = opCtx != null && opCtx.isKeepBinary(); ComputeTaskInternalFuture fut = ctx.kernalContext().closure().callAsync(BROADCAST, Collections.singletonList( new LoadCacheJobV2<>(ctx.name(), ctx.affinity().affinityTopologyVersion(), p, args, plc, keepBinary)), nodes); return fut; }
/** {@inheritDoc} */ @Override public List<FieldsQueryCursor<List<?>>> queryMultipleStatements(SqlFieldsQuery qry) { GridCacheContext<K, V> ctx = getContextSafe(); A.notNull(qry, "qry"); try { ctx.checkSecurity(SecurityPermission.CACHE_READ); validate(qry); convertToBinary(qry); CacheOperationContext opCtxCall = ctx.operationContextPerCall(); boolean keepBinary = opCtxCall != null && opCtxCall.isKeepBinary(); return ctx.kernalContext().query().querySqlFields(ctx, qry, null, keepBinary, false); } catch (Exception e) { if (e instanceof CacheException) throw (CacheException)e; throw new CacheException(e); } }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable final Collection<? extends K> keys) { A.notNull(keys, "keys"); final boolean statsEnabled = ctx.statisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; String taskName = ctx.kernalContext().job().currentTaskName(); CacheOperationContext opCtx = ctx.operationContextPerCall(); IgniteInternalFuture<Map<K, V>> fut = getAllAsync( keys, !ctx.config().isReadFromBackup(), /*skip tx*/false, opCtx != null ? opCtx.subjectId() : null, taskName, !(opCtx != null && opCtx.isKeepBinary()), opCtx != null && opCtx.recovery(), /*skip vals*/false, /*need ver*/false); if (ctx.config().getInterceptor() != null) return fut.chain(new CX1<IgniteInternalFuture<Map<K, V>>, Map<K, V>>() { @Override public Map<K, V> applyx(IgniteInternalFuture<Map<K, V>> f) throws IgniteCheckedException { return interceptGet(keys, f.get()); } }); if (statsEnabled) fut.listen(new UpdateGetTimeStatClosure<Map<K, V>>(metrics0(), start)); return fut; }
/** {@inheritDoc} */ @Override public <R> QueryCursor<R> query(Query<R> qry) { GridCacheContext<K, V> ctx = getContextSafe(); A.notNull(qry, "qry"); try { ctx.checkSecurity(SecurityPermission.CACHE_READ); validate(qry); convertToBinary(qry); CacheOperationContext opCtxCall = ctx.operationContextPerCall(); boolean keepBinary = opCtxCall != null && opCtxCall.isKeepBinary(); if (qry instanceof ContinuousQuery || qry instanceof ContinuousQueryWithTransformer) return (QueryCursor<R>)queryContinuous((AbstractContinuousQuery)qry, qry.isLocal(), keepBinary); if (qry instanceof SqlQuery) return (QueryCursor<R>)ctx.kernalContext().query().querySql(ctx, (SqlQuery)qry, keepBinary); if (qry instanceof SqlFieldsQuery) return (FieldsQueryCursor<R>)ctx.kernalContext().query().querySqlFields(ctx, (SqlFieldsQuery)qry, null, keepBinary, true).get(0); if (qry instanceof ScanQuery) return query((ScanQuery)qry, null, projection(qry.isLocal())); return (QueryCursor<R>)query(qry, projection(qry.isLocal())); } catch (Exception e) { if (e instanceof CacheException) throw (CacheException)e; throw new CacheException(e.getMessage(), e); } }
/** {@inheritDoc} */ @Override public void removeAll() throws IgniteCheckedException { try { AffinityTopologyVersion topVer; boolean retry; CacheOperationContext opCtx = ctx.operationContextPerCall(); boolean skipStore = opCtx != null && opCtx.skipStore(); boolean keepBinary = opCtx != null && opCtx.isKeepBinary(); do { retry = false; topVer = ctx.affinity().affinityTopologyVersion(); // Send job to all data nodes. Collection<ClusterNode> nodes = ctx.grid().cluster().forDataNodes(name()).nodes(); if (!nodes.isEmpty()) { ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes); retry = !ctx.kernalContext().task().execute( new RemoveAllTask(ctx.name(), topVer, skipStore, keepBinary), null).get(); } } while (ctx.affinity().affinityTopologyVersion().compareTo(topVer) != 0 || retry); } catch (ClusterGroupEmptyCheckedException ignore) { if (log.isDebugEnabled()) log.debug("All remote nodes left while cache remove [cacheName=" + name() + "]"); } }