http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5674cdde/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectInputStream.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectInputStream.java
 
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectInputStream.java
deleted file mode 100644
index 690bdd6..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectInputStream.java
+++ /dev/null
@@ -1,1016 +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.marshaller.optimized;
-
-import org.apache.ignite.internal.util.*;
-import org.apache.ignite.internal.util.io.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-import sun.misc.*;
-
-import java.io.*;
-import java.lang.reflect.*;
-import java.util.*;
-
-import static 
org.apache.ignite.marshaller.optimized.IgniteOptimizedMarshallerUtils.*;
-
-/**
- * Optimized object input stream.
- */
-class IgniteOptimizedObjectInputStream extends ObjectInputStream {
-    /** Unsafe. */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** Dummy object for HashSet. */
-    private static final Object DUMMY = new Object();
-
-    /** */
-    private final HandleTable handles = new HandleTable(10);
-
-    /** */
-    private ClassLoader clsLdr;
-
-    /** */
-    private GridDataInput in;
-
-    /** */
-    private Object curObj;
-
-    /** */
-    private List<T2<IgniteOptimizedFieldType, Long>> curFields;
-
-    /** */
-    private List<IgniteBiTuple<Integer, IgniteOptimizedFieldType>> 
curFieldInfoList;
-
-    /** */
-    private Map<String, IgniteBiTuple<Integer, IgniteOptimizedFieldType>> 
curFieldInfoMap;
-
-    /** */
-    private Class<?> curCls;
-
-    /**
-     * @param in Input.
-     * @throws IOException In case of error.
-     */
-    IgniteOptimizedObjectInputStream(GridDataInput in) throws IOException {
-        this.in = in;
-    }
-
-    /**
-     * @throws IOException In case of error.
-     */
-    IgniteOptimizedObjectInputStream() throws IOException {
-        // No-op.
-    }
-
-    /**
-     * @param clsLdr Class loader.
-     */
-    void classLoader(ClassLoader clsLdr) {
-        this.clsLdr = clsLdr;
-    }
-
-    /**
-     * @return Class loader.
-     */
-    ClassLoader classLoader() {
-        return clsLdr;
-    }
-
-    /**
-     * @return Input.
-     */
-    public GridDataInput in() {
-        return in;
-    }
-
-    /**
-     * @param in Input.
-     */
-    public void in(GridDataInput in) {
-        this.in = in;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void close() throws IOException {
-        reset();
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod")
-    @Override public void reset() throws IOException {
-        in.reset();
-        handles.clear();
-
-        curObj = null;
-        curFields = null;
-        curFieldInfoList = null;
-        curFieldInfoMap = null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object readObjectOverride() throws 
ClassNotFoundException, IOException {
-        curObj = null;
-        curFields = null;
-        curFieldInfoList = null;
-        curFieldInfoMap = null;
-
-        byte ref = in.readByte();
-
-        switch (ref) {
-            case NULL:
-                return null;
-
-            case HANDLE:
-                return handles.lookup(readInt());
-
-            case OBJECT:
-                IgniteOptimizedClassDescriptor desc = 
IgniteOptimizedClassResolver.readClass(this, clsLdr);
-
-                curCls = desc.describedClass();
-
-                return desc.read(this);
-
-            default:
-                SB msg = new SB("Unexpected error occurred during 
unmarshalling");
-
-                if (curCls != null)
-                    msg.a(" of an instance of the class: 
").a(curCls.getName());
-
-                msg.a(". Check that all nodes are running the same version of 
GridGain and that all nodes have " +
-                    "GridOptimizedMarshaller configured with identical 
optimized classes lists, if any " +
-                    "(see setClassNames and setClassNamesPath methods). If 
your serialized classes implement " +
-                    "java.io.Externalizable interface, verify that 
serialization logic is correct.");
-
-                throw new IOException(msg.toString());
-        }
-    }
-
-    /**
-     * Reads array from this stream.
-     *
-     * @param compType Array component type.
-     * @return Array.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    <T> T[] readArray(Class<T> compType) throws ClassNotFoundException, 
IOException {
-        int len = in.readInt();
-
-        T[] arr = (T[])Array.newInstance(compType, len);
-
-        handles.assign(arr);
-
-        for (int i = 0; i < len; i++)
-            arr[i] = (T)readObject();
-
-        return arr;
-    }
-
-    /**
-     * Reads {@link UUID} from this stream.
-     *
-     * @return UUID.
-     * @throws IOException In case of error.
-     */
-    UUID readUuid() throws IOException {
-        UUID uuid = new UUID(readLong(), readLong());
-
-        handles.assign(uuid);
-
-        return uuid;
-    }
-
-    /**
-     * Reads {@link Properties} from this stream.
-     *
-     * @return Properties.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    Properties readProperties() throws ClassNotFoundException, IOException {
-        Properties dflts = readBoolean() ? null : (Properties)readObject();
-
-        Properties props = new Properties(dflts);
-
-        int size = in.readInt();
-
-        for (int i = 0; i < size; i++)
-            props.setProperty(readUTF(), readUTF());
-
-        handles.assign(props);
-
-        return props;
-    }
-
-    /**
-     * Reads and sets all non-static and non-transient field values from this 
stream.
-     *
-     * @param obj Object.
-     * @param fieldOffs Field offsets.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    @SuppressWarnings("ForLoopReplaceableByForEach")
-    void readFields(Object obj, List<T2<IgniteOptimizedFieldType, Long>> 
fieldOffs) throws ClassNotFoundException,
-        IOException {
-        for (int i = 0; i < fieldOffs.size(); i++) {
-            T2<IgniteOptimizedFieldType, Long> t = fieldOffs.get(i);
-
-            switch ((t.get1())) {
-                case BYTE:
-                    setByte(obj, t.get2(), readByte());
-
-                    break;
-
-                case SHORT:
-                    setShort(obj, t.get2(), readShort());
-
-                    break;
-
-                case INT:
-                    setInt(obj, t.get2(), readInt());
-
-                    break;
-
-                case LONG:
-                    setLong(obj, t.get2(), readLong());
-
-                    break;
-
-                case FLOAT:
-                    setFloat(obj, t.get2(), readFloat());
-
-                    break;
-
-                case DOUBLE:
-                    setDouble(obj, t.get2(), readDouble());
-
-                    break;
-
-                case CHAR:
-                    setChar(obj, t.get2(), readChar());
-
-                    break;
-
-                case BOOLEAN:
-                    setBoolean(obj, t.get2(), readBoolean());
-
-                    break;
-
-                case OTHER:
-                    setObject(obj, t.get2(), readObject());
-            }
-        }
-    }
-
-    /**
-     * Reads {@link Externalizable} object.
-     *
-     * @param constructor Constructor.
-     * @param readResolveMtd {@code readResolve} method.
-     * @return Object.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    Object readExternalizable(Constructor<?> constructor, Method 
readResolveMtd)
-        throws ClassNotFoundException, IOException {
-        Object obj;
-
-        try {
-            obj = constructor.newInstance();
-        }
-        catch (InstantiationException | InvocationTargetException | 
IllegalAccessException e) {
-            throw new IOException(e);
-        }
-
-        int handle = handles.assign(obj);
-
-        Externalizable extObj = ((Externalizable)obj);
-
-        extObj.readExternal(this);
-
-        if (readResolveMtd != null) {
-            try {
-                obj = readResolveMtd.invoke(obj);
-
-                handles.set(handle, obj);
-            }
-            catch (IllegalAccessException | InvocationTargetException e) {
-                throw new IOException(e);
-            }
-        }
-
-        return obj;
-    }
-
-    /**
-     * Reads serializable object.
-     *
-     * @param cls Class.
-     * @param mtds {@code readObject} methods.
-     * @param readResolveMtd {@code readResolve} method.
-     * @param fields class fields details.
-     * @return Object.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    @SuppressWarnings("ForLoopReplaceableByForEach")
-    Object readSerializable(Class<?> cls, List<Method> mtds, Method 
readResolveMtd,
-        IgniteOptimizedClassDescriptor.Fields fields) throws 
ClassNotFoundException, IOException {
-        Object obj;
-
-        try {
-            obj = UNSAFE.allocateInstance(cls);
-        }
-        catch (InstantiationException e) {
-            throw new IOException(e);
-        }
-
-        int handle = handles.assign(obj);
-
-        for (int i = 0; i < mtds.size(); i++) {
-            Method mtd = mtds.get(i);
-
-            if (mtd != null) {
-                curObj = obj;
-                curFields = fields.fieldOffs(i);
-                curFieldInfoList = fields.fieldInfoList(i);
-                curFieldInfoMap = fields.fieldInfoMap(i);
-
-                try {
-                    mtd.invoke(obj, this);
-                }
-                catch (IllegalAccessException | InvocationTargetException e) {
-                    throw new IOException(e);
-                }
-            }
-            else
-                readFields(obj, fields.fieldOffs(i));
-        }
-
-        if (readResolveMtd != null) {
-            try {
-                obj = readResolveMtd.invoke(obj);
-
-                handles.set(handle, obj);
-            }
-            catch (IllegalAccessException | InvocationTargetException e) {
-                throw new IOException(e);
-            }
-        }
-
-        return obj;
-    }
-
-    /**
-     * Reads {@link ArrayList}.
-     *
-     * @return List.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    ArrayList<?> readArrayList() throws ClassNotFoundException, IOException {
-        int size = readInt();
-
-        ArrayList<Object> list = new ArrayList<>(size);
-
-        handles.assign(list);
-
-        for (int i = 0; i < size; i++)
-            list.add(readObject());
-
-        return list;
-    }
-
-    /**
-     * Reads {@link HashMap}.
-     *
-     * @param set Whether reading underlying map from {@link HashSet}.
-     * @return Map.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    HashMap<?, ?> readHashMap(boolean set) throws ClassNotFoundException, 
IOException {
-        int size = readInt();
-        float loadFactor = readFloat();
-
-        HashMap<Object, Object> map = new HashMap<>(size, loadFactor);
-
-        if (!set)
-            handles.assign(map);
-
-        for (int i = 0; i < size; i++) {
-            Object key = readObject();
-            Object val = !set ? readObject() : DUMMY;
-
-            map.put(key, val);
-        }
-
-        return map;
-    }
-
-    /**
-     * Reads {@link HashSet}.
-     *
-     * @param mapFieldOff Map field offset.
-     * @return Set.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    HashSet<?> readHashSet(long mapFieldOff) throws ClassNotFoundException, 
IOException {
-        try {
-            HashSet<Object> set = 
(HashSet<Object>)UNSAFE.allocateInstance(HashSet.class);
-
-            handles.assign(set);
-
-            setObject(set, mapFieldOff, readHashMap(true));
-
-            return set;
-        }
-        catch (InstantiationException e) {
-            throw new IOException(e);
-        }
-    }
-
-    /**
-     * Reads {@link LinkedList}.
-     *
-     * @return List.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    LinkedList<?> readLinkedList() throws ClassNotFoundException, IOException {
-        int size = readInt();
-
-        LinkedList<Object> list = new LinkedList<>();
-
-        handles.assign(list);
-
-        for (int i = 0; i < size; i++)
-            list.add(readObject());
-
-        return list;
-    }
-
-    /**
-     * Reads {@link LinkedHashMap}.
-     *
-     * @param set Whether reading underlying map from {@link LinkedHashSet}.
-     * @return Map.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    LinkedHashMap<?, ?> readLinkedHashMap(boolean set) throws 
ClassNotFoundException, IOException {
-        int size = readInt();
-        float loadFactor = readFloat();
-        boolean accessOrder = readBoolean();
-
-        LinkedHashMap<Object, Object> map = new LinkedHashMap<>(size, 
loadFactor, accessOrder);
-
-        if (!set)
-            handles.assign(map);
-
-        for (int i = 0; i < size; i++) {
-            Object key = readObject();
-            Object val = !set ? readObject() : DUMMY;
-
-            map.put(key, val);
-        }
-
-        return map;
-    }
-
-    /**
-     * Reads {@link LinkedHashSet}.
-     *
-     * @param mapFieldOff Map field offset.
-     * @return Set.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    LinkedHashSet<?> readLinkedHashSet(long mapFieldOff) throws 
ClassNotFoundException, IOException {
-        try {
-            LinkedHashSet<Object> set = 
(LinkedHashSet<Object>)UNSAFE.allocateInstance(LinkedHashSet.class);
-
-            handles.assign(set);
-
-            setObject(set, mapFieldOff, readLinkedHashMap(true));
-
-            return set;
-        }
-        catch (InstantiationException e) {
-            throw new IOException(e);
-        }
-    }
-
-    /**
-     * Reads {@link Date}.
-     *
-     * @return Date.
-     * @throws ClassNotFoundException If class not found.
-     * @throws IOException In case of error.
-     */
-    Date readDate() throws ClassNotFoundException, IOException {
-        Date date = new Date(readLong());
-
-        handles.assign(date);
-
-        return date;
-    }
-
-    /**
-     * Reads array of {@code byte}s.
-     *
-     * @return Array.
-     * @throws IOException In case of error.
-     */
-    byte[] readByteArray() throws IOException {
-        byte[] arr = in.readByteArray();
-
-        handles.assign(arr);
-
-        return arr;
-    }
-
-    /**
-     * Reads array of {@code short}s.
-     *
-     * @return Array.
-     * @throws IOException In case of error.
-     */
-    short[] readShortArray() throws IOException {
-        short[] arr = in.readShortArray();
-
-        handles.assign(arr);
-
-        return arr;
-    }
-
-    /**
-     * Reads array of {@code int}s.
-     *
-     * @return Array.
-     * @throws IOException In case of error.
-     */
-    int[] readIntArray() throws IOException {
-        int[] arr = in.readIntArray();
-
-        handles.assign(arr);
-
-        return arr;
-    }
-
-    /**
-     * Reads array of {@code long}s.
-     *
-     * @return Array.
-     * @throws IOException In case of error.
-     */
-    long[] readLongArray() throws IOException {
-        long[] arr = in.readLongArray();
-
-        handles.assign(arr);
-
-        return arr;
-    }
-
-    /**
-     * Reads array of {@code float}s.
-     *
-     * @return Array.
-     * @throws IOException In case of error.
-     */
-    float[] readFloatArray() throws IOException {
-        float[] arr = in.readFloatArray();
-
-        handles.assign(arr);
-
-        return arr;
-    }
-
-    /**
-     * Reads array of {@code double}s.
-     *
-     * @return Array.
-     * @throws IOException In case of error.
-     */
-    double[] readDoubleArray() throws IOException {
-        double[] arr = in.readDoubleArray();
-
-        handles.assign(arr);
-
-        return arr;
-    }
-
-    /**
-     * Reads array of {@code char}s.
-     *
-     * @return Array.
-     * @throws IOException In case of error.
-     */
-    char[] readCharArray() throws IOException {
-        char[] arr = in.readCharArray();
-
-        handles.assign(arr);
-
-        return arr;
-    }
-
-    /**
-     * Reads array of {@code boolean}s.
-     *
-     * @return Array.
-     * @throws IOException In case of error.
-     */
-    boolean[] readBooleanArray() throws IOException {
-        boolean[] arr = in.readBooleanArray();
-
-        handles.assign(arr);
-
-        return arr;
-    }
-
-    /**
-     * Reads {@link String}.
-     *
-     * @return String.
-     * @throws IOException In case of error.
-     */
-    public String readString() throws IOException {
-        String str = in.readUTF();
-
-        handles.assign(str);
-
-        return str;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readFully(byte[] b) throws IOException {
-        in.readFully(b);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readFully(byte[] b, int off, int len) throws 
IOException {
-        in.readFully(b, off, len);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int skipBytes(int n) throws IOException {
-        return in.skipBytes(n);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean readBoolean() throws IOException {
-        return in.readBoolean();
-    }
-
-    /** {@inheritDoc} */
-    @Override public byte readByte() throws IOException {
-        return in.readByte();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int readUnsignedByte() throws IOException {
-        return in.readUnsignedByte();
-    }
-
-    /** {@inheritDoc} */
-    @Override public short readShort() throws IOException {
-        return in.readShort();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int readUnsignedShort() throws IOException {
-        return in.readUnsignedShort();
-    }
-
-    /** {@inheritDoc} */
-    @Override public char readChar() throws IOException {
-        return in.readChar();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int readInt() throws IOException {
-        return in.readInt();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long readLong() throws IOException {
-        return in.readLong();
-    }
-
-    /** {@inheritDoc} */
-    @Override public float readFloat() throws IOException {
-        return in.readFloat();
-    }
-
-    /** {@inheritDoc} */
-    @Override public double readDouble() throws IOException {
-        return in.readDouble();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int read() throws IOException {
-        return in.read();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int read(byte[] b) throws IOException {
-        return in.read(b);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int read(byte[] b, int off, int len) throws IOException {
-        return in.read(b, off, len);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("deprecation")
-    @Override public String readLine() throws IOException {
-        return in.readLine();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String readUTF() throws IOException {
-        return in.readUTF();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object readUnshared() throws IOException, 
ClassNotFoundException {
-        return readObject();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void defaultReadObject() throws IOException, 
ClassNotFoundException {
-        if (curObj == null)
-            throw new NotActiveException("Not in readObject() call.");
-
-        readFields(curObj, curFields);
-    }
-
-    /** {@inheritDoc} */
-    @Override public ObjectInputStream.GetField readFields() throws 
IOException, ClassNotFoundException {
-        if (curObj == null)
-            throw new NotActiveException("Not in readObject() call.");
-
-        return new GetFieldImpl(this);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void registerValidation(ObjectInputValidation obj, int 
pri) {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public int available() throws IOException {
-        return -1;
-    }
-
-    /**
-     * Returns objects that were added to handles table.
-     * Used ONLY for test purposes.
-     *
-     * @return Handled objects.
-     */
-    Object[] handledObjects() {
-        return handles.entries;
-    }
-
-    /**
-     * Lightweight identity hash table which maps objects to integer handles,
-     * assigned in ascending order.
-     */
-    private static class HandleTable {
-        /** Array mapping handle -> object/exception (depending on status). */
-        private Object[] entries;
-
-        /** Number of handles in table. */
-        private int size;
-
-        /**
-         * Creates handle table with the given initial capacity.
-         *
-         * @param initCap Initial capacity.
-         */
-        HandleTable(int initCap) {
-            entries = new Object[initCap];
-        }
-
-        /**
-         * Assigns next available handle to given object, and returns assigned
-         * handle.
-         *
-         * @param obj Object.
-         * @return Handle.
-         */
-        int assign(Object obj) {
-            if (size >= entries.length)
-                grow();
-
-            entries[size] = obj;
-
-            return size++;
-        }
-
-        /**
-         * Assigns new object to existing handle. Old object is forgotten.
-         *
-         * @param handle Handle.
-         * @param obj Object.
-         */
-        void set(int handle, Object obj) {
-            entries[handle] = obj;
-        }
-
-        /**
-         * Looks up and returns object associated with the given handle.
-         *
-         * @param handle Handle.
-         * @return Object.
-         */
-        Object lookup(int handle) {
-            return entries[handle];
-        }
-
-        /**
-         * Resets table to its initial state.
-         */
-        void clear() {
-            Arrays.fill(entries, 0, size, null);
-
-            size = 0;
-        }
-
-        /**
-         * Expands capacity of internal arrays.
-         */
-        private void grow() {
-            int newCap = (entries.length << 1) + 1;
-
-            Object[] newEntries = new Object[newCap];
-
-            System.arraycopy(entries, 0, newEntries, 0, size);
-
-            entries = newEntries;
-        }
-    }
-
-    /**
-     * {@link GetField} implementation.
-     */
-    private static class GetFieldImpl extends GetField {
-        /** Field info map. */
-        private final Map<String, IgniteBiTuple<Integer, 
IgniteOptimizedFieldType>> fieldInfoMap;
-
-        /** Values. */
-        private final Object[] objs;
-
-        /**
-         * @param in Stream.
-         * @throws IOException In case of error.
-         * @throws ClassNotFoundException If class not found.
-         */
-        @SuppressWarnings("ForLoopReplaceableByForEach")
-        private GetFieldImpl(IgniteOptimizedObjectInputStream in) throws 
IOException, ClassNotFoundException {
-            fieldInfoMap = in.curFieldInfoMap;
-
-            List<IgniteBiTuple<Integer, IgniteOptimizedFieldType>> infos = 
in.curFieldInfoList;
-
-            objs = new Object[infos.size()];
-
-            for (int i = 0; i < infos.size(); i++) {
-                IgniteBiTuple<Integer, IgniteOptimizedFieldType> t = 
infos.get(i);
-
-                Object obj = null;
-
-                switch (t.get2()) {
-                    case BYTE:
-                        obj = in.readByte();
-
-                        break;
-
-                    case SHORT:
-                        obj = in.readShort();
-
-                        break;
-
-                    case INT:
-                        obj = in.readInt();
-
-                        break;
-
-                    case LONG:
-                        obj = in.readLong();
-
-                        break;
-
-                    case FLOAT:
-                        obj = in.readFloat();
-
-                        break;
-
-                    case DOUBLE:
-                        obj = in.readDouble();
-
-                        break;
-
-                    case CHAR:
-                        obj = in.readChar();
-
-                        break;
-
-                    case BOOLEAN:
-                        obj = in.readBoolean();
-
-                        break;
-
-                    case OTHER:
-                        obj = in.readObject();
-                }
-
-                objs[t.get1()] = obj;
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public ObjectStreamClass getObjectStreamClass() {
-            throw new UnsupportedOperationException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean defaulted(String name) throws IOException {
-            return objs[fieldInfoMap.get(name).get1()] == null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean get(String name, boolean dflt) throws 
IOException {
-            return value(name, dflt);
-        }
-
-        /** {@inheritDoc} */
-        @Override public byte get(String name, byte dflt) throws IOException {
-            return value(name, dflt);
-        }
-
-        /** {@inheritDoc} */
-        @Override public char get(String name, char dflt) throws IOException {
-            return value(name, dflt);
-        }
-
-        /** {@inheritDoc} */
-        @Override public short get(String name, short dflt) throws IOException 
{
-            return value(name, dflt);
-        }
-
-        /** {@inheritDoc} */
-        @Override public int get(String name, int dflt) throws IOException {
-            return value(name, dflt);
-        }
-
-        /** {@inheritDoc} */
-        @Override public long get(String name, long dflt) throws IOException {
-            return value(name, dflt);
-        }
-
-        /** {@inheritDoc} */
-        @Override public float get(String name, float dflt) throws IOException 
{
-            return value(name, dflt);
-        }
-
-        /** {@inheritDoc} */
-        @Override public double get(String name, double dflt) throws 
IOException {
-            return value(name, dflt);
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object get(String name, Object dflt) throws 
IOException {
-            return value(name, dflt);
-        }
-
-        /**
-         * @param name Field name.
-         * @param dflt Default value.
-         * @return Value.
-         */
-        private <T> T value(String name, T dflt) {
-            return objs[fieldInfoMap.get(name).get1()] != null ? 
(T)objs[fieldInfoMap.get(name).get1()] : dflt;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5674cdde/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectOutputStream.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectOutputStream.java
 
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectOutputStream.java
deleted file mode 100644
index 8bc4a09..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectOutputStream.java
+++ /dev/null
@@ -1,839 +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.marshaller.optimized;
-
-import org.apache.ignite.internal.util.*;
-import org.apache.ignite.internal.util.io.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.lang.*;
-
-import java.io.*;
-import java.lang.reflect.*;
-import java.util.*;
-
-import static 
org.apache.ignite.marshaller.optimized.IgniteOptimizedMarshallerUtils.*;
-
-/**
- * Optimized object output stream.
- */
-class IgniteOptimizedObjectOutputStream extends ObjectOutputStream {
-    /** */
-    private static final Collection<String> CONVERTED_ERR = F.asList(
-        "weblogic/management/ManagementException",
-        "Externalizable class doesn't have default constructor: class " +
-            "org.gridgain.grid.kernal.processors.email.GridEmailProcessor$2"
-    );
-
-    /** */
-    private final GridHandleTable handles = new GridHandleTable(10, 3.00f);
-
-    /** */
-    private boolean requireSer;
-
-    /** */
-    private GridDataOutput out;
-
-    /** */
-    private Object curObj;
-
-    /** */
-    private List<T2<IgniteOptimizedFieldType, Long>> curFields;
-
-    /** */
-    private Map<String, IgniteBiTuple<Integer, IgniteOptimizedFieldType>> 
curFieldInfoMap;
-
-    /** */
-    private PutFieldImpl curPut;
-
-
-    /**
-     * @throws IOException In case of error.
-     */
-    IgniteOptimizedObjectOutputStream() throws IOException {
-        // No-op.
-    }
-
-    /**
-     * @param out Output.
-     * @throws IOException In case of error.
-     */
-    IgniteOptimizedObjectOutputStream(GridDataOutput out) throws IOException {
-        this.out = out;
-    }
-
-    /**
-     * @param requireSer Require {@link Serializable} flag.
-     */
-    void requireSerializable(boolean requireSer) {
-        this.requireSer = requireSer;
-    }
-
-    /**
-     * @return Require {@link Serializable} flag.
-     */
-    boolean requireSerializable() {
-        return requireSer;
-    }
-
-    /**
-     * @param out Output.
-     */
-    public void out(GridDataOutput out) {
-        this.out = out;
-    }
-
-    /**
-     * @return Output.
-     */
-    public GridDataOutput out() {
-        return out;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void close() throws IOException {
-        reset();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void write(byte[] b) throws IOException {
-        out.write(b);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void write(byte[] b, int off, int len) throws IOException 
{
-        out.write(b, off, len);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void writeObjectOverride(Object obj) throws 
IOException {
-        try {
-            writeObject0(obj);
-        }
-        catch (IOException e) {
-            Throwable t = e;
-
-            do {
-                if (CONVERTED_ERR.contains(t.getMessage()))
-                    throw new IOException("You are trying to serialize 
internal classes that are not supposed " +
-                        "to be serialized. Check that all non-serializable 
fields are transient. Consider using " +
-                        "static inner classes instead of non-static inner 
classes and anonymous classes.", e);
-            }
-            while ((t = t.getCause()) != null);
-
-            throw e;
-        }
-    }
-
-    /**
-     * Writes object to stream.
-     *
-     * @param obj Object.
-     * @throws IOException In case of error.
-     */
-    private void writeObject0(Object obj) throws IOException {
-        curObj = null;
-        curFields = null;
-        curPut = null;
-        curFieldInfoMap = null;
-
-        if (obj == null)
-            writeByte(NULL);
-        else {
-            Class<?> cls = obj.getClass();
-
-            IgniteOptimizedClassDescriptor desc = classDescriptor(cls, obj);
-
-            if (desc.excluded()) {
-                writeByte(NULL);
-
-                return;
-            }
-
-            Object obj0 = desc.replace(obj);
-
-            if (obj0 == null) {
-                writeByte(NULL);
-
-                return;
-            }
-
-            int handle = -1;
-
-            if (!desc.isPrimitive() && !desc.isEnum() && !desc.isClass())
-                handle = handles.lookup(obj);
-
-            if (obj0 != obj) {
-                obj = obj0;
-
-                desc = classDescriptor(obj.getClass(), obj);
-            }
-
-            if (handle >= 0) {
-                writeByte(HANDLE);
-                writeInt(handle);
-            }
-            else {
-                writeByte(OBJECT);
-
-                IgniteOptimizedClassResolver.writeClass(this, desc);
-
-                desc.write(this, obj);
-            }
-        }
-    }
-
-    /**
-     * Writes array to this stream.
-     *
-     * @param arr Array.
-     * @throws IOException In case of error.
-     */
-    @SuppressWarnings("ForLoopReplaceableByForEach")
-    void writeArray(Object[] arr) throws IOException {
-        int len = arr.length;
-
-        writeInt(len);
-
-        for (int i = 0; i < len; i++) {
-            Object obj = arr[i];
-
-            writeObject0(obj);
-        }
-    }
-
-    /**
-     * Writes {@link UUID} to this stream.
-     *
-     * @param uuid UUID.
-     * @throws IOException In case of error.
-     */
-    void writeUuid(UUID uuid) throws IOException {
-        writeLong(uuid.getMostSignificantBits());
-        writeLong(uuid.getLeastSignificantBits());
-    }
-
-    /**
-     * Writes {@link Properties} to this stream.
-     *
-     * @param props Properties.
-     * @param dfltsFieldOff Defaults field offset.
-     * @throws IOException In case of error.
-     */
-    void writeProperties(Properties props, long dfltsFieldOff) throws 
IOException {
-        Properties dflts = (Properties)getObject(props, dfltsFieldOff);
-
-        if (dflts == null)
-            writeBoolean(true);
-        else {
-            writeBoolean(false);
-
-            writeObject0(dflts);
-        }
-
-        Set<String> names = props.stringPropertyNames();
-
-        writeInt(names.size());
-
-        for (String name : names) {
-            writeUTF(name);
-            writeUTF(props.getProperty(name));
-        }
-    }
-
-    /**
-     * Writes externalizable object.
-     *
-     * @param obj Object.
-     * @throws IOException In case of error.
-     */
-    void writeExternalizable(Object obj) throws IOException {
-        Externalizable extObj = (Externalizable)obj;
-
-        extObj.writeExternal(this);
-    }
-
-    /**
-     * Writes serializable object.
-     *
-     * @param obj Object.
-     * @param mtds {@code writeObject} methods.
-     * @param fields class fields details.
-     * @throws IOException In case of error.
-     */
-    @SuppressWarnings("ForLoopReplaceableByForEach")
-    void writeSerializable(Object obj, List<Method> mtds, 
IgniteOptimizedClassDescriptor.Fields fields)
-        throws IOException {
-        for (int i = 0; i < mtds.size(); i++) {
-            Method mtd = mtds.get(i);
-
-            if (mtd != null) {
-                curObj = obj;
-                curFields = fields.fieldOffs(i);
-                curFieldInfoMap = fields.fieldInfoMap(i);
-
-                try {
-                    mtd.invoke(obj, this);
-                }
-                catch (IllegalAccessException e) {
-                    throw new IOException(e);
-                }
-                catch (InvocationTargetException e) {
-                    throw new IOException(e.getCause());
-                }
-            }
-            else
-                writeFields(obj, fields.fieldOffs(i));
-        }
-    }
-
-    /**
-     * Writes {@link ArrayList}.
-     *
-     * @param list List.
-     * @throws IOException In case of error.
-     */
-    @SuppressWarnings({"ForLoopReplaceableByForEach", "TypeMayBeWeakened"})
-    void writeArrayList(ArrayList<?> list) throws IOException {
-        int size = list.size();
-
-        writeInt(size);
-
-        for (int i = 0; i < size; i++)
-            writeObject0(list.get(i));
-    }
-
-    /**
-     * Writes {@link HashMap}.
-     *
-     * @param map Map.
-     * @param loadFactorFieldOff Load factor field offset.
-     * @param set Whether writing underlying map from {@link HashSet}.
-     * @throws IOException In case of error.
-     */
-    @SuppressWarnings("TypeMayBeWeakened")
-    void writeHashMap(HashMap<?, ?> map, long loadFactorFieldOff, boolean set) 
throws IOException {
-        int size = map.size();
-
-        writeInt(size);
-        writeFloat(getFloat(map, loadFactorFieldOff));
-
-        for (Map.Entry<?, ?> e : map.entrySet()) {
-            writeObject0(e.getKey());
-
-            if (!set)
-                writeObject0(e.getValue());
-        }
-    }
-
-    /**
-     * Writes {@link HashSet}.
-     *
-     * @param set Set.
-     * @param mapFieldOff Map field offset.
-     * @param loadFactorFieldOff Load factor field offset.
-     * @throws IOException In case of error.
-     */
-    void writeHashSet(HashSet<?> set, long mapFieldOff, long 
loadFactorFieldOff) throws IOException {
-        writeHashMap((HashMap<?, ?>)getObject(set, mapFieldOff), 
loadFactorFieldOff, true);
-    }
-
-    /**
-     * Writes {@link LinkedList}.
-     *
-     * @param list List.
-     * @throws IOException In case of error.
-     */
-    @SuppressWarnings("TypeMayBeWeakened")
-    void writeLinkedList(LinkedList<?> list) throws IOException {
-        int size = list.size();
-
-        writeInt(size);
-
-        for (Object obj : list)
-            writeObject0(obj);
-    }
-
-    /**
-     * Writes {@link LinkedHashMap}.
-     *
-     * @param map Map.
-     * @param loadFactorFieldOff Load factor field offset.
-     * @param accessOrderFieldOff access order field offset.
-     * @param set Whether writing underlying map from {@link LinkedHashSet}.
-     * @throws IOException In case of error.
-     */
-    @SuppressWarnings("TypeMayBeWeakened")
-    void writeLinkedHashMap(LinkedHashMap<?, ?> map, long loadFactorFieldOff, 
long accessOrderFieldOff, boolean set)
-        throws IOException {
-        int size = map.size();
-
-        writeInt(size);
-        writeFloat(getFloat(map, loadFactorFieldOff));
-
-        if (accessOrderFieldOff >= 0)
-            writeBoolean(getBoolean(map, accessOrderFieldOff));
-        else
-            writeBoolean(false);
-
-        for (Map.Entry<?, ?> e : map.entrySet()) {
-            writeObject0(e.getKey());
-
-            if (!set)
-                writeObject0(e.getValue());
-        }
-    }
-
-    /**
-     * Writes {@link LinkedHashSet}.
-     *
-     * @param set Set.
-     * @param mapFieldOff Map field offset.
-     * @param loadFactorFieldOff Load factor field offset.
-     * @throws IOException In case of error.
-     */
-    void writeLinkedHashSet(LinkedHashSet<?> set, long mapFieldOff, long 
loadFactorFieldOff) throws IOException {
-        LinkedHashMap<?, ?> map = (LinkedHashMap<?, ?>)getObject(set, 
mapFieldOff);
-
-        writeLinkedHashMap(map, loadFactorFieldOff, -1, true);
-    }
-
-    /**
-     * Writes {@link Date}.
-     *
-     * @param date Date.
-     * @throws IOException In case of error.
-     */
-    void writeDate(Date date) throws IOException {
-        writeLong(date.getTime());
-    }
-
-    /**
-     * Writes all non-static and non-transient field values to this stream.
-     *
-     * @param obj Object.
-     * @param fieldOffs Field offsets.
-     * @throws IOException In case of error.
-     */
-    @SuppressWarnings("ForLoopReplaceableByForEach")
-    private void writeFields(Object obj, List<T2<IgniteOptimizedFieldType, 
Long>> fieldOffs) throws IOException {
-        for (int i = 0; i < fieldOffs.size(); i++) {
-            T2<IgniteOptimizedFieldType, Long> t = fieldOffs.get(i);
-
-            switch (t.get1()) {
-                case BYTE:
-                    writeByte(getByte(obj, t.get2()));
-
-                    break;
-
-                case SHORT:
-                    writeShort(getShort(obj, t.get2()));
-
-                    break;
-
-                case INT:
-                    writeInt(getInt(obj, t.get2()));
-
-                    break;
-
-                case LONG:
-                    writeLong(getLong(obj, t.get2()));
-
-                    break;
-
-                case FLOAT:
-                    writeFloat(getFloat(obj, t.get2()));
-
-                    break;
-
-                case DOUBLE:
-                    writeDouble(getDouble(obj, t.get2()));
-
-                    break;
-
-                case CHAR:
-                    writeChar(getChar(obj, t.get2()));
-
-                    break;
-
-                case BOOLEAN:
-                    writeBoolean(getBoolean(obj, t.get2()));
-
-                    break;
-
-                case OTHER:
-                    writeObject0(getObject(obj, t.get2()));
-            }
-        }
-    }
-
-    /**
-     * Writes array of {@code byte}s.
-     *
-     * @param arr Array.
-     * @throws IOException In case of error.
-     */
-    void writeByteArray(byte[] arr) throws IOException {
-        out.writeByteArray(arr);
-    }
-
-    /**
-     * Writes array of {@code short}s.
-     *
-     * @param arr Array.
-     * @throws IOException In case of error.
-     */
-    void writeShortArray(short[] arr) throws IOException {
-        out.writeShortArray(arr);
-    }
-
-    /**
-     * Writes array of {@code int}s.
-     *
-     * @param arr Array.
-     * @throws IOException In case of error.
-     */
-    void writeIntArray(int[] arr) throws IOException {
-        out.writeIntArray(arr);
-    }
-
-    /**
-     * Writes array of {@code long}s.
-     *
-     * @param arr Array.
-     * @throws IOException In case of error.
-     */
-    void writeLongArray(long[] arr) throws IOException {
-        out.writeLongArray(arr);
-    }
-
-    /**
-     * Writes array of {@code float}s.
-     *
-     * @param arr Array.
-     * @throws IOException In case of error.
-     */
-    void writeFloatArray(float[] arr) throws IOException {
-        out.writeFloatArray(arr);
-    }
-
-    /**
-     * Writes array of {@code double}s.
-     *
-     * @param arr Array.
-     * @throws IOException In case of error.
-     */
-    void writeDoubleArray(double[] arr) throws IOException {
-        out.writeDoubleArray(arr);
-    }
-
-    /**
-     * Writes array of {@code char}s.
-     *
-     * @param arr Array.
-     * @throws IOException In case of error.
-     */
-    void writeCharArray(char[] arr) throws IOException {
-        out.writeCharArray(arr);
-    }
-
-    /**
-     * Writes array of {@code boolean}s.
-     *
-     * @param arr Array.
-     * @throws IOException In case of error.
-     */
-    void writeBooleanArray(boolean[] arr) throws IOException {
-        out.writeBooleanArray(arr);
-    }
-
-    /**
-     * Writes {@link String}.
-     *
-     * @param str String.
-     * @throws IOException In case of error.
-     */
-    void writeString(String str) throws IOException {
-        out.writeUTF(str);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeBoolean(boolean v) throws IOException {
-        out.writeBoolean(v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeByte(int v) throws IOException {
-        out.writeByte(v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeShort(int v) throws IOException {
-        out.writeShort(v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeChar(int v) throws IOException {
-        out.writeChar(v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeInt(int v) throws IOException {
-        out.writeInt(v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeLong(long v) throws IOException {
-        out.writeLong(v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeFloat(float v) throws IOException {
-        out.writeFloat(v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDouble(double v) throws IOException {
-        out.writeDouble(v);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void write(int b) throws IOException {
-        writeByte(b);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeBytes(String s) throws IOException {
-        out.writeBytes(s);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeChars(String s) throws IOException {
-        out.writeChars(s);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeUTF(String s) throws IOException {
-        out.writeUTF(s);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void useProtocolVersion(int ver) throws IOException {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeUnshared(Object obj) throws IOException {
-        writeObject0(obj);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void defaultWriteObject() throws IOException {
-        if (curObj == null)
-            throw new NotActiveException("Not in writeObject() call.");
-
-        writeFields(curObj, curFields);
-    }
-
-    /** {@inheritDoc} */
-    @Override public ObjectOutputStream.PutField putFields() throws 
IOException {
-        if (curObj == null)
-            throw new NotActiveException("Not in writeObject() call or fields 
already written.");
-
-        if (curPut == null)
-            curPut = new PutFieldImpl(this);
-
-        return curPut;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeFields() throws IOException {
-        if (curObj == null)
-            throw new NotActiveException("Not in writeObject() call.");
-
-        if (curPut == null)
-            throw new NotActiveException("putFields() was not called.");
-
-        for (IgniteBiTuple<IgniteOptimizedFieldType, Object> t : curPut.objs) {
-            switch (t.get1()) {
-                case BYTE:
-                    writeByte((Byte)t.get2());
-
-                    break;
-
-                case SHORT:
-                    writeShort((Short)t.get2());
-
-                    break;
-
-                case INT:
-                    writeInt((Integer)t.get2());
-
-                    break;
-
-                case LONG:
-                    writeLong((Long)t.get2());
-
-                    break;
-
-                case FLOAT:
-                    writeFloat((Float)t.get2());
-
-                    break;
-
-                case DOUBLE:
-                    writeDouble((Double)t.get2());
-
-                    break;
-
-                case CHAR:
-                    writeChar((Character)t.get2());
-
-                    break;
-
-                case BOOLEAN:
-                    writeBoolean((Boolean)t.get2());
-
-                    break;
-
-                case OTHER:
-                    writeObject0(t.get2());
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void reset() throws IOException {
-        out.reset();
-        handles.clear();
-
-        curObj = null;
-        curFields = null;
-        curPut = null;
-        curFieldInfoMap = null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void flush() throws IOException {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public void drain() throws IOException {
-        // No-op.
-    }
-
-    /**
-     * Returns objects that were added to handles table.
-     * Used ONLY for test purposes.
-     *
-     * @return Handled objects.
-     */
-    Object[] handledObjects() {
-        return handles.objects();
-    }
-
-    /**
-     * {@link PutField} implementation.
-     */
-    private static class PutFieldImpl extends PutField {
-        /** Stream. */
-        private final IgniteOptimizedObjectOutputStream out;
-
-        /** Field info map. */
-        private final Map<String, IgniteBiTuple<Integer, 
IgniteOptimizedFieldType>> fieldInfoMap;
-
-        /** Values. */
-        private final IgniteBiTuple<IgniteOptimizedFieldType, Object>[] objs;
-
-        /**
-         * @param out Output stream.
-         * @throws IOException In case of error.
-         */
-        @SuppressWarnings("unchecked")
-        private PutFieldImpl(IgniteOptimizedObjectOutputStream out) {
-            this.out = out;
-
-            fieldInfoMap = out.curFieldInfoMap;
-
-            objs = new IgniteBiTuple[fieldInfoMap.size()];
-        }
-
-        /** {@inheritDoc} */
-        @Override public void put(String name, boolean val) {
-            value(name, val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void put(String name, byte val) {
-            value(name, val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void put(String name, char val) {
-            value(name, val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void put(String name, short val) {
-            value(name, val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void put(String name, int val) {
-            value(name, val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void put(String name, long val) {
-            value(name, val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void put(String name, float val) {
-            value(name, val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void put(String name, double val) {
-            value(name, val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void put(String name, Object val) {
-            value(name, val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void write(ObjectOutput out) throws IOException {
-            if (out != this.out)
-                throw new IllegalArgumentException("Wrong stream.");
-
-            this.out.writeFields();
-        }
-
-        /**
-         * @param name Field name.
-         * @param val Value.
-         */
-        private void value(String name, Object val) {
-            IgniteBiTuple<Integer, IgniteOptimizedFieldType> info = 
fieldInfoMap.get(name);
-
-            objs[info.get1()] = F.t(info.get2(), val);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5674cdde/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectStreamRegistry.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectStreamRegistry.java
 
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectStreamRegistry.java
deleted file mode 100644
index 5498a88..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectStreamRegistry.java
+++ /dev/null
@@ -1,224 +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.marshaller.optimized;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.io.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-import java.io.*;
-import java.util.concurrent.*;
-
-/**
- * Storage for object streams.
- */
-class IgniteOptimizedObjectStreamRegistry {
-    /** Holders. */
-    private static final ThreadLocal<StreamHolder> holders = new 
ThreadLocal<>();
-
-    /** Holders pool. */
-    private static BlockingQueue<StreamHolder> pool;
-
-    /**
-     * Ensures singleton.
-     */
-    private IgniteOptimizedObjectStreamRegistry() {
-        // No-op.
-    }
-
-    /**
-     * Sets streams pool size.
-     *
-     * @param size Streams pool size.
-     */
-    static void poolSize(int size) {
-        if (size > 0) {
-            pool = new LinkedBlockingQueue<>(size);
-
-            for (int i = 0; i < size; i++) {
-                boolean b = pool.offer(new StreamHolder());
-
-                assert b;
-            }
-        }
-        else
-            pool = null;
-    }
-
-    /**
-     * Gets output stream.
-     *
-     * @return Object output stream.
-     * @throws org.apache.ignite.internal.IgniteInterruptedCheckedException If 
thread is interrupted while trying to take holder from pool.
-     */
-    static IgniteOptimizedObjectOutputStream out() throws 
IgniteInterruptedCheckedException {
-        return holder().acquireOut();
-    }
-
-    /**
-     * Gets input stream.
-     *
-     * @return Object input stream.
-     * @throws org.apache.ignite.internal.IgniteInterruptedCheckedException If 
thread is interrupted while trying to take holder from pool.
-     */
-    static IgniteOptimizedObjectInputStream in() throws 
IgniteInterruptedCheckedException {
-        return holder().acquireIn();
-    }
-
-    /**
-     * Closes and releases output stream.
-     *
-     * @param out Object output stream.
-     */
-    static void closeOut(IgniteOptimizedObjectOutputStream out) {
-        U.close(out, null);
-
-        StreamHolder holder = holders.get();
-
-        holder.releaseOut();
-
-        if (pool != null) {
-            holders.remove();
-
-            boolean b = pool.offer(holder);
-
-            assert b;
-        }
-    }
-
-    /**
-     * Closes and releases input stream.
-     *
-     * @param in Object input stream.
-     */
-    @SuppressWarnings("TypeMayBeWeakened")
-    static void closeIn(IgniteOptimizedObjectInputStream in) {
-        U.close(in, null);
-
-        StreamHolder holder = holders.get();
-
-        holder.releaseIn();
-
-        if (pool != null) {
-            holders.remove();
-
-            boolean b = pool.offer(holder);
-
-            assert b;
-        }
-    }
-
-    /**
-     * Gets holder from pool or thread local.
-     *
-     * @return Stream holder.
-     * @throws org.apache.ignite.internal.IgniteInterruptedCheckedException If 
thread is interrupted while trying to take holder from pool.
-     */
-    private static StreamHolder holder() throws 
IgniteInterruptedCheckedException {
-        StreamHolder holder = holders.get();
-
-        if (holder == null) {
-            try {
-                holders.set(holder = pool != null ? pool.take() : new 
StreamHolder());
-            }
-            catch (InterruptedException e) {
-                throw new IgniteInterruptedCheckedException("Failed to take 
object stream from pool (thread interrupted).", e);
-            }
-        }
-
-        return holder;
-    }
-
-    /**
-     * Streams holder.
-     */
-    private static class StreamHolder {
-        /** Output stream. */
-        private final IgniteOptimizedObjectOutputStream out = createOut();
-
-        /** Input stream. */
-        private final IgniteOptimizedObjectInputStream in = createIn();
-
-        /** Output streams counter. */
-        private int outAcquireCnt;
-
-        /** Input streams counter. */
-        private int inAcquireCnt;
-
-        /**
-         * Gets output stream.
-         *
-         * @return Object output stream.
-         */
-        IgniteOptimizedObjectOutputStream acquireOut() {
-            return outAcquireCnt++ > 0 ? createOut() : out;
-        }
-
-        /**
-         * Gets input stream.
-         *
-         * @return Object input stream.
-         */
-        IgniteOptimizedObjectInputStream acquireIn() {
-            return inAcquireCnt++ > 0 ? createIn() : in;
-        }
-
-        /**
-         * Releases output stream.
-         */
-        void releaseOut() {
-            outAcquireCnt--;
-        }
-
-        /**
-         * Releases input stream.
-         */
-        void releaseIn() {
-            inAcquireCnt--;
-        }
-
-        /**
-         * Creates output stream.
-         *
-         * @return Object output stream.
-         */
-        private IgniteOptimizedObjectOutputStream createOut() {
-            try {
-                return new IgniteOptimizedObjectOutputStream(new 
GridUnsafeDataOutput(4 * 1024));
-            }
-            catch (IOException e) {
-                throw new IgniteException("Failed to create object output 
stream.", e);
-            }
-        }
-
-        /**
-         * Creates input stream.
-         *
-         * @return Object input stream.
-         */
-        private IgniteOptimizedObjectInputStream createIn() {
-            try {
-                return new IgniteOptimizedObjectInputStream(new 
GridUnsafeDataInput());
-            }
-            catch (IOException e) {
-                throw new IgniteException("Failed to create object input 
stream.", e);
-            }
-        }
-    }
-}

Reply via email to