You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/03/03 22:21:11 UTC
incubator-ignite git commit: ignite-320 Fix
CacheExpiryTest.iteratorNextShouldCallGetExpiryForAccessedEntry
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-320 [created] 1afb83746
ignite-320 Fix CacheExpiryTest.iteratorNextShouldCallGetExpiryForAccessedEntry
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1afb8374
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1afb8374
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1afb8374
Branch: refs/heads/ignite-320
Commit: 1afb83746b646693c66a47447841bcbe301c364d
Parents: 6909cc4
Author: sevdokimov <se...@jetbrains.com>
Authored: Wed Mar 4 00:20:59 2015 +0300
Committer: sevdokimov <se...@jetbrains.com>
Committed: Wed Mar 4 00:20:59 2015 +0300
----------------------------------------------------------------------
.../processors/cache/CachePeekModes.java | 28 ++++++++++++++++
.../processors/cache/GridCacheAdapter.java | 35 ++++++++++++++++++++
.../cache/query/GridCacheQueryManager.java | 4 +--
3 files changed, 64 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1afb8374/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachePeekModes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachePeekModes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachePeekModes.java
new file mode 100644
index 0000000..7c5b1e8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachePeekModes.java
@@ -0,0 +1,28 @@
+/*
+ * 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.cache.*;
+
+/**
+ *
+ */
+public class CachePeekModes {
+ /** */
+ public static final CachePeekMode[] ONHEAP_ONLY = {CachePeekMode.ONHEAP};
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1afb8374/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 12ea535..3092702 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
@@ -4281,9 +4281,44 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
}
/**
+ *
+ */
+ private Iterator<Cache.Entry<K, V>> localIteratorHonorExpirePolicy() {
+ return F.iterator(
+ iterator(),
+
+ new IgniteClosure<Cache.Entry<K, V>, Cache.Entry<K, V>>() {
+ private IgniteCacheExpiryPolicy expiryPlc = ctx.cache().expiryPolicy(ctx.expiry());
+
+ @Override public Cache.Entry<K, V> apply(Cache.Entry<K, V> lazyEntry) {
+ try {
+ V val = localPeek(lazyEntry.getKey(), CachePeekModes.ONHEAP_ONLY, expiryPlc);
+
+ return new CacheEntryImpl<>(lazyEntry.getKey(), val);
+ }
+ catch (IgniteCheckedException e) {
+ throw CU.convertToCacheException(e);
+ }
+ }
+ },
+
+ false,
+
+ new IgnitePredicate<Cache.Entry<K, V>>() {
+ @Override public boolean apply(Cache.Entry<K, V> lazyEntry) {
+ return !lazyEntry.unwrap(GridCacheEntryEx.class).obsoleteOrDeleted();
+ }
+ }
+ );
+ }
+
+ /**
* @return Distributed ignite cache iterator.
*/
public Iterator<Cache.Entry<K, V>> igniteIterator() {
+ if (!ctx.isSwapOrOffheapEnabled() && ctx.kernalContext().discovery().size() == 1)
+ return localIteratorHonorExpirePolicy();
+
CacheQueryFuture<Map.Entry<K, V>> fut = queries().createScanQuery(null)
.keepAll(false)
.execute();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1afb8374/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 8fa48aa..f021d9c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -756,8 +756,6 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
injectResources(keyValFilter);
- final CachePeekMode[] peekModes = {CachePeekMode.ONHEAP};
-
final GridDhtCacheAdapter dht = cctx.isLocal() ? null : (cctx.isNear() ? cctx.near().dht() : cctx.dht());
final ExpiryPolicy plc = cctx.expiry();
@@ -800,7 +798,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
V val;
try {
- val = prj.localPeek(key, peekModes, expiryPlc);
+ val = prj.localPeek(key, CachePeekModes.ONHEAP_ONLY, expiryPlc);
}
catch (IgniteCheckedException e) {
if (log.isDebugEnabled())