http://git-wip-us.apache.org/repos/asf/ignite/blob/35b6d61f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheIgniteObjectsAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheIgniteObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheIgniteObjectsAbstractSelfTest.java new file mode 100644 index 0000000..09f8527 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheIgniteObjectsAbstractSelfTest.java @@ -0,0 +1,981 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.portable; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import javax.cache.Cache; +import javax.cache.processor.EntryProcessor; +import javax.cache.processor.MutableEntry; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteObjects; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CachePeekMode; +import org.apache.ignite.cache.store.CacheStoreAdapter; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.portable.IgniteObjectImpl; +import org.apache.ignite.internal.processors.cache.GridCacheAdapter; +import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; +import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; +import org.apache.ignite.internal.util.typedef.P2; +import org.apache.ignite.internal.util.typedef.internal.CU; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteBiInClosure; +import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.apache.ignite.igniteobject.IgniteObjectBuilder; +import org.apache.ignite.igniteobject.IgniteObjectException; +import org.apache.ignite.igniteobject.IgniteObjectMarshalAware; +import org.apache.ignite.igniteobject.IgniteObject; +import org.apache.ignite.igniteobject.IgniteObjectReader; +import org.apache.ignite.igniteobject.IgniteObjectWriter; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * Test for portable objects stored in cache. + */ +public abstract class GridCacheIgniteObjectsAbstractSelfTest extends GridCommonAbstractTest { + /** */ + public static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** */ + private static final int ENTRY_CNT = 100; + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + TcpDiscoverySpi disco = new TcpDiscoverySpi(); + + disco.setIpFinder(IP_FINDER); + + cfg.setDiscoverySpi(disco); + + CacheConfiguration cacheCfg = new CacheConfiguration(); + + cacheCfg.setCacheMode(cacheMode()); + cacheCfg.setAtomicityMode(atomicityMode()); + cacheCfg.setNearConfiguration(nearConfiguration()); + cacheCfg.setWriteSynchronizationMode(FULL_SYNC); + cacheCfg.setCacheStoreFactory(singletonFactory(new TestStore())); + cacheCfg.setReadThrough(true); + cacheCfg.setWriteThrough(true); + cacheCfg.setLoadPreviousValue(true); + cacheCfg.setBackups(1); + + if (offheapTiered()) { + cacheCfg.setMemoryMode(OFFHEAP_TIERED); + cacheCfg.setOffHeapMaxMemory(0); + } + + cfg.setCacheConfiguration(cacheCfg); + + cfg.setMarshaller(new PortableMarshaller()); + + return cfg; + } + + /** + * @return {@code True} if should use OFFHEAP_TIERED mode. + */ + protected boolean offheapTiered() { + return false; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + startGridsMultiThreaded(gridCount()); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + for (int i = 0; i < gridCount(); i++) { + GridCacheAdapter<Object, Object> c = ((IgniteKernal)grid(i)).internalCache(); + + for (GridCacheEntryEx e : c.map().entries0()) { + Object key = e.key().value(c.context().cacheObjectContext(), false); + Object val = CU.value(e.rawGet(), c.context(), false); + + if (key instanceof IgniteObject) + assert ((IgniteObjectImpl)key).detached() : val; + + if (val instanceof IgniteObject) + assert ((IgniteObjectImpl)val).detached() : val; + } + } + + IgniteCache<Object, Object> c = jcache(0); + + for (int i = 0; i < ENTRY_CNT; i++) + c.remove(i); + + if (offheapTiered()) { + for (int k = 0; k < 100; k++) + c.remove(k); + } + + assertEquals(0, c.size()); + } + + /** + * @return Cache mode. + */ + protected abstract CacheMode cacheMode(); + + /** + * @return Atomicity mode. + */ + protected abstract CacheAtomicityMode atomicityMode(); + + /** + * @return Distribution mode. + */ + protected abstract NearCacheConfiguration nearConfiguration(); + + /** + * @return Grid count. + */ + protected abstract int gridCount(); + + /** + * @throws Exception If failed. + */ + @SuppressWarnings("unchecked") + public void testCircularReference() throws Exception { + IgniteCache c = keepPortableCache(); + + TestReferenceObject obj1 = new TestReferenceObject(); + + obj1.obj = new TestReferenceObject(obj1); + + c.put(1, obj1); + + IgniteObject po = (IgniteObject)c.get(1); + + String str = po.toString(); + + log.info("toString: " + str); + + assertNotNull(str); + + assertTrue("Unexpected toString: " + str, + str.startsWith("TestReferenceObject") && str.contains("obj=TestReferenceObject [")); + + TestReferenceObject obj1_r = po.deserialize(); + + assertNotNull(obj1_r); + + TestReferenceObject obj2_r = obj1_r.obj; + + assertNotNull(obj2_r); + + assertSame(obj1_r, obj2_r.obj); + } + + /** + * @throws Exception If failed. + */ + public void testGet() throws Exception { + IgniteCache<Integer, TestObject> c = jcache(0); + + for (int i = 0; i < ENTRY_CNT; i++) + c.put(i, new TestObject(i)); + + for (int i = 0; i < ENTRY_CNT; i++) { + TestObject obj = c.get(i); + + assertEquals(i, obj.val); + } + + IgniteCache<Integer, IgniteObject> kpc = keepPortableCache(); + + for (int i = 0; i < ENTRY_CNT; i++) { + IgniteObject po = kpc.get(i); + + assertEquals(i, (int)po.field("val")); + } + } + + /** + * @throws Exception If failed. + */ + public void testIterator() throws Exception { + IgniteCache<Integer, TestObject> c = jcache(0); + + Map<Integer, TestObject> entries = new HashMap<>(); + + for (int i = 0; i < ENTRY_CNT; i++) { + TestObject val = new TestObject(i); + + c.put(i, val); + + entries.put(i, val); + } + + IgniteCache<Integer, IgniteObject> prj = ((IgniteCacheProxy)c).keepPortable(); + + Iterator<Cache.Entry<Integer, IgniteObject>> it = prj.iterator(); + + assertTrue(it.hasNext()); + + while (it.hasNext()) { + Cache.Entry<Integer, IgniteObject> entry = it.next(); + + assertTrue(entries.containsKey(entry.getKey())); + + TestObject o = entries.get(entry.getKey()); + + IgniteObject po = entry.getValue(); + + assertEquals(o.val, (int)po.field("val")); + + entries.remove(entry.getKey()); + } + + assertEquals(0, entries.size()); + } + + /** + * @throws Exception If failed. + */ + public void testCollection() throws Exception { + IgniteCache<Integer, Collection<TestObject>> c = jcache(0); + + for (int i = 0; i < ENTRY_CNT; i++) { + Collection<TestObject> col = new ArrayList<>(3); + + for (int j = 0; j < 3; j++) + col.add(new TestObject(i * 10 + j)); + + c.put(i, col); + } + + for (int i = 0; i < ENTRY_CNT; i++) { + Collection<TestObject> col = c.get(i); + + assertEquals(3, col.size()); + + Iterator<TestObject> it = col.iterator(); + + for (int j = 0; j < 3; j++) { + assertTrue(it.hasNext()); + + assertEquals(i * 10 + j, it.next().val); + } + } + + IgniteCache<Integer, Collection<IgniteObject>> kpc = keepPortableCache(); + + for (int i = 0; i < ENTRY_CNT; i++) { + Collection<IgniteObject> col = kpc.get(i); + + assertEquals(3, col.size()); + + Iterator<IgniteObject> it = col.iterator(); + + for (int j = 0; j < 3; j++) { + assertTrue(it.hasNext()); + + assertEquals(i * 10 + j, (int)it.next().field("val")); + } + } + } + + /** + * @throws Exception If failed. + */ + public void testMap() throws Exception { + IgniteCache<Integer, Map<Integer, TestObject>> c = jcache(0); + + for (int i = 0; i < ENTRY_CNT; i++) { + Map<Integer, TestObject> map = U.newHashMap(3); + + for (int j = 0; j < 3; j++) { + int idx = i * 10 + j; + + map.put(idx, new TestObject(idx)); + } + + c.put(i, map); + } + + for (int i = 0; i < ENTRY_CNT; i++) { + Map<Integer, TestObject> map = c.get(i); + + assertEquals(3, map.size()); + + for (int j = 0; j < 3; j++) { + int idx = i * 10 + j; + + assertEquals(idx, map.get(idx).val); + } + } + + IgniteCache<Integer, Map<Integer, IgniteObject>> kpc = keepPortableCache(); + + for (int i = 0; i < ENTRY_CNT; i++) { + Map<Integer, IgniteObject> map = kpc.get(i); + + assertEquals(3, map.size()); + + for (int j = 0; j < 3; j++) { + int idx = i * 10 + j; + + assertEquals(idx, (int)map.get(idx).field("val")); + } + } + } + + /** + * @throws Exception If failed. + */ + public void testGetAsync() throws Exception { + IgniteCache<Integer, TestObject> c = jcache(0); + + IgniteCache<Integer, TestObject> cacheAsync = c.withAsync(); + + for (int i = 0; i < ENTRY_CNT; i++) + c.put(i, new TestObject(i)); + + for (int i = 0; i < ENTRY_CNT; i++) { + cacheAsync.get(i); + + TestObject obj = cacheAsync.<TestObject>future().get(); + + assertNotNull(obj); + + assertEquals(i, obj.val); + } + + IgniteCache<Integer, IgniteObject> kpc = keepPortableCache(); + + IgniteCache<Integer, IgniteObject> cachePortableAsync = kpc.withAsync(); + + for (int i = 0; i < ENTRY_CNT; i++) { + cachePortableAsync.get(i); + + IgniteObject po = cachePortableAsync.<IgniteObject>future().get(); + + assertEquals(i, (int)po.field("val")); + } + } + + /** + * @throws Exception If failed. + */ + public void testGetTx() throws Exception { + if (atomicityMode() != TRANSACTIONAL) + return; + + IgniteCache<Integer, TestObject> c = jcache(0); + + for (int i = 0; i < ENTRY_CNT; i++) + c.put(i, new TestObject(i)); + + for (int i = 0; i < ENTRY_CNT; i++) { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + TestObject obj = c.get(i); + + assertEquals(i, obj.val); + + tx.commit(); + } + } + + for (int i = 0; i < ENTRY_CNT; i++) { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { + TestObject obj = c.get(i); + + assertEquals(i, obj.val); + + tx.commit(); + } + } + + IgniteCache<Integer, IgniteObject> kpc = keepPortableCache(); + + for (int i = 0; i < ENTRY_CNT; i++) { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + IgniteObject po = kpc.get(i); + + assertEquals(i, (int)po.field("val")); + + tx.commit(); + } + } + + for (int i = 0; i < ENTRY_CNT; i++) { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { + IgniteObject po = kpc.get(i); + + assertEquals(i, (int)po.field("val")); + + tx.commit(); + } + } + } + + /** + * @throws Exception If failed. + */ + public void testGetAsyncTx() throws Exception { + if (atomicityMode() != TRANSACTIONAL) + return; + + IgniteCache<Integer, TestObject> c = jcache(0); + + IgniteCache<Integer, TestObject> cacheAsync = c.withAsync(); + + for (int i = 0; i < ENTRY_CNT; i++) + c.put(i, new TestObject(i)); + + for (int i = 0; i < ENTRY_CNT; i++) { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + cacheAsync.get(i); + + TestObject obj = cacheAsync.<TestObject>future().get(); + + assertEquals(i, obj.val); + + tx.commit(); + } + } + + IgniteCache<Integer, IgniteObject> kpc = keepPortableCache(); + IgniteCache<Integer, IgniteObject> cachePortableAsync = kpc.withAsync(); + + for (int i = 0; i < ENTRY_CNT; i++) { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + cachePortableAsync.get(i); + + IgniteObject po = cachePortableAsync.<IgniteObject>future().get(); + + assertEquals(i, (int)po.field("val")); + + tx.commit(); + } + } + } + + /** + * @throws Exception If failed. + */ + public void testGetAll() throws Exception { + IgniteCache<Integer, TestObject> c = jcache(0); + + for (int i = 0; i < ENTRY_CNT; i++) + c.put(i, new TestObject(i)); + + for (int i = 0; i < ENTRY_CNT; ) { + Set<Integer> keys = new HashSet<>(); + + for (int j = 0; j < 10; j++) + keys.add(i++); + + Map<Integer, TestObject> objs = c.getAll(keys); + + assertEquals(10, objs.size()); + + for (Map.Entry<Integer, TestObject> e : objs.entrySet()) + assertEquals(e.getKey().intValue(), e.getValue().val); + } + + IgniteCache<Integer, IgniteObject> kpc = keepPortableCache(); + + for (int i = 0; i < ENTRY_CNT; ) { + Set<Integer> keys = new HashSet<>(); + + for (int j = 0; j < 10; j++) + keys.add(i++); + + Map<Integer, IgniteObject> objs = kpc.getAll(keys); + + assertEquals(10, objs.size()); + + for (Map.Entry<Integer, IgniteObject> e : objs.entrySet()) + assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); + } + } + + /** + * @throws Exception If failed. + */ + public void testGetAllAsync() throws Exception { + IgniteCache<Integer, TestObject> c = jcache(0); + + IgniteCache<Integer, TestObject> cacheAsync = c.withAsync(); + + for (int i = 0; i < ENTRY_CNT; i++) + c.put(i, new TestObject(i)); + + for (int i = 0; i < ENTRY_CNT; ) { + Set<Integer> keys = new HashSet<>(); + + for (int j = 0; j < 10; j++) + keys.add(i++); + + cacheAsync.getAll(keys); + + Map<Integer, TestObject> objs = cacheAsync.<Map<Integer, TestObject>>future().get(); + + assertEquals(10, objs.size()); + + for (Map.Entry<Integer, TestObject> e : objs.entrySet()) + assertEquals(e.getKey().intValue(), e.getValue().val); + } + + IgniteCache<Integer, IgniteObject> kpc = keepPortableCache(); + IgniteCache<Integer, IgniteObject> cachePortableAsync = kpc.withAsync(); + + for (int i = 0; i < ENTRY_CNT; ) { + Set<Integer> keys = new HashSet<>(); + + for (int j = 0; j < 10; j++) + keys.add(i++); + + + cachePortableAsync.getAll(keys); + + Map<Integer, IgniteObject> objs = cachePortableAsync.<Map<Integer, IgniteObject>>future().get(); + + assertEquals(10, objs.size()); + + for (Map.Entry<Integer, IgniteObject> e : objs.entrySet()) + assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); + } + } + + /** + * @throws Exception If failed. + */ + public void testGetAllTx() throws Exception { + if (atomicityMode() != TRANSACTIONAL) + return; + + IgniteCache<Integer, TestObject> c = jcache(0); + + for (int i = 0; i < ENTRY_CNT; i++) + c.put(i, new TestObject(i)); + + for (int i = 0; i < ENTRY_CNT; ) { + Set<Integer> keys = new HashSet<>(); + + for (int j = 0; j < 10; j++) + keys.add(i++); + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + Map<Integer, TestObject> objs = c.getAll(keys); + + assertEquals(10, objs.size()); + + for (Map.Entry<Integer, TestObject> e : objs.entrySet()) + assertEquals(e.getKey().intValue(), e.getValue().val); + + tx.commit(); + } + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { + Map<Integer, TestObject> objs = c.getAll(keys); + + assertEquals(10, objs.size()); + + for (Map.Entry<Integer, TestObject> e : objs.entrySet()) + assertEquals(e.getKey().intValue(), e.getValue().val); + + tx.commit(); + } + } + + IgniteCache<Integer, IgniteObject> kpc = keepPortableCache(); + + for (int i = 0; i < ENTRY_CNT; ) { + Set<Integer> keys = new HashSet<>(); + + for (int j = 0; j < 10; j++) + keys.add(i++); + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + Map<Integer, IgniteObject> objs = kpc.getAll(keys); + + assertEquals(10, objs.size()); + + for (Map.Entry<Integer, IgniteObject> e : objs.entrySet()) + assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); + + tx.commit(); + } + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { + Map<Integer, IgniteObject> objs = kpc.getAll(keys); + + assertEquals(10, objs.size()); + + for (Map.Entry<Integer, IgniteObject> e : objs.entrySet()) + assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); + + tx.commit(); + } + } + } + + /** + * @throws Exception If failed. + */ + public void testGetAllAsyncTx() throws Exception { + if (atomicityMode() != TRANSACTIONAL) + return; + + IgniteCache<Integer, TestObject> c = jcache(0); + IgniteCache<Integer, TestObject> cacheAsync = c.withAsync(); + + for (int i = 0; i < ENTRY_CNT; i++) + c.put(i, new TestObject(i)); + + for (int i = 0; i < ENTRY_CNT; ) { + Set<Integer> keys = new HashSet<>(); + + for (int j = 0; j < 10; j++) + keys.add(i++); + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + cacheAsync.getAll(keys); + + Map<Integer, TestObject> objs = cacheAsync.<Map<Integer, TestObject>>future().get(); + + assertEquals(10, objs.size()); + + for (Map.Entry<Integer, TestObject> e : objs.entrySet()) + assertEquals(e.getKey().intValue(), e.getValue().val); + + tx.commit(); + } + } + + IgniteCache<Integer, IgniteObject> cache = keepPortableCache(); + + for (int i = 0; i < ENTRY_CNT; ) { + Set<Integer> keys = new HashSet<>(); + + for (int j = 0; j < 10; j++) + keys.add(i++); + + IgniteCache<Integer, IgniteObject> asyncCache = cache.withAsync(); + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + asyncCache.getAll(keys); + + Map<Integer, IgniteObject> objs = asyncCache.<Map<Integer, IgniteObject>>future().get(); + + assertEquals(10, objs.size()); + + for (Map.Entry<Integer, IgniteObject> e : objs.entrySet()) + assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); + + tx.commit(); + } + } + } + + /** + * @throws Exception If failed. + */ + public void testLoadCache() throws Exception { + for (int i = 0; i < gridCount(); i++) + jcache(i).localLoadCache(null); + + IgniteCache<Integer, TestObject> cache = jcache(0); + + assertEquals(3, cache.size(CachePeekMode.PRIMARY)); + + assertEquals(1, cache.get(1).val); + assertEquals(2, cache.get(2).val); + assertEquals(3, cache.get(3).val); + } + + /** + * @throws Exception If failed. + */ + public void testLoadCacheAsync() throws Exception { + for (int i = 0; i < gridCount(); i++) { + IgniteCache<Object, Object> jcache = jcache(i).withAsync(); + + jcache.loadCache(null); + + jcache.future().get(); + } + + IgniteCache<Integer, TestObject> cache = jcache(0); + + assertEquals(3, cache.size(CachePeekMode.PRIMARY)); + + assertEquals(1, cache.get(1).val); + assertEquals(2, cache.get(2).val); + assertEquals(3, cache.get(3).val); + } + + /** + * @throws Exception If failed. + */ + public void testLoadCacheFilteredAsync() throws Exception { + for (int i = 0; i < gridCount(); i++) { + IgniteCache<Integer, TestObject> c = this.<Integer, TestObject>jcache(i).withAsync(); + + c.loadCache(new P2<Integer, TestObject>() { + @Override public boolean apply(Integer key, TestObject val) { + return val.val < 3; + } + }); + + c.future().get(); + } + + IgniteCache<Integer, TestObject> cache = jcache(0); + + assertEquals(2, cache.size(CachePeekMode.PRIMARY)); + + assertEquals(1, cache.get(1).val); + assertEquals(2, cache.get(2).val); + + assertNull(cache.get(3)); + } + + /** + * @throws Exception If failed. + */ + public void testTransform() throws Exception { + IgniteCache<Integer, IgniteObject> c = keepPortableCache(); + + checkTransform(primaryKey(c)); + + if (cacheMode() != CacheMode.LOCAL) { + checkTransform(backupKey(c)); + + if (nearConfiguration() != null) + checkTransform(nearKey(c)); + } + } + + /** + * @return Cache with keep portable flag. + */ + private <K, V> IgniteCache<K, V> keepPortableCache() { + return ignite(0).cache(null).withKeepBinary(); + } + + /** + * @param key Key. + * @throws Exception If failed. + */ + private void checkTransform(Integer key) throws Exception { + log.info("Transform: " + key); + + IgniteCache<Integer, IgniteObject> c = keepPortableCache(); + + try { + c.invoke(key, new EntryProcessor<Integer, IgniteObject, Void>() { + @Override public Void process(MutableEntry<Integer, IgniteObject> e, Object... args) { + IgniteObject val = e.getValue(); + + assertNull("Unexpected value: " + val, val); + + return null; + } + }); + + jcache(0).put(key, new TestObject(1)); + + c.invoke(key, new EntryProcessor<Integer, IgniteObject, Void>() { + @Override public Void process(MutableEntry<Integer, IgniteObject> e, Object... args) { + IgniteObject val = e.getValue(); + + assertNotNull("Unexpected value: " + val, val); + + assertEquals(new Integer(1), val.field("val")); + + Ignite ignite = e.unwrap(Ignite.class); + + IgniteObjects portables = ignite.portables(); + + IgniteObjectBuilder builder = portables.builder(val); + + builder.setField("val", 2); + + e.setValue(builder.build()); + + return null; + } + }); + + IgniteObject obj = c.get(key); + + assertEquals(new Integer(2), obj.field("val")); + + c.invoke(key, new EntryProcessor<Integer, IgniteObject, Void>() { + @Override public Void process(MutableEntry<Integer, IgniteObject> e, Object... args) { + IgniteObject val = e.getValue(); + + assertNotNull("Unexpected value: " + val, val); + + assertEquals(new Integer(2), val.field("val")); + + e.setValue(val); + + return null; + } + }); + + obj = c.get(key); + + assertEquals(new Integer(2), obj.field("val")); + + c.invoke(key, new EntryProcessor<Integer, IgniteObject, Void>() { + @Override public Void process(MutableEntry<Integer, IgniteObject> e, Object... args) { + IgniteObject val = e.getValue(); + + assertNotNull("Unexpected value: " + val, val); + + assertEquals(new Integer(2), val.field("val")); + + e.remove(); + + return null; + } + }); + + assertNull(c.get(key)); + } + finally { + c.remove(key); + } + } + + /** + * + */ + private static class TestObject implements IgniteObjectMarshalAware { + /** */ + private int val; + + /** + */ + private TestObject() { + // No-op. + } + + /** + * @param val Value. + */ + private TestObject(int val) { + this.val = val; + } + + /** {@inheritDoc} */ + @Override public void writePortable(IgniteObjectWriter writer) throws IgniteObjectException { + writer.writeInt("val", val); + } + + /** {@inheritDoc} */ + @Override public void readPortable(IgniteObjectReader reader) throws IgniteObjectException { + val = reader.readInt("val"); + } + } + + /** + * + */ + private static class TestReferenceObject implements IgniteObjectMarshalAware { + /** */ + private TestReferenceObject obj; + + /** + */ + private TestReferenceObject() { + // No-op. + } + + /** + * @param obj Object. + */ + private TestReferenceObject(TestReferenceObject obj) { + this.obj = obj; + } + + /** {@inheritDoc} */ + @Override public void writePortable(IgniteObjectWriter writer) throws IgniteObjectException { + writer.writeObject("obj", obj); + } + + /** {@inheritDoc} */ + @Override public void readPortable(IgniteObjectReader reader) throws IgniteObjectException { + obj = reader.readObject("obj"); + } + } + + /** + * + */ + private static class TestStore extends CacheStoreAdapter<Integer, Object> { + /** {@inheritDoc} */ + @Override public void loadCache(IgniteBiInClosure<Integer, Object> clo, Object... args) { + for (int i = 1; i <= 3; i++) + clo.apply(i, new TestObject(i)); + } + + /** {@inheritDoc} */ + @Nullable @Override public Object load(Integer key) { + return null; + } + + /** {@inheritDoc} */ + @Override public void write(Cache.Entry<? extends Integer, ?> e) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void delete(Object key) { + // No-op. + } + } +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/35b6d61f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractDataStreamerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractDataStreamerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractDataStreamerSelfTest.java deleted file mode 100644 index 9ba38d9..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractDataStreamerSelfTest.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.portable; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.ignite.IgniteDataStreamer; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableTypeConfiguration; -import org.apache.ignite.portable.PortableWriter; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.jsr166.LongAdder8; - -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; - -/** - * Test for portable objects stored in cache. - */ -public abstract class GridCachePortableObjectsAbstractDataStreamerSelfTest extends GridCommonAbstractTest { - /** */ - private static final int THREAD_CNT = 64; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - CacheConfiguration cacheCfg = new CacheConfiguration(); - - cacheCfg.setCacheMode(cacheMode()); - cacheCfg.setAtomicityMode(atomicityMode()); - cacheCfg.setNearConfiguration(nearConfiguration()); - cacheCfg.setWriteSynchronizationMode(writeSynchronizationMode()); - - cfg.setCacheConfiguration(cacheCfg); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setTypeConfigurations(Arrays.asList( - new PortableTypeConfiguration(TestObject.class.getName()))); - - cfg.setMarshaller(marsh); - - return cfg; - } - - /** - * @return Sync mode. - */ - protected CacheWriteSynchronizationMode writeSynchronizationMode() { - return PRIMARY_SYNC; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGridsMultiThreaded(gridCount()); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** - * @return Cache mode. - */ - protected abstract CacheMode cacheMode(); - - /** - * @return Atomicity mode. - */ - protected abstract CacheAtomicityMode atomicityMode(); - - /** - * @return Near configuration. - */ - protected abstract NearCacheConfiguration nearConfiguration(); - - /** - * @return Grid count. - */ - protected int gridCount() { - return 1; - } - - /** - * @throws Exception If failed. - */ - @SuppressWarnings("BusyWait") - public void testGetPut() throws Exception { - final AtomicBoolean flag = new AtomicBoolean(); - - final LongAdder8 cnt = new LongAdder8(); - - try (IgniteDataStreamer<Object, Object> ldr = grid(0).dataStreamer(null)) { - IgniteInternalFuture<?> f = multithreadedAsync( - new Callable<Object>() { - @Override public Object call() throws Exception { - ThreadLocalRandom rnd = ThreadLocalRandom.current(); - - while (!flag.get()) { - ldr.addData(rnd.nextInt(10000), new TestObject(rnd.nextInt(10000))); - - cnt.add(1); - } - - return null; - } - }, - THREAD_CNT - ); - - for (int i = 0; i < 30 && !f.isDone(); i++) - Thread.sleep(1000); - - flag.set(true); - - f.get(); - } - - info("Operations in 30 sec: " + cnt.sum()); - } - - /** - */ - private static class TestObject implements PortableMarshalAware, Serializable { - /** */ - private int val; - - /** - */ - private TestObject() { - // No-op. - } - - /** - * @param val Value. - */ - private TestObject(int val) { - this.val = val; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return val; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object obj) { - return obj instanceof TestObject && ((TestObject)obj).val == val; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeInt("val", val); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - val = reader.readInt("val"); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/35b6d61f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractMultiThreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractMultiThreadedSelfTest.java deleted file mode 100644 index 67f0e52..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractMultiThreadedSelfTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.portable; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableTypeConfiguration; -import org.apache.ignite.portable.PortableWriter; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.jsr166.LongAdder8; - -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; - -/** - * Test for portable objects stored in cache. - */ -public abstract class GridCachePortableObjectsAbstractMultiThreadedSelfTest extends GridCommonAbstractTest { - /** */ - private static final int THREAD_CNT = 64; - - /** */ - private static final AtomicInteger idxGen = new AtomicInteger(); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - CacheConfiguration cacheCfg = new CacheConfiguration(); - - cacheCfg.setCacheMode(cacheMode()); - cacheCfg.setAtomicityMode(atomicityMode()); - cacheCfg.setNearConfiguration(nearConfiguration()); - cacheCfg.setWriteSynchronizationMode(writeSynchronizationMode()); - - cfg.setCacheConfiguration(cacheCfg); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setTypeConfigurations(Arrays.asList( - new PortableTypeConfiguration(TestObject.class.getName()))); - - cfg.setMarshaller(marsh); - - return cfg; - } - - /** - * @return Sync mode. - */ - protected CacheWriteSynchronizationMode writeSynchronizationMode() { - return PRIMARY_SYNC; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGridsMultiThreaded(gridCount()); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** - * @return Cache mode. - */ - protected abstract CacheMode cacheMode(); - - /** - * @return Atomicity mode. - */ - protected abstract CacheAtomicityMode atomicityMode(); - - /** - * @return Distribution mode. - */ - protected abstract NearCacheConfiguration nearConfiguration(); - - /** - * @return Grid count. - */ - protected int gridCount() { - return 1; - } - - /** - * @throws Exception If failed. - */ - @SuppressWarnings("BusyWait") public void testGetPut() throws Exception { - final AtomicBoolean flag = new AtomicBoolean(); - - final LongAdder8 cnt = new LongAdder8(); - - IgniteInternalFuture<?> f = multithreadedAsync( - new Callable<Object>() { - @Override public Object call() throws Exception { - int threadId = idxGen.getAndIncrement() % 2; - - ThreadLocalRandom rnd = ThreadLocalRandom.current(); - - while (!flag.get()) { - IgniteCache<Object, Object> c = jcache(rnd.nextInt(gridCount())); - - switch (threadId) { - case 0: - // Put/get/remove portable -> portable. - - c.put(new TestObject(rnd.nextInt(10000)), new TestObject(rnd.nextInt(10000))); - - IgniteCache<Object, Object> p2 = ((IgniteCacheProxy<Object, Object>)c).keepPortable(); - - PortableObject v = (PortableObject)p2.get(new TestObject(rnd.nextInt(10000))); - - if (v != null) - v.deserialize(); - - c.remove(new TestObject(rnd.nextInt(10000))); - - break; - - case 1: - // Put/get int -> portable. - c.put(rnd.nextInt(10000), new TestObject(rnd.nextInt(10000))); - - IgniteCache<Integer, PortableObject> p4 = ((IgniteCacheProxy<Object, Object>)c).keepPortable(); - - PortableObject v1 = p4.get(rnd.nextInt(10000)); - - if (v1 != null) - v1.deserialize(); - - p4.remove(rnd.nextInt(10000)); - - break; - - default: - assert false; - } - - cnt.add(3); - } - - return null; - } - }, - THREAD_CNT - ); - - for (int i = 0; i < 30 && !f.isDone(); i++) - Thread.sleep(1000); - - flag.set(true); - - f.get(); - - info("Operations in 30 sec: " + cnt.sum()); - } - - /** - */ - private static class TestObject implements PortableMarshalAware, Serializable { - /** */ - private int val; - - /** - */ - private TestObject() { - // No-op. - } - - /** - * @param val Value. - */ - private TestObject(int val) { - this.val = val; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return val; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object obj) { - return obj instanceof TestObject && ((TestObject)obj).val == val; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeInt("val", val); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - val = reader.readInt("val"); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/35b6d61f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java deleted file mode 100644 index 5213d21..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java +++ /dev/null @@ -1,981 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.portable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import javax.cache.Cache; -import javax.cache.processor.EntryProcessor; -import javax.cache.processor.MutableEntry; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgnitePortables; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.cache.store.CacheStoreAdapter; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.internal.portable.PortableObjectImpl; -import org.apache.ignite.internal.processors.cache.GridCacheAdapter; -import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; -import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; -import org.apache.ignite.internal.util.typedef.P2; -import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.transactions.Transaction; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; -import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; -import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; - -/** - * Test for portable objects stored in cache. - */ -public abstract class GridCachePortableObjectsAbstractSelfTest extends GridCommonAbstractTest { - /** */ - public static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final int ENTRY_CNT = 100; - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - - CacheConfiguration cacheCfg = new CacheConfiguration(); - - cacheCfg.setCacheMode(cacheMode()); - cacheCfg.setAtomicityMode(atomicityMode()); - cacheCfg.setNearConfiguration(nearConfiguration()); - cacheCfg.setWriteSynchronizationMode(FULL_SYNC); - cacheCfg.setCacheStoreFactory(singletonFactory(new TestStore())); - cacheCfg.setReadThrough(true); - cacheCfg.setWriteThrough(true); - cacheCfg.setLoadPreviousValue(true); - cacheCfg.setBackups(1); - - if (offheapTiered()) { - cacheCfg.setMemoryMode(OFFHEAP_TIERED); - cacheCfg.setOffHeapMaxMemory(0); - } - - cfg.setCacheConfiguration(cacheCfg); - - cfg.setMarshaller(new PortableMarshaller()); - - return cfg; - } - - /** - * @return {@code True} if should use OFFHEAP_TIERED mode. - */ - protected boolean offheapTiered() { - return false; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGridsMultiThreaded(gridCount()); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - for (int i = 0; i < gridCount(); i++) { - GridCacheAdapter<Object, Object> c = ((IgniteKernal)grid(i)).internalCache(); - - for (GridCacheEntryEx e : c.map().entries0()) { - Object key = e.key().value(c.context().cacheObjectContext(), false); - Object val = CU.value(e.rawGet(), c.context(), false); - - if (key instanceof PortableObject) - assert ((PortableObjectImpl)key).detached() : val; - - if (val instanceof PortableObject) - assert ((PortableObjectImpl)val).detached() : val; - } - } - - IgniteCache<Object, Object> c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) - c.remove(i); - - if (offheapTiered()) { - for (int k = 0; k < 100; k++) - c.remove(k); - } - - assertEquals(0, c.size()); - } - - /** - * @return Cache mode. - */ - protected abstract CacheMode cacheMode(); - - /** - * @return Atomicity mode. - */ - protected abstract CacheAtomicityMode atomicityMode(); - - /** - * @return Distribution mode. - */ - protected abstract NearCacheConfiguration nearConfiguration(); - - /** - * @return Grid count. - */ - protected abstract int gridCount(); - - /** - * @throws Exception If failed. - */ - @SuppressWarnings("unchecked") - public void testCircularReference() throws Exception { - IgniteCache c = keepPortableCache(); - - TestReferenceObject obj1 = new TestReferenceObject(); - - obj1.obj = new TestReferenceObject(obj1); - - c.put(1, obj1); - - PortableObject po = (PortableObject)c.get(1); - - String str = po.toString(); - - log.info("toString: " + str); - - assertNotNull(str); - - assertTrue("Unexpected toString: " + str, - str.startsWith("TestReferenceObject") && str.contains("obj=TestReferenceObject [")); - - TestReferenceObject obj1_r = po.deserialize(); - - assertNotNull(obj1_r); - - TestReferenceObject obj2_r = obj1_r.obj; - - assertNotNull(obj2_r); - - assertSame(obj1_r, obj2_r.obj); - } - - /** - * @throws Exception If failed. - */ - public void testGet() throws Exception { - IgniteCache<Integer, TestObject> c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; i++) { - TestObject obj = c.get(i); - - assertEquals(i, obj.val); - } - - IgniteCache<Integer, PortableObject> kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; i++) { - PortableObject po = kpc.get(i); - - assertEquals(i, (int)po.field("val")); - } - } - - /** - * @throws Exception If failed. - */ - public void testIterator() throws Exception { - IgniteCache<Integer, TestObject> c = jcache(0); - - Map<Integer, TestObject> entries = new HashMap<>(); - - for (int i = 0; i < ENTRY_CNT; i++) { - TestObject val = new TestObject(i); - - c.put(i, val); - - entries.put(i, val); - } - - IgniteCache<Integer, PortableObject> prj = ((IgniteCacheProxy)c).keepPortable(); - - Iterator<Cache.Entry<Integer, PortableObject>> it = prj.iterator(); - - assertTrue(it.hasNext()); - - while (it.hasNext()) { - Cache.Entry<Integer, PortableObject> entry = it.next(); - - assertTrue(entries.containsKey(entry.getKey())); - - TestObject o = entries.get(entry.getKey()); - - PortableObject po = entry.getValue(); - - assertEquals(o.val, (int)po.field("val")); - - entries.remove(entry.getKey()); - } - - assertEquals(0, entries.size()); - } - - /** - * @throws Exception If failed. - */ - public void testCollection() throws Exception { - IgniteCache<Integer, Collection<TestObject>> c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) { - Collection<TestObject> col = new ArrayList<>(3); - - for (int j = 0; j < 3; j++) - col.add(new TestObject(i * 10 + j)); - - c.put(i, col); - } - - for (int i = 0; i < ENTRY_CNT; i++) { - Collection<TestObject> col = c.get(i); - - assertEquals(3, col.size()); - - Iterator<TestObject> it = col.iterator(); - - for (int j = 0; j < 3; j++) { - assertTrue(it.hasNext()); - - assertEquals(i * 10 + j, it.next().val); - } - } - - IgniteCache<Integer, Collection<PortableObject>> kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; i++) { - Collection<PortableObject> col = kpc.get(i); - - assertEquals(3, col.size()); - - Iterator<PortableObject> it = col.iterator(); - - for (int j = 0; j < 3; j++) { - assertTrue(it.hasNext()); - - assertEquals(i * 10 + j, (int)it.next().field("val")); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testMap() throws Exception { - IgniteCache<Integer, Map<Integer, TestObject>> c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) { - Map<Integer, TestObject> map = U.newHashMap(3); - - for (int j = 0; j < 3; j++) { - int idx = i * 10 + j; - - map.put(idx, new TestObject(idx)); - } - - c.put(i, map); - } - - for (int i = 0; i < ENTRY_CNT; i++) { - Map<Integer, TestObject> map = c.get(i); - - assertEquals(3, map.size()); - - for (int j = 0; j < 3; j++) { - int idx = i * 10 + j; - - assertEquals(idx, map.get(idx).val); - } - } - - IgniteCache<Integer, Map<Integer, PortableObject>> kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; i++) { - Map<Integer, PortableObject> map = kpc.get(i); - - assertEquals(3, map.size()); - - for (int j = 0; j < 3; j++) { - int idx = i * 10 + j; - - assertEquals(idx, (int)map.get(idx).field("val")); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAsync() throws Exception { - IgniteCache<Integer, TestObject> c = jcache(0); - - IgniteCache<Integer, TestObject> cacheAsync = c.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; i++) { - cacheAsync.get(i); - - TestObject obj = cacheAsync.<TestObject>future().get(); - - assertNotNull(obj); - - assertEquals(i, obj.val); - } - - IgniteCache<Integer, PortableObject> kpc = keepPortableCache(); - - IgniteCache<Integer, PortableObject> cachePortableAsync = kpc.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) { - cachePortableAsync.get(i); - - PortableObject po = cachePortableAsync.<PortableObject>future().get(); - - assertEquals(i, (int)po.field("val")); - } - } - - /** - * @throws Exception If failed. - */ - public void testGetTx() throws Exception { - if (atomicityMode() != TRANSACTIONAL) - return; - - IgniteCache<Integer, TestObject> c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - TestObject obj = c.get(i); - - assertEquals(i, obj.val); - - tx.commit(); - } - } - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { - TestObject obj = c.get(i); - - assertEquals(i, obj.val); - - tx.commit(); - } - } - - IgniteCache<Integer, PortableObject> kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - PortableObject po = kpc.get(i); - - assertEquals(i, (int)po.field("val")); - - tx.commit(); - } - } - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { - PortableObject po = kpc.get(i); - - assertEquals(i, (int)po.field("val")); - - tx.commit(); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAsyncTx() throws Exception { - if (atomicityMode() != TRANSACTIONAL) - return; - - IgniteCache<Integer, TestObject> c = jcache(0); - - IgniteCache<Integer, TestObject> cacheAsync = c.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - cacheAsync.get(i); - - TestObject obj = cacheAsync.<TestObject>future().get(); - - assertEquals(i, obj.val); - - tx.commit(); - } - } - - IgniteCache<Integer, PortableObject> kpc = keepPortableCache(); - IgniteCache<Integer, PortableObject> cachePortableAsync = kpc.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - cachePortableAsync.get(i); - - PortableObject po = cachePortableAsync.<PortableObject>future().get(); - - assertEquals(i, (int)po.field("val")); - - tx.commit(); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAll() throws Exception { - IgniteCache<Integer, TestObject> c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; ) { - Set<Integer> keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - Map<Integer, TestObject> objs = c.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry<Integer, TestObject> e : objs.entrySet()) - assertEquals(e.getKey().intValue(), e.getValue().val); - } - - IgniteCache<Integer, PortableObject> kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; ) { - Set<Integer> keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - Map<Integer, PortableObject> objs = kpc.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry<Integer, PortableObject> e : objs.entrySet()) - assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAllAsync() throws Exception { - IgniteCache<Integer, TestObject> c = jcache(0); - - IgniteCache<Integer, TestObject> cacheAsync = c.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; ) { - Set<Integer> keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - cacheAsync.getAll(keys); - - Map<Integer, TestObject> objs = cacheAsync.<Map<Integer, TestObject>>future().get(); - - assertEquals(10, objs.size()); - - for (Map.Entry<Integer, TestObject> e : objs.entrySet()) - assertEquals(e.getKey().intValue(), e.getValue().val); - } - - IgniteCache<Integer, PortableObject> kpc = keepPortableCache(); - IgniteCache<Integer, PortableObject> cachePortableAsync = kpc.withAsync(); - - for (int i = 0; i < ENTRY_CNT; ) { - Set<Integer> keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - - cachePortableAsync.getAll(keys); - - Map<Integer, PortableObject> objs = cachePortableAsync.<Map<Integer, PortableObject>>future().get(); - - assertEquals(10, objs.size()); - - for (Map.Entry<Integer, PortableObject> e : objs.entrySet()) - assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAllTx() throws Exception { - if (atomicityMode() != TRANSACTIONAL) - return; - - IgniteCache<Integer, TestObject> c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; ) { - Set<Integer> keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - Map<Integer, TestObject> objs = c.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry<Integer, TestObject> e : objs.entrySet()) - assertEquals(e.getKey().intValue(), e.getValue().val); - - tx.commit(); - } - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { - Map<Integer, TestObject> objs = c.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry<Integer, TestObject> e : objs.entrySet()) - assertEquals(e.getKey().intValue(), e.getValue().val); - - tx.commit(); - } - } - - IgniteCache<Integer, PortableObject> kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; ) { - Set<Integer> keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - Map<Integer, PortableObject> objs = kpc.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry<Integer, PortableObject> e : objs.entrySet()) - assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); - - tx.commit(); - } - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { - Map<Integer, PortableObject> objs = kpc.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry<Integer, PortableObject> e : objs.entrySet()) - assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); - - tx.commit(); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAllAsyncTx() throws Exception { - if (atomicityMode() != TRANSACTIONAL) - return; - - IgniteCache<Integer, TestObject> c = jcache(0); - IgniteCache<Integer, TestObject> cacheAsync = c.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; ) { - Set<Integer> keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - cacheAsync.getAll(keys); - - Map<Integer, TestObject> objs = cacheAsync.<Map<Integer, TestObject>>future().get(); - - assertEquals(10, objs.size()); - - for (Map.Entry<Integer, TestObject> e : objs.entrySet()) - assertEquals(e.getKey().intValue(), e.getValue().val); - - tx.commit(); - } - } - - IgniteCache<Integer, PortableObject> cache = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; ) { - Set<Integer> keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - IgniteCache<Integer, PortableObject> asyncCache = cache.withAsync(); - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - asyncCache.getAll(keys); - - Map<Integer, PortableObject> objs = asyncCache.<Map<Integer, PortableObject>>future().get(); - - assertEquals(10, objs.size()); - - for (Map.Entry<Integer, PortableObject> e : objs.entrySet()) - assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); - - tx.commit(); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testLoadCache() throws Exception { - for (int i = 0; i < gridCount(); i++) - jcache(i).localLoadCache(null); - - IgniteCache<Integer, TestObject> cache = jcache(0); - - assertEquals(3, cache.size(CachePeekMode.PRIMARY)); - - assertEquals(1, cache.get(1).val); - assertEquals(2, cache.get(2).val); - assertEquals(3, cache.get(3).val); - } - - /** - * @throws Exception If failed. - */ - public void testLoadCacheAsync() throws Exception { - for (int i = 0; i < gridCount(); i++) { - IgniteCache<Object, Object> jcache = jcache(i).withAsync(); - - jcache.loadCache(null); - - jcache.future().get(); - } - - IgniteCache<Integer, TestObject> cache = jcache(0); - - assertEquals(3, cache.size(CachePeekMode.PRIMARY)); - - assertEquals(1, cache.get(1).val); - assertEquals(2, cache.get(2).val); - assertEquals(3, cache.get(3).val); - } - - /** - * @throws Exception If failed. - */ - public void testLoadCacheFilteredAsync() throws Exception { - for (int i = 0; i < gridCount(); i++) { - IgniteCache<Integer, TestObject> c = this.<Integer, TestObject>jcache(i).withAsync(); - - c.loadCache(new P2<Integer, TestObject>() { - @Override public boolean apply(Integer key, TestObject val) { - return val.val < 3; - } - }); - - c.future().get(); - } - - IgniteCache<Integer, TestObject> cache = jcache(0); - - assertEquals(2, cache.size(CachePeekMode.PRIMARY)); - - assertEquals(1, cache.get(1).val); - assertEquals(2, cache.get(2).val); - - assertNull(cache.get(3)); - } - - /** - * @throws Exception If failed. - */ - public void testTransform() throws Exception { - IgniteCache<Integer, PortableObject> c = keepPortableCache(); - - checkTransform(primaryKey(c)); - - if (cacheMode() != CacheMode.LOCAL) { - checkTransform(backupKey(c)); - - if (nearConfiguration() != null) - checkTransform(nearKey(c)); - } - } - - /** - * @return Cache with keep portable flag. - */ - private <K, V> IgniteCache<K, V> keepPortableCache() { - return ignite(0).cache(null).withKeepPortable(); - } - - /** - * @param key Key. - * @throws Exception If failed. - */ - private void checkTransform(Integer key) throws Exception { - log.info("Transform: " + key); - - IgniteCache<Integer, PortableObject> c = keepPortableCache(); - - try { - c.invoke(key, new EntryProcessor<Integer, PortableObject, Void>() { - @Override public Void process(MutableEntry<Integer, PortableObject> e, Object... args) { - PortableObject val = e.getValue(); - - assertNull("Unexpected value: " + val, val); - - return null; - } - }); - - jcache(0).put(key, new TestObject(1)); - - c.invoke(key, new EntryProcessor<Integer, PortableObject, Void>() { - @Override public Void process(MutableEntry<Integer, PortableObject> e, Object... args) { - PortableObject val = e.getValue(); - - assertNotNull("Unexpected value: " + val, val); - - assertEquals(new Integer(1), val.field("val")); - - Ignite ignite = e.unwrap(Ignite.class); - - IgnitePortables portables = ignite.portables(); - - PortableBuilder builder = portables.builder(val); - - builder.setField("val", 2); - - e.setValue(builder.build()); - - return null; - } - }); - - PortableObject obj = c.get(key); - - assertEquals(new Integer(2), obj.field("val")); - - c.invoke(key, new EntryProcessor<Integer, PortableObject, Void>() { - @Override public Void process(MutableEntry<Integer, PortableObject> e, Object... args) { - PortableObject val = e.getValue(); - - assertNotNull("Unexpected value: " + val, val); - - assertEquals(new Integer(2), val.field("val")); - - e.setValue(val); - - return null; - } - }); - - obj = c.get(key); - - assertEquals(new Integer(2), obj.field("val")); - - c.invoke(key, new EntryProcessor<Integer, PortableObject, Void>() { - @Override public Void process(MutableEntry<Integer, PortableObject> e, Object... args) { - PortableObject val = e.getValue(); - - assertNotNull("Unexpected value: " + val, val); - - assertEquals(new Integer(2), val.field("val")); - - e.remove(); - - return null; - } - }); - - assertNull(c.get(key)); - } - finally { - c.remove(key); - } - } - - /** - * - */ - private static class TestObject implements PortableMarshalAware { - /** */ - private int val; - - /** - */ - private TestObject() { - // No-op. - } - - /** - * @param val Value. - */ - private TestObject(int val) { - this.val = val; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeInt("val", val); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - val = reader.readInt("val"); - } - } - - /** - * - */ - private static class TestReferenceObject implements PortableMarshalAware { - /** */ - private TestReferenceObject obj; - - /** - */ - private TestReferenceObject() { - // No-op. - } - - /** - * @param obj Object. - */ - private TestReferenceObject(TestReferenceObject obj) { - this.obj = obj; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeObject("obj", obj); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - obj = reader.readObject("obj"); - } - } - - /** - * - */ - private static class TestStore extends CacheStoreAdapter<Integer, Object> { - /** {@inheritDoc} */ - @Override public void loadCache(IgniteBiInClosure<Integer, Object> clo, Object... args) { - for (int i = 1; i <= 3; i++) - clo.apply(i, new TestObject(i)); - } - - /** {@inheritDoc} */ - @Nullable @Override public Object load(Integer key) { - return null; - } - - /** {@inheritDoc} */ - @Override public void write(Cache.Entry<? extends Integer, ?> e) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void delete(Object key) { - // No-op. - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/35b6d61f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStorePortablesSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStorePortablesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStorePortablesSelfTest.java index 5c0fc8e..3a7f8fb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStorePortablesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStorePortablesSelfTest.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.cache.portable; import java.util.Map; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.igniteobject.IgniteObject; /** * Tests for cache store with portables. @@ -47,9 +47,9 @@ public class GridCachePortableStorePortablesSelfTest extends GridCachePortableSt for (int idx : idxs) { Object val = map.get(portable(new Key(idx))); - assertTrue(String.valueOf(val), val instanceof PortableObject); + assertTrue(String.valueOf(val), val instanceof IgniteObject); - PortableObject po = (PortableObject)val; + IgniteObject po = (IgniteObject)val; assertEquals("Value", po.metaData().typeName()); assertEquals(new Integer(idx), po.field("idx")); http://git-wip-us.apache.org/repos/asf/ignite/blob/35b6d61f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java index 0db650e..5799017 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java @@ -25,8 +25,8 @@ import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.MarshallerContextTestImpl; import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMetadata; +import org.apache.ignite.igniteobject.IgniteObjectException; +import org.apache.ignite.igniteobject.IgniteObjectMetadata; /** * @@ -39,11 +39,11 @@ public class GridPortableCacheEntryMemorySizeSelfTest extends GridCacheEntryMemo marsh.setContext(new MarshallerContextTestImpl(null)); PortableContext pCtx = new PortableContext(new PortableMetaDataHandler() { - @Override public void addMeta(int typeId, PortableMetadata meta) throws PortableException { + @Override public void addMeta(int typeId, IgniteObjectMetadata meta) throws IgniteObjectException { // No-op } - @Override public PortableMetadata metadata(int typeId) throws PortableException { + @Override public IgniteObjectMetadata metadata(int typeId) throws IgniteObjectException { return null; } }, null); http://git-wip-us.apache.org/repos/asf/ignite/blob/35b6d61f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java index a1a623b..1ba8136 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java @@ -31,7 +31,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.igniteobject.IgniteObject; /** * Tests that portable object is the same in cache entry and in index. @@ -96,9 +96,9 @@ public abstract class GridPortableDuplicateIndexObjectsAbstractSelfTest extends cache.put(key, new TestPortable(fieldOneVal, fieldTwoVal)); - IgniteCache<Integer, PortableObject> prj = grid(0).cache(null).withKeepPortable(); + IgniteCache<Integer, IgniteObject> prj = grid(0).cache(null).withKeepBinary(); - PortableObject cacheVal = prj.get(key); + IgniteObject cacheVal = prj.get(key); assertEquals(fieldOneVal, cacheVal.field("fieldOne")); assertEquals(new Integer(fieldTwoVal), cacheVal.field("fieldTwo")); @@ -108,7 +108,7 @@ public abstract class GridPortableDuplicateIndexObjectsAbstractSelfTest extends assertEquals(1, row.size()); - PortableObject qryVal = (PortableObject)row.get(0); + IgniteObject qryVal = (IgniteObject)row.get(0); assertEquals(fieldOneVal, qryVal.field("fieldOne")); assertEquals(new Integer(fieldTwoVal), qryVal.field("fieldTwo")); http://git-wip-us.apache.org/repos/asf/ignite/blob/35b6d61f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java index 836440a..ad21a47 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java @@ -23,7 +23,7 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorSelfTest; import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.igniteobject.IgniteObject; import org.apache.ignite.stream.StreamReceiver; /** @@ -55,9 +55,9 @@ public class DataStreamProcessorPortableSelfTest extends DataStreamProcessorSelf Collection<Map.Entry<String, TestObject>> entries) { for (Map.Entry<String, TestObject> e : entries) { assertTrue(e.getKey() instanceof String); - assertTrue(e.getValue() instanceof PortableObject); + assertTrue(e.getValue() instanceof IgniteObject); - TestObject obj = ((PortableObject)e.getValue()).deserialize(); + TestObject obj = ((IgniteObject)e.getValue()).deserialize(); cache.put(e.getKey(), new TestObject(obj.val + 1)); }
