Merge branches 'ignite-96' and 'sprint-1' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-96
Conflicts: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContext.java modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e9b822d6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e9b822d6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e9b822d6 Branch: refs/heads/ignite-96 Commit: e9b822d67aad49ee78b8679458e30f49411ca229 Parents: c3ea6fd Author: Yakov Zhdanov <yzhda...@gridgain.com> Authored: Tue Feb 10 16:24:49 2015 +0300 Committer: Yakov Zhdanov <yzhda...@gridgain.com> Committed: Tue Feb 10 16:24:49 2015 +0300 ---------------------------------------------------------------------- ...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 325 +++++++++---------- .../GridCacheSwapScanQueryAbstractSelfTest.java | 11 +- 2 files changed, 166 insertions(+), 170 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e9b822d6/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 2c2e075..15b56b3 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 @@ -24,20 +24,15 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; -import org.apache.ignite.testframework.*; -import org.apache.ignite.transactions.*; -import javax.cache.expiry.*; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; import java.util.concurrent.locks.*; -import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*; import static org.apache.ignite.cache.CacheDistributionMode.*; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; @@ -207,165 +202,167 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio * @throws Exception */ private void checkReaderTtl(boolean inTx) throws Exception { - int ttl = 1000; - - final ExpiryPolicy expiry = new TouchedExpiryPolicy(new Duration(MILLISECONDS, ttl)); - - final GridCache<String, Integer> c = cache(); - - final String key = primaryKeysForCache(jcache(), 1).get(0); - - c.put(key, 1); - - CacheEntry<String, Integer> entry = c.entry(key); - - assert entry != null; - - assertEquals(0, entry.timeToLive()); - assertEquals(0, entry.expirationTime()); - - long startTime = System.currentTimeMillis(); - - int fullIdx = nearIdx == 0 ? 1 : 0; - - // Now commit transaction and check that ttl and expire time have been saved. - IgniteTx tx = inTx ? grid(fullIdx).transactions().txStart() : null; - - try { - jcache(fullIdx).withExpiryPolicy(expiry).put(key, 1); - - if (tx != null) - tx.commit(); - } - finally { - if (tx != null) - tx.close(); - } - - long[] expireTimes = new long[gridCount()]; - - for (int i = 0; i < gridCount(); i++) { - CacheEntry<String, Integer> curEntry = cache(i).entry(key); - - if (curEntry.primary() || curEntry.backup() || i == nearIdx) { - assertEquals(ttl, curEntry.timeToLive()); - - assert curEntry.expirationTime() > startTime; - - expireTimes[i] = curEntry.expirationTime(); - } - } - - // One more update from the same cache entry to ensure that expire time is shifted forward. - U.sleep(100); - - tx = inTx ? grid(fullIdx).transactions().txStart() : null; - - try { - jcache(fullIdx).withExpiryPolicy(expiry).put(key, 2); - - if (tx != null) - tx.commit(); - } - finally { - if (tx != null) - tx.close(); - } - - for (int i = 0; i < gridCount(); i++) { - CacheEntry<String, Integer> curEntry = cache(i).entry(key); - - if (curEntry.primary() || curEntry.backup() || i == nearIdx) { - assertEquals(ttl, curEntry.timeToLive()); - - assert curEntry.expirationTime() > expireTimes[i]; - - expireTimes[i] = curEntry.expirationTime(); - } - } - - // And one more update to ensure that ttl is not changed and expire time is not shifted forward. - U.sleep(100); - - tx = inTx ? grid(fullIdx).transactions().txStart() : null; - - try { - jcache(fullIdx).put(key, 4); - } - finally { - if (tx != null) - tx.commit(); - } - - for (int i = 0; i < gridCount(); i++) { - CacheEntry<String, Integer> curEntry = cache(i).entry(key); - - if (curEntry.primary() || curEntry.backup() || i == nearIdx) { - assertEquals(ttl, curEntry.timeToLive()); - assertEquals(expireTimes[i], curEntry.expirationTime()); - } - } - - // Avoid reloading from store. - map.remove(key); - - assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() { - @SuppressWarnings("unchecked") - @Override public boolean applyx() throws IgniteCheckedException { - try { - Integer val = c.get(key); - - if (val != null) { - info("Value is in cache [key=" + key + ", val=" + val + ']'); - - return false; - } - - // Get "cache" field from GridCacheProxyImpl. - GridCacheAdapter c0 = GridTestUtils.getFieldValue(c, "cache"); - - if (!c0.context().deferredDelete()) { - GridCacheEntryEx e0 = c0.peekEx(key); - - return e0 == null || (e0.rawGet() == null && e0.valueBytes() == null); - } - else - return true; - } - catch (GridCacheEntryRemovedException e) { - throw new RuntimeException(e); - } - } - }, Math.min(ttl * 10, getTestTimeout()))); - - // Ensure that old TTL and expire time are not longer "visible". - entry = c.entry(key); - - assert entry.get() == null; - - assertEquals(0, entry.timeToLive()); - assertEquals(0, entry.expirationTime()); - - // Ensure that next update will not pick old expire time. - - tx = inTx ? c.txStart() : null; - - try { - entry.set(10); - } - finally { - if (tx != null) - tx.commit(); - } - - U.sleep(2000); - - entry = c.entry(key); - - assertEquals((Integer)10, entry.get()); - - assertEquals(0, entry.timeToLive()); - assertEquals(0, entry.expirationTime()); + assert false : "ignite-96"; + +// int ttl = 1000; +// +// final ExpiryPolicy expiry = new TouchedExpiryPolicy(new Duration(MILLISECONDS, ttl)); +// +// final GridCache<String, Integer> c = cache(); +// +// final String key = primaryKeysForCache(jcache(), 1).get(0); +// +// c.put(key, 1); +// +// Cache.Entry<String, Integer> entry = c.entry(key); +// +// assert entry != null; +// +// assertEquals(0, entry.timeToLive()); +// assertEquals(0, entry.expirationTime()); +// +// long startTime = System.currentTimeMillis(); +// +// int fullIdx = nearIdx == 0 ? 1 : 0; +// +// // Now commit transaction and check that ttl and expire time have been saved. +// IgniteTx tx = inTx ? grid(fullIdx).transactions().txStart() : null; +// +// try { +// jcache(fullIdx).withExpiryPolicy(expiry).put(key, 1); +// +// if (tx != null) +// tx.commit(); +// } +// finally { +// if (tx != null) +// tx.close(); +// } +// +// long[] expireTimes = new long[gridCount()]; +// +// for (int i = 0; i < gridCount(); i++) { +// CacheEntry<String, Integer> curEntry = cache(i).entry(key); +// +// if (curEntry.primary() || curEntry.backup() || i == nearIdx) { +// assertEquals(ttl, curEntry.timeToLive()); +// +// assert curEntry.expirationTime() > startTime; +// +// expireTimes[i] = curEntry.expirationTime(); +// } +// } +// +// // One more update from the same cache entry to ensure that expire time is shifted forward. +// U.sleep(100); +// +// tx = inTx ? grid(fullIdx).transactions().txStart() : null; +// +// try { +// jcache(fullIdx).withExpiryPolicy(expiry).put(key, 2); +// +// if (tx != null) +// tx.commit(); +// } +// finally { +// if (tx != null) +// tx.close(); +// } +// +// for (int i = 0; i < gridCount(); i++) { +// CacheEntry<String, Integer> curEntry = cache(i).entry(key); +// +// if (curEntry.primary() || curEntry.backup() || i == nearIdx) { +// assertEquals(ttl, curEntry.timeToLive()); +// +// assert curEntry.expirationTime() > expireTimes[i]; +// +// expireTimes[i] = curEntry.expirationTime(); +// } +// } +// +// // And one more update to ensure that ttl is not changed and expire time is not shifted forward. +// U.sleep(100); +// +// tx = inTx ? grid(fullIdx).transactions().txStart() : null; +// +// try { +// jcache(fullIdx).put(key, 4); +// } +// finally { +// if (tx != null) +// tx.commit(); +// } +// +// for (int i = 0; i < gridCount(); i++) { +// CacheEntry<String, Integer> curEntry = cache(i).entry(key); +// +// if (curEntry.primary() || curEntry.backup() || i == nearIdx) { +// assertEquals(ttl, curEntry.timeToLive()); +// assertEquals(expireTimes[i], curEntry.expirationTime()); +// } +// } +// +// // Avoid reloading from store. +// map.remove(key); +// +// assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() { +// @SuppressWarnings("unchecked") +// @Override public boolean applyx() throws IgniteCheckedException { +// try { +// Integer val = c.get(key); +// +// if (val != null) { +// info("Value is in cache [key=" + key + ", val=" + val + ']'); +// +// return false; +// } +// +// // Get "cache" field from GridCacheProxyImpl. +// GridCacheAdapter c0 = GridTestUtils.getFieldValue(c, "cache"); +// +// if (!c0.context().deferredDelete()) { +// GridCacheEntryEx e0 = c0.peekEx(key); +// +// return e0 == null || (e0.rawGet() == null && e0.valueBytes() == null); +// } +// else +// return true; +// } +// catch (GridCacheEntryRemovedException e) { +// throw new RuntimeException(e); +// } +// } +// }, Math.min(ttl * 10, getTestTimeout()))); +// +// // Ensure that old TTL and expire time are not longer "visible". +// entry = c.entry(key); +// +// assert entry.get() == null; +// +// assertEquals(0, entry.timeToLive()); +// assertEquals(0, entry.expirationTime()); +// +// // Ensure that next update will not pick old expire time. +// +// tx = inTx ? c.txStart() : null; +// +// try { +// entry.set(10); +// } +// finally { +// if (tx != null) +// tx.commit(); +// } +// +// U.sleep(2000); +// +// entry = c.entry(key); +// +// assertEquals((Integer)10, entry.get()); +// +// assertEquals(0, entry.timeToLive()); +// assertEquals(0, entry.expirationTime()); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e9b822d6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java index 2aa3264..7ae2db4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java @@ -29,6 +29,7 @@ import org.apache.ignite.spi.swapspace.file.*; import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.common.*; +import javax.cache.*; import java.util.*; import java.util.concurrent.*; @@ -195,13 +196,11 @@ public abstract class GridCacheSwapScanQueryAbstractSelfTest extends GridCommonA * @param cache Cache. * @return Projection. */ - protected CacheProjection createProjectionForFilter(GridCache cache) { - return cache.projection(new IgnitePredicate<CacheEntry<Key, Person>>() { - @Override public boolean apply(CacheEntry<Key, Person> e) { + protected CacheProjection createProjectionForFilter(final GridCache cache) { + return cache.projection(new IgnitePredicate<Cache.Entry<Key, Person>>() { + @Override public boolean apply(Cache.Entry<Key, Person> e) { Key key = e.getKey(); - Person val = e.peek(); - - assertNotNull(e.version()); + Person val = e.getValue(); assertEquals(key.id, (Integer)val.salary);