ignite-96 wip
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a6a57ab0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a6a57ab0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a6a57ab0 Branch: refs/heads/ignite-96 Commit: a6a57ab01fcc8a05fbb21bfd12dd0260bda91b4c Parents: 4fcea52 Author: Yakov Zhdanov <[email protected]> Authored: Fri Feb 6 15:05:13 2015 +0300 Committer: Yakov Zhdanov <[email protected]> Committed: Fri Feb 6 15:05:14 2015 +0300 ---------------------------------------------------------------------- .../src/main/java/org/apache/ignite/Ignite.java | 6 +- .../org/apache/ignite/IgniteCountDownLatch.java | 2 - .../main/java/org/apache/ignite/IgniteSet.java | 1 - .../cache/eviction/CacheEvictionFilter.java | 2 + .../cache/eviction/CacheEvictionPolicy.java | 2 - .../ignite/cache/eviction/EvictableEntry.java | 54 ++- .../eviction/fifo/CacheFifoEvictionPolicy.java | 51 +-- .../fifo/CacheFifoEvictionPolicyMBean.java | 8 - .../eviction/ggfs/CacheGgfsEvictionFilter.java | 3 +- .../CacheGgfsPerBlockLruEvictionPolicy.java | 49 ++- .../eviction/lru/CacheLruEvictionPolicy.java | 32 +- .../lru/CacheLruEvictionPolicyMBean.java | 8 - .../random/CacheRandomEvictionPolicy.java | 44 +- .../IgniteAtomicConfiguration.java | 2 +- .../configuration/IgniteConfiguration.java | 9 +- .../discovery/GridDiscoveryManager.java | 1 - .../processors/cache/GridCacheAdapter.java | 12 +- .../cache/GridCacheConcurrentMap.java | 36 +- .../cache/GridCacheDeploymentManager.java | 2 +- .../processors/cache/GridCacheEntryEx.java | 15 +- .../processors/cache/GridCacheEntrySet.java | 13 +- .../cache/GridCacheEvictionEntry.java | 399 ++--------------- .../cache/GridCacheEvictionManager.java | 9 +- .../processors/cache/GridCacheIterator.java | 2 +- .../processors/cache/GridCacheKeySet.java | 2 +- .../processors/cache/GridCacheMapEntry.java | 14 +- .../processors/cache/GridCacheMessage.java | 2 +- .../cache/GridCacheProjectionImpl.java | 3 +- .../processors/cache/GridCacheUtils.java | 32 +- .../cache/GridCacheValueCollection.java | 2 +- .../GridDistributedCacheAdapter.java | 1 + .../GridDistributedTxRemoteAdapter.java | 2 +- .../distributed/dht/GridDhtCacheAdapter.java | 9 +- .../cache/distributed/dht/GridDhtGetFuture.java | 2 +- .../distributed/dht/GridDhtLockFuture.java | 2 +- .../dht/GridDhtTransactionalCacheAdapter.java | 2 +- .../distributed/dht/GridDhtTxLocalAdapter.java | 2 +- .../dht/GridPartitionedGetFuture.java | 2 +- .../dht/atomic/GridDhtAtomicCache.java | 8 +- .../dht/atomic/GridDhtAtomicCacheEntry.java | 5 - .../dht/atomic/GridNearAtomicUpdateFuture.java | 1 + .../dht/atomic/GridNearAtomicUpdateRequest.java | 1 + .../dht/colocated/GridDhtColocatedCache.java | 15 +- .../colocated/GridDhtColocatedCacheEntry.java | 2 - .../colocated/GridDhtColocatedLockFuture.java | 2 +- .../distributed/near/GridNearAtomicCache.java | 2 +- .../distributed/near/GridNearCacheAdapter.java | 4 +- .../distributed/near/GridNearGetFuture.java | 2 +- .../distributed/near/GridNearGetRequest.java | 2 +- .../distributed/near/GridNearLockFuture.java | 2 +- .../distributed/near/GridNearLockRequest.java | 2 +- .../near/GridNearTransactionalCache.java | 8 +- .../processors/cache/local/GridLocalCache.java | 2 +- .../cache/local/GridLocalLockFuture.java | 2 +- .../local/atomic/GridLocalAtomicCache.java | 1 - .../query/GridCacheDistributedQueryManager.java | 1 - .../cache/query/GridCacheLocalQueryFuture.java | 2 +- .../cache/query/GridCacheQueriesImpl.java | 2 +- .../cache/query/GridCacheQueryAdapter.java | 1 + .../cache/query/GridCacheQueryInfo.java | 2 +- .../cache/query/GridCacheQueryManager.java | 263 ------------ .../cache/query/GridCacheQueryRequest.java | 2 +- .../GridCacheContinuousQueryAdapter.java | 1 + .../GridCacheContinuousQueryEntry.java | 424 +------------------ .../GridCacheContinuousQueryHandler.java | 2 +- .../GridCacheContinuousQueryManager.java | 4 +- .../cache/transactions/IgniteTxEntry.java | 4 +- .../transactions/IgniteTxLocalAdapter.java | 2 +- .../cache/transactions/IgniteTxLocalEx.java | 2 +- .../processors/fs/GridGgfsDataManager.java | 19 +- .../service/GridServiceProcessor.java | 17 +- .../ignite/internal/util/IgniteUtils.java | 26 -- .../ignite/internal/util/lang/GridFunc.java | 132 ++---- .../ignite/internal/util/typedef/PCE.java | 4 +- .../ignite/internal/visor/cache/VisorCache.java | 12 +- .../visor/cache/VisorCacheSwapBackupsTask.java | 7 +- .../org/apache/ignite/lang/IgniteFuture.java | 1 - .../apache/ignite/lang/GridFuncSelfTest.java | 22 - 78 files changed, 345 insertions(+), 1507 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/Ignite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/Ignite.java b/modules/core/src/main/java/org/apache/ignite/Ignite.java index aa6607c..879bca5 100644 --- a/modules/core/src/main/java/org/apache/ignite/Ignite.java +++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java @@ -21,11 +21,11 @@ import org.apache.ignite.cache.*; import org.apache.ignite.cache.affinity.*; import org.apache.ignite.cluster.*; import org.apache.ignite.configuration.*; -import org.apache.ignite.fs.IgniteFsConfiguration; -import org.apache.ignite.plugin.*; +import org.apache.ignite.fs.*; import org.apache.ignite.internal.product.*; -import org.apache.ignite.plugin.security.*; import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.plugin.*; +import org.apache.ignite.plugin.security.*; import org.jetbrains.annotations.*; import java.util.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/IgniteCountDownLatch.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCountDownLatch.java b/modules/core/src/main/java/org/apache/ignite/IgniteCountDownLatch.java index ba35448..1761766 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCountDownLatch.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCountDownLatch.java @@ -17,8 +17,6 @@ package org.apache.ignite; -import org.apache.ignite.*; - import java.io.*; import java.util.concurrent.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/IgniteSet.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSet.java b/modules/core/src/main/java/org/apache/ignite/IgniteSet.java index 1228958..e779679 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSet.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSet.java @@ -18,7 +18,6 @@ package org.apache.ignite; import org.apache.ignite.configuration.*; -import org.jetbrains.annotations.*; import java.io.*; import java.util.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/cache/eviction/CacheEvictionFilter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/CacheEvictionFilter.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/CacheEvictionFilter.java index 592e79c..2a73018 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/CacheEvictionFilter.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/CacheEvictionFilter.java @@ -19,6 +19,8 @@ package org.apache.ignite.cache.eviction; import org.apache.ignite.cache.*; +import javax.cache.Cache.*; + /** * Eviction filter to specify which entries should not be evicted. Not applicable when * calling explicit evict via {@link org.apache.ignite.cache.Entry#evict()}. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/cache/eviction/CacheEvictionPolicy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/CacheEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/CacheEvictionPolicy.java index c2978a0..fdf8f3a 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/CacheEvictionPolicy.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/CacheEvictionPolicy.java @@ -17,8 +17,6 @@ package org.apache.ignite.cache.eviction; -import org.apache.ignite.cache.*; - /** * Pluggable cache eviction policy. Usually, implementations will internally order * cache entries based on {@link #onEntryAccessed(boolean, org.apache.ignite.cache.Entry)} notifications and http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictableEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictableEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictableEntry.java index 2379179..c306125 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictableEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/EvictableEntry.java @@ -28,20 +28,56 @@ import javax.cache.*; * @version @java.version */ public interface EvictableEntry<K, V> extends Cache.Entry<K, V> { + public boolean evict(); + + public boolean isCached(); + + /** + * Gets metadata by name. + * + * @return Metadata value or {@code null}. + */ + @Nullable public <T> T meta(); + + /** + * Adds a new metadata. + * + * @param val Metadata value. + * @return Metadata previously associated with given name, or + * {@code null} if there was none. + */ + @Nullable public <T> T addMeta(T val); + + /** + * Adds given metadata value only if it was absent. + * + * @param val Value to add if it's not attached already. + * @return {@code null} if new value was put, or current value if put didn't happen. + */ + @Nullable public <T> T putMetaIfAbsent(T val); + + /** + * Replaces given metadata with new {@code newVal} value only if its current value + * is equal to {@code curVal}. Otherwise, it is no-op. + * + * @param curVal Current value to check. + * @param newVal New value. + * @return {@code true} if replacement occurred, {@code false} otherwise. + */ + public <T> boolean replaceMeta(T curVal, T newVal); + /** - * Attaches metadata to the entry. + * Removes metadata by name. * - * @param meta Metadata to attach. Pass {@code null} to remove previous value. - * @return Previous metadata value. + * @return Value of removed metadata or {@code null}. */ - public <T> T attachMeta(@Nullable Object meta); + @Nullable public <T> T removeMeta(); /** - * Replaces entry metadata. + * Removes metadata only if its current value is equal to {@code val} passed in. * - * @param oldMeta Old metadata value, possibly {@code null}. - * @param newMeta New metadata value, possibly {@code null}. - * @return {@code True} if metadata value was replaced. + * @param val Value to compare. + * @return {@code True} if value was removed, {@code false} otherwise. */ - public boolean replaceMeta(@Nullable Object oldMeta, @Nullable Object newMeta); + public <T> boolean removeMeta(T val); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicy.java index ff84fa4..76fc9ca 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicy.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicy.java @@ -17,16 +17,12 @@ package org.apache.ignite.cache.eviction.fifo; -import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.cache.eviction.*; -import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.jdk8.backport.*; import org.jdk8.backport.ConcurrentLinkedDeque8.*; -import javax.cache.Cache.*; import java.util.*; /** @@ -37,14 +33,11 @@ import java.util.*; */ public class CacheFifoEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, CacheFifoEvictionPolicyMBean { - /** Tag. */ - private final String meta = UUID.randomUUID().toString(); - /** Maximum size. */ private volatile int max = CacheConfiguration.DFLT_CACHE_SIZE; /** FIFO queue. */ - private final ConcurrentLinkedDeque8<Entry<K, V>> queue = + private final ConcurrentLinkedDeque8<EvictableEntry<K, V>> queue = new ConcurrentLinkedDeque8<>(); /** @@ -90,22 +83,17 @@ public class CacheFifoEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, return queue.size(); } - /** {@inheritDoc} */ - @Override public String getMetaAttributeName() { - return meta; - } - /** * Gets read-only view on internal {@code FIFO} queue in proper order. * * @return Read-only view ono internal {@code 'FIFO'} queue. */ - public Collection<Entry<K, V>> queue() { + public Collection<EvictableEntry<K, V>> queue() { return Collections.unmodifiableCollection(queue); } /** {@inheritDoc} */ - @Override public void onEntryAccessed(boolean rmv, Entry<K, V> entry) { + @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> entry) { if (!rmv) { if (!entry.isCached()) return; @@ -115,7 +103,7 @@ public class CacheFifoEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, shrink(); } else { - Node<Entry<K, V>> node = entry.removeMeta(meta); + Node<EvictableEntry<K, V>> node = entry.removeMeta(); if (node != null) queue.unlinkx(node); @@ -126,15 +114,15 @@ public class CacheFifoEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, * @param entry Entry to touch. * @return {@code True} if queue has been changed by this call. */ - private boolean touch(Entry<K, V> entry) { - Node<Entry<K, V>> node = entry.meta(meta); + private boolean touch(EvictableEntry<K, V> entry) { + Node<EvictableEntry<K, V>> node = entry.meta(); // Entry has not been enqueued yet. if (node == null) { while (true) { node = queue.offerLastx(entry); - if (entry.putMetaIfAbsent(meta, node) != null) { + if (entry.putMetaIfAbsent(node) != null) { // Was concurrently added, need to clear it from queue. queue.unlinkx(node); @@ -152,7 +140,7 @@ public class CacheFifoEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, return true; } // If node was unlinked by concurrent shrink() call, we must repeat the whole cycle. - else if (!entry.removeMeta(meta, node)) + else if (!entry.removeMeta(node)) return false; } } @@ -170,38 +158,19 @@ public class CacheFifoEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, int startSize = queue.sizex(); for (int i = 0; i < startSize && queue.sizex() > max; i++) { - Entry<K, V> entry = queue.poll(); + EvictableEntry<K, V> entry = queue.poll(); if (entry == null) break; if (!entry.evict()) { - entry.removeMeta(meta); + entry.removeMeta(); touch(entry); } } } - /** - * Checks entry for empty value. - * - * @param entry Entry to check. - * @return {@code True} if entry is empty. - */ - private boolean empty(Entry<K, V> entry) { - try { - return entry.peek(F.asList(GridCachePeekMode.GLOBAL)) == null; - } - catch (IgniteCheckedException e) { - U.error(null, e.getMessage(), e); - - assert false : "Should never happen: " + e; - - return false; - } - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(CacheFifoEvictionPolicy.class, this); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicyMBean.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicyMBean.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicyMBean.java index 1dd5f18..b3a8b6c 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicyMBean.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/CacheFifoEvictionPolicyMBean.java @@ -25,14 +25,6 @@ import org.apache.ignite.mxbean.*; @IgniteMXBeanDescription("MBean for FIFO cache eviction policy.") public interface CacheFifoEvictionPolicyMBean { /** - * Gets name of metadata attribute used to store eviction policy data. - * - * @return Name of metadata attribute used to store eviction policy data. - */ - @IgniteMXBeanDescription("Name of metadata attribute used to store eviction policy data.") - public String getMetaAttributeName(); - - /** * Gets maximum allowed cache size. * * @return Maximum allowed cache size. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/cache/eviction/ggfs/CacheGgfsEvictionFilter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/ggfs/CacheGgfsEvictionFilter.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/ggfs/CacheGgfsEvictionFilter.java index d931f74..53613eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/ggfs/CacheGgfsEvictionFilter.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/ggfs/CacheGgfsEvictionFilter.java @@ -17,10 +17,11 @@ package org.apache.ignite.cache.eviction.ggfs; -import org.apache.ignite.cache.*; import org.apache.ignite.cache.eviction.*; import org.apache.ignite.internal.processors.fs.*; +import javax.cache.Cache.*; + /** * GGFS eviction filter which will not evict blocks of particular files. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/cache/eviction/ggfs/CacheGgfsPerBlockLruEvictionPolicy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/ggfs/CacheGgfsPerBlockLruEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/ggfs/CacheGgfsPerBlockLruEvictionPolicy.java index 736ac34..f66a44f 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/ggfs/CacheGgfsPerBlockLruEvictionPolicy.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/ggfs/CacheGgfsPerBlockLruEvictionPolicy.java @@ -18,9 +18,9 @@ package org.apache.ignite.cache.eviction.ggfs; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.cache.eviction.*; import org.apache.ignite.fs.*; +import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.fs.*; import org.jdk8.backport.*; import org.jdk8.backport.ConcurrentLinkedDeque8.*; @@ -35,9 +35,6 @@ import java.util.regex.*; */ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<GridGgfsBlockKey, byte[]>, CacheGgfsPerBlockLruEvictionPolicyMBean { - /** Meta denoting node in the queue. */ - public static final String META_NODE = "ggfs_node"; - /** Maximum size. When reached, eviction begins. */ private volatile long maxSize; @@ -54,7 +51,7 @@ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<G private final AtomicBoolean excludeRecompile = new AtomicBoolean(true); /** Queue. */ - private final ConcurrentLinkedDeque8<Entry<GridGgfsBlockKey, byte[]>> queue = + private final ConcurrentLinkedDeque8<EvictableEntry<GridGgfsBlockKey, byte[]>> queue = new ConcurrentLinkedDeque8<>(); /** Current size of all enqueued blocks in bytes. */ @@ -92,7 +89,7 @@ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<G } /** {@inheritDoc} */ - @Override public void onEntryAccessed(boolean rmv, Entry<GridGgfsBlockKey, byte[]> entry) { + @Override public void onEntryAccessed(boolean rmv, EvictableEntry<GridGgfsBlockKey, byte[]> entry) { if (!rmv) { if (!entry.isCached()) return; @@ -101,7 +98,7 @@ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<G shrink(); } else { - MetaEntry meta = entry.removeMeta(META_NODE); + MetaEntry meta = entry.removeMeta(); if (meta != null && queue.unlinkx(meta.node())) changeSize(-meta.size()); @@ -112,21 +109,21 @@ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<G * @param entry Entry to touch. * @return {@code True} if new node has been added to queue by this call. */ - private boolean touch(Entry<GridGgfsBlockKey, byte[]> entry) { - byte[] val = entry.peek(); + private boolean touch(EvictableEntry<GridGgfsBlockKey, byte[]> entry) { + byte[] val = peek(entry); int blockSize = val != null ? val.length : 0; - MetaEntry meta = entry.meta(META_NODE); + MetaEntry meta = entry.meta(); // Entry has not been enqueued yet. if (meta == null) { while (true) { - Node<Entry<GridGgfsBlockKey, byte[]>> node = queue.offerLastx(entry); + Node<EvictableEntry<GridGgfsBlockKey, byte[]>> node = queue.offerLastx(entry); meta = new MetaEntry(node, blockSize); - if (entry.putMetaIfAbsent(META_NODE, meta) != null) { + if (entry.putMetaIfAbsent(meta) != null) { // Was concurrently added, need to clear it from queue. queue.unlinkx(node); @@ -147,22 +144,22 @@ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<G return true; } // If node was unlinked by concurrent shrink() call, we must repeat the whole cycle. - else if (!entry.removeMeta(META_NODE, node)) + else if (!entry.removeMeta(node)) return false; } } else { int oldBlockSize = meta.size(); - Node<Entry<GridGgfsBlockKey, byte[]>> node = meta.node(); + Node<EvictableEntry<GridGgfsBlockKey, byte[]>> node = meta.node(); if (queue.unlinkx(node)) { // Move node to tail. - Node<Entry<GridGgfsBlockKey, byte[]>> newNode = queue.offerLastx(entry); + Node<EvictableEntry<GridGgfsBlockKey, byte[]>> newNode = queue.offerLastx(entry); int delta = blockSize - oldBlockSize; - if (!entry.replaceMeta(META_NODE, meta, new MetaEntry(newNode, blockSize))) { + if (!entry.replaceMeta(meta, new MetaEntry(newNode, blockSize))) { // Was concurrently added, need to clear it from queue. if (queue.unlinkx(newNode)) delta -= blockSize; @@ -183,6 +180,14 @@ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<G } /** + * @param entry Entry. + * @return Peeked value. + */ + @Nullable private byte[] peek(EvictableEntry<GridGgfsBlockKey, byte[]> entry) { + return (byte[])((GridCacheEvictionEntry)entry).peek(); + } + + /** * Shrinks queue to maximum allowed size. */ private void shrink() { @@ -193,19 +198,19 @@ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<G for (int i = 0; i < cnt && (maxBlocks > 0 && queue.sizex() > maxBlocks || maxSize > 0 && curSize.longValue() > maxSize); i++) { - Entry<GridGgfsBlockKey, byte[]> entry = queue.poll(); + EvictableEntry<GridGgfsBlockKey, byte[]> entry = queue.poll(); if (entry == null) break; // Queue is empty. - byte[] val = entry.peek(); + byte[] val = peek(entry); if (val != null) changeSize(-val.length); // Change current size as we polled entry from the queue. if (!entry.evict()) { // Reorder entries which we failed to evict. - entry.removeMeta(META_NODE); + entry.removeMeta(); touch(entry); } @@ -317,7 +322,7 @@ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<G */ private static class MetaEntry { /** Queue node. */ - private final Node<Entry<GridGgfsBlockKey, byte[]>> node; + private final Node<EvictableEntry<GridGgfsBlockKey, byte[]>> node; /** Data size. */ private final int size; @@ -328,7 +333,7 @@ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<G * @param node Queue node. * @param size Data size. */ - private MetaEntry(Node<Entry<GridGgfsBlockKey, byte[]>> node, int size) { + private MetaEntry(Node<EvictableEntry<GridGgfsBlockKey, byte[]>> node, int size) { assert node != null; assert size >= 0; @@ -339,7 +344,7 @@ public class CacheGgfsPerBlockLruEvictionPolicy implements CacheEvictionPolicy<G /** * @return Queue node. */ - private Node<Entry<GridGgfsBlockKey, byte[]>> node() { + private Node<EvictableEntry<GridGgfsBlockKey, byte[]>> node() { return node; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicy.java index 87a0d41..9166880 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicy.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicy.java @@ -33,14 +33,11 @@ import java.util.*; */ public class CacheLruEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, CacheLruEvictionPolicyMBean { - /** Tag. */ - private final String meta = UUID.randomUUID().toString(); - /** Maximum size. */ private volatile int max = CacheConfiguration.DFLT_CACHE_SIZE; /** Queue. */ - private final ConcurrentLinkedDeque8<Entry<K, V>> queue = + private final ConcurrentLinkedDeque8<EvictableEntry<K, V>> queue = new ConcurrentLinkedDeque8<>(); /** @@ -86,22 +83,17 @@ public class CacheLruEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, return queue.size(); } - /** {@inheritDoc} */ - @Override public String getMetaAttributeName() { - return meta; - } - /** * Gets read-only view on internal {@code FIFO} queue in proper order. * * @return Read-only view ono internal {@code 'FIFO'} queue. */ - public Collection<Entry<K, V>> queue() { + public Collection<EvictableEntry<K, V>> queue() { return Collections.unmodifiableCollection(queue); } /** {@inheritDoc} */ - @Override public void onEntryAccessed(boolean rmv, Entry<K, V> entry) { + @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> entry) { if (!rmv) { if (!entry.isCached()) return; @@ -110,7 +102,7 @@ public class CacheLruEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, shrink(); } else { - Node<Entry<K, V>> node = entry.removeMeta(meta); + Node<EvictableEntry<K, V>> node = entry.removeMeta(); if (node != null) queue.unlinkx(node); @@ -121,15 +113,15 @@ public class CacheLruEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, * @param entry Entry to touch. * @return {@code True} if new node has been added to queue by this call. */ - private boolean touch(Entry<K, V> entry) { - Node<Entry<K, V>> node = entry.meta(meta); + private boolean touch(EvictableEntry<K, V> entry) { + Node<EvictableEntry<K, V>> node = entry.meta(); // Entry has not been enqueued yet. if (node == null) { while (true) { node = queue.offerLastx(entry); - if (entry.putMetaIfAbsent(meta, node) != null) { + if (entry.putMetaIfAbsent(node) != null) { // Was concurrently added, need to clear it from queue. queue.unlinkx(node); @@ -147,15 +139,15 @@ public class CacheLruEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, return true; } // If node was unlinked by concurrent shrink() call, we must repeat the whole cycle. - else if (!entry.removeMeta(meta, node)) + else if (!entry.removeMeta(node)) return false; } } else if (queue.unlinkx(node)) { // Move node to tail. - Node<Entry<K, V>> newNode = queue.offerLastx(entry); + Node<EvictableEntry<K, V>> newNode = queue.offerLastx(entry); - if (!entry.replaceMeta(meta, node, newNode)) + if (!entry.replaceMeta(node, newNode)) // Was concurrently added, need to clear it from queue. queue.unlinkx(newNode); } @@ -173,13 +165,13 @@ public class CacheLruEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V>, int startSize = queue.sizex(); for (int i = 0; i < startSize && queue.sizex() > max; i++) { - Entry<K, V> entry = queue.poll(); + EvictableEntry<K, V> entry = queue.poll(); if (entry == null) break; if (!entry.evict()) { - entry.removeMeta(meta); + entry.removeMeta(); touch(entry); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicyMBean.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicyMBean.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicyMBean.java index 199a8c7..4200b7c 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicyMBean.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/CacheLruEvictionPolicyMBean.java @@ -25,14 +25,6 @@ import org.apache.ignite.mxbean.*; @IgniteMXBeanDescription("MBean for LRU cache eviction policy.") public interface CacheLruEvictionPolicyMBean { /** - * Gets name of metadata attribute used to store eviction policy data. - * - * @return Name of metadata attribute used to store eviction policy data. - */ - @IgniteMXBeanDescription("Name of metadata attribute used to store eviction policy data.") - public String getMetaAttributeName(); - - /** * Gets maximum allowed cache size. * * @return Maximum allowed cache size. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicy.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicy.java index 67f2c84..2edd395 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicy.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/CacheRandomEvictionPolicy.java @@ -24,6 +24,8 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import javax.cache.Cache.*; + /** * Cache eviction policy which will select random cache entry for eviction if cache * size exceeds the {@link #getMaxSize()} parameter. This implementation is @@ -77,39 +79,21 @@ public class CacheRandomEvictionPolicy<K, V> implements CacheEvictionPolicy<K, V } /** {@inheritDoc} */ - @Override public void onEntryAccessed(boolean rmv, Entry<K, V> entry) { + @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> entry) { if (!entry.isCached()) return; - GridCache<K, V> cache = entry.projection().cache(); - - int size = cache.size(); - - for (int i = max; i < size; i++) { - Entry<K, V> e = cache.randomEntry(); - - if (e != null) - e.evict(); - } - } - - /** - * Checks entry for empty value. - * - * @param entry Entry to check. - * @return {@code True} if entry is empty. - */ - private boolean empty(Entry<K, V> entry) { - try { - return entry.peek(F.asList(GridCachePeekMode.GLOBAL)) == null; - } - catch (IgniteCheckedException e) { - U.error(null, e.getMessage(), e); - - assert false : "Should never happen: " + e; - - return false; - } +// TODO ignite-96 +// GridCache<K, V> cache = entry.projection().cache(); +// +// int size = cache.size(); +// +// for (int i = max; i < size; i++) { +// Entry<K, V> e = cache.randomEntry(); +// +// if (e != null) +// e.evict(); +// } } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/configuration/IgniteAtomicConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteAtomicConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteAtomicConfiguration.java index 0cd911c..5ea4ec6 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteAtomicConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteAtomicConfiguration.java @@ -17,7 +17,7 @@ package org.apache.ignite.configuration; -import org.apache.ignite.IgniteAtomicSequence; +import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.internal.util.typedef.internal.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java index a38cba8..7ad9dc6 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java @@ -22,20 +22,14 @@ import org.apache.ignite.cache.*; import org.apache.ignite.client.ssl.*; import org.apache.ignite.events.*; import org.apache.ignite.fs.*; -import org.apache.ignite.internal.processors.hadoop.*; import org.apache.ignite.internal.managers.eventstorage.*; +import org.apache.ignite.internal.processors.hadoop.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.lifecycle.*; import org.apache.ignite.managed.*; import org.apache.ignite.marshaller.*; import org.apache.ignite.plugin.*; -import org.apache.ignite.portables.*; -import org.apache.ignite.spi.authentication.*; -import org.apache.ignite.spi.indexing.*; -import org.apache.ignite.streamer.*; -import org.apache.ignite.client.ssl.*; -import org.apache.ignite.internal.managers.eventstorage.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.plugin.segmentation.*; import org.apache.ignite.portables.*; @@ -51,7 +45,6 @@ import org.apache.ignite.spi.indexing.*; import org.apache.ignite.spi.loadbalancing.*; import org.apache.ignite.spi.securesession.*; import org.apache.ignite.spi.swapspace.*; -import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.streamer.*; import javax.management.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java index b612465e4..b5811c6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java @@ -27,7 +27,6 @@ import org.apache.ignite.internal.managers.eventstorage.*; import org.apache.ignite.internal.managers.security.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.jobmetrics.*; -import org.apache.ignite.internal.processors.service.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.future.*; import org.apache.ignite.internal.util.lang.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/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 bb99ea2..378bd41 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 @@ -63,10 +63,10 @@ import java.util.concurrent.locks.*; import static java.util.Collections.*; import static org.apache.ignite.IgniteSystemProperties.*; -import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*; import static org.apache.ignite.events.IgniteEventType.*; import static org.apache.ignite.internal.GridClosureCallMode.*; import static org.apache.ignite.internal.processors.cache.CacheFlag.*; +import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*; import static org.apache.ignite.internal.processors.dr.GridDrType.*; import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.*; import static org.apache.ignite.transactions.IgniteTxConcurrency.*; @@ -1278,16 +1278,6 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, } /** - * Same as {@link #entrySet()} but for internal use only to - * avoid casting. - * - * @return Set of entry wrappers. - */ - public Set<GridCacheEntryImpl<K, V>> wrappers() { - return map.wrappers(CU.<K, V>empty()); - } - - /** * @return Set of internal cached entry representations, excluding {@link GridCacheInternal} keys. */ public Set<GridCacheEntryEx<K, V>> entries() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/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 6065615..5618f9b 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 @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.*; @@ -27,6 +26,7 @@ import org.apache.ignite.lang.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.io.*; import java.lang.ref.*; import java.lang.reflect.*; @@ -556,34 +556,6 @@ public class GridCacheConcurrentMap<K, V> { } /** - * Entry wrapper set. - * - * @param filter Filter. - * @return Entry wrapper set. - */ - @SuppressWarnings({"unchecked", "RedundantCast"}) - public Set<GridCacheEntryImpl<K, V>> wrappers(IgnitePredicate<Entry<K, V>>[] filter) { - checkWeakQueue(); - - return (Set<GridCacheEntryImpl<K, V>>)(Set<? extends Entry<K, V>>)entries(filter); - } - - /** - * Entry wrapper set casted to projections. - * - * @param filter Filter to check. - * @return Entry projections set. - */ - @SuppressWarnings({"unchecked", "RedundantCast"}) - public Set<Entry<K, V>> projections(IgnitePredicate<Entry<K, V>>[] filter) { - checkWeakQueue(); - - return (Set<Entry<K, V>>)(Set<? extends Entry<K, V>>)wrappers(filter); - } - - /** - * Same as {@link #wrappers(org.apache.ignite.lang.IgnitePredicate[])} - * * @param filter Filter. * @return Set of the mappings contained in this map. */ @@ -1688,7 +1660,7 @@ public class GridCacheConcurrentMap<K, V> { continue; if (isVal) { - nextVal = next.wrap(true).peek(); + nextVal = next.wrap(true).getValue(); if (nextVal == null) continue; @@ -2384,8 +2356,8 @@ public class GridCacheConcurrentMap<K, V> { /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) @Override public boolean contains(Object o) { - if (o instanceof GridCacheEntryImpl) { - GridCacheEntryEx<K, V> unwrapped = ((GridCacheEntryImpl<K, V>)o).unwrapNoCreate(); + if (o instanceof CacheEntryImpl) { + GridCacheEntryEx<K, V> unwrapped = set.map.getEntry(((CacheEntryImpl)o).getKey()); return unwrapped != null && set.contains(unwrapped); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java index 71242b2..d547ece 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.cluster.*; import org.apache.ignite.configuration.*; import org.apache.ignite.events.*; @@ -34,6 +33,7 @@ import org.apache.ignite.lang.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java index 899ec4c..4835902 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; +import org.apache.ignite.cache.eviction.*; import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; @@ -133,6 +134,16 @@ public interface GridCacheEntryEx<K, V> { public V rawPut(V val, long ttl); /** + * Wraps this map entry into cache entry. + * + * @param prjAware {@code true} if entry should inherit projection properties. + * @return Wrapped entry. + * + */ + @Deprecated + public Entry<K, V> wrap(boolean prjAware); + + /** * Wraps this map entry into cache entry for filter evaluation inside entry lock. * * @return Wrapped entry. @@ -143,7 +154,7 @@ public interface GridCacheEntryEx<K, V> { /** * @return Entry which is safe to pass into eviction policy. */ - public Entry<K, V> evictWrap(); + public EvictableEntry<K, V> evictWrap(); /** * @return Not-null version if entry is obsolete. @@ -585,7 +596,7 @@ public interface GridCacheEntryEx<K, V> { * @param heap Read from heap flag. * @param offheap Read from offheap flag. * @param swap Read from swap flag. - * @param topVer Topology version.. + * @param topVer Topology version. * @return Value. * @throws GridCacheEntryRemovedException If entry has been removed. * @throws IgniteCheckedException If failed. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntrySet.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntrySet.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntrySet.java index 7d41cb7..e4ed1e3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntrySet.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntrySet.java @@ -18,12 +18,11 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.util.*; /** @@ -66,22 +65,20 @@ public class GridCacheEntrySet<K, V> extends AbstractSet<Entry<K, V>> { /** {@inheritDoc} */ @Override public void clear() { - ctx.cache().clearLocally0(F.viewReadOnly(set, F.<K>mapEntry2Key(), filter), CU.<K, V>empty()); - - set.clear(); + throw new UnsupportedOperationException("clear"); } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) @Override public boolean remove(Object o) { - if (!(o instanceof GridCacheEntryImpl)) + if (!(o instanceof CacheEntryImpl)) return false; Entry<K, V> e = (Entry<K,V>)o; if (F.isAll(e, filter) && set.remove(e)) { try { - e.removex(); + ctx.cache().remove(e.getKey(), e.getValue()); } catch (IgniteCheckedException ex) { throw new IgniteException(ex); @@ -101,7 +98,7 @@ public class GridCacheEntrySet<K, V> extends AbstractSet<Entry<K, V>> { /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) @Override public boolean contains(Object o) { - if (!(o instanceof GridCacheEntryImpl)) + if (!(o instanceof CacheEntryImpl)) return false; Entry<K,V> e = (Entry<K, V>)o; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionEntry.java index 6558cf6..ab60f36 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionEntry.java @@ -18,37 +18,19 @@ 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.transactions.*; -import org.apache.ignite.internal.util.lang.*; +import org.apache.ignite.cache.eviction.*; import org.apache.ignite.internal.util.tostring.*; -import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.lang.*; import org.jetbrains.annotations.*; import java.io.*; -import java.util.*; -import java.util.Map.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*; /** * Entry wrapper that never obscures obsolete entries from user. */ -public class GridCacheEvictionEntry<K, V> implements Entry<K, V>, Externalizable { +public class GridCacheEvictionEntry<K, V> implements EvictableEntry<K, V> { /** */ - private static final long serialVersionUID = 0L; - - /** Static logger to avoid re-creation. */ - private static final AtomicReference<IgniteLogger> logRef = new AtomicReference<>(); - - /** Logger. */ - protected static volatile IgniteLogger log; + private static final String META_KEY = "ignite-eviction-entry-meta"; /** Cached entry. */ @GridToStringInclude @@ -67,13 +49,6 @@ public class GridCacheEvictionEntry<K, V> implements Entry<K, V>, Externalizable @SuppressWarnings({"TypeMayBeWeakened"}) protected GridCacheEvictionEntry(GridCacheEntryEx<K, V> cached) { this.cached = cached; - - log = U.logger(cached.context().kernalContext(), logRef, this); - } - - /** {@inheritDoc} */ - @Override public CacheProjection<K, V> projection() { - return cached.context().cache(); } /** {@inheritDoc} */ @@ -81,144 +56,10 @@ public class GridCacheEvictionEntry<K, V> implements Entry<K, V>, Externalizable return cached.key(); } - /** {@inheritDoc} */ - @Nullable - @Override public V getValue() throws IllegalStateException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Nullable @Override public V setValue(V val) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public Object version() { - try { - return cached.version().drVersion(); - } - catch (GridCacheEntryRemovedException ignore) { - return cached.obsoleteVersion().drVersion(); - } - } - - /** {@inheritDoc} */ - @Override public long expirationTime() { - return cached.rawExpireTime(); - } - - /** {@inheritDoc} */ - @Override public boolean primary() { - GridCacheContext<K, V> ctx = cached.context(); - - return ctx.config().getCacheMode() == LOCAL || - ctx.nodeId().equals(ctx.affinity().primary(cached.key(), ctx.affinity().affinityTopologyVersion()).id()); - } - - /** {@inheritDoc} */ - @Override public boolean backup() { - GridCacheContext<K, V> ctx = cached.context(); - - return ctx.config().getCacheMode() != LOCAL && - ctx.affinity().backups(cached.key(), ctx.affinity().affinityTopologyVersion()).contains(ctx.localNode()); - } - - /** {@inheritDoc} */ - @Override public int partition() { - return cached.partition(); - } - - /** {@inheritDoc} */ - @Override public V peek() { - try { - return peek0(SMART, null, cached.context().tm().localTxx()); - } - catch (IgniteCheckedException e) { - // Should never happen. - throw new IgniteException("Unable to perform entry peek() operation.", e); - } - } - - /** {@inheritDoc} */ - @Override public V peek(@Nullable Collection<GridCachePeekMode> modes) throws IgniteCheckedException { - return peek0(modes, CU.<K, V>empty(), cached.context().tm().localTxx()); - } - - /** - * @param mode Peek mode. - * @param filter Optional entry filter. - * @param tx Transaction to peek at (if mode is TX). - * @return Peeked value. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings({"unchecked"}) - @Nullable private V peek0(@Nullable GridCachePeekMode mode, - @Nullable IgnitePredicate<Entry<K, V>>[] filter, @Nullable IgniteInternalTx<K, V> tx) - throws IgniteCheckedException { - assert tx == null || tx.local(); - - if (mode == null) - mode = SMART; - - try { - GridTuple<V> peek = cached.peek0(false, mode, filter, tx); - - return peek != null ? peek.get() : null; - } - catch (GridCacheEntryRemovedException ignore) { - return null; - } - catch (GridCacheFilterFailedException e) { - e.printStackTrace(); - - assert false; - - return null; - } - } - - /** - * @param modes Peek modes. - * @param filter Optional entry filter. - * @param tx Transaction to peek at (if modes contains TX value). - * @return Peeked value. - * @throws IgniteCheckedException If failed. - */ - @Nullable private V peek0(@Nullable Collection<GridCachePeekMode> modes, - @Nullable IgnitePredicate<Entry<K, V>>[] filter, IgniteInternalTx<K, V> tx) throws IgniteCheckedException { - if (F.isEmpty(modes)) - return peek0(SMART, filter, tx); - - assert modes != null; - - for (GridCachePeekMode mode : modes) { - V val = peek0(mode, filter, tx); - - if (val != null) - return val; - } - - return null; - } - - /** - * @return Unsupported exception. - */ - private RuntimeException unsupported() { - return new UnsupportedOperationException("Operation not supported during eviction."); - } - - /** {@inheritDoc} */ - @Nullable @Override public V reload() throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> reloadAsync() { - throw unsupported(); + @Override public boolean isCached() { + return !cached.obsoleteOrDeleted(); } - /** {@inheritDoc} */ @Override public boolean evict() { GridCacheContext<K, V> ctx = cached.context(); @@ -229,229 +70,63 @@ public class GridCacheEvictionEntry<K, V> implements Entry<K, V>, Externalizable return ctx.evicts().evict(cached, null, false, null); } catch (IgniteCheckedException e) { - U.error(log, "Failed to evict entry from cache: " + cached, e); + U.error(ctx.grid().log(), "Failed to evict entry from cache: " + cached, e); return false; } } - /** {@inheritDoc} */ - @Override public boolean clear() { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public boolean compact() throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Nullable @Override public V get() throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> getAsync() { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Nullable @Override public V set(V val, IgnitePredicate<Entry<K, V>>[] filter) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> setAsync(V val, IgnitePredicate<Entry<K, V>>[] filter) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public boolean setx(V val, IgnitePredicate<Entry<K, V>>[] filter) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> setxAsync(V val, IgnitePredicate<Entry<K, V>>[] filter) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Nullable @Override public V replace(V val) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> replaceAsync(V val) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public boolean replace(V oldVal, V newVal) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> replaceAsync(V oldVal, V newVal) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public long timeToLive() { - return cached.rawTtl(); - } - - /** {@inheritDoc} */ - @Override public void timeToLive(long ttl) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Nullable @Override public V setIfAbsent(V val) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> setIfAbsentAsync(V val) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public boolean setxIfAbsent(V val) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> setxIfAbsentAsync(V val) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public boolean replacex(V val) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> replacexAsync(V val) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Nullable @Override public V remove(IgnitePredicate<Entry<K, V>>[] filter) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<V> removeAsync(IgnitePredicate<Entry<K, V>>[] filter) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public boolean removex(IgnitePredicate<Entry<K, V>>[] filter) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> removexAsync(IgnitePredicate<Entry<K, V>>[] filter) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public boolean remove(V val) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> removeAsync(V val) { - throw unsupported(); + /** + * @return Peeks value. + */ + @Nullable public V peek() { + try { + return cached.peek(GridCachePeekMode.GLOBAL); + } + catch (GridCacheEntryRemovedException e) { + return null; + } } /** {@inheritDoc} */ - @Override public <V> V addMeta(String name, V val) { - return cached.addMeta(name, val); + @Nullable @Override public V getValue() throws IllegalStateException { + throw new UnsupportedOperationException("Operation not supported during eviction."); } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) - @Override public <V> V meta(String name) { - return cached.meta(name); + @Nullable @Override public <T> T addMeta(T val) { + return cached.addMeta(META_KEY, val); } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) - @Override public <V> V removeMeta(String name) { - return cached.removeMeta(name); - } - - /** {@inheritDoc} */ - @Override public <V> V putMetaIfAbsent(String name, V val) { - return cached.putMetaIfAbsent(name, val); - } - - /** {@inheritDoc} */ - @Override public <V> V putMetaIfAbsent(String name, Callable<V> c) { - return cached.putMetaIfAbsent(name, c); - } - - /** {@inheritDoc} */ - @Override public <V> boolean replaceMeta(String name, V curVal, V newVal) { - return cached.replaceMeta(name, curVal, newVal); - } - - /** {@inheritDoc} */ - @Override public <V> boolean removeMeta(String name, V val) { - return cached.removeMeta(name, val); - } - - /** {@inheritDoc} */ - @Override public boolean isLocked() { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public boolean isLockedByThread() { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public boolean lock(long timeout, - @Nullable IgnitePredicate<Entry<K, V>>[] filter) throws IgniteCheckedException { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<Boolean> lockAsync(long timeout, - @Nullable IgnitePredicate<Entry<K, V>>[] filter) { - throw unsupported(); - } - - /** {@inheritDoc} */ - @Override public void unlock(IgnitePredicate<Entry<K, V>>[] filter) throws IgniteCheckedException { - throw unsupported(); + @Nullable @Override public <T> T meta() { + return cached.meta(META_KEY); } /** {@inheritDoc} */ - @Override public boolean isCached() { - return !cached.obsolete(); + @SuppressWarnings({"unchecked"}) + @Nullable @Override public <T> T removeMeta() { + return cached.removeMeta(META_KEY); } /** {@inheritDoc} */ - @Override public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(cached.context()); - out.writeObject(cached.key()); + @SuppressWarnings({"unchecked"}) + @Override public <T> boolean removeMeta(T val) { + return cached.removeMeta(META_KEY, val); } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - GridCacheContext<K, V> ctx = (GridCacheContext<K, V>)in.readObject(); - K key = (K)in.readObject(); - - cached = ctx.cache().entryEx(key); + @Nullable @Override public <T> T putMetaIfAbsent(T val) { + return cached.putMetaIfAbsent(META_KEY, val); } /** {@inheritDoc} */ - @Override public int memorySize() throws IgniteCheckedException{ - return cached.memorySize(); + @SuppressWarnings({"RedundantTypeArguments"}) + @Override public <T> boolean replaceMeta(T curVal, T newVal) { + return cached.replaceMeta(META_KEY,curVal, newVal); } /** {@inheritDoc} */ @@ -476,13 +151,7 @@ public class GridCacheEvictionEntry<K, V> implements Entry<K, V>, Externalizable if (obj instanceof GridCacheEvictionEntry) { GridCacheEvictionEntry<K, V> other = (GridCacheEvictionEntry<K, V>)obj; - V v1 = peek(); - V v2 = other.peek(); - - return - cached.key().equals(other.cached.key()) && - F.eq(cached.context().cache().name(), other.cached.context().cache().name()) && - F.eq(v1, v2); + return cached.key().equals(other.getKey()); } return false; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java index e73cfc0..0b52d60 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java @@ -649,8 +649,13 @@ public class GridCacheEvictionManager<K, V> extends GridCacheManagerAdapter<K, V * @return {@code true} if entry has been evicted. * @throws IgniteCheckedException If failed to evict entry. */ - private boolean evict0(GridCacheAdapter<K, V> cache, GridCacheEntryEx<K, V> entry, GridCacheVersion obsoleteVer, - @Nullable IgnitePredicate<Entry<K, V>>[] filter, boolean explicit) throws IgniteCheckedException { + private boolean evict0( + GridCacheAdapter<K, V> cache, + GridCacheEntryEx<K, V> entry, + GridCacheVersion obsoleteVer, + @Nullable IgnitePredicate<Entry<K, V>>[] filter, + boolean explicit + ) throws IgniteCheckedException { assert cache != null; assert entry != null; assert obsoleteVer != null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIterator.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIterator.java index 9b3230a..4d177fc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIterator.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIterator.java @@ -18,12 +18,12 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; +import javax.cache.Cache.*; import java.util.*; /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java index 757da90..fc7f979 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java @@ -18,12 +18,12 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import javax.cache.Cache.*; import java.util.*; /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index b2571d8..7d033ce 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; import org.apache.ignite.cache.*; +import org.apache.ignite.cache.eviction.*; import org.apache.ignite.internal.managers.deployment.*; import org.apache.ignite.internal.processors.cache.distributed.dht.*; import org.apache.ignite.internal.processors.cache.extras.*; @@ -3692,13 +3693,22 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K, V> return rawGetOrUnmarshalUnlocked(false); } - /** {@inheritDoc} */ + @Override public Entry<K, V> wrap(boolean prjAware) { + try { + return new CacheEntryImpl<>(key, rawGetOrUnmarshal(true)); + } + catch (IgniteCheckedException e) { + throw new RuntimeException("Fixme"); //TODO ignite-96 + } + } + + /** {@inheritDoc} */ @Override public Entry<K, V> wrapFilterLocked() throws IgniteCheckedException { return new CacheEntryImpl<>(key, rawGetOrUnmarshal(true)); } /** {@inheritDoc} */ - @Override public Entry<K, V> evictWrap() { + @Override public EvictableEntry<K, V> evictWrap() { return new GridCacheEvictionEntry<>(this); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 4717e39..1692f04 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -18,7 +18,6 @@ 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.managers.deployment.*; import org.apache.ignite.internal.processors.cache.transactions.*; @@ -29,6 +28,7 @@ import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.nio.*; import java.util.*; import java.util.concurrent.atomic.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/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 index 32853d5..e8cb939 100644 --- 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 @@ -36,6 +36,7 @@ import org.apache.ignite.portables.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import javax.cache.expiry.*; import javax.cache.processor.*; import java.io.*; @@ -1397,7 +1398,7 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K, V /** {@inheritDoc} */ @Override public boolean apply(Entry<K, V> e) { if (kvFilter != null) { - if (!kvFilter.apply(e.getKey(), e.peek())) + if (!kvFilter.apply(e.getKey(), e.getValue())) return false; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java index 68164f4..bc499fa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java @@ -37,6 +37,7 @@ import org.apache.ignite.transactions.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import javax.cache.expiry.*; import java.io.*; import java.util.*; @@ -49,10 +50,10 @@ import static org.apache.ignite.cache.CacheDistributionMode.*; import static org.apache.ignite.cache.CacheMode.*; import static org.apache.ignite.cache.CachePreloadMode.*; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; -import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*; import static org.apache.ignite.internal.GridNodeAttributes.*; import static org.apache.ignite.internal.GridTopic.*; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*; +import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*; /** * Cache utility methods. @@ -379,14 +380,14 @@ public class GridCacheUtils { } /** - * Gets closure which returns {@link org.apache.ignite.cache.Entry} given cache key. + * Gets closure which returns {@code Entry} given cache key. * If current cache is DHT and key doesn't belong to current partition, * {@code null} is returned. * * @param ctx Cache context. * @param <K> Cache key type. * @param <V> Cache value type. - * @return Closure which returns {@link org.apache.ignite.cache.Entry} given cache key or {@code null} if partition is invalid. + * @return Closure which returns {@code Entry} given cache key or {@code null} if partition is invalid. */ public static <K, V> IgniteClosure<K, Entry<K, V>> cacheKey2Entry( final GridCacheContext<K, V> ctx) { @@ -1675,4 +1676,29 @@ public class GridCacheUtils { return duration.getTimeUnit().toMillis(duration.getDurationAmount()); } + + /** + * Reads array from input stream. + * + * @param in Input stream. + * @return Deserialized array. + * @throws IOException If failed. + * @throws ClassNotFoundException If class not found. + */ + @SuppressWarnings("unchecked") + @Nullable public static <K, V> IgnitePredicate<Entry<K, V>>[] readEntryFilterArray(ObjectInput in) + throws IOException, ClassNotFoundException { + int len = in.readInt(); + + IgnitePredicate<Entry<K, V>>[] arr = null; + + if (len > 0) { + arr = new IgnitePredicate[len]; + + for (int i = 0; i < len; i++) + arr[i] = (IgnitePredicate<Entry<K, V>>)in.readObject(); + } + + return arr; + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java index e9e61ab..66dd627 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueCollection.java @@ -18,13 +18,13 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.util.*; /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java index bce5607..46f1953 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java @@ -35,6 +35,7 @@ import org.apache.ignite.resources.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.io.*; import java.util.*; import java.util.concurrent.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java index de282b0..5abb0b8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache.distributed; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.near.*; @@ -33,6 +32,7 @@ import org.apache.ignite.lang.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.io.*; import java.util.*; import java.util.concurrent.atomic.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java index f792a80..3c1a761 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java @@ -35,6 +35,7 @@ import org.apache.ignite.lang.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.io.*; import java.util.*; import java.util.concurrent.*; @@ -836,14 +837,14 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap Entry<K, V> entry = (Entry<K, V>)o; K key = entry.getKey(); - V val = entry.peek(); + V val = entry.getValue(); if (val == null) return false; try { // Cannot use remove(key, val) since we may be in DHT cache and should go through near. - return entry(key).remove(val); + return GridDhtCacheAdapter.this.remove(key, val); } catch (IgniteCheckedException e) { throw new IgniteException(e); @@ -913,7 +914,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap /** * Complex partition iterator for both partition and swap iteration. */ - private static class PartitionEntryIterator<K, V> extends GridIteratorAdapter<Entry<K, V>> { + private class PartitionEntryIterator<K, V> extends GridIteratorAdapter<Entry<K, V>> { /** */ private static final long serialVersionUID = 0L; @@ -957,7 +958,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap if (last == null) throw new IllegalStateException(); - last.remove(); + ctx.cache().remove(last.getKey(), last.getValue()); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java index 0a02b6a..79a0cc2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.transactions.*; @@ -31,6 +30,7 @@ import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.io.*; import java.util.*; import java.util.concurrent.atomic.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java index f1f528c..4b00acf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.cluster.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.cluster.*; @@ -37,6 +36,7 @@ import org.apache.ignite.transactions.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.io.*; import java.util.*; import java.util.concurrent.atomic.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java index 9bcafe0..b4cbf13 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.cluster.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.cluster.*; @@ -38,6 +37,7 @@ import org.apache.ignite.lang.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.io.*; import java.util.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a6a57ab0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java index e1d68f2..c812fac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.cluster.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; @@ -35,6 +34,7 @@ import org.apache.ignite.transactions.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; +import javax.cache.Cache.*; import java.io.*; import java.util.*; import java.util.concurrent.atomic.*;
