You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/09/06 14:39:36 UTC
[14/50] [abbrv] ignite git commit: Backported test fixes.
Backported test fixes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f045558c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f045558c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f045558c
Branch: refs/heads/ignite-1.5.31-1
Commit: f045558c6152de274f6c9a7539d69b0645fe3526
Parents: e2ec9fe
Author: sboikov <sb...@gridgain.com>
Authored: Mon Jul 4 21:08:24 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jul 7 12:38:04 2016 +0300
----------------------------------------------------------------------
.../cache/GridCacheAbstractFullApiSelfTest.java | 322 ++++++++++---------
...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 170 ++++------
.../junits/common/GridCommonAbstractTest.java | 12 +-
.../multijvm/IgniteCacheProcessProxy.java | 107 +++---
4 files changed, 301 insertions(+), 310 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f045558c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 41d93b1..179e601 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -70,6 +70,7 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
+import org.apache.ignite.internal.util.lang.IgnitePair;
import org.apache.ignite.internal.util.typedef.CIX1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.PA;
@@ -219,6 +220,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
+ initStoreStrategy();
+
if (cacheStartType() == CacheStartMode.STATIC)
super.beforeTestsStarted();
else {
@@ -262,17 +265,12 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
- * Checks that skipStore flag gets overriden inside a transaction.
- *
- * @throws Exception if failed.
+ * Checks that skipStore flag gets overridden inside a transaction.
*/
public void testWriteThroughTx() {
- if(isMultiJvm())
- fail("https://issues.apache.org/jira/browse/IGNITE-1088");
-
String key = "writeThroughKey";
- map.remove(key);
+ storeStgy.removeFromStore(key);
try (final Transaction transaction = grid(0).transactions().txStart()) {
IgniteCache<String, Integer> cache = jcache(0);
@@ -289,27 +287,22 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
transaction.commit();
}
- assertEquals(2, map.get(key));
+ assertEquals(2, storeStgy.getFromStore(key));
}
/**
- * Checks that skipStore flag gets overriden inside a transaction.
- *
- * @throws Exception if failed.
+ * Checks that skipStore flag gets overridden inside a transaction.
*/
public void testNoReadThroughTx() {
- if(isMultiJvm())
- fail("https://issues.apache.org/jira/browse/IGNITE-1088");
-
String key = "writeThroughKey";
IgniteCache<String, Integer> cache = jcache(0);
- resetStore();
+ storeStgy.resetStore();
cache.put(key, 1);
- putToStore(key, 2);
+ storeStgy.putToStore(key, 2);
try (final Transaction transaction = grid(0).transactions().txStart()) {
Integer old = cache.get(key);
@@ -323,7 +316,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
transaction.commit();
}
- assertEquals(0, reads.get());
+ assertEquals(0, storeStgy.getReads());
}
/** {@inheritDoc} */
@@ -559,9 +552,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @throws Exception If failed.
*/
public void testRemoveAllSkipStore() throws Exception {
- if (isMultiJvm())
- fail("https://issues.apache.org/jira/browse/IGNITE-1088");
-
IgniteCache<String, Integer> jcache = jcache();
jcache.putAll(F.asMap("1", 1, "2", 2, "3", 3));
@@ -2063,7 +2053,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
// Check db.
if (!isMultiJvm()) {
- putToStore("key3", 3);
+ storeStgy.putToStore("key3", 3);
assertEquals((Integer)3, cache.getAndPutIfAbsent("key3", 4));
@@ -2135,7 +2125,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
// Check db.
if (!isMultiJvm()) {
- putToStore("key3", 3);
+ storeStgy.putToStore("key3", 3);
cacheAsync.getAndPutIfAbsent("key3", 4);
@@ -2184,7 +2174,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
// Check db.
if (!isMultiJvm()) {
- putToStore("key3", 3);
+ storeStgy.putToStore("key3", 3);
assertFalse(cache.putIfAbsent("key3", 4));
}
@@ -2257,7 +2247,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
// Check db.
if (!isMultiJvm()) {
- putToStore("key3", 3);
+ storeStgy.putToStore("key3", 3);
cacheAsync.putIfAbsent("key3", 4);
@@ -2361,7 +2351,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assert cache.get("key") == 4;
if (!isMultiJvm()) {
- putToStore("key2", 5);
+ storeStgy.putToStore("key2", 5);
info("key2 5 -> 6");
@@ -2420,7 +2410,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assert cache.get("key") == 4;
if (!isMultiJvm()) {
- putToStore("key2", 5);
+ storeStgy.putToStore("key2", 5);
assert cache.replace("key2", 6);
@@ -2496,7 +2486,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assert cache.get("key") == 4;
if (!isMultiJvm()) {
- putToStore("key2", 5);
+ storeStgy.putToStore("key2", 5);
cacheAsync.replace("key2", 5, 6);
@@ -2558,7 +2548,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assert cache.get("key") == 4;
if (!isMultiJvm()) {
- putToStore("key2", 5);
+ storeStgy.putToStore("key2", 5);
cacheAsync.replace("key2", 6);
@@ -2683,9 +2673,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @throws Exception If failed.
*/
public void testRemoveLoad() throws Exception {
- if (isMultiJvm())
- fail("https://issues.apache.org/jira/browse/IGNITE-1088");
-
int cnt = 10;
Set<String> keys = new HashSet<>();
@@ -2696,7 +2683,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
jcache().removeAll(keys);
for (String key : keys)
- putToStore(key, Integer.parseInt(key));
+ storeStgy.putToStore(key, Integer.parseInt(key));
for (int g = 0; g < gridCount(); g++)
grid(g).cache(null).localLoadCache(null);
@@ -3572,9 +3559,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @throws Exception If failed.
*/
private void checkTtl(boolean inTx, boolean oldEntry) throws Exception {
- if (isMultiJvm())
- fail("https://issues.apache.org/jira/browse/IGNITE-1089");
-
if (memoryMode() == OFFHEAP_TIERED)
return;
@@ -3586,22 +3570,17 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
final String key = primaryKeysForCache(jcache(), 1).get(0);
- GridCacheAdapter<String, Integer> internalCache = internalCache(fullCache());
-
- if (internalCache.isNear())
- internalCache = internalCache.context().near().dht();
-
- GridCacheEntryEx entry;
+ IgnitePair<Long> entryTtl;
if (oldEntry) {
c.put(key, 1);
- entry = internalCache.peekEx(key);
+ entryTtl = entryTtl(fullCache(), key);
- assert entry != null;
-
- assertEquals(0, entry.ttl());
- assertEquals(0, entry.expireTime());
+ assertNotNull(entryTtl.get1());
+ assertNotNull(entryTtl.get2());
+ assertEquals((Long)0L, entryTtl.get1());
+ assertEquals((Long)0L, entryTtl.get2());
}
long startTime = System.currentTimeMillis();
@@ -3618,10 +3597,10 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
if (oldEntry) {
- entry = internalCache.peekEx(key);
+ entryTtl = entryTtl(fullCache(), key);
- assertEquals(0, entry.ttl());
- assertEquals(0, entry.expireTime());
+ assertEquals((Long)0L, entryTtl.get1());
+ assertEquals((Long)0L, entryTtl.get2());
}
}
@@ -3643,18 +3622,14 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (int i = 0; i < gridCount(); i++) {
if (grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), key)) {
- GridCacheAdapter<String, Integer> cache = internalCache(jcache(i));
-
- if (cache.context().isNear())
- cache = cache.context().near().dht();
-
- GridCacheEntryEx curEntry = cache.peekEx(key);
+ IgnitePair<Long> curEntryTtl = entryTtl(jcache(i), key);
- assertEquals(ttl, curEntry.ttl());
+ assertNotNull(curEntryTtl.get1());
+ assertNotNull(curEntryTtl.get2());
+ assertEquals(ttl, (long) curEntryTtl.get1());
+ assertTrue(curEntryTtl.get2() > startTime);
- assert curEntry.expireTime() > startTime;
-
- expireTimes[i] = curEntry.expireTime();
+ expireTimes[i] = curEntryTtl.get2();
}
}
@@ -3676,18 +3651,14 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (int i = 0; i < gridCount(); i++) {
if (grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), key)) {
- GridCacheAdapter<String, Integer> cache = internalCache(jcache(i));
-
- if (cache.context().isNear())
- cache = cache.context().near().dht();
-
- GridCacheEntryEx curEntry = cache.peekEx(key);
+ IgnitePair<Long> curEntryTtl = entryTtl(jcache(i), key);
- assertEquals(ttl, curEntry.ttl());
+ assertNotNull(curEntryTtl.get1());
+ assertNotNull(curEntryTtl.get2());
+ assertEquals(ttl, (long) curEntryTtl.get1());
+ assertTrue(curEntryTtl.get2() > startTime);
- assert curEntry.expireTime() > startTime;
-
- expireTimes[i] = curEntry.expireTime();
+ expireTimes[i] = curEntryTtl.get2();
}
}
@@ -3709,18 +3680,14 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (int i = 0; i < gridCount(); i++) {
if (grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), key)) {
- GridCacheAdapter<String, Integer> cache = internalCache(jcache(i));
-
- if (cache.context().isNear())
- cache = cache.context().near().dht();
-
- GridCacheEntryEx curEntry = cache.peekEx(key);
+ IgnitePair<Long> curEntryTtl = entryTtl(jcache(i), key);
- assertEquals(ttl, curEntry.ttl());
+ assertNotNull(curEntryTtl.get1());
+ assertNotNull(curEntryTtl.get2());
+ assertEquals(ttl, (long) curEntryTtl.get1());
+ assertTrue(curEntryTtl.get2() > startTime);
- assert curEntry.expireTime() > startTime;
-
- expireTimes[i] = curEntry.expireTime();
+ expireTimes[i] = curEntryTtl.get2();
}
}
@@ -3746,20 +3713,17 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (int i = 0; i < gridCount(); i++) {
if (grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), key)) {
- GridCacheAdapter<String, Integer> cache = internalCache(jcache(i));
-
- if (cache.context().isNear())
- cache = cache.context().near().dht();
-
- GridCacheEntryEx curEntry = cache.peekEx(key);
+ IgnitePair<Long> curEntryTtl = entryTtl(jcache(i), key);
- assertEquals(ttl, curEntry.ttl());
- assertEquals(expireTimes[i], curEntry.expireTime());
+ assertNotNull(curEntryTtl.get1());
+ assertNotNull(curEntryTtl.get2());
+ assertEquals(ttl, (long)curEntryTtl.get1());
+ assertEquals(expireTimes[i], (long)curEntryTtl.get2());
}
}
// Avoid reloading from store.
- map.remove(key);
+ storeStgy.removeFromStore(key);
assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() {
@SuppressWarnings("unchecked")
@@ -3790,21 +3754,24 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
}, Math.min(ttl * 10, getTestTimeout())));
- if (internalCache.isLocal())
- return;
+ IgniteCache fullCache = fullCache();
- assert c.get(key) == null;
+ if (!isMultiJvmObject(fullCache)) {
+ GridCacheAdapter internalCache = internalCache(fullCache);
- internalCache = internalCache(fullCache());
+ if (internalCache.isLocal())
+ return;
+ }
- if (internalCache.isNear())
- internalCache = internalCache.context().near().dht();
+ assert c.get(key) == null;
// Ensure that old TTL and expire time are not longer "visible".
- entry = internalCache.peekEx(key);
+ entryTtl = entryTtl(fullCache(), key);
- assertEquals(0, entry.ttl());
- assertEquals(0, entry.expireTime());
+ assertNotNull(entryTtl.get1());
+ assertNotNull(entryTtl.get2());
+ assertEquals(0, (long)entryTtl.get1());
+ assertEquals(0, (long)entryTtl.get2());
// Ensure that next update will not pick old expire time.
@@ -3823,12 +3790,14 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
U.sleep(2000);
- entry = internalCache.peekEx(key);
+ entryTtl = entryTtl(fullCache(), key);
assertEquals((Integer)10, c.get(key));
- assertEquals(0, entry.ttl());
- assertEquals(0, entry.expireTime());
+ assertNotNull(entryTtl.get1());
+ assertNotNull(entryTtl.get2());
+ assertEquals(0, (long)entryTtl.get1());
+ assertEquals(0, (long)entryTtl.get2());
}
/**
@@ -4332,6 +4301,15 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
+ * @param cache Cache.
+ * @param key Entry key.
+ * @return Pair [ttl, expireTime]; both values null if entry not found
+ */
+ protected IgnitePair<Long> entryTtl(IgniteCache cache, String key) {
+ return executeOnLocalOrRemoteJvm(cache, new EntryTtlTask(key, true));
+ }
+
+ /**
* @throws Exception If failed.
*/
public void testIterator() throws Exception {
@@ -4752,9 +4730,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @throws Exception If failed.
*/
public void testWithSkipStore() throws Exception {
- if(isMultiJvm())
- fail("https://issues.apache.org/jira/browse/IGNITE-1088");
-
IgniteCache<String, Integer> cache = grid(0).cache(null);
IgniteCache<String, Integer> cacheSkipStore = cache.withSkipStore();
@@ -4762,7 +4737,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
List<String> keys = primaryKeysForCache(cache, 10);
for (int i = 0; i < keys.size(); ++i)
- putToStore(keys.get(i), i);
+ storeStgy.putToStore(keys.get(i), i);
assertFalse(cacheSkipStore.iterator().hasNext());
@@ -4800,7 +4775,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertEquals(i, map.get(key));
+ assertEquals(i, storeStgy.getFromStore(key));
}
for (int i = 0; i < keys.size(); ++i) {
@@ -4809,13 +4784,13 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
Integer val1 = -1;
cacheSkipStore.put(key, val1);
- assertEquals(i, map.get(key));
+ assertEquals(i, storeStgy.getFromStore(key));
assertEquals(val1, cacheSkipStore.get(key));
Integer val2 = -2;
assertEquals(val1, cacheSkipStore.invoke(key, new SetValueProcessor(val2)));
- assertEquals(i, map.get(key));
+ assertEquals(i, storeStgy.getFromStore(key));
assertEquals(val2, cacheSkipStore.get(key));
}
@@ -4824,7 +4799,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertTrue(map.containsKey(key));
+ assertTrue(storeStgy.isInStore(key));
}
for (String key : keys) {
@@ -4832,37 +4807,37 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertNull(cacheSkipStore.get(key));
assertNull(cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
- map.put(key, 0);
+ storeStgy.putToStore(key, 0);
Integer val = -1;
assertNull(cacheSkipStore.invoke(key, new SetValueProcessor(val)));
- assertEquals(0, map.get(key));
+ assertEquals(0, storeStgy.getFromStore(key));
assertEquals(val, cacheSkipStore.get(key));
cache.remove(key);
- map.put(key, 0);
+ storeStgy.putToStore(key, 0);
assertTrue(cacheSkipStore.putIfAbsent(key, val));
assertEquals(val, cacheSkipStore.get(key));
- assertEquals(0, map.get(key));
+ assertEquals(0, storeStgy.getFromStore(key));
cache.remove(key);
- map.put(key, 0);
+ storeStgy.putToStore(key, 0);
assertNull(cacheSkipStore.getAndPut(key, val));
assertEquals(val, cacheSkipStore.get(key));
- assertEquals(0, map.get(key));
+ assertEquals(0, storeStgy.getFromStore(key));
cache.remove(key);
}
assertFalse(cacheSkipStore.iterator().hasNext());
- assertTrue(map.size() == 0);
+ assertTrue(storeStgy.getStoreSize() == 0);
assertTrue(cache.size(ALL) == 0);
// putAll/removeAll from multiple nodes.
@@ -4877,7 +4852,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key : keys) {
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
cache.putAll(data);
@@ -4885,7 +4860,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key : keys) {
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertTrue(map.containsKey(key));
+ assertTrue(storeStgy.isInStore(key));
}
cacheSkipStore.removeAll(data.keySet());
@@ -4893,7 +4868,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key : keys) {
assertNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertTrue(map.containsKey(key));
+ assertTrue(storeStgy.isInStore(key));
}
cacheSkipStore.putAll(data);
@@ -4901,7 +4876,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key : keys) {
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertTrue(map.containsKey(key));
+ assertTrue(storeStgy.isInStore(key));
}
cacheSkipStore.removeAll(data.keySet());
@@ -4909,7 +4884,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key : keys) {
assertNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertTrue(map.containsKey(key));
+ assertTrue(storeStgy.isInStore(key));
}
cache.removeAll(data.keySet());
@@ -4917,24 +4892,24 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key : keys) {
assertNull(cacheSkipStore.get(key));
assertNull(cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
- assertTrue(map.size() == 0);
+ assertTrue(storeStgy.getStoreSize() == 0);
// Miscellaneous checks.
String newKey = "New key";
- assertFalse(map.containsKey(newKey));
+ assertFalse(storeStgy.isInStore(newKey));
cacheSkipStore.put(newKey, 1);
- assertFalse(map.containsKey(newKey));
+ assertFalse(storeStgy.isInStore(newKey));
cache.put(newKey, 1);
- assertTrue(map.containsKey(newKey));
+ assertTrue(storeStgy.isInStore(newKey));
Iterator<Cache.Entry<String, Integer>> it = cacheSkipStore.iterator();
@@ -4944,29 +4919,26 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
String rmvKey = entry.getKey();
- assertTrue(map.containsKey(rmvKey));
+ assertTrue(storeStgy.isInStore(rmvKey));
it.remove();
assertNull(cacheSkipStore.get(rmvKey));
- assertTrue(map.containsKey(rmvKey));
+ assertTrue(storeStgy.isInStore(rmvKey));
assertTrue(cache.size(ALL) == 0);
assertTrue(cacheSkipStore.size(ALL) == 0);
cache.remove(rmvKey);
- assertTrue(map.size() == 0);
+ assertTrue(storeStgy.getStoreSize() == 0);
}
/**
* @throws Exception If failed.
*/
public void testWithSkipStoreRemoveAll() throws Exception {
- if (isMultiJvm())
- fail("https://issues.apache.org/jira/browse/IGNITE-1088");
-
if (atomicityMode() == TRANSACTIONAL || (atomicityMode() == ATOMIC && nearEnabled())) // TODO IGNITE-373.
return;
@@ -4984,7 +4956,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key : data.keySet()) {
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertTrue(map.containsKey(key));
+ assertTrue(storeStgy.isInStore(key));
}
cacheSkipStore.removeAll();
@@ -4992,7 +4964,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key : data.keySet()) {
assertNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertTrue(map.containsKey(key));
+ assertTrue(storeStgy.isInStore(key));
}
cache.removeAll();
@@ -5000,7 +4972,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key : data.keySet()) {
assertNull(cacheSkipStore.get(key));
assertNull(cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
}
@@ -5076,7 +5048,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key: keys) {
assertEquals(val, cacheSkipStore.get(key));
assertEquals(val, cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
tx.commit();
@@ -5085,10 +5057,10 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key: keys) {
assertEquals(val, cacheSkipStore.get(key));
assertEquals(val, cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
- assertEquals(0, map.size());
+ assertEquals(0, storeStgy.getStoreSize());
// cacheSkipStore putAll(..)/removeAll(..) check.
try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
@@ -5102,10 +5074,10 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertEquals(val, cacheSkipStore.get(key));
assertEquals(val, cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
- map.putAll(data);
+ storeStgy.putAllToStore(data);
try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
cacheSkipStore.removeAll(data.keySet());
@@ -5116,12 +5088,12 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key: keys) {
assertNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertTrue(map.containsKey(key));
+ assertTrue(storeStgy.isInStore(key));
cache.remove(key);
}
- assertTrue(map.size() == 0);
+ assertTrue(storeStgy.getStoreSize() == 0);
// cache putAll(..)/removeAll(..) check.
try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
@@ -5130,7 +5102,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key: keys) {
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
cache.removeAll(data.keySet());
@@ -5138,13 +5110,13 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key: keys) {
assertNull(cacheSkipStore.get(key));
assertNull(cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
tx.commit();
}
- assertTrue(map.size() == 0);
+ assertTrue(storeStgy.getStoreSize() == 0);
// putAll(..) from both cacheSkipStore and cache.
try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
@@ -5165,7 +5137,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key: keys) {
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
tx.commit();
@@ -5176,7 +5148,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
for (int i = keys.size() / 2; i < keys.size(); i++) {
@@ -5184,7 +5156,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
- assertTrue(map.containsKey(key));
+ assertTrue(storeStgy.isInStore(key));
}
cache.removeAll(data.keySet());
@@ -5192,16 +5164,16 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
for (String key: keys) {
assertNull(cacheSkipStore.get(key));
assertNull(cache.get(key));
- assertFalse(map.containsKey(key));
+ assertFalse(storeStgy.isInStore(key));
}
// Check that read-through is disabled when cacheSkipStore is used.
for (int i = 0; i < keys.size(); i++)
- putToStore(keys.get(i), i);
+ storeStgy.putToStore(keys.get(i), i);
assertTrue(cacheSkipStore.size(ALL) == 0);
assertTrue(cache.size(ALL) == 0);
- assertTrue(map.size() != 0);
+ assertTrue(storeStgy.getStoreSize() != 0);
try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
assertTrue(cacheSkipStore.getAll(data.keySet()).size() == 0);
@@ -5224,7 +5196,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
for (String key : data.keySet()) {
- map.put(key, 0);
+ storeStgy.putToStore(key, 0);
assertNull(cacheSkipStore.invoke(key, new SetValueProcessor(val)));
}
@@ -5233,7 +5205,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
for (String key : data.keySet()) {
- assertEquals(0, map.get(key));
+ assertEquals(0, storeStgy.getFromStore(key));
assertEquals(val, cacheSkipStore.get(key));
assertEquals(val, cache.get(key));
@@ -5243,7 +5215,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
for (String key : data.keySet()) {
- map.put(key, 0);
+ storeStgy.putToStore(key, 0);
assertTrue(cacheSkipStore.putIfAbsent(key, val));
}
@@ -5252,7 +5224,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
for (String key : data.keySet()) {
- assertEquals(0, map.get(key));
+ assertEquals(0, storeStgy.getFromStore(key));
assertEquals(val, cacheSkipStore.get(key));
assertEquals(val, cache.get(key));
@@ -5262,7 +5234,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
for (String key : data.keySet()) {
- map.put(key, 0);
+ storeStgy.putToStore(key, 0);
assertNull(cacheSkipStore.getAndPut(key, val));
}
@@ -5271,7 +5243,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
for (String key : data.keySet()) {
- assertEquals(0, map.get(key));
+ assertEquals(0, storeStgy.getFromStore(key));
assertEquals(val, cacheSkipStore.get(key));
assertEquals(val, cache.get(key));
@@ -5291,7 +5263,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
throws Exception {
assertTrue(cache.size(ALL) == 0);
assertTrue(cacheSkipStore.size(ALL) == 0);
- assertTrue(map.size() == 0);
+ assertTrue(storeStgy.getStoreSize() == 0);
}
/**
@@ -5631,6 +5603,40 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
*
*/
+ public static class EntryTtlTask implements TestCacheCallable<String, Integer, IgnitePair<Long>> {
+ /** Entry key. */
+ private final String key;
+
+ /** Check cache for nearness, use DHT cache if it is near. */
+ private final boolean useDhtForNearCache;
+
+ /**
+ * @param key Entry key.
+ * @param useDhtForNearCache Check cache for nearness, use DHT cache if it is near.
+ */
+ public EntryTtlTask(String key, boolean useDhtForNearCache) {
+ this.key = key;
+ this.useDhtForNearCache = useDhtForNearCache;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgnitePair<Long> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
+ GridCacheAdapter<?, ?> internalCache = internalCache0(cache);
+
+ if (useDhtForNearCache && internalCache.context().isNear())
+ internalCache = internalCache.context().near().dht();
+
+ GridCacheEntryEx entry = internalCache.peekEx(key);
+
+ return entry != null ?
+ new IgnitePair<>(entry.ttl(), entry.expireTime()) :
+ new IgnitePair<Long>(null, null);
+ }
+ }
+
+ /**
+ *
+ */
private static class CheckIteratorTask extends TestIgniteIdxCallable<Void> {
/**
* @param idx Index.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f045558c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
index eaab103..5fab800 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
@@ -39,10 +39,10 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.events.Event;
-import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
+import org.apache.ignite.internal.util.lang.IgnitePair;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.P1;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -211,6 +211,10 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
* @throws Exception If failed.
*/
public void testReaderTtlTx() throws Exception {
+ // IgniteProcessProxy#transactions is not implemented.
+ if (isMultiJvm())
+ return;
+
checkReaderTtl(true);
}
@@ -222,13 +226,19 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
}
/**
+ * @param cache Cache.
+ * @param key Entry key.
+ * @return Pair [ttl, expireTime] for near cache entry; both values null if entry not found
+ */
+ protected IgnitePair<Long> nearEntryTtl(IgniteCache cache, String key) {
+ return executeOnLocalOrRemoteJvm(cache, new EntryTtlTask(key, false));
+ }
+
+ /**
* @param inTx If {@code true} starts explicit transaction.
* @throws Exception If failed.
*/
private void checkReaderTtl(boolean inTx) throws Exception {
- if (isMultiJvm())
- fail("https://issues.apache.org/jira/browse/IGNITE-1089");
-
int ttl = 1000;
final ExpiryPolicy expiry = new TouchedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, ttl));
@@ -242,17 +252,14 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
info("Finished first put.");
{
- GridCacheAdapter<String, Integer> dht = internalCache(fullCache());
-
- if (dht.context().isNear())
- dht = dht.context().near().dht();
+ IgnitePair<Long> entryTtl = entryTtl(fullCache(), key);
- GridCacheEntryEx entry = dht.peekEx(key);
+ assertEquals((Integer)1, c.get(key));
- assert entry != null;
-
- assertEquals(0, entry.ttl());
- assertEquals(0, entry.expireTime());
+ assertNotNull(entryTtl.get1());
+ assertNotNull(entryTtl.get2());
+ assertEquals(0, (long)entryTtl.get1());
+ assertEquals(0, (long)entryTtl.get2());
}
long startTime = System.currentTimeMillis();
@@ -278,30 +285,19 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
for (int i = 0; i < gridCount(); i++) {
info("Checking grid: " + grid(i).localNode().id());
- GridCacheEntryEx entry = null;
-
- if (grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), key)) {
- GridCacheAdapter<String, Integer> dht = internalCache(jcache(i));
+ IgnitePair<Long> entryTtl = null;
- if (dht.context().isNear())
- dht = dht.context().near().dht();
+ if (grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), key))
+ entryTtl = entryTtl(jcache(i), key);
+ else if (i == nearIdx)
+ entryTtl = nearEntryTtl(jcache(i), key);
- entry = dht.peekEx(key);
-
- assert entry != null;
- }
- else if (i == nearIdx) {
- GridCacheAdapter<String, Integer> near = internalCache(jcache(i));
-
- entry = near.peekEx(key);
-
- assert entry != null;
- }
-
- if (entry != null) {
- assertEquals(ttl, entry.ttl());
- assert entry.expireTime() > startTime;
- expireTimes[i] = entry.expireTime();
+ if (entryTtl != null) {
+ assertNotNull(entryTtl.get1());
+ assertNotNull(entryTtl.get2());
+ assertEquals(ttl, (long)entryTtl.get1());
+ assertTrue(entryTtl.get2() > startTime);
+ expireTimes[i] = entryTtl.get2();
}
}
@@ -322,30 +318,19 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
}
for (int i = 0; i < gridCount(); i++) {
- GridCacheEntryEx entry = null;
-
- if (grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), key)) {
- GridCacheAdapter<String, Integer> dht = internalCache(jcache(i));
-
- if (dht.context().isNear())
- dht = dht.context().near().dht();
-
- entry = dht.peekEx(key);
-
- assert entry != null;
- }
- else if (i == nearIdx) {
- GridCacheAdapter<String, Integer> near = internalCache(jcache(i));
-
- entry = near.peekEx(key);
-
- assert entry != null;
- }
-
- if (entry != null) {
- assertEquals(ttl, entry.ttl());
- assert entry.expireTime() > expireTimes[i];
- expireTimes[i] = entry.expireTime();
+ IgnitePair<Long> entryTtl = null;
+
+ if (grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), key))
+ entryTtl = entryTtl(jcache(i), key);
+ else if (i == nearIdx)
+ entryTtl = nearEntryTtl(jcache(i), key);
+
+ if (entryTtl != null) {
+ assertNotNull(entryTtl.get1());
+ assertNotNull(entryTtl.get2());
+ assertEquals(ttl, (long)entryTtl.get1());
+ assertTrue(entryTtl.get2() > startTime);
+ expireTimes[i] = entryTtl.get2();
}
}
@@ -363,34 +348,23 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
}
for (int i = 0; i < gridCount(); i++) {
- GridCacheEntryEx entry = null;
-
- if (grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), key)) {
- GridCacheAdapter<String, Integer> dht = internalCache(jcache(i));
-
- if (dht.context().isNear())
- dht = dht.context().near().dht();
-
- entry = dht.peekEx(key);
-
- assert entry != null;
- }
- else if (i == nearIdx) {
- GridCacheAdapter<String, Integer> near = internalCache(jcache(i));
-
- entry = near.peekEx(key);
-
- assert entry != null;
- }
-
- if (entry != null) {
- assertEquals(ttl, entry.ttl());
- assertEquals(expireTimes[i], entry.expireTime());
+ IgnitePair<Long> entryTtl = null;
+
+ if (grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), key))
+ entryTtl = entryTtl(jcache(i), key);
+ else if (i == nearIdx)
+ entryTtl = nearEntryTtl(jcache(i), key);
+
+ if (entryTtl != null) {
+ assertNotNull(entryTtl.get1());
+ assertNotNull(entryTtl.get2());
+ assertEquals(ttl, (long)entryTtl.get1());
+ assertEquals(expireTimes[i], (long)entryTtl.get2());
}
}
// Avoid reloading from store.
- map.remove(key);
+ storeStgy.removeFromStore(key);
assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() {
@SuppressWarnings("unchecked")
@@ -421,17 +395,12 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
// Ensure that old TTL and expire time are not longer "visible".
{
- GridCacheAdapter<String, Integer> dht = internalCache(fullCache());
-
- if (dht.context().isNear())
- dht = dht.context().near().dht();
+ IgnitePair<Long> entryTtl = entryTtl(fullCache(), key);
- GridCacheEntryEx entry = dht.peekEx(key);
-
- assert entry != null;
-
- assertEquals(0, entry.ttl());
- assertEquals(0, entry.expireTime());
+ assertNotNull(entryTtl.get1());
+ assertNotNull(entryTtl.get2());
+ assertEquals(0, (long)entryTtl.get1());
+ assertEquals(0, (long)entryTtl.get2());
}
// Ensure that next update will not pick old expire time.
@@ -451,17 +420,12 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
U.sleep(2000);
{
- GridCacheAdapter<String, Integer> dht = internalCache(fullCache());
-
- if (dht.context().isNear())
- dht = dht.context().near().dht();
-
- GridCacheEntryEx entry = dht.peekEx(key);
-
- assert entry != null;
+ IgnitePair<Long> entryTtl = entryTtl(fullCache(), key);
- assertEquals(0, entry.ttl());
- assertEquals(0, entry.expireTime());
+ assertNotNull(entryTtl.get1());
+ assertNotNull(entryTtl.get2());
+ assertEquals(0, (long)entryTtl.get1());
+ assertEquals(0, (long)entryTtl.get2());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f045558c/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 4d40c68..18a0f6a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -159,15 +159,23 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
* @param cache Cache.
* @return Cache.
*/
- protected <K, V> GridCacheAdapter<K, V> internalCache(IgniteCache<K, V> cache) {
+ protected static <K, V> GridCacheAdapter<K, V> internalCache0(IgniteCache<K, V> cache) {
if (isMultiJvmObject(cache))
- throw new UnsupportedOperationException("Oparetion can't be supported automatically for multi jvm " +
+ throw new UnsupportedOperationException("Operation can't be supported automatically for multi jvm " +
"(send closure instead).");
return ((IgniteKernal)cache.unwrap(Ignite.class)).internalCache(cache.getName());
}
/**
+ * @param cache Cache.
+ * @return Cache.
+ */
+ protected <K, V> GridCacheAdapter<K, V> internalCache(IgniteCache<K, V> cache) {
+ return internalCache0(cache);
+ }
+
+ /**
* @return Cache.
*/
protected <K, V> IgniteCache<K, V> jcache() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/f045558c/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 7286fb3..f2f69dd 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -65,6 +65,9 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/** With async. */
private final boolean isAsync;
+ /** Expiry policy. */
+ private final ExpiryPolicy expiryPlc;
+
/** Ignite proxy. */
private final transient IgniteProcessProxy igniteProxy;
@@ -73,24 +76,26 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param proxy Ignite Process Proxy.
*/
public IgniteCacheProcessProxy(String name, IgniteProcessProxy proxy) {
- this(name, false, proxy);
+ this(name, false, null, proxy);
}
/**
* @param name Name.
* @param async Async flag.
+ * @param plc Expiry policy.
* @param proxy Ignite Process Proxy.
*/
- public IgniteCacheProcessProxy(String name, boolean async, IgniteProcessProxy proxy) {
+ private IgniteCacheProcessProxy(String name, boolean async, ExpiryPolicy plc, IgniteProcessProxy proxy) {
cacheName = name;
isAsync = async;
+ expiryPlc = plc;
igniteProxy = proxy;
compute = proxy.remoteCompute();
}
/** {@inheritDoc} */
@Override public IgniteCache<K, V> withAsync() {
- return new IgniteCacheProcessProxy<>(cacheName, true, igniteProxy);
+ return new IgniteCacheProcessProxy<>(cacheName, true, null, igniteProxy);
}
/** {@inheritDoc} */
@@ -116,7 +121,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/** {@inheritDoc} */
@Override public IgniteCache<K, V> withExpiryPolicy(ExpiryPolicy plc) {
- throw new UnsupportedOperationException("Method should be supported.");
+ return new IgniteCacheProcessProxy<>(cacheName, isAsync, plc, igniteProxy);
}
/** {@inheritDoc} */
@@ -261,7 +266,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/** {@inheritDoc} */
@Override public void put(K key, V val) {
- compute.call(new PutTask<>(cacheName, isAsync, key, val));
+ compute.call(new PutTask<>(cacheName, isAsync, expiryPlc, key, val));
}
/** {@inheritDoc} */
@@ -462,7 +467,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param clazz Clazz.
*/
public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.clazz = clazz;
}
@@ -489,7 +494,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param args Args.
*/
public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.p = p;
this.args = args;
}
@@ -519,7 +524,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param val Value.
*/
public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
this.val = val;
}
@@ -547,7 +552,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param byCurrThread By current thread.
*/
public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
this.byCurrThread = byCurrThread;
}
@@ -571,7 +576,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param peekModes Peek modes.
*/
public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.peekModes = peekModes;
}
@@ -599,7 +604,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param keys Keys.
*/
public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.keys = keys;
}
@@ -628,7 +633,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param peekModes Peek modes.
*/
public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
this.peekModes = peekModes;
}
@@ -656,7 +661,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param loc Local.
*/
public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.loc = loc;
this.peekModes = peekModes;
}
@@ -684,7 +689,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param loc Local.
*/
public SizeLongTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.loc = loc;
this.peekModes = peekModes;
}
@@ -708,7 +713,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param key Key.
*/
public GetTask(String cacheName, boolean async, K key) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
}
@@ -731,7 +736,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param key Key.
*/
public GetEntryTask(String cacheName, boolean async, K key) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
}
@@ -750,7 +755,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param async Async.
*/
public RemoveAllTask(String cacheName, boolean async) {
- super(cacheName, async);
+ super(cacheName, async, null);
}
/** {@inheritDoc} */
@@ -779,11 +784,12 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/**
* @param cacheName Cache name.
* @param async Async.
+ * @param expiryPlc Expiry policy.
* @param key Key.
* @param val Value.
*/
- public PutTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
+ public PutTask(String cacheName, boolean async, ExpiryPolicy expiryPlc, K key, V val) {
+ super(cacheName, async, expiryPlc);
this.key = key;
this.val = val;
}
@@ -809,7 +815,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param key Key.
*/
public ContainsKeyTask(String cacheName, boolean async, K key) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
}
@@ -828,7 +834,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param async Async.
*/
public ClearTask(String cacheName, boolean async) {
- super(cacheName, async);
+ super(cacheName, async, null);
}
/** {@inheritDoc} */
@@ -848,7 +854,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param async Async.
*/
public IteratorTask(String cacheName, boolean async) {
- super(cacheName, async);
+ super(cacheName, async, null);
}
/** {@inheritDoc} */
@@ -879,7 +885,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param val Value.
*/
public ReplaceTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
this.val = val;
}
@@ -899,7 +905,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param async Async.
*/
public GetNameTask(String cacheName, boolean async) {
- super(cacheName, async);
+ super(cacheName, async, null);
}
/** {@inheritDoc} */
@@ -921,7 +927,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param key Key.
*/
public RemoveTask(String cacheName, boolean async, K key) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
}
@@ -944,7 +950,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param map Map.
*/
public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.map = map;
}
@@ -969,7 +975,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param keys Keys.
*/
public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.keys = keys;
}
@@ -994,7 +1000,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param keys Keys.
*/
public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.keys = keys;
}
@@ -1017,7 +1023,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param keys Keys.
*/
public GetEntriesTask(String cacheName, boolean async, Set<? extends K> keys) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.keys = keys;
}
@@ -1040,7 +1046,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param keys Keys.
*/
public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.keys = keys;
}
@@ -1063,7 +1069,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param keys Keys.
*/
public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.keys = keys;
}
@@ -1090,7 +1096,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param val Value.
*/
public GetAndPutTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
this.val = val;
}
@@ -1118,7 +1124,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param val Value.
*/
public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
this.val = val;
}
@@ -1146,7 +1152,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param oldVal Old value.
*/
public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
this.oldVal = oldVal;
}
@@ -1170,7 +1176,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param key Key.
*/
public GetAndRemoveTask(String cacheName, boolean async, K key) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
}
@@ -1201,7 +1207,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param newVal New value.
*/
public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
this.oldVal = oldVal;
this.newVal = newVal;
@@ -1230,7 +1236,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param val Value.
*/
public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
this.val = val;
}
@@ -1257,7 +1263,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param key Key.
*/
public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.key = key;
this.loc = loc;
}
@@ -1289,7 +1295,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param keys Keys.
*/
public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.keys = keys;
this.loc = loc;
}
@@ -1327,7 +1333,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
*/
public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
Object[] args) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.args = args;
this.key = key;
this.processor = processor;
@@ -1361,7 +1367,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
*/
public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
EntryProcessor<K, V, T> processor, Object[] args) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.args = args;
this.keys = keys;
this.processor = processor;
@@ -1382,7 +1388,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param async Async.
*/
public CloseTask(String cacheName, boolean async) {
- super(cacheName, async);
+ super(cacheName, async, null);
}
/** {@inheritDoc} */
@@ -1402,7 +1408,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param async Async.
*/
public DestroyTask(String cacheName, boolean async) {
- super(cacheName, async);
+ super(cacheName, async, null);
}
/** {@inheritDoc} */
@@ -1422,7 +1428,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param async Async.
*/
public IsClosedTask(String cacheName, boolean async) {
- super(cacheName, async);
+ super(cacheName, async, null);
}
/** {@inheritDoc} */
@@ -1444,7 +1450,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
* @param clazz Clazz.
*/
public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
- super(cacheName, async);
+ super(cacheName, async, null);
this.clazz = clazz;
}
@@ -1468,21 +1474,28 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/** Async. */
protected final boolean async;
+ /** Expiry policy. */
+ protected final ExpiryPolicy expiryPlc;
+
/**
* @param cacheName Cache name.
* @param async Async.
+ * @param expiryPlc Optional expiry policy.
*/
- public CacheTaskAdapter(String cacheName, boolean async) {
+ public CacheTaskAdapter(String cacheName, boolean async, ExpiryPolicy expiryPlc) {
this.async = async;
this.cacheName = cacheName;
+ this.expiryPlc = expiryPlc;
}
/**
- * Returns cache instance.
+ * @return Cache instance.
*/
protected IgniteCache<K, V> cache() {
IgniteCache<K, V> cache = ignite.cache(cacheName);
+ cache = expiryPlc != null ? cache.withExpiryPolicy(expiryPlc) : cache;
+
return async ? cache.withAsync() : cache;
}
}