#ignite-758:CacheProjectionContext implements Serializable.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3811c9a1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3811c9a1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3811c9a1 Branch: refs/heads/ignite-758 Commit: 3811c9a1bc809c97b0e7cea6154039c7e341448b Parents: ddc9178 Author: ivasilinets <ivasilin...@gridgain.com> Authored: Thu Apr 16 11:27:43 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Thu Apr 16 11:27:43 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/CacheLockImpl.java | 12 +- .../processors/cache/CacheProjection.java | 4 +- .../cache/CacheProjectionContext.java | 649 +------------------ .../processors/cache/GridCacheAdapter.java | 64 +- .../cache/GridCacheConcurrentMap.java | 8 +- .../processors/cache/GridCacheContext.java | 20 +- .../processors/cache/GridCacheGateway.java | 6 +- .../processors/cache/GridCacheProjectionEx.java | 4 +- .../processors/cache/GridCacheProxyImpl.java | 253 ++++---- .../processors/cache/IgniteCacheProxy.java | 120 ++-- .../cache/affinity/GridCacheAffinityProxy.java | 30 +- .../distributed/dht/GridDhtCacheAdapter.java | 2 +- .../dht/atomic/GridDhtAtomicCache.java | 6 +- .../dht/colocated/GridDhtColocatedCache.java | 2 +- .../distributed/near/GridNearAtomicCache.java | 2 +- .../near/GridNearTransactionalCache.java | 2 +- .../local/atomic/GridLocalAtomicCache.java | 4 +- .../cache/query/CacheQueriesImpl.java | 4 +- .../cache/query/CacheQueriesProxy.java | 34 +- .../transactions/IgniteTxLocalAdapter.java | 4 +- 20 files changed, 294 insertions(+), 936 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3811c9a1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java index e16490a..5e9ed70 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java @@ -38,7 +38,7 @@ class CacheLockImpl<K, V> implements Lock { private final GridCacheProjectionEx<K, V> delegate; /** Projection. */ - private final CacheProjectionContext<K, V> prj; + private final CacheProjectionContext prj; /** */ private final Collection<? extends K> keys; @@ -55,7 +55,7 @@ class CacheLockImpl<K, V> implements Lock { * @param prj Projection. * @param keys Keys. */ - CacheLockImpl(GridCacheGateway<K, V> gate, GridCacheProjectionEx<K, V> delegate, CacheProjectionContext<K, V> prj, + CacheLockImpl(GridCacheGateway<K, V> gate, GridCacheProjectionEx<K, V> delegate, CacheProjectionContext prj, Collection<? extends K> keys) { this.gate = gate; this.delegate = delegate; @@ -65,7 +65,7 @@ class CacheLockImpl<K, V> implements Lock { /** {@inheritDoc} */ @Override public void lock() { - CacheProjectionContext<K, V> prev = gate.enter(prj); + CacheProjectionContext prev = gate.enter(prj); try { delegate.lockAll(keys, 0); @@ -98,7 +98,7 @@ class CacheLockImpl<K, V> implements Lock { /** {@inheritDoc} */ @Override public boolean tryLock() { - CacheProjectionContext<K, V> prev = gate.enter(prj); + CacheProjectionContext prev = gate.enter(prj); try { boolean res = delegate.lockAll(keys, -1); @@ -124,7 +124,7 @@ class CacheLockImpl<K, V> implements Lock { if (time <= 0) return tryLock(); - CacheProjectionContext<K, V> prev = gate.enter(prj); + CacheProjectionContext prev = gate.enter(prj); try { IgniteInternalFuture<Boolean> fut = delegate.lockAllAsync(keys, unit.toMillis(time)); @@ -167,7 +167,7 @@ class CacheLockImpl<K, V> implements Lock { /** {@inheritDoc} */ @Override public void unlock() { - CacheProjectionContext<K, V> prev = gate.enter(prj); + CacheProjectionContext prev = gate.enter(prj); try { if (lockedThread != Thread.currentThread()) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3811c9a1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java index 87af7fa..99ca0f4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java @@ -211,7 +211,7 @@ public interface CacheProjection<K, V> extends Iterable<Cache.Entry<K, V>> { * @param skipStore Skip store flag. * @return New projection based on this one, but with skip store flag enabled. */ - public CacheProjection<K, V> setSkipStore(boolean skipStore); + public GridCacheProxyImpl<K, V> setSkipStore(boolean skipStore); /** * Creates projection that will operate with portable objects. @@ -250,7 +250,7 @@ public interface CacheProjection<K, V> extends Iterable<Cache.Entry<K, V>> { * * @return Projection for portable objects. */ - public <K1, V1> CacheProjection<K1, V1> keepPortable(); + public <K1, V1> GridCacheProxyImpl<K1, V1> keepPortable(); /** * Returns {@code true} if this map contains no key-value mappings. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3811c9a1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjectionContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjectionContext.java index 3de6338..f8cefda 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjectionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjectionContext.java @@ -17,44 +17,21 @@ package org.apache.ignite.internal.processors.cache; -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.internal.processors.cache.dr.*; -import org.apache.ignite.internal.processors.cache.query.*; -import org.apache.ignite.internal.processors.cache.transactions.*; -import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; -import javax.cache.*; import javax.cache.expiry.*; -import javax.cache.processor.*; import java.io.*; import java.util.*; -import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.internal.processors.cache.GridCacheUtils.*; - /** * Cache projection context. */ -public class CacheProjectionContext<K, V> implements GridCacheProjectionEx<K, V>, Externalizable { +public class CacheProjectionContext implements Serializable { /** */ private static final long serialVersionUID = 0L; - /** Base cache. */ - private GridCacheAdapter<K, V> cache; - - /** Cache context. */ - private GridCacheContext<K, V> cctx; - - /** Queries impl. */ - private CacheQueries<K, V> qry; - /** Skip store. */ @GridToStringInclude private boolean skipStore; @@ -76,48 +53,27 @@ public class CacheProjectionContext<K, V> implements GridCacheProjectionEx<K, V> } /** - * @param parent Parent projection. - * @param cctx Cache context. * @param skipStore Skip store flag. * @param subjId Subject ID. * @param keepPortable Keep portable flag. * @param expiryPlc Expiry policy. */ public CacheProjectionContext( - CacheProjection<K, V> parent, - GridCacheContext<K, V> cctx, boolean skipStore, @Nullable UUID subjId, boolean keepPortable, @Nullable ExpiryPolicy expiryPlc) { - assert parent != null; - assert cctx != null; - - this.cctx = cctx; this.skipStore = skipStore; this.subjId = subjId; - cache = cctx.cache(); - - qry = new CacheQueriesImpl<>(cctx, this); - this.keepPortable = keepPortable; this.expiryPlc = expiryPlc; } /** - * Gets cache context. - * - * @return Cache context. - */ - @Override public GridCacheContext<K, V> context() { - return cctx; - } - - /** * @return Keep portable flag. */ public boolean isKeepPortable() { @@ -132,28 +88,12 @@ public class CacheProjectionContext<K, V> implements GridCacheProjectionEx<K, V> } /** {@inheritDoc} */ - @SuppressWarnings( {"unchecked", "RedundantCast"}) - @Override public <K1, V1> GridCache<K1, V1> cache() { - return (GridCache<K1, V1>)cctx.cache(); - } - - /** {@inheritDoc} */ - @Override public CacheQueries<K, V> queries() { - return qry; - } - - /** {@inheritDoc} */ - @Override public GridCacheProjectionEx<K, V> forSubjectId(UUID subjId) { - A.notNull(subjId, "subjId"); - - CacheProjectionContext<K, V> prj = new CacheProjectionContext<>(this, - cctx, + public CacheProjectionContext keepPortable() { + return new CacheProjectionContext( skipStore, subjId, - keepPortable, + true, expiryPlc); - - return new GridCacheProxyImpl<>(cctx, cache, prj); } /** @@ -166,570 +106,38 @@ public class CacheProjectionContext<K, V> implements GridCacheProjectionEx<K, V> } /** {@inheritDoc} */ - @Override public CacheProjection<K, V> setSkipStore(boolean skipStore) { - if (this.skipStore == skipStore) - return new GridCacheProxyImpl<>(cctx, cache, this); + public CacheProjectionContext forSubjectId(UUID subjId) { + A.notNull(subjId, "subjId"); - CacheProjectionContext<K, V> prj = new CacheProjectionContext<>(this, - cctx, + return new CacheProjectionContext( skipStore, subjId, keepPortable, expiryPlc); - - return new GridCacheProxyImpl<>(cctx, cache, prj); - } - - /** {@inheritDoc} */ - @Override public <K1, V1> CacheProjection<K1, V1> keepPortable() { - CacheProjectionContext<K1, V1> prj = new CacheProjectionContext<>( - (CacheProjection<K1, V1>)this, - (GridCacheContext<K1, V1>)cctx, - skipStore, - subjId, - true, - expiryPlc); - - return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)cctx, (GridCacheAdapter<K1, V1>)cache, prj); - } - - /** {@inheritDoc} */ - @Override public int size() { - return keySet().size(); - } - - /** {@inheritDoc} */ - @Override public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException { - return cache.localSize(peekModes); - } - - /** {@inheritDoc} */ - @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException { - return cache.size(peekModes); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Integer> sizeAsync(CachePeekMode[] peekModes) { - return cache.sizeAsync(peekModes); - } - - /** {@inheritDoc} */ - @Override public int nearSize() { - return cctx.config().getCacheMode() == PARTITIONED && isNearEnabled(cctx) ? - cctx.near().nearKeySet(null).size() : 0; - } - - /** {@inheritDoc} */ - @Override public int primarySize() { - return primaryKeySet().size(); - } - - /** {@inheritDoc} */ - @Override public boolean isEmpty() { - return cache.isEmpty() || size() == 0; - } - - /** {@inheritDoc} */ - @Override public boolean containsKey(K key) { - return cache.containsKey(key); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> containsKeyAsync(K key) { - return cache.containsKeyAsync(key); - } - - /** {@inheritDoc} */ - @Override public boolean containsKeys(Collection<? extends K> keys) { - return cache.containsKeys(keys); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> containsKeysAsync(Collection<? extends K> keys) { - return cache.containsKeysAsync(keys); - } - - /** {@inheritDoc} */ - @Override public V get(K key) throws IgniteCheckedException { - return cache.get(key, deserializePortables()); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> getAsync(K key) { - return cache.getAsync(key, deserializePortables()); - } - - /** {@inheritDoc} */ - @Override public V getForcePrimary(K key) throws IgniteCheckedException { - return cache.getForcePrimary(key); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> getForcePrimaryAsync(K key) { - return cache.getForcePrimaryAsync(key); - } - - /** {@inheritDoc} */ - @Nullable @Override public Map<K, V> getAllOutTx(List<K> keys) throws IgniteCheckedException { - return cache.getAllOutTx(keys); - } - - /** {@inheritDoc} */ - @Override public boolean isIgfsDataCache() { - return cache.isIgfsDataCache(); - } - - /** {@inheritDoc} */ - @Override public long igfsDataSpaceUsed() { - return cache.igfsDataSpaceUsed(); } /** {@inheritDoc} */ - @Override public long igfsDataSpaceMax() { - return cache.igfsDataSpaceMax(); - } - - /** {@inheritDoc} */ - @Override public boolean isMongoDataCache() { - return cache.isMongoDataCache(); - } - - /** {@inheritDoc} */ - @Override public boolean isMongoMetaCache() { - return cache.isMongoMetaCache(); - } - - /** {@inheritDoc} */ - @Override public Map<K, V> getAll(@Nullable Collection<? extends K> keys) throws IgniteCheckedException { - return cache.getAll(keys, deserializePortables()); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable Collection<? extends K> keys) { - return cache.getAllAsync(keys, deserializePortables()); - } - - /** {@inheritDoc} */ - @Override public V getAndPut(K key, V val) - throws IgniteCheckedException { - return getAndPutAsync(key, val).get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> getAndPutAsync(K key, V val) { - return cache.getAndPutAsync(key, val); - } - - /** {@inheritDoc} */ - @Override public boolean put(K key, V val) throws IgniteCheckedException { - return cache.put(key, val); - } - - /** {@inheritDoc} */ - @Override public void putAllConflict(Map<KeyCacheObject, GridCacheDrInfo> drMap) throws IgniteCheckedException { - cache.putAllConflict(drMap); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> putAllConflictAsync(Map<KeyCacheObject, GridCacheDrInfo> drMap) - throws IgniteCheckedException { - return cache.putAllConflictAsync(drMap); - } - - /** {@inheritDoc} */ - @Override public <T> EntryProcessorResult<T> invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... args) - throws IgniteCheckedException { - return cache.invoke(key, entryProcessor, args); - } - - /** {@inheritDoc} */ - @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, - EntryProcessor<K, V, T> entryProcessor, - Object... args) throws IgniteCheckedException { - return cache.invokeAll(keys, entryProcessor, args); - } - - /** {@inheritDoc} */ - @Override public <T> IgniteInternalFuture<EntryProcessorResult<T>> invokeAsync(K key, - EntryProcessor<K, V, T> entryProcessor, - Object... args) { - return cache.invokeAsync(key, entryProcessor, args); - } - - /** {@inheritDoc} */ - @Override public <T> IgniteInternalFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys, - EntryProcessor<K, V, T> entryProcessor, - Object... args) { - return cache.invokeAllAsync(keys, entryProcessor, args); - } - - /** {@inheritDoc} */ - @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll( - Map<? extends K, ? extends EntryProcessor<K, V, T>> map, - Object... args) throws IgniteCheckedException { - return cache.invokeAll(map, args); - } - - /** {@inheritDoc} */ - @Override public <T> IgniteInternalFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync( - Map<? extends K, ? extends EntryProcessor<K, V, T>> map, - Object... args) { - return cache.invokeAllAsync(map, args); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> putAsync(K key, V val) { - return cache.putAsync(key, val); - } - - /** {@inheritDoc} */ - @Override public V getAndPutIfAbsent(K key, V val) throws IgniteCheckedException { - return getAndPutIfAbsentAsync(key, val).get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> getAndPutIfAbsentAsync(K key, V val) { - return cache.getAndPutIfAbsentAsync(key, val); - } - - /** {@inheritDoc} */ - @Override public boolean putIfAbsent(K key, V val) throws IgniteCheckedException { - return putIfAbsentAsync(key, val).get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> putIfAbsentAsync(K key, V val) { - return cache.putIfAbsentAsync(key, val); - } - - /** {@inheritDoc} */ - @Override public V getAndReplace(K key, V val) throws IgniteCheckedException { - return getAndReplaceAsync(key, val).get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> getAndReplaceAsync(K key, V val) { - return cache.getAndReplaceAsync(key, val); - } - - /** {@inheritDoc} */ - @Override public boolean replace(K key, V val) throws IgniteCheckedException { - return replaceAsync(key, val).get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> replaceAsync(K key, V val) { - return cache.replaceAsync(key, val); - } - - /** {@inheritDoc} */ - @Override public boolean replace(K key, V oldVal, V newVal) throws IgniteCheckedException { - return replaceAsync(key, oldVal, newVal).get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) { - CacheEntryPredicate fltr = cctx.equalsValue(oldVal); - - return cache.putAsync(key, newVal, fltr); - } - - /** {@inheritDoc} */ - @Override public void putAll(Map<? extends K, ? extends V> m) throws IgniteCheckedException { - putAllAsync(m).get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> putAllAsync(Map<? extends K, ? extends V> m) { - return cache.putAllAsync(m); - } - - /** {@inheritDoc} */ - @Override public Set<K> keySet() { - return cache.keySet(); - } - - /** {@inheritDoc} */ - @Override public Set<K> primaryKeySet() { - return cache.primaryKeySet(); - } - - /** {@inheritDoc} */ - @Override public Collection<V> values() { - return cache.values(); - } - - /** {@inheritDoc} */ - @Override public Set<Cache.Entry<K, V>> entrySet() { - return cache.entrySet(); - } - - /** {@inheritDoc} */ - @Override public Set<Cache.Entry<K, V>> entrySetx(CacheEntryPredicate... filter) { - return cache.entrySetx(filter); - } - - /** {@inheritDoc} */ - @Override public Set<Cache.Entry<K, V>> entrySet(int part) { - // TODO pass entry filter. - return cache.entrySet(part); - } - - /** {@inheritDoc} */ - @Override public boolean skipStore() { + public boolean skipStore() { return skipStore; } /** {@inheritDoc} */ - @Override public String name() { - return cache.name(); - } - - /** {@inheritDoc} */ - @Nullable @Override public V localPeek(K key, - CachePeekMode[] peekModes, - @Nullable IgniteCacheExpiryPolicy plc) - throws IgniteCheckedException - { - return cache.localPeek(key, peekModes, plc); - } - - /** {@inheritDoc} */ - @Override public Iterable<Cache.Entry<K, V>> localEntries(CachePeekMode[] peekModes) throws IgniteCheckedException { - return cache.localEntries(peekModes); - } - - /** {@inheritDoc} */ - @Override public boolean evict(K key) { - return cache.evict(key); - } - - /** {@inheritDoc} */ - @Override public void evictAll(@Nullable Collection<? extends K> keys) { - cache.evictAll(keys); - } - - /** {@inheritDoc} */ - @Override public void clearLocally() { - cache.clearLocally(); - } - - /** {@inheritDoc} */ - @Override public void clearLocallyAll(Set<? extends K> keys) { - cache.clearLocallyAll(keys); - } - - /** {@inheritDoc} */ - @Override public void clear() throws IgniteCheckedException { - cache.clear(); - } - - /** {@inheritDoc} */ - @Override public void clear(K key) throws IgniteCheckedException { - cache.clear(key); - } - - /** {@inheritDoc} */ - @Override public void clearAll(Set<? extends K> keys) throws IgniteCheckedException { - cache.clearAll(keys); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> clearAsync(K key) { - return cache.clearAsync(key); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> clearAsync(Set<? extends K> keys) { - return cache.clearAsync(keys); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> clearAsync() { - return cache.clearAsync(); - } - - /** {@inheritDoc} */ - @Override public boolean clearLocally(K key) { - return cache.clearLocally0(key); - } - - /** {@inheritDoc} */ - @Override public V getAndRemove(K key) throws IgniteCheckedException { - return getAndRemoveAsync(key).get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> getAndRemoveAsync(K key) { - return cache.getAndRemoveAsync(key); - } - - /** {@inheritDoc} */ - @Override public boolean remove(K key) throws IgniteCheckedException { - return removeAsync(key).get(); - } - - /** {@inheritDoc} */ - @Override public void removeAllConflict(Map<KeyCacheObject, GridCacheVersion> drMap) throws IgniteCheckedException { - cache.removeAllConflict(drMap); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> removeAllConflictAsync(Map<KeyCacheObject, GridCacheVersion> drMap) - throws IgniteCheckedException { - return cache.removeAllConflictAsync(drMap); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> removeAsync(K key) { - return cache.removeAsync(key); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<GridCacheReturn> replacexAsync(K key, V oldVal, V newVal) { - A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal"); - - return cache.replacexAsync(key, oldVal, newVal); - } - - /** {@inheritDoc} */ - @Override public GridCacheReturn replacex(K key, V oldVal, V newVal) throws IgniteCheckedException { - return replacexAsync(key, oldVal, newVal).get(); - } - - /** {@inheritDoc} */ - @Override public GridCacheReturn removex(K key, V val) throws IgniteCheckedException { - return removexAsync(key, val).get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<GridCacheReturn> removexAsync(K key, V val) { - return cache.removexAsync(key, val); - } - - /** {@inheritDoc} */ - @Override public boolean remove(K key, V val) throws IgniteCheckedException { - return removeAsync(key, val).get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> removeAsync(K key, V val) { - return cache.removeAsync(key, val); - } - - /** {@inheritDoc} */ - @Override public void removeAll(@Nullable Collection<? extends K> keys) throws IgniteCheckedException { - cache.removeAll(keys); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> removeAllAsync(@Nullable Collection<? extends K> keys) { - return cache.removeAllAsync(keys); - } - - /** {@inheritDoc} */ - @Override public void removeAll() - throws IgniteCheckedException { - removeAllAsync().get(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> removeAllAsync() { - return cache.removeAllAsync(); - } - - /** {@inheritDoc} */ - @Override public boolean lock(K key, long timeout) throws IgniteCheckedException { - return cache.lock(key, timeout); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> lockAsync(K key, long timeout) { - return cache.lockAsync(key, timeout); - } - - /** {@inheritDoc} */ - @Override public boolean lockAll(@Nullable Collection<? extends K> keys, long timeout) throws IgniteCheckedException { - return cache.lockAll(keys, timeout); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> lockAllAsync(@Nullable Collection<? extends K> keys, long timeout) { - return cache.lockAllAsync(keys, timeout); - } - - /** {@inheritDoc} */ - @Override public void unlock(K key) throws IgniteCheckedException { - cache.unlock(key); - } - - /** {@inheritDoc} */ - @Override public void unlockAll(@Nullable Collection<? extends K> keys) throws IgniteCheckedException { - cache.unlockAll(keys); - } - - /** {@inheritDoc} */ - @Override public boolean isLocked(K key) { - return cache.isLocked(key); - } - - /** {@inheritDoc} */ - @Override public boolean isLockedByThread(K key) { - return cache.isLockedByThread(key); - } - - /** {@inheritDoc} */ - @Override public void promoteAll(@Nullable Collection<? extends K> keys) throws IgniteCheckedException { - cache.promoteAll(keys); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalTx txStartEx(TransactionConcurrency concurrency, TransactionIsolation isolation) { - return cache.txStartEx(concurrency, isolation); - } - - /** {@inheritDoc} */ - @Override public Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation) { - return cache.txStart(concurrency, isolation); - } - - /** {@inheritDoc} */ - @Override public Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation, - long timeout, int txSize) { - return cache.txStart(concurrency, isolation, timeout, txSize); - } - - /** {@inheritDoc} */ - @Override public Transaction tx() { - return cache.tx(); - } - - /** {@inheritDoc} */ - @Override public Iterator<Cache.Entry<K, V>> iterator() { - return cache.entrySet().iterator(); + public CacheProjectionContext setSkipStore(boolean skipStore) { + return new CacheProjectionContext( + skipStore, + subjId, + keepPortable, + expiryPlc); } /** {@inheritDoc} */ - @Nullable @Override public ExpiryPolicy expiry() { + @Nullable public ExpiryPolicy expiry() { return expiryPlc; } /** {@inheritDoc} */ - @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) - throws IgniteCheckedException { - cache.localLoadCache(p, args); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<?> localLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) { - return cache.localLoadCacheAsync(p, args); - } - - /** {@inheritDoc} */ - @Override public GridCacheProjectionEx<K, V> withExpiryPolicy(ExpiryPolicy plc) { - return new CacheProjectionContext<>( - this, - cctx, + public CacheProjectionContext withExpiryPolicy(ExpiryPolicy plc) { + return new CacheProjectionContext( skipStore, subjId, true, @@ -737,29 +145,6 @@ public class CacheProjectionContext<K, V> implements GridCacheProjectionEx<K, V> } /** {@inheritDoc} */ - @Override public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(cctx); - - out.writeBoolean(skipStore); - - out.writeBoolean(keepPortable); - } - - /** {@inheritDoc} */ - @SuppressWarnings({"unchecked"}) - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - cctx = (GridCacheContext<K, V>)in.readObject(); - - skipStore = in.readBoolean(); - - cache = cctx.cache(); - - qry = new CacheQueriesImpl<>(cctx, this); - - keepPortable = in.readBoolean(); - } - - /** {@inheritDoc} */ @Override public String toString() { return S.toString(CacheProjectionContext.class, this); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3811c9a1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 4a5658a..b83c42f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -372,13 +372,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, } /** {@inheritDoc} */ - @Override public GridCacheProjectionEx<K, V> forSubjectId(UUID subjId) { - CacheProjectionContext<K, V> prj = new CacheProjectionContext<>(this, - ctx, - false, - subjId, - false, - null); + @Override public GridCacheProxyImpl<K, V> forSubjectId(UUID subjId) { + CacheProjectionContext prj = new CacheProjectionContext(false, subjId, false, null); return new GridCacheProxyImpl<>(ctx, this, prj); } @@ -389,42 +384,19 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, } /** {@inheritDoc} */ - @Override public CacheProjection<K, V> setSkipStore(boolean skipStore) { - if (!skipStore) - return this; - - CacheProjectionContext<K, V> prj = new CacheProjectionContext<>(this, - ctx, - false, - null, - false, - null); + @Override public GridCacheProxyImpl<K, V> setSkipStore(boolean skipStore) { + CacheProjectionContext prj = new CacheProjectionContext(true, null, false, null); return new GridCacheProxyImpl<>(ctx, this, prj); } /** {@inheritDoc} */ - @Override public <K1, V1> CacheProjection<K1, V1> keepPortable() { - CacheProjectionContext<K1, V1> prj = keepPortable0(); + @Override public <K1, V1> GridCacheProxyImpl<K1, V1> keepPortable() { + CacheProjectionContext prj = new CacheProjectionContext(false, null, true, null); return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx, (GridCacheAdapter<K1, V1>)this, prj); } - /** - * Internal routine to get "keep-portable" projection. - * - * @return Projection with "keep-portable" flag. - */ - public <K1, V1> CacheProjectionContext<K1, V1> keepPortable0() { - return new CacheProjectionContext<>( - (CacheProjection<K1, V1>)this, - (GridCacheContext<K1, V1>)ctx, - false, - null, - true, - null - ); - } /** {@inheritDoc} */ @Nullable @Override public ExpiryPolicy expiry() { @@ -432,14 +404,10 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, } /** {@inheritDoc} */ - @Override public GridCacheProjectionEx<K, V> withExpiryPolicy(ExpiryPolicy plc) { - return new CacheProjectionContext<>( - this, - ctx, - false, - null, - false, - plc); + @Override public GridCacheProxyImpl<K, V> withExpiryPolicy(ExpiryPolicy plc) { + CacheProjectionContext prj = new CacheProjectionContext(false, null, false, plc); + + return new GridCacheProxyImpl<>(ctx, this, prj); } /** {@inheritDoc} */ @@ -1625,7 +1593,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, boolean deserializePortable, boolean skipVals ) { - CacheProjectionContext<K, V> prj = ctx.projectionPerCall(); + CacheProjectionContext prj = ctx.projectionPerCall(); subjId = ctx.subjectIdPerCall(subjId, prj); @@ -3315,7 +3283,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, final boolean replicate = ctx.isDrEnabled(); final AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); - CacheProjectionContext<K, V> prj = ctx.projectionPerCall(); + CacheProjectionContext prj = ctx.projectionPerCall(); ExpiryPolicy plc0 = prj != null ? prj.expiry() : null; @@ -3438,7 +3406,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, if (!ctx.store().configured()) return new GridFinishedFuture<>(); - CacheProjectionContext<K, V> prj = ctx.projectionPerCall(); + CacheProjectionContext prj = ctx.projectionPerCall(); ExpiryPolicy plc = prj != null ? prj.expiry() : null; @@ -3578,7 +3546,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, ctx.kernalContext().task().setThreadContext(TC_NO_FAILOVER, true); - CacheProjectionContext<K, V> prj = ctx.projectionPerCall(); + CacheProjectionContext prj = ctx.projectionPerCall(); ExpiryPolicy plc = prj != null ? prj.expiry() : null; @@ -3740,7 +3708,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, if (!ctx0.isSwapOrOffheapEnabled() && ctx0.kernalContext().discovery().size() == 1) return localIteratorHonorExpirePolicy(); - final CacheProjectionContext<K, V> prj = ctx.projectionPerCall(); + final CacheProjectionContext prj = ctx.projectionPerCall(); CacheQueryFuture<Map.Entry<K, V>> fut = queries().createScanQuery(null) .keepAll(false) @@ -3752,7 +3720,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, } @Override protected void remove(Cache.Entry<K, V> item) { - CacheProjectionContext<K, V> prev = ctx.gate().enter(prj); + CacheProjectionContext prev = ctx.gate().enter(prj); try { GridCacheAdapter.this.remove(item.getKey()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3811c9a1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java index 8336351..0827730 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java @@ -1963,7 +1963,7 @@ public class GridCacheConcurrentMap { private GridCacheContext<K, V> ctx; /** */ - private CacheProjectionContext<K, V> prjPerCall; + private CacheProjectionContext prjPerCall; /** * Empty constructor required for {@link Externalizable}. @@ -1982,7 +1982,7 @@ public class GridCacheConcurrentMap { GridCacheConcurrentMap map, CacheEntryPredicate[] filter, GridCacheContext<K, V> ctx, - CacheProjectionContext<K, V> prjPerCall) { + CacheProjectionContext prjPerCall) { it = new Iterator0<>(map, false, filter, -1, -1); this.ctx = ctx; @@ -1996,7 +1996,7 @@ public class GridCacheConcurrentMap { /** {@inheritDoc} */ @Override public Cache.Entry<K, V> next() { - CacheProjectionContext<K, V> oldPrj = ctx.projectionPerCall(); + CacheProjectionContext oldPrj = ctx.projectionPerCall(); ctx.projectionPerCall(prjPerCall); @@ -2025,7 +2025,7 @@ public class GridCacheConcurrentMap { @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { it = (Iterator0<K, V>)in.readObject(); ctx = (GridCacheContext<K, V>)in.readObject(); - prjPerCall = (CacheProjectionContext<K, V>)in.readObject(); + prjPerCall = (CacheProjectionContext)in.readObject(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3811c9a1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java index dc3fcb8..0d059a9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java @@ -158,7 +158,7 @@ public class GridCacheContext<K, V> implements Externalizable { * Thread local projection. If it's set it means that method call was initiated * by child projection of initial cache. */ - private ThreadLocal<CacheProjectionContext<K, V>> prjPerCall = new ThreadLocal<>(); + private ThreadLocal<CacheProjectionContext> prjPerCall = new ThreadLocal<>(); /** Cache name. */ private String cacheName; @@ -1205,7 +1205,7 @@ public class GridCacheContext<K, V> implements Externalizable { * * @param prj Flags to set. */ - public void projectionPerCall(@Nullable CacheProjectionContext<K, V> prj) { + public void projectionPerCall(@Nullable CacheProjectionContext prj) { if (nearContext()) dht().near().context().prjPerCall.set(prj); else @@ -1217,7 +1217,7 @@ public class GridCacheContext<K, V> implements Externalizable { * * @return Projection per call. */ - public CacheProjectionContext<K, V> projectionPerCall() { + public CacheProjectionContext projectionPerCall() { return nearContext() ? dht().near().context().prjPerCall.get() : prjPerCall.get(); } @@ -1241,7 +1241,7 @@ public class GridCacheContext<K, V> implements Externalizable { * @param prj Optional thread local projection. * @return Subject ID per call. */ - public UUID subjectIdPerCall(@Nullable UUID subjId, @Nullable CacheProjectionContext<K, V> prj) { + public UUID subjectIdPerCall(@Nullable UUID subjId, @Nullable CacheProjectionContext prj) { if (prj != null) subjId = prj.subjectId(); @@ -1258,7 +1258,7 @@ public class GridCacheContext<K, V> implements Externalizable { if (nearContext()) return dht().near().context().skipStore(); - CacheProjectionContext<K, V> prj = prjPerCall.get(); + CacheProjectionContext prj = prjPerCall.get(); return (prj != null && prj.skipStore()); } @@ -1286,14 +1286,14 @@ public class GridCacheContext<K, V> implements Externalizable { assert r != null; // Have to get projection per call used by calling thread to use it in a new thread. - final CacheProjectionContext<K, V> prj = projectionPerCall(); + final CacheProjectionContext prj = projectionPerCall(); if (prj == null) return r; return new GPR() { @Override public void run() { - CacheProjectionContext<K, V> oldPrj = projectionPerCall(); + CacheProjectionContext oldPrj = projectionPerCall(); projectionPerCall(prj); @@ -1321,14 +1321,14 @@ public class GridCacheContext<K, V> implements Externalizable { assert r != null; // Have to get projection per call used by calling thread to use it in a new thread. - final CacheProjectionContext<K, V> prj = projectionPerCall(); + final CacheProjectionContext prj = projectionPerCall(); if (prj == null) return r; return new GPC<T>() { @Override public T call() throws Exception { - CacheProjectionContext<K, V> oldPrj = projectionPerCall(); + CacheProjectionContext oldPrj = projectionPerCall(); projectionPerCall(prj); @@ -1642,7 +1642,7 @@ public class GridCacheContext<K, V> implements Externalizable { * @return Keep portable flag. */ public boolean keepPortable() { - CacheProjectionContext<K, V> prj = projectionPerCall(); + CacheProjectionContext prj = projectionPerCall(); return prj != null && prj.isKeepPortable(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3811c9a1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java ---------------------------------------------------------------------- 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 0cc7caa..b43d92d 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 @@ -106,7 +106,7 @@ public class GridCacheGateway<K, V> { * @param prj Projection to guard. * @return Previous projection set on this thread. */ - @Nullable public CacheProjectionContext<K, V> enter(@Nullable CacheProjectionContext<K, V> prj) { + @Nullable public CacheProjectionContext enter(@Nullable CacheProjectionContext prj) { try { ctx.itHolder().checkWeakQueue(); @@ -140,7 +140,7 @@ public class GridCacheGateway<K, V> { // deadlocks during kernal stop. try { // Set thread local projection per call. - CacheProjectionContext<K, V> prev = ctx.projectionPerCall(); + CacheProjectionContext prev = ctx.projectionPerCall(); if (prev != null || prj != null) ctx.projectionPerCall(prj); @@ -157,7 +157,7 @@ public class GridCacheGateway<K, V> { /** * @param prev Previous. */ - public void leave(CacheProjectionContext<K, V> prev) { + public void leave(CacheProjectionContext prev) { try { ctx.tm().resetContext(); ctx.mvcc().contextReset(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3811c9a1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionEx.java index d7db04e..17e6c37 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionEx.java @@ -40,7 +40,7 @@ public interface GridCacheProjectionEx<K, V> extends CacheProjection<K, V> { * @param subjId Client ID. * @return Internal projection. */ - GridCacheProjectionEx<K, V> forSubjectId(UUID subjId); + GridCacheProxyImpl<K, V> forSubjectId(UUID subjId); /** * Store DR data. * @@ -234,7 +234,7 @@ public interface GridCacheProjectionEx<K, V> extends CacheProjection<K, V> { * @param plc {@link ExpiryPolicy} to associate with this projection. * @return New projection based on this one, but with the specified expiry policy. */ - public GridCacheProjectionEx<K, V> withExpiryPolicy(ExpiryPolicy plc); + public GridCacheProxyImpl<K, V> withExpiryPolicy(ExpiryPolicy plc); /** * @param key Key.