Fix Cache.localEntries() for binary marshaller.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a3a8138a Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a3a8138a Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a3a8138a Branch: refs/heads/ignite-1537 Commit: a3a8138a255608f9bc87c7d60108f2ac241fad85 Parents: 3ec44ba Author: ashutak <ashu...@gridgain.com> Authored: Mon Dec 14 19:24:48 2015 +0300 Committer: ashutak <ashu...@gridgain.com> Committed: Mon Dec 14 19:24:48 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheAdapter.java | 9 +-- .../BinaryAtomicCacheLocalEntriesSelfTest.java | 30 +++++++ .../BinaryTxCacheLocalEntriesSelfTest.java | 84 ++++++++++++++++++++ .../IgniteBinaryObjectsTestSuite.java | 23 +++--- 4 files changed, 130 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/a3a8138a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index ea57caf..cc4e962 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -4753,13 +4753,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V KeyCacheObject key = entry.key(); - Object key0 = key.value(ctx.cacheObjectContext(), true); - Object val0 = val.value(ctx.cacheObjectContext(), true); - - if (deserializeBinary) { - key0 = ctx.unwrapBinaryIfNeeded(key0, true); - val0 = ctx.unwrapBinaryIfNeeded(val0, true); - } + Object key0 = ctx.unwrapBinaryIfNeeded(key, !deserializeBinary, true); + Object val0 = ctx.unwrapBinaryIfNeeded(val, !deserializeBinary, true); return new CacheEntryImpl<>((K)key0, (V)val0, entry.version()); } http://git-wip-us.apache.org/repos/asf/ignite/blob/a3a8138a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryAtomicCacheLocalEntriesSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryAtomicCacheLocalEntriesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryAtomicCacheLocalEntriesSelfTest.java new file mode 100644 index 0000000..41a4286 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryAtomicCacheLocalEntriesSelfTest.java @@ -0,0 +1,30 @@ +/* +* 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 org.apache.ignite.cache.CacheAtomicityMode; + +/** + * + */ +public class BinaryAtomicCacheLocalEntriesSelfTest extends BinaryTxCacheLocalEntriesSelfTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/a3a8138a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryTxCacheLocalEntriesSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryTxCacheLocalEntriesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryTxCacheLocalEntriesSelfTest.java new file mode 100644 index 0000000..aa25caf --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryTxCacheLocalEntriesSelfTest.java @@ -0,0 +1,84 @@ +/* +* 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 org.apache.ignite.IgniteCache; +import org.apache.ignite.binary.BinaryObject; +import org.apache.ignite.cache.CachePeekMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; + +/** + * + */ +public class BinaryTxCacheLocalEntriesSelfTest extends GridCacheAbstractSelfTest { + /** */ + private static final String FIELD = "user-name"; + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 2; + } + + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration ccfg = super.cacheConfiguration(gridName); + + ccfg.setKeepBinaryInStore(true); + + return ccfg; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + cfg.setMarshaller(new BinaryMarshaller()); + + return cfg; + } + + /** + * @throws Exception If failed. + */ + public void testLocalEntries() throws Exception { + IgniteCache<Integer, BinaryObject> cache = grid(0).cache(null).withKeepBinary(); + + final int ENTRY_CNT = 10; + + for (int i = 0; i < ENTRY_CNT; i++) + cache.put(i, userObject("user-" + i)); + + assertEquals(ENTRY_CNT, cache.localSize(CachePeekMode.ALL)); + + for (int i = 0; i < gridCount(); i++) + jcache(i).withKeepBinary().localEntries(); + + cache.removeAll(); + } + + /** + * @param userName User name. + * @return Binary object. + */ + private BinaryObject userObject(String userName) { + return grid(0).binary().builder("orders").setField(FIELD, userName).build(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/a3a8138a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java index 2b0ad63..9651f6d 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java @@ -19,17 +19,17 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; import org.apache.ignite.internal.binary.BinaryEnumsSelfTest; -import org.apache.ignite.internal.binary.GridBinaryAffinityKeySelfTest; +import org.apache.ignite.internal.binary.BinaryFieldsHeapSelfTest; +import org.apache.ignite.internal.binary.BinaryFieldsOffheapSelfTest; +import org.apache.ignite.internal.binary.BinaryFooterOffsetsHeapSelfTest; +import org.apache.ignite.internal.binary.BinaryFooterOffsetsOffheapSelfTest; +import org.apache.ignite.internal.binary.BinaryMarshallerSelfTest; import org.apache.ignite.internal.binary.BinaryObjectBuilderAdditionalSelfTest; import org.apache.ignite.internal.binary.BinaryObjectBuilderSelfTest; +import org.apache.ignite.internal.binary.GridBinaryAffinityKeySelfTest; import org.apache.ignite.internal.binary.GridBinaryMarshallerCtxDisabledSelfTest; -import org.apache.ignite.internal.binary.BinaryMarshallerSelfTest; import org.apache.ignite.internal.binary.GridBinaryMetaDataSelfTest; import org.apache.ignite.internal.binary.GridBinaryWildcardsSelfTest; -import org.apache.ignite.internal.binary.BinaryFooterOffsetsHeapSelfTest; -import org.apache.ignite.internal.binary.BinaryFooterOffsetsOffheapSelfTest; -import org.apache.ignite.internal.binary.BinaryFieldsHeapSelfTest; -import org.apache.ignite.internal.binary.BinaryFieldsOffheapSelfTest; import org.apache.ignite.internal.binary.noncompact.BinaryFieldsHeapNonCompactSelfTest; import org.apache.ignite.internal.binary.noncompact.BinaryFieldsOffheapNonCompactSelfTest; import org.apache.ignite.internal.binary.noncompact.BinaryFooterOffsetsHeapNonCompactSelfTest; @@ -37,11 +37,10 @@ import org.apache.ignite.internal.binary.noncompact.BinaryFooterOffsetsOffheapNo import org.apache.ignite.internal.binary.noncompact.BinaryMarshallerNonCompactSelfTest; import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderAdditionalNonCompactSelfTest; import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.IgniteBinaryMetadataUpdateChangingTopologySelfTest; +import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSelfTest; +import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest; import org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataMultinodeTest; import org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataTest; -import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest; -import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSelfTest; import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryObjectsAtomicNearDisabledOffheapTieredSelfTest; import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryObjectsAtomicNearDisabledSelfTest; import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryObjectsAtomicOffheapTieredSelfTest; @@ -54,6 +53,9 @@ import org.apache.ignite.internal.processors.cache.binary.distributed.replicated import org.apache.ignite.internal.processors.cache.binary.local.GridCacheBinaryObjectsAtomicLocalSelfTest; import org.apache.ignite.internal.processors.cache.binary.local.GridCacheBinaryObjectsLocalOffheapTieredSelfTest; import org.apache.ignite.internal.processors.cache.binary.local.GridCacheBinaryObjectsLocalSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteBinaryMetadataUpdateChangingTopologySelfTest; +import org.apache.ignite.internal.processors.cache.portable.BinaryAtomicCacheLocalEntriesSelfTest; +import org.apache.ignite.internal.processors.cache.portable.BinaryTxCacheLocalEntriesSelfTest; /** * Test for binary objects stored in cache. @@ -109,6 +111,9 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite { suite.addTestSuite(GridCacheClientNodeBinaryObjectMetadataMultinodeTest.class); suite.addTestSuite(IgniteBinaryMetadataUpdateChangingTopologySelfTest.class); + suite.addTestSuite(BinaryTxCacheLocalEntriesSelfTest.class); + suite.addTestSuite(BinaryAtomicCacheLocalEntriesSelfTest.class); + return suite; } }