#sberb-23: Get caused exception for indexed entity in offheap mode. Add test for bug
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/638dd313 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/638dd313 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/638dd313 Branch: refs/heads/ignite-961 Commit: 638dd313eded4946adcf3dc3d309db1c59ae8ce3 Parents: 410c1d7 Author: ivasilinets <ivasilin...@gridgain.com> Authored: Tue Jun 9 12:13:51 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Tue Jun 9 12:13:51 2015 +0300 ---------------------------------------------------------------------- .../cache/GridCacheOffheapIndexGetSelfTest.java | 62 +++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/638dd313/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java index 41eb45a..4e613ae 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java @@ -19,14 +19,17 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; import org.apache.ignite.cache.query.*; +import org.apache.ignite.cache.query.annotations.*; import org.apache.ignite.configuration.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.spi.swapspace.file.*; import org.apache.ignite.testframework.junits.common.*; +import org.apache.ignite.transactions.*; import javax.cache.*; +import java.io.*; import java.util.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; @@ -71,7 +74,7 @@ public class GridCacheOffheapIndexGetSelfTest extends GridCommonAbstractTest { cacheCfg.setAtomicityMode(TRANSACTIONAL); cacheCfg.setMemoryMode(OFFHEAP_TIERED); cacheCfg.setEvictionPolicy(null); - cacheCfg.setIndexedTypes(Long.class, Long.class); + cacheCfg.setIndexedTypes(Long.class, Long.class, String.class, TestEntity.class); cfg.setCacheConfiguration(cacheCfg); @@ -120,4 +123,61 @@ public class GridCacheOffheapIndexGetSelfTest extends GridCommonAbstractTest { assertNotNull(e.getValue()); } } + + /** + * @throws Exception If failed. + */ + public void testPutGet() throws Exception { + IgniteCache<Object, Object> cache = grid(0).cache(null); + + Map map = new HashMap(); + + try (Transaction tx = grid(0).transactions().txStart(TransactionConcurrency.PESSIMISTIC, + TransactionIsolation.REPEATABLE_READ, 100000, 1000)) { + + for (int i = 4; i < 400; i++) { + map.put("key" + i, new TestEntity("value")); + map.put(i, "value"); + } + + cache.putAll(map); + + tx.commit(); + } + + for (int i = 0; i < 100; i++) { + cache.get("key" + i); + cache.get(i); + } + } + + /** + * Test entry class. + */ + private static class TestEntity implements Serializable { + /** Value. */ + @QuerySqlField(index = true) + private String val; + + /** + * @param value Value. + */ + public TestEntity(String value) { + this.val = value; + } + + /** + * @return Value. + */ + public String getValue() { + return val; + } + + /** + * @param val Value + */ + public void setValue(String val) { + this.val = val; + } + } }