ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [16/38] incubator-ignite git commit: # ignite-41
Date Tue, 23 Dec 2014 08:22:52 GMT
# ignite-41


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/736dcc11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/736dcc11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/736dcc11

Branch: refs/heads/ignite-1
Commit: 736dcc1149b58b66dd7af6419bf71def36ccbe40
Parents: 0230134
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Dec 19 09:24:27 2014 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Dec 19 11:05:31 2014 +0300

----------------------------------------------------------------------
 .../cache/GridCacheAccessExpiryPolicy.java      | 10 ++++-
 .../processors/cache/GridCacheExpiryPolicy.java | 13 +++++-
 .../processors/cache/GridCacheMapEntry.java     | 10 ++++-
 .../cache/GridCacheTxLocalAdapter.java          | 32 +++++++++++---
 .../distributed/GridCacheTtlUpdateRequest.java  | 17 ++++----
 .../GridDistributedTxRemoteAdapter.java         |  3 ++
 .../distributed/dht/GridDhtCacheAdapter.java    |  2 +-
 .../distributed/dht/GridDhtTxFinishRequest.java |  8 ++--
 .../dht/atomic/GridDhtAtomicCache.java          | 44 ++++++++++++++++++--
 .../IgniteCacheExpiryPolicyAbstractTest.java    | 34 ++++++++++++++-
 .../cache/GridCacheBasicApiAbstractTest.java    | 16 +++----
 11 files changed, 150 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAccessExpiryPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAccessExpiryPolicy.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAccessExpiryPolicy.java
index f0904dd..2205108 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAccessExpiryPolicy.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAccessExpiryPolicy.java
@@ -83,7 +83,10 @@ public class GridCacheAccessExpiryPolicy implements GridCacheExpiryPolicy
{
      * @param ver Entry version.
      */
     @SuppressWarnings("unchecked")
-    @Override public void onAccessUpdated(Object key, byte[] keyBytes, GridCacheVersion ver)
{
+    @Override public void onAccessUpdated(Object key,
+        byte[] keyBytes,
+        GridCacheVersion ver,
+        @Nullable Collection<UUID> rdrs) {
         Map<Object, IgniteBiTuple<byte[], GridCacheVersion>> entries0 = entries;
 
         if (entries0 == null) {
@@ -106,6 +109,11 @@ public class GridCacheAccessExpiryPolicy implements GridCacheExpiryPolicy
{
     }
 
     /** {@inheritDoc} */
+    @Nullable @Override public Map<UUID, Collection<IgniteBiTuple<byte[], GridCacheVersion>>>
readers() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridCacheAccessExpiryPolicy.class, this);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheExpiryPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheExpiryPolicy.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheExpiryPolicy.java
index 3ce9572..0328d51 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheExpiryPolicy.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheExpiryPolicy.java
@@ -37,11 +37,20 @@ public interface GridCacheExpiryPolicy {
      * @param key Entry key.
      * @param keyBytes Entry key bytes.
      * @param ver Entry version.
+     * @param rdrs Entry readers.
      */
-    public void onAccessUpdated(Object key, byte[] keyBytes, GridCacheVersion ver);
+    public void onAccessUpdated(Object key,
+        byte[] keyBytes,
+        GridCacheVersion ver,
+        @Nullable Collection<UUID> rdrs);
 
     /**
-     * @return TTL update request.
+     * @return Entries with TTL updated on access.
      */
     @Nullable public Map<Object, IgniteBiTuple<byte[], GridCacheVersion>> entries();
+
+    /**
+     * @return Readers for updated entries.
+     */
+    @Nullable Map<UUID, Collection<IgniteBiTuple<byte[], GridCacheVersion>>>
readers();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
index 6f5fae6..8b79382 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMapEntry.java
@@ -888,7 +888,10 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
 
                 updateTtl(ttl);
 
-                expiryPlc.onAccessUpdated(key(), getOrMarshalKeyBytes(), version());
+                expiryPlc.onAccessUpdated(key(),
+                    getOrMarshalKeyBytes(),
+                    version(),
+                    hasReaders() ? ((GridDhtCacheEntry)this).readers() : null);
             }
         }
 
@@ -1851,7 +1854,10 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
                         if (newTtl != -1L) {
                             updateTtl(newTtl);
 
-                            expiryPlc.onAccessUpdated(key, getOrMarshalKeyBytes(), version());
+                            expiryPlc.onAccessUpdated(key,
+                                getOrMarshalKeyBytes(),
+                                version(),
+                                hasReaders() ? ((GridDhtCacheEntry)this).readers() : null);
                         }
                     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
index d2e0413..1cafbed 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
@@ -788,6 +788,9 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends GridCacheTxAdapter<K
                                             "Transaction does not own lock for group lock
entry during  commit [tx=" +
                                                 this + ", txEntry=" + txEntry + ']';
 
+                                        if (txEntry.ttl() != -1L)
+                                            cached.updateTtl(null, txEntry.ttl());
+
                                         if (log.isDebugEnabled())
                                             log.debug("Ignoring NOOP entry when committing:
" + txEntry);
                                     }
@@ -1710,9 +1713,10 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends GridCacheTxAdapter<K
     /**
      * Internal routine for <tt>putAll(..)</tt>
      *
+     * @param cacheCtx Cache context.
      * @param keys Keys to enlist.
      * @param cached Cached entry.
-     * @param expiry Expiry policy for entry. If {@code null}, leave unchanged.
+     * @param expiryPlc Explicitly specified expiry policy for entry.
      * @param implicit Implicit flag.
      * @param lookup Value lookup map ({@code null} for remove).
      * @param transformMap Map with transform closures if this is a transform operation.
@@ -1729,7 +1733,7 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends GridCacheTxAdapter<K
         GridCacheContext<K, V> cacheCtx,
         Collection<? extends K> keys,
         @Nullable GridCacheEntryEx<K, V> cached,
-        @Nullable ExpiryPolicy expiry,
+        @Nullable ExpiryPolicy expiryPlc,
         boolean implicit,
         @Nullable Map<? extends K, ? extends V> lookup,
         @Nullable Map<? extends K, ? extends IgniteClosure<V, V>> transformMap,
@@ -1884,7 +1888,7 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends GridCacheTxAdapter<K
                             }
 
                             txEntry = addEntry(lockOnly ? NOOP : rmv ? DELETE : transformClo
!= null ? TRANSFORM :
-                                old != null ? UPDATE : CREATE, val, transformClo, entry,
expiry, filter, true, drTtl,
+                                old != null ? UPDATE : CREATE, val, transformClo, entry,
expiryPlc, filter, true, drTtl,
                                 drExpireTime, drVer);
 
                             if (!implicit() && readCommitted())
@@ -1971,7 +1975,7 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends GridCacheTxAdapter<K
                         }
 
                         txEntry = addEntry(rmv ? DELETE : transformClo != null ? TRANSFORM
:
-                            v != null ? UPDATE : CREATE, val, transformClo, entry, expiry,
filter, true, drTtl,
+                            v != null ? UPDATE : CREATE, val, transformClo, entry, expiryPlc,
filter, true, drTtl,
                             drExpireTime, drVer);
 
                         enlisted.add(key);
@@ -2100,6 +2104,11 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends GridCacheTxAdapter<K
                         txEntry.setAndMarkValid(txEntry.previousOperation(), ret.value());
                         txEntry.filters(CU.<K, V>empty());
                         txEntry.filtersSet(false);
+
+                        ExpiryPolicy expiryPlc = txEntry.expiry() != null ? txEntry.expiry()
: cacheCtx.expiry();
+
+                        if (expiryPlc != null)
+                            txEntry.ttl(GridCacheMapEntry.toTtl(expiryPlc.getExpiryForAccess()));
                     }
 
                     break; // While.
@@ -2341,6 +2350,7 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends GridCacheTxAdapter<K
     }
 
     /**
+     * @param cacheCtx Cache context.
      * @param keys Keys to remove.
      * @param drMap DR map.
      * @param retval Flag indicating whether a value should be returned.
@@ -2418,11 +2428,21 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends
GridCacheTxAdapter<K
         try {
             Collection<K> enlisted = new LinkedList<>();
 
+            ExpiryPolicy plc;
+
+            if (!F.isEmpty(filter)) {
+                GridCacheProjectionImpl<K, V> prj = cacheCtx.projectionPerCall();
+
+                plc = prj != null ? prj.expiry() : null;
+            }
+            else
+                plc = null;
+
             final IgniteFuture<Set<K>> loadFut = enlistWrite(
                 cacheCtx,
                 keys0,
                 /** cached entry */null,
-                /** expiry */null,
+                plc,
                 implicit,
                 /** lookup map */null,
                 /** transform map */null,
@@ -2689,7 +2709,7 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends GridCacheTxAdapter<K
     /**
      * @param op Cache operation.
      * @param val Value.
-     * @param expiryPlc Expiry policy, if {@code null}, leave unchanged.
+     * @param expiryPlc Explicitly specified expiry policy.
      * @param transformClos Transform closure.
      * @param entry Cache entry.
      * @param filter Filter.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheTtlUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheTtlUpdateRequest.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheTtlUpdateRequest.java
index c862904..b2e9141 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheTtlUpdateRequest.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheTtlUpdateRequest.java
@@ -36,6 +36,14 @@ public class GridCacheTtlUpdateRequest<K, V> extends GridCacheMessage<K,
V> {
     @GridDirectCollection(GridCacheVersion.class)
     private List<GridCacheVersion> vers;
 
+    /** */
+    @GridDirectCollection(byte[].class)
+    private List<byte[]> nearKeysBytes;
+
+    /** Versions for near entries. */
+    @GridDirectCollection(GridCacheVersion.class)
+    private List<GridCacheVersion> nearVers;
+
     /** New TTL. */
     private long ttl;
 
@@ -63,21 +71,16 @@ public class GridCacheTtlUpdateRequest<K, V> extends GridCacheMessage<K,
V> {
     }
 
     /**
-     * @param key Key.
      * @param keyBytes Key bytes.
      * @param ver Version.
      */
-    public void addEntry(K key, byte[] keyBytes, GridCacheVersion ver) {
-        if (keys == null) {
-            keys = new ArrayList<>();
-
+    public void addEntry(byte[] keyBytes, GridCacheVersion ver) {
+        if (keysBytes == null) {
             keysBytes = new ArrayList<>();
 
             vers = new ArrayList<>();
         }
 
-        keys.add(key);
-
         keysBytes.add(keyBytes);
 
         vers.add(ver);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
index c35c284..ffc8ca6 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
@@ -584,6 +584,9 @@ public class GridDistributedTxRemoteAdapter<K, V> extends GridCacheTxAdapter<K,
                                             "Transaction does not own lock for group lock
entry during  commit [tx=" +
                                                 this + ", txEntry=" + txEntry + ']';
 
+                                        if (txEntry.ttl() != -1L)
+                                            cached.updateTtl(null, txEntry.ttl());
+
                                         if (nearCached != null) {
                                             V val0 = null;
                                             byte[] valBytes0 = null;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index a7b1fea..e67c6dd 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -627,7 +627,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
                                     req.cacheId(ctx.cacheId());
                                 }
 
-                                req.addEntry((K)e.getKey(), e.getValue().get1(), e.getValue().get2());
+                                req.addEntry(e.getValue().get1(), e.getValue().get2());
                             }
                         }
                     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
index 931d40c..612b7f6 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java
@@ -495,13 +495,13 @@ public class GridDhtTxFinishRequest<K, V> extends GridDistributedTxFinishRequest
 
                 commState.idx++;
 
-            case 31:
+            case 32:
                 if (!commState.putLongList(ttls))
                     return false;
 
                 commState.idx++;
 
-            case 32:
+            case 33:
                 if (!commState.putLongList(nearTtls))
                     return false;
 
@@ -661,7 +661,7 @@ public class GridDhtTxFinishRequest<K, V> extends GridDistributedTxFinishRequest
 
                 commState.idx++;
 
-            case 31:
+            case 32:
                 GridLongList ttls0 = commState.getLongList();
 
                 if (ttls0 == LONG_LIST_NOT_READ)
@@ -671,7 +671,7 @@ public class GridDhtTxFinishRequest<K, V> extends GridDistributedTxFinishRequest
 
                 commState.idx++;
 
-            case 32:
+            case 33:
                 GridLongList nearTtls0 = commState.getLongList();
 
                 if (nearTtls0 == LONG_LIST_NOT_READ)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index c3ef323..21afa83 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -667,7 +667,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
 
         GridCacheProjectionImpl<K, V> prj = ctx.projectionPerCall();
 
-        UUID subjId = ctx.subjectIdPerCall(null); // TODO IGNITE-41.
+        UUID subjId = ctx.subjectIdPerCall(null, prj);
 
         int taskNameHash = ctx.kernalContext().job().currentTaskNameHash();
 
@@ -1110,7 +1110,10 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
                         if (ttl != -1L) {
                             entry.updateTtl(null, ttl);
 
-                            expiry.onAccessUpdated(entry.key(), entry.getOrMarshalKeyBytes(),
entry.version());
+                            expiry.onAccessUpdated(entry.key(),
+                                entry.getOrMarshalKeyBytes(),
+                                entry.version(),
+                                entry.readers());
                         }
                     }
 
@@ -2376,6 +2379,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
      * @param nodeId Sender node ID.
      * @param res Deferred atomic update response.
      */
+    @SuppressWarnings("unchecked")
     private void processDhtAtomicDeferredUpdateResponse(UUID nodeId, GridDhtAtomicDeferredUpdateResponse<K,
V> res) {
         if (log.isDebugEnabled())
             log.debug("Processing deferred dht atomic update response [nodeId=" + nodeId
+ ", res=" + res + ']');
@@ -2705,6 +2709,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
         /** */
         private Map<Object, IgniteBiTuple<byte[], GridCacheVersion>> entries;
 
+        /** */
+        private Map<UUID, Collection<IgniteBiTuple<byte[], GridCacheVersion>>>
rdrsMap;
+
         /**
          * @param plc Expiry policy.
          */
@@ -2730,16 +2737,45 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
         }
 
         /** {@inheritDoc} */
-        @Override public void onAccessUpdated(Object key, byte[] keyBytes, GridCacheVersion
ver) {
+        @Override public void onAccessUpdated(Object key,
+            byte[] keyBytes,
+            GridCacheVersion ver,
+            @Nullable Collection<UUID> rdrs) {
             if (entries == null)
                 entries = new HashMap<>();
 
-            entries.put(key, new IgniteBiTuple<>(keyBytes, ver));
+            IgniteBiTuple t = new IgniteBiTuple<>(keyBytes, ver);
+
+            entries.put(key, t);
+
+            if (!F.isEmpty(rdrs)) {
+                if (rdrs == null)
+                    rdrsMap = new HashMap<>();
+
+                for (UUID nodeId : rdrs) {
+                    Collection<IgniteBiTuple<byte[], GridCacheVersion>> col =
rdrsMap.get(nodeId);
+
+                    if (col == null)
+                        rdrsMap.put(nodeId, col = new ArrayList<>());
+
+                    col.add(t);
+                }
+            }
         }
 
         /** {@inheritDoc} */
         @Nullable @Override public Map<Object, IgniteBiTuple<byte[], GridCacheVersion>>
entries() {
             return entries;
         }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public Map<UUID, Collection<IgniteBiTuple<byte[], GridCacheVersion>>>
readers() {
+            return rdrsMap;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(UpdateExpiryPolicy.class, this);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java
index 326b232..bffe6af 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java
@@ -144,10 +144,16 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs
         accessGetAll();
 
         for (final Integer key : keys()) {
-            log.info("Test filter access [key=" + key + ']');
+            log.info("Test filterAccessRemove access [key=" + key + ']');
 
             filterAccessRemove(key);
         }
+
+        for (final Integer key : keys()) {
+            log.info("Test filterAccessReplace access [key=" + key + ']');
+
+            filterAccessReplace(key);
+        }
     }
 
     /**
@@ -183,9 +189,33 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs
 
         checkTtl(key, 60_000L);
 
-        assertFalse(cache.remove(key, 2));
+        assertFalse(cache.remove(key, 2)); // Remove fails, access expiry policy should be
used.
+
+        checkTtl(key, 62_000L, true);
+
+        assertFalse(cache.withExpiryPolicy(new TestPolicy(100L, 200L, 1000L)).remove(key,
2));
+
+        checkTtl(key, 1000L, true);
+    }
+
+    /**
+     * @param key Key.
+     * @throws Exception If failed.
+     */
+    private void filterAccessReplace(Integer key) throws Exception {
+        IgniteCache<Integer, Integer> cache = jcache();
+
+        cache.put(key, 1);
+
+        checkTtl(key, 60_000L);
+
+        assertFalse(cache.replace(key, 2, 3)); // Put fails, access expiry policy should
be used.
 
         checkTtl(key, 62_000L, true);
+
+        assertFalse(cache.withExpiryPolicy(new TestPolicy(100L, 200L, 1000L)).remove(key,
2));
+
+        checkTtl(key, 1000L, true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/736dcc11/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicApiAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicApiAbstractTest.java
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicApiAbstractTest.java
index faa18b2..f56309c 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicApiAbstractTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicApiAbstractTest.java
@@ -23,6 +23,7 @@ import org.gridgain.testframework.*;
 import org.gridgain.testframework.junits.common.*;
 import org.jetbrains.annotations.*;
 
+import javax.cache.expiry.*;
 import java.util.*;
 import java.util.concurrent.*;
 
@@ -491,27 +492,22 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
      * @throws Exception In case of error.
      */
     public void testPutWithExpiration() throws Exception {
-        GridCache<Integer, String> cache = ignite.cache(null);
+        IgniteCache<Integer, String> cache = ignite.jcache(null);
 
         CacheEventListener lsnr = new CacheEventListener(new CountDownLatch(1));
 
         ignite.events().localListen(lsnr, EVTS_CACHE);
 
+        ExpiryPolicy expiry = new TouchedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS,
200L));
+
         try {
             int key = (int)System.currentTimeMillis();
 
-            GridCacheEntry<Integer, String> entry = cache.entry(key);
-
-            entry.timeToLive(200);
-
-            entry.set("val");
+            cache.withExpiryPolicy(expiry).put(key, "val");
 
             assert cache.get(key) != null;
 
-            entry.timeToLive(200);
-
-            // Must update for TTL to have effect.
-            entry.set("val");
+            cache.withExpiryPolicy(expiry).put(key, "val");
 
             Thread.sleep(500);
 


Mime
View raw message