ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [03/14] ignite git commit: IGNITE-1513: Merged Java to core module.
Date Fri, 18 Sep 2015 10:04:07 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryPool.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryPool.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryPool.java
deleted file mode 100644
index 0aec5f0..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryPool.java
+++ /dev/null
@@ -1,140 +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.processors.platform.memory;
-
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.POOL_HDR_OFF_MEM_1;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.POOL_HDR_OFF_MEM_2;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.POOL_HDR_OFF_MEM_3;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.allocatePool;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.allocatePooled;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.allocateUnpooled;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.reallocatePooled;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.releasePooled;
-
-/**
- * Memory pool associated with a thread.
- */
-public class PlatformMemoryPool {
-    /** base pointer. */
-    private final long poolPtr;
-
-    /** First pooled memory chunk. */
-    private PlatformPooledMemory mem1;
-
-    /** Second pooled memory chunk. */
-    private PlatformPooledMemory mem2;
-
-    /** Third pooled memory chunk. */
-    private PlatformPooledMemory mem3;
-
-    /**
-     * Constructor.
-     */
-    public PlatformMemoryPool() {
-        poolPtr = allocatePool();
-
-        sun.misc.Cleaner.create(this, new CleanerRunnable(poolPtr));
-    }
-
-    /**
-     * Allocate memory chunk, optionally pooling it.
-     *
-     * @param cap Minimum capacity.
-     * @return Memory chunk.
-     */
-    public PlatformMemory allocate(int cap) {
-        long memPtr = allocatePooled(poolPtr, cap);
-
-        // memPtr == 0 means that we failed to acquire thread-local memory chunk, so fallback to unpooled memory.
-        return memPtr != 0 ? get(memPtr) : new PlatformUnpooledMemory(allocateUnpooled(cap));
-    }
-
-    /**
-     * Re-allocate existing pool memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @param cap Minimum capacity.
-     */
-    void reallocate(long memPtr, int cap) {
-        reallocatePooled(memPtr, cap);
-    }
-
-    /**
-     * Release pooled memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     */
-    void release(long memPtr) {
-        releasePooled(memPtr);
-    }
-
-    /**
-     * Get pooled memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @return Memory chunk.
-     */
-    public PlatformMemory get(long memPtr) {
-        long delta = memPtr - poolPtr;
-
-        if (delta == POOL_HDR_OFF_MEM_1) {
-            if (mem1 == null)
-                mem1 = new PlatformPooledMemory(this, memPtr);
-
-            return mem1;
-        }
-        else if (delta == POOL_HDR_OFF_MEM_2) {
-            if (mem2 == null)
-                mem2 = new PlatformPooledMemory(this, memPtr);
-
-            return mem2;
-        }
-        else {
-            assert delta == POOL_HDR_OFF_MEM_3;
-
-            if (mem3 == null)
-                mem3 = new PlatformPooledMemory(this, memPtr);
-
-            return mem3;
-        }
-    }
-
-    /**
-     * Cleaner runnable.
-     */
-    private static class CleanerRunnable implements Runnable {
-        /** Pointer. */
-        private final long poolPtr;
-
-        /**
-         * Constructor.
-         *
-         * @param poolPtr Pointer.
-         */
-        private CleanerRunnable(long poolPtr) {
-            assert poolPtr != 0;
-
-            this.poolPtr = poolPtr;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void run() {
-            PlatformMemoryUtils.releasePool(poolPtr);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
deleted file mode 100644
index 2520a47..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
+++ /dev/null
@@ -1,467 +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.processors.platform.memory;
-
-import java.nio.ByteOrder;
-import org.apache.ignite.internal.util.GridUnsafe;
-import sun.misc.Unsafe;
-
-/**
- * Utility classes for memory management.
- */
-public class PlatformMemoryUtils {
-    /** Unsafe instance. */
-    public static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** Array offset: boolean. */
-    public static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
-
-    /** Array offset: byte. */
-    public static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** Array offset: short. */
-    public static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
-
-    /** Array offset: char. */
-    public static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
-    /** Array offset: int. */
-    public static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
-
-    /** Array offset: float. */
-    public static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
-
-    /** Array offset: long. */
-    public static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
-
-    /** Array offset: double. */
-    public static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
-
-    /** Whether little endian is used on the platform. */
-    public static final boolean LITTLE_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN;
-
-    /** Header length. */
-    public static final int POOL_HDR_LEN = 64;
-
-    /** Pool header offset: first memory chunk. */
-    public static final int POOL_HDR_OFF_MEM_1 = 0;
-
-    /** Pool header offset: second memory chunk. */
-    public static final int POOL_HDR_OFF_MEM_2 = 20;
-
-    /** Pool header offset: third memory chunk. */
-    public static final int POOL_HDR_OFF_MEM_3 = 40;
-
-    /** Memory chunk header length. */
-    public static final int MEM_HDR_LEN = 20;
-
-    /** Offset: capacity. */
-    public static final int MEM_HDR_OFF_CAP = 8;
-
-    /** Offset: length. */
-    public static final int MEM_HDR_OFF_LEN = 12;
-
-    /** Offset: flags. */
-    public static final int MEM_HDR_OFF_FLAGS = 16;
-
-    /** Flag: external. */
-    public static final int FLAG_EXT = 0x1;
-
-    /** Flag: pooled. */
-    public static final int FLAG_POOLED = 0x2;
-
-    /** Flag: whether this pooled memory chunk is acquired. */
-    public static final int FLAG_ACQUIRED = 0x4;
-
-    /** --- COMMON METHODS. --- */
-
-    /**
-     * Gets data pointer for the given memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @return Data pointer.
-     */
-    public static long data(long memPtr) {
-        return UNSAFE.getLong(memPtr);
-    }
-
-    /**
-     * Gets capacity for the given memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @return Capacity.
-     */
-    public static int capacity(long memPtr) {
-        return UNSAFE.getInt(memPtr + MEM_HDR_OFF_CAP);
-    }
-
-    /**
-     * Sets capacity for the given memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @param cap Capacity.
-     */
-    public static void capacity(long memPtr, int cap) {
-        assert !isExternal(memPtr) : "Attempt to update external memory chunk capacity: " + memPtr;
-
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
-    }
-
-    /**
-     * Gets length for the given memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @return Length.
-     */
-    public static int length(long memPtr) {
-        return UNSAFE.getInt(memPtr + MEM_HDR_OFF_LEN);
-    }
-
-    /**
-     * Sets length for the given memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @param len Length.
-     */
-    public static void length(long memPtr, int len) {
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_LEN, len);
-    }
-
-    /**
-     * Gets flags for the given memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @return Flags.
-     */
-    public static int flags(long memPtr) {
-        return UNSAFE.getInt(memPtr + MEM_HDR_OFF_FLAGS);
-    }
-
-    /**
-     * Sets flags for the given memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @param flags Flags.
-     */
-    public static void flags(long memPtr, int flags) {
-        assert !isExternal(memPtr) : "Attempt to update external memory chunk flags: " + memPtr;
-
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_FLAGS, flags);
-    }
-
-    /**
-     * Check whether this memory chunk is external.
-     *
-     * @param memPtr Memory pointer.
-     * @return {@code True} if owned by native platform.
-     */
-    public static boolean isExternal(long memPtr) {
-        return isExternal(flags(memPtr));
-    }
-
-    /**
-     * Check whether flags denote that this memory chunk is external.
-     *
-     * @param flags Flags.
-     * @return {@code True} if owned by native platform.
-     */
-    public static boolean isExternal(int flags) {
-        return (flags & FLAG_EXT) == FLAG_EXT;
-    }
-
-    /**
-     * Check whether this memory chunk is pooled.
-     *
-     * @param memPtr Memory pointer.
-     * @return {@code True} if pooled.
-     */
-    public static boolean isPooled(long memPtr) {
-        return isPooled(flags(memPtr));
-    }
-
-    /**
-     * Check whether flags denote pooled memory chunk.
-     *
-     * @param flags Flags.
-     * @return {@code True} if pooled.
-     */
-    public static boolean isPooled(int flags) {
-        return (flags & FLAG_POOLED) != 0;
-    }
-
-    /**
-     * Check whether this memory chunk is pooled and acquired.
-     *
-     * @param memPtr Memory pointer.
-     * @return {@code True} if pooled and acquired.
-     */
-    public static boolean isAcquired(long memPtr) {
-        return isAcquired(flags(memPtr));
-    }
-
-    /**
-     * Check whether flags denote pooled and acquired memory chunk.
-     *
-     * @param flags Flags.
-     * @return {@code True} if acquired.
-     */
-    public static boolean isAcquired(int flags) {
-        assert isPooled(flags);
-
-        return (flags & FLAG_ACQUIRED) != 0;
-    }
-
-    /** --- UNPOOLED MEMORY MANAGEMENT. --- */
-
-    /**
-     * Allocate unpooled memory chunk.
-     *
-     * @param cap Minimum capacity.
-     * @return New memory pointer.
-     */
-    public static long allocateUnpooled(int cap) {
-        assert cap > 0;
-
-        long memPtr = UNSAFE.allocateMemory(MEM_HDR_LEN);
-        long dataPtr = UNSAFE.allocateMemory(cap);
-
-        UNSAFE.putLong(memPtr, dataPtr);              // Write address.
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write capacity.
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_LEN, 0);   // Write length.
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_FLAGS, 0); // Write flags.
-
-        return memPtr;
-    }
-
-    /**
-     * Reallocate unpooled memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @param cap Minimum capacity.
-     */
-    public static void reallocateUnpooled(long memPtr, int cap) {
-        assert cap > 0;
-
-        assert !isExternal(memPtr) : "Attempt to reallocate external memory chunk directly: " + memPtr;
-        assert !isPooled(memPtr) : "Attempt to reallocate pooled memory chunk directly: " + memPtr;
-
-        long dataPtr = data(memPtr);
-
-        long newDataPtr = UNSAFE.reallocateMemory(dataPtr, cap);
-
-        if (dataPtr != newDataPtr)
-            UNSAFE.putLong(memPtr, newDataPtr); // Write new data address if needed.
-
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write new capacity.
-    }
-
-    /**
-     * Release unpooled memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     */
-    public static void releaseUnpooled(long memPtr) {
-        assert !isExternal(memPtr) : "Attempt to release external memory chunk directly: " + memPtr;
-        assert !isPooled(memPtr) : "Attempt to release pooled memory chunk directly: " + memPtr;
-
-        UNSAFE.freeMemory(data(memPtr));
-        UNSAFE.freeMemory(memPtr);
-    }
-
-    /** --- POOLED MEMORY MANAGEMENT. --- */
-
-    /**
-     * Allocate pool memory.
-     *
-     * @return Pool pointer.
-     */
-    public static long allocatePool() {
-        long poolPtr = UNSAFE.allocateMemory(POOL_HDR_LEN);
-
-        UNSAFE.setMemory(poolPtr, POOL_HDR_LEN, (byte)0);
-
-        flags(poolPtr + POOL_HDR_OFF_MEM_1, FLAG_POOLED);
-        flags(poolPtr + POOL_HDR_OFF_MEM_2, FLAG_POOLED);
-        flags(poolPtr + POOL_HDR_OFF_MEM_3, FLAG_POOLED);
-
-        return poolPtr;
-    }
-
-    /**
-     * Release pool memory.
-     *
-     * @param poolPtr Pool pointer.
-     */
-    public static void releasePool(long poolPtr) {
-        // Clean predefined memory chunks.
-        long mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_1);
-
-        if (mem != 0)
-            UNSAFE.freeMemory(mem);
-
-        mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_2);
-
-        if (mem != 0)
-            UNSAFE.freeMemory(mem);
-
-        mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_3);
-
-        if (mem != 0)
-            UNSAFE.freeMemory(mem);
-
-        // Clean pool chunk.
-        UNSAFE.freeMemory(poolPtr);
-    }
-
-    /**
-     * Allocate pooled memory chunk.
-     *
-     * @param poolPtr Pool pointer.
-     * @param cap Capacity.
-     * @return Cross-platform memory pointer or {@code 0} in case there are no free memory chunks in the pool.
-     */
-    public static long allocatePooled(long poolPtr, int cap) {
-        long memPtr1 = poolPtr + POOL_HDR_OFF_MEM_1;
-
-        if (isAcquired(memPtr1)) {
-            long memPtr2 = poolPtr + POOL_HDR_OFF_MEM_2;
-
-            if (isAcquired(memPtr2)) {
-                long memPtr3 = poolPtr + POOL_HDR_OFF_MEM_3;
-
-                if (isAcquired(memPtr3))
-                    return 0L;
-                else {
-                    allocatePooled0(memPtr3, cap);
-
-                    return memPtr3;
-                }
-            }
-            else {
-                allocatePooled0(memPtr2, cap);
-
-                return memPtr2;
-            }
-        }
-        else {
-            allocatePooled0(memPtr1, cap);
-
-            return memPtr1;
-        }
-    }
-
-    /**
-     * Internal pooled memory chunk allocation routine.
-     *
-     * @param memPtr Memory pointer.
-     * @param cap Capacity.
-     */
-    private static void allocatePooled0(long memPtr, int cap) {
-        assert !isExternal(memPtr);
-        assert isPooled(memPtr);
-        assert !isAcquired(memPtr);
-
-        long data = UNSAFE.getLong(memPtr);
-
-        if (data == 0) {
-            // First allocation of the chunk.
-            data = UNSAFE.allocateMemory(cap);
-
-            UNSAFE.putLong(memPtr, data);
-            UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
-        }
-        else {
-            // Ensure that we have enough capacity.
-            int curCap = capacity(memPtr);
-
-            if (cap > curCap) {
-                data = UNSAFE.reallocateMemory(data, cap);
-
-                UNSAFE.putLong(memPtr, data);
-                UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
-            }
-        }
-
-        flags(memPtr, FLAG_POOLED | FLAG_ACQUIRED);
-    }
-
-    /**
-     * Reallocate pooled memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @param cap Minimum capacity.
-     */
-    public static void reallocatePooled(long memPtr, int cap) {
-        assert !isExternal(memPtr);
-        assert isPooled(memPtr);
-        assert isAcquired(memPtr);
-
-        long data = UNSAFE.getLong(memPtr);
-
-        assert data != 0;
-
-        int curCap = capacity(memPtr);
-
-        if (cap > curCap) {
-            data = UNSAFE.reallocateMemory(data, cap);
-
-            UNSAFE.putLong(memPtr, data);
-            UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
-        }
-    }
-
-    /**
-     * Release pooled memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     */
-    public static void releasePooled(long memPtr) {
-        assert !isExternal(memPtr);
-        assert isPooled(memPtr);
-        assert isAcquired(memPtr);
-
-        flags(memPtr, flags(memPtr) ^ FLAG_ACQUIRED);
-    }
-
-    /** --- UTILITY STUFF. --- */
-
-    /**
-     * Reallocate arbitrary memory chunk.
-     *
-     * @param memPtr Memory pointer.
-     * @param cap Capacity.
-     */
-    public static void reallocate(long memPtr, int cap) {
-        int flags = flags(memPtr);
-
-        if (isPooled(flags))
-            reallocatePooled(memPtr, cap);
-        else {
-            assert !isExternal(flags);
-
-            reallocateUnpooled(memPtr, cap);
-        }
-    }
-
-    /**
-     * Constructor.
-     */
-    private PlatformMemoryUtils() {
-        // No-op.
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
deleted file mode 100644
index 13c3dd3..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
+++ /dev/null
@@ -1,267 +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.processors.platform.memory;
-
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.BOOLEAN_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.CHAR_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.DOUBLE_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.FLOAT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.INT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.LONG_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.SHORT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.UNSAFE;
-
-/**
- * Interop output stream implementation.
- */
-public class PlatformOutputStreamImpl implements PlatformOutputStream {
-    /** Underlying memory chunk. */
-    protected final PlatformMemory mem;
-
-    /** Pointer. */
-    protected long data;
-
-    /** Maximum capacity. */
-    protected int cap;
-
-    /** Current position. */
-    protected int pos;
-
-    /**
-     * Constructor.
-     *
-     * @param mem Underlying memory chunk.
-     */
-    public PlatformOutputStreamImpl(PlatformMemory mem) {
-        this.mem = mem;
-
-        data = mem.data();
-        cap = mem.capacity();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeByte(byte val) {
-        ensureCapacity(pos + 1);
-
-        UNSAFE.putByte(data + pos++, val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeByteArray(byte[] val) {
-        copyAndShift(val, BYTE_ARR_OFF, val.length);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeBoolean(boolean val) {
-        writeByte(val ? (byte) 1 : (byte) 0);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeBooleanArray(boolean[] val) {
-        copyAndShift(val, BOOLEAN_ARR_OFF, val.length);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeShort(short val) {
-        ensureCapacity(pos + 2);
-
-        UNSAFE.putShort(data + pos, val);
-
-        shift(2);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeShortArray(short[] val) {
-        copyAndShift(val, SHORT_ARR_OFF, val.length << 1);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeChar(char val) {
-        ensureCapacity(pos + 2);
-
-        UNSAFE.putChar(data + pos, val);
-
-        shift(2);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeCharArray(char[] val) {
-        copyAndShift(val, CHAR_ARR_OFF, val.length << 1);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeInt(int val) {
-        ensureCapacity(pos + 4);
-
-        UNSAFE.putInt(data + pos, val);
-
-        shift(4);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeIntArray(int[] val) {
-        copyAndShift(val, INT_ARR_OFF, val.length << 2);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeInt(int pos, int val) {
-        ensureCapacity(pos + 4);
-
-        UNSAFE.putInt(data + pos, val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeFloat(float val) {
-        writeInt(Float.floatToIntBits(val));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeFloatArray(float[] val) {
-        copyAndShift(val, FLOAT_ARR_OFF, val.length << 2);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeLong(long val) {
-        ensureCapacity(pos + 8);
-
-        UNSAFE.putLong(data + pos, val);
-
-        shift(8);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeLongArray(long[] val) {
-        copyAndShift(val, LONG_ARR_OFF, val.length << 3);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDouble(double val) {
-        writeLong(Double.doubleToLongBits(val));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeDoubleArray(double[] val) {
-        copyAndShift(val, DOUBLE_ARR_OFF, val.length << 3);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void write(byte[] arr, int off, int len) {
-        copyAndShift(arr, BYTE_ARR_OFF + off, len);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void write(long addr, int cnt) {
-        copyAndShift(null, addr, cnt);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int position() {
-        return pos;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void position(int pos) {
-        ensureCapacity(pos);
-
-        this.pos = pos;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void close() {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public byte[] array() {
-        assert false;
-
-        throw new UnsupportedOperationException("Should not be called.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public byte[] arrayCopy() {
-        assert false;
-
-        throw new UnsupportedOperationException("Should not be called.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public long offheapPointer() {
-        assert false;
-
-        throw new UnsupportedOperationException("Should not be called.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean hasArray() {
-        assert false;
-
-        throw new UnsupportedOperationException("Should not be called.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public void synchronize() {
-        PlatformMemoryUtils.length(mem.pointer(), pos);
-    }
-
-    /**
-     * Ensure capacity.
-     *
-     * @param reqCap Required byte count.
-     */
-    protected void ensureCapacity(int reqCap) {
-        if (reqCap > cap) {
-            int newCap = cap << 1;
-
-            if (newCap < reqCap)
-                newCap = reqCap;
-
-            mem.reallocate(newCap);
-
-            assert mem.capacity() >= newCap;
-
-            data = mem.data();
-            cap = newCap;
-        }
-    }
-
-    /**
-     * Shift position.
-     *
-     * @param cnt Byte count.
-     */
-    protected void shift(int cnt) {
-        pos += cnt;
-    }
-
-    /**
-     * Copy source object to the stream shifting position afterwards.
-     *
-     * @param src Source.
-     * @param off Offset.
-     * @param len Length.
-     */
-    private void copyAndShift(Object src, long off, int len) {
-        ensureCapacity(pos + len);
-
-        UNSAFE.copyMemory(src, off, null, data + pos, len);
-
-        shift(len);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformPooledMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformPooledMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformPooledMemory.java
deleted file mode 100644
index df38c22..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformPooledMemory.java
+++ /dev/null
@@ -1,64 +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.processors.platform.memory;
-
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.isAcquired;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.isPooled;
-
-/**
- * Interop pooled memory chunk.
- */
-public class PlatformPooledMemory extends PlatformAbstractMemory {
-    /** Owning memory pool. */
-    private final PlatformMemoryPool pool;
-
-    /**
-     * Constructor.
-     *
-     * @param pool Owning memory pool.
-     * @param memPtr Cross-platform memory pointer.
-     */
-    public PlatformPooledMemory(PlatformMemoryPool pool, long memPtr) {
-        super(memPtr);
-
-        assert isPooled(memPtr);
-        assert isAcquired(memPtr);
-
-        this.pool = pool;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void reallocate(int cap) {
-        assert isAcquired(memPtr);
-
-        // Try doubling capacity to avoid excessive allocations.
-        int doubledCap = PlatformMemoryUtils.capacity(memPtr) << 1;
-
-        if (doubledCap > cap)
-            cap = doubledCap;
-
-        pool.reallocate(memPtr, cap);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void close() {
-        assert isAcquired(memPtr);
-
-        pool.release(memPtr); // Return to the pool.
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformUnpooledMemory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformUnpooledMemory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformUnpooledMemory.java
deleted file mode 100644
index 9d0d30a..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformUnpooledMemory.java
+++ /dev/null
@@ -1,51 +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.processors.platform.memory;
-
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.reallocateUnpooled;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.releaseUnpooled;
-
-/**
- * Interop un-pooled memory chunk.
- */
-public class PlatformUnpooledMemory extends PlatformAbstractMemory {
-    /**
-     * Constructor.
-     *
-     * @param memPtr Cross-platform memory pointer.
-     */
-    public PlatformUnpooledMemory(long memPtr) {
-        super(memPtr);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void reallocate(int cap) {
-        // Try doubling capacity to avoid excessive allocations.
-        int doubledCap = PlatformMemoryUtils.capacity(memPtr) << 1;
-
-        if (doubledCap > cap)
-            cap = doubledCap;
-
-        reallocateUnpooled(memPtr, cap);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void close() {
-        releaseUnpooled(memPtr);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageFilterImpl.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageFilterImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageFilterImpl.java
deleted file mode 100644
index 67d5bbb..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageFilterImpl.java
+++ /dev/null
@@ -1,110 +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.processors.platform.messaging;
-
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.portable.PortableRawWriterEx;
-import org.apache.ignite.internal.processors.platform.PlatformAbstractPredicate;
-import org.apache.ignite.internal.processors.platform.PlatformContext;
-import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
-import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
-import org.apache.ignite.internal.processors.platform.message.PlatformMessageFilter;
-import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
-
-import java.util.UUID;
-
-/**
- * Platform message filter. Delegates apply to native platform.
- */
-public class PlatformMessageFilterImpl extends PlatformAbstractPredicate implements PlatformMessageFilter {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /**
-     * Constructor.
-     */
-    public PlatformMessageFilterImpl()
-    {
-        super();
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param pred .Net portable predicate.
-     * @param ptr Pointer to predicate in the native platform.
-     * @param ctx Kernal context.
-     */
-    public PlatformMessageFilterImpl(Object pred, long ptr, PlatformContext ctx) {
-        super(pred, ptr, ctx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean apply(UUID uuid, Object m) {
-        if (ptr == 0)
-            return false;  // Destroyed.
-
-        try (PlatformMemory mem = ctx.memory().allocate()) {
-            PlatformOutputStream out = mem.output();
-
-            PortableRawWriterEx writer = ctx.writer(out);
-
-            writer.writeObject(uuid);
-            writer.writeObject(m);
-
-            out.synchronize();
-
-            return ctx.gateway().messagingFilterApply(ptr, mem.pointer()) != 0;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void initialize(GridKernalContext kernalCtx) {
-        if (ptr != 0)
-            return;
-
-        ctx = PlatformUtils.platformContext(kernalCtx.grid());
-
-        try (PlatformMemory mem = ctx.memory().allocate()) {
-            PlatformOutputStream out = mem.output();
-
-            PortableRawWriterEx writer = ctx.writer(out);
-
-            writer.writeObject(pred);
-
-            out.synchronize();
-
-            ptr = ctx.gateway().messagingFilterCreate(mem.pointer());
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onClose() {
-        if (ptr == 0) // Already destroyed or not initialized yet.
-            return;
-
-        try {
-            assert ctx != null;
-
-            ctx.gateway().messagingFilterDestroy(ptr);
-        }
-        finally {
-            ptr = 0;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageLocalFilter.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageLocalFilter.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageLocalFilter.java
deleted file mode 100644
index 50643e1..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageLocalFilter.java
+++ /dev/null
@@ -1,102 +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.processors.platform.messaging;
-
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.portable.PortableRawWriterEx;
-import org.apache.ignite.internal.processors.platform.PlatformContext;
-import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
-import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
-import org.apache.ignite.internal.processors.platform.message.PlatformMessageFilter;
-
-import java.util.UUID;
-
-/**
- * Interop local filter. Delegates apply to native platform, uses id to identify native target.
- */
-public class PlatformMessageLocalFilter implements PlatformMessageFilter {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** */
-    protected final long hnd;
-
-    /** */
-    protected final PlatformContext platformCtx;
-
-    /**
-     * Constructor.
-     *
-     * @param hnd Handle in the native platform.
-     * @param ctx Context.
-     */
-    public PlatformMessageLocalFilter(long hnd, PlatformContext ctx) {
-        assert ctx != null;
-        assert hnd != 0;
-
-        this.hnd = hnd;
-        this.platformCtx = ctx;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean apply(UUID uuid, Object m) {
-        try (PlatformMemory mem = platformCtx.memory().allocate()) {
-            PlatformOutputStream out = mem.output();
-
-            PortableRawWriterEx writer = platformCtx.writer(out);
-
-            writer.writeObject(uuid);
-            writer.writeObject(m);
-
-            out.synchronize();
-
-            int res = platformCtx.gateway().messagingFilterApply(hnd, mem.pointer());
-
-            return res != 0;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onClose() {
-        platformCtx.gateway().messagingFilterDestroy(hnd);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void initialize(GridKernalContext ctx) {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (this == o)
-            return true;
-
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        PlatformMessageLocalFilter filter = (PlatformMessageLocalFilter)o;
-
-        return hnd == filter.hnd;
-
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        return (int)(hnd ^ (hnd >>> 32));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
deleted file mode 100644
index 6dfd570..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
+++ /dev/null
@@ -1,166 +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.processors.platform.messaging;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.internal.portable.PortableRawReaderEx;
-import org.apache.ignite.internal.portable.PortableRawWriterEx;
-import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
-import org.apache.ignite.internal.processors.platform.PlatformContext;
-import org.apache.ignite.internal.processors.platform.message.PlatformMessageFilter;
-import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
-import org.apache.ignite.lang.IgniteFuture;
-
-import java.util.UUID;
-
-/**
- * Interop messaging.
- */
-public class PlatformMessaging extends PlatformAbstractTarget {
-    /** */
-    public static final int OP_LOC_LISTEN = 1;
-
-    /** */
-    public static final int OP_REMOTE_LISTEN = 2;
-
-    /** */
-    public static final int OP_SEND = 3;
-
-    /** */
-    public static final int OP_SEND_MULTI = 4;
-
-    /** */
-    public static final int OP_SEND_ORDERED = 5;
-
-    /** */
-    public static final int OP_STOP_LOC_LISTEN = 6;
-
-    /** */
-    public static final int OP_STOP_REMOTE_LISTEN = 7;
-
-    /** */
-    private final IgniteMessaging messaging;
-
-    /**
-     * Ctor.
-     *
-     * @param platformCtx Context.
-     * @param messaging Ignite messaging.
-     */
-    public PlatformMessaging(PlatformContext platformCtx, IgniteMessaging messaging) {
-        super(platformCtx);
-
-        assert messaging != null;
-
-        this.messaging = messaging;
-    }
-
-    /**
-     * Gets messaging with asynchronous mode enabled.
-     *
-     * @return Messaging with asynchronous mode enabled.
-     */
-    public PlatformMessaging withAsync() {
-        if (messaging.isAsync())
-            return this;
-
-        return new PlatformMessaging (platformCtx, messaging.withAsync());
-    }
-
-    /** {@inheritDoc} */
-    @Override protected long processInStreamOutLong(int type, PortableRawReaderEx reader)
-        throws IgniteCheckedException {
-        switch (type) {
-            case OP_SEND:
-                messaging.send(reader.readObjectDetached(), reader.readObjectDetached());
-
-                return TRUE;
-
-            case OP_SEND_MULTI:
-                messaging.send(reader.readObjectDetached(), PlatformUtils.readCollection(reader));
-
-                return TRUE;
-
-            case OP_SEND_ORDERED:
-                messaging.sendOrdered(reader.readObjectDetached(), reader.readObjectDetached(), reader.readLong());
-
-                return TRUE;
-
-            case OP_LOC_LISTEN: {
-                PlatformMessageLocalFilter filter = new PlatformMessageLocalFilter(reader.readLong(), platformCtx);
-
-                Object topic = reader.readObjectDetached();
-
-                messaging.localListen(topic, filter);
-
-                return TRUE;
-            }
-
-            case OP_STOP_LOC_LISTEN: {
-                PlatformMessageLocalFilter filter = new PlatformMessageLocalFilter(reader.readLong(), platformCtx);
-
-                Object topic = reader.readObjectDetached();
-
-                messaging.stopLocalListen(topic, filter);
-
-                return TRUE;
-            }
-
-            case OP_STOP_REMOTE_LISTEN: {
-                messaging.stopRemoteListen(reader.readUuid());
-
-                return TRUE;
-            }
-
-            default:
-                return super.processInStreamOutLong(type, reader);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"IfMayBeConditional", "ConstantConditions", "unchecked"})
-    @Override protected void processInStreamOutStream(int type, PortableRawReaderEx reader, PortableRawWriterEx writer)
-        throws IgniteCheckedException {
-        switch (type) {
-            case OP_REMOTE_LISTEN:{
-                Object nativeFilter = reader.readObjectDetached();
-
-                long ptr = reader.readLong();  // interop pointer
-
-                Object topic = reader.readObjectDetached();
-
-                PlatformMessageFilter filter = platformCtx.createRemoteMessageFilter(nativeFilter, ptr);
-
-                UUID listenId = messaging.remoteListen(topic, filter);
-
-                writer.writeUuid(listenId);
-
-                break;
-            }
-
-            default:
-                super.processInStreamOutStream(type, reader, writer);
-        }
-    }
-
-    /** <inheritDoc /> */
-    @Override protected IgniteFuture currentFuture() throws IgniteCheckedException {
-        return messaging.future();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java
deleted file mode 100644
index 0b9ee53..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java
+++ /dev/null
@@ -1,230 +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.processors.platform.services;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.portable.PortableRawReaderEx;
-import org.apache.ignite.internal.portable.PortableRawWriterEx;
-import org.apache.ignite.internal.processors.platform.PlatformContext;
-import org.apache.ignite.internal.processors.platform.memory.PlatformInputStream;
-import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
-import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
-import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.services.ServiceContext;
-
-/**
- * Base platform service implementation.
- */
-public abstract class PlatformAbstractService implements PlatformService, Externalizable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** .Net portable service. */
-    protected Object svc;
-
-    /** Whether to keep objects portable on server if possible. */
-    protected boolean srvKeepPortable;
-
-    /** Pointer to deployed service. */
-    protected transient long ptr;
-
-    /** Context. */
-    protected transient PlatformContext platformCtx;
-
-    /**
-     * Default constructor for serialization.
-     */
-    public PlatformAbstractService() {
-        // No-op.
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param svc Service.
-     * @param ctx Context.
-     * @param srvKeepPortable Whether to keep objects portable on server if possible.
-     */
-    public PlatformAbstractService(Object svc, PlatformContext ctx, boolean srvKeepPortable) {
-        assert svc != null;
-        assert ctx != null;
-
-        this.svc = svc;
-        this.platformCtx = ctx;
-        this.srvKeepPortable = srvKeepPortable;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void init(ServiceContext ctx) throws Exception {
-        assert ptr == 0;
-        assert platformCtx != null;
-
-        try (PlatformMemory mem = platformCtx.memory().allocate()) {
-            PlatformOutputStream out = mem.output();
-
-            PortableRawWriterEx writer = platformCtx.writer(out);
-
-            writer.writeBoolean(srvKeepPortable);
-            writer.writeObject(svc);
-
-            writeServiceContext(ctx, writer);
-
-            out.synchronize();
-
-            ptr = platformCtx.gateway().serviceInit(mem.pointer());
-        }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void execute(ServiceContext ctx) throws Exception {
-        assert ptr != 0;
-        assert platformCtx != null;
-
-        try (PlatformMemory mem = platformCtx.memory().allocate()) {
-            PlatformOutputStream out = mem.output();
-
-            PortableRawWriterEx writer = platformCtx.writer(out);
-
-            writer.writeBoolean(srvKeepPortable);
-
-            writeServiceContext(ctx, writer);
-
-            out.synchronize();
-
-            platformCtx.gateway().serviceExecute(ptr, mem.pointer());
-        }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void cancel(ServiceContext ctx) {
-        assert ptr != 0;
-        assert platformCtx != null;
-
-        try (PlatformMemory mem = platformCtx.memory().allocate()) {
-            PlatformOutputStream out = mem.output();
-
-            PortableRawWriterEx writer = platformCtx.writer(out);
-
-            writer.writeBoolean(srvKeepPortable);
-
-            writeServiceContext(ctx, writer);
-
-            out.synchronize();
-
-            platformCtx.gateway().serviceCancel(ptr, mem.pointer());
-        }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
-        }
-    }
-
-    /**
-     * Writes service context.
-     *
-     * @param ctx Context.
-     * @param writer Writer.
-     */
-    private void writeServiceContext(ServiceContext ctx, PortableRawWriterEx writer) {
-        writer.writeString(ctx.name());
-        writer.writeUuid(ctx.executionId());
-        writer.writeBoolean(ctx.isCancelled());
-        writer.writeString(ctx.cacheName());
-        writer.writeObject(ctx.affinityKey());
-    }
-
-    /** {@inheritDoc} */
-    @Override public long pointer() {
-        assert ptr != 0;
-
-        return ptr;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object invokeMethod(String mthdName, boolean srvKeepPortable, Object[] args)
-        throws IgniteCheckedException {
-        assert ptr != 0;
-        assert platformCtx != null;
-
-        try (PlatformMemory outMem = platformCtx.memory().allocate()) {
-            PlatformOutputStream out = outMem.output();
-            PortableRawWriterEx writer = platformCtx.writer(out);
-
-            writer.writeBoolean(srvKeepPortable);
-            writer.writeString(mthdName);
-
-            if (args == null)
-                writer.writeBoolean(false);
-            else {
-                writer.writeBoolean(true);
-                writer.writeInt(args.length);
-
-                for (Object arg : args)
-                    writer.writeObjectDetached(arg);
-            }
-
-            out.synchronize();
-
-            try (PlatformMemory inMem = platformCtx.memory().allocate()) {
-                PlatformInputStream in = inMem.input();
-
-                PortableRawReaderEx reader = platformCtx.reader(in);
-
-                platformCtx.gateway().serviceInvokeMethod(ptr, outMem.pointer(), inMem.pointer());
-
-                in.synchronize();
-
-                return PlatformUtils.readInvocationResult(platformCtx, reader);
-            }
-        }
-    }
-
-    /**
-     * @param ignite Ignite instance.
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    @IgniteInstanceResource
-    public void setIgniteInstance(Ignite ignite) {
-        // Ignite instance can be null here because service processor invokes "cleanup" on resource manager.
-        platformCtx = ignite != null ? PlatformUtils.platformContext(ignite) : null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        svc = in.readObject();
-        srvKeepPortable = in.readBoolean();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(svc);
-        out.writeBoolean(srvKeepPortable);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
deleted file mode 100644
index bfa4570..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
+++ /dev/null
@@ -1,275 +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.processors.platform.services;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteServices;
-import org.apache.ignite.internal.portable.PortableRawReaderEx;
-import org.apache.ignite.internal.portable.PortableRawWriterEx;
-import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
-import org.apache.ignite.internal.processors.platform.PlatformContext;
-import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetService;
-import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetServiceImpl;
-import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
-import org.apache.ignite.internal.processors.platform.utils.PlatformWriterBiClosure;
-import org.apache.ignite.internal.processors.platform.utils.PlatformWriterClosure;
-import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.services.Service;
-import org.apache.ignite.services.ServiceConfiguration;
-import org.apache.ignite.services.ServiceDescriptor;
-
-/**
- * Interop services.
- */
-@SuppressWarnings({"UnusedDeclaration"})
-public class PlatformServices extends PlatformAbstractTarget {
-    /** */
-    private static final int OP_DOTNET_DEPLOY = 1;
-
-    /** */
-    private static final int OP_DOTNET_DEPLOY_MULTIPLE = 2;
-
-    /** */
-    private static final int OP_DOTNET_SERVICES = 3;
-
-    /** */
-    private static final int OP_DOTNET_INVOKE = 4;
-
-    /** */
-    private static final int OP_DESCRIPTORS = 5;
-
-    /** */
-    private final IgniteServices services;
-
-    /** Server keep portable flag. */
-    private final boolean srvKeepPortable;
-
-    /**
-     * Ctor.
-     *
-     * @param platformCtx Context.
-     * @param services Services facade.
-     * @param srvKeepPortable Server keep portable flag.
-     */
-    public PlatformServices(PlatformContext platformCtx, IgniteServices services, boolean srvKeepPortable) {
-        super(platformCtx);
-
-        assert services != null;
-
-        this.services = services;
-        this.srvKeepPortable = srvKeepPortable;
-    }
-
-    /**
-     * Gets services with asynchronous mode enabled.
-     *
-     * @return Services with asynchronous mode enabled.
-     */
-    public PlatformServices withAsync() {
-        if (services.isAsync())
-            return this;
-
-        return new PlatformServices(platformCtx, services.withAsync(), srvKeepPortable);
-    }
-
-    /**
-     * Gets services with server "keep portable" mode enabled.
-     *
-     * @return Services with server "keep portable" mode enabled.
-     */
-    public PlatformServices withServerKeepPortable() {
-        return srvKeepPortable ? this : new PlatformServices(platformCtx, services, true);
-    }
-
-    /**
-     * Cancels service deployment.
-     *
-     * @param name Name of service to cancel.
-     */
-    public void cancel(String name) {
-        services.cancel(name);
-    }
-
-    /**
-     * Cancels all deployed services.
-     */
-    public void cancelAll() {
-        services.cancelAll();
-    }
-
-    /**
-     * Gets a remote handle on the service.
-     *
-     * @param name Service name.
-     * @param sticky Whether or not Ignite should always contact the same remote service.
-     * @return Either proxy over remote service or local service if it is deployed locally.
-     */
-    public Object dotNetServiceProxy(String name, boolean sticky) {
-        return services.serviceProxy(name, PlatformDotNetService.class, sticky);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected long processInStreamOutLong(int type, PortableRawReaderEx reader)
-        throws IgniteCheckedException {
-        switch (type) {
-            case OP_DOTNET_DEPLOY: {
-                ServiceConfiguration cfg = new ServiceConfiguration();
-
-                cfg.setName(reader.readString());
-                cfg.setService(new PlatformDotNetServiceImpl(reader.readObjectDetached(), platformCtx, srvKeepPortable));
-                cfg.setTotalCount(reader.readInt());
-                cfg.setMaxPerNodeCount(reader.readInt());
-                cfg.setCacheName(reader.readString());
-                cfg.setAffinityKey(reader.readObjectDetached());
-
-                Object filter = reader.readObjectDetached();
-
-                if (filter != null)
-                    cfg.setNodeFilter(platformCtx.createClusterNodeFilter(filter));
-
-                services.deploy(cfg);
-
-                return TRUE;
-            }
-
-            case OP_DOTNET_DEPLOY_MULTIPLE: {
-                String name = reader.readString();
-                Object svc = reader.readObjectDetached();
-                int totalCnt = reader.readInt();
-                int maxPerNodeCnt = reader.readInt();
-
-                services.deployMultiple(name, new PlatformDotNetServiceImpl(svc, platformCtx, srvKeepPortable),
-                    totalCnt, maxPerNodeCnt);
-
-                return TRUE;
-            }
-
-            default:
-                return super.processInStreamOutLong(type, reader);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void processInStreamOutStream(int type, PortableRawReaderEx reader, PortableRawWriterEx writer)
-        throws IgniteCheckedException {
-        switch (type) {
-            case OP_DOTNET_SERVICES: {
-                Collection<Service> svcs = services.services(reader.readString());
-
-                PlatformUtils.writeNullableCollection(writer, svcs,
-                    new PlatformWriterClosure<Service>() {
-                        @Override public void write(PortableRawWriterEx writer, Service svc) {
-                            writer.writeLong(((PlatformService) svc).pointer());
-                        }
-                    },
-                    new IgnitePredicate<Service>() {
-                        @Override public boolean apply(Service svc) {
-                            return svc instanceof PlatformDotNetService;
-                        }
-                    }
-                );
-
-                return;
-            }
-
-            default:
-                super.processInStreamOutStream(type, reader, writer);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void processInObjectStreamOutStream(int type, Object arg, PortableRawReaderEx reader,
-        PortableRawWriterEx writer) throws IgniteCheckedException {
-        switch (type) {
-            case OP_DOTNET_INVOKE: {
-                assert arg != null;
-                assert arg instanceof PlatformDotNetService;
-
-                String mthdName = reader.readString();
-
-                Object[] args;
-
-                if (reader.readBoolean()) {
-                    args = new Object[reader.readInt()];
-
-                    for (int i = 0; i < args.length; i++)
-                        args[i] = reader.readObjectDetached();
-                }
-                else
-                    args = null;
-
-                try {
-                    Object result = ((PlatformDotNetService)arg).invokeMethod(mthdName, srvKeepPortable, args);
-
-                    PlatformUtils.writeInvocationResult(writer, result, null);
-                }
-                catch (Exception e) {
-                    PlatformUtils.writeInvocationResult(writer, null, e);
-                }
-
-                return;
-            }
-
-            default:
-                super.processInObjectStreamOutStream(type, arg, reader, writer);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void processOutStream(int type, PortableRawWriterEx writer) throws IgniteCheckedException {
-        switch (type) {
-            case OP_DESCRIPTORS: {
-                Collection<ServiceDescriptor> descs = services.serviceDescriptors();
-
-                PlatformUtils.writeCollection(writer, descs, new PlatformWriterClosure<ServiceDescriptor>() {
-                    @Override public void write(PortableRawWriterEx writer, ServiceDescriptor d) {
-                        writer.writeString(d.name());
-                        writer.writeString(d.cacheName());
-                        writer.writeInt(d.maxPerNodeCount());
-                        writer.writeInt(d.totalCount());
-                        writer.writeUuid(d.originNodeId());
-                        writer.writeObject(d.affinityKey());
-
-                        Map<UUID, Integer> top = d.topologySnapshot();
-
-                        PlatformUtils.writeMap(writer, top, new PlatformWriterBiClosure<UUID, Integer>() {
-                            @Override public void write(PortableRawWriterEx writer, UUID key, Integer val) {
-                                writer.writeUuid(key);
-                                writer.writeInt(val);
-                            }
-                        });
-                    }
-                });
-
-                return;
-            }
-
-            default:
-                super.processOutStream(type, writer);
-        }
-    }
-
-    /** <inheritDoc /> */
-    @Override protected IgniteFuture currentFuture() throws IgniteCheckedException {
-        return services.future();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
deleted file mode 100644
index 1d2c315..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
+++ /dev/null
@@ -1,259 +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.processors.platform.transactions;
-
-import java.util.Date;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicLong;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteTransactions;
-import org.apache.ignite.configuration.TransactionConfiguration;
-import org.apache.ignite.internal.portable.PortableRawWriterEx;
-import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
-import org.apache.ignite.internal.processors.platform.PlatformContext;
-import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
-import org.apache.ignite.internal.util.GridConcurrentFactory;
-import org.apache.ignite.internal.util.typedef.C1;
-import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.transactions.Transaction;
-import org.apache.ignite.transactions.TransactionConcurrency;
-import org.apache.ignite.transactions.TransactionIsolation;
-import org.apache.ignite.transactions.TransactionMetrics;
-
-/**
- * Native transaction wrapper implementation.
- */
-@SuppressWarnings({"unchecked", "UnusedDeclaration", "TryFinallyCanBeTryWithResources"})
-public class PlatformTransactions extends PlatformAbstractTarget {
-    /** */
-    public static final int OP_CACHE_CONFIG_PARAMETERS = 1;
-
-    /** */
-    public static final int OP_METRICS = 2;
-
-    /** */
-    private final IgniteTransactions txs;
-
-    /** Map with currently active transactions. */
-    private final ConcurrentMap<Long, Transaction> txMap = GridConcurrentFactory.newMap();
-
-    /** Transaction ID sequence. Must be static to ensure uniqueness across different caches. */
-    private static final AtomicLong TX_ID_GEN = new AtomicLong();
-
-    /**
-     * Constructor.
-     *
-     * @param platformCtx Context.
-     */
-    public PlatformTransactions(PlatformContext platformCtx) {
-        super(platformCtx);
-
-        txs = platformCtx.kernalContext().grid().transactions();
-    }
-
-    /**
-     * @param concurrency Concurrency.
-     * @param isolation Isolation.
-     * @param timeout Timeout
-     * @param txSize Number of entries participating in transaction.
-     * @return Transaction thread ID.
-     */
-    public long txStart(int concurrency, int isolation, long timeout, int txSize) {
-        TransactionConcurrency txConcurrency = TransactionConcurrency.fromOrdinal(concurrency);
-
-        assert txConcurrency != null;
-
-        TransactionIsolation txIsolation = TransactionIsolation.fromOrdinal(isolation);
-
-        assert txIsolation != null;
-
-        Transaction tx = txs.txStart(txConcurrency, txIsolation);
-
-        return registerTx(tx);
-    }
-
-    /**
-     * @param id Transaction ID.
-     * @throws org.apache.ignite.IgniteCheckedException In case of error.
-     */
-    public int txCommit(long id) throws IgniteCheckedException {
-        tx(id).commit();
-
-        return txClose(id);
-    }
-
-    /**
-     * @param id Transaction ID.
-     * @throws org.apache.ignite.IgniteCheckedException In case of error.
-     */
-    public int txRollback(long id) throws IgniteCheckedException {
-        tx(id).rollback();
-
-        return txClose(id);
-    }
-
-    /**
-     * @param id Transaction ID.
-     * @throws org.apache.ignite.IgniteCheckedException In case of error.
-     * @return Transaction state.
-     */
-    public int txClose(long id) throws IgniteCheckedException {
-        Transaction tx = tx(id);
-
-        try {
-            tx.close();
-
-            return tx.state().ordinal();
-        }
-        finally {
-            unregisterTx(id);
-        }
-    }
-
-    /**
-     * @param id Transaction ID.
-     * @return Transaction state.
-     */
-    public int txState(long id) {
-        Transaction tx = tx(id);
-
-        return tx.state().ordinal();
-    }
-
-    /**
-     * @param id Transaction ID.
-     * @return {@code True} if rollback only flag was set.
-     */
-    public boolean txSetRollbackOnly(long id) {
-        Transaction tx = tx(id);
-
-        return tx.setRollbackOnly();
-    }
-
-    /**
-     * Commits tx in async mode.
-     */
-    public void txCommitAsync(final long txId, final long futId) {
-        final Transaction asyncTx = (Transaction)tx(txId).withAsync();
-
-        asyncTx.commit();
-
-        listenAndNotifyIntFuture(futId, asyncTx);
-    }
-
-    /**
-     * Rolls back tx in async mode.
-     */
-    public void txRollbackAsync(final long txId, final long futId) {
-        final Transaction asyncTx = (Transaction)tx(txId).withAsync();
-
-        asyncTx.rollback();
-
-        listenAndNotifyIntFuture(futId, asyncTx);
-    }
-
-    /**
-     * Listens to the transaction future and notifies .NET int future.
-     */
-    private void listenAndNotifyIntFuture(final long futId, final Transaction asyncTx) {
-        IgniteFuture fut = asyncTx.future().chain(new C1<IgniteFuture, Object>() {
-            private static final long serialVersionUID = 0L;
-
-            @Override public Object apply(IgniteFuture fut) {
-                return null;
-            }
-        });
-
-        PlatformFutureUtils.listen(platformCtx, fut, futId, PlatformFutureUtils.TYP_OBJ, this);
-    }
-
-    /**
-     * Resets transaction metrics.
-     */
-    public void resetMetrics() {
-       txs.resetMetrics();
-    }
-
-    /**
-     * Register transaction.
-     *
-     * @param tx Transaction.
-     * @return Transaction ID.
-     */
-    private long registerTx(Transaction tx) {
-        long id = TX_ID_GEN.incrementAndGet();
-
-        Transaction old = txMap.put(id, tx);
-
-        assert old == null : "Duplicate TX ids: " + old;
-
-        return id;
-    }
-
-    /**
-     * Unregister transaction.
-     *
-     * @param id Transaction ID.
-     */
-    private void unregisterTx(long id) {
-        Transaction tx = txMap.remove(id);
-
-        assert tx != null : "Failed to unregister transaction: " + id;
-    }
-
-    /**
-     * Get transaction by ID.
-     *
-     * @param id ID.
-     * @return Transaction.
-     */
-    private Transaction tx(long id) {
-        Transaction tx = txMap.get(id);
-
-        assert tx != null : "Transaction not found for ID: " + id;
-
-        return tx;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void processOutStream(int type, PortableRawWriterEx writer) throws IgniteCheckedException {
-        switch (type) {
-            case OP_CACHE_CONFIG_PARAMETERS:
-                TransactionConfiguration txCfg = platformCtx.kernalContext().config().getTransactionConfiguration();
-
-                writer.writeEnum(txCfg.getDefaultTxConcurrency());
-                writer.writeEnum(txCfg.getDefaultTxIsolation());
-                writer.writeLong(txCfg.getDefaultTxTimeout());
-
-                break;
-
-            case OP_METRICS:
-                TransactionMetrics metrics = txs.metrics();
-
-                writer.writeDate(new Date(metrics.commitTime()));
-                writer.writeDate(new Date(metrics.rollbackTime()));
-                writer.writeInt(metrics.txCommits());
-                writer.writeInt(metrics.txRollbacks());
-
-                break;
-
-            default:
-                super.processOutStream(type, writer);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
deleted file mode 100644
index 0019986..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java
+++ /dev/null
@@ -1,397 +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.processors.platform.utils;
-
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.portable.PortableRawWriterEx;
-import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
-import org.apache.ignite.internal.processors.platform.PlatformContext;
-import org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway;
-import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
-import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
-import org.apache.ignite.lang.IgniteBiInClosure;
-import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteInClosure;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Interop future utils.
- */
-public class PlatformFutureUtils {
-    /** Future type: byte. */
-    public static final int TYP_BYTE = 1;
-
-    /** Future type: boolean. */
-    public static final int TYP_BOOL = 2;
-
-    /** Future type: short. */
-    public static final int TYP_SHORT = 3;
-
-    /** Future type: char. */
-    public static final int TYP_CHAR = 4;
-
-    /** Future type: int. */
-    public static final int TYP_INT = 5;
-
-    /** Future type: float. */
-    public static final int TYP_FLOAT = 6;
-
-    /** Future type: long. */
-    public static final int TYP_LONG = 7;
-
-    /** Future type: double. */
-    public static final int TYP_DOUBLE = 8;
-
-    /** Future type: object. */
-    public static final int TYP_OBJ = 9;
-
-    /**
-     * Listen future.
-     *
-     * @param ctx Context.
-     * @param fut Java future.
-     * @param futPtr Native future pointer.
-     * @param typ Expected return type.
-     */
-    public static void listen(final PlatformContext ctx, IgniteInternalFuture fut, final long futPtr, final int typ,
-        PlatformAbstractTarget target) {
-        listen(ctx, new InternalFutureListenable(fut), futPtr, typ, null, target);
-    }
-    /**
-     * Listen future.
-     *
-     * @param ctx Context.
-     * @param fut Java future.
-     * @param futPtr Native future pointer.
-     * @param typ Expected return type.
-     */
-    public static void listen(final PlatformContext ctx, IgniteFuture fut, final long futPtr, final int typ,
-        PlatformAbstractTarget target) {
-        listen(ctx, new FutureListenable(fut), futPtr, typ, null, target);
-    }
-
-    /**
-     * Listen future.
-     *
-     * @param ctx Context.
-     * @param fut Java future.
-     * @param futPtr Native future pointer.
-     * @param typ Expected return type.
-     * @param writer Writer.
-     */
-    public static void listen(final PlatformContext ctx, IgniteInternalFuture fut, final long futPtr, final int typ,
-        Writer writer, PlatformAbstractTarget target) {
-        listen(ctx, new InternalFutureListenable(fut), futPtr, typ, writer, target);
-    }
-
-    /**
-     * Listen future.
-     *
-     * @param ctx Context.
-     * @param fut Java future.
-     * @param futPtr Native future pointer.
-     * @param typ Expected return type.
-     * @param writer Writer.
-     */
-    public static void listen(final PlatformContext ctx, IgniteFuture fut, final long futPtr, final int typ,
-        Writer writer, PlatformAbstractTarget target) {
-        listen(ctx, new FutureListenable(fut), futPtr, typ, writer, target);
-    }
-
-    /**
-     * Listen future.
-     *
-     * @param ctx Context.
-     * @param fut Java future.
-     * @param futPtr Native future pointer.
-     * @param writer Writer.
-     */
-    public static void listen(final PlatformContext ctx, IgniteInternalFuture fut, final long futPtr, Writer writer,
-        PlatformAbstractTarget target) {
-        listen(ctx, new InternalFutureListenable(fut), futPtr, TYP_OBJ, writer, target);
-    }
-
-    /**
-     * Listen future.
-     *
-     * @param ctx Context.
-     * @param listenable Listenable entry.
-     * @param futPtr Native future pointer.
-     * @param typ Expected return type.
-     * @param writer Optional writer.
-     */
-    @SuppressWarnings("unchecked")
-    private static void listen(final PlatformContext ctx, Listenable listenable, final long futPtr, final int typ,
-        @Nullable final Writer writer, final PlatformAbstractTarget target) {
-        final PlatformCallbackGateway gate = ctx.gateway();
-
-        listenable.listen(new IgniteBiInClosure<Object, Throwable>() {
-            private static final long serialVersionUID = 0L;
-
-            @Override public void apply(Object res, Throwable err) {
-                if (err instanceof Exception)
-                    err = target.convertException((Exception)err);
-
-                if (writer != null && writeToWriter(res, err, ctx, writer, futPtr))
-                    return;
-
-                if (err != null) {
-                    writeFutureError(ctx, futPtr, err);
-
-                    return;
-                }
-
-                try {
-                    if (typ == TYP_OBJ) {
-                        if (res == null)
-                            gate.futureNullResult(futPtr);
-                        else {
-                            try (PlatformMemory mem = ctx.memory().allocate()) {
-                                PlatformOutputStream out = mem.output();
-
-                                PortableRawWriterEx outWriter = ctx.writer(out);
-
-                                outWriter.writeObjectDetached(res);
-
-                                out.synchronize();
-
-                                gate.futureObjectResult(futPtr, mem.pointer());
-                            }
-                        }
-                    }
-                    else if (res == null)
-                        gate.futureNullResult(futPtr);
-                    else {
-                        switch (typ) {
-                            case TYP_BYTE:
-                                gate.futureByteResult(futPtr, (byte) res);
-
-                                break;
-
-                            case TYP_BOOL:
-                                gate.futureBoolResult(futPtr, (boolean) res ? 1 : 0);
-
-                                break;
-
-                            case TYP_SHORT:
-                                gate.futureShortResult(futPtr, (short) res);
-
-                                break;
-
-                            case TYP_CHAR:
-                                gate.futureCharResult(futPtr, (char) res);
-
-                                break;
-
-                            case TYP_INT:
-                                gate.futureIntResult(futPtr, (int) res);
-
-                                break;
-
-                            case TYP_FLOAT:
-                                gate.futureFloatResult(futPtr, (float) res);
-
-                                break;
-
-                            case TYP_LONG:
-                                gate.futureLongResult(futPtr, (long) res);
-
-                                break;
-
-                            case TYP_DOUBLE:
-                                gate.futureDoubleResult(futPtr, (double) res);
-
-                                break;
-
-                            default:
-                                assert false : "Should not reach this: " + typ;
-                        }
-                    }
-                }
-                catch (Throwable t) {
-                    writeFutureError(ctx, futPtr, t);
-
-                    if (t instanceof Error)
-                        throw t;
-                }
-            }
-        });
-    }
-
-    /**
-     * Write future error.
-     *
-     * @param ctx Context.
-     * @param futPtr Future pointer.
-     * @param err Error.
-     */
-    private static void writeFutureError(final PlatformContext ctx, long futPtr, Throwable err) {
-        try (PlatformMemory mem = ctx.memory().allocate()) {
-            PlatformOutputStream out = mem.output();
-
-            PortableRawWriterEx outWriter = ctx.writer(out);
-
-            outWriter.writeString(err.getClass().getName());
-            outWriter.writeString(err.getMessage());
-
-            PlatformUtils.writeErrorData(err, outWriter);
-
-            out.synchronize();
-
-            ctx.gateway().futureError(futPtr, mem.pointer());
-        }
-    }
-
-    /**
-     * Write result to a custom writer
-     *
-     * @param obj Object to write.
-     * @param err Error to write.
-     * @param ctx Context.
-     * @param writer Writer.
-     * @param futPtr Future pointer.
-     * @return Value indicating whether custom write was performed. When false, default write will be used.
-     */
-    private static boolean writeToWriter(Object obj, Throwable err, PlatformContext ctx, Writer writer, long futPtr) {
-        boolean canWrite = writer.canWrite(obj, err);
-
-        if (!canWrite)
-            return false;
-
-        try (PlatformMemory mem = ctx.memory().allocate()) {
-            PlatformOutputStream out = mem.output();
-
-            PortableRawWriterEx outWriter = ctx.writer(out);
-
-            writer.write(outWriter, obj, err);
-
-            out.synchronize();
-
-            ctx.gateway().futureObjectResult(futPtr, mem.pointer());
-        }
-
-        return true;
-    }
-
-    /**
-     * Writer allowing special future result handling.
-     */
-    public static interface Writer {
-        /**
-         * Write object.
-         *
-         * @param writer Writer.
-         * @param obj Object.
-         * @param err Error.
-         */
-        public void write(PortableRawWriterEx writer, Object obj, Throwable err);
-
-        /**
-         * Determines whether this writer can write given data.
-         *
-         * @param obj Object.
-         * @param err Error.
-         * @return Value indicating whether this writer can write given data.
-         */
-        public boolean canWrite(Object obj, Throwable err);
-    }
-
-    /**
-     * Listenable entry.
-     */
-    private static interface Listenable {
-        /**
-         * Listen.
-         *
-         * @param lsnr Listener.
-         */
-        public void listen(IgniteBiInClosure<Object, Throwable> lsnr);
-    }
-
-    /**
-     * Listenable around Ignite future.
-     */
-    private static class FutureListenable implements Listenable {
-        /** Future. */
-        private final IgniteFuture fut;
-
-        /**
-         * Constructor.
-         *
-         * @param fut Future.
-         */
-        public FutureListenable(IgniteFuture fut) {
-            this.fut = fut;
-        }
-
-        /** {@inheritDoc} */
-        @SuppressWarnings("unchecked")
-        @Override public void listen(final IgniteBiInClosure<Object, Throwable> lsnr) {
-            fut.listen(new IgniteInClosure<IgniteFuture>() {
-                private static final long serialVersionUID = 0L;
-
-                @Override public void apply(IgniteFuture fut0) {
-                    try {
-                        lsnr.apply(fut0.get(), null);
-                    }
-                    catch (Throwable err) {
-                        lsnr.apply(null, err);
-
-                        if (err instanceof Error)
-                            throw err;
-                    }
-                }
-            });
-        }
-    }
-
-    /**
-     * Listenable around Ignite future.
-     */
-    private static class InternalFutureListenable implements Listenable {
-        /** Future. */
-        private final IgniteInternalFuture fut;
-
-        /**
-         * Constructor.
-         *
-         * @param fut Future.
-         */
-        public InternalFutureListenable(IgniteInternalFuture fut) {
-            this.fut = fut;
-        }
-
-        /** {@inheritDoc} */
-        @SuppressWarnings("unchecked")
-        @Override public void listen(final IgniteBiInClosure<Object, Throwable> lsnr) {
-            fut.listen(new IgniteInClosure<IgniteInternalFuture>() {
-                private static final long serialVersionUID = 0L;
-
-                @Override public void apply(IgniteInternalFuture fut0) {
-                    try {
-                        lsnr.apply(fut0.get(), null);
-                    }
-                    catch (Throwable err) {
-                        lsnr.apply(null, err);
-                    }
-                }
-            });
-        }
-    }
-
-}
\ No newline at end of file


Mime
View raw message