#ignite-758: IgniteCacheProxy constructor has parameters GridCacheAdapter and CacheProjectionContext.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ddc9178a Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ddc9178a Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ddc9178a Branch: refs/heads/ignite-758 Commit: ddc9178ab8c56efd3cbc1287afba6b6be74733d3 Parents: 6bbdea0 Author: ivasilinets <ivasilin...@gridgain.com> Authored: Thu Apr 16 10:50:50 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Thu Apr 16 10:50:50 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/CacheLockImpl.java | 12 +- .../cache/CacheProjectionContext.java | 766 +++++++++++++++++++ .../processors/cache/GridCacheAdapter.java | 30 +- .../cache/GridCacheConcurrentMap.java | 10 +- .../processors/cache/GridCacheContext.java | 20 +- .../processors/cache/GridCacheGateway.java | 6 +- .../cache/GridCacheProjectionImpl.java | 766 ------------------- .../processors/cache/GridCacheProxyImpl.java | 236 +++--- .../processors/cache/IgniteCacheProxy.java | 156 ++-- .../cache/affinity/GridCacheAffinityProxy.java | 30 +- .../distributed/dht/GridDhtCacheAdapter.java | 2 +- .../dht/atomic/GridDhtAtomicCache.java | 6 +- .../dht/colocated/GridDhtColocatedCache.java | 3 +- .../distributed/near/GridNearAtomicCache.java | 2 +- .../near/GridNearTransactionalCache.java | 2 +- .../local/atomic/GridLocalAtomicCache.java | 4 +- .../cache/query/CacheQueriesImpl.java | 4 +- .../cache/query/CacheQueriesProxy.java | 24 +- .../transactions/IgniteTxLocalAdapter.java | 8 +- 19 files changed, 1043 insertions(+), 1044 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ddc9178a/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 a35f8a1..e16490a 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 GridCacheProjectionImpl<K, V> prj; + private final CacheProjectionContext<K, V> 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, GridCacheProjectionImpl<K, V> prj, + CacheLockImpl(GridCacheGateway<K, V> gate, GridCacheProjectionEx<K, V> delegate, CacheProjectionContext<K, V> 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() { - GridCacheProjectionImpl<K, V> prev = gate.enter(prj); + CacheProjectionContext<K, V> prev = gate.enter(prj); try { delegate.lockAll(keys, 0); @@ -98,7 +98,7 @@ class CacheLockImpl<K, V> implements Lock { /** {@inheritDoc} */ @Override public boolean tryLock() { - GridCacheProjectionImpl<K, V> prev = gate.enter(prj); + CacheProjectionContext<K, V> 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(); - GridCacheProjectionImpl<K, V> prev = gate.enter(prj); + CacheProjectionContext<K, V> 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() { - GridCacheProjectionImpl<K, V> prev = gate.enter(prj); + CacheProjectionContext<K, V> prev = gate.enter(prj); try { if (lockedThread != Thread.currentThread()) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ddc9178a/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 new file mode 100644 index 0000000..3de6338 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjectionContext.java @@ -0,0 +1,766 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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 { + /** */ + 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; + + /** Client ID which operates over this projection, if any, */ + private UUID subjId; + + /** */ + private boolean keepPortable; + + /** */ + private ExpiryPolicy expiryPlc; + + /** + * Empty constructor required for {@link Externalizable}. + */ + public CacheProjectionContext() { + // No-op. + } + + /** + * @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() { + return keepPortable; + } + + /** + * @return {@code True} if portables should be deserialized. + */ + public boolean deserializePortables() { + return !keepPortable; + } + + /** {@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, + skipStore, + subjId, + keepPortable, + expiryPlc); + + return new GridCacheProxyImpl<>(cctx, cache, prj); + } + + /** + * Gets client ID for which this projection was created. + * + * @return Client ID. + */ + @Nullable public UUID subjectId() { + return subjId; + } + + /** {@inheritDoc} */ + @Override public CacheProjection<K, V> setSkipStore(boolean skipStore) { + if (this.skipStore == skipStore) + return new GridCacheProxyImpl<>(cctx, cache, this); + + CacheProjectionContext<K, V> prj = new CacheProjectionContext<>(this, + cctx, + 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() { + 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(); + } + + /** {@inheritDoc} */ + @Nullable @Override 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, + skipStore, + subjId, + true, + plc); + } + + /** {@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/ddc9178a/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 da5fa3c..4a5658a 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 @@ -373,14 +373,14 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, /** {@inheritDoc} */ @Override public GridCacheProjectionEx<K, V> forSubjectId(UUID subjId) { - GridCacheProjectionImpl<K, V> prj = new GridCacheProjectionImpl<>(this, + CacheProjectionContext<K, V> prj = new CacheProjectionContext<>(this, ctx, false, subjId, false, null); - return new GridCacheProxyImpl<>(ctx, prj, prj); + return new GridCacheProxyImpl<>(ctx, this, prj); } /** {@inheritDoc} */ @@ -393,21 +393,21 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, if (!skipStore) return this; - GridCacheProjectionImpl<K, V> prj = new GridCacheProjectionImpl<>(this, + CacheProjectionContext<K, V> prj = new CacheProjectionContext<>(this, ctx, false, null, false, null); - return new GridCacheProxyImpl<>(ctx, prj, prj); + return new GridCacheProxyImpl<>(ctx, this, prj); } /** {@inheritDoc} */ @Override public <K1, V1> CacheProjection<K1, V1> keepPortable() { - GridCacheProjectionImpl<K1, V1> prj = keepPortable0(); + CacheProjectionContext<K1, V1> prj = keepPortable0(); - return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx, prj, prj); + return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx, (GridCacheAdapter<K1, V1>)this, prj); } /** @@ -415,8 +415,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, * * @return Projection with "keep-portable" flag. */ - public <K1, V1> GridCacheProjectionImpl<K1, V1> keepPortable0() { - return new GridCacheProjectionImpl<>( + public <K1, V1> CacheProjectionContext<K1, V1> keepPortable0() { + return new CacheProjectionContext<>( (CacheProjection<K1, V1>)this, (GridCacheContext<K1, V1>)ctx, false, @@ -433,7 +433,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, /** {@inheritDoc} */ @Override public GridCacheProjectionEx<K, V> withExpiryPolicy(ExpiryPolicy plc) { - return new GridCacheProjectionImpl<>( + return new CacheProjectionContext<>( this, ctx, false, @@ -1625,7 +1625,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, boolean deserializePortable, boolean skipVals ) { - GridCacheProjectionImpl<K, V> prj = ctx.projectionPerCall(); + CacheProjectionContext<K, V> prj = ctx.projectionPerCall(); subjId = ctx.subjectIdPerCall(subjId, prj); @@ -3315,7 +3315,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, final boolean replicate = ctx.isDrEnabled(); final AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); - GridCacheProjectionImpl<K, V> prj = ctx.projectionPerCall(); + CacheProjectionContext<K, V> prj = ctx.projectionPerCall(); ExpiryPolicy plc0 = prj != null ? prj.expiry() : null; @@ -3438,7 +3438,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, if (!ctx.store().configured()) return new GridFinishedFuture<>(); - GridCacheProjectionImpl<K, V> prj = ctx.projectionPerCall(); + CacheProjectionContext<K, V> prj = ctx.projectionPerCall(); ExpiryPolicy plc = prj != null ? prj.expiry() : null; @@ -3578,7 +3578,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, ctx.kernalContext().task().setThreadContext(TC_NO_FAILOVER, true); - GridCacheProjectionImpl<K, V> prj = ctx.projectionPerCall(); + CacheProjectionContext<K, V> prj = ctx.projectionPerCall(); ExpiryPolicy plc = prj != null ? prj.expiry() : null; @@ -3740,7 +3740,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, if (!ctx0.isSwapOrOffheapEnabled() && ctx0.kernalContext().discovery().size() == 1) return localIteratorHonorExpirePolicy(); - final GridCacheProjectionImpl<K, V> prj = ctx.projectionPerCall(); + final CacheProjectionContext<K, V> prj = ctx.projectionPerCall(); CacheQueryFuture<Map.Entry<K, V>> fut = queries().createScanQuery(null) .keepAll(false) @@ -3752,7 +3752,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, } @Override protected void remove(Cache.Entry<K, V> item) { - GridCacheProjectionImpl<K, V> prev = ctx.gate().enter(prj); + CacheProjectionContext<K, V> prev = ctx.gate().enter(prj); try { GridCacheAdapter.this.remove(item.getKey()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ddc9178a/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 7d5260c..8336351 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 @@ -1791,7 +1791,7 @@ public class GridCacheConcurrentMap { private GridCacheContext<K, V> ctx; /** */ - private GridCacheProjectionImpl prjPerCall; + private CacheProjectionContext prjPerCall; /** * Empty constructor required for {@link Externalizable}. @@ -1963,7 +1963,7 @@ public class GridCacheConcurrentMap { private GridCacheContext<K, V> ctx; /** */ - private GridCacheProjectionImpl<K, V> prjPerCall; + private CacheProjectionContext<K, V> prjPerCall; /** * Empty constructor required for {@link Externalizable}. @@ -1982,7 +1982,7 @@ public class GridCacheConcurrentMap { GridCacheConcurrentMap map, CacheEntryPredicate[] filter, GridCacheContext<K, V> ctx, - GridCacheProjectionImpl<K, V> prjPerCall) { + CacheProjectionContext<K, V> 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() { - GridCacheProjectionImpl<K, V> oldPrj = ctx.projectionPerCall(); + CacheProjectionContext<K, V> 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 = (GridCacheProjectionImpl<K, V>)in.readObject(); + prjPerCall = (CacheProjectionContext<K, V>)in.readObject(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ddc9178a/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 952ece2..dc3fcb8 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<GridCacheProjectionImpl<K, V>> prjPerCall = new ThreadLocal<>(); + private ThreadLocal<CacheProjectionContext<K, V>> 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 GridCacheProjectionImpl<K, V> prj) { + public void projectionPerCall(@Nullable CacheProjectionContext<K, V> 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 GridCacheProjectionImpl<K, V> projectionPerCall() { + public CacheProjectionContext<K, V> 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 GridCacheProjectionImpl<K, V> prj) { + public UUID subjectIdPerCall(@Nullable UUID subjId, @Nullable CacheProjectionContext<K, V> 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(); - GridCacheProjectionImpl<K, V> prj = prjPerCall.get(); + CacheProjectionContext<K, V> 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 GridCacheProjectionImpl<K, V> prj = projectionPerCall(); + final CacheProjectionContext<K, V> prj = projectionPerCall(); if (prj == null) return r; return new GPR() { @Override public void run() { - GridCacheProjectionImpl<K, V> oldPrj = projectionPerCall(); + CacheProjectionContext<K, V> 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 GridCacheProjectionImpl<K, V> prj = projectionPerCall(); + final CacheProjectionContext<K, V> prj = projectionPerCall(); if (prj == null) return r; return new GPC<T>() { @Override public T call() throws Exception { - GridCacheProjectionImpl<K, V> oldPrj = projectionPerCall(); + CacheProjectionContext<K, V> oldPrj = projectionPerCall(); projectionPerCall(prj); @@ -1642,7 +1642,7 @@ public class GridCacheContext<K, V> implements Externalizable { * @return Keep portable flag. */ public boolean keepPortable() { - GridCacheProjectionImpl<K, V> prj = projectionPerCall(); + CacheProjectionContext<K, V> prj = projectionPerCall(); return prj != null && prj.isKeepPortable(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ddc9178a/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 4868b3f..0cc7caa 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 GridCacheProjectionImpl<K, V> enter(@Nullable GridCacheProjectionImpl<K, V> prj) { + @Nullable public CacheProjectionContext<K, V> enter(@Nullable CacheProjectionContext<K, V> 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. - GridCacheProjectionImpl<K, V> prev = ctx.projectionPerCall(); + CacheProjectionContext<K, V> 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(GridCacheProjectionImpl<K, V> prev) { + public void leave(CacheProjectionContext<K, V> prev) { try { ctx.tm().resetContext(); ctx.mvcc().contextReset(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ddc9178a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java deleted file mode 100644 index 52fc8e6..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java +++ /dev/null @@ -1,766 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -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. - */ -public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K, V>, Externalizable { - /** */ - 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; - - /** Client ID which operates over this projection, if any, */ - private UUID subjId; - - /** */ - private boolean keepPortable; - - /** */ - private ExpiryPolicy expiryPlc; - - /** - * Empty constructor required for {@link Externalizable}. - */ - public GridCacheProjectionImpl() { - // No-op. - } - - /** - * @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 GridCacheProjectionImpl( - 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() { - return keepPortable; - } - - /** - * @return {@code True} if portables should be deserialized. - */ - public boolean deserializePortables() { - return !keepPortable; - } - - /** {@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"); - - GridCacheProjectionImpl<K, V> prj = new GridCacheProjectionImpl<>(this, - cctx, - skipStore, - subjId, - keepPortable, - expiryPlc); - - return new GridCacheProxyImpl<>(cctx, prj, prj); - } - - /** - * Gets client ID for which this projection was created. - * - * @return Client ID. - */ - @Nullable public UUID subjectId() { - return subjId; - } - - /** {@inheritDoc} */ - @Override public CacheProjection<K, V> setSkipStore(boolean skipStore) { - if (this.skipStore == skipStore) - return new GridCacheProxyImpl<>(cctx, this, this); - - GridCacheProjectionImpl<K, V> prj = new GridCacheProjectionImpl<>(this, - cctx, - skipStore, - subjId, - keepPortable, - expiryPlc); - - return new GridCacheProxyImpl<>(cctx, prj, prj); - } - - /** {@inheritDoc} */ - @Override public <K1, V1> CacheProjection<K1, V1> keepPortable() { - GridCacheProjectionImpl<K1, V1> prj = new GridCacheProjectionImpl<>( - (CacheProjection<K1, V1>)this, - (GridCacheContext<K1, V1>)cctx, - skipStore, - subjId, - true, - expiryPlc); - - return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)cctx, prj, 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() { - 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(); - } - - /** {@inheritDoc} */ - @Nullable @Override 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 GridCacheProjectionImpl<>( - this, - cctx, - skipStore, - subjId, - true, - plc); - } - - /** {@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(GridCacheProjectionImpl.class, this); - } -}