You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/11/19 15:08:02 UTC

[13/13] ignite git commit: Merge branch ignite-1282 into ignite-1945

Merge branch ignite-1282 into ignite-1945


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

Branch: refs/heads/ignite-1945
Commit: a511fa178d0e1c0cbc6587141a87daa134e36c4b
Parents: 29e586f 5ea0625
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Nov 19 17:07:35 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Nov 19 17:07:35 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/binary/BinaryObject.java  |    6 +-
 .../apache/ignite/internal/IgniteKernal.java    |    6 +
 .../ignite/internal/IgniteNodeAttributes.java   |    3 +
 .../portable/BinaryCachingMetadataHandler.java  |   70 +
 .../internal/portable/BinaryMetadata.java       |   16 +-
 .../portable/BinaryMetadataCollector.java       |   49 +-
 .../internal/portable/BinaryObjectEx.java       |    2 +-
 .../internal/portable/BinaryObjectImpl.java     |   14 +-
 .../portable/BinaryObjectOffheapImpl.java       |   14 +-
 .../internal/portable/BinaryReaderExImpl.java   |  132 +-
 .../internal/portable/BinaryTypeImpl.java       |    7 +-
 .../internal/portable/BinaryWriterExImpl.java   |  161 +-
 .../portable/PortableClassDescriptor.java       |  102 +-
 .../internal/portable/PortableContext.java      |   66 +-
 .../internal/portable/PortableSchema.java       |  296 +-
 .../ignite/internal/portable/PortableUtils.java |  457 ++-
 .../builder/BinaryObjectBuilderImpl.java        |  130 +-
 .../portable/builder/PortableBuilderReader.java |   21 +-
 .../portable/CacheObjectBinaryProcessor.java    |    2 +-
 .../CacheObjectBinaryProcessorImpl.java         |  162 +-
 .../platform/PlatformContextImpl.java           |   10 +-
 .../cpp/PlatformCppConfigurationClosure.java    |    7 +
 .../PlatformDotNetConfigurationClosure.java     |    9 +-
 .../ignite/internal/util/IgniteUtils.java       |   25 +
 .../ignite/spi/discovery/tcp/ServerImpl.java    |   51 +-
 .../portable/BinaryFieldsAbstractSelfTest.java  |   13 +-
 .../BinaryFooterOffsetsAbstractSelfTest.java    |  206 +
 .../BinaryFooterOffsetsHeapSelfTest.java        |   32 +
 .../BinaryFooterOffsetsOffheapSelfTest.java     |   61 +
 .../portable/BinaryMarshallerSelfTest.java      | 3687 ++++++++++++++++++
 .../BinaryObjectBuilderAdditionalSelfTest.java  | 1292 ++++++
 .../portable/BinaryObjectBuilderSelfTest.java   | 1069 +++++
 ...idBinaryObjectBuilderAdditionalSelfTest.java | 1281 ------
 .../GridBinaryObjectBuilderSelfTest.java        | 1056 -----
 ...idPortableMarshallerCtxDisabledSelfTest.java |    2 +-
 .../GridPortableMarshallerSelfTest.java         | 3672 -----------------
 .../PortableCompactOffsetsAbstractSelfTest.java |  197 -
 .../PortableCompactOffsetsHeapSelfTest.java     |   32 -
 .../PortableCompactOffsetsOffheapSelfTest.java  |   61 -
 .../BinaryFieldsHeapNonCompactSelfTest.java     |   34 +
 .../BinaryFieldsOffheapNonCompactSelfTest.java  |   30 +
 ...naryFooterOffsetsHeapNonCompactSelfTest.java |   30 +
 ...yFooterOffsetsOffheapNonCompactSelfTest.java |   30 +
 .../BinaryMarshallerNonCompactSelfTest.java     |   30 +
 ...jectBuilderAdditionalNonCompactSelfTest.java |   30 +
 .../BinaryObjectBuilderNonCompactSelfTest.java  |   30 +
 .../IgnitePortableObjectsTestSuite.java         |   36 +-
 .../query/IgniteSqlSplitterSelfTest.java        |   54 +
 .../platforms/cpp/common/include/Makefile.am    |    3 +
 .../cpp/common/os/linux/include/Makefile.am     |    3 +
 .../core-test/src/binary_reader_writer_test.cpp |   64 +-
 modules/platforms/cpp/core/include/Makefile.am  |    3 +
 .../include/ignite/impl/binary/binary_common.h  |   22 +-
 .../ignite/impl/binary/binary_reader_impl.h     |   58 +-
 .../include/ignite/impl/binary/binary_schema.h  |    6 +-
 .../ignite/impl/binary/binary_writer_impl.h     |    2 +-
 .../cpp/core/os/linux/include/Makefile.am       |    3 +
 .../core/src/impl/binary/binary_reader_impl.cpp |    8 +-
 .../cpp/core/src/impl/binary/binary_schema.cpp  |   12 +-
 .../core/src/impl/binary/binary_writer_impl.cpp |   29 +-
 .../Config/Compute/compute-grid1.xml            |    1 +
 .../Config/marshaller-explicit.xml              |    4 +-
 .../Impl/Binary/BinaryObjectBuilder.cs          |   25 +-
 .../Impl/Binary/BinaryObjectHeader.cs           |  131 +-
 .../Impl/Binary/BinaryObjectSchemaHolder.cs     |    9 +-
 .../Impl/Binary/BinaryReader.cs                 |    2 +-
 .../Impl/Binary/BinaryWriter.cs                 |   27 +-
 .../Impl/Binary/IgniteBinary.cs                 |    3 +-
 68 files changed, 8087 insertions(+), 7111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index e37275d,8543ce6..01bfcaa
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@@ -91,9 -96,18 +95,15 @@@ public class PortableClassDescriptor 
      private final Method readResolveMtd;
  
      /** */
-     private final Map<String, Integer> fieldsMeta;
+     private final Map<String, Integer> stableFieldsMeta;
+ 
+     /** Object schemas. Initialized only for serializable classes and contains only 1 entry. */
+     private final Collection<PortableSchema> stableSchemas;
+ 
+     /** Schema registry. */
+     private final PortableSchemaRegistry schemaReg;
  
      /** */
 -    private final boolean keepDeserialized;
 -
 -    /** */
      private final boolean registered;
  
      /** */
@@@ -111,9 -126,10 +122,9 @@@
       * @param idMapper ID mapper.
       * @param serializer Serializer.
       * @param metaDataEnabled Metadata enabled flag.
 -     * @param keepDeserialized Keep deserialized flag.
       * @param registered Whether typeId has been successfully registered by MarshallerContext or not.
       * @param predefined Whether the class is predefined or not.
-      * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+      * @throws BinaryObjectException In case of error.
       */
      PortableClassDescriptor(
          PortableContext ctx,
@@@ -132,13 -151,17 +145,16 @@@
  
          this.ctx = ctx;
          this.cls = cls;
-         this.userType = userType;
          this.typeId = typeId;
+         this.userType = userType;
          this.typeName = typeName;
+         this.affKeyFieldName = affKeyFieldName;
          this.serializer = serializer;
          this.idMapper = idMapper;
 -        this.keepDeserialized = keepDeserialized;
          this.registered = registered;
  
+         schemaReg = ctx.schemaRegistry(typeId);
+ 
          excluded = MarshallerExclusions.isExcluded(cls);
  
          useOptMarshaller = !predefined && initUseOptimizedMarshallerFlag();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 7c61f50,afc23e1..62917b6
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@@ -149,6 -147,12 +148,9 @@@ public class PortableContext implement
      /** */
      private final OptimizedMarshaller optmMarsh = new OptimizedMarshaller();
  
 -    /** */
 -    private boolean keepDeserialized;
 -
+     /** Compact footer flag. */
+     private boolean compactFooter;
+ 
      /** Object schemas. */
      private volatile Map<Integer, PortableSchemaRegistry> schemas;
  
@@@ -257,10 -258,14 +259,12 @@@
          optmMarsh.setContext(marshCtx);
  
          configure(
 -            marsh.getIdMapper(),
 -            marsh.getSerializer(),
 -            marsh.isKeepDeserialized(),
 -            marsh.getClassNames(),
 -            marsh.getTypeConfigurations()
 +            binaryCfg.getIdMapper(),
 +            binaryCfg.getSerializer(),
 +            binaryCfg.getTypeConfigurations()
          );
+ 
+         compactFooter = marsh.isCompactFooter();
      }
  
      /**
@@@ -532,8 -564,6 +538,9 @@@
              false /* predefined */
          );
  
-         metaHnd.addMeta(typeId, new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), null).wrap(this));
++        metaHnd.addMeta(typeId,
++            new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), null, desc.schemas()).wrap(this));
 +
          // perform put() instead of putIfAbsent() because "registered" flag might have been changed or class loader
          // might have reloaded described class.
          if (IgniteUtils.detectClassLoader(cls).equals(dfltLdr))

http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
index 12c9d36,e9cd1e3..6cdf53b
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
@@@ -71,14 -71,21 +71,21 @@@ public class PlatformCppConfigurationCl
          Marshaller marsh = igniteCfg.getMarshaller();
  
          if (marsh == null) {
 -            PortableMarshaller marsh0 = new PortableMarshaller();
++            BinaryMarshaller marsh0 = new BinaryMarshaller();
+ 
+             marsh0.setCompactFooter(false);
 -
 -            igniteCfg.setMarshaller(marsh0);
++            
 +            igniteCfg.setMarshaller(new BinaryMarshaller());
  
              cppCfg0.warnings(Collections.singleton("Marshaller is automatically set to " +
 -                PortableMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
 +                BinaryMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
          }
 -        else if (!(marsh instanceof PortableMarshaller))
 -            throw new IgniteException("Unsupported marshaller (only " + PortableMarshaller.class.getName() +
 +        else if (!(marsh instanceof BinaryMarshaller))
 +            throw new IgniteException("Unsupported marshaller (only " + BinaryMarshaller.class.getName() +
                  " can be used when running Apache Ignite C++): " + marsh.getClass().getName());
 -        else if (((PortableMarshaller)marsh).isCompactFooter())
 -            throw new IgniteException("Unsupported " + PortableMarshaller.class.getName() +
++        else if (((BinaryMarshaller)marsh).isCompactFooter())
++            throw new IgniteException("Unsupported " + BinaryMarshaller.class.getName() +
+                 " \"compactFooter\" flag: must be false when running Apache Ignite C++.");
  
          // Set Ignite home so that marshaller context works.
          String ggHome = igniteCfg.getIgniteHome();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index f68c08e,a59fd22..4289d4c
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@@ -92,14 -92,21 +92,21 @@@ public class PlatformDotNetConfiguratio
          Marshaller marsh = igniteCfg.getMarshaller();
  
          if (marsh == null) {
-             igniteCfg.setMarshaller(new BinaryMarshaller());
 -            PortableMarshaller marsh0 = new PortableMarshaller();
++            BinaryMarshaller marsh0 = new BinaryMarshaller();
+ 
+             marsh0.setCompactFooter(false);
+ 
+             igniteCfg.setMarshaller(marsh0);
  
              dotNetCfg0.warnings(Collections.singleton("Marshaller is automatically set to " +
 -                PortableMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
 +                BinaryMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
          }
 -        else if (!(marsh instanceof PortableMarshaller))
 -            throw new IgniteException("Unsupported marshaller (only " + PortableMarshaller.class.getName() +
 +        else if (!(marsh instanceof BinaryMarshaller))
 +            throw new IgniteException("Unsupported marshaller (only " + BinaryMarshaller.class.getName() +
                  " can be used when running Apache Ignite.NET): " + marsh.getClass().getName());
 -        else if (((PortableMarshaller)marsh).isCompactFooter())
 -            throw new IgniteException("Unsupported " + PortableMarshaller.class.getName() +
++        else if (((BinaryMarshaller)marsh).isCompactFooter())
++            throw new IgniteException("Unsupported " + BinaryMarshaller.class.getName() +
+                 " \"compactFooter\" flag: must be false when running Apache Ignite.NET.");
  
          // Set Ignite home so that marshaller context works.
          String ggHome = igniteCfg.getIgniteHome();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
index 21fab62,8f79db1..dd08390
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
@@@ -47,14 -46,14 +47,16 @@@ public abstract class BinaryFieldsAbstr
       * @return Portable marshaller.
       * @throws Exception If failed.
       */
-     protected static BinaryMarshaller createMarshaller() throws Exception {
-         PortableContext ctx = new PortableContext(new TestCachingMetadataHandler(), new IgniteConfiguration());
 -    protected PortableMarshaller createMarshaller() throws Exception {
++    protected BinaryMarshaller createMarshaller() throws Exception {
+         PortableContext ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
  
 -        PortableMarshaller marsh = new PortableMarshaller();
 +        BinaryMarshaller marsh = new BinaryMarshaller();
  
 -        marsh.setCompactFooter(compactFooter());
 +        BinaryConfiguration bCfg = new BinaryConfiguration();
++        
++        bCfg.setCompactFooter(compactFooter());
  
 -        marsh.setTypeConfigurations(Arrays.asList(
 +        bCfg.setTypeConfigurations(Arrays.asList(
              new BinaryTypeConfiguration(TestObject.class.getName()),
              new BinaryTypeConfiguration(TestOuterObject.class.getName()),
              new BinaryTypeConfiguration(TestInnerObject.class.getName())

http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
index 0000000,3ec0b83..7267b16
mode 000000,100644..100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
@@@ -1,0 -1,199 +1,206 @@@
+ /*
+  * 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.portable;
+ 
++import java.util.Arrays;
+ import org.apache.ignite.binary.BinaryField;
+ import org.apache.ignite.binary.BinaryTypeConfiguration;
++import org.apache.ignite.configuration.BinaryConfiguration;
+ import org.apache.ignite.configuration.IgniteConfiguration;
+ import org.apache.ignite.internal.util.IgniteUtils;
+ import org.apache.ignite.marshaller.MarshallerContextTestImpl;
 -import org.apache.ignite.marshaller.portable.PortableMarshaller;
++import org.apache.ignite.marshaller.portable.BinaryMarshaller;
+ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+ 
 -import java.util.Arrays;
 -
+ /**
+  * Contains tests for compact offsets.
+  */
+ public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbstractTest {
+     /** 2 pow 8. */
+     private static int POW_8 = 1 << 8;
+ 
+     /** 2 pow 16. */
+     private static int POW_16 = 1 << 16;
+ 
+     /** Marshaller. */
 -    protected PortableMarshaller marsh;
++    protected BinaryMarshaller marsh;
+ 
+     /** Portable context. */
+     protected PortableContext ctx;
+ 
+     /** {@inheritDoc} */
+     @Override protected void beforeTest() throws Exception {
+         super.beforeTest();
+ 
+         ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
+ 
 -        marsh = new PortableMarshaller();
++        marsh = new BinaryMarshaller();
++
++        IgniteConfiguration iCfg = new IgniteConfiguration();
+ 
 -        marsh.setCompactFooter(compactFooter());
++        BinaryConfiguration bCfg = new BinaryConfiguration();
++
++        bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
++        
++        bCfg.setCompactFooter(compactFooter());
++
++        iCfg.setBinaryConfiguration(bCfg);
+ 
 -        marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
+         marsh.setContext(new MarshallerContextTestImpl(null));
+ 
 -        IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
++        IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg);
+     }
+ 
+     /**
+      * @return Whether to use compact footers.
+      */
+     protected boolean compactFooter() {
+         return true;
+     }
 -
++    
+     /**
+      * Test 1 byte.
+      *
+      * @throws Exception If failed.
+      */
+     public void test1Byte() throws Exception {
+         check(POW_8 >> 2);
+     }
+ 
+     /**
+      * Test 1 byte with sign altering.
+      *
+      * @throws Exception If failed.
+      */
+     public void test1ByteSign() throws Exception {
+         check(POW_8 >> 1);
+     }
+ 
+     /**
+      * Test 2 bytes.
+      *
+      * @throws Exception If failed.
+      */
+     public void test2Bytes() throws Exception {
+         check(POW_16 >> 2);
+     }
+ 
+     /**
+      * Test 2 bytes with sign altering.
+      *
+      * @throws Exception If failed.
+      */
+     public void test2BytesSign() throws Exception {
+         check(POW_16 >> 1);
+     }
+ 
+     /**
+      * Test 4 bytes.
+      *
+      * @throws Exception If failed.
+      */
+     public void test4Bytes() throws Exception {
+         check(POW_16 << 2);
+     }
+ 
+     /**
+      * Main check routine.
+      *
+      * @param len Length of the first field.
+      *
+      * @throws Exception If failed.
+      */
+     private void check(int len) throws Exception {
+         TestObject obj = new TestObject(len);
+ 
+         BinaryObjectEx portObj = toPortable(marsh, obj);
+ 
+         // 1. Test portable object content.
+         assert portObj.hasField("field1");
+         assert portObj.hasField("field2");
+ 
+         byte[] field1 = portObj.field("field1");
+         Integer field2 = portObj.field("field2");
+ 
+         assert field1 != null;
+         assert field2 != null;
+ 
+         assert Arrays.equals(obj.field1, field1);
+         assert obj.field2 == field2;
+ 
+         // 2. Test fields API.
+         BinaryField field1Desc = portObj.type().field("field1");
+         BinaryField field2Desc = portObj.type().field("field2");
+ 
+         assert field1Desc.exists(portObj);
+         assert field2Desc.exists(portObj);
+ 
+         assert Arrays.equals(obj.field1, (byte[])field1Desc.value(portObj));
+         assert obj.field2 == (Integer)field2Desc.value(portObj);
+ 
+         // 3. Test deserialize.
+         TestObject objRestored = portObj.deserialize();
+ 
+         assert objRestored != null;
+ 
+         assert Arrays.equals(obj.field1, objRestored.field1);
+         assert obj.field2 == objRestored.field2;
+     }
+ 
+     /**
+      * Convert object to portable object.
+      *
+      * @param marsh Marshaller.
+      * @param obj Object.
+      * @return Portable object.
+      * @throws Exception If failed.
+      */
 -    protected abstract BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception;
++    protected abstract BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception;
+ 
+     /**
+      * Test object.
+      */
+     public static class TestObject {
+         /** First field with variable length. */
+         public byte[] field1;
+ 
+         /** Second field. */
+         public int field2;
+ 
+         /**
+          * Default constructor.
+          */
+         public TestObject() {
+             // No-op.
+         }
+ 
+         /**
+          * Constructor.
+          *
+          * @param len Array length.
+          */
+         public TestObject(int len) {
+             field1 = new byte[len];
+ 
+             field1[0] = 1;
+             field1[len - 1] = 2;
+ 
+             field2 = len;
+         }
+     }
+ }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
index 0000000,b23f012..471bd44
mode 000000,100644..100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
@@@ -1,0 -1,32 +1,32 @@@
+ /*
+  * 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.portable;
+ 
 -import org.apache.ignite.marshaller.portable.PortableMarshaller;
++import org.apache.ignite.marshaller.portable.BinaryMarshaller;
+ 
+ /**
+  * Compact offsets tests for heap portable objects.
+  */
+ public class BinaryFooterOffsetsHeapSelfTest extends BinaryFooterOffsetsAbstractSelfTest {
+     /** {@inheritDoc} */
 -    @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
++    @Override protected BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception {
+         byte[] bytes = marsh.marshal(obj);
+ 
+         return new BinaryObjectImpl(ctx, bytes, 0);
+     }
+ }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a511fa17/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
index 0000000,e52ebe7..7b44b80
mode 000000,100644..100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
@@@ -1,0 -1,61 +1,61 @@@
+ /*
+  * 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.portable;
+ 
+ import org.apache.ignite.internal.util.GridUnsafe;
 -import org.apache.ignite.marshaller.portable.PortableMarshaller;
++import org.apache.ignite.marshaller.portable.BinaryMarshaller;
+ import org.eclipse.jetty.util.ConcurrentHashSet;
+ import sun.misc.Unsafe;
+ 
+ /**
+  * Compact offsets tests for offheap portable objects.
+  */
+ public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstractSelfTest {
+     /** Unsafe instance. */
+     private static final Unsafe UNSAFE = GridUnsafe.unsafe();
+ 
+     /** Byte array offset for unsafe mechanics. */
+     protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
+ 
+     /** Allocated unsafe pointer. */
+     private final ConcurrentHashSet<Long> ptrs = new ConcurrentHashSet<>();
+ 
+     /** {@inheritDoc} */
+     @Override protected void afterTest() throws Exception {
+         super.afterTest();
+ 
+         // Cleanup allocated objects.
+         for (Long ptr : ptrs)
+             UNSAFE.freeMemory(ptr);
+ 
+         ptrs.clear();
+     }
+ 
+     /** {@inheritDoc} */
 -    @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
++    @Override protected BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception {
+         byte[] arr = marsh.marshal(obj);
+ 
+         long ptr = UNSAFE.allocateMemory(arr.length);
+ 
+         ptrs.add(ptr);
+ 
+         UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+ 
+         return new BinaryObjectOffheapImpl(ctx, ptr, 0, arr.length);
+     }
+ }