diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java index 04c721a98ab24..9d680ef75ed26 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java @@ -120,10 +120,10 @@ public void leave() { } /** - * @param prj Projection to guard. - * @return Previous projection set on this thread. + * @param opCtx Cache operation context to guard. + * @return Previous operation context set on this thread. */ - @Nullable public CacheOperationContext enter(@Nullable CacheOperationContext prj) { + @Nullable public CacheOperationContext enter(@Nullable CacheOperationContext opCtx) { try { GridCacheAdapter cache = ctx.cache(); @@ -153,7 +153,7 @@ public void leave() { // Must unlock in case of unexpected errors to avoid // deadlocks during kernal stop. try { - return setProjectionPerCall(prj); + return setOperationContextPerCall(opCtx); } catch (RuntimeException e) { rwLock.readUnlock(); @@ -163,29 +163,29 @@ public void leave() { } /** - * @param prj Projection to guard. - * @return Previous projection set on this thread. + * @param opCtx Operation context to guard. + * @return Previous operation context set on this thread. */ - @Nullable public GridCacheProjectionImpl enterNoLock(@Nullable GridCacheProjectionImpl prj) { + @Nullable public CacheOperationContext enterNoLock(@Nullable CacheOperationContext opCtx) { onEnter(); if (stopped) throw new IllegalStateException("Cache has been stopped: " + ctx.name()); - return setProjectionPerCall(prj); + return setOperationContextPerCall(opCtx); } /** - * Set thread local projection per call. + * Set thread local operation context per call. * - * @param prj Projection to guard. - * @return Previous projection set on this thread. + * @param opCtx Operation context to guard. + * @return Previous operation context set on this thread. */ - private CacheOperationContext setProjectionPerCall(@Nullable CacheOperationContext prj) { + private CacheOperationContext setOperationContextPerCall(@Nullable CacheOperationContext opCtx) { CacheOperationContext prev = ctx.operationContextPerCall(); - if (prev != null || prj != null) - ctx.operationContextPerCall(prj); + if (prev != null || opCtx != null) + ctx.operationContextPerCall(opCtx); return prev; } @@ -212,7 +212,7 @@ public void leaveNoLock(CacheOperationContext prev) { // Unwind eviction notifications. CU.unwindEvicts(ctx); - // Return back previous thread local projection per call. + // Return back previous thread local operation context per call. ctx.operationContextPerCall(prev); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index 91f12b379f660..128091f8fb853 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -111,7 +111,7 @@ public IgniteCacheProxy( /** * @param ctx Context. * @param delegate Delegate. - * @param prj Projection. + * @param opCtx Operation context. * @param async Async support flag. * @param lock If {@code false} does not acquire read lock on gateway enter. */ @@ -195,13 +195,13 @@ public GridCacheGateway gate() { return new CacheMetricsSnapshot(ctx.cache().metrics(), metrics); } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Override public CacheMetricsMXBean mxBean() { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = gate.enter(opCtx); try { return ctx.cache().mxBean(); @@ -223,27 +223,27 @@ public GridCacheGateway gate() { /** {@inheritDoc} */ @Nullable @Override public Entry randomEntry() { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { return ctx.cache().randomEntry(); } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Override public IgniteCache withExpiryPolicy(ExpiryPolicy plc) { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { - GridCacheProjectionEx prj0 = prj != null ? prj.withExpiryPolicy(plc) : delegate.withExpiryPolicy(plc); + CacheOperationContext prj0 = opCtx.withExpiryPolicy(plc); - return new IgniteCacheProxy<>(ctx, prj0, (GridCacheProjectionImpl)prj0, isAsync()); + return new IgniteCacheProxy<>(ctx, delegate, prj0, isAsync(), lock); } finally { - gate.leave(prev); + onLeave(prev); } } @@ -255,7 +255,7 @@ public GridCacheGateway gate() { /** {@inheritDoc} */ @Override public void loadCache(@Nullable IgniteBiPredicate p, @Nullable Object... args) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) @@ -264,7 +264,7 @@ public GridCacheGateway gate() { ctx.cache().globalLoadCache(p, args); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -275,7 +275,7 @@ public GridCacheGateway gate() { /** {@inheritDoc} */ @Override public void localLoadCache(@Nullable IgniteBiPredicate p, @Nullable Object... args) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) @@ -284,7 +284,7 @@ public GridCacheGateway gate() { delegate.localLoadCache(p, args); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -295,7 +295,7 @@ public GridCacheGateway gate() { /** {@inheritDoc} */ @Nullable @Override public V getAndPutIfAbsent(K key, V val) throws CacheException { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -307,7 +307,7 @@ public GridCacheGateway gate() { return delegate.getAndPutIfAbsent(key, val); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -322,18 +322,18 @@ public GridCacheGateway gate() { /** {@inheritDoc} */ @Override public Lock lockAll(final Collection keys) { - return new CacheLockImpl<>(gate, delegate, prj, keys); + return new CacheLockImpl<>(gate, delegate, opCtx, keys); } /** {@inheritDoc} */ @Override public boolean isLocalLocked(K key, boolean byCurrThread) { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { return byCurrThread ? delegate.isLockedByThread(key) : delegate.isLocked(key); } finally { - gate.leave(prev); + onLeave(prev); } } @@ -350,7 +350,7 @@ private QueryCursor> query(Query filter, @Nullable ClusterGroup grp) if (filter instanceof ScanQuery) { IgniteBiPredicate p = ((ScanQuery)filter).getFilter(); - qry = delegate.queries().createScanQuery(p != null ? p : ACCEPT_ALL); + qry = ctx.queries().createScanQuery(p != null ? p : ACCEPT_ALL, opCtx.isKeepPortable()); if (grp != null) qry.projection(grp); @@ -360,7 +360,7 @@ private QueryCursor> query(Query filter, @Nullable ClusterGroup grp) else if (filter instanceof TextQuery) { TextQuery p = (TextQuery)filter; - qry = delegate.queries().createFullTextQuery(p.getType(), p.getText()); + qry = ctx.queries().createFullTextQuery(p.getType(), p.getText(), opCtx.isKeepPortable()); if (grp != null) qry.projection(grp); @@ -368,7 +368,7 @@ else if (filter instanceof TextQuery) { fut = qry.execute(); } else if (filter instanceof SpiQuery) { - qry = delegate.queries().createSpiQuery(); + qry = ctx.queries().createSpiQuery(opCtx.isKeepPortable()); if (grp != null) qry.projection(grp); @@ -482,7 +482,7 @@ private QueryCursor> queryContinuous(ContinuousQuery qry, boolean lo @Override public QueryCursor query(Query qry) { A.notNull(qry, "qry"); - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { ctx.checkSecurity(SecurityPermission.CACHE_READ); @@ -519,7 +519,7 @@ private QueryCursor> queryContinuous(ContinuousQuery qry, boolean lo throw new CacheException(e); } finally { - gate.leave(prev); + onLeave(prev); } } @@ -544,7 +544,7 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public Iterable> localEntries(CachePeekMode... peekModes) throws CacheException { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { return delegate.localEntries(peekModes); @@ -553,37 +553,37 @@ private void validate(Query qry) { throw cacheException(e); } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Override public QueryMetrics queryMetrics() { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { - return delegate.queries().metrics(); + return delegate.context().queries().metrics(); } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Override public void localEvict(Collection keys) { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { delegate.evictAll(keys); } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Nullable @Override public V localPeek(K key, CachePeekMode... peekModes) { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { return delegate.localPeek(key, peekModes, null); @@ -592,20 +592,20 @@ private void validate(Query qry) { throw cacheException(e); } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Override public void localPromote(Set keys) throws CacheException { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { delegate.promoteAll(keys); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -615,7 +615,7 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public int size(CachePeekMode... peekModes) throws CacheException { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -630,13 +630,13 @@ private void validate(Query qry) { throw cacheException(e); } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Override public int localSize(CachePeekMode... peekModes) { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { return delegate.localSize(peekModes); @@ -645,14 +645,14 @@ private void validate(Query qry) { throw cacheException(e); } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Override public V get(K key) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -664,7 +664,7 @@ private void validate(Query qry) { return delegate.get(key); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -675,7 +675,7 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public Map getAll(Set keys) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -687,7 +687,7 @@ private void validate(Query qry) { return delegate.getAll(keys); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -701,7 +701,7 @@ private void validate(Query qry) { */ public Map getAll(Collection keys) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -713,7 +713,7 @@ public Map getAll(Collection keys) { return delegate.getAll(keys); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -728,19 +728,19 @@ public Map getAll(Collection keys) { * @return Entry set. */ public Set> entrySetx(CacheEntryPredicate... filter) { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { return delegate.entrySetx(filter); } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Override public boolean containsKey(K key) { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -752,13 +752,13 @@ public Set> entrySetx(CacheEntryPredicate... filter) { return delegate.containsKey(key); } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Override public boolean containsKeys(Set keys) { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -770,7 +770,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { return delegate.containsKeys(keys); } finally { - gate.leave(prev); + onLeave(prev); } } @@ -780,7 +780,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { boolean replaceExisting, @Nullable final CompletionListener completionLsnr ) { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { IgniteInternalFuture fut = ctx.cache().loadAll(keys, replaceExisting); @@ -801,14 +801,14 @@ public Set> entrySetx(CacheEntryPredicate... filter) { } } finally { - gate.leave(prev); + onLeave(prev); } } /** {@inheritDoc} */ @Override public void put(K key, V val) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) @@ -817,7 +817,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { delegate.put(key, val); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -828,7 +828,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { /** {@inheritDoc} */ @Override public V getAndPut(K key, V val) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -840,7 +840,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { return delegate.getAndPut(key, val); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -851,7 +851,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { /** {@inheritDoc} */ @Override public void putAll(Map map) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) @@ -860,7 +860,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { delegate.putAll(map); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -871,7 +871,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { /** {@inheritDoc} */ @Override public boolean putIfAbsent(K key, V val) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -883,7 +883,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { return delegate.putIfAbsent(key, val); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -894,7 +894,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { /** {@inheritDoc} */ @Override public boolean remove(K key) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -906,7 +906,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { return delegate.remove(key); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -917,7 +917,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { /** {@inheritDoc} */ @Override public boolean remove(K key, V oldVal) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -929,7 +929,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { return delegate.remove(key, oldVal); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -940,7 +940,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { /** {@inheritDoc} */ @Override public V getAndRemove(K key) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -952,7 +952,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { return delegate.getAndRemove(key); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -963,7 +963,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { /** {@inheritDoc} */ @Override public boolean replace(K key, V oldVal, V newVal) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -975,7 +975,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { return delegate.replace(key, oldVal, newVal); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -986,7 +986,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { /** {@inheritDoc} */ @Override public boolean replace(K key, V val) { try { - GridCacheProjectionImpl prev = gate.enter(prj); + CacheOperationContext prev = onEnter(opCtx); try { if (isAsync()) { @@ -998,7 +998,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { return delegate.replace(key, val); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -1021,7 +1021,7 @@ public Set> entrySetx(CacheEntryPredicate... filter) { return delegate.getAndReplace(key, val); } finally { - gate.leave(prev); + onLeave(prev); } } catch (IgniteCheckedException e) { @@ -1441,12 +1441,12 @@ public IgniteCache keepPortable() { CacheOperationContext prev = onEnter(opCtx); try { - CacheOperationContext prj = + CacheOperationContext opCtx0 = new CacheOperationContext(opCtx.skipStore(), opCtx.subjectId(), true, opCtx.expiry()); return new IgniteCacheProxy<>((GridCacheContext)ctx, (GridCacheAdapter)delegate, - prj, + opCtx0, isAsync(), lock); } @@ -1467,12 +1467,12 @@ public IgniteCache skipStore() { if (skip) return this; - CacheOperationContext prj0 = + CacheOperationContext opCtx0 = new CacheOperationContext(true, opCtx.subjectId(), opCtx.isKeepPortable(), opCtx.expiry()); return new IgniteCacheProxy<>(ctx, delegate, - prj0, + opCtx0, isAsync(), lock); }