ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [21/27] ignite git commit: IGNITE-5223 Allow use local binary metadata cache if it's possible
Date Wed, 31 May 2017 12:28:07 GMT
IGNITE-5223 Allow use local binary metadata cache if it's possible


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/04fadd4a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/04fadd4a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/04fadd4a

Branch: refs/heads/ignite-5232-1.7.2
Commit: 04fadd4a499239176ba21c390d93e30809abb4c1
Parents: 2a818d3
Author: dkarachentsev <dkarachentsev@gridgain.com>
Authored: Tue May 23 15:42:20 2017 +0300
Committer: dkarachentsev <dkarachentsev@gridgain.com>
Committed: Tue May 23 15:42:20 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/IgniteSystemProperties.java   |   8 +
 .../ignite/internal/binary/BinaryContext.java   |   4 +
 .../internal/binary/BinaryReaderExImpl.java     |  23 +-
 .../binary/CacheObjectBinaryProcessorImpl.java  |  98 ++++--
 .../BinaryMarshallerLocalMetadataCacheTest.java | 297 +++++++++++++++++++
 .../IgniteBinaryObjectsTestSuite.java           |   3 +
 6 files changed, 406 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/04fadd4a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index d77b2fb..713defe 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -516,6 +516,14 @@ public final class IgniteSystemProperties {
     public static final String IGNITE_UNWRAP_BINARY_FOR_INDEXING_SPI = "IGNITE_UNWRAP_BINARY_FOR_INDEXING_SPI";
 
     /**
+     * Use local metadata cache instead of distributed one. May be used only when binary
objects schema
+     * are not modified and all classes available on each node. Classes that implements Binarylizable
are
+     * not supported.
+     * @deprecated Should be removed in Apache Ignite 2.0.
+     */
+    public static final String IGNITE_USE_LOCAL_BINARY_MARSHALLER_CACHE = "IGNITE_USE_LOCAL_BINARY_MARSHALLER_CACHE";
+
+    /**
      * Enforces singleton.
      */
     private IgniteSystemProperties() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/04fadd4a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 7b21dfb..9f66b3e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -612,6 +612,7 @@ public class BinaryContext {
 
     /**
      * @param cls Class.
+     * @param deserialize If {@code false}, metadata will be updated.
      * @return Class descriptor.
      * @throws BinaryObjectException In case of error.
      */
@@ -664,6 +665,7 @@ public class BinaryContext {
      * @param userType User type or not.
      * @param typeId Type ID.
      * @param ldr Class loader.
+     * @param deserialize If {@code false}, metadata will be updated.
      * @return Class descriptor.
      */
     public BinaryClassDescriptor descriptorForTypeId(
@@ -719,6 +721,7 @@ public class BinaryContext {
      * Creates and registers {@link BinaryClassDescriptor} for the given {@code class}.
      *
      * @param cls Class.
+     * @param deserialize If {@code false}, metadata will be updated.
      * @return Class descriptor.
      */
     private BinaryClassDescriptor registerClassDescriptor(Class<?> cls, boolean deserialize)
{
@@ -759,6 +762,7 @@ public class BinaryContext {
      * Creates and registers {@link BinaryClassDescriptor} for the given user {@code class}.
      *
      * @param cls Class.
+     * @param deserialize If {@code false}, metadata will be updated.
      * @return Class descriptor.
      */
     private BinaryClassDescriptor registerUserClassDescriptor(Class<?> cls, boolean
deserialize) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/04fadd4a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
index 775f237..ad2e736 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
@@ -26,6 +26,7 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.util.UUID;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.binary.BinaryCollectionFactory;
 import org.apache.ignite.binary.BinaryInvalidTypeException;
 import org.apache.ignite.binary.BinaryMapFactory;
@@ -1722,15 +1723,23 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx,
Bina
             if (fieldIdLen != BinaryUtils.FIELD_ID_LEN) {
                 BinaryTypeImpl type = (BinaryTypeImpl)ctx.metadata(typeId);
 
-                if (type == null || type.metadata() == null)
-                    throw new BinaryObjectException("Cannot find metadata for object with
compact footer: " +
-                        typeId);
+                if (type == null || type.metadata() == null || type.metadata().schemas().isEmpty())
{
+                    if (IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_USE_LOCAL_BINARY_MARSHALLER_CACHE,
false)) {
+                        BinaryClassDescriptor desc = ctx.descriptorForTypeId(true, typeId,
getClass().getClassLoader(), false);
 
-                for (BinarySchema typeSchema : type.metadata().schemas()) {
-                    if (schemaId == typeSchema.schemaId()) {
-                        schema = typeSchema;
+                        schema = desc.schema();
+                    }
+                    else
+                        throw new BinaryObjectException("Cannot find metadata for object
with compact footer: " +
+                            typeId);
+                }
+                else {
+                    for (BinarySchema typeSchema : type.metadata().schemas()) {
+                        if (schemaId == typeSchema.schemaId()) {
+                            schema = typeSchema;
 
-                        break;
+                            break;
+                        }
                     }
                 }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/04fadd4a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index 1d60c42..6b691c2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -39,6 +39,7 @@ import javax.cache.processor.MutableEntry;
 import org.apache.ignite.IgniteBinary;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.binary.BinaryBasicNameMapper;
 import org.apache.ignite.binary.BinaryField;
 import org.apache.ignite.binary.BinaryObject;
@@ -127,6 +128,9 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     private volatile IgniteCacheProxy<BinaryMetadataKey, BinaryMetadata> metaDataCache;
 
     /** */
+    private final ConcurrentHashMap8<BinaryMetadataKey, BinaryMetadata> locMetadataCache;
+
+    /** */
     private final ConcurrentHashMap8<Integer, BinaryTypeImpl> clientMetaDataCache;
 
     /** Predicate to filter binary meta data in utility cache. */
@@ -175,6 +179,10 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
         clientNode = this.ctx.clientNode();
 
         clientMetaDataCache = clientNode ? new ConcurrentHashMap8<Integer, BinaryTypeImpl>()
: null;
+
+        boolean useLocCache = IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_USE_LOCAL_BINARY_MARSHALLER_CACHE,
false);
+
+        locMetadataCache = useLocCache ? new ConcurrentHashMap8<BinaryMetadataKey, BinaryMetadata>()
: null;
     }
 
     /** {@inheritDoc} */
@@ -190,7 +198,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
 
                     BinaryMetadata newMeta0 = ((BinaryTypeImpl)newMeta).metadata();
 
-                    if (metaDataCache == null) {
+                    if (metaDataCache == null && locMetadataCache == null) {
                         BinaryMetadata oldMeta = metaBuf.get(typeId);
                         BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0);
 
@@ -213,13 +221,13 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
                             return;
                     }
 
-                    assert metaDataCache != null;
+                    assert metaDataCache != null || locMetadataCache != null;
 
                     CacheObjectBinaryProcessorImpl.this.addMeta(typeId, newMeta0.wrap(binaryCtx));
                 }
 
                 @Override public BinaryType metadata(int typeId) throws BinaryObjectException
{
-                    if (metaDataCache == null)
+                    if (metaDataCache == null && locMetadataCache == null)
                         U.awaitQuiet(startLatch);
 
                     return CacheObjectBinaryProcessorImpl.this.metadata(typeId);
@@ -289,6 +297,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public void onUtilityCacheStarted() throws IgniteCheckedException {
+        if (locMetadataCache != null) {
+            startLatch.countDown();
+
+            return;
+        }
+
         IgniteCacheProxy<Object, Object> proxy = ctx.cache().jcache(CU.UTILITY_CACHE_NAME);
 
         boolean old = proxy.context().deploy().ignoreOwnership(true);
@@ -573,22 +587,31 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
 
         final BinaryMetadataKey key = new BinaryMetadataKey(typeId);
 
-        try {
-            BinaryMetadata oldMeta = metaDataCache.localPeek(key);
-            BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0);
+        if (locMetadataCache != null) {
+            locMetadataCache.merge(key, newMeta0, new ConcurrentHashMap8.BiFun<BinaryMetadata,
BinaryMetadata, BinaryMetadata>() {
+                @Override public BinaryMetadata apply(BinaryMetadata curMeta, BinaryMetadata
newMeta) {
+                    return BinaryUtils.mergeMetadata(curMeta, newMeta);
+                }
+            });
+        }
+        else {
+            try {
+                BinaryMetadata oldMeta = metaDataCache.localPeek(key);
+                BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0);
 
-            AffinityTopologyVersion topVer = ctx.cache().context().lockedTopologyVersion(null);
+                AffinityTopologyVersion topVer = ctx.cache().context().lockedTopologyVersion(null);
 
-            if (topVer == null)
-                topVer = ctx.cache().context().exchange().readyAffinityVersion();
+                if (topVer == null)
+                    topVer = ctx.cache().context().exchange().readyAffinityVersion();
 
-            BinaryObjectException err = metaDataCache.invoke(topVer, key, new MetadataProcessor(mergedMeta));
+                BinaryObjectException err = metaDataCache.invoke(topVer, key, new MetadataProcessor(mergedMeta));
 
-            if (err != null)
-                throw err;
-        }
-        catch (CacheException e) {
-            throw new BinaryObjectException("Failed to update meta data for type: " + newMeta.typeName(),
e);
+                if (err != null)
+                    throw err;
+            }
+            catch (CacheException e) {
+                throw new BinaryObjectException("Failed to update meta data for type: " +
newMeta.typeName(), e);
+            }
         }
     }
 
@@ -601,17 +624,28 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
                 if (typeMeta != null)
                     return typeMeta;
 
-                BinaryMetadata meta = metaDataCache.getTopologySafe(new BinaryMetadataKey(typeId));
+                BinaryMetadata meta;
+
+                if (locMetadataCache != null)
+                    meta = locMetadataCache.get(new BinaryMetadataKey(typeId));
+                else
+                    meta = metaDataCache.getTopologySafe(new BinaryMetadataKey(typeId));
 
                 return meta != null ? meta.wrap(binaryCtx) : null;
             }
             else {
                 BinaryMetadataKey key = new BinaryMetadataKey(typeId);
 
-                BinaryMetadata meta = metaDataCache.localPeek(key);
+                BinaryMetadata meta;
+
+                if (locMetadataCache != null)
+                    meta = locMetadataCache.get(key);
+                else {
+                    meta = metaDataCache.localPeek(key);
 
-                if (meta == null && !metaDataCache.context().preloader().syncFuture().isDone())
-                    meta = metaDataCache.getTopologySafe(key);
+                    if (meta == null && !metaDataCache.context().preloader().syncFuture().isDone())
+                        meta = metaDataCache.getTopologySafe(key);
+                }
 
                 return meta != null ? meta.wrap(binaryCtx) : null;
             }
@@ -630,7 +664,20 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
             for (Integer typeId : typeIds)
                 keys.add(new BinaryMetadataKey(typeId));
 
-            Map<BinaryMetadataKey, BinaryMetadata> meta = metaDataCache.getAll(keys);
+            Map<BinaryMetadataKey, BinaryMetadata> meta;
+
+            if (locMetadataCache != null) {
+                meta = new HashMap<>();
+
+                for (BinaryMetadataKey key : keys) {
+                    BinaryMetadata metadata = locMetadataCache.get(key);
+
+                    if (metadata != null)
+                        meta.put(key, metadata);
+                }
+            }
+            else
+                meta = metaDataCache.getAll(keys);
 
             Map<Integer, BinaryType> res = U.newHashMap(meta.size());
 
@@ -654,6 +701,17 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
                 }
             });
         else {
+            if (locMetadataCache != null) {
+                ConcurrentHashMap8.ValuesView<BinaryMetadataKey, BinaryMetadata> vals
= locMetadataCache.values();
+
+                ArrayList<BinaryType> res = new ArrayList<>(vals.size());
+
+                for (BinaryMetadata metadata : vals)
+                    res.add(metadata.wrap(binaryCtx));
+
+                return res;
+            }
+
             return F.viewReadOnly(metaDataCache.entrySetx(metaPred),
                 new C1<Cache.Entry<BinaryMetadataKey, BinaryMetadata>, BinaryType>()
{
                     private static final long serialVersionUID = 0L;

http://git-wip-us.apache.org/repos/asf/ignite/blob/04fadd4a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerLocalMetadataCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerLocalMetadataCacheTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerLocalMetadataCacheTest.java
new file mode 100644
index 0000000..ad3c5f3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerLocalMetadataCacheTest.java
@@ -0,0 +1,297 @@
+/*
+ * 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.binary;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.testframework.junits.IgniteTestResources;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests IGNITE_USE_LOCAL_BINARY_MARSHALLER_CACHE property.
+ */
+public class BinaryMarshallerLocalMetadataCacheTest extends GridCommonAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName,
+        IgniteTestResources rsrcs) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName, rsrcs);
+
+        cfg.setMarshaller(new BinaryMarshaller());
+
+        cfg.setClientMode(gridName.startsWith("client"));
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        System.setProperty(IgniteSystemProperties.IGNITE_USE_LOCAL_BINARY_MARSHALLER_CACHE,
"true");
+
+        startGrid(0);
+        startGrid(1);
+        startGrid("client");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        try {
+            stopAllGrids();
+        }
+        finally {
+            System.clearProperty(IgniteSystemProperties.IGNITE_USE_LOCAL_BINARY_MARSHALLER_CACHE);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testComputeLocalMetadata() throws Exception {
+        final BinaryObject obj = grid(0).binary().toBinary(new OptimizedContainer(new Optimized()));
+
+        ClusterGroup remotes = grid(0).cluster().forRemotes();
+
+        OptimizedContainer res = grid(0).compute(remotes).call(new IgniteCallable<OptimizedContainer>()
{
+            @Override public OptimizedContainer call() throws Exception {
+
+                return obj.deserialize();
+            }
+        });
+
+        OptimizedContainer res2 = grid(0).compute(remotes).call(new IgniteCallable<OptimizedContainer>()
{
+            @Override public OptimizedContainer call() throws Exception {
+
+                return obj.deserialize();
+            }
+        });
+
+        System.out.println(res);
+        System.out.println(res2);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCacheLocalMetadata() throws Exception {
+        IgniteCache<Key, Object> cache = grid("client").createCache("cache");
+
+        Map<Key, Object> data = new HashMap<>();
+
+        for (int i = 0; i < 1000; i++)
+            data.put(new Key(i), new OptimizedContainer(new Optimized(String.valueOf(i))));
+
+        for (int i = 1000; i < 2000; i++)
+            data.put(new Key(i), new Simple(i, String.valueOf(i), new BigInteger(String.valueOf(i),
10)));
+
+        cache.putAll(data);
+
+        checkCache(cache, data);
+        checkCache(grid(0).<Key, Object>cache("cache"), data);
+        checkCache(grid(1).<Key, Object>cache("cache"), data);
+    }
+
+    /**
+     * @param cache Cache.
+     * @param data Data.
+     */
+    private void checkCache(IgniteCache<Key, Object> cache,
+        Map<Key, Object> data) {
+        for (Map.Entry<Key, Object> entry : cache.getAll(data.keySet()).entrySet())
+            assertEquals(data.get(entry.getKey()), entry.getValue());
+    }
+
+    /**
+     *
+     */
+    private static class Key {
+        /** */
+        private Integer i;
+
+        /**
+         * @param i I.
+         */
+        public Key(Integer i) {
+            this.i = i;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            Key key = (Key)o;
+
+            return i != null ? i.equals(key.i) : key.i == null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return i != null ? i.hashCode() : 0;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class OptimizedContainer {
+        /** */
+        private Optimized optim;
+
+        /**
+         * @param optim Val.
+         */
+        public OptimizedContainer(Optimized optim) {
+            this.optim = optim;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            OptimizedContainer container = (OptimizedContainer)o;
+
+            return optim != null ? optim.equals(container.optim) : container.optim == null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return optim != null ? optim.hashCode() : 0;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class Optimized implements Externalizable {
+        /** Serial version uid. */
+        private static final long serialVersionUID = 0L;
+
+        /** */
+        private String fld;
+
+        /**
+         * @param fld Fld.
+         */
+        public Optimized(String fld) {
+            this.fld = fld;
+        }
+
+        /**
+         * Default constructor (required by Externalizable).
+         */
+        public Optimized() {
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            U.writeUTFStringNullable(out, fld);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
+            fld = U.readUTFStringNullable(in);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            Optimized optimized = (Optimized)o;
+
+            return fld != null ? fld.equals(optimized.fld) : optimized.fld == null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return fld != null ? fld.hashCode() : 0;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class Simple {
+        /** I. */
+        private int i;
+
+        /** String. */
+        private String str;
+
+        /** Big integer. */
+        private BigInteger bigInteger;
+
+        /**
+         * @param i I.
+         * @param str String.
+         * @param bigInteger Big integer.
+         */
+        public Simple(int i, String str, BigInteger bigInteger) {
+            this.i = i;
+            this.str = str;
+            this.bigInteger = bigInteger;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            Simple simple = (Simple)o;
+
+            if (i != simple.i)
+                return false;
+
+            if (str != null ? !str.equals(simple.str) : simple.str != null)
+                return false;
+
+            return bigInteger != null ? bigInteger.equals(simple.bigInteger) : simple.bigInteger
== null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            int res = i;
+
+            res = 31 * res + (str != null ? str.hashCode() : 0);
+            res = 31 * res + (bigInteger != null ? bigInteger.hashCode() : 0);
+
+            return res;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/04fadd4a/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 c1d9974..29e43e4 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
@@ -26,6 +26,7 @@ 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.BinaryMarshallerLocalMetadataCacheTest;
 import org.apache.ignite.internal.binary.BinaryMarshallerSelfTest;
 import org.apache.ignite.internal.binary.BinaryObjectBuilderAdditionalSelfTest;
 import org.apache.ignite.internal.binary.BinaryObjectBuilderDefaultMappersSelfTest;
@@ -147,6 +148,8 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
 
         suite.addTestSuite(GridCacheBinaryObjectUserClassloaderSelfTest.class);
 
+        suite.addTestSuite(BinaryMarshallerLocalMetadataCacheTest.class);
+
         return suite;
     }
 }


Mime
View raw message