ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [11/66] [abbrv] ignite git commit: IGNITE-950 - Renaming.
Date Thu, 05 Nov 2015 03:28:03 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/portable/IgniteObjectWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/IgniteObjectWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/IgniteObjectWriterExImpl.java
deleted file mode 100644
index 34ea5e8..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/IgniteObjectWriterExImpl.java
+++ /dev/null
@@ -1,1855 +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.portable;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.igniteobject.IgniteObjectIdMapper;
-import org.apache.ignite.internal.portable.streams.PortableHeapOutputStream;
-import org.apache.ignite.internal.portable.streams.PortableOutputStream;
-import org.apache.ignite.internal.util.typedef.internal.A;
-import org.apache.ignite.igniteobject.IgniteObjectException;
-import org.apache.ignite.igniteobject.IgniteObjectRawWriter;
-import org.apache.ignite.igniteobject.IgniteObjectWriter;
-import org.jetbrains.annotations.Nullable;
-
-import java.io.IOException;
-import java.io.ObjectOutput;
-import java.lang.reflect.InvocationTargetException;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Timestamp;
-import java.util.Collection;
-import java.util.Date;
-import java.util.IdentityHashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.BOOLEAN;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.BOOLEAN_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.BYTE;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.BYTE_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CHAR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CHAR_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLASS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.COL;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DATE;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DATE_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DECIMAL;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DECIMAL_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DOUBLE;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DOUBLE_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.ENUM;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.ENUM_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLAGS_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLOAT;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLOAT_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.INT;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.INT_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP_ENTRY;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.OPTM_MARSH;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.PORTABLE_OBJ;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.SCHEMA_ID_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_ARR;
-
-/**
- * Portable writer implementation.
- */
-public class IgniteObjectWriterExImpl implements IgniteObjectWriter, IgniteObjectRawWriterEx, ObjectOutput {
-    /** Length: integer. */
-    private static final int LEN_INT = 4;
-
-    /** */
-    private static final int INIT_CAP = 1024;
-
-    /** FNV1 hash offset basis. */
-    private static final int FNV1_OFFSET_BASIS = 0x811C9DC5;
-
-    /** FNV1 hash prime. */
-    private static final int FNV1_PRIME = 0x01000193;
-
-    /** Thread-local schema. */
-    private static final ThreadLocal<SchemaHolder> SCHEMA = new ThreadLocal<>();
-
-    /** */
-    private final PortableContext ctx;
-
-    /** */
-    private final int start;
-
-    /** */
-    private Class<?> cls;
-
-    /** */
-    private int typeId;
-
-    /** Raw offset position. */
-    private int rawOffPos;
-
-    /** */
-    private boolean metaEnabled;
-
-    /** */
-    private int metaHashSum;
-
-    /** Handles. */
-    private Map<Object, Integer> handles;
-
-    /** Output stream. */
-    private PortableOutputStream out;
-
-    /** Schema. */
-    private SchemaHolder schema;
-
-    /** Schema ID. */
-    private int schemaId;
-
-    /** Amount of written fields. */
-    private int fieldCnt;
-
-    /** ID mapper. */
-    private IgniteObjectIdMapper idMapper;
-
-    /**
-     * @param ctx Context.
-     */
-    IgniteObjectWriterExImpl(PortableContext ctx) {
-        this(ctx, new PortableHeapOutputStream(INIT_CAP));
-    }
-
-    /**
-     * @param ctx Context.
-     * @param out Output stream.
-     */
-    IgniteObjectWriterExImpl(PortableContext ctx, PortableOutputStream out) {
-        this(ctx, out, new IdentityHashMap<Object, Integer>());
-    }
-
-     /**
-      * @param ctx Context.
-      * @param out Output stream.
-      * @param handles Handles.
-      */
-     private IgniteObjectWriterExImpl(PortableContext ctx, PortableOutputStream out, Map<Object, Integer> handles) {
-         this.ctx = ctx;
-         this.out = out;
-         this.handles = handles;
-
-         start = out.position();
-     }
-
-    /**
-     * @param ctx Context.
-     * @param typeId Type ID.
-     */
-    public IgniteObjectWriterExImpl(PortableContext ctx, int typeId, boolean metaEnabled) {
-        this(ctx);
-
-        this.typeId = typeId;
-        this.metaEnabled = metaEnabled;
-    }
-
-    /**
-     * Close the writer releasing resources if necessary.
-     */
-    @Override public void close() {
-        out.close();
-    }
-
-    /**
-     * @return Meta data hash sum or {@code null} if meta data is disabled.
-     */
-    @Nullable Integer metaDataHashSum() {
-        return metaEnabled ? metaHashSum : null;
-    }
-
-    /**
-     * @param obj Object.
-     * @throws IgniteObjectException In case of error.
-     */
-    void marshal(Object obj) throws IgniteObjectException {
-        marshal(obj, true);
-    }
-
-    /**
-     * @param obj Object.
-     * @param enableReplace Object replacing enabled flag.
-     * @throws IgniteObjectException In case of error.
-     */
-    void marshal(Object obj, boolean enableReplace) throws IgniteObjectException {
-        assert obj != null;
-
-        cls = obj.getClass();
-
-        PortableClassDescriptor desc = ctx.descriptorForClass(cls);
-
-        if (desc == null)
-            throw new IgniteObjectException("Object is not portable: [class=" + cls + ']');
-
-        if (desc.excluded()) {
-            doWriteByte(NULL);
-            return;
-        }
-
-        if (desc.useOptimizedMarshaller()) {
-            writeByte(OPTM_MARSH);
-
-            try {
-                byte[] arr = ctx.optimizedMarsh().marshal(obj);
-
-                writeInt(arr.length);
-
-                write(arr);
-            }
-            catch (IgniteCheckedException e) {
-                throw new IgniteObjectException("Failed to marshal object with optimized marshaller: " + obj, e);
-            }
-
-            return;
-        }
-
-        if (enableReplace && desc.getWriteReplaceMethod() != null) {
-            Object replacedObj;
-
-            try {
-                replacedObj = desc.getWriteReplaceMethod().invoke(obj);
-            }
-            catch (IllegalAccessException e) {
-                throw new RuntimeException(e);
-            }
-            catch (InvocationTargetException e) {
-                if (e.getTargetException() instanceof IgniteObjectException)
-                    throw (IgniteObjectException)e.getTargetException();
-
-                throw new IgniteObjectException("Failed to execute writeReplace() method on " + obj, e);
-            }
-
-            if (replacedObj == null) {
-                doWriteByte(NULL);
-                return;
-            }
-
-            marshal(replacedObj, false);
-
-            return;
-        }
-
-        typeId = desc.typeId();
-
-        metaEnabled = ctx.isMetaDataEnabled(typeId);
-
-        desc.write(obj, this);
-    }
-
-    /**
-     * @param obj Object.
-     * @return Handle.
-     */
-    int handle(Object obj) {
-        assert obj != null;
-
-        Integer h = handles.get(obj);
-
-        if (h != null)
-            return out.position() - h;
-        else {
-            handles.put(obj, out.position());
-
-            return -1;
-        }
-    }
-
-    /**
-     * @return Array.
-     */
-    public byte[] array() {
-        return out.arrayCopy();
-    }
-
-    /**
-     * @return Stream current position.
-     */
-    int position() {
-        return out.position();
-    }
-
-    /**
-     * Sets new position.
-     *
-     * @param pos Position.
-     */
-    void position(int pos) {
-        out.position(pos);
-    }
-
-    /**
-     * @param bytes Number of bytes to reserve.
-     * @return Offset.
-     */
-    public int reserve(int bytes) {
-        int pos = out.position();
-
-        out.position(pos + bytes);
-
-        return pos;
-    }
-
-    /**
-     * Perform post-write activity. This includes:
-     * - writing object length;
-     * - writing schema offset;
-     * - writing schema to the tail.
-     *
-     * @param userType User type flag.
-     */
-    public void postWrite(boolean userType) {
-        if (schema != null) {
-            // Write schema ID.
-            out.writeInt(start + SCHEMA_ID_POS, schemaId);
-
-            // Write schema offset.
-            out.writeInt(start + SCHEMA_OR_RAW_OFF_POS, out.position() - start);
-
-            // Write the schema.
-            schema.writeAndPop(this, fieldCnt);
-
-            // Write raw offset if needed.
-            if (rawOffPos != 0)
-                out.writeInt(rawOffPos - start);
-        }
-        else {
-            // Write raw-only flag is needed.
-            int flags = (userType ? PortableUtils.FLAG_USR_TYP : 0) | PortableUtils.FLAG_RAW_ONLY;
-
-            out.writeShort(start + FLAGS_POS, (short)flags);
-
-            // If there are no schema, we are free to write raw offset to schema offset.
-            out.writeInt(start + SCHEMA_OR_RAW_OFF_POS, (rawOffPos == 0 ? out.position() : rawOffPos) - start);
-        }
-
-        // 5. Write length.
-        out.writeInt(start + TOTAL_LEN_POS, out.position() - start);
-    }
-
-    /**
-     * @param val Byte array.
-     */
-    public void write(byte[] val) {
-        assert val != null;
-
-        out.writeByteArray(val);
-    }
-
-    /**
-     * @param val Byte array.
-     * @param off Offset.
-     * @param len Length.
-     */
-    public void write(byte[] val, int off, int len) {
-        assert val != null;
-
-        out.write(val, off, len);
-    }
-
-    /**
-     * @param val Value.
-     */
-    public void doWriteByte(byte val) {
-        out.writeByte(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    public void doWriteShort(short val) {
-        out.writeShort(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    public void doWriteInt(int val) {
-        out.writeInt(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    public void doWriteLong(long val) {
-        out.writeLong(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    public void doWriteFloat(float val) {
-        out.writeFloat(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    public void doWriteDouble(double val) {
-        out.writeDouble(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    public void doWriteChar(char val) {
-        out.writeChar(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    public void doWriteBoolean(boolean val) {
-        out.writeBoolean(val);
-    }
-
-    /**
-     * @param val String value.
-     */
-    public void doWriteDecimal(@Nullable BigDecimal val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(DECIMAL);
-
-            BigInteger intVal = val.unscaledValue();
-
-            if (intVal.signum() == -1) {
-                intVal = intVal.negate();
-
-                out.writeInt(val.scale() | 0x80000000);
-            }
-            else
-                out.writeInt(val.scale());
-
-            byte[] vals = intVal.toByteArray();
-
-            out.writeInt(vals.length);
-            out.writeByteArray(vals);
-        }
-    }
-
-    /**
-     * @param val String value.
-     */
-    public void doWriteString(@Nullable String val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(STRING);
-
-            if (ctx.isConvertString()) {
-                doWriteBoolean(true);
-
-                byte[] strArr = val.getBytes(UTF_8);
-
-                doWriteInt(strArr.length);
-
-                out.writeByteArray(strArr);
-            }
-            else {
-                doWriteBoolean(false);
-
-                char[] strArr = val.toCharArray();
-
-                doWriteInt(strArr.length);
-
-                out.writeCharArray(strArr);
-            }
-        }
-    }
-
-    /**
-     * @param uuid UUID.
-     */
-    public void doWriteUuid(@Nullable UUID uuid) {
-        if (uuid == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(UUID);
-            doWriteLong(uuid.getMostSignificantBits());
-            doWriteLong(uuid.getLeastSignificantBits());
-        }
-    }
-
-    /**
-     * @param date Date.
-     */
-    public void doWriteDate(@Nullable Date date) {
-        if (date == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(DATE);
-            doWriteLong(date.getTime());
-        }
-    }
-
-    /**
-     * @param ts Timestamp.
-     */
-    public void doWriteTimestamp(@Nullable Timestamp ts) {
-        if (ts== null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(TIMESTAMP);
-            doWriteLong(ts.getTime());
-            doWriteInt(ts.getNanos() % 1000000);
-        }
-    }
-
-    /**
-     * Write object.
-     *
-     * @param obj Object.
-     * @throws IgniteObjectException In case of error.
-     */
-    public void doWriteObject(@Nullable Object obj) throws IgniteObjectException {
-        if (obj == null)
-            doWriteByte(NULL);
-        else {
-            IgniteObjectWriterExImpl writer = new IgniteObjectWriterExImpl(ctx, out, handles);
-
-            writer.marshal(obj);
-        }
-    }
-
-    /**
-     * @param val Byte array.
-     */
-    void doWriteByteArray(@Nullable byte[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(BYTE_ARR);
-            doWriteInt(val.length);
-
-            out.writeByteArray(val);
-        }
-    }
-
-    /**
-     * @param val Short array.
-     */
-    void doWriteShortArray(@Nullable short[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(SHORT_ARR);
-            doWriteInt(val.length);
-
-            out.writeShortArray(val);
-        }
-    }
-
-    /**
-     * @param val Integer array.
-     */
-    void doWriteIntArray(@Nullable int[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(INT_ARR);
-            doWriteInt(val.length);
-
-            out.writeIntArray(val);
-        }
-    }
-
-    /**
-     * @param val Long array.
-     */
-    void doWriteLongArray(@Nullable long[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(LONG_ARR);
-            doWriteInt(val.length);
-
-            out.writeLongArray(val);
-        }
-    }
-
-    /**
-     * @param val Float array.
-     */
-    void doWriteFloatArray(@Nullable float[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(FLOAT_ARR);
-            doWriteInt(val.length);
-
-            out.writeFloatArray(val);
-        }
-    }
-
-    /**
-     * @param val Double array.
-     */
-    void doWriteDoubleArray(@Nullable double[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(DOUBLE_ARR);
-            doWriteInt(val.length);
-
-            out.writeDoubleArray(val);
-        }
-    }
-
-    /**
-     * @param val Char array.
-     */
-    void doWriteCharArray(@Nullable char[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(CHAR_ARR);
-            doWriteInt(val.length);
-
-            out.writeCharArray(val);
-        }
-    }
-
-    /**
-     * @param val Boolean array.
-     */
-    void doWriteBooleanArray(@Nullable boolean[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(BOOLEAN_ARR);
-            doWriteInt(val.length);
-
-            out.writeBooleanArray(val);
-        }
-    }
-
-    /**
-     * @param val Array of strings.
-     */
-    void doWriteDecimalArray(@Nullable BigDecimal[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(DECIMAL_ARR);
-            doWriteInt(val.length);
-
-            for (BigDecimal str : val)
-                doWriteDecimal(str);
-        }
-    }
-
-    /**
-     * @param val Array of strings.
-     */
-    void doWriteStringArray(@Nullable String[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(STRING_ARR);
-            doWriteInt(val.length);
-
-            for (String str : val)
-                doWriteString(str);
-        }
-    }
-
-    /**
-     * @param val Array of UUIDs.
-     */
-    void doWriteUuidArray(@Nullable UUID[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(UUID_ARR);
-            doWriteInt(val.length);
-
-            for (UUID uuid : val)
-                doWriteUuid(uuid);
-        }
-    }
-
-    /**
-     * @param val Array of dates.
-     */
-    void doWriteDateArray(@Nullable Date[] val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            doWriteByte(DATE_ARR);
-            doWriteInt(val.length);
-
-            for (Date date : val)
-                doWriteDate(date);
-        }
-    }
-
-     /**
-      * @param val Array of timestamps.
-      */
-     void doWriteTimestampArray(@Nullable Timestamp[] val) {
-         if (val == null)
-             doWriteByte(NULL);
-         else {
-             if (tryWriteAsHandle(val))
-                 return;
-
-             doWriteByte(TIMESTAMP_ARR);
-             doWriteInt(val.length);
-
-             for (Timestamp ts : val)
-                 doWriteTimestamp(ts);
-         }
-     }
-
-    /**
-     * @param val Array of objects.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
-     */
-    void doWriteObjectArray(@Nullable Object[] val) throws IgniteObjectException {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(val))
-                return;
-
-            PortableClassDescriptor desc = ctx.descriptorForClass(val.getClass().getComponentType());
-
-            doWriteByte(OBJ_ARR);
-
-            if (desc.registered())
-                doWriteInt(desc.typeId());
-            else {
-                doWriteInt(UNREGISTERED_TYPE_ID);
-                doWriteString(val.getClass().getComponentType().getName());
-            }
-
-            doWriteInt(val.length);
-
-            for (Object obj : val)
-                doWriteObject(obj);
-        }
-    }
-
-    /**
-     * @param col Collection.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
-     */
-    void doWriteCollection(@Nullable Collection<?> col) throws IgniteObjectException {
-        if (col == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(col))
-                return;
-
-            doWriteByte(COL);
-            doWriteInt(col.size());
-            doWriteByte(ctx.collectionType(col.getClass()));
-
-            for (Object obj : col)
-                doWriteObject(obj);
-        }
-    }
-
-    /**
-     * @param map Map.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
-     */
-    void doWriteMap(@Nullable Map<?, ?> map) throws IgniteObjectException {
-        if (map == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(map))
-                return;
-
-            doWriteByte(MAP);
-            doWriteInt(map.size());
-            doWriteByte(ctx.mapType(map.getClass()));
-
-            for (Map.Entry<?, ?> e : map.entrySet()) {
-                doWriteObject(e.getKey());
-                doWriteObject(e.getValue());
-            }
-        }
-    }
-
-    /**
-     * @param e Map entry.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
-     */
-    void doWriteMapEntry(@Nullable Map.Entry<?, ?> e) throws IgniteObjectException {
-        if (e == null)
-            doWriteByte(NULL);
-        else {
-            if (tryWriteAsHandle(e))
-                return;
-
-            doWriteByte(MAP_ENTRY);
-            doWriteObject(e.getKey());
-            doWriteObject(e.getValue());
-        }
-    }
-
-    /**
-     * @param val Value.
-     */
-    void doWriteEnum(@Nullable Enum<?> val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            PortableClassDescriptor desc = ctx.descriptorForClass(val.getClass());
-
-            doWriteByte(ENUM);
-
-            if (desc.registered())
-                doWriteInt(desc.typeId());
-            else {
-                doWriteInt(UNREGISTERED_TYPE_ID);
-                doWriteString(val.getClass().getName());
-            }
-
-            doWriteInt(val.ordinal());
-        }
-    }
-
-    /**
-     * @param val Array.
-     */
-    void doWriteEnumArray(@Nullable Object[] val) {
-        assert val == null || val.getClass().getComponentType().isEnum();
-
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            PortableClassDescriptor desc = ctx.descriptorForClass(val.getClass().getComponentType());
-            doWriteByte(ENUM_ARR);
-
-            if (desc.registered())
-                doWriteInt(desc.typeId());
-            else {
-                doWriteInt(UNREGISTERED_TYPE_ID);
-                doWriteString(val.getClass().getComponentType().getName());
-            }
-
-            doWriteInt(val.length);
-
-            // TODO: Denis: Redundant data for each element of the array.
-            for (Object o : val)
-                doWriteEnum((Enum<?>)o);
-        }
-    }
-
-    /**
-     * @param val Class.
-     */
-    void doWriteClass(@Nullable Class val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            PortableClassDescriptor desc = ctx.descriptorForClass(val);
-
-            doWriteByte(CLASS);
-
-            if (desc.registered())
-                doWriteInt(desc.typeId());
-            else {
-                doWriteInt(UNREGISTERED_TYPE_ID);
-                doWriteString(val.getClass().getName());
-            }
-        }
-    }
-
-    /**
-     * @param po Portable object.
-     */
-    public void doWritePortableObject(@Nullable IgniteObjectImpl po) {
-        if (po == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(PORTABLE_OBJ);
-
-            byte[] poArr = po.array();
-
-            doWriteInt(poArr.length);
-
-            out.writeByteArray(poArr);
-
-            doWriteInt(po.start());
-        }
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeByteField(@Nullable Byte val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(BYTE);
-            doWriteByte(val);
-        }
-    }
-
-    /**
-     * @param val Class.
-     */
-    void writeClassField(@Nullable Class val) {
-        doWriteClass(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeShortField(@Nullable Short val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(SHORT);
-            doWriteShort(val);
-        }
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeIntField(@Nullable Integer val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(INT);
-            doWriteInt(val);
-        }
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeLongField(@Nullable Long val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(LONG);
-            doWriteLong(val);
-        }
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeFloatField(@Nullable Float val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(FLOAT);
-            doWriteFloat(val);
-        }
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeDoubleField(@Nullable Double val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(DOUBLE);
-            doWriteDouble(val);
-        }
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeCharField(@Nullable Character val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(CHAR);
-            doWriteChar(val);
-        }
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeBooleanField(@Nullable Boolean val) {
-        if (val == null)
-            doWriteByte(NULL);
-        else {
-            doWriteByte(BOOLEAN);
-            doWriteBoolean(val);
-        }
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeDecimalField(@Nullable BigDecimal val) {
-        doWriteDecimal(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeStringField(@Nullable String val) {
-        doWriteString(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeUuidField(@Nullable UUID val) {
-        doWriteUuid(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeDateField(@Nullable Date val) {
-        doWriteDate(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeTimestampField(@Nullable Timestamp val) {
-        doWriteTimestamp(val);
-    }
-
-    /**
-     * @param obj Object.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
-     */
-    void writeObjectField(@Nullable Object obj) throws IgniteObjectException {
-        doWriteObject(obj);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeByteArrayField(@Nullable byte[] val) {
-        doWriteByteArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeShortArrayField(@Nullable short[] val) {
-        doWriteShortArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeIntArrayField(@Nullable int[] val) {
-        doWriteIntArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeLongArrayField(@Nullable long[] val) {
-        doWriteLongArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeFloatArrayField(@Nullable float[] val) {
-        doWriteFloatArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeDoubleArrayField(@Nullable double[] val) {
-        doWriteDoubleArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeCharArrayField(@Nullable char[] val) {
-        doWriteCharArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeBooleanArrayField(@Nullable boolean[] val) {
-        doWriteBooleanArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeDecimalArrayField(@Nullable BigDecimal[] val) {
-        doWriteDecimalArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeStringArrayField(@Nullable String[] val) {
-        doWriteStringArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeUuidArrayField(@Nullable UUID[] val) {
-        doWriteUuidArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeDateArrayField(@Nullable Date[] val) {
-        doWriteDateArray(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeTimestampArrayField(@Nullable Timestamp[] val) {
-        doWriteTimestampArray(val);
-    }
-
-    /**
-     * @param val Value.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
-     */
-    void writeObjectArrayField(@Nullable Object[] val) throws IgniteObjectException {
-        doWriteObjectArray(val);
-    }
-
-    /**
-     * @param col Collection.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
-     */
-    void writeCollectionField(@Nullable Collection<?> col) throws IgniteObjectException {
-        doWriteCollection(col);
-    }
-
-    /**
-     * @param map Map.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
-     */
-    void writeMapField(@Nullable Map<?, ?> map) throws IgniteObjectException {
-        doWriteMap(map);
-    }
-
-    /**
-     * @param e Map entry.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
-     */
-    void writeMapEntryField(@Nullable Map.Entry<?, ?> e) throws IgniteObjectException {
-        doWriteMapEntry(e);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeEnumField(@Nullable Enum<?> val) {
-        doWriteEnum(val);
-    }
-
-    /**
-     * @param val Value.
-     */
-    void writeEnumArrayField(@Nullable Object[] val) {
-        doWriteEnumArray(val);
-    }
-
-    /**
-     * @param po Portable object.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
-     */
-    void writePortableObjectField(@Nullable IgniteObjectImpl po) throws IgniteObjectException {
-        doWritePortableObject(po);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeByte(String fieldName, byte val) throws IgniteObjectException {
-        writeFieldId(fieldName, BYTE);
-        writeByteField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeByte(byte val) throws IgniteObjectException {
-        doWriteByte(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeShort(String fieldName, short val) throws IgniteObjectException {
-        writeFieldId(fieldName, SHORT);
-        writeShortField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeShort(short val) throws IgniteObjectException {
-        doWriteShort(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeInt(String fieldName, int val) throws IgniteObjectException {
-        writeFieldId(fieldName, INT);
-        writeIntField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeInt(int val) throws IgniteObjectException {
-        doWriteInt(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeLong(String fieldName, long val) throws IgniteObjectException {
-        writeFieldId(fieldName, LONG);
-        writeLongField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeLong(long val) throws IgniteObjectException {
-        doWriteLong(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeFloat(String fieldName, float val) throws IgniteObjectException {
-        writeFieldId(fieldName, FLOAT);
-        writeFloatField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeFloat(float val) throws IgniteObjectException {
-        doWriteFloat(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDouble(String fieldName, double val) throws IgniteObjectException {
-        writeFieldId(fieldName, DOUBLE);
-        writeDoubleField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDouble(double val) throws IgniteObjectException {
-        doWriteDouble(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeChar(String fieldName, char val) throws IgniteObjectException {
-        writeFieldId(fieldName, CHAR);
-        writeCharField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeChar(char val) throws IgniteObjectException {
-        doWriteChar(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeBoolean(String fieldName, boolean val) throws IgniteObjectException {
-        writeFieldId(fieldName, BOOLEAN);
-        writeBooleanField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeBoolean(boolean val) throws IgniteObjectException {
-        doWriteBoolean(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws IgniteObjectException {
-        writeFieldId(fieldName, DECIMAL);
-        writeDecimalField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDecimal(@Nullable BigDecimal val) throws IgniteObjectException {
-        doWriteDecimal(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeString(String fieldName, @Nullable String val) throws IgniteObjectException {
-        writeFieldId(fieldName, STRING);
-        writeStringField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeString(@Nullable String val) throws IgniteObjectException {
-        doWriteString(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeUuid(String fieldName, @Nullable UUID val) throws IgniteObjectException {
-        writeFieldId(fieldName, UUID);
-        writeUuidField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeUuid(@Nullable UUID val) throws IgniteObjectException {
-        doWriteUuid(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDate(String fieldName, @Nullable Date val) throws IgniteObjectException {
-        writeFieldId(fieldName, DATE);
-        writeDateField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDate(@Nullable Date val) throws IgniteObjectException {
-        doWriteDate(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws IgniteObjectException {
-        writeFieldId(fieldName, TIMESTAMP);
-        writeTimestampField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTimestamp(@Nullable Timestamp val) throws IgniteObjectException {
-        doWriteTimestamp(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeObject(String fieldName, @Nullable Object obj) throws IgniteObjectException {
-        writeFieldId(fieldName, OBJ);
-        writeObjectField(obj);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeObject(@Nullable Object obj) throws IgniteObjectException {
-        doWriteObject(obj);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeObjectDetached(@Nullable Object obj) throws IgniteObjectException {
-        if (obj == null)
-            doWriteByte(NULL);
-        else {
-            IgniteObjectWriterExImpl writer = new IgniteObjectWriterExImpl(ctx, out, new IdentityHashMap<Object, Integer>());
-
-            writer.marshal(obj);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, BYTE_ARR);
-        writeByteArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeByteArray(@Nullable byte[] val) throws IgniteObjectException {
-        doWriteByteArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeShortArray(String fieldName, @Nullable short[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, SHORT_ARR);
-        writeShortArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeShortArray(@Nullable short[] val) throws IgniteObjectException {
-        doWriteShortArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeIntArray(String fieldName, @Nullable int[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, INT_ARR);
-        writeIntArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeIntArray(@Nullable int[] val) throws IgniteObjectException {
-        doWriteIntArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeLongArray(String fieldName, @Nullable long[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, LONG_ARR);
-        writeLongArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeLongArray(@Nullable long[] val) throws IgniteObjectException {
-        doWriteLongArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, FLOAT_ARR);
-        writeFloatArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeFloatArray(@Nullable float[] val) throws IgniteObjectException {
-        doWriteFloatArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDoubleArray(String fieldName, @Nullable double[] val)
-        throws IgniteObjectException {
-        writeFieldId(fieldName, DOUBLE_ARR);
-        writeDoubleArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDoubleArray(@Nullable double[] val) throws IgniteObjectException {
-        doWriteDoubleArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeCharArray(String fieldName, @Nullable char[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, CHAR_ARR);
-        writeCharArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeCharArray(@Nullable char[] val) throws IgniteObjectException {
-        doWriteCharArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val)
-        throws IgniteObjectException {
-        writeFieldId(fieldName, BOOLEAN_ARR);
-        writeBooleanArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeBooleanArray(@Nullable boolean[] val) throws IgniteObjectException {
-        doWriteBooleanArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val)
-        throws IgniteObjectException {
-        writeFieldId(fieldName, DECIMAL_ARR);
-        writeDecimalArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDecimalArray(@Nullable BigDecimal[] val) throws IgniteObjectException {
-        doWriteDecimalArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeStringArray(String fieldName, @Nullable String[] val)
-        throws IgniteObjectException {
-        writeFieldId(fieldName, STRING_ARR);
-        writeStringArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeStringArray(@Nullable String[] val) throws IgniteObjectException {
-        doWriteStringArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, UUID_ARR);
-        writeUuidArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeUuidArray(@Nullable UUID[] val) throws IgniteObjectException {
-        doWriteUuidArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, DATE_ARR);
-        writeDateArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDateArray(@Nullable Date[] val) throws IgniteObjectException {
-        doWriteDateArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, TIMESTAMP_ARR);
-        writeTimestampArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTimestampArray(@Nullable Timestamp[] val) throws IgniteObjectException {
-        doWriteTimestampArray(val);
-    }
-
-     /** {@inheritDoc} */
-    @Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, OBJ_ARR);
-        writeObjectArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeObjectArray(@Nullable Object[] val) throws IgniteObjectException {
-        doWriteObjectArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> void writeCollection(String fieldName, @Nullable Collection<T> col)
-        throws IgniteObjectException {
-        writeFieldId(fieldName, COL);
-        writeCollectionField(col);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> void writeCollection(@Nullable Collection<T> col) throws IgniteObjectException {
-        doWriteCollection(col);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <K, V> void writeMap(String fieldName, @Nullable Map<K, V> map)
-        throws IgniteObjectException {
-        writeFieldId(fieldName, MAP);
-        writeMapField(map);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <K, V> void writeMap(@Nullable Map<K, V> map) throws IgniteObjectException {
-        doWriteMap(map);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T extends Enum<?>> void writeEnum(String fieldName, T val) throws IgniteObjectException {
-        writeFieldId(fieldName, ENUM);
-        writeEnumField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T extends Enum<?>> void writeEnum(T val) throws IgniteObjectException {
-        doWriteEnum(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T extends Enum<?>> void writeEnumArray(String fieldName, T[] val) throws IgniteObjectException {
-        writeFieldId(fieldName, ENUM_ARR);
-        writeEnumArrayField(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T extends Enum<?>> void writeEnumArray(T[] val) throws IgniteObjectException {
-        doWriteEnumArray(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteObjectRawWriter rawWriter() {
-        if (rawOffPos == 0)
-            rawOffPos = out.position();
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public PortableOutputStream out() {
-        return out;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("NullableProblems")
-    @Override public void writeBytes(String s) throws IOException {
-        int len = s.length();
-
-        writeInt(len);
-
-        for (int i = 0; i < len; i++)
-            writeByte(s.charAt(i));
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("NullableProblems")
-    @Override public void writeChars(String s) throws IOException {
-        int len = s.length();
-
-        writeInt(len);
-
-        for (int i = 0; i < len; i++)
-            writeChar(s.charAt(i));
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("NullableProblems")
-    @Override public void writeUTF(String s) throws IOException {
-        writeString(s);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeByte(int v) throws IOException {
-        doWriteByte((byte) v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeShort(int v) throws IOException {
-        doWriteShort((short) v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeChar(int v) throws IOException {
-        doWriteChar((char) v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void write(int b) throws IOException {
-        doWriteByte((byte) b);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void flush() throws IOException {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public int reserveInt() {
-        return reserve(LEN_INT);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeInt(int pos, int val) throws IgniteObjectException {
-        out.writeInt(pos, val);
-    }
-
-    /**
-     * @param fieldName Field name.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException If fields are not allowed.
-     */
-    private void writeFieldId(String fieldName, byte fieldType) throws IgniteObjectException {
-        A.notNull(fieldName, "fieldName");
-
-        if (rawOffPos != 0)
-            throw new IgniteObjectException("Individual field can't be written after raw writer is acquired " +
-                "via rawWriter() method. Consider fixing serialization logic for class: " + cls.getName());
-
-        if (idMapper == null)
-            idMapper = ctx.userTypeIdMapper(typeId);
-
-        int id = idMapper.fieldId(typeId, fieldName);
-
-        writeFieldId(id);
-
-        if (metaEnabled)
-            metaHashSum = 31 * metaHashSum + (id + fieldType);
-    }
-
-    /**
-     * Write field ID.
-     * @param fieldId Field ID.
-     */
-    public void writeFieldId(int fieldId) {
-        int fieldOff = out.position() - start;
-
-        if (schema == null) {
-            schema = SCHEMA.get();
-
-            if (schema == null) {
-                schema = new SchemaHolder();
-
-                SCHEMA.set(schema);
-            }
-
-            // Initialize offset when the first field is written.
-            schemaId = FNV1_OFFSET_BASIS;
-        }
-
-        // Advance schema hash.
-        int schemaId0 = schemaId ^ (fieldId & 0xFF);
-        schemaId0 = schemaId0 * FNV1_PRIME;
-        schemaId0 = schemaId0 ^ ((fieldId >> 8) & 0xFF);
-        schemaId0 = schemaId0 * FNV1_PRIME;
-        schemaId0 = schemaId0 ^ ((fieldId >> 16) & 0xFF);
-        schemaId0 = schemaId0 * FNV1_PRIME;
-        schemaId0 = schemaId0 ^ ((fieldId >> 24) & 0xFF);
-        schemaId0 = schemaId0 * FNV1_PRIME;
-
-        schemaId = schemaId0;
-
-        schema.push(fieldId, fieldOff);
-
-        fieldCnt++;
-    }
-
-    /**
-     * Attempts to write the object as a handle.
-     *
-     * @param obj Object to write.
-     * @return {@code true} if the object has been written as a handle.
-     */
-    boolean tryWriteAsHandle(Object obj) {
-        int handle = handle(obj);
-
-        if (handle >= 0) {
-            doWriteByte(GridPortableMarshaller.HANDLE);
-            doWriteInt(handle);
-
-            return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * Create new writer with same context.
-     *
-     * @param typeId type
-     * @return New writer.
-     */
-    public IgniteObjectWriterExImpl newWriter(int typeId) {
-        IgniteObjectWriterExImpl res = new IgniteObjectWriterExImpl(ctx, out, handles);
-
-        res.typeId = typeId;
-
-        return res;
-    }
-
-    /**
-     * @return Portable context.
-     */
-    public PortableContext context() {
-        return ctx;
-    }
-
-    /**
-     * Schema holder.
-     */
-    private static class SchemaHolder {
-        /** Grow step. */
-        private static final int GROW_STEP = 16;
-
-        /** Maximum stable size. */
-        private static final int MAX_SIZE = 256;
-
-        /** Data. */
-        private int[] data;
-
-        /** Index. */
-        private int idx;
-
-        /**
-         * Constructor.
-         */
-        public SchemaHolder() {
-            data = new int[GROW_STEP];
-        }
-
-        /**
-         * Push another frame.
-         *
-         * @param id Field ID.
-         * @param off Field offset.
-         */
-        public void push(int id, int off) {
-            if (idx == data.length) {
-                int[] data0 = new int[data.length + GROW_STEP];
-
-                System.arraycopy(data, 0, data0, 0, data.length);
-
-                data = data0;
-            }
-
-            data[idx] = id;
-            data[idx + 1] = off;
-
-            idx += 2;
-        }
-
-        /**
-         * Write collected frames and pop them.
-         *
-         * @param writer Writer.
-         * @param cnt Count.
-         */
-        public void writeAndPop(IgniteObjectWriterExImpl writer, int cnt) {
-            int startIdx = idx - cnt * 2;
-
-            assert startIdx >= 0;
-
-            for (int idx0 = startIdx; idx0 < idx;) {
-                writer.writeInt(data[idx0++]);
-                writer.writeInt(data[idx0++]);
-            }
-
-            idx = startIdx;
-
-            // Shrink data array if needed.
-            if (idx == 0 && data.length > MAX_SIZE)
-                data = new int[MAX_SIZE];
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git 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
index 5d76b0f..bbd6ad9 100644
--- 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
@@ -43,17 +43,10 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.MarshallerExclusions;
-import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.igniteobject.IgniteObjectException;
-import org.apache.ignite.igniteobject.IgniteObjectIdMapper;
-import org.apache.ignite.igniteobject.IgniteObjectMarshalAware;
-import org.apache.ignite.igniteobject.IgniteObjectSerializer;
-import org.jetbrains.annotations.Nullable;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryTypeIdMapper;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.binary.BinarySerializer;
 
 import static java.lang.reflect.Modifier.isStatic;
 import static java.lang.reflect.Modifier.isTransient;
@@ -69,10 +62,10 @@ public class PortableClassDescriptor {
     private final Class<?> cls;
 
     /** */
-    private final IgniteObjectSerializer serializer;
+    private final BinarySerializer serializer;
 
     /** ID mapper. */
-    private final IgniteObjectIdMapper idMapper;
+    private final BinaryTypeIdMapper idMapper;
 
     /** */
     private final Mode mode;
@@ -125,7 +118,7 @@ public class PortableClassDescriptor {
      * @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.igniteobject.IgniteObjectException In case of error.
+     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
     PortableClassDescriptor(
         PortableContext ctx,
@@ -133,13 +126,13 @@ public class PortableClassDescriptor {
         boolean userType,
         int typeId,
         String typeName,
-        @Nullable IgniteObjectIdMapper idMapper,
-        @Nullable IgniteObjectSerializer serializer,
+        @Nullable BinaryTypeIdMapper idMapper,
+        @Nullable BinarySerializer serializer,
         boolean metaDataEnabled,
         boolean keepDeserialized,
         boolean registered,
         boolean predefined
-    ) throws IgniteObjectException {
+    ) throws BinaryObjectException {
         assert ctx != null;
         assert cls != null;
 
@@ -232,12 +225,12 @@ public class PortableClassDescriptor {
                             String name = f.getName();
 
                             if (!names.add(name))
-                                throw new IgniteObjectException("Duplicate field name: " + name);
+                                throw new BinaryObjectException("Duplicate field name: " + name);
 
                             int fieldId = idMapper.fieldId(typeId, name);
 
                             if (!ids.add(fieldId))
-                                throw new IgniteObjectException("Duplicate field ID: " + name);
+                                throw new BinaryObjectException("Duplicate field ID: " + name);
 
                             FieldInfo fieldInfo = new FieldInfo(f, fieldId);
 
@@ -253,7 +246,7 @@ public class PortableClassDescriptor {
 
             default:
                 // Should never happen.
-                throw new IgniteObjectException("Invalid mode: " + mode);
+                throw new BinaryObjectException("Invalid mode: " + mode);
         }
 
         if (mode == Mode.PORTABLE || mode == Mode.EXTERNALIZABLE || mode == Mode.OBJECT) {
@@ -323,7 +316,7 @@ public class PortableClassDescriptor {
      *
      * @return ID mapper.
      */
-    public IgniteObjectIdMapper idMapper() {
+    public BinaryTypeIdMapper idMapper() {
         return idMapper;
     }
 
@@ -344,9 +337,9 @@ public class PortableClassDescriptor {
     /**
      * @param obj Object.
      * @param writer Writer.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
-    void write(Object obj, IgniteObjectWriterExImpl writer) throws IgniteObjectException {
+    void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
         assert obj != null;
         assert writer != null;
 
@@ -430,62 +423,62 @@ public class PortableClassDescriptor {
                 break;
 
             case SHORT_ARR:
-                writer.doWriteShortArray((short[]) obj);
+                writer.doWriteShortArray((short[])obj);
 
                 break;
 
             case INT_ARR:
-                writer.doWriteIntArray((int[]) obj);
+                writer.doWriteIntArray((int[])obj);
 
                 break;
 
             case LONG_ARR:
-                writer.doWriteLongArray((long[]) obj);
+                writer.doWriteLongArray((long[])obj);
 
                 break;
 
             case FLOAT_ARR:
-                writer.doWriteFloatArray((float[]) obj);
+                writer.doWriteFloatArray((float[])obj);
 
                 break;
 
             case DOUBLE_ARR:
-                writer.doWriteDoubleArray((double[]) obj);
+                writer.doWriteDoubleArray((double[])obj);
 
                 break;
 
             case CHAR_ARR:
-                writer.doWriteCharArray((char[]) obj);
+                writer.doWriteCharArray((char[])obj);
 
                 break;
 
             case BOOLEAN_ARR:
-                writer.doWriteBooleanArray((boolean[]) obj);
+                writer.doWriteBooleanArray((boolean[])obj);
 
                 break;
 
             case DECIMAL_ARR:
-                writer.doWriteDecimalArray((BigDecimal[]) obj);
+                writer.doWriteDecimalArray((BigDecimal[])obj);
 
                 break;
 
             case STRING_ARR:
-                writer.doWriteStringArray((String[]) obj);
+                writer.doWriteStringArray((String[])obj);
 
                 break;
 
             case UUID_ARR:
-                writer.doWriteUuidArray((UUID[]) obj);
+                writer.doWriteUuidArray((UUID[])obj);
 
                 break;
 
             case DATE_ARR:
-                writer.doWriteDateArray((Date[]) obj);
+                writer.doWriteDateArray((Date[])obj);
 
                 break;
 
             case TIMESTAMP_ARR:
-                writer.doWriteTimestampArray((Timestamp[]) obj);
+                writer.doWriteTimestampArray((Timestamp[])obj);
 
                 break;
 
@@ -525,27 +518,27 @@ public class PortableClassDescriptor {
                 break;
 
             case PORTABLE_OBJ:
-                writer.doWritePortableObject((IgniteObjectImpl)obj);
+                writer.doWritePortableObject((BinaryObjectImpl)obj);
 
                 break;
 
             case PORTABLE:
                 if (writeHeader(obj, writer)) {
                     if (serializer != null)
-                        serializer.writePortable(obj, writer);
+                        serializer.writeBinary(obj, writer);
                     else
-                        ((IgniteObjectMarshalAware)obj).writePortable(writer);
+                        ((Binarylizable)obj).writeBinary(writer);
 
                     writer.postWrite(userType);
 
-                    if (obj.getClass() != IgniteObjectMetaDataImpl.class
+                    if (obj.getClass() != BinaryMetaDataImpl.class
                         && ctx.isMetaDataChanged(typeId, writer.metaDataHashSum())) {
-                        IgniteObjectMetaDataCollector metaCollector = new IgniteObjectMetaDataCollector(typeName);
+                        BinaryMetaDataCollector metaCollector = new BinaryMetaDataCollector(typeName);
 
                         if (serializer != null)
-                            serializer.writePortable(obj, metaCollector);
+                            serializer.writeBinary(obj, metaCollector);
                         else
-                            ((IgniteObjectMarshalAware)obj).writePortable(metaCollector);
+                            ((Binarylizable)obj).writeBinary(metaCollector);
 
                         ctx.updateMetaData(typeId, typeName, metaCollector.meta());
                     }
@@ -561,7 +554,7 @@ public class PortableClassDescriptor {
                         ((Externalizable)obj).writeExternal(writer);
                     }
                     catch (IOException e) {
-                        throw new IgniteObjectException("Failed to write Externalizable object: " + obj, e);
+                        throw new BinaryObjectException("Failed to write Externalizable object: " + obj, e);
                     }
 
                     writer.postWrite(userType);
@@ -587,9 +580,9 @@ public class PortableClassDescriptor {
     /**
      * @param reader Reader.
      * @return Object.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException If failed.
+     * @throws org.apache.ignite.binary.BinaryObjectException If failed.
      */
-    Object read(IgniteObjectReaderExImpl reader) throws IgniteObjectException {
+    Object read(BinaryReaderExImpl reader) throws BinaryObjectException {
         assert reader != null;
 
         Object res;
@@ -601,9 +594,9 @@ public class PortableClassDescriptor {
                 reader.setHandler(res);
 
                 if (serializer != null)
-                    serializer.readPortable(res, reader);
+                    serializer.readBinary(res, reader);
                 else
-                    ((IgniteObjectMarshalAware)res).readPortable(reader);
+                    ((Binarylizable)res).readBinary(reader);
 
                 break;
 
@@ -616,7 +609,7 @@ public class PortableClassDescriptor {
                     ((Externalizable)res).readExternal(reader);
                 }
                 catch (IOException | ClassNotFoundException e) {
-                    throw new IgniteObjectException("Failed to read Externalizable object: " +
+                    throw new BinaryObjectException("Failed to read Externalizable object: " +
                         res.getClass().getName(), e);
                 }
 
@@ -648,10 +641,10 @@ public class PortableClassDescriptor {
                 throw new RuntimeException(e);
             }
             catch (InvocationTargetException e) {
-                if (e.getTargetException() instanceof IgniteObjectException)
-                    throw (IgniteObjectException)e.getTargetException();
+                if (e.getTargetException() instanceof BinaryObjectException)
+                    throw (BinaryObjectException)e.getTargetException();
 
-                throw new IgniteObjectException("Failed to execute readResolve() method on " + res, e);
+                throw new BinaryObjectException("Failed to execute readResolve() method on " + res, e);
             }
         }
 
@@ -663,7 +656,7 @@ public class PortableClassDescriptor {
      * @param writer Writer.
      * @return Whether further write is needed.
      */
-    private boolean writeHeader(Object obj, IgniteObjectWriterExImpl writer) {
+    private boolean writeHeader(Object obj, BinaryWriterExImpl writer) {
         if (writer.tryWriteAsHandle(obj))
             return false;
 
@@ -680,25 +673,25 @@ public class PortableClassDescriptor {
 
     /**
      * @return Instance.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
-    private Object newInstance() throws IgniteObjectException {
+    private Object newInstance() throws BinaryObjectException {
         assert ctor != null;
 
         try {
             return ctor.newInstance();
         }
         catch (InstantiationException | InvocationTargetException | IllegalAccessException e) {
-            throw new IgniteObjectException("Failed to instantiate instance: " + cls, e);
+            throw new BinaryObjectException("Failed to instantiate instance: " + cls, e);
         }
     }
 
     /**
      * @param cls Class.
      * @return Constructor.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException If constructor doesn't exist.
+     * @throws org.apache.ignite.binary.BinaryObjectException If constructor doesn't exist.
      */
-    @Nullable private static Constructor<?> constructor(Class<?> cls) throws IgniteObjectException {
+    @Nullable private static Constructor<?> constructor(Class<?> cls) throws BinaryObjectException {
         assert cls != null;
 
         try {
@@ -709,7 +702,7 @@ public class PortableClassDescriptor {
             return ctor;
         }
         catch (IgniteCheckedException e) {
-            throw new IgniteObjectException("Failed to get constructor for class: " + cls.getName(), e);
+            throw new BinaryObjectException("Failed to get constructor for class: " + cls.getName(), e);
         }
     }
 
@@ -801,9 +794,9 @@ public class PortableClassDescriptor {
             return Mode.TIMESTAMP_ARR;
         else if (cls.isArray())
             return cls.getComponentType().isEnum() ? Mode.ENUM_ARR : Mode.OBJ_ARR;
-        else if (cls == IgniteObjectImpl.class)
+        else if (cls == BinaryObjectImpl.class)
             return Mode.PORTABLE_OBJ;
-        else if (IgniteObjectMarshalAware.class.isAssignableFrom(cls))
+        else if (Binarylizable.class.isAssignableFrom(cls))
             return Mode.PORTABLE;
         else if (Externalizable.class.isAssignableFrom(cls))
             return Mode.EXTERNALIZABLE;
@@ -813,7 +806,7 @@ public class PortableClassDescriptor {
             return Mode.COL;
         else if (Map.class.isAssignableFrom(cls))
             return Mode.MAP;
-        else if (cls == IgniteObjectImpl.class)
+        else if (cls == BinaryObjectImpl.class)
             return Mode.PORTABLE_OBJ;
         else if (cls.isEnum())
             return Mode.ENUM;
@@ -859,9 +852,9 @@ public class PortableClassDescriptor {
         /**
          * @param obj Object.
          * @param writer Writer.
-         * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+         * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
          */
-        public void write(Object obj, IgniteObjectWriterExImpl writer) throws IgniteObjectException {
+        public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
             assert obj != null;
             assert writer != null;
 
@@ -873,7 +866,7 @@ public class PortableClassDescriptor {
                 val = field.get(obj);
             }
             catch (IllegalAccessException e) {
-                throw new IgniteObjectException("Failed to get value for field: " + field, e);
+                throw new BinaryObjectException("Failed to get value for field: " + field, e);
             }
 
             switch (mode) {
@@ -948,62 +941,62 @@ public class PortableClassDescriptor {
                     break;
 
                 case SHORT_ARR:
-                    writer.writeShortArrayField((short[]) val);
+                    writer.writeShortArrayField((short[])val);
 
                     break;
 
                 case INT_ARR:
-                    writer.writeIntArrayField((int[]) val);
+                    writer.writeIntArrayField((int[])val);
 
                     break;
 
                 case LONG_ARR:
-                    writer.writeLongArrayField((long[]) val);
+                    writer.writeLongArrayField((long[])val);
 
                     break;
 
                 case FLOAT_ARR:
-                    writer.writeFloatArrayField((float[]) val);
+                    writer.writeFloatArrayField((float[])val);
 
                     break;
 
                 case DOUBLE_ARR:
-                    writer.writeDoubleArrayField((double[]) val);
+                    writer.writeDoubleArrayField((double[])val);
 
                     break;
 
                 case CHAR_ARR:
-                    writer.writeCharArrayField((char[]) val);
+                    writer.writeCharArrayField((char[])val);
 
                     break;
 
                 case BOOLEAN_ARR:
-                    writer.writeBooleanArrayField((boolean[]) val);
+                    writer.writeBooleanArrayField((boolean[])val);
 
                     break;
 
                 case DECIMAL_ARR:
-                    writer.writeDecimalArrayField((BigDecimal[]) val);
+                    writer.writeDecimalArrayField((BigDecimal[])val);
 
                     break;
 
                 case STRING_ARR:
-                    writer.writeStringArrayField((String[]) val);
+                    writer.writeStringArrayField((String[])val);
 
                     break;
 
                 case UUID_ARR:
-                    writer.writeUuidArrayField((UUID[]) val);
+                    writer.writeUuidArrayField((UUID[])val);
 
                     break;
 
                 case DATE_ARR:
-                    writer.writeDateArrayField((Date[]) val);
+                    writer.writeDateArrayField((Date[])val);
 
                     break;
 
                 case TIMESTAMP_ARR:
-                    writer.writeTimestampArrayField((Timestamp[]) val);
+                    writer.writeTimestampArrayField((Timestamp[])val);
 
                     break;
 
@@ -1028,7 +1021,7 @@ public class PortableClassDescriptor {
                     break;
 
                 case PORTABLE_OBJ:
-                    writer.writePortableObjectField((IgniteObjectImpl)val);
+                    writer.writePortableObjectField((BinaryObjectImpl)val);
 
                     break;
 
@@ -1062,9 +1055,9 @@ public class PortableClassDescriptor {
         /**
          * @param obj Object.
          * @param reader Reader.
-         * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+         * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
          */
-        public void read(Object obj, IgniteObjectReaderExImpl reader) throws IgniteObjectException {
+        public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
             Object val = null;
 
             switch (mode) {
@@ -1254,7 +1247,7 @@ public class PortableClassDescriptor {
                     field.set(obj, val);
             }
             catch (IllegalAccessException e) {
-                throw new IgniteObjectException("Failed to set value for field: " + field, e);
+                throw new BinaryObjectException("Failed to set value for field: " + field, e);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/20f5b9cd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git 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
index 146455c..7632e2a 100644
--- 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
@@ -52,12 +52,12 @@ import java.util.jar.JarFile;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cache.CacheKeyConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.igniteobject.IgniteObjectConfiguration;
-import org.apache.ignite.igniteobject.IgniteObjectException;
-import org.apache.ignite.igniteobject.IgniteObjectIdMapper;
-import org.apache.ignite.igniteobject.IgniteObjectInvalidClassException;
-import org.apache.ignite.igniteobject.IgniteObjectMetadata;
-import org.apache.ignite.igniteobject.IgniteObjectSerializer;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryTypeIdMapper;
+import org.apache.ignite.binary.BinaryInvalidTypeException;
+import org.apache.ignite.binary.BinaryTypeMetadata;
+import org.apache.ignite.binary.BinarySerializer;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.IgnitionEx;
 import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
@@ -85,10 +85,10 @@ public class PortableContext implements Externalizable {
     private static final ClassLoader dfltLdr = U.gridClassLoader();
 
     /** */
-    static final IgniteObjectIdMapper DFLT_ID_MAPPER = new IdMapperWrapper(null);
+    static final BinaryTypeIdMapper DFLT_ID_MAPPER = new IdMapperWrapper(null);
 
     /** */
-    static final IgniteObjectIdMapper BASIC_CLS_ID_MAPPER = new BasicClassIdMapper();
+    static final BinaryTypeIdMapper BASIC_CLS_ID_MAPPER = new BasicClassIdMapper();
 
     /** */
     static final char[] LOWER_CASE_CHARS;
@@ -128,10 +128,10 @@ public class PortableContext implements Externalizable {
     private final Map<Class<? extends Map>, Byte> mapTypes = new HashMap<>();
 
     /** */
-    private final ConcurrentMap<Integer, IgniteObjectIdMapper> mappers = new ConcurrentHashMap8<>(0);
+    private final ConcurrentMap<Integer, BinaryTypeIdMapper> mappers = new ConcurrentHashMap8<>(0);
 
     /** */
-    private final Map<String, IgniteObjectIdMapper> typeMappers = new ConcurrentHashMap8<>(0);
+    private final Map<String, BinaryTypeIdMapper> typeMappers = new ConcurrentHashMap8<>(0);
 
     /** */
     private Map<Integer, Boolean> metaEnabled = new HashMap<>(0);
@@ -247,15 +247,15 @@ public class PortableContext implements Externalizable {
 
         // IDs range [200..1000] is used by Ignite internal APIs.
 
-        registerPredefinedType(IgniteObjectImpl.class, 200);
-        registerPredefinedType(IgniteObjectMetaDataImpl.class, 201);
+        registerPredefinedType(BinaryObjectImpl.class, 200);
+        registerPredefinedType(BinaryMetaDataImpl.class, 201);
     }
 
     /**
      * @param marsh Portable marshaller.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
-    public void configure(PortableMarshaller marsh) throws IgniteObjectException {
+    public void configure(PortableMarshaller marsh) throws BinaryObjectException {
         if (marsh == null)
             return;
 
@@ -286,20 +286,20 @@ public class PortableContext implements Externalizable {
      * @param globalKeepDeserialized Keep deserialized flag.
      * @param clsNames Class names.
      * @param typeCfgs Type configurations.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
     private void configure(
-        IgniteObjectIdMapper globalIdMapper,
-        IgniteObjectSerializer globalSerializer,
+        BinaryTypeIdMapper globalIdMapper,
+        BinarySerializer globalSerializer,
         boolean globalMetaDataEnabled,
         boolean globalKeepDeserialized,
         Collection<String> clsNames,
-        Collection<IgniteObjectConfiguration> typeCfgs
-    ) throws IgniteObjectException {
+        Collection<BinaryTypeConfiguration> typeCfgs
+    ) throws BinaryObjectException {
         TypeDescriptors descs = new TypeDescriptors();
 
         if (clsNames != null) {
-            IgniteObjectIdMapper idMapper = new IdMapperWrapper(globalIdMapper);
+            BinaryTypeIdMapper idMapper = new IdMapperWrapper(globalIdMapper);
 
             for (String clsName : clsNames) {
                 if (clsName.endsWith(".*")) { // Package wildcard
@@ -323,20 +323,20 @@ public class PortableContext implements Externalizable {
         }
 
         if (typeCfgs != null) {
-            for (IgniteObjectConfiguration typeCfg : typeCfgs) {
+            for (BinaryTypeConfiguration typeCfg : typeCfgs) {
                 String clsName = typeCfg.getClassName();
 
                 if (clsName == null)
-                    throw new IgniteObjectException("Class name is required for portable type configuration.");
+                    throw new BinaryObjectException("Class name is required for portable type configuration.");
 
-                IgniteObjectIdMapper idMapper = globalIdMapper;
+                BinaryTypeIdMapper idMapper = globalIdMapper;
 
                 if (typeCfg.getIdMapper() != null)
                     idMapper = typeCfg.getIdMapper();
 
                 idMapper = new IdMapperWrapper(idMapper);
 
-                IgniteObjectSerializer serializer = globalSerializer;
+                BinarySerializer serializer = globalSerializer;
 
                 if (typeCfg.getSerializer() != null)
                     serializer = typeCfg.getSerializer();
@@ -436,10 +436,10 @@ public class PortableContext implements Externalizable {
     /**
      * @param cls Class.
      * @return Class descriptor.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
     public PortableClassDescriptor descriptorForClass(Class<?> cls)
-        throws IgniteObjectException {
+        throws BinaryObjectException {
         assert cls != null;
 
         PortableClassDescriptor desc = descByCls.get(cls);
@@ -489,7 +489,7 @@ public class PortableContext implements Externalizable {
             if (userType && !ldr.equals(dfltLdr) && (desc = descriptorForTypeId(true, typeId, dfltLdr)) != null)
                 return desc;
 
-            throw new IgniteObjectInvalidClassException(e);
+            throw new BinaryInvalidTypeException(e);
         }
         catch (IgniteCheckedException e) {
             // Class might have been loaded by default class loader.
@@ -500,7 +500,7 @@ public class PortableContext implements Externalizable {
 
             U.dumpStack("Failed resolve class for ID: " + typeId);
 
-            throw new IgniteObjectException("Failed resolve class for ID: " + typeId, e);
+            throw new BinaryObjectException("Failed resolve class for ID: " + typeId, e);
         }
 
         if (desc == null) {
@@ -559,7 +559,7 @@ public class PortableContext implements Externalizable {
 
         String typeName = typeName(cls.getName());
 
-        IgniteObjectIdMapper idMapper = userTypeIdMapper(typeName);
+        BinaryTypeIdMapper idMapper = userTypeIdMapper(typeName);
 
         int typeId = idMapper.typeId(typeName);
 
@@ -567,7 +567,7 @@ public class PortableContext implements Externalizable {
             registered = marshCtx.registerClass(typeId, cls);
         }
         catch (IgniteCheckedException e) {
-            throw new IgniteObjectException("Failed to register class.", e);
+            throw new BinaryObjectException("Failed to register class.", e);
         }
 
         PortableClassDescriptor desc = new PortableClassDescriptor(this,
@@ -657,8 +657,8 @@ public class PortableContext implements Externalizable {
      * @param typeId Type ID.
      * @return Instance of ID mapper.
      */
-    public IgniteObjectIdMapper userTypeIdMapper(int typeId) {
-        IgniteObjectIdMapper idMapper = mappers.get(typeId);
+    public BinaryTypeIdMapper userTypeIdMapper(int typeId) {
+        BinaryTypeIdMapper idMapper = mappers.get(typeId);
 
         if (idMapper != null)
             return idMapper;
@@ -673,8 +673,8 @@ public class PortableContext implements Externalizable {
      * @param typeName Type name.
      * @return Instance of ID mapper.
      */
-    private IgniteObjectIdMapper userTypeIdMapper(String typeName) {
-        IgniteObjectIdMapper idMapper = typeMappers.get(typeName);
+    private BinaryTypeIdMapper userTypeIdMapper(String typeName) {
+        BinaryTypeIdMapper idMapper = typeMappers.get(typeName);
 
         return idMapper != null ? idMapper : DFLT_ID_MAPPER;
     }
@@ -744,16 +744,16 @@ public class PortableContext implements Externalizable {
      * @param affKeyFieldName Affinity key field name.
      * @param metaDataEnabled Metadata enabled flag.
      * @param keepDeserialized Keep deserialized flag.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
     @SuppressWarnings("ErrorNotRethrown")
     public void registerUserType(String clsName,
-        IgniteObjectIdMapper idMapper,
-        @Nullable IgniteObjectSerializer serializer,
+        BinaryTypeIdMapper idMapper,
+        @Nullable BinarySerializer serializer,
         @Nullable String affKeyFieldName,
         boolean metaDataEnabled,
         boolean keepDeserialized)
-        throws IgniteObjectException {
+        throws BinaryObjectException {
         assert idMapper != null;
 
         Class<?> cls = null;
@@ -769,10 +769,10 @@ public class PortableContext implements Externalizable {
 
         //Workaround for IGNITE-1358
         if (predefinedTypes.get(id) != null)
-            throw new IgniteObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
+            throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
 
         if (mappers.put(id, idMapper) != null)
-            throw new IgniteObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
+            throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
 
         String typeName = typeName(clsName);
 
@@ -805,15 +805,15 @@ public class PortableContext implements Externalizable {
             descByCls.put(cls, desc);
         }
 
-        metaHnd.addMeta(id, new IgniteObjectMetaDataImpl(typeName, fieldsMeta, affKeyFieldName));
+        metaHnd.addMeta(id, new BinaryMetaDataImpl(typeName, fieldsMeta, affKeyFieldName));
     }
 
     /**
      * @param typeId Type ID.
      * @return Meta data.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
-    @Nullable public IgniteObjectMetadata metaData(int typeId) throws IgniteObjectException {
+    @Nullable public BinaryTypeMetadata metaData(int typeId) throws BinaryObjectException {
         return metaHnd != null ? metaHnd.metadata(typeId) : null;
     }
 
@@ -852,18 +852,18 @@ public class PortableContext implements Externalizable {
      * @param typeId Type ID.
      * @param typeName Type name.
      * @param fields Fields map.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
-    public void updateMetaData(int typeId, String typeName, Map<String, String> fields) throws IgniteObjectException {
-        updateMetaData(typeId, new IgniteObjectMetaDataImpl(typeName, fields, null));
+    public void updateMetaData(int typeId, String typeName, Map<String, String> fields) throws BinaryObjectException {
+        updateMetaData(typeId, new BinaryMetaDataImpl(typeName, fields, null));
     }
 
     /**
      * @param typeId Type ID.
      * @param meta Meta data.
-     * @throws org.apache.ignite.igniteobject.IgniteObjectException In case of error.
+     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
-    public void updateMetaData(int typeId, IgniteObjectMetaDataImpl meta) throws IgniteObjectException {
+    public void updateMetaData(int typeId, BinaryMetaDataImpl meta) throws BinaryObjectException {
         metaHnd.addMeta(typeId, meta);
     }
 
@@ -1001,14 +1001,14 @@ public class PortableContext implements Externalizable {
 
     /**
      */
-    private static class IdMapperWrapper implements IgniteObjectIdMapper {
+    private static class IdMapperWrapper implements BinaryTypeIdMapper {
         /** */
-        private final IgniteObjectIdMapper mapper;
+        private final BinaryTypeIdMapper mapper;
 
         /**
          * @param mapper Custom ID mapper.
          */
-        private IdMapperWrapper(@Nullable IgniteObjectIdMapper mapper) {
+        private IdMapperWrapper(@Nullable BinaryTypeIdMapper mapper) {
             this.mapper = mapper;
         }
 
@@ -1036,7 +1036,7 @@ public class PortableContext implements Externalizable {
     /**
      * Basic class ID mapper.
      */
-    private static class BasicClassIdMapper implements IgniteObjectIdMapper {
+    private static class BasicClassIdMapper implements BinaryTypeIdMapper {
         /** {@inheritDoc} */
         @Override public int typeId(String clsName) {
             return clsName.hashCode();
@@ -1065,16 +1065,16 @@ public class PortableContext implements Externalizable {
          * @param metadataEnabled Metadata enabled flag.
          * @param keepDeserialized Keep deserialized flag.
          * @param canOverride Whether this descriptor can be override.
-         * @throws org.apache.ignite.igniteobject.IgniteObjectException If failed.
+         * @throws org.apache.ignite.binary.BinaryObjectException If failed.
          */
         private void add(String clsName,
-            IgniteObjectIdMapper idMapper,
-            IgniteObjectSerializer serializer,
+            BinaryTypeIdMapper idMapper,
+            BinarySerializer serializer,
             String affKeyFieldName,
             boolean metadataEnabled,
             boolean keepDeserialized,
             boolean canOverride)
-            throws IgniteObjectException {
+            throws BinaryObjectException {
             TypeDescriptor desc = new TypeDescriptor(clsName,
                 idMapper,
                 serializer,
@@ -1109,10 +1109,10 @@ public class PortableContext implements Externalizable {
         private final String clsName;
 
         /** ID mapper. */
-        private IgniteObjectIdMapper idMapper;
+        private BinaryTypeIdMapper idMapper;
 
         /** Serializer. */
-        private IgniteObjectSerializer serializer;
+        private BinarySerializer serializer;
 
         /** Affinity key field name. */
         private String affKeyFieldName;
@@ -1137,7 +1137,7 @@ public class PortableContext implements Externalizable {
          * @param keepDeserialized Keep deserialized flag.
          * @param canOverride Whether this descriptor can be override.
          */
-        private TypeDescriptor(String clsName, IgniteObjectIdMapper idMapper, IgniteObjectSerializer serializer,
+        private TypeDescriptor(String clsName, BinaryTypeIdMapper idMapper, BinarySerializer serializer,
             String affKeyFieldName, boolean metadataEnabled, boolean keepDeserialized,
             boolean canOverride) {
             this.clsName = clsName;
@@ -1153,9 +1153,9 @@ public class PortableContext implements Externalizable {
          * Override portable class descriptor.
          *
          * @param other Other descriptor.
-         * @throws org.apache.ignite.igniteobject.IgniteObjectException If failed.
+         * @throws org.apache.ignite.binary.BinaryObjectException If failed.
          */
-        private void override(TypeDescriptor other) throws IgniteObjectException {
+        private void override(TypeDescriptor other) throws BinaryObjectException {
             assert clsName.equals(other.clsName);
 
             if (canOverride) {
@@ -1167,7 +1167,7 @@ public class PortableContext implements Externalizable {
                 canOverride = other.canOverride;
             }
             else if (!other.canOverride)
-                throw new IgniteObjectException("Duplicate explicit class definition in configuration: " + clsName);
+                throw new BinaryObjectException("Duplicate explicit class definition in configuration: " + clsName);
         }
     }
 


Mime
View raw message