ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [36/50] [abbrv] incubator-ignite git commit: ignite-320 Fix CacheExpiryTest.iteratorNextShouldCallGetExpiryForAccessedEntry
Date Wed, 11 Mar 2015 16:17:58 GMT
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/2bd7421d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2bd7421d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2bd7421d

Branch: refs/heads/ignite-422
Commit: 2bd7421dea2d1d2e6822841936fcff1626760428
Parents: efed98d
Author: sevdokimov <sergey.evdokimov@jetbrains.com>
Authored: Wed Mar 4 00:20:59 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Wed Mar 11 16:34:22 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/2bd7421d/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/2bd7421d/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 a966a86..e1d3562 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
@@ -4121,9 +4121,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/2bd7421d/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 b5e26eb..da75742 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
@@ -745,8 +745,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();
@@ -789,7 +787,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())


Mime
View raw message