You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/09/04 12:36:43 UTC

[01/50] [abbrv] ignite git commit: Added test.

Repository: ignite
Updated Branches:
  refs/heads/ignite-843 316b9421a -> 852772cf8


Added test.


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

Branch: refs/heads/ignite-843
Commit: 67699564d594647236552450d362be1e04c3d476
Parents: 3aa9ea3
Author: sboikov <sb...@gridgain.com>
Authored: Wed Sep 2 15:25:15 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Sep 2 15:34:57 2015 +0300

----------------------------------------------------------------------
 .../CachePutAllFailoverAbstractTest.java        | 110 ++++++++++++++-----
 ...gniteCachePutRetryTransactionalSelfTest.java |  42 -------
 .../junits/common/GridCommonAbstractTest.java   |  41 +++++++
 3 files changed, 123 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/67699564/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
index 62fddda..f558ba0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
@@ -17,7 +17,15 @@
 
 package org.apache.ignite.internal.processors.cache.distributed;
 
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.TreeMap;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
@@ -29,14 +37,6 @@ import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.jetbrains.annotations.NotNull;
 
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.TreeMap;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.atomic.AtomicBoolean;
-
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 
 /**
@@ -85,21 +85,31 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
      * @throws Exception If failed.
      */
     public void testPutAllFailover() throws Exception {
-        testPutAllFailover(false);
+        testPutAllFailover(Test.PUT_ALL);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPutAllFailoverPessimisticTx() throws Exception {
+        if (atomicityMode() == CacheAtomicityMode.ATOMIC)
+            return;
+
+        testPutAllFailover(Test.PUT_ALL_PESSIMISTIC_TX);
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testPutAllFailoverAsync() throws Exception {
-        testPutAllFailover(true);
+        testPutAllFailover(Test.PUT_ALL_ASYNC);
     }
 
     /**
-     * @param async If {@code true} tests asynchronous operation.
+     * @param test Test type
      * @throws Exception If failed.
      */
-    private void testPutAllFailover(final boolean async) throws Exception {
+    private void testPutAllFailover(final Test test) throws Exception {
         final AtomicBoolean finished = new AtomicBoolean();
 
         final long endTime = System.currentTimeMillis() + TEST_TIME;
@@ -123,7 +133,7 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
         try {
             IgniteCache<TestKey, TestValue> cache0 = ignite(0).cache(null);
 
-            final IgniteCache<TestKey, TestValue> cache = async ? cache0.withAsync() : cache0;
+            final IgniteCache<TestKey, TestValue> cache = test == Test.PUT_ALL_ASYNC ? cache0.withAsync() : cache0;
 
             GridTestUtils.runMultiThreaded(new Callable<Object>() {
                 @Override public Object call() throws Exception {
@@ -142,10 +152,8 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
                             lastInfo = time;
                         }
 
-                        if (async) {
-                            Collection<IgniteFuture<?>> futs = new ArrayList<>();
-
-                            for (int i = 0 ; i < 10; i++) {
+                        switch (test) {
+                            case PUT_ALL: {
                                 TreeMap<TestKey, TestValue> map = new TreeMap<>();
 
                                 for (int k = 0; k < 100; k++)
@@ -153,23 +161,55 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
 
                                 cache.putAll(map);
 
-                                IgniteFuture<?> fut = cache.future();
+                                break;
+                            }
+
+                            case PUT_ALL_ASYNC: {
+                                Collection<IgniteFuture<?>> futs = new ArrayList<>();
 
-                                assertNotNull(fut);
+                                for (int i = 0 ; i < 10; i++) {
+                                    TreeMap<TestKey, TestValue> map = new TreeMap<>();
 
-                                futs.add(fut);
+                                    for (int k = 0; k < 100; k++)
+                                        map.put(new TestKey(rnd.nextInt(200)), new TestValue(iter));
+
+                                    cache.putAll(map);
+
+                                    IgniteFuture<?> fut = cache.future();
+
+                                    assertNotNull(fut);
+
+                                    futs.add(fut);
+                                }
+
+                                for (IgniteFuture<?> fut : futs)
+                                    fut.get();
+
+                                break;
                             }
 
-                            for (IgniteFuture<?> fut : futs)
-                                fut.get();
-                        }
-                        else {
-                            TreeMap<TestKey, TestValue> map = new TreeMap<>();
+                            case PUT_ALL_PESSIMISTIC_TX: {
+                                final TreeMap<TestKey, TestValue> map = new TreeMap<>();
+
+                                for (int k = 0; k < 100; k++)
+                                    map.put(new TestKey(rnd.nextInt(200)), new TestValue(iter));
+
+                                doInTransaction(ignite(0), new Callable<Object>() {
+                                    @Override public Object call() throws Exception {
+                                        for (TestKey key : map.keySet())
+                                            cache.get(key);
+
+                                        cache.putAll(map);
 
-                            for (int k = 0; k < 100; k++)
-                                map.put(new TestKey(rnd.nextInt(200)), new TestValue(iter));
+                                        return null;
+                                    }
+                                });
 
-                            cache.putAll(map);
+                                break;
+                            }
+
+                            default:
+                                assert false;
                         }
 
                         iter++;
@@ -277,4 +317,18 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
             return S.toString(TestValue.class, this);
         }
     }
+
+    /**
+     *
+     */
+    private enum Test {
+        /** */
+        PUT_ALL,
+
+        /** */
+        PUT_ALL_ASYNC,
+
+        /** */
+        PUT_ALL_PESSIMISTIC_TX
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/67699564/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
index 997848b..7c66efc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java
@@ -24,7 +24,6 @@ import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReferenceArray;
-import javax.cache.CacheException;
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
@@ -32,18 +31,12 @@ import org.apache.ignite.IgniteAtomicLong;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheEntryProcessor;
-import org.apache.ignite.cluster.ClusterTopologyException;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.transactions.Transaction;
-import org.apache.ignite.transactions.TransactionRollbackException;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
-import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
 
 /**
  *
@@ -171,41 +164,6 @@ public class IgniteCachePutRetryTransactionalSelfTest extends IgniteCachePutRetr
     }
 
     /**
-     * @param ignite Ignite instance.
-     * @param clo Closure.
-     * @return Result of closure execution.
-     * @throws Exception If failed.
-     */
-    private <T> T doInTransaction(Ignite ignite, Callable<T> clo) throws Exception {
-        while (true) {
-            try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
-                T res = clo.call();
-
-                tx.commit();
-
-                return res;
-            }
-            catch (CacheException e) {
-                if (e.getCause() instanceof ClusterTopologyException) {
-                    ClusterTopologyException topEx = (ClusterTopologyException)e.getCause();
-
-                    topEx.retryReadyFuture().get();
-                }
-                else
-                    throw e;
-            }
-            catch (ClusterTopologyException e) {
-                IgniteFuture<?> fut = e.retryReadyFuture();
-
-                fut.get();
-            }
-            catch (TransactionRollbackException ignore) {
-                // Safe to retry right away.
-            }
-        }
-    }
-
-    /**
      * Callable to process inside transaction.
      */
     private static class ProcessCallable implements Callable<Void> {

http://git-wip-us.apache.org/repos/asf/ignite/blob/67699564/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 4d7e923..13ec665 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -24,6 +24,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicReference;
 import javax.cache.Cache;
@@ -47,6 +48,7 @@ import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cache.affinity.AffinityFunction;
 import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.cluster.ClusterTopologyException;
 import org.apache.ignite.compute.ComputeTask;
 import org.apache.ignite.compute.ComputeTaskFuture;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -74,12 +76,16 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.testframework.junits.GridAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionRollbackException;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.cache.CacheMode.LOCAL;
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheRebalanceMode.NONE;
 import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isNearEnabled;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
 
 /**
  * Super class for all common tests.
@@ -986,4 +992,39 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
             idx++;
         }
     }
+
+    /**
+     * @param ignite Ignite instance.
+     * @param clo Closure.
+     * @return Result of closure execution.
+     * @throws Exception If failed.
+     */
+    protected <T> T doInTransaction(Ignite ignite, Callable<T> clo) throws Exception {
+        while (true) {
+            try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+                T res = clo.call();
+
+                tx.commit();
+
+                return res;
+            }
+            catch (CacheException e) {
+                if (e.getCause() instanceof ClusterTopologyException) {
+                    ClusterTopologyException topEx = (ClusterTopologyException)e.getCause();
+
+                    topEx.retryReadyFuture().get();
+                }
+                else
+                    throw e;
+            }
+            catch (ClusterTopologyException e) {
+                IgniteFuture<?> fut = e.retryReadyFuture();
+
+                fut.get();
+            }
+            catch (TransactionRollbackException ignore) {
+                // Safe to retry right away.
+            }
+        }
+    }
 }
\ No newline at end of file


[02/50] [abbrv] ignite git commit: Javadoc fix (GG-10706) (cherry picked from commit 1225751)

Posted by ak...@apache.org.
Javadoc fix (GG-10706)
(cherry picked from commit 1225751)


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

Branch: refs/heads/ignite-843
Commit: f940db1f04c812b7c9d536ffb35ebf37a3e45420
Parents: 6769956
Author: Anton Vinogradov <av...@apache.org>
Authored: Wed Sep 2 16:26:59 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Sep 2 16:45:49 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/platform/cache/PlatformCache.java   | 2 +-
 parent/pom.xml                                                     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f940db1f/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index 184aa33..27af344 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -704,7 +704,7 @@ public class PlatformCache extends PlatformAbstractTarget {
 
     /**
      * Clears the contents of the cache, without notifying listeners or
-     * {@link javax.cache.integration.CacheWriter}s.
+     * {@ignitelink javax.cache.integration.CacheWriter}s.
      *
      * @throws IllegalStateException if the cache is closed.
      * @throws javax.cache.CacheException if there is a problem during the clear

http://git-wip-us.apache.org/repos/asf/ignite/blob/f940db1f/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 2380b08..f56b064 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -42,6 +42,7 @@
         <doxygen.exec>doxygen</doxygen.exec>
         <git.exec>git</git.exec>
         <jetty.version>9.2.11.v20150529</jetty.version>
+        <javadoc.opts>-XDenableSunApiLintControl</javadoc.opts>
     </properties>
 
     <groupId>org.apache.ignite</groupId>


[22/50] [abbrv] ignite git commit: Disabled hanging tests.

Posted by ak...@apache.org.
Disabled hanging tests.


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

Branch: refs/heads/ignite-843
Commit: 66a49d75e3cdd001135f32a81dbfb931b9e1584b
Parents: 27cd615
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 3 15:32:26 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 3 15:32:26 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java  | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/66a49d75/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
index b62cc48..ecb2698 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
@@ -42,6 +42,11 @@ public class IgniteCacheP2pUnmarshallingErrorTest extends IgniteCacheAbstractTes
     protected static int key = 0;
 
     /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1366");
+    }
+
+    /** {@inheritDoc} */
     @Override protected int gridCount() {
         return 3;
     }


[34/50] [abbrv] ignite git commit: Fixed update notifier executor service issue.

Posted by ak...@apache.org.
Fixed update notifier executor service issue.


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

Branch: refs/heads/ignite-843
Commit: 28213a311213cd46e2ade744590f339f4fc385a3
Parents: f1f6be8
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Sep 4 10:27:17 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Sep 4 10:27:17 2015 +0300

----------------------------------------------------------------------
 .../main/java/org/apache/ignite/internal/IgniteKernal.java   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/28213a31/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index ad4940a..70cd56f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -821,7 +821,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                     updateNtfTimer = new Timer("ignite-update-notifier-timer", true);
 
                     // Setup periodic version check.
-                    updateNtfTimer.scheduleAtFixedRate(new UpdateNotifierTimerTask(this, verChecker),
+                    updateNtfTimer.scheduleAtFixedRate(new UpdateNotifierTimerTask(this, execSvc, verChecker),
                         0, PERIODIC_VER_CHECK_DELAY);
                 }
                 catch (IgniteCheckedException e) {
@@ -3199,15 +3199,15 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
          * Constructor.
          *
          * @param kernal Kernal.
+         * @param execSvc Executor service.
          * @param verChecker Version checker.
          */
-        private UpdateNotifierTimerTask(IgniteKernal kernal, GridUpdateNotifier verChecker) {
+        private UpdateNotifierTimerTask(IgniteKernal kernal, ExecutorService execSvc, GridUpdateNotifier verChecker) {
             kernalRef = new WeakReference<>(kernal);
 
             log = kernal.log.getLogger(UpdateNotifierTimerTask.class);
 
-            execSvc = kernal.executorService();
-
+            this.execSvc = execSvc;
             this.verChecker = verChecker;
         }
 


[50/50] [abbrv] ignite git commit: IGNITE-843: Update version as in master.

Posted by ak...@apache.org.
IGNITE-843: Update version as in master.


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

Branch: refs/heads/ignite-843
Commit: 852772cf8500cbe7dcc829c84948e60510aee9e1
Parents: 0f15b83
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Sep 4 17:36:55 2015 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Sep 4 17:36:55 2015 +0700

----------------------------------------------------------------------
 modules/control-center-agent/pom.xml | 2 +-
 modules/control-center-web/pom.xml   | 4 ++--
 modules/json/pom.xml                 | 4 ++--
 modules/nodejs/pom.xml               | 4 ++--
 modules/schema-import-db/pom.xml     | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/852772cf/modules/control-center-agent/pom.xml
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/pom.xml b/modules/control-center-agent/pom.xml
index 72fb46c..5204913 100644
--- a/modules/control-center-agent/pom.xml
+++ b/modules/control-center-agent/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-control-center-agent</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
 
     <properties>
         <jetty.version>9.2.12.v20150709</jetty.version>

http://git-wip-us.apache.org/repos/asf/ignite/blob/852772cf/modules/control-center-web/pom.xml
----------------------------------------------------------------------
diff --git a/modules/control-center-web/pom.xml b/modules/control-center-web/pom.xml
index eb71764..d5241ca 100644
--- a/modules/control-center-web/pom.xml
+++ b/modules/control-center-web/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-control-center-web</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
 
     <build>
         <plugins>
@@ -66,4 +66,4 @@
             </plugin>
         </plugins>
     </build>
-</project>
\ No newline at end of file
+</project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/852772cf/modules/json/pom.xml
----------------------------------------------------------------------
diff --git a/modules/json/pom.xml b/modules/json/pom.xml
index 35863ac..9821c67 100644
--- a/modules/json/pom.xml
+++ b/modules/json/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-json</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>
@@ -79,4 +79,4 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/852772cf/modules/nodejs/pom.xml
----------------------------------------------------------------------
diff --git a/modules/nodejs/pom.xml b/modules/nodejs/pom.xml
index aa649f1..dd99580 100644
--- a/modules/nodejs/pom.xml
+++ b/modules/nodejs/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-nodejs</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>
@@ -79,4 +79,4 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/852772cf/modules/schema-import-db/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/pom.xml b/modules/schema-import-db/pom.xml
index 81b0a65..f42192e 100644
--- a/modules/schema-import-db/pom.xml
+++ b/modules/schema-import-db/pom.xml
@@ -32,6 +32,6 @@
     </parent>
 
     <artifactId>ignite-schema-import-db</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
 
 </project>


[15/50] [abbrv] ignite git commit: More debug info for 'get' futures.

Posted by ak...@apache.org.
More debug info for 'get' futures.


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

Branch: refs/heads/ignite-843
Commit: 3de5f98cf91f17a2848b0ffae8326011e88e7e7e
Parents: 3a280a0
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 3 11:39:33 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 3 11:39:33 2015 +0300

----------------------------------------------------------------------
 .../dht/GridPartitionedGetFuture.java           | 19 +++++++++++++++--
 .../distributed/near/GridNearGetFuture.java     | 22 +++++++++++++++++++-
 .../ignite/internal/util/lang/GridFunc.java     |  1 +
 3 files changed, 39 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3de5f98c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index 82ff69f..2f0de86 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -290,7 +290,7 @@ public class GridPartitionedGetFuture<K, V> extends GridCompoundIdentityFuture<M
      * @param f Future.
      * @return {@code True} if mini-future.
      */
-    private boolean isMini(IgniteInternalFuture<Map<K, V>> f) {
+    private boolean isMini(IgniteInternalFuture<?> f) {
         return f.getClass().equals(MiniFuture.class);
     }
 
@@ -598,7 +598,22 @@ public class GridPartitionedGetFuture<K, V> extends GridCompoundIdentityFuture<M
 
     /** {@inheritDoc} */
     @Override public String toString() {
-        return S.toString(GridPartitionedGetFuture.class, this, super.toString());
+        Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
+            @SuppressWarnings("unchecked")
+            @Override public String apply(IgniteInternalFuture<?> f) {
+                if (isMini(f)) {
+                    return "[node=" + ((MiniFuture)f).node().id() +
+                        ", loc=" + ((MiniFuture)f).node().isLocal() +
+                        ", done=" + f.isDone() + "]";
+                }
+                else
+                    return "[loc=true, done=" + f.isDone() + "]";
+            }
+        });
+
+        return S.toString(GridPartitionedGetFuture.class, this,
+            "innerFuts", futs,
+            "super", super.toString());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/3de5f98c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index 4de8294..9d2113e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -291,7 +291,7 @@ public final class GridNearGetFuture<K, V> extends GridCompoundIdentityFuture<Ma
      * @param f Future.
      * @return {@code True} if mini-future.
      */
-    private boolean isMini(IgniteInternalFuture<Map<K, V>> f) {
+    private boolean isMini(IgniteInternalFuture<?> f) {
         return f.getClass().equals(MiniFuture.class);
     }
 
@@ -721,6 +721,26 @@ public final class GridNearGetFuture<K, V> extends GridCompoundIdentityFuture<Ma
         return map;
     }
 
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
+            @SuppressWarnings("unchecked")
+            @Override public String apply(IgniteInternalFuture<?> f) {
+                if (isMini(f)) {
+                    return "[node=" + ((MiniFuture)f).node().id() +
+                        ", loc=" + ((MiniFuture)f).node().isLocal() +
+                        ", done=" + f.isDone() + "]";
+                }
+                else
+                    return "[loc=true, done=" + f.isDone() + "]";
+            }
+        });
+
+        return S.toString(GridNearGetFuture.class, this,
+            "innerFuts", futs,
+            "super", super.toString());
+    }
+
     /**
      * Mini-future for get operations. Mini-futures are only waiting on a single
      * node as opposed to multiple nodes.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3de5f98c/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index a9e6cd0..ffeeca0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -1658,6 +1658,7 @@ public class GridFunc {
      * @return Light-weight view on given collection with provided predicate.
      */
     @SuppressWarnings("RedundantTypeArguments")
+    @SafeVarargs
     public static <T1, T2> Collection<T2> viewReadOnly(@Nullable final Collection<? extends T1> c,
         final IgniteClosure<? super T1, T2> trans, @Nullable final IgnitePredicate<? super T1>... p) {
         A.notNull(trans, "trans");


[47/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/project/vs/core-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/project/vs/core-test.vcxproj b/modules/platform/src/main/cpp/core-test/project/vs/core-test.vcxproj
new file mode 100644
index 0000000..aa8cb98
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/project/vs/core-test.vcxproj
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\common\project\vs\common.vcxproj">
+      <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\core\project\vs\core.vcxproj">
+      <Project>{e2dea693-f2ea-43c2-a813-053378f6e4db}</Project>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\config\cache-query.xml" />
+    <None Include="..\..\config\cache-test.xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\src\cache_test.cpp" />
+    <ClCompile Include="..\..\src\concurrent_test.cpp" />
+    <ClCompile Include="..\..\src\ignition_test.cpp" />
+    <ClCompile Include="..\..\src\handle_registry_test.cpp" />
+    <ClCompile Include="..\..\src\portable_reader_writer_raw_test.cpp" />
+    <ClCompile Include="..\..\src\portable_reader_writer_test.cpp" />
+    <ClCompile Include="..\..\src\portable_session_test.cpp" />
+    <ClCompile Include="..\..\src\portable_test_defs.cpp" />
+    <ClCompile Include="..\..\src\cache_query_test.cpp" />
+    <ClCompile Include="..\..\src\teamcity_boost.cpp" />
+    <ClCompile Include="..\..\src\teamcity_messages.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\include\ignite\portable_test_defs.h" />
+    <ClInclude Include="..\..\include\ignite\portable_test_utils.h" />
+    <ClInclude Include="..\..\include\teamcity_messages.h" />
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{133A22DB-FD60-44B9-B5E3-6CBB3EA5ABF0}</ProjectGuid>
+    <RootNamespace>coretest</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\core\os\win\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>_DEBUG;IGNITE_IMPL;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;_CRT_SECURE_NO_WARNINGS;IGNITE_FRIEND;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ExceptionHandling>Async</ExceptionHandling>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-gd-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <SubSystem>Console</SubSystem>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\core\os\win\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>_DEBUG;IGNITE_IMPL;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;_CRT_SECURE_NO_WARNINGS;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ExceptionHandling>Async</ExceptionHandling>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-gd-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\core\os\win\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>NDEBUG;IGNITE_IMPL;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;_CRT_SECURE_NO_WARNINGS;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ExceptionHandling>Async</ExceptionHandling>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\core\os\win\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>NDEBUG;IGNITE_IMPL;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;_CRT_SECURE_NO_WARNINGS;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ExceptionHandling>Async</ExceptionHandling>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/project/vs/core-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/project/vs/core-test.vcxproj.filters b/modules/platform/src/main/cpp/core-test/project/vs/core-test.vcxproj.filters
new file mode 100644
index 0000000..7e8dd95
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/project/vs/core-test.vcxproj.filters
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <ClCompile Include="..\..\src\cache_test.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\concurrent_test.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\ignition_test.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\handle_registry_test.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\portable_reader_writer_raw_test.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\portable_reader_writer_test.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\portable_session_test.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\portable_test_defs.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\cache_query_test.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\teamcity_boost.cpp">
+      <Filter>TeamCity</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\teamcity_messages.cpp">
+      <Filter>TeamCity</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\include\ignite\portable_test_defs.h">
+      <Filter>Code</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\portable_test_utils.h">
+      <Filter>Code</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\teamcity_messages.h">
+      <Filter>TeamCity</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <Filter Include="Code">
+      <UniqueIdentifier>{486c367c-57e9-430a-80f0-39fd5b09bc64}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Configs">
+      <UniqueIdentifier>{a46d9d4c-44eb-40da-b4f6-89cc43b70c12}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="TeamCity">
+      <UniqueIdentifier>{76bceab0-e251-445f-88c3-3f6f8739423b}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\config\cache-test.xml">
+      <Filter>Configs</Filter>
+    </None>
+    <None Include="..\..\config\cache-query.xml">
+      <Filter>Configs</Filter>
+    </None>
+  </ItemGroup>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/cache_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/cache_query_test.cpp b/modules/platform/src/main/cpp/core-test/src/cache_query_test.cpp
new file mode 100644
index 0000000..6ccfd51
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/cache_query_test.cpp
@@ -0,0 +1,651 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <sstream>
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/utils.h"
+#include "ignite/cache/cache.h"
+#include "ignite/cache/query/query_cursor.h"
+#include "ignite/cache/query/query_sql.h"
+#include "ignite/cache/query/query_text.h"
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace boost::unit_test;
+
+using namespace ignite;
+using namespace ignite::cache;
+using namespace ignite::cache::query;
+using namespace ignite::impl::utils;
+
+/**
+ * Person class for query tests.
+ */
+class IGNITE_IMPORT_EXPORT QueryPerson
+{
+public:
+    /**
+     * Constructor.
+     */
+    QueryPerson() : name(NULL), age(0)
+    {
+        // No-op.
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param name Name.
+     * @param age Age.
+     */
+    QueryPerson(std::string name, int age) : name(CopyChars(name.c_str())), age(age)
+    {
+        // No-op.
+    }
+
+    /**
+     * Copy constructor.
+     *
+     * @param other Other instance.
+     */
+    QueryPerson(const QueryPerson& other)
+    {
+        name = CopyChars(other.name);
+        age = other.age;
+    }
+
+    /**
+     * Assignment operator.
+     *
+     * @param other Other instance.
+     * @return This instance.
+     */
+    QueryPerson& operator=(const QueryPerson& other)
+    {
+        if (&other != this)
+        {
+            QueryPerson tmp(other);
+
+            char* name0 = name;
+            int age0 = age;
+
+            name = tmp.name;
+            age = tmp.age;
+
+            tmp.name = name0;
+            tmp.age = age0;
+        }
+
+        return *this;
+    }
+
+    /**
+     * Destructor.
+     */
+    ~QueryPerson()
+    {
+        ReleaseChars(name);
+    }
+
+    /**
+     * Get name.
+     * 
+     * @return Name.
+     */
+    std::string GetName()
+    {
+        return name ? std::string(name) : std::string();
+    }
+
+    /**
+     * Get age.
+     * 
+     * @return Age.
+     */
+    int32_t GetAge()
+    {
+        return age;
+    }
+
+private:
+    /** Name. */
+    char* name;
+
+    /** Age. */
+    int age;
+};
+
+namespace ignite
+{
+    namespace portable
+    {
+        /**
+         * Portable type definition.
+         */
+        IGNITE_PORTABLE_TYPE_START(QueryPerson)
+            IGNITE_PORTABLE_GET_TYPE_ID_AS_HASH(QueryPerson)
+            IGNITE_PORTABLE_GET_TYPE_NAME_AS_IS(QueryPerson)
+            IGNITE_PORTABLE_GET_FIELD_ID_AS_HASH
+            IGNITE_PORTABLE_GET_HASH_CODE_ZERO(QueryPerson)
+            IGNITE_PORTABLE_IS_NULL_FALSE(QueryPerson)
+            IGNITE_PORTABLE_GET_NULL_DEFAULT_CTOR(QueryPerson)
+
+            void Write(PortableWriter& writer, QueryPerson obj)
+            {
+                writer.WriteString("name", obj.GetName());
+                writer.WriteInt32("age", obj.GetAge());
+            }
+
+            QueryPerson Read(PortableReader& reader)
+            {
+                std::string name = reader.ReadString("name");
+                int age = reader.ReadInt32("age");
+            
+                return QueryPerson(name, age);
+            }
+
+        IGNITE_PORTABLE_TYPE_END
+    }
+}
+
+/** Node started during the test. */
+Ignite grid = Ignite();
+
+/** Cache accessor. */
+Cache<int, QueryPerson> GetCache()
+{
+    return grid.GetCache<int, QueryPerson>("cache");
+}
+
+/**
+ * Test setup fixture.
+ */
+struct CacheQueryTestSuiteFixture {
+    /**
+     * Constructor.
+     */
+    CacheQueryTestSuiteFixture()
+    {
+        IgniteConfiguration cfg;
+
+        IgniteJvmOption opts[5];
+
+        opts[0] = IgniteJvmOption("-Xdebug");
+        opts[1] = IgniteJvmOption("-Xnoagent");
+        opts[2] = IgniteJvmOption("-Djava.compiler=NONE");
+        opts[3] = IgniteJvmOption("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+        opts[4] = IgniteJvmOption("-XX:+HeapDumpOnOutOfMemoryError");
+
+        cfg.jvmOptsLen = 5;
+        cfg.jvmOpts = opts;
+
+        cfg.jvmInitMem = 1024;
+        cfg.jvmMaxMem = 4096;
+
+        char* cfgPath = getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH");
+
+        std::string cfgPathStr = std::string(cfgPath).append("/").append("cache-query.xml");
+
+        cfg.springCfgPath = const_cast<char*>(cfgPathStr.c_str());
+
+        IgniteError err;
+
+        Ignite grid0 = Ignition::Start(cfg, &err);
+
+        if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+            BOOST_ERROR(err.GetText());
+
+        grid = grid0;
+    }
+
+    /**
+     * Destructor.
+     */
+    ~CacheQueryTestSuiteFixture()
+    {
+        Ignition::Stop(grid.GetName(), true);
+    }
+};
+
+/**
+ * Ensure that HasNext() fails.
+ *
+ * @param cur Cursor.
+ */
+void CheckHasNextFail(QueryCursor<int, QueryPerson>& cur)
+{
+    try
+    {
+        cur.HasNext();
+
+        BOOST_FAIL("Must fail.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_GENERIC);
+    }
+}
+
+/**
+ * Ensure that GetNext() fails.
+ *
+ * @param cur Cursor.
+ */
+void CheckGetNextFail(QueryCursor<int, QueryPerson>& cur)
+{
+    try
+    {
+        cur.GetNext();
+
+        BOOST_FAIL("Must fail.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_GENERIC);
+    }
+}
+
+/**
+ * Ensure that GetAll() fails.
+ *
+ * @param cur Cursor.
+ */
+void CheckGetAllFail(QueryCursor<int, QueryPerson>& cur)
+{
+    try 
+    {
+        std::vector<CacheEntry<int, QueryPerson>> res;
+
+        cur.GetAll(res);
+
+        BOOST_FAIL("Must fail.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_GENERIC);
+    }
+}
+
+/**
+ * Check empty result through iteration.
+ *
+ * @param cur Cursor.
+ */
+void CheckEmpty(QueryCursor<int, QueryPerson>& cur)
+{
+    BOOST_REQUIRE(!cur.HasNext());
+
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+}
+
+/**
+ * Check empty result through GetAll().
+ *
+ * @param cur Cursor.
+ */
+void CheckEmptyGetAll(QueryCursor<int, QueryPerson>& cur)
+{
+    std::vector<CacheEntry<int, QueryPerson>> res;
+
+    cur.GetAll(res);
+
+    BOOST_REQUIRE(res.size() == 0);
+
+    CheckHasNextFail(cur);
+    CheckGetNextFail(cur);
+}
+
+/**
+ * Check single result through iteration.
+ *
+ * @param cur Cursor.
+ * @param key1 Key.
+ * @param name1 Name.
+ * @param age1 Age.
+ */
+void CheckSingle(QueryCursor<int, QueryPerson>& cur, int key, std::string name, int age)
+{
+    BOOST_REQUIRE(cur.HasNext());
+
+    CheckGetAllFail(cur);
+
+    CacheEntry<int, QueryPerson> entry = cur.GetNext();
+
+    CheckGetAllFail(cur);
+
+    BOOST_REQUIRE(entry.GetKey() == key);
+    BOOST_REQUIRE(entry.GetValue().GetName().compare(name) == 0);
+    BOOST_REQUIRE(entry.GetValue().GetAge() == age);
+
+    BOOST_REQUIRE(!cur.HasNext());
+
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+}
+
+/**
+ * Check single result through GetAll().
+ *
+ * @param cur Cursor.
+ * @param key1 Key.
+ * @param name1 Name.
+ * @param age1 Age.
+ */
+void CheckSingleGetAll(QueryCursor<int, QueryPerson>& cur, int key, std::string name, int age)
+{
+    std::vector<CacheEntry<int, QueryPerson>> res;
+
+    cur.GetAll(res);
+
+    CheckHasNextFail(cur);
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+
+    BOOST_REQUIRE(res.size() == 1);
+
+    BOOST_REQUIRE(res[0].GetKey() == 1);    
+    BOOST_REQUIRE(res[0].GetValue().GetName().compare(name) == 0);
+    BOOST_REQUIRE(res[0].GetValue().GetAge() == age);
+
+    CheckHasNextFail(cur);
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+}
+
+/**
+ * Check multiple results through iteration.
+ *
+ * @param cur Cursor.
+ * @param key1 Key 1.
+ * @param name1 Name 1.
+ * @param age1 Age 1.
+ * @param key2 Key 2.
+ * @param name2 Name 2.
+ * @param age2 Age 2.
+ */
+void CheckMultiple(QueryCursor<int, QueryPerson>& cur, int key1, std::string name1, 
+    int age1, int key2, std::string name2, int age2)
+{
+    for (int i = 0; i < 2; i++)
+    {
+        BOOST_REQUIRE(cur.HasNext());
+
+        CheckGetAllFail(cur);
+
+        CacheEntry<int, QueryPerson> entry = cur.GetNext();
+
+        CheckGetAllFail(cur);
+
+        if (entry.GetKey() == key1)
+        {
+            BOOST_REQUIRE(entry.GetValue().GetName().compare(name1) == 0);
+            BOOST_REQUIRE(entry.GetValue().GetAge() == age1);            
+        }
+        else if (entry.GetKey() == key2)
+        {
+            BOOST_REQUIRE(entry.GetValue().GetName().compare(name2) == 0);
+            BOOST_REQUIRE(entry.GetValue().GetAge() == age2);            
+        }
+        else
+            BOOST_FAIL("Unexpected entry.");
+    }
+    
+    BOOST_REQUIRE(!cur.HasNext());
+
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+}
+
+/**
+ * Check multiple results through GetAll().
+ *
+ * @param cur Cursor.
+ * @param key1 Key 1.
+ * @param name1 Name 1.
+ * @param age1 Age 1.
+ * @param key2 Key 2.
+ * @param name2 Name 2.
+ * @param age2 Age 2.
+ */
+void CheckMultipleGetAll(QueryCursor<int, QueryPerson>& cur, int key1, std::string name1, int age1, 
+    int key2, std::string name2, int age2)
+{
+    std::vector<CacheEntry<int, QueryPerson>> res;
+
+    cur.GetAll(res);
+
+    CheckHasNextFail(cur);
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+
+    BOOST_REQUIRE(res.size() == 2);
+
+    for (int i = 0; i < 2; i++)
+    {
+        CacheEntry<int, QueryPerson> entry = res[i];
+
+        if (entry.GetKey() == key1)
+        {
+            BOOST_REQUIRE(entry.GetValue().GetName().compare(name1) == 0);
+            BOOST_REQUIRE(entry.GetValue().GetAge() == age1);            
+        }
+        else if (entry.GetKey() == key2)
+        {
+            BOOST_REQUIRE(entry.GetValue().GetName().compare(name2) == 0);
+            BOOST_REQUIRE(entry.GetValue().GetAge() == age2);
+        }
+        else
+            BOOST_FAIL("Unexpected entry.");
+    }
+}
+
+BOOST_FIXTURE_TEST_SUITE(CacheQueryTestSuite, CacheQueryTestSuiteFixture)
+
+/**
+ * Test SQL query.
+ */
+BOOST_AUTO_TEST_CASE(TestSqlQuery)
+{    
+    Cache<int, QueryPerson> cache = GetCache();
+
+    // Test query with no results.
+    SqlQuery qry("QueryPerson", "age < 20");
+
+    QueryCursor<int, QueryPerson> cursor = cache.Query(qry);
+    CheckEmpty(cursor);
+
+    cursor = cache.Query(qry);
+    CheckEmptyGetAll(cursor);
+
+    // Test simple query.
+    cache.Put(1, QueryPerson("A1", 10));
+    cache.Put(2, QueryPerson("A2", 20));
+    
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+    
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test simple local query.
+    qry.SetLocal(true);
+
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test query with arguments.
+    qry.SetSql("age < ? AND name = ?");
+    qry.AddArgument<int>(20);
+    qry.AddArgument<std::string>("A1");
+
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test query returning multiple entries.
+    qry = SqlQuery("QueryPerson", "age < 30");
+
+    cursor = cache.Query(qry);
+    CheckMultiple(cursor, 1, "A1", 10, 2, "A2", 20);
+
+    cursor = cache.Query(qry);
+    CheckMultipleGetAll(cursor, 1, "A1", 10, 2, "A2", 20);
+}
+
+/**
+ * Test text query.
+ */
+BOOST_AUTO_TEST_CASE(TestTextQuery)
+{
+    Cache<int, QueryPerson> cache = GetCache();
+
+    // Test query with no results.
+    TextQuery qry("QueryPerson", "A1");
+
+    QueryCursor<int, QueryPerson> cursor = cache.Query(qry);
+    CheckEmpty(cursor);
+
+    cursor = cache.Query(qry);
+    CheckEmptyGetAll(cursor);
+
+    // Test simple query.
+    cache.Put(1, QueryPerson("A1", 10));
+    cache.Put(2, QueryPerson("A2", 20));
+
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test simple local query.
+    qry.SetLocal(true);
+
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test query returning multiple entries.
+    qry = TextQuery("QueryPerson", "A*");
+
+    cursor = cache.Query(qry);
+    CheckMultiple(cursor, 1, "A1", 10, 2, "A2", 20);
+
+    cursor = cache.Query(qry);
+    CheckMultipleGetAll(cursor, 1, "A1", 10, 2, "A2", 20);
+}
+
+/**
+ * Test scan query.
+ */
+BOOST_AUTO_TEST_CASE(TestScanQuery)
+{
+    // Test simple query.
+    Cache<int, QueryPerson> cache = GetCache();
+
+    // Test query with no results.
+    ScanQuery qry;
+
+    QueryCursor<int, QueryPerson> cursor = cache.Query(qry);
+    CheckEmpty(cursor);
+
+    cursor = cache.Query(qry);
+    CheckEmptyGetAll(cursor);
+
+    // Test simple query.
+    cache.Put(1, QueryPerson("A1", 10));
+
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test query returning multiple entries.
+    cache.Put(2, QueryPerson("A2", 20));
+
+    cursor = cache.Query(qry);
+    CheckMultiple(cursor, 1, "A1", 10, 2, "A2", 20);
+
+    cursor = cache.Query(qry);
+    CheckMultipleGetAll(cursor, 1, "A1", 10, 2, "A2", 20);
+}
+
+/**
+ * Test scan query over partitions.
+ */
+BOOST_AUTO_TEST_CASE(TestScanQueryPartitioned)
+{
+    // Populate cache with data.
+    Cache<int, QueryPerson> cache = GetCache();
+
+    int32_t partCnt = 256;   // Defined in configuration explicitly.   
+    int32_t entryCnt = 1000; // Should be greater than partCnt.
+    
+    for (int i = 0; i < entryCnt; i++) 
+    {
+        std::stringstream stream; 
+        
+        stream << "A" << i;
+            
+        cache.Put(i, QueryPerson(stream.str(), i * 10));
+    }
+
+    // Iterate over all partitions and collect data.
+    std::set<int> keys;
+
+    for (int i = 0; i < partCnt; i++)
+    {
+        ScanQuery qry(i);
+
+        QueryCursor<int, QueryPerson> cur = cache.Query(qry);
+
+        while (cur.HasNext())
+        {
+            CacheEntry<int, QueryPerson> entry = cur.GetNext();
+
+            int key = entry.GetKey();
+
+            keys.insert(key);
+
+            std::stringstream stream;
+            stream << "A" << key;
+            BOOST_REQUIRE(entry.GetValue().GetName().compare(stream.str()) == 0);
+
+            BOOST_REQUIRE(entry.GetValue().GetAge() == key * 10);
+        }
+    }
+
+    // Ensure that all keys were read.
+    BOOST_REQUIRE(keys.size() == entryCnt);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/cache_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/cache_test.cpp b/modules/platform/src/main/cpp/core-test/src/cache_test.cpp
new file mode 100644
index 0000000..b69caab
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/cache_test.cpp
@@ -0,0 +1,481 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/cache/cache_peek_mode.h"
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace boost::unit_test;
+
+/* Nodes started during the test. */
+Ignite grid0 = Ignite();
+Ignite grid1 = Ignite();
+
+/** Cache accessor. */
+cache::Cache<int, int> Cache()
+{
+    return grid0.GetCache<int, int>("partitioned");
+}
+
+struct Person
+{
+    std::string name;
+    int age;
+
+    Person() : name(""), age(0)
+    {
+        // No-op.
+    }
+
+    Person(std::string name, int age) : name(name), age(age)
+    {
+        // No-op.
+    }
+};
+
+namespace ignite
+{
+    namespace portable
+    {
+        IGNITE_PORTABLE_TYPE_START(Person)
+        IGNITE_PORTABLE_GET_TYPE_ID_AS_HASH(Person)
+        IGNITE_PORTABLE_GET_TYPE_NAME_AS_IS(Person)
+        IGNITE_PORTABLE_GET_FIELD_ID_AS_HASH
+        IGNITE_PORTABLE_GET_HASH_CODE_ZERO(Person)
+        IGNITE_PORTABLE_IS_NULL_FALSE(Person)
+        IGNITE_PORTABLE_GET_NULL_DEFAULT_CTOR(Person)
+            
+        void Write(PortableWriter& writer, Person obj)
+        {
+            writer.WriteString("name", obj.name);
+            writer.WriteInt32("age", obj.age);            
+        }
+
+        Person Read(PortableReader& reader)
+        {
+            std::string name = reader.ReadString("name");
+            int age = reader.ReadInt32("age");
+            
+            return Person(name, age);
+        }
+
+        IGNITE_PORTABLE_TYPE_END
+    }
+}
+
+/*
+ * Test setup fixture.
+ */
+struct CacheTestSuiteFixture {
+    /*
+     * Constructor.
+     */
+    CacheTestSuiteFixture()
+    {
+        IgniteConfiguration cfg;
+
+        IgniteJvmOption opts[5];
+
+        opts[0] = IgniteJvmOption("-Xdebug");
+        opts[1] = IgniteJvmOption("-Xnoagent");
+        opts[2] = IgniteJvmOption("-Djava.compiler=NONE");
+        opts[3] = IgniteJvmOption("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+        opts[4] = IgniteJvmOption("-XX:+HeapDumpOnOutOfMemoryError");
+
+        cfg.jvmOptsLen = 5;
+        cfg.jvmOpts = opts;
+
+        cfg.jvmInitMem = 1024;
+        cfg.jvmMaxMem = 4096;
+
+        char* cfgPath = getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH");
+
+        std::string cfgPathStr = std::string(cfgPath).append("/").append("cache-test.xml");
+
+        cfg.springCfgPath = const_cast<char*>(cfgPathStr.c_str());
+        
+        for (int i = 0; i < 2; i++) 
+        {
+            std::stringstream stream;
+
+            stream << "grid-" << i;
+
+            IgniteError err;
+
+            Ignite grid = Ignition::Start(cfg, stream.str().c_str(), &err);
+                
+            if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+                BOOST_FAIL(err.GetText());
+
+            if (i == 0)
+                grid0 = grid;
+            else
+                grid1 = grid;
+        }
+    }
+
+    /*
+     * Destructor.
+     */
+    ~CacheTestSuiteFixture()
+    {
+        Ignition::Stop(grid0.GetName(), true);
+        Ignition::Stop(grid1.GetName(), true);
+
+        grid0 = Ignite();
+        grid1 = Ignite();
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(CacheTestSuite, CacheTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(TestRemoveAllKeys)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 1);
+    cache.Put(2, 2);
+    cache.Put(3, 3);
+
+    int size = cache.Size(cache::IGNITE_PEEK_MODE_PRIMARY);
+
+    BOOST_REQUIRE(3 == size);
+
+    cache.RemoveAll();
+
+    size = cache.Size(cache::IGNITE_PEEK_MODE_ALL);
+
+    BOOST_REQUIRE(0 == size);
+
+    cache.Put(1, 1);
+    cache.Put(2, 2);
+    cache.Put(3, 3);
+
+    int keys[] = { 1, 2, 4, 5 };
+
+    std::set<int> keySet(keys, keys + 4);
+
+    cache.RemoveAll(keySet);
+
+    size = cache.Size(cache::IGNITE_PEEK_MODE_PRIMARY);
+
+    BOOST_REQUIRE(1 == size);
+}
+
+BOOST_AUTO_TEST_CASE(TestPut)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 1);
+
+    BOOST_REQUIRE(1 == cache.Get(1));
+}
+
+BOOST_AUTO_TEST_CASE(TestPutAll)
+{
+    std::map<int, int> map;
+
+    for (int i = 0; i < 100; i++)
+        map[i] = i + 1;
+    
+    cache::Cache<int, int> cache = Cache();
+
+    cache.PutAll(map);
+
+    for (int i = 0; i < 100; i++)
+        BOOST_REQUIRE(i + 1 == cache.Get(i));
+}
+
+BOOST_AUTO_TEST_CASE(TestPutIfAbsent)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(true == cache.PutIfAbsent(1, 3));
+    BOOST_REQUIRE(false == cache.PutIfAbsent(1, 3));
+}
+
+BOOST_AUTO_TEST_CASE(TestGet)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 1);
+    cache.Put(2, 2);
+
+    BOOST_REQUIRE(1 == cache.Get(1));
+    BOOST_REQUIRE(2 == cache.Get(2));
+    
+    BOOST_REQUIRE(0 == cache.Get(3));
+}
+
+BOOST_AUTO_TEST_CASE(TestGetAll)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    int keys[] = { 1, 2, 3, 4, 5 };
+    
+    std::set<int> keySet (keys, keys + 5);
+
+    for (int i = 0; i < keySet.size(); i++)
+        cache.Put(i + 1, i + 1);
+
+    std::map<int, int> map = cache.GetAll(keySet);
+
+    for (int i = 0; i < keySet.size(); i++)
+        BOOST_REQUIRE(i + 1 == map[i + 1]);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetAndPut)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(0 == cache.GetAndPut(1, 3));
+    BOOST_REQUIRE(3 == cache.GetAndPut(1, 1));
+    BOOST_REQUIRE(1 == cache.GetAndPut(1, 0));
+}
+
+BOOST_AUTO_TEST_CASE(TestGetAndPutIfAbsent)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(0 == cache.GetAndPutIfAbsent(1, 3));
+    BOOST_REQUIRE(3 == cache.GetAndPutIfAbsent(1, 1));
+    BOOST_REQUIRE(3 == cache.GetAndPutIfAbsent(1, 1));
+}
+
+BOOST_AUTO_TEST_CASE(TestGetAndRemove)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 3);
+
+    BOOST_REQUIRE(3 == cache.GetAndRemove(1));
+    BOOST_REQUIRE(0 == cache.GetAndRemove(1));
+}
+
+BOOST_AUTO_TEST_CASE(TestGetAndReplace)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(0 == cache.GetAndReplace(1, 3));
+    BOOST_REQUIRE(0 == cache.GetAndReplace(1, 3));
+
+    cache.Put(1, 5);
+
+    BOOST_REQUIRE(5 == cache.GetAndReplace(1, 3));
+    BOOST_REQUIRE(3 == cache.GetAndReplace(1, 3));
+}
+
+BOOST_AUTO_TEST_CASE(TestContainsKey)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(false == cache.ContainsKey(1));
+
+    cache.Put(1, 1);
+
+    BOOST_REQUIRE(true == cache.ContainsKey(1));
+
+    BOOST_REQUIRE(true == cache.Remove(1));
+    
+    BOOST_REQUIRE(false == cache.ContainsKey(1));
+}
+
+BOOST_AUTO_TEST_CASE(TestContainsKeys)
+{
+    cache::Cache<int, int> cache = Cache();
+    
+    int keys[] = { 1, 2 };
+
+    std::set<int> keySet(keys, keys + 2);
+
+    BOOST_REQUIRE(false == cache.ContainsKeys(keySet));
+
+    cache.Put(1, 1);
+    cache.Put(2, 2);
+    
+    BOOST_REQUIRE(true == cache.ContainsKeys(keySet));
+
+    cache.Remove(1);
+
+    BOOST_REQUIRE(false == cache.ContainsKeys(keySet));
+}
+
+BOOST_AUTO_TEST_CASE(TestIsEmpty)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(true == cache.IsEmpty());
+
+    cache.Put(1, 1);
+
+    BOOST_REQUIRE(false == cache.IsEmpty());
+
+    cache.Remove(1);
+
+    BOOST_REQUIRE(true == cache.IsEmpty());
+}
+
+BOOST_AUTO_TEST_CASE(TestRemove)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(false == cache.Remove(1));
+
+    cache.Put(1, 1);
+
+    BOOST_REQUIRE(true == cache.Remove(1));
+    BOOST_REQUIRE(false == cache.Remove(1));
+    BOOST_REQUIRE(false == cache.ContainsKey(1));
+}
+
+BOOST_AUTO_TEST_CASE(TestClear)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 1);
+
+    BOOST_REQUIRE(true == cache.ContainsKey(1));
+
+    cache.Clear(1);
+
+    BOOST_REQUIRE(false == cache.ContainsKey(1));
+}
+
+BOOST_AUTO_TEST_CASE(TestLocalClear)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(0, 2);
+
+    BOOST_REQUIRE(2 == cache.LocalPeek(0, cache::IGNITE_PEEK_MODE_PRIMARY));
+
+    cache.LocalClear(0);
+
+    BOOST_REQUIRE(0 == cache.LocalPeek(0, cache::IGNITE_PEEK_MODE_PRIMARY));
+}
+
+BOOST_AUTO_TEST_CASE(TestLocalClearAll)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(0, 3);
+    cache.Put(1, 3);
+
+    int keys[] = { 0, 1 };
+
+    std::set<int> keySet(keys, keys + 2);
+
+    BOOST_REQUIRE(3 == cache.LocalPeek(0, cache::IGNITE_PEEK_MODE_PRIMARY));
+    BOOST_REQUIRE(3 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_PRIMARY));
+
+    cache.LocalClearAll(keySet);
+
+    BOOST_REQUIRE(0 == cache.LocalPeek(0, cache::IGNITE_PEEK_MODE_PRIMARY));
+    BOOST_REQUIRE(0 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_PRIMARY));
+}
+
+BOOST_AUTO_TEST_CASE(TestSizes)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(0 == cache.Size());
+
+    cache.Put(1, 1);
+    cache.Put(2, 2);
+
+    BOOST_REQUIRE(2 <= cache.Size());
+
+    BOOST_REQUIRE(1 <= cache.LocalSize(cache::IGNITE_PEEK_MODE_PRIMARY));
+}
+
+BOOST_AUTO_TEST_CASE(TestLocalEvict)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 5);
+
+    BOOST_REQUIRE(5 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_ONHEAP));
+
+    int keys[] = { 0, 1 };
+
+    std::set<int> keySet(keys, keys + 2);
+
+    cache.LocalEvict(keySet);
+
+    BOOST_REQUIRE(0 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_ONHEAP));
+
+    BOOST_REQUIRE(5 == cache.Get(1));
+
+    BOOST_REQUIRE(5 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_ONHEAP));
+}
+
+BOOST_AUTO_TEST_CASE(TestPortable)
+{
+    cache::Cache<int, Person> cache = grid0.GetCache<int, Person>("partitioned");
+
+    Person person("John Johnson", 3);
+
+    cache.Put(1, person);
+
+    Person person0 = cache.Get(1);
+
+    BOOST_REQUIRE(person.age == person0.age);
+    BOOST_REQUIRE(person.name.compare(person0.name) == 0);
+}
+
+BOOST_AUTO_TEST_CASE(TestCreateCache)
+{
+    // Create new cache
+    cache::Cache<int, int> cache = grid0.CreateCache<int, int>("dynamic_cache");
+
+    cache.Put(5, 7);
+
+    BOOST_REQUIRE(7 == cache.Get(5));
+
+    // Attempt to create cache with existing name
+    IgniteError err;
+
+    grid0.CreateCache<int, int>("dynamic_cache", &err);
+
+    BOOST_REQUIRE(err.GetCode() != IgniteError::IGNITE_SUCCESS);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetOrCreateCache)
+{
+    // Get existing cache
+    cache::Cache<int, int> cache = grid0.GetOrCreateCache<int, int>("partitioned");
+
+    cache.Put(5, 7);
+
+    BOOST_REQUIRE(7 == cache.Get(5));
+
+    // Create new cache
+    cache::Cache<int, int> cache2 = grid0.GetOrCreateCache<int, int>("partitioned_new");
+
+    cache2.Put(5, 7);
+
+    BOOST_REQUIRE(7 == cache2.Get(5));
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/concurrent_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/concurrent_test.cpp b/modules/platform/src/main/cpp/core-test/src/concurrent_test.cpp
new file mode 100644
index 0000000..2d89b7a
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/concurrent_test.cpp
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <ignite/common/concurrent.h>
+
+using namespace ignite::common::concurrent;
+
+BOOST_AUTO_TEST_SUITE(ConcurrentTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestAtomic32)
+{
+    int32_t val = 1;
+
+    BOOST_REQUIRE(Atomics::CompareAndSet32(&val, 1, 2));
+    BOOST_REQUIRE(val == 2);
+
+    BOOST_REQUIRE(!Atomics::CompareAndSet32(&val, 3, 1));
+    BOOST_REQUIRE(val == 2);
+
+    BOOST_REQUIRE(Atomics::CompareAndSet32Val(&val, 2, 3) == 2);
+    BOOST_REQUIRE(val == 3);
+
+    BOOST_REQUIRE(Atomics::CompareAndSet32Val(&val, 4, 2) == 3);
+    BOOST_REQUIRE(val == 3);
+
+    BOOST_REQUIRE(Atomics::IncrementAndGet32(&val) == 4);
+    BOOST_REQUIRE(val == 4);
+
+    BOOST_REQUIRE(Atomics::DecrementAndGet32(&val) == 3);
+    BOOST_REQUIRE(val == 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestAtomic64)
+{
+    int64_t val = 1;
+
+    BOOST_REQUIRE(Atomics::CompareAndSet64(&val, 1, 2));
+    BOOST_REQUIRE(val == 2);
+
+    BOOST_REQUIRE(!Atomics::CompareAndSet64(&val, 3, 1));
+    BOOST_REQUIRE(val == 2);
+
+    BOOST_REQUIRE(Atomics::CompareAndSet64Val(&val, 2, 3) == 2);
+    BOOST_REQUIRE(val == 3);
+
+    BOOST_REQUIRE(Atomics::CompareAndSet64Val(&val, 4, 2) == 3);
+    BOOST_REQUIRE(val == 3);
+
+    BOOST_REQUIRE(Atomics::IncrementAndGet64(&val) == 4);
+    BOOST_REQUIRE(val == 4);
+
+    BOOST_REQUIRE(Atomics::DecrementAndGet64(&val) == 3);
+    BOOST_REQUIRE(val == 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestThreadLocal)
+{
+    int32_t idx1 = ThreadLocal::NextIndex();
+    int32_t idx2 = ThreadLocal::NextIndex();
+    BOOST_REQUIRE(idx2 > idx1);
+
+    BOOST_REQUIRE(ThreadLocal::Get<int32_t>(idx1) == 0);
+
+    ThreadLocal::Set(idx1, 1);
+    BOOST_REQUIRE(ThreadLocal::Get<int32_t>(idx1) == 1);
+
+    ThreadLocal::Set(idx1, 2);
+    BOOST_REQUIRE(ThreadLocal::Get<int32_t>(idx1) == 2);
+
+    ThreadLocal::Remove(idx1);
+    BOOST_REQUIRE(ThreadLocal::Get<int32_t>(idx1) == 0);
+    
+    ThreadLocal::Set(idx1, 1);
+    BOOST_REQUIRE(ThreadLocal::Get<int32_t>(idx1) == 1);
+
+    ThreadLocal::Remove(idx1);
+}
+
+BOOST_AUTO_TEST_CASE(TestThreadLocalInstance)
+{
+    ThreadLocalInstance<int32_t> val;
+
+    BOOST_REQUIRE(val.Get() == 0);
+
+    val.Set(1);
+    BOOST_REQUIRE(val.Get() == 1);
+
+    val.Set(2);
+    BOOST_REQUIRE(val.Get() == 2);
+
+    val.Remove();
+    BOOST_REQUIRE(val.Get() == 0);
+
+    val.Set(1);
+    BOOST_REQUIRE(val.Get() == 1);
+
+    val.Remove();
+}
+
+struct SharedPointerTarget
+{
+    bool deleted;
+
+    SharedPointerTarget() : deleted(false)
+    {
+        // No-op.
+    }
+};
+
+void DeleteSharedPointerTarget(SharedPointerTarget* ptr)
+{
+    ptr->deleted = true;
+}
+
+BOOST_AUTO_TEST_CASE(TestSharedPointer)
+{
+    // 1. Test the simples scenario.
+    SharedPointerTarget* target = new SharedPointerTarget();
+
+    SharedPointer<SharedPointerTarget>* ptr1 = 
+        new SharedPointer<SharedPointerTarget>(target, DeleteSharedPointerTarget);
+
+    delete ptr1;
+    BOOST_REQUIRE(target->deleted);
+
+    target->deleted = false;
+
+    // 2. Test copy ctor.
+    ptr1 = new SharedPointer<SharedPointerTarget>(target, DeleteSharedPointerTarget);
+    SharedPointer<SharedPointerTarget>* ptr2 = new SharedPointer<SharedPointerTarget>(*ptr1);
+
+    delete ptr1;
+    BOOST_REQUIRE(!target->deleted);
+
+    delete ptr2;
+    BOOST_REQUIRE(target->deleted);
+
+    target->deleted = false;
+
+    // 3. Test assignment logic.
+    ptr1 = new SharedPointer<SharedPointerTarget>(target, DeleteSharedPointerTarget);
+
+    SharedPointer<SharedPointerTarget> ptr3 = *ptr1;
+
+    delete ptr1;
+    BOOST_REQUIRE(!target->deleted);
+
+    ptr3 = SharedPointer<SharedPointerTarget>();
+    BOOST_REQUIRE(target->deleted);
+
+    target->deleted = false;
+
+    // 4. Test self-assignment.
+    ptr1 = new SharedPointer<SharedPointerTarget>(target, DeleteSharedPointerTarget);
+
+    *ptr1 = *ptr1;
+
+    delete ptr1;
+
+    BOOST_REQUIRE(target->deleted);
+
+    // 5. Tear-down.
+    delete target;    
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/handle_registry_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/handle_registry_test.cpp b/modules/platform/src/main/cpp/core-test/src/handle_registry_test.cpp
new file mode 100644
index 0000000..bc4a654
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/handle_registry_test.cpp
@@ -0,0 +1,176 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/handle_registry.h"
+
+using namespace ignite::common::concurrent;
+using namespace ignite::impl;
+
+struct HandleRegistryTestProbe
+{
+    bool deleted;
+    
+    HandleRegistryTestProbe()
+    {
+        deleted = false;
+    }
+};
+
+class HandleRegistryTestEntry : public HandleRegistryEntry
+{
+public:
+    HandleRegistryTestEntry(HandleRegistryTestProbe* probe) : probe(probe)
+    {
+        // No-op.
+    }
+
+    virtual ~HandleRegistryTestEntry()
+    {
+        probe->deleted = true;
+    }
+
+private:
+    HandleRegistryTestProbe* probe;
+};
+
+BOOST_AUTO_TEST_SUITE(HandleRegistryTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestCritical)
+{
+    HandleRegistry reg(2, 1);
+
+    HandleRegistryTestProbe probe0;
+    HandleRegistryTestProbe probe1;
+    HandleRegistryTestProbe probe2;
+
+    HandleRegistryTestEntry* entry0 = new HandleRegistryTestEntry(&probe0);
+    HandleRegistryTestEntry* entry1 = new HandleRegistryTestEntry(&probe1);
+    HandleRegistryTestEntry* entry2 = new HandleRegistryTestEntry(&probe2);
+
+    int64_t hnd0 = reg.AllocateCritical(SharedPointer<HandleRegistryEntry>(entry0));
+    int64_t hnd1 = reg.AllocateCritical(SharedPointer<HandleRegistryEntry>(entry1));
+    int64_t hnd2 = reg.AllocateCritical(SharedPointer<HandleRegistryEntry>(entry2));
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == entry0);
+    BOOST_REQUIRE(!probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == entry1);
+    BOOST_REQUIRE(!probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == entry2);
+    BOOST_REQUIRE(!probe2.deleted);
+
+    reg.Release(hnd0);
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == NULL);
+    BOOST_REQUIRE(probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == entry1);
+    BOOST_REQUIRE(!probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == entry2);
+    BOOST_REQUIRE(!probe2.deleted);
+
+    reg.Close();
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == NULL);
+    BOOST_REQUIRE(probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == NULL);
+    BOOST_REQUIRE(probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == NULL);
+    BOOST_REQUIRE(probe2.deleted);
+
+    HandleRegistry closedReg(2, 1);
+
+    closedReg.Close();
+
+    HandleRegistryTestProbe closedProbe;
+    HandleRegistryTestEntry* closedEntry = new HandleRegistryTestEntry(&closedProbe);
+
+    int64_t closedHnd = closedReg.AllocateCritical(SharedPointer<HandleRegistryEntry>(closedEntry));
+    BOOST_REQUIRE(closedHnd == -1);
+    BOOST_REQUIRE(closedProbe.deleted);
+}
+
+BOOST_AUTO_TEST_CASE(TestNonCritical)
+{
+    HandleRegistry reg(0, 2);
+
+    HandleRegistryTestProbe probe0;
+    HandleRegistryTestProbe probe1;
+    HandleRegistryTestProbe probe2;
+
+    HandleRegistryTestEntry* entry0 = new HandleRegistryTestEntry(&probe0);
+    HandleRegistryTestEntry* entry1 = new HandleRegistryTestEntry(&probe1);
+    HandleRegistryTestEntry* entry2 = new HandleRegistryTestEntry(&probe2);
+
+    int64_t hnd0 = reg.AllocateCritical(SharedPointer<HandleRegistryEntry>(entry0));
+    int64_t hnd1 = reg.Allocate(SharedPointer<HandleRegistryEntry>(entry1));
+    int64_t hnd2 = reg.Allocate(SharedPointer<HandleRegistryEntry>(entry2));
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == entry0);
+    BOOST_REQUIRE(!probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == entry1);
+    BOOST_REQUIRE(!probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == entry2);
+    BOOST_REQUIRE(!probe2.deleted);
+
+    reg.Release(hnd0);
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == NULL);
+    BOOST_REQUIRE(probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == entry1);
+    BOOST_REQUIRE(!probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == entry2);
+    BOOST_REQUIRE(!probe2.deleted);
+
+    reg.Close();
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == NULL);
+    BOOST_REQUIRE(probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == NULL);
+    BOOST_REQUIRE(probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == NULL);
+    BOOST_REQUIRE(probe2.deleted);
+
+    HandleRegistry closedReg(0, 2);
+
+    closedReg.Close();
+
+    HandleRegistryTestProbe closedProbe;
+    HandleRegistryTestEntry* closedEntry = new HandleRegistryTestEntry(&closedProbe);
+
+    int64_t closedHnd = closedReg.Allocate(SharedPointer<HandleRegistryEntry>(closedEntry));
+    BOOST_REQUIRE(closedHnd == -1);
+    BOOST_REQUIRE(closedProbe.deleted);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/ignition_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/ignition_test.cpp b/modules/platform/src/main/cpp/core-test/src/ignition_test.cpp
new file mode 100644
index 0000000..f55977a
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/ignition_test.cpp
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace boost::unit_test;
+
+BOOST_AUTO_TEST_SUITE(IgnitionTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestIgnition)
+{
+    IgniteConfiguration cfg;
+
+    IgniteJvmOption opts[5];
+
+    opts[0] = IgniteJvmOption("-Xdebug");
+    opts[1] = IgniteJvmOption("-Xnoagent");
+    opts[2] = IgniteJvmOption("-Djava.compiler=NONE");
+    opts[3] = IgniteJvmOption("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+    opts[4] = IgniteJvmOption("-XX:+HeapDumpOnOutOfMemoryError");
+
+    cfg.jvmOptsLen = 5;
+    cfg.jvmOpts = opts;
+
+    cfg.jvmInitMem = 1024;
+    cfg.jvmMaxMem = 4096;
+
+    char* cfgPath = getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH");
+
+    std::string cfgPathStr = std::string(cfgPath).append("/").append("cache-test.xml");
+
+    cfg.springCfgPath = const_cast<char*>(cfgPathStr.c_str());
+
+    IgniteError err;
+
+    // Start two Ignite instances.
+    Ignite grid1 = Ignition::Start(cfg, "ignitionTest-1", &err);
+    
+    if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+        BOOST_ERROR(err.GetText());
+    
+    BOOST_REQUIRE(strcmp(grid1.GetName(), "ignitionTest-1") == 0);
+
+    Ignite grid2 = Ignition::Start(cfg, "ignitionTest-2", &err);
+
+    if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+        BOOST_ERROR(err.GetText());
+
+    BOOST_REQUIRE(strcmp(grid2.GetName(), "ignitionTest-2") == 0);
+
+    // Test get
+    Ignite grid0 = Ignition::Get("ignitionTest-1", &err);
+    
+    if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+        BOOST_ERROR(err.GetText());
+
+    BOOST_REQUIRE(strcmp(grid0.GetName(), grid1.GetName()) == 0);
+
+    // Stop one grid
+    Ignition::Stop(grid1.GetName(), true);
+    
+    Ignition::Get("ignitionTest-1", &err);
+    BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_GENERIC);
+    
+    Ignition::Get("ignitionTest-2", &err);
+    BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+    // Stop all
+    Ignition::StopAll(true);
+    
+    Ignition::Get("ignitionTest-2", &err);
+    BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_GENERIC);    
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file


[12/50] [abbrv] ignite git commit: ignite-1273: added ability to modify arrays returned from PortableBuilder and fixed cyclic references processing for arrays and collections in PortableMarshaller

Posted by ak...@apache.org.
ignite-1273: added ability to modify arrays returned from PortableBuilder and fixed cyclic references processing for arrays and collections in PortableMarshaller


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

Branch: refs/heads/ignite-843
Commit: 9057a4c0c7b2242dc9396432d700a87f21a52f1f
Parents: 6769956
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Sep 3 09:06:54 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Sep 3 09:06:54 2015 +0300

----------------------------------------------------------------------
 .../portable/GridPortableMarshaller.java        |  44 +-
 .../portable/PortableAbstractLazyValue.java     |  57 --
 .../internal/portable/PortableBuilderEnum.java  | 114 ---
 .../internal/portable/PortableBuilderImpl.java  | 531 ------------
 .../portable/PortableBuilderReader.java         | 776 ------------------
 .../PortableBuilderSerializationAware.java      |  29 -
 .../portable/PortableBuilderSerializer.java     | 211 -----
 .../portable/PortableClassDescriptor.java       |  57 +-
 .../internal/portable/PortableContext.java      |   6 +-
 .../portable/PortableEnumArrayLazyValue.java    | 112 ---
 .../portable/PortableLazyArrayList.java         | 159 ----
 .../portable/PortableLazyLinkedList.java        | 215 -----
 .../internal/portable/PortableLazyMap.java      | 218 -----
 .../internal/portable/PortableLazyMapEntry.java |  66 --
 .../internal/portable/PortableLazySet.java      |  89 ---
 .../internal/portable/PortableLazyValue.java    |  28 -
 .../portable/PortableObjectArrayLazyValue.java  |  89 ---
 .../portable/PortablePlainLazyValue.java        |  47 --
 .../portable/PortablePlainPortableObject.java   |  50 --
 .../internal/portable/PortableReaderExImpl.java | 154 +++-
 .../ignite/internal/portable/PortableUtils.java |  11 +
 .../portable/PortableValueWithType.java         |  74 --
 .../internal/portable/PortableWriterExImpl.java | 159 +++-
 .../builder/PortableAbstractLazyValue.java      |  57 ++
 .../portable/builder/PortableBuilderEnum.java   | 116 +++
 .../portable/builder/PortableBuilderImpl.java   | 537 +++++++++++++
 .../portable/builder/PortableBuilderReader.java | 800 +++++++++++++++++++
 .../PortableBuilderSerializationAware.java      |  31 +
 .../builder/PortableBuilderSerializer.java      | 214 +++++
 .../builder/PortableEnumArrayLazyValue.java     | 114 +++
 .../portable/builder/PortableLazyArrayList.java | 166 ++++
 .../builder/PortableLazyLinkedList.java         | 217 +++++
 .../portable/builder/PortableLazyMap.java       | 220 +++++
 .../portable/builder/PortableLazyMapEntry.java  |  68 ++
 .../portable/builder/PortableLazySet.java       |  92 +++
 .../portable/builder/PortableLazyValue.java     |  28 +
 .../builder/PortableModifiableLazyValue.java    |  52 ++
 .../builder/PortableObjectArrayLazyValue.java   |  91 +++
 .../builder/PortablePlainLazyValue.java         |  49 ++
 .../builder/PortablePlainPortableObject.java    |  53 ++
 .../portable/builder/PortableValueWithType.java |  75 ++
 .../internal/portable/builder/package-info.java |  22 +
 .../CacheObjectPortableProcessorImpl.java       |   2 +-
 .../resources/META-INF/classnames.properties    |   2 +-
 .../GridPortableBuilderAdditionalSelfTest.java  | 232 +++++-
 .../portable/GridPortableBuilderSelfTest.java   |   1 +
 .../GridPortableMarshallerSelfTest.java         |  72 +-
 .../GridPortableMetaDataDisabledSelfTest.java   |  17 +
 .../portable/GridPortableMetaDataSelfTest.java  |  17 +
 .../mutabletest/GridPortableTestClasses.java    |  38 +-
 ...ClientNodePortableMetadataMultinodeTest.java |  11 +
 51 files changed, 3687 insertions(+), 3003 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
index 3b2357e..c7a9e6f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
@@ -142,67 +142,67 @@ public class GridPortableMarshaller {
     public static final byte OBJ = (byte)103;
 
     /** */
-    static final byte USER_SET = -1;
+    public static final byte USER_SET = -1;
 
     /** */
-    static final byte USER_COL = 0;
+    public static final byte USER_COL = 0;
 
     /** */
-    static final byte ARR_LIST = 1;
+    public static final byte ARR_LIST = 1;
 
     /** */
-    static final byte LINKED_LIST = 2;
+    public static final byte LINKED_LIST = 2;
 
     /** */
-    static final byte HASH_SET = 3;
+    public static final byte HASH_SET = 3;
 
     /** */
-    static final byte LINKED_HASH_SET = 4;
+    public static final byte LINKED_HASH_SET = 4;
 
     /** */
-    static final byte TREE_SET = 5;
+    public static final byte TREE_SET = 5;
 
     /** */
-    static final byte CONC_SKIP_LIST_SET = 6;
+    public static final byte CONC_SKIP_LIST_SET = 6;
 
     /** */
-    static final byte HASH_MAP = 1;
+    public static final byte HASH_MAP = 1;
 
     /** */
-    static final byte LINKED_HASH_MAP = 2;
+    public static final byte LINKED_HASH_MAP = 2;
 
     /** */
-    static final byte TREE_MAP = 3;
+    public static final byte TREE_MAP = 3;
 
     /** */
-    static final byte CONC_HASH_MAP = 4;
+    public static final byte CONC_HASH_MAP = 4;
 
     /** */
-    static final byte PROPERTIES_MAP = 5;
+    public static final byte PROPERTIES_MAP = 5;
 
     /** */
-    static final int OBJECT_TYPE_ID = -1;
+    public static final int OBJECT_TYPE_ID = -1;
 
     /** */
-    static final int UNREGISTERED_TYPE_ID = 0;
+    public static final int UNREGISTERED_TYPE_ID = 0;
 
     /** */
-    static final int TYPE_ID_POS = 2;
+    public static final int TYPE_ID_POS = 2;
 
     /** */
-    static final int HASH_CODE_POS = 6;
+    public static final int HASH_CODE_POS = 6;
 
     /** */
-    static final int TOTAL_LEN_POS = 10;
+    public static final int TOTAL_LEN_POS = 10;
 
     /** */
-    static final byte RAW_DATA_OFF_POS = 14;
+    public static final byte RAW_DATA_OFF_POS = 14;
 
     /** */
-    static final int CLS_NAME_POS = 18;
+    public static final int CLS_NAME_POS = 18;
 
     /** */
-    static final byte DFLT_HDR_LEN = 18;
+    public static final byte DFLT_HDR_LEN = 18;
 
     /** */
     private final PortableContext ctx;
@@ -301,4 +301,4 @@ public class GridPortableMarshaller {
     public PortableContext context() {
         return ctx;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableAbstractLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableAbstractLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableAbstractLazyValue.java
deleted file mode 100644
index 2b1c4b7..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableAbstractLazyValue.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-/**
- *
- */
-abstract class PortableAbstractLazyValue implements PortableLazyValue {
-    /** */
-    protected Object val;
-
-    /** */
-    protected final PortableBuilderReader reader;
-
-    /** */
-    protected final int valOff;
-
-    /**
-     * @param reader Reader.
-     * @param valOff Value.
-     */
-    protected PortableAbstractLazyValue(PortableBuilderReader reader, int valOff) {
-        this.reader = reader;
-        this.valOff = valOff;
-    }
-
-    /**
-     * @return Value.
-     */
-    protected abstract Object init();
-
-    /** {@inheritDoc} */
-    @Override public Object value() {
-        if (val == null) {
-            val = init();
-
-            assert val != null;
-        }
-
-        return val;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderEnum.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderEnum.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderEnum.java
deleted file mode 100644
index b6ace99..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderEnum.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.portable.PortableInvalidClassException;
-
-/**
- *
- */
-public class PortableBuilderEnum implements PortableBuilderSerializationAware {
-    /** */
-    private final int ordinal;
-
-    /** */
-    private final int typeId;
-
-    /** */
-    private final String clsName;
-
-    /**
-     * @param typeId Type ID.
-     * @param anEnum Enum instance.
-     */
-    public PortableBuilderEnum(int typeId, Enum anEnum) {
-        ordinal = anEnum.ordinal();
-        this.typeId = typeId;
-        clsName = null;
-    }
-
-    /**
-     * @param reader PortableBuilderReader.
-     */
-    public PortableBuilderEnum(PortableBuilderReader reader) {
-        int typeId = reader.readInt();
-
-        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
-            clsName = reader.readString();
-
-            Class cls;
-
-            try {
-                // TODO: IGNITE-1272 - Is class loader needed here?
-                cls = U.forName(reader.readString(), null);
-            }
-            catch (ClassNotFoundException e) {
-                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
-            }
-
-            this.typeId = reader.portableContext().descriptorForClass(cls).typeId();
-        }
-        else {
-            this.typeId = typeId;
-            this.clsName = null;
-        }
-
-        ordinal = reader.readInt();
-    }
-
-    /**
-     * @return Ordinal.
-     */
-    public int getOrdinal() {
-        return ordinal;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        writer.writeByte(GridPortableMarshaller.ENUM);
-
-        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
-            writer.writeInt(GridPortableMarshaller.UNREGISTERED_TYPE_ID);
-            writer.writeString(clsName);
-        }
-        else
-            writer.writeInt(typeId);
-
-        writer.writeInt(ordinal);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        PortableBuilderEnum that = (PortableBuilderEnum)o;
-
-        return ordinal == that.ordinal && typeId == that.typeId;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int result = ordinal;
-
-        result = 31 * result + typeId;
-
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderImpl.java
deleted file mode 100644
index dac199a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderImpl.java
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
-import org.apache.ignite.internal.util.GridArgumentCheck;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.portable.PortableBuilder;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableInvalidClassException;
-import org.apache.ignite.portable.PortableMetadata;
-import org.apache.ignite.portable.PortableObject;
-import org.jetbrains.annotations.Nullable;
-
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLS_NAME_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.HASH_CODE_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.RAW_DATA_OFF_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TYPE_ID_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
-
-/**
- *
- */
-public class PortableBuilderImpl implements PortableBuilder {
-    /** */
-    private static final Object REMOVED_FIELD_MARKER = new Object();
-
-    /** */
-    private final PortableContext ctx;
-
-    /** */
-    private final int typeId;
-
-    /** May be null. */
-    private String typeName;
-
-    /** May be null. */
-    private String clsNameToWrite;
-
-    /** */
-    private boolean registeredType = true;
-
-    /** */
-    private Map<String, Object> assignedVals;
-
-    /** */
-    private Map<Integer, Object> readCache;
-
-    /** Position of object in source array, or -1 if object is not created from PortableObject. */
-    private final int start;
-
-    /** Total header length */
-    private final int hdrLen;
-
-    /**
-     * Context of PortableObject reading process. Or {@code null} if object is not created from PortableObject.
-     */
-    private final PortableBuilderReader reader;
-
-    /** */
-    private int hashCode;
-
-    /**
-     * @param clsName Class name.
-     * @param ctx Portable context.
-     */
-    public PortableBuilderImpl(PortableContext ctx, String clsName) {
-        this(ctx, ctx.typeId(clsName), PortableContext.typeName(clsName));
-    }
-
-    /**
-     * @param typeId Type ID.
-     * @param ctx Portable context.
-     */
-    public PortableBuilderImpl(PortableContext ctx, int typeId) {
-        this(ctx, typeId, null);
-    }
-
-    /**
-     * @param typeName Type name.
-     * @param ctx Context.
-     * @param typeId Type id.
-     */
-    public PortableBuilderImpl(PortableContext ctx, int typeId, String typeName) {
-        this.typeId = typeId;
-        this.typeName = typeName;
-        this.ctx = ctx;
-
-        start = -1;
-        reader = null;
-        hdrLen = DFLT_HDR_LEN;
-
-        readCache = Collections.emptyMap();
-    }
-
-    /**
-     * @param obj Object to wrap.
-     */
-    public PortableBuilderImpl(PortableObjectImpl obj) {
-        this(new PortableBuilderReader(obj), obj.start());
-
-        reader.registerObject(this);
-    }
-
-    /**
-     * @param reader ctx
-     * @param start Start.
-     */
-    PortableBuilderImpl(PortableBuilderReader reader, int start) {
-        this.reader = reader;
-        this.start = start;
-
-        int typeId = reader.readIntAbsolute(start + TYPE_ID_POS);
-        ctx = reader.portableContext();
-        hashCode = reader.readIntAbsolute(start + HASH_CODE_POS);
-
-        if (typeId == UNREGISTERED_TYPE_ID) {
-            int mark = reader.position();
-
-            reader.position(start + CLS_NAME_POS);
-
-            clsNameToWrite = reader.readString();
-
-            Class cls;
-
-            try {
-                // TODO: IGNITE-1272 - Is class loader needed here?
-                cls = U.forName(clsNameToWrite, null);
-            }
-            catch (ClassNotFoundException e) {
-                throw new PortableInvalidClassException("Failed to load the class: " + clsNameToWrite, e);
-            }
-
-            this.typeId = ctx.descriptorForClass(cls).typeId();
-
-            registeredType = false;
-
-            hdrLen = reader.position() - mark;
-
-            reader.position(mark);
-        }
-        else {
-            this.typeId = typeId;
-            hdrLen = DFLT_HDR_LEN;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public PortableObject build() {
-        try (PortableWriterExImpl writer = new PortableWriterExImpl(ctx, 0, typeId, false)) {
-
-            PortableBuilderSerializer serializationCtx = new PortableBuilderSerializer();
-
-            serializationCtx.registerObjectWriting(this, 0);
-
-            serializeTo(writer, serializationCtx);
-
-            byte[] arr = writer.array();
-
-            return new PortableObjectImpl(ctx, arr, 0);
-        }
-    }
-
-    /**
-     * @param writer Writer.
-     * @param serializer Serializer.
-     */
-    void serializeTo(PortableWriterExImpl writer, PortableBuilderSerializer serializer) {
-        writer.doWriteByte(GridPortableMarshaller.OBJ);
-        writer.doWriteBoolean(true);
-        writer.doWriteInt(registeredType ? typeId : UNREGISTERED_TYPE_ID);
-        writer.doWriteInt(hashCode);
-
-        // Length and raw offset.
-        writer.reserve(8);
-
-        if (!registeredType)
-            writer.writeString(clsNameToWrite);
-
-
-        Set<Integer> remainsFlds = null;
-
-        if (reader != null) {
-            Map<Integer, Object> assignedFldsById;
-
-            if (assignedVals != null) {
-                assignedFldsById = U.newHashMap(assignedVals.size());
-
-                for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
-                    int fldId = ctx.fieldId(typeId, entry.getKey());
-
-                    assignedFldsById.put(fldId, entry.getValue());
-                }
-
-                remainsFlds = assignedFldsById.keySet();
-            }
-            else
-                assignedFldsById = Collections.emptyMap();
-
-            int rawOff = start + reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
-
-            reader.position(start + hdrLen);
-
-            int cpStart = -1;
-
-            while (reader.position() < rawOff) {
-                int fldId = reader.readInt();
-
-                int len = reader.readInt();
-
-                if (assignedFldsById.containsKey(fldId)) {
-                    if (cpStart >= 0) {
-                        writer.write(reader.array(), cpStart, reader.position() - 4 - 4 - cpStart);
-
-                        cpStart = -1;
-                    }
-
-                    Object assignedVal = assignedFldsById.remove(fldId);
-
-                    reader.skip(len);
-
-                    if (assignedVal != REMOVED_FIELD_MARKER) {
-                        writer.writeInt(fldId);
-
-                        int lenPos = writer.reserveAndMark(4);
-
-                        serializer.writeValue(writer, assignedVal);
-
-                        writer.writeDelta(lenPos);
-                    }
-                }
-                else {
-                    if (len != 0 && PortableUtils.isPlainType(reader.readByte(0))) {
-                        if (cpStart < 0)
-                            cpStart = reader.position() - 4 - 4;
-
-                        reader.skip(len);
-                    }
-                    else {
-                        if (cpStart >= 0) {
-                            writer.write(reader.array(), cpStart, reader.position() - 4 - cpStart);
-
-                            cpStart = -1;
-                        }
-                        else
-                            writer.writeInt(fldId);
-
-                        Object val;
-
-                        if (len == 0)
-                            val = null;
-                        else if (readCache == null) {
-                            int savedPos = reader.position();
-
-                            val = reader.parseValue();
-
-                            assert reader.position() == savedPos + len;
-                        }
-                        else {
-                            val = readCache.get(fldId);
-
-                            reader.skip(len);
-                        }
-
-                        int lenPos = writer.reserveAndMark(4);
-
-                        serializer.writeValue(writer, val);
-
-                        writer.writeDelta(lenPos);
-                    }
-                }
-            }
-
-            if (cpStart >= 0)
-                writer.write(reader.array(), cpStart, reader.position() - cpStart);
-        }
-
-        if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) {
-            boolean metadataEnabled = ctx.isMetaDataEnabled(typeId);
-
-            PortableMetadata metadata = null;
-
-            if (metadataEnabled)
-                metadata = ctx.metaData(typeId);
-
-            Map<String, String> newFldsMetadata = null;
-
-            for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
-                Object val = entry.getValue();
-
-                if (val == REMOVED_FIELD_MARKER)
-                    continue;
-
-                String name = entry.getKey();
-
-                int fldId = ctx.fieldId(typeId, name);
-
-                if (remainsFlds != null && !remainsFlds.contains(fldId))
-                    continue;
-
-                writer.writeInt(fldId);
-
-                int lenPos = writer.reserveAndMark(4);
-
-                serializer.writeValue(writer, val);
-
-                writer.writeDelta(lenPos);
-
-                if (metadataEnabled) {
-                    String oldFldTypeName = metadata == null ? null : metadata.fieldTypeName(name);
-
-                    String newFldTypeName;
-
-                    if (val instanceof PortableValueWithType)
-                        newFldTypeName = ((PortableValueWithType)val).typeName();
-                    else {
-                        byte type = PortableUtils.typeByClass(val.getClass());
-
-                        newFldTypeName = CacheObjectPortableProcessorImpl.fieldTypeName(type);
-                    }
-
-                    if (oldFldTypeName == null) {
-                        // It's a new field, we have to add it to metadata.
-
-                        if (newFldsMetadata == null)
-                            newFldsMetadata = new HashMap<>();
-
-                        newFldsMetadata.put(name, newFldTypeName);
-                    }
-                    else {
-                        if (!"Object".equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) {
-                            throw new PortableException(
-                                "Wrong value has been set [" +
-                                    "typeName=" + (typeName == null ? metadata.typeName() : typeName) +
-                                    ", fieldName=" + name +
-                                    ", fieldType=" + oldFldTypeName +
-                                    ", assignedValueType=" + newFldTypeName +
-                                    ", assignedValue=" + (((PortableValueWithType)val).value()) + ']'
-                            );
-                        }
-                    }
-                }
-            }
-
-            if (newFldsMetadata != null) {
-                String typeName = this.typeName;
-
-                if (typeName == null)
-                    typeName = metadata.typeName();
-
-                ctx.updateMetaData(typeId, typeName, newFldsMetadata);
-            }
-        }
-
-        writer.writeRawOffsetIfNeeded();
-
-        if (reader != null) {
-            int rawOff = reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
-            int len = reader.readIntAbsolute(start + TOTAL_LEN_POS);
-
-            if (rawOff < len)
-                writer.write(reader.array(), rawOff, len - rawOff);
-        }
-
-        writer.writeLength();
-    }
-
-    /** {@inheritDoc} */
-    @Override public PortableBuilderImpl hashCode(int hashCode) {
-        this.hashCode = hashCode;
-
-        return this;
-    }
-
-    /**
-     *
-     */
-    private void ensureReadCacheInit() {
-        if (readCache == null) {
-            Map<Integer, Object> readCache = new HashMap<>();
-
-            int pos = start + hdrLen;
-            int end = start + reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
-
-            while (pos < end) {
-                int fieldId = reader.readIntAbsolute(pos);
-
-                pos += 4;
-
-                int len = reader.readIntAbsolute(pos);
-
-                pos += 4;
-
-                Object val = reader.getValueQuickly(pos, len);
-
-                readCache.put(fieldId, val);
-
-                pos += len;
-            }
-
-            this.readCache = readCache;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <F> F getField(String name) {
-        Object val;
-
-        if (assignedVals != null && assignedVals.containsKey(name)) {
-            val = assignedVals.get(name);
-
-            if (val == REMOVED_FIELD_MARKER)
-                return null;
-        }
-        else {
-            ensureReadCacheInit();
-
-            int fldId = ctx.fieldId(typeId, name);
-
-            val = readCache.get(fldId);
-        }
-
-        return (F)PortableUtils.unwrapLazy(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public PortableBuilder setField(String name, Object val) {
-        GridArgumentCheck.notNull(val, "val");
-
-        if (assignedVals == null)
-            assignedVals = new LinkedHashMap<>();
-
-        Object oldVal = assignedVals.put(name, val);
-
-        if (oldVal instanceof PortableValueWithType) {
-            ((PortableValueWithType)oldVal).value(val);
-
-            assignedVals.put(name, oldVal);
-        }
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> PortableBuilder setField(String name, @Nullable T val, Class<? super T> type) {
-        if (assignedVals == null)
-            assignedVals = new LinkedHashMap<>();
-
-        //int fldId = ctx.fieldId(typeId, fldName);
-
-        assignedVals.put(name, new PortableValueWithType(PortableUtils.typeByClass(type), val));
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public PortableBuilder setField(String name, @Nullable PortableBuilder builder) {
-        if (builder == null)
-            return setField(name, null, Object.class);
-        else
-            return setField(name, (Object)builder);
-    }
-
-    /**
-     * Removes field from portable object.
-     *
-     * @param name Field name.
-     * @return {@code this} instance for chaining.
-     */
-    @Override public PortableBuilderImpl removeField(String name) {
-        if (assignedVals == null)
-            assignedVals = new LinkedHashMap<>();
-
-        assignedVals.put(name, REMOVED_FIELD_MARKER);
-
-        return this;
-    }
-
-    /**
-     * Creates builder initialized by specified portable object.
-     *
-     * @param obj Portable object to initialize builder.
-     * @return New builder.
-     */
-    public static PortableBuilderImpl wrap(PortableObject obj) {
-        PortableObjectImpl heapObj;
-
-        if (obj instanceof PortableObjectOffheapImpl)
-            heapObj = (PortableObjectImpl)((PortableObjectOffheapImpl)obj).heapCopy();
-        else
-            heapObj = (PortableObjectImpl)obj;
-
-        return new PortableBuilderImpl(heapObj);
-    }
-
-    /**
-     * @return Object start position in source array.
-     */
-    int start() {
-        return start;
-    }
-
-    /**
-     * @return Object type id.
-     */
-    int typeId() {
-        return typeId;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderReader.java
deleted file mode 100644
index 30b31f0..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderReader.java
+++ /dev/null
@@ -1,776 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.portable.PortableException;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
-
-/**
- *
- */
-class PortableBuilderReader {
-    /** */
-    private static final PortablePrimitives PRIM = PortablePrimitives.get();
-
-    /** */
-    private final Map<Integer, PortableBuilderImpl> objMap = new HashMap<>();
-
-    /** */
-    private final PortableContext ctx;
-
-    /** */
-    private final PortableReaderExImpl reader;
-
-    /** */
-    private byte[] arr;
-
-    /** */
-    private int pos;
-
-    /**
-     * @param objImpl Portable object
-     */
-    PortableBuilderReader(PortableObjectImpl objImpl) {
-        ctx = objImpl.context();
-        arr = objImpl.array();
-        pos = objImpl.start();
-
-        // TODO: IGNITE-1272 - Is class loader needed here?
-        reader = new PortableReaderExImpl(portableContext(), arr, pos, null);
-    }
-
-    /**
-     * @return Portable context.
-     */
-    public PortableContext portableContext() {
-        return ctx;
-    }
-
-    /**
-     * @param obj Mutable portable object.
-     */
-    public void registerObject(PortableBuilderImpl obj) {
-        objMap.put(obj.start(), obj);
-    }
-
-    /**
-     * @return Read int value.
-     */
-    public int readInt() {
-        int res = readInt(0);
-
-        pos += 4;
-
-        return res;
-    }
-
-    /**
-     * @return Read int value.
-     */
-    public byte readByte() {
-        return arr[pos++];
-    }
-
-    /**
-     * @return Read boolean value.
-     */
-    public boolean readBoolean() {
-        return readByte() == 1;
-    }
-
-    /**
-     * @return Read int value.
-     */
-    public byte readByte(int off) {
-        return arr[pos + off];
-    }
-
-    /**
-     * @param off Offset related to {@link #pos}
-     * @return Read int value.
-     */
-    public int readInt(int off) {
-        return PRIM.readInt(arr, pos + off);
-    }
-
-    /**
-     * @param pos Position in the source array.
-     * @return Read int value.
-     */
-    public int readIntAbsolute(int pos) {
-        return PRIM.readInt(arr, pos);
-    }
-
-    /**
-     * @return Read length of array.
-     */
-    public int readLength() {
-        return PRIM.readInt(arr, pos);
-    }
-
-    /**
-     * Read string length.
-     *
-     * @return String length.
-     */
-    public int readStringLength() {
-        boolean utf = PRIM.readBoolean(arr, pos);
-
-        int arrLen = PRIM.readInt(arr, pos + 1);
-
-        return 1 + (utf ? arrLen : arrLen << 1);
-    }
-
-    /**
-     * Reads string.
-     *
-     * @return String.
-     */
-    public String readString() {
-        byte flag = readByte();
-
-        if (flag == NULL)
-            return null;
-
-        if (flag != STRING)
-            throw new PortableException("Failed to deserialize String.");
-
-        boolean convert = readBoolean();
-        int len = readInt();
-
-        String str;
-
-        if (convert) {
-            str = new String(arr, pos, len, UTF_8);
-
-            pos += len;
-        }
-        else {
-            str = String.valueOf(PRIM.readCharArray(arr, pos, len));
-
-            pos += len << 1;
-        }
-
-        return str;
-    }
-
-    /**
-     *
-     */
-    public void skipValue() {
-        byte type = arr[pos++];
-
-        int len;
-
-        switch (type) {
-            case GridPortableMarshaller.NULL:
-                return;
-
-            case GridPortableMarshaller.OBJ:
-                pos += readInt(GridPortableMarshaller.TOTAL_LEN_POS - 1) - 1;
-
-                return;
-
-            case GridPortableMarshaller.BOOLEAN:
-            case GridPortableMarshaller.BYTE:
-                len = 1;
-                break;
-
-            case GridPortableMarshaller.CHAR:
-            case GridPortableMarshaller.SHORT:
-                len = 2;
-
-                break;
-
-            case GridPortableMarshaller.HANDLE:
-            case GridPortableMarshaller.FLOAT:
-            case GridPortableMarshaller.INT:
-                len = 4;
-
-                break;
-
-            case GridPortableMarshaller.ENUM:
-                //skipping type id and ordinal value
-                len = 8;
-
-                break;
-
-            case GridPortableMarshaller.LONG:
-            case GridPortableMarshaller.DOUBLE:
-                len = 8;
-
-                break;
-
-            case GridPortableMarshaller.BYTE_ARR:
-            case GridPortableMarshaller.BOOLEAN_ARR:
-                len = 4 + readLength();
-
-                break;
-
-            case GridPortableMarshaller.STRING:
-                len = 4 + readStringLength();
-
-                break;
-
-            case GridPortableMarshaller.DECIMAL:
-                len = /** scale */ 4  + /** mag len */ 4  + /** mag bytes count */ readInt(4);
-
-                break;
-
-            case GridPortableMarshaller.UUID:
-                len = 8 + 8;
-
-                break;
-
-            case GridPortableMarshaller.DATE:
-                len = 8 + 4;
-
-                break;
-
-            case GridPortableMarshaller.CHAR_ARR:
-            case GridPortableMarshaller.SHORT_ARR:
-                len = 4 + readLength() * 2;
-
-                break;
-
-            case GridPortableMarshaller.INT_ARR:
-            case GridPortableMarshaller.FLOAT_ARR:
-                len = 4 + readLength() * 4;
-
-                break;
-
-            case GridPortableMarshaller.LONG_ARR:
-            case GridPortableMarshaller.DOUBLE_ARR:
-                len = 4 + readLength() * 8;
-
-                break;
-
-            case GridPortableMarshaller.DECIMAL_ARR:
-            case GridPortableMarshaller.DATE_ARR:
-            case GridPortableMarshaller.OBJ_ARR:
-            case GridPortableMarshaller.ENUM_ARR:
-            case GridPortableMarshaller.UUID_ARR:
-            case GridPortableMarshaller.STRING_ARR: {
-                int size = readInt();
-
-                for (int i = 0; i < size; i++)
-                    skipValue();
-
-                return;
-            }
-
-            case GridPortableMarshaller.COL: {
-                int size = readInt();
-
-                pos++; // skip collection type
-
-                for (int i = 0; i < size; i++)
-                    skipValue();
-
-                return;
-            }
-
-            case GridPortableMarshaller.MAP: {
-                int size = readInt();
-
-                pos++; // skip collection type
-
-                for (int i = 0; i < size; i++) {
-                    skipValue(); // skip key.
-                    skipValue(); // skip value.
-                }
-
-                return;
-            }
-
-            case GridPortableMarshaller.MAP_ENTRY:
-                skipValue();
-                skipValue();
-
-                return;
-
-            case GridPortableMarshaller.PORTABLE_OBJ:
-                len = readInt() + 4;
-
-                break;
-
-            default:
-                throw new PortableException("Invalid flag value: " + type);
-        }
-
-        pos += len;
-    }
-
-    /**
-     * @param pos Position.
-     * @param len Length.
-     * @return Object.
-     */
-    public Object getValueQuickly(int pos, int len) {
-        byte type = arr[pos];
-
-        switch (type) {
-            case GridPortableMarshaller.NULL:
-                return null;
-
-            case GridPortableMarshaller.HANDLE: {
-                int objStart = pos - readIntAbsolute(pos + 1);
-
-                PortableBuilderImpl res = objMap.get(objStart);
-
-                if (res == null) {
-                    res = new PortableBuilderImpl(this, objStart);
-
-                    objMap.put(objStart, res);
-                }
-
-                return res;
-            }
-
-            case GridPortableMarshaller.OBJ: {
-                PortableBuilderImpl res = objMap.get(pos);
-
-                if (res == null) {
-                    res = new PortableBuilderImpl(this, pos);
-
-                    objMap.put(pos, res);
-                }
-
-                return res;
-            }
-
-            case GridPortableMarshaller.BYTE:
-                return arr[pos + 1];
-
-            case GridPortableMarshaller.SHORT:
-                return PRIM.readShort(arr, pos + 1);
-
-            case GridPortableMarshaller.INT:
-                return PRIM.readInt(arr, pos + 1);
-
-            case GridPortableMarshaller.LONG:
-                return PRIM.readLong(arr, pos + 1);
-
-            case GridPortableMarshaller.FLOAT:
-                return PRIM.readFloat(arr, pos + 1);
-
-            case GridPortableMarshaller.DOUBLE:
-                return PRIM.readDouble(arr, pos + 1);
-
-            case GridPortableMarshaller.CHAR:
-                return PRIM.readChar(arr, pos + 1);
-
-            case GridPortableMarshaller.BOOLEAN:
-                return arr[pos + 1] != 0;
-
-            case GridPortableMarshaller.DECIMAL:
-            case GridPortableMarshaller.STRING:
-            case GridPortableMarshaller.UUID:
-            case GridPortableMarshaller.DATE:
-            case GridPortableMarshaller.BYTE_ARR:
-            case GridPortableMarshaller.SHORT_ARR:
-            case GridPortableMarshaller.INT_ARR:
-            case GridPortableMarshaller.LONG_ARR:
-            case GridPortableMarshaller.FLOAT_ARR:
-            case GridPortableMarshaller.DOUBLE_ARR:
-            case GridPortableMarshaller.CHAR_ARR:
-            case GridPortableMarshaller.BOOLEAN_ARR:
-            case GridPortableMarshaller.DECIMAL_ARR:
-            case GridPortableMarshaller.DATE_ARR:
-            case GridPortableMarshaller.UUID_ARR:
-            case GridPortableMarshaller.STRING_ARR:
-                return new PortablePlainLazyValue(this, pos, len);
-
-            case GridPortableMarshaller.COL:
-            case GridPortableMarshaller.OBJ_ARR:
-            case GridPortableMarshaller.MAP:
-            case GridPortableMarshaller.ENUM_ARR:
-            case GridPortableMarshaller.MAP_ENTRY:
-                return new LazyCollection(pos);
-
-            case GridPortableMarshaller.ENUM: {
-                if (len == 1) {
-                    assert readByte(pos) == GridPortableMarshaller.NULL;
-
-                    return null;
-                }
-
-                int mark = position();
-                position(pos + 1);
-
-                PortableBuilderEnum builderEnum = new PortableBuilderEnum(this);
-
-                position(mark);
-
-                return builderEnum;
-            }
-
-            case GridPortableMarshaller.PORTABLE_OBJ: {
-                int size = readIntAbsolute(pos + 1);
-
-                int start = readIntAbsolute(pos + 4 + size);
-
-                PortableObjectImpl portableObj = new PortableObjectImpl(ctx, arr, pos + 4 + start);
-
-                return new PortablePlainPortableObject(portableObj);
-            }
-
-            default:
-                throw new PortableException("Invalid flag value: " + type);
-        }
-    }
-
-    /**
-     * @return Parsed value.
-     */
-    public Object parseValue() {
-        int valPos = pos;
-
-        byte type = arr[pos++];
-
-        int plainLazyValLen;
-
-        switch (type) {
-            case GridPortableMarshaller.NULL:
-                return null;
-
-            case GridPortableMarshaller.HANDLE: {
-                int objStart = pos - 1 - readInt();
-
-                PortableBuilderImpl res = objMap.get(objStart);
-
-                if (res == null) {
-                    res = new PortableBuilderImpl(this, objStart);
-
-                    objMap.put(objStart, res);
-                }
-
-                return res;
-            }
-
-            case GridPortableMarshaller.OBJ: {
-                pos--;
-
-                PortableBuilderImpl res = objMap.get(pos);
-
-                if (res == null) {
-                    res = new PortableBuilderImpl(this, pos);
-
-                    objMap.put(pos, res);
-                }
-
-                pos += readInt(GridPortableMarshaller.TOTAL_LEN_POS);
-
-                return res;
-            }
-
-            case GridPortableMarshaller.BYTE:
-                return arr[pos++];
-
-            case GridPortableMarshaller.SHORT: {
-                Object res = PRIM.readShort(arr, pos);
-                pos += 2;
-                return res;
-            }
-
-            case GridPortableMarshaller.INT:
-                return readInt();
-
-            case GridPortableMarshaller.LONG:
-                plainLazyValLen = 8;
-
-                break;
-
-            case GridPortableMarshaller.FLOAT:
-                plainLazyValLen = 4;
-
-                break;
-
-            case GridPortableMarshaller.DOUBLE:
-                plainLazyValLen = 8;
-
-                break;
-
-            case GridPortableMarshaller.CHAR:
-                plainLazyValLen = 2;
-
-                break;
-
-            case GridPortableMarshaller.BOOLEAN:
-                return arr[pos++] != 0;
-
-            case GridPortableMarshaller.DECIMAL:
-                plainLazyValLen = /** scale */ 4  + /** mag len */ 4  + /** mag bytes count */ readInt(4);
-
-                break;
-
-            case GridPortableMarshaller.STRING:
-                plainLazyValLen = 4 + readStringLength();
-
-                break;
-
-            case GridPortableMarshaller.UUID:
-                plainLazyValLen = 8 + 8;
-
-                break;
-
-            case GridPortableMarshaller.DATE:
-                plainLazyValLen = 8 + 4;
-
-                break;
-
-            case GridPortableMarshaller.BYTE_ARR:
-                plainLazyValLen = 4 + readLength();
-
-                break;
-
-            case GridPortableMarshaller.SHORT_ARR:
-                plainLazyValLen = 4 + readLength() * 2;
-
-                break;
-
-            case GridPortableMarshaller.INT_ARR:
-                plainLazyValLen = 4 + readLength() * 4;
-
-                break;
-
-            case GridPortableMarshaller.LONG_ARR:
-                plainLazyValLen = 4 + readLength() * 8;
-
-                break;
-
-            case GridPortableMarshaller.FLOAT_ARR:
-                plainLazyValLen = 4 + readLength() * 4;
-
-                break;
-
-            case GridPortableMarshaller.DOUBLE_ARR:
-                plainLazyValLen = 4 + readLength() * 8;
-
-                break;
-
-            case GridPortableMarshaller.CHAR_ARR:
-                plainLazyValLen = 4 + readLength() * 2;
-
-                break;
-
-            case GridPortableMarshaller.BOOLEAN_ARR:
-                plainLazyValLen = 4 + readLength();
-
-                break;
-
-            case GridPortableMarshaller.OBJ_ARR:
-                return new PortableObjectArrayLazyValue(this);
-
-            case GridPortableMarshaller.DATE_ARR: {
-                int size = readInt();
-
-                Date[] res = new Date[size];
-
-                for (int i = 0; i < res.length; i++) {
-                    byte flag = arr[pos++];
-
-                    if (flag == GridPortableMarshaller.NULL) continue;
-
-                    if (flag != GridPortableMarshaller.DATE)
-                        throw new PortableException("Invalid flag value: " + flag);
-
-                    long time = PRIM.readLong(arr, pos);
-
-                    pos += 8;
-
-                    if (ctx.isUseTimestamp()) {
-                        Timestamp ts = new Timestamp(time);
-
-                        ts.setNanos(ts.getNanos() + readInt());
-
-                        res[i] = ts;
-                    }
-                    else {
-                        res[i] = new Date(time);
-
-                        pos += 4;
-                    }
-                }
-
-                return res;
-            }
-
-            case GridPortableMarshaller.UUID_ARR:
-            case GridPortableMarshaller.STRING_ARR:
-            case GridPortableMarshaller.DECIMAL_ARR: {
-                int size = readInt();
-
-                for (int i = 0; i < size; i++) {
-                    byte flag = arr[pos++];
-
-                    if (flag == GridPortableMarshaller.UUID)
-                        pos += 8 + 8;
-                    else if (flag == GridPortableMarshaller.STRING)
-                        pos += 4 + readStringLength();
-                    else if (flag == GridPortableMarshaller.DECIMAL)
-                        pos += 4 + readLength();
-                    else
-                        assert flag == GridPortableMarshaller.NULL;
-                }
-
-                return new PortablePlainLazyValue(this, valPos, pos - valPos);
-            }
-
-            case GridPortableMarshaller.COL: {
-                int size = readInt();
-                byte colType = arr[pos++];
-
-                switch (colType) {
-                    case GridPortableMarshaller.USER_COL:
-                    case GridPortableMarshaller.ARR_LIST:
-                        return new PortableLazyArrayList(this, size);
-
-                    case GridPortableMarshaller.LINKED_LIST:
-                        return new PortableLazyLinkedList(this, size);
-
-                    case GridPortableMarshaller.HASH_SET:
-                    case GridPortableMarshaller.LINKED_HASH_SET:
-                    case GridPortableMarshaller.TREE_SET:
-                    case GridPortableMarshaller.CONC_SKIP_LIST_SET:
-                        return new PortableLazySet(this, size);
-                }
-
-                throw new PortableException("Unknown collection type: " + colType);
-            }
-
-            case GridPortableMarshaller.MAP:
-                return PortableLazyMap.parseMap(this);
-
-            case GridPortableMarshaller.ENUM:
-                return new PortableBuilderEnum(this);
-
-            case GridPortableMarshaller.ENUM_ARR:
-                return new PortableEnumArrayLazyValue(this);
-
-            case GridPortableMarshaller.MAP_ENTRY:
-                return new PortableLazyMapEntry(this);
-
-            case GridPortableMarshaller.PORTABLE_OBJ: {
-                int size = readInt();
-
-                pos += size;
-
-                int start = readInt();
-
-                PortableObjectImpl portableObj = new PortableObjectImpl(ctx, arr,
-                    pos - 4 - size + start);
-
-                return new PortablePlainPortableObject(portableObj);
-            }
-
-
-            default:
-                throw new PortableException("Invalid flag value: " + type);
-        }
-
-        PortablePlainLazyValue res = new PortablePlainLazyValue(this, valPos, 1 + plainLazyValLen);
-
-        pos += plainLazyValLen;
-
-        return res;
-    }
-
-    /**
-     * @return Array.
-     */
-    public byte[] array() {
-        return arr;
-    }
-
-    /**
-     * @return Position of reader.
-     */
-    public int position() {
-        return pos;
-    }
-
-    /**
-     * @param pos New pos.
-     */
-    public void position(int pos) {
-        this.pos = pos;
-    }
-
-    /**
-     * @param n Number of bytes to skip.
-     */
-    public void skip(int n) {
-        pos += n;
-    }
-
-    /**
-     * @return Reader.
-     */
-    PortableReaderExImpl reader() {
-        return reader;
-    }
-
-    /**
-     *
-     */
-    private class LazyCollection implements PortableLazyValue {
-        /** */
-        private final int valOff;
-
-        /** */
-        private Object col;
-
-        /**
-         * @param valOff Value.
-         */
-        protected LazyCollection(int valOff) {
-            this.valOff = valOff;
-        }
-
-        /**
-         * @return Object.
-         */
-        private Object wrappedCollection() {
-            if (col == null) {
-                position(valOff);
-
-                col = parseValue();
-            }
-
-            return col;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-            ctx.writeValue(writer, wrappedCollection());
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object value() {
-            return PortableUtils.unwrapLazy(wrappedCollection());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializationAware.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializationAware.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializationAware.java
deleted file mode 100644
index d75cd7b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializationAware.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-/**
- *
- */
-interface PortableBuilderSerializationAware {
-    /**
-     * @param writer Writer.
-     * @param ctx Context.
-     */
-    public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializer.java
deleted file mode 100644
index 6ce9f4c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializer.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.Collection;
-import java.util.IdentityHashMap;
-import java.util.Map;
-import org.apache.ignite.internal.util.GridConcurrentSkipListSet;
-import org.apache.ignite.portable.PortableObject;
-
-/**
- *
- */
-class PortableBuilderSerializer {
-    /** */
-    private final Map<PortableBuilderImpl, Integer> objToPos = new IdentityHashMap<>();
-
-    /** */
-    private Map<PortableObject, PortableBuilderImpl> portableObjToWrapper;
-
-    /**
-     * @param obj Mutable object.
-     * @param posInResArr Object position in the array.
-     */
-    public void registerObjectWriting(PortableBuilderImpl obj, int posInResArr) {
-        objToPos.put(obj, posInResArr);
-    }
-
-    /**
-     * @param writer Writer.
-     * @param val Value.
-     */
-    public void writeValue(PortableWriterExImpl writer, Object val) {
-        if (val == null) {
-            writer.writeByte(GridPortableMarshaller.NULL);
-
-            return;
-        }
-
-        if (val instanceof PortableBuilderSerializationAware) {
-            ((PortableBuilderSerializationAware)val).writeTo(writer, this);
-
-            return;
-        }
-
-        if (val instanceof PortableObjectEx) {
-            if (portableObjToWrapper == null)
-                portableObjToWrapper = new IdentityHashMap<>();
-
-            PortableBuilderImpl wrapper = portableObjToWrapper.get(val);
-
-            if (wrapper == null) {
-                wrapper = PortableBuilderImpl.wrap((PortableObject)val);
-
-                portableObjToWrapper.put((PortableObject)val, wrapper);
-            }
-
-            val = wrapper;
-        }
-
-        if (val instanceof PortableBuilderImpl) {
-            PortableBuilderImpl obj = (PortableBuilderImpl)val;
-
-            Integer posInResArr = objToPos.get(obj);
-
-            if (posInResArr == null) {
-                objToPos.put(obj, writer.outputStream().position());
-
-                obj.serializeTo(writer.newWriter(obj.typeId()), this);
-            }
-            else {
-                int handle = writer.outputStream().position() - posInResArr;
-
-                writer.writeByte(GridPortableMarshaller.HANDLE);
-                writer.writeInt(handle);
-            }
-
-            return;
-        }
-
-        if (val.getClass().isEnum()) {
-            writer.writeByte(GridPortableMarshaller.ENUM);
-            writer.writeInt(writer.context().typeId(val.getClass().getName()));
-            writer.writeInt(((Enum)val).ordinal());
-
-            return;
-        }
-
-        if (val instanceof Collection) {
-            Collection<?> c = (Collection<?>)val;
-
-            writer.writeByte(GridPortableMarshaller.COL);
-            writer.writeInt(c.size());
-
-            byte colType;
-
-            if (c instanceof GridConcurrentSkipListSet)
-                colType = GridPortableMarshaller.CONC_SKIP_LIST_SET;
-            else
-                colType = writer.context().collectionType(c.getClass());
-
-
-            writer.writeByte(colType);
-
-            for (Object obj : c)
-                writeValue(writer, obj);
-
-            return;
-        }
-
-        if (val instanceof Map) {
-            Map<?, ?> map = (Map<?, ?>)val;
-
-            writer.writeByte(GridPortableMarshaller.MAP);
-            writer.writeInt(map.size());
-
-            writer.writeByte(writer.context().mapType(map.getClass()));
-
-            for (Map.Entry<?, ?> entry : map.entrySet()) {
-                writeValue(writer, entry.getKey());
-                writeValue(writer, entry.getValue());
-            }
-
-            return;
-        }
-
-        Byte flag = PortableUtils.PLAIN_CLASS_TO_FLAG.get(val.getClass());
-
-        if (flag != null) {
-            PortableUtils.writePlainObject(writer, val);
-
-            return;
-        }
-
-        if (val instanceof Object[]) {
-            int compTypeId = writer.context().typeId(((Object[])val).getClass().getComponentType().getName());
-
-            if (val instanceof PortableBuilderEnum[]) {
-                writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, compTypeId);
-
-                return;
-            }
-
-            if (((Object[])val).getClass().getComponentType().isEnum()) {
-                Enum[] enumArr = (Enum[])val;
-
-                writer.writeByte(GridPortableMarshaller.ENUM_ARR);
-                writer.writeInt(compTypeId);
-                writer.writeInt(enumArr.length);
-
-                for (Enum anEnum : enumArr)
-                    writeValue(writer, anEnum);
-
-                return;
-            }
-
-            writeArray(writer, GridPortableMarshaller.OBJ_ARR, (Object[])val, compTypeId);
-
-            return;
-        }
-
-        writer.doWriteObject(val, false);
-    }
-
-    /**
-     * @param writer Writer.
-     * @param elementType Element type.
-     * @param arr The array.
-     * @param compTypeId Component type ID.
-     */
-    public void writeArray(PortableWriterExImpl writer, byte elementType, Object[] arr, int compTypeId) {
-        writer.writeByte(elementType);
-        writer.writeInt(compTypeId);
-        writer.writeInt(arr.length);
-
-        for (Object obj : arr)
-            writeValue(writer, obj);
-    }
-
-    /**
-     * @param writer Writer.
-     * @param elementType Element type.
-     * @param arr The array.
-     * @param clsName Component class name.
-     */
-    public void writeArray(PortableWriterExImpl writer, byte elementType, Object[] arr, String clsName) {
-        writer.writeByte(elementType);
-        writer.writeInt(GridPortableMarshaller.UNREGISTERED_TYPE_ID);
-        writer.writeString(clsName);
-        writer.writeInt(arr.length);
-
-        for (Object obj : arr)
-            writeValue(writer, obj);
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index 7e4266c..24ad5ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -48,7 +48,7 @@ import static java.lang.reflect.Modifier.isTransient;
 /**
  * Portable class descriptor.
  */
-class PortableClassDescriptor {
+public class PortableClassDescriptor {
     /** */
     private final PortableContext ctx;
 
@@ -123,7 +123,7 @@ class PortableClassDescriptor {
         boolean keepDeserialized
     ) throws PortableException {
         this(ctx, cls, userType, typeId, typeName, idMapper, serializer, useTs, metaDataEnabled, keepDeserialized,
-             true);
+            true);
     }
 
     /**
@@ -285,7 +285,7 @@ class PortableClassDescriptor {
     /**
      * @return Type ID.
      */
-    int typeId() {
+    public int typeId() {
         return typeId;
     }
 
@@ -399,7 +399,7 @@ class PortableClassDescriptor {
                 break;
 
             case DECIMAL:
-                writer.doWriteDecimal((BigDecimal) obj);
+                writer.doWriteDecimal((BigDecimal)obj);
 
                 break;
 
@@ -656,39 +656,32 @@ class PortableClassDescriptor {
      * @return Whether further write is needed.
      */
     private boolean writeHeader(Object obj, PortableWriterExImpl writer) {
-        int handle = writer.handle(obj);
-
-        if (handle >= 0) {
-            writer.doWriteByte(GridPortableMarshaller.HANDLE);
-            writer.doWriteInt(handle);
-
+        if (writer.tryWriteAsHandle(obj))
             return false;
-        }
-        else {
-            int pos = writer.position();
 
-            writer.doWriteByte(GridPortableMarshaller.OBJ);
-            writer.doWriteBoolean(userType);
-            writer.doWriteInt(registered ? typeId : GridPortableMarshaller.UNREGISTERED_TYPE_ID);
-            writer.doWriteInt(obj instanceof CacheObjectImpl ? 0 : obj.hashCode());
+        int pos = writer.position();
 
-            // For length and raw offset.
-            int reserved = writer.reserve(8);
+        writer.doWriteByte(GridPortableMarshaller.OBJ);
+        writer.doWriteBoolean(userType);
+        writer.doWriteInt(registered ? typeId : GridPortableMarshaller.UNREGISTERED_TYPE_ID);
+        writer.doWriteInt(obj instanceof CacheObjectImpl ? 0 : obj.hashCode());
 
-            // Class name in case if typeId registration is failed.
-            if (!registered)
-                writer.doWriteString(cls.getName());
+        // For length and raw offset.
+        int reserved = writer.reserve(8);
 
-            int current = writer.position();
-            int len = current - pos;
+        // Class name in case if typeId registration is failed.
+        if (!registered)
+            writer.doWriteString(cls.getName());
 
-            // Default raw offset (equal to header length).
-            writer.position(reserved + 4);
-            writer.doWriteInt(len);
-            writer.position(current);
+        int current = writer.position();
+        int len = current - pos;
 
-            return true;
-        }
+        // Default raw offset (equal to header length).
+        writer.position(reserved + 4);
+        writer.doWriteInt(len);
+        writer.position(current);
+
+        return true;
     }
 
     /**
@@ -787,7 +780,7 @@ class PortableClassDescriptor {
         else if (cls == PortableObjectImpl.class)
             return Mode.PORTABLE_OBJ;
         else if (PortableMarshalAware.class.isAssignableFrom(cls))
-           return Mode.PORTABLE;
+            return Mode.PORTABLE;
         else if (Externalizable.class.isAssignableFrom(cls))
             return Mode.EXTERNALIZABLE;
         else if (Map.Entry.class.isAssignableFrom(cls))
@@ -1352,4 +1345,4 @@ class PortableClassDescriptor {
             return typeName;
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 15b6433..db7e41e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -794,10 +794,10 @@ public class PortableContext implements Externalizable {
      * @param typeId Type ID.
      * @return Whether meta data is enabled.
      */
-    boolean isMetaDataEnabled(int typeId) {
+    public boolean isMetaDataEnabled(int typeId) {
         Boolean enabled = metaEnabled.get(typeId);
 
-        return enabled != null ? enabled : true;
+        return enabled != null ? enabled : metaDataEnabled;
     }
 
     /**
@@ -827,7 +827,7 @@ public class PortableContext implements Externalizable {
      * @param fields Fields map.
      * @throws PortableException In case of error.
      */
-    void updateMetaData(int typeId, String typeName, Map<String, String> fields) throws PortableException {
+    public void updateMetaData(int typeId, String typeName, Map<String, String> fields) throws PortableException {
         updateMetaData(typeId, new PortableMetaDataImpl(typeName, fields, null));
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableEnumArrayLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableEnumArrayLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableEnumArrayLazyValue.java
deleted file mode 100644
index c953bb3..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableEnumArrayLazyValue.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableInvalidClassException;
-
-/**
- *
- */
-class PortableEnumArrayLazyValue extends PortableAbstractLazyValue {
-    /** */
-    private final int len;
-
-    /** */
-    private final int compTypeId;
-
-    /** */
-    private final String clsName;
-
-    /**
-     * @param reader Reader.
-     */
-    protected PortableEnumArrayLazyValue(PortableBuilderReader reader) {
-        super(reader, reader.position() - 1);
-
-        int typeId = reader.readInt();
-
-        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
-            clsName = reader.readString();
-
-            Class cls;
-
-            try {
-                // TODO: IGNITE-1272 - Is class loader needed here?
-                cls = U.forName(reader.readString(), null);
-            }
-            catch (ClassNotFoundException e) {
-                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
-            }
-
-            compTypeId = reader.portableContext().descriptorForClass(cls).typeId();
-        }
-        else {
-            compTypeId = typeId;
-            clsName = null;
-        }
-
-        int size = reader.readInt();
-
-        for (int i = 0; i < size; i++)
-            reader.skipValue();
-
-        len = reader.position() - valOff;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Object init() {
-        reader.position(valOff + 1);
-
-        //skipping component type id
-        reader.readInt();
-
-        int size = reader.readInt();
-
-        PortableBuilderEnum[] res = new PortableBuilderEnum[size];
-
-        for (int i = 0; i < size; i++) {
-            byte flag = reader.readByte();
-
-            if (flag == GridPortableMarshaller.NULL)
-                continue;
-
-            if (flag != GridPortableMarshaller.ENUM)
-                throw new PortableException("Invalid flag value: " + flag);
-
-            res[i] = new PortableBuilderEnum(reader);
-        }
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (val != null) {
-            if (clsName != null)
-                ctx.writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, clsName);
-            else
-                ctx.writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, compTypeId);
-
-            return;
-        }
-
-        writer.write(reader.array(), valOff, len);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyArrayList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyArrayList.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyArrayList.java
deleted file mode 100644
index 84a0c22..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyArrayList.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- *
- */
-class PortableLazyArrayList extends AbstractList<Object> implements PortableBuilderSerializationAware {
-    /** */
-    private final PortableBuilderReader reader;
-
-    /** */
-    private final int off;
-
-    /** */
-    private List<Object> delegate;
-
-    /**
-     * @param reader Reader.
-     * @param size Size,
-     */
-    PortableLazyArrayList(PortableBuilderReader reader, int size) {
-        this.reader = reader;
-        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
-
-        assert size >= 0;
-
-        for (int i = 0; i < size; i++)
-            reader.skipValue();
-    }
-
-    /**
-     *
-     */
-    private void ensureDelegateInit() {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
-
-            delegate = new ArrayList<>(size);
-
-            for (int i = 0; i < size; i++)
-                delegate.add(reader.parseValue());
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object get(int idx) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.get(idx));
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean add(Object o) {
-        ensureDelegateInit();
-
-        return delegate.add(o);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void add(int idx, Object element) {
-        ensureDelegateInit();
-
-        delegate.add(idx, element);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object set(int idx, Object element) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.set(idx, element));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object remove(int idx) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.remove(idx));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() {
-        if (delegate == null)
-            delegate = new ArrayList<>();
-        else
-            delegate.clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean addAll(int idx, Collection<?> c) {
-        return delegate.addAll(idx, c);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void removeRange(int fromIdx, int toIdx) {
-        ensureDelegateInit();
-
-        delegate.subList(fromIdx, toIdx).clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        if (delegate == null)
-            return reader.readIntAbsolute(off + 1);
-
-        return delegate.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
-
-            writer.write(reader.array(), off, hdrSize);
-
-            reader.position(off + hdrSize);
-
-            for (int i = 0; i < size; i++) {
-                Object o = reader.parseValue();
-
-                ctx.writeValue(writer, o);
-            }
-        }
-        else {
-            writer.writeByte(GridPortableMarshaller.COL);
-            writer.writeInt(delegate.size());
-
-            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
-            writer.writeByte(colType);
-
-            for (Object o : delegate)
-                ctx.writeValue(writer, o);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyLinkedList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyLinkedList.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyLinkedList.java
deleted file mode 100644
index 7b2e15a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyLinkedList.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.AbstractList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- *
- */
-class PortableLazyLinkedList extends AbstractList<Object> implements PortableBuilderSerializationAware {
-    /** */
-    private final PortableBuilderReader reader;
-
-    /** */
-    private final int off;
-
-    /** */
-    private List<Object> delegate;
-
-    /**
-     * @param reader Reader.
-     * @param size Size,
-     */
-    PortableLazyLinkedList(PortableBuilderReader reader, int size) {
-        this.reader = reader;
-        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
-
-        assert size >= 0;
-
-        for (int i = 0; i < size; i++)
-            reader.skipValue();
-    }
-
-    /**
-     *
-     */
-    private void ensureDelegateInit() {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
-
-            delegate = new LinkedList<>();
-
-            for (int i = 0; i < size; i++)
-                delegate.add(reader.parseValue());
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object get(int idx) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.get(idx));
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean add(Object o) {
-        ensureDelegateInit();
-
-        return delegate.add(o);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void add(int idx, Object element) {
-        ensureDelegateInit();
-
-        delegate.add(idx, element);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object set(int idx, Object element) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.set(idx, element));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object remove(int idx) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.remove(idx));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() {
-        if (delegate == null)
-            delegate = new LinkedList<>();
-        else
-            delegate.clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean addAll(int idx, Collection<?> c) {
-        ensureDelegateInit();
-
-        return delegate.addAll(idx, c);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void removeRange(int fromIdx, int toIdx) {
-        ensureDelegateInit();
-
-        delegate.subList(fromIdx, toIdx).clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        if (delegate == null)
-            return reader.readIntAbsolute(off + 1);
-
-        return delegate.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public ListIterator<Object> listIterator(final int idx) {
-        ensureDelegateInit();
-
-        return new ListIterator<Object>() {
-            /** */
-            private final ListIterator<Object> delegate = PortableLazyLinkedList.super.listIterator(idx);
-
-            @Override public boolean hasNext() {
-                return delegate.hasNext();
-            }
-
-            @Override public Object next() {
-                return PortableUtils.unwrapLazy(delegate.next());
-            }
-
-            @Override public boolean hasPrevious() {
-                return delegate.hasPrevious();
-            }
-
-            @Override public Object previous() {
-                return PortableUtils.unwrapLazy(delegate.previous());
-            }
-
-            @Override public int nextIndex() {
-                return delegate.nextIndex();
-            }
-
-            @Override public int previousIndex() {
-                return delegate.previousIndex();
-            }
-
-            @Override public void remove() {
-                delegate.remove();
-            }
-
-            @Override public void set(Object o) {
-                delegate.set(o);
-            }
-
-            @Override public void add(Object o) {
-                delegate.add(o);
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterator<Object> iterator() {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazyIterator(super.iterator());
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
-            writer.write(reader.array(), off, hdrSize);
-
-            reader.position(off + hdrSize);
-
-            for (int i = 0; i < size; i++) {
-                Object o = reader.parseValue();
-
-                ctx.writeValue(writer, o);
-            }
-        }
-        else {
-            writer.writeByte(GridPortableMarshaller.COL);
-            writer.writeInt(delegate.size());
-
-            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
-            writer.writeByte(colType);
-
-            for (Object o : delegate)
-                ctx.writeValue(writer, o);
-        }
-    }
-}
\ No newline at end of file


[43/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop.h b/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop.h
new file mode 100644
index 0000000..da4fdb9
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop.h
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_INTEROP
+#define _IGNITE_IMPL_INTEROP
+
+#include "ignite/impl/interop/interop_memory.h"
+#include "ignite/impl/interop/interop_output_stream.h"
+#include "ignite/impl/interop/interop_input_stream.h"
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_input_stream.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_input_stream.h b/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_input_stream.h
new file mode 100644
index 0000000..d8fcfc3
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_input_stream.h
@@ -0,0 +1,234 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_INTEROP_INPUT_STREAM
+#define _IGNITE_IMPL_INTEROP_INPUT_STREAM
+
+#include "ignite/impl/interop/interop_memory.h"
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace interop
+        {
+            /**
+             * Interop input stream implementation.
+             */
+            class IGNITE_IMPORT_EXPORT InteropInputStream {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param mem Memory.
+                 */
+                InteropInputStream(InteropMemory* mem);
+
+                /**
+                 * Read signed 8-byte int.
+                 *
+                 * @return Value.
+                 */
+                int8_t ReadInt8();
+                    
+                /**
+                 * Read signed 8-byte int array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.                 
+                 */
+                void ReadInt8Array(int8_t* const res, const int32_t len);
+
+                /**
+                 * Read bool.
+                 *
+                 * @return Value.
+                 */
+                bool ReadBool();
+
+                /**
+                 * Read bool array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadBoolArray(bool* const res, const int32_t len);
+
+                /**
+                 * Read signed 16-byte int.
+                 *
+                 * @return Value.
+                 */
+                int16_t ReadInt16();
+
+                /**
+                 * Read signed 16-byte int array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadInt16Array(int16_t* const res, const int32_t len);
+
+                /**
+                 * Read unsigned 16-byte int.
+                 *
+                 * @return Value.
+                 */
+                uint16_t ReadUInt16();
+
+                /**
+                 * Read unsigned 16-byte int array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadUInt16Array(uint16_t* const res, const int32_t len);
+
+                /**
+                 * Read signed 32-byte int.
+                 *
+                 * @return Value.
+                 */
+                int32_t ReadInt32();
+
+                /**
+                 * Read signed 32-byte int at the given position.
+                 *
+                 * @param pos Position.
+                 * @return Value.
+                 */
+                int32_t ReadInt32(int32_t pos);
+                    
+                /**
+                 * Read signed 32-byte int array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadInt32Array(int32_t* const res, const int32_t len);
+
+                /**
+                 * Read signed 64-byte int.
+                 *
+                 * @return Value.
+                 */
+                int64_t ReadInt64();
+
+                /**
+                 * Read signed 64-byte int array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadInt64Array(int64_t* const res, const int32_t len);
+
+                /**
+                 * Read float.
+                 *
+                 * @return Value.
+                 */
+                float ReadFloat();
+
+                /**
+                 * Read float array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadFloatArray(float* const res, const int32_t len);
+
+                /**
+                 * Read double.
+                 *
+                 * @return Value.
+                 */
+                double ReadDouble();
+
+                /**
+                 * Read double array.
+                 *
+                 * @param res Allocated array.
+                 * @param len Length.
+                 */
+                void ReadDoubleArray(double* const res, const int32_t len);
+
+                /**
+                 * Get remaining bytes.
+                 *
+                 * @return Remaining bytes.
+                 */
+                int32_t Remaining();
+
+                /**
+                 * Get position.
+                 *
+                 * @return Position.
+                 */
+                int32_t Position();
+
+                /**
+                 * Set position.
+                 *
+                 * @param Position.
+                 */
+                void Position(int32_t pos);
+
+                /**
+                 * Synchronize data from underlying memory.
+                 */
+                void Synchronize();
+            private:
+                /** Memory. */
+                InteropMemory* mem; 
+                
+                /** Pointer to data. */
+                int8_t* data;       
+                
+                /** Length. */
+                int len;            
+                
+                /** Current position. */
+                int pos;            
+                    
+                /**
+                 * Ensure there is enough data in the stream.
+                 *
+                 * @param cnt Amount of byte expected to be available.
+                 */
+                void EnsureEnoughData(int32_t cnt);
+
+                /**
+                 * Copy data from the stream shifting it along the way.
+                 *
+                 * @param ptr Pointer to data.
+                 * @param off Offset.
+                 * @param cnt Amount of data to copy.
+                 */
+                void CopyAndShift(int8_t* dest, int32_t off, int32_t cnt);
+
+                /**
+                 * Shift stream to the right.
+                 *
+                 * @param cnt Amount of bytes to shift the stream to.
+                 */
+                void Shift(int32_t cnt);
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_memory.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_memory.h b/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_memory.h
new file mode 100644
index 0000000..00cba43
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_memory.h
@@ -0,0 +1,280 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_INTEROP_MEMORY
+#define _IGNITE_IMPL_INTEROP_MEMORY
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+namespace ignite 
+{
+    namespace impl 
+    {
+        namespace interop 
+        {
+            /** Memory header length. */
+            const int IGNITE_MEM_HDR_LEN = 20;
+
+            /** Memory header offset: capacity. */
+            const int IGNITE_MEM_HDR_OFF_CAP = 8;
+
+            /** Memory header offset: length. */
+            const int IGNITE_MEM_HDR_OFF_LEN = 12;
+
+            /** Memory header offset: flags. */
+            const int IGNITE_MEM_HDR_OFF_FLAGS = 16;
+
+            /** Flag: external. */
+            const int IGNITE_MEM_FLAG_EXT = 0x1;
+
+            /** Flag: pooled. */
+            const int IGNITE_MEM_FLAG_POOLED = 0x2;
+
+            /** Flag: acquired. */
+            const int IGNITE_MEM_FLAG_ACQUIRED = 0x4;
+                
+            /**
+             * Interop memory.
+             */
+            class IGNITE_IMPORT_EXPORT InteropMemory
+            {
+            public:
+                /**
+                 * Get raw data pointer.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Raw data pointer.
+                 */
+                static int8_t* Data(int8_t* memPtr);
+
+                /**
+                 * Set raw data pointer.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @param ptr Raw data pointer.
+                 */
+                static void Data(int8_t* memPtr, void* ptr);
+
+                /**
+                 * Get capacity.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Capacity.
+                 */
+                static int32_t Capacity(int8_t* memPtr);
+
+                /**
+                 * Set capacity.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @param val Value.
+                 */
+                static void Capacity(int8_t* memPtr, int32_t val);
+
+                /**
+                 * Get length.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Length.
+                 */
+                static int32_t Length(int8_t* memPtr);
+
+                /**
+                 * Set length.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @param val Value.
+                 */
+                static void Length(int8_t* memPtr, int32_t val);
+
+                /**
+                 * Get flags.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Flags.
+                 */
+                static int32_t Flags(int8_t* memPtr);
+
+                /**
+                 * Set flags.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @param val Value.
+                 */
+                static void Flags(int8_t* memPtr, int32_t val);
+
+                /**
+                 * Get "external" flag state.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Flag state.
+                 */
+                static bool IsExternal(int8_t* memPtr);
+
+                /**
+                 * Get "external" flag state.
+                 *
+                 * @param flags Flags.
+                 * @return Flag state.
+                 */
+                static bool IsExternal(int32_t flags);
+
+                /**
+                 * Get "pooled" flag state.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Flag state.
+                 */
+                static bool IsPooled(int8_t* memPtr);
+
+                /**
+                 * Get "pooled" flag state.
+                 *
+                 * @param flags Flags.
+                 * @return Flag state.
+                 */
+                static bool IsPooled(int32_t flags);
+
+                /**
+                 * Get "acquired" flag state.
+                 *
+                 * @param memPtr Memory pointer.
+                 * @return Flag state.
+                 */
+                static bool IsAcquired(int8_t* memPtr);
+
+                /**
+                 * Get "acquired" flag state.
+                 *
+                 * @param flags Flags.
+                 * @return Flag state.
+                 */
+                static bool IsAcquired(int32_t flags);
+
+                /**
+                 * Destructor.
+                 */
+                virtual ~InteropMemory() { }
+                    
+                /**
+                 * Get cross-platform memory pointer.
+                 *
+                 * @return Memory pointer.
+                 */
+                int8_t* Pointer();
+
+                /**
+                 * Get cross-platform pointer in long form.
+                 */
+                int64_t PointerLong();
+
+                /**
+                 * Get raw data pointer.
+                 *
+                 * @return Data pointer.
+                 */
+                int8_t* Data();
+
+                /**
+                 * Get capacity.
+                 *
+                 * @return Capacity.
+                 */
+                int32_t Capacity();
+
+                /**
+                 * Get length.
+                 *
+                 * @return Length.
+                 */
+                int32_t Length();
+
+                /**
+                 * Set length.
+                 *
+                 * @param val Length.
+                 */
+                void Length(int32_t val);
+
+                /**
+                 * Reallocate memory.
+                 *
+                 * @param cap Desired capactiy.
+                 */
+                virtual void Reallocate(int32_t cap) = 0;
+            protected:
+                /** Memory pointer. */
+                int8_t* memPtr; 
+            };
+
+            /**
+             * Interop unpooled memory.
+             */
+            class IGNITE_IMPORT_EXPORT InteropUnpooledMemory : public InteropMemory
+            {
+            public:
+                /**
+                 * Constructor create new unpooled memory object from scratch.
+                 *
+                 * @param cap Capacity.
+                 */
+                explicit InteropUnpooledMemory(int32_t cap);
+
+                /**
+                 * Constructor creating unpooled memory object from existing memory pointer.
+                 *
+                 * @param memPtr Memory pointer.
+                 */
+                explicit InteropUnpooledMemory(int8_t* memPtr);
+
+                /**
+                 * Destructor.
+                 */
+                ~InteropUnpooledMemory();
+
+                virtual void Reallocate(int32_t cap);
+            private:
+                /** Whether this instance is owner of memory chunk. */
+                bool owning; 
+
+                IGNITE_NO_COPY_ASSIGNMENT(InteropUnpooledMemory)
+            };
+
+            /**
+             * Interop external memory.
+             */
+            class IGNITE_IMPORT_EXPORT InteropExternalMemory : public InteropMemory
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param memPtr External memory pointer.
+                 */
+                explicit InteropExternalMemory(int8_t* memPtr);
+
+                virtual void Reallocate(int32_t cap);
+            private:
+                IGNITE_NO_COPY_ASSIGNMENT(InteropExternalMemory)
+            };
+        }
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_output_stream.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_output_stream.h b/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_output_stream.h
new file mode 100644
index 0000000..5a08aed
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/interop/interop_output_stream.h
@@ -0,0 +1,234 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_INTEROP_OUTPUT_STREAM
+#define _IGNITE_IMPL_INTEROP_OUTPUT_STREAM
+
+#include "ignite/impl/interop/interop_memory.h"
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace interop
+        {
+            /**
+             * Interop output stream.
+             */
+            class IGNITE_IMPORT_EXPORT InteropOutputStream {
+            public:
+                /**
+                 * Create new output stream with the given capacity.
+                 *
+                 * @param mem Memory.
+                 */
+                InteropOutputStream(InteropMemory* mem);
+
+                /**
+                 * Write signed 8-byte integer.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt8(const int8_t val);
+
+                /**
+                 * Write signed 8-byte integer at the given position.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt8(const int8_t val, const int32_t pos);
+
+                /**
+                 * Write signed 8-byte integer array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteInt8Array(const int8_t* val, const int32_t len);
+
+                /**
+                 * Write bool.
+                 *
+                 * @param val Value.
+                 */
+                void WriteBool(const bool val);
+
+                /**
+                 * Write bool array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteBoolArray(const bool* val, const int32_t len);
+
+                /**
+                 * Write signed 16-byte integer.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt16(const int16_t val);
+
+                /**
+                 * Write signed 16-byte integer array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteInt16Array(const int16_t* val, const int32_t len);
+
+                /**
+                 * Write unsigned 16-byte integer.
+                 *
+                 * @param val Value.
+                 */
+                void WriteUInt16(const uint16_t val);
+
+                /**
+                 * Write unsigned 16-byte integer array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteUInt16Array(const uint16_t* val, const int32_t len);
+
+                /**
+                 * Write signed 32-byte integer.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt32(const int32_t val);
+
+                /**
+                 * Write signed 32-byte integer at the given position.
+                 *
+                 * @param pos Position.
+                 * @param val Value.
+                 */
+                void WriteInt32(const int32_t pos, const int32_t val);
+
+                /**
+                 * Write signed 32-byte integer array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteInt32Array(const int32_t* val, const int32_t len);
+
+                /**
+                 * Write signed 64-byte integer.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt64(const int64_t val);
+
+                /**
+                 * Write signed 64-byte integer array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteInt64Array(const int64_t* val, const int32_t len);
+
+                /**
+                 * Write float.
+                 *
+                 * @param val Value.
+                 */
+                void WriteFloat(const float val);
+
+                /**
+                 * Write float array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteFloatArray(const float* val, const int32_t len);
+
+                /**
+                 * Write double.
+                 *
+                 * @param val Value.
+                 */
+                void WriteDouble(const double val);
+
+                /**
+                 * Write double array.
+                 *
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteDoubleArray(const double* val, const int32_t len);
+
+                /**
+                 * Get current stream position.
+                 */
+                int32_t Position();
+
+                /**
+                 * Set current stream position (absolute).
+                 *
+                 * @param val Position (absolute).
+                 */
+                void Position(const int32_t val);
+
+                /**
+                 * Synchronize data with underlying memory.
+                 */
+                void Synchronize();
+            private:
+                /** Memory. */
+                InteropMemory* mem; 
+
+                /** Pointer to data. */
+                int8_t* data;       
+
+                /** Capacity. */
+                int cap;            
+
+                /** Current position. */
+                int pos;            
+
+                IGNITE_NO_COPY_ASSIGNMENT(InteropOutputStream)
+
+                /**
+                 * Ensure that stream enough capacity optionally extending it.
+                 *
+                 * @param reqCap Requsted capacity.
+                 */
+                void EnsureCapacity(int32_t reqCap);
+
+                /**
+                 * Shift stream to the right.
+                 *
+                 * @param cnt Amount of bytes to shift the stream to.
+                 */
+                void Shift(int32_t cnt);
+
+                /**
+                 * Copy data to the stream shifting it along the way.
+                 *
+                 * @param ptr Pointer to data.
+                 * @param off Offset.
+                 * @param len Length.
+                 */
+                void CopyAndShift(const int8_t* src, int32_t off, int32_t len);
+            };
+        }
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/operations.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/operations.h b/modules/platform/src/main/cpp/core/include/ignite/impl/operations.h
new file mode 100644
index 0000000..8f32922
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/operations.h
@@ -0,0 +1,452 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_OPERATION
+#define _IGNITE_IMPL_OPERATION
+
+#include <map>
+#include <set>
+#include <vector>
+
+#include <ignite/common/common.h>
+
+#include "ignite/cache/cache_entry.h"
+#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/impl/portable/portable_writer_impl.h"
+#include "ignite/portable/portable.h"
+
+namespace ignite
+{
+    namespace impl
+    {
+        /**
+         * Input operation.
+         */
+        class InputOperation
+        {
+        public:
+            /**
+             * Destructor.
+             */
+            virtual ~InputOperation()
+            {
+                // No-op.
+            }
+
+            /**
+             * Process input.
+             *
+             * @param writer Writer.
+             */
+            virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer) = 0;
+        };
+
+        /**
+         * Input operation accepting a single argument.
+         */
+        template<typename T>
+        class In1Operation : public InputOperation
+        {
+        public:
+            /**
+             * Constructor.
+             * 
+             * @param val Value.
+             */
+            In1Operation(const T* val) : val(val)
+            {
+                // No-op.
+            }
+
+            virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+            {
+                writer.WriteTopObject<T>(*val);
+            }
+        private:
+            /** Value. */
+            const T* val; 
+
+            IGNITE_NO_COPY_ASSIGNMENT(In1Operation)
+        };
+
+        /**
+         * Input operation accepting two single objects.
+         */
+        template<typename T1, typename T2>
+        class In2Operation : public InputOperation
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param val1 First value.
+             * @param val2 Second value.
+             */
+            In2Operation(const T1* val1, const T2* val2) : val1(val1), val2(val2)
+            {
+                // No-op.
+            }
+
+            virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+            {
+                writer.WriteTopObject<T1>(*val1);
+                writer.WriteTopObject<T2>(*val2);
+            }
+        private:
+            /** First value. */
+            const T1* val1; 
+
+            /** Second value. */
+            const T2* val2; 
+
+            IGNITE_NO_COPY_ASSIGNMENT(In2Operation)
+        };
+
+        /**
+         * Input operation accepting three single objects.
+         */
+        template<typename T1, typename T2, typename T3>
+        class In3Operation : public InputOperation
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param val1 First value.
+             * @param val2 Second value.
+             * @param val3 Third value.
+             */
+            In3Operation(const T1* val1, const T2* val2, const T3* val3) : val1(val1), val2(val2), val3(val3)
+            {
+                // No-op.
+            }
+
+            virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+            {
+                writer.WriteTopObject<T1>(*val1);
+                writer.WriteTopObject<T2>(*val2);
+                writer.WriteTopObject<T3>(*val3);
+            }
+        private:
+            /** First value. */
+            const T1* val1;
+
+            /** Second value. */
+            const T2* val2;
+
+            /** Third value. */
+            const T3* val3;
+
+            IGNITE_NO_COPY_ASSIGNMENT(In3Operation)
+        };
+
+        /*
+         * Input set operation.
+         */
+        template<typename T>
+        class InSetOperation : public InputOperation
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param val Value.
+             */
+            InSetOperation(const std::set<T>* val) : val(val)
+            {
+                // No-op.
+            }
+
+            virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+            {
+                writer.GetStream()->WriteInt32(static_cast<int32_t>(val->size()));
+
+                for (typename std::set<T>::const_iterator it = val->begin(); it != val->end(); ++it)
+                    writer.WriteTopObject<T>(*it);
+            }
+        private:
+            /** Value. */
+            const std::set<T>* val; 
+
+            IGNITE_NO_COPY_ASSIGNMENT(InSetOperation)
+        };
+
+        /**
+         * Input map operation.
+         */
+        template<typename K, typename V>
+        class InMapOperation : public InputOperation
+        {
+        public:
+            /*
+             * Constructor.
+             *
+             * @param val Value.
+             */
+            InMapOperation(const std::map<K, V>* val) : val(val)
+            {
+                // No-op.
+            }
+
+            virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+            {
+                writer.GetStream()->WriteInt32(static_cast<int32_t>(val->size()));
+
+                for (typename std::map<K, V>::const_iterator it = val->begin(); it != val->end(); ++it) {
+                    writer.WriteTopObject<K>(it->first);
+                    writer.WriteTopObject<V>(it->second);
+                }
+            }
+        private:
+            /** Value. */
+            const std::map<K, V>* val; 
+
+            IGNITE_NO_COPY_ASSIGNMENT(InMapOperation)
+        };
+
+        /**
+         * Cache LocalPeek input operation.
+         */
+        template<typename T>
+        class InCacheLocalPeekOperation : public InputOperation
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param key Key.
+             * @param peekModes Peek modes.
+             */
+            InCacheLocalPeekOperation(const T* key, int32_t peekModes) : key(key), peekModes(peekModes)
+            {
+                // No-op.
+            }
+
+            virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+            {
+                writer.WriteTopObject<T>(*key);
+                writer.GetStream()->WriteInt32(peekModes);
+            }
+        private:
+            /** Key. */
+            const T* key;   
+
+            /** Peek modes. */
+            int32_t peekModes; 
+
+            IGNITE_NO_COPY_ASSIGNMENT(InCacheLocalPeekOperation)
+        };
+
+        /**
+         * Output operation.
+         */
+        class OutputOperation
+        {
+        public:
+            /**
+             * Destructor.
+             */
+            virtual ~OutputOperation()
+            {
+                // No-op.
+            }
+
+            /**
+             * Process output.
+             *
+             * @param reader Reader.
+             */
+            virtual void ProcessOutput(ignite::impl::portable::PortableReaderImpl& reader) = 0;
+        };
+
+        /**
+         * Output operation returning single object.
+         */
+        template<typename T>
+        class Out1Operation : public OutputOperation
+        {
+        public:
+            /**
+             * Constructor.
+             */
+            Out1Operation()
+            {
+                // No-op.
+            }
+
+            virtual void ProcessOutput(ignite::impl::portable::PortableReaderImpl& reader)
+            {
+                val = reader.ReadTopObject<T>();
+            }
+
+            /**
+             * Get value.
+             *
+             * @param Value.
+             */
+            T GetResult()
+            {
+                return val;
+            }
+        private:
+            /** Value. */
+            T val; 
+
+            IGNITE_NO_COPY_ASSIGNMENT(Out1Operation)
+        };
+
+        /**
+         * Output operation returning single object.
+         */
+        template<typename T1, typename T2>
+        class Out2Operation : public OutputOperation
+        {
+        public:
+            /**
+             * Constructor.
+             */
+            Out2Operation()
+            {
+                // No-op.
+            }
+
+            virtual void ProcessOutput(ignite::impl::portable::PortableReaderImpl& reader)
+            {
+                val1 = reader.ReadTopObject<T1>();
+                val2 = reader.ReadTopObject<T2>();
+            }
+
+            /**
+             * Get value 1.
+             *
+             * @param Value 1.
+             */
+            T1& Get1()
+            {
+                return val1;
+            }
+
+            /**
+             * Get value 2.
+             *
+             * @param Value 2.
+             */
+            T2& Get2()
+            {
+                return val2;
+            }
+
+        private:
+            /** Value 1. */
+            T1 val1; 
+            
+            /** Value 2. */
+            T2 val2; 
+
+            IGNITE_NO_COPY_ASSIGNMENT(Out2Operation)
+        };
+        
+        /*
+         * Output map operation.
+         */
+        template<typename T1, typename T2>
+        class OutMapOperation :public OutputOperation
+        {
+        public:
+            /**
+             * Constructor.
+             */
+            OutMapOperation()
+            {
+                // No-op.
+            }
+
+            virtual void ProcessOutput(ignite::impl::portable::PortableReaderImpl& reader)
+            {
+                bool exists = reader.GetStream()->ReadBool();
+
+                if (exists)
+                {
+                    int32_t cnt = reader.GetStream()->ReadInt32();
+
+                    std::map<T1, T2> val0;
+
+                    for (int i = 0; i < cnt; i++) {
+                        T1 t1 = reader.ReadTopObject<T1>();
+                        T2 t2 = reader.ReadTopObject<T2>();
+
+                        val0[t1] = t2;
+                    }
+
+                    val = val0;
+                }
+            }
+
+            /**
+             * Get value.
+             *
+             * @param Value.
+             */
+            std::map<T1, T2> GetResult()
+            {
+                return val;
+            }
+        private:
+            /** Value. */
+            std::map<T1, T2> val;
+
+            IGNITE_NO_COPY_ASSIGNMENT(OutMapOperation)
+        };
+
+        /*
+         * Output query GET ALL operation.
+         */
+        template<typename K, typename V>
+        class OutQueryGetAllOperation : public OutputOperation
+        {
+        public:
+            /**
+             * Constructor.
+             */
+            OutQueryGetAllOperation(std::vector<ignite::cache::CacheEntry<K, V>>* res) : res(res)
+            {
+                // No-op.
+            }
+
+            virtual void ProcessOutput(ignite::impl::portable::PortableReaderImpl& reader)
+            {
+                int32_t cnt = reader.ReadInt32();
+
+                for (int i = 0; i < cnt; i++) 
+                {
+                    K key = reader.ReadTopObject<K>();
+                    V val = reader.ReadTopObject<V>();
+
+                    res->push_back(ignite::cache::CacheEntry<K, V>(key, val));
+                }
+            }
+
+        private:
+            /** Entries. */
+            std::vector<ignite::cache::CacheEntry<K, V>>* res;
+            
+            IGNITE_NO_COPY_ASSIGNMENT(OutQueryGetAllOperation)
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_common.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_common.h b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_common.h
new file mode 100644
index 0000000..622cb54
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_common.h
@@ -0,0 +1,146 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_PORTABLE_COMMON
+#define _IGNITE_IMPL_PORTABLE_COMMON
+
+#include <stdint.h>
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            /** Header: null. */
+            const int8_t IGNITE_HDR_NULL = 101;
+
+            /** Header: handle. */
+            const int8_t IGNITE_HDR_HND = 102;
+
+            /** Header: fulle form. */
+            const int8_t IGNITE_HDR_FULL = 103;
+
+            /** Full header length. */
+            const int32_t IGNITE_FULL_HDR_LEN = 18;
+
+            /** Type: object. */
+            const int8_t IGNITE_TYPE_OBJECT = IGNITE_HDR_FULL;
+
+            /** Type: unsigned byte. */
+            const int8_t IGNITE_TYPE_BYTE = 1;
+
+            /** Type: short. */
+            const int8_t IGNITE_TYPE_SHORT = 2;
+
+            /** Type: int. */
+            const int8_t IGNITE_TYPE_INT = 3;
+
+            /** Type: long. */
+            const int8_t IGNITE_TYPE_LONG = 4;
+
+            /** Type: float. */
+            const int8_t IGNITE_TYPE_FLOAT = 5;
+
+            /** Type: double. */
+            const int8_t IGNITE_TYPE_DOUBLE = 6;
+
+            /** Type: char. */
+            const int8_t IGNITE_TYPE_CHAR = 7;
+
+            /** Type: boolean. */
+            const int8_t IGNITE_TYPE_BOOL = 8;
+
+            /** Type: decimal. */
+            const int8_t IGNITE_TYPE_DECIMAL = 30;
+
+            /** Type: string. */
+            const int8_t IGNITE_TYPE_STRING = 9;
+
+            /** Type: UUID. */
+            const int8_t IGNITE_TYPE_UUID = 10;
+
+            /** Type: date. */
+            const int8_t IGNITE_TYPE_DATE = 11;
+
+            /** Type: unsigned byte array. */
+            const int8_t IGNITE_TYPE_ARRAY_BYTE = 12;
+
+            /** Type: short array. */
+            const int8_t IGNITE_TYPE_ARRAY_SHORT = 13;
+
+            /** Type: int array. */
+            const int8_t IGNITE_TYPE_ARRAY_INT = 14;
+
+            /** Type: long array. */
+            const int8_t IGNITE_TYPE_ARRAY_LONG = 15;
+
+            /** Type: float array. */
+            const int8_t IGNITE_TYPE_ARRAY_FLOAT = 16;
+
+            /** Type: double array. */
+            const int8_t IGNITE_TYPE_ARRAY_DOUBLE = 17;
+
+            /** Type: char array. */
+            const int8_t IGNITE_TYPE_ARRAY_CHAR = 18;
+
+            /** Type: boolean array. */
+            const int8_t IGNITE_TYPE_ARRAY_BOOL = 19;
+
+            /** Type: decimal array. */
+            const int8_t IGNITE_TYPE_ARRAY_DECIMAL = 31;
+
+            /** Type: string array. */
+            const int8_t IGNITE_TYPE_ARRAY_STRING = 20;
+
+            /** Type: UUID array. */
+            const int8_t IGNITE_TYPE_ARRAY_UUID = 21;
+
+            /** Type: date array. */
+            const int8_t IGNITE_TYPE_ARRAY_DATE = 22;
+
+            /** Type: object array. */
+            const int8_t IGNITE_TYPE_ARRAY = 23;
+
+            /** Type: collection. */
+            const int8_t IGNITE_TYPE_COLLECTION = 24;
+
+            /** Type: map. */
+            const int8_t IGNITE_TYPE_MAP = 25;
+
+            /** Type: map entry. */
+            const int8_t IGNITE_TYPE_MAP_ENTRY = 26;
+
+            /** Type: portable object. */
+            const int8_t IGNITE_TYPE_PORTABLE = 27;
+
+            /** Read/write single object. */
+            const int32_t IGNITE_PORTABLE_MODE_SINGLE = 0;
+
+            /** Read/write array. */
+            const int32_t IGNITE_PORTABLE_MODE_ARRAY = 1;
+
+            /** Read/write collection. */
+            const int32_t IGNITE_PORTABLE_MODE_COL = 2;
+
+            /** Read/write map. */
+            const int32_t IGNITE_PORTABLE_MODE_MAP = 3;
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_id_resolver.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_id_resolver.h b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_id_resolver.h
new file mode 100644
index 0000000..d8f7883
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_id_resolver.h
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_PORTABLE_ID_RESOLVER
+#define _IGNITE_IMPL_PORTABLE_ID_RESOLVER
+
+#include "ignite/portable/portable_type.h"
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace portable
+        {
+            /**
+             * Portable type id resolver.
+             */
+            class PortableIdResolver
+            {
+            public:
+                /**
+                 * Destructor.
+                 */
+                virtual ~PortableIdResolver()
+                {
+                    // No-op.
+                }
+
+                /**
+                 * Get portable object type ID.
+                 *
+                 * @return Type ID.
+                 */
+                virtual int32_t GetTypeId() = 0;
+
+                /**
+                 * Get portable object field ID.
+                 *
+                 * @param typeId Type ID.
+                 * @param name Field name.
+                 * @return Field ID.
+                 */
+                virtual int32_t GetFieldId(const int32_t typeId, const char* name) = 0;
+            };
+
+            /**
+             * Templated portable type descriptor.
+             */
+            template<typename T>
+            class TemplatedPortableIdResolver : public PortableIdResolver
+            {
+            public:
+                /**
+                 * Constructor.
+                 */
+                TemplatedPortableIdResolver()
+                {
+                    type = ignite::portable::PortableType<T>();
+                }
+
+                /**
+                 * Constructor.
+                 *
+                 * @param type Portable type.
+                 */
+                TemplatedPortableIdResolver(ignite::portable::PortableType<T> type) : type(type)
+                {
+                    // No-op.
+                }
+
+                virtual int32_t GetTypeId()
+                {
+                    return type.GetTypeId();
+                }
+
+                virtual int32_t GetFieldId(const int32_t typeId, const char* name) {
+                    if (!name)
+                    {
+                        IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Field name cannot be NULL.");
+                    }
+
+                    return type.GetFieldId(name);
+                }
+            private:
+                /** Actual type.  */
+                ignite::portable::PortableType<T> type; 
+            };
+        }
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_handler.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_handler.h b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_handler.h
new file mode 100644
index 0000000..a557129
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_handler.h
@@ -0,0 +1,102 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_PORTABLE_METADATA_HANDLER
+#define _IGNITE_IMPL_PORTABLE_METADATA_HANDLER
+
+#include <ignite/common/concurrent.h>
+
+#include "ignite/impl/portable/portable_metadata_snapshot.h"
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            /**
+             * Metadata handler. Tracks all metadata updates during write session.
+             */
+            class PortableMetadataHandler 
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param snap Snapshot.
+                 */
+                PortableMetadataHandler(SPSnap snap);
+                
+                /**
+                 * Destructor.
+                 */
+                ~PortableMetadataHandler();
+
+                /**
+                 * Callback invoked when field is being written.
+                 *
+                 * @param fieldId Field ID.
+                 * @param fieldName Field name.
+                 * @param fieldTypeId Field type ID.
+                 */
+                void OnFieldWritten(int32_t fieldId, std::string fieldName, int32_t fieldTypeId);
+
+                /**
+                 * Get initial snapshot.
+                 *
+                 * @param Snapshot.
+                 */
+                SPSnap GetSnapshot();
+
+                /**
+                 * Whether any difference exists.
+                 *
+                 * @param True if difference exists.
+                 */
+                bool HasDifference();
+
+                /**
+                 * Get recorded field IDs difference.
+                 *
+                 * @param Recorded field IDs difference.
+                 */
+                std::set<int32_t>* GetFieldIds();
+
+                /**
+                 * Get recorded fields difference.
+                 *
+                 * @param Recorded fields difference.
+                 */
+                std::map<std::string, int32_t>* GetFields();
+
+            private:
+                /** Snapshot. */
+                SPSnap snap;                          
+
+                /** Recorded field IDs difference. */
+                std::set<int32_t>* fieldIds;           
+                
+                /** Recorded fields difference. */
+                std::map<std::string, int32_t>* fields; 
+
+                IGNITE_NO_COPY_ASSIGNMENT(PortableMetadataHandler)
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_manager.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_manager.h b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_manager.h
new file mode 100644
index 0000000..3e2b770
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_manager.h
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_PORTABLE_METADATA_MANAGER
+#define _IGNITE_IMPL_PORTABLE_METADATA_MANAGER
+
+#include <vector>
+
+#include "ignite/ignite_error.h"
+#include "ignite/impl/portable/portable_metadata_handler.h"
+#include "ignite/impl/portable/portable_metadata_updater.h"
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            /**
+             * Metadata manager.
+             */
+            class IGNITE_IMPORT_EXPORT PortableMetadataManager
+            {
+            public:
+                /**
+                 * Constructor.
+                 */
+                PortableMetadataManager();
+
+                /**
+                 * Destructor.
+                 */
+                ~PortableMetadataManager();
+
+                /**
+                 * Get handler.
+                 *
+                 * @param typeId Type ID.
+                 */
+                ignite::common::concurrent::SharedPointer<PortableMetadataHandler> GetHandler(int32_t typeId);
+
+                /**
+                 * Submit handler for processing.
+                 * 
+                 * @param typeName Type name.
+                 * @param typeId Type ID.
+                 * @param hnd Handler.
+                 */
+                void SubmitHandler(std::string typeName, int32_t typeId, PortableMetadataHandler* hnd);
+
+                /**
+                 * Get current metadata manager version.
+                 *
+                 * @param Version.
+                 */
+                int32_t GetVersion();
+
+                /**
+                 * Check whether something is updated since the given version.
+                 *
+                 * @param oldVer Old version.
+                 * @return True if updated and it is very likely that pending metadata exists.
+                 */
+                bool IsUpdatedSince(int32_t oldVer);
+
+                /**
+                 * Process pending updates.
+                 *
+                 * @param updated Updater.
+                 * @param err Error.
+                 * @return In case of success.
+                 */
+                bool ProcessPendingUpdates(PortableMetadataUpdater* updater, IgniteError* err);
+
+            private:
+                /** Current snapshots. */
+                ignite::common::concurrent::SharedPointer<std::map<int32_t, SPSnap>> snapshots;
+                
+                /** Pending snapshots. */
+                std::vector<SPSnap>* pending;                                          
+
+                /** Critical section. */
+                ignite::common::concurrent::CriticalSection* cs;
+
+                /** Version of pending changes. */
+                int32_t pendingVer;                                                    
+                
+                /** Latest version. */
+                int32_t ver;          
+
+                IGNITE_NO_COPY_ASSIGNMENT(PortableMetadataManager);
+
+                /**
+                 * Copy fields from a snapshot into relevant collections.
+                 *
+                 * @param snap Target snapshot.
+                 * @param fieldIds Field IDs.
+                 * @param fields Fields.
+                 */
+                void CopyFields(Snap* snap, std::set<int32_t>* fieldIds, std::map<std::string, int32_t>* fields);
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_snapshot.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_snapshot.h b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_snapshot.h
new file mode 100644
index 0000000..1e000fc
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_snapshot.h
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_PORTABLE_METADATA_SNAPSHOT
+#define _IGNITE_IMPL_PORTABLE_METADATA_SNAPSHOT
+
+#include <map>
+#include <set>
+#include <stdint.h>
+#include <string>
+
+#include <ignite/common/common.h>
+#include <ignite/common/concurrent.h>
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            /**
+             * Metadata snapshot. 
+             */
+            class PortableMetadataSnapshot
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param typeName Type name.
+                 * @param typeId Type ID.
+                 * @param fieldIds Field IDs.
+                 * @param fields Fields.
+                 */
+                PortableMetadataSnapshot(std::string typeName, int32_t typeId, std::set<int32_t>* fieldIds, 
+                    std::map<std::string, int32_t>* fields);
+                
+                /**
+                 * Destructor.
+                 */
+                ~PortableMetadataSnapshot();
+
+                /**
+                 * Check whether snapshot contains a field with the given ID.
+                 *
+                 * @param fieldId Field ID.
+                 * @return True if contains, false otherwise.
+                 */
+                bool ContainsFieldId(int32_t fieldId);
+
+                /**
+                 * Get type name.
+                 *
+                 * @param Type name.
+                 */
+                std::string GetTypeName();
+
+                /**
+                 * Get type ID.
+                 *
+                 * @return Type ID.
+                 */
+                int32_t GetTypeId();
+
+                /**
+                 * Whether snapshot contains any fields.
+                 *
+                 * @param True if fields exist.
+                 */
+                bool HasFields();
+
+                /** 
+                 * Get field IDs.
+                 *
+                 * @param Field IDs.
+                 */
+                std::set<int32_t>* GetFieldIds();
+
+                /**
+                 * Get fields.
+                 *
+                 * @return Fields.
+                 */
+                std::map<std::string, int32_t>* GetFields();
+
+            private:
+                /** Type name. */
+                std::string typeName;                   
+                
+                /** Type ID. */
+                int32_t typeId;
+
+                /** Known field IDs. */
+                std::set<int32_t>* fieldIds;
+
+                /** Field name-type mappings. */
+                std::map<std::string, int32_t>* fields; 
+
+                IGNITE_NO_COPY_ASSIGNMENT(PortableMetadataSnapshot)
+            };
+
+            typedef PortableMetadataSnapshot Snap;
+            typedef ignite::common::concurrent::SharedPointer<Snap> SPSnap;
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_updater.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_updater.h b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_updater.h
new file mode 100644
index 0000000..a734db7
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_updater.h
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_PORTABLE_METADATA_UPDATER
+#define _IGNITE_IMPL_PORTABLE_METADATA_UPDATER
+
+#include "ignite/ignite_error.h"
+#include "ignite/impl/portable/portable_metadata_snapshot.h"
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            /**
+             * Metadata updater interface.
+             */
+            class IGNITE_IMPORT_EXPORT PortableMetadataUpdater
+            {
+            public:
+                /**
+                 * Destructor.
+                 */
+                virtual ~PortableMetadataUpdater();
+
+                /**
+                 * Update metadata using provided snapshot.
+                 *
+                 * @param snapshot Snapshot.
+                 * @param err Error.
+                 */
+                virtual bool Update(Snap* snapshot, IgniteError* err) = 0;
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_updater_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_updater_impl.h b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_updater_impl.h
new file mode 100644
index 0000000..832c2a3
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_metadata_updater_impl.h
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_PORTABLE_METADATA_UPDATER_IMPL
+#define _IGNITE_IMPL_PORTABLE_METADATA_UPDATER_IMPL
+
+#include <ignite/common/exports.h>
+
+#include "ignite/impl/ignite_environment.h"
+#include "ignite/impl/portable/portable_metadata_updater.h"
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            /**
+             * Metadata updater implementation.
+             */
+            class IGNITE_IMPORT_EXPORT PortableMetadataUpdaterImpl : public PortableMetadataUpdater
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param env Environment.
+                 * @param javaRef Reference to Java object which is able to process metadata request.
+                 */
+                PortableMetadataUpdaterImpl(ignite::common::concurrent::SharedPointer<IgniteEnvironment> env, jobject javaRef);
+
+                /**
+                 * Destructor.
+                 */
+                ~PortableMetadataUpdaterImpl();
+
+                bool Update(Snap* snapshot, IgniteError* err);
+            private:
+                /** Environment. */
+                ignite::common::concurrent::SharedPointer<IgniteEnvironment> env;
+                
+                /** Handle to Java object. */
+                jobject javaRef;                 
+
+                IGNITE_NO_COPY_ASSIGNMENT(PortableMetadataUpdaterImpl)
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file


[05/50] [abbrv] ignite git commit: ignite-1273: fixed cyclic references processing by PortableMarshaller and ability to modify array fields returned by PortableBuilder

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
index 488361c..61ec714 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
@@ -22,6 +22,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import java.lang.reflect.Field;
+import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -38,6 +39,8 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgnitePortables;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.builder.PortableBuilderEnum;
+import org.apache.ignite.internal.portable.builder.PortableBuilderImpl;
 import org.apache.ignite.internal.portable.mutabletest.GridPortableMarshalerAwareTestClass;
 import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
 import org.apache.ignite.internal.processors.cache.portable.IgnitePortablesImpl;
@@ -237,10 +240,214 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
     /**
      *
      */
-    public void testSimpleArrayModification() {
+    public void testDateArrayModification() {
         TestObjectAllTypes obj = new TestObjectAllTypes();
 
-        obj.strArr = new String[]{"a", "a", "a"};
+        obj.dateArr =  new Date[] {new Date(11111), new Date(11111), new Date(11111)};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        Date[] arr = mutObj.getField("dateArr");
+        arr[0] = new Date(22222);
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new Date[] {new Date(22222), new Date(11111), new Date(11111)}, res.dateArr);
+    }
+
+    /**
+     *
+     */
+    public void testUUIDArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.uuidArr = new UUID[] {new UUID(1, 1), new UUID(1, 1), new UUID(1, 1)};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        UUID[] arr = mutObj.getField("uuidArr");
+        arr[0] = new UUID(2, 2);
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new UUID[] {new UUID(2, 2), new UUID(1, 1), new UUID(1, 1)}, res.uuidArr);
+    }
+
+    /**
+     *
+     */
+    public void testDecimalArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.bdArr = new BigDecimal[] {new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000)};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        BigDecimal[] arr = mutObj.getField("bdArr");
+        arr[0] = new BigDecimal(2000);
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new BigDecimal[] {new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000)},
+            res.bdArr);
+    }
+
+    /**
+     *
+     */
+    public void testBooleanArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.zArr = new boolean[] {false, false, false};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        boolean[] arr = mutObj.getField("zArr");
+        arr[0] = true;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        boolean[] expected = new boolean[] {true, false, false};
+
+        assertEquals(expected.length, res.zArr.length);
+
+        for (int i = 0; i < expected.length; i++)
+            assertEquals(expected[i], res.zArr[i]);
+    }
+
+    /**
+     *
+     */
+    public void testCharArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.cArr = new char[] {'a', 'a', 'a'};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        char[] arr = mutObj.getField("cArr");
+        arr[0] = 'b';
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new char[] {'b', 'a', 'a'}, res.cArr);
+    }
+
+    /**
+     *
+     */
+    public void testDoubleArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.dArr = new double[] {1.0, 1.0, 1.0};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        double[] arr = mutObj.getField("dArr");
+        arr[0] = 2.0;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new double[] {2.0, 1.0, 1.0}, res.dArr, 0);
+    }
+
+    /**
+     *
+     */
+    public void testFloatArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.fArr = new float[] {1.0f, 1.0f, 1.0f};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        float[] arr = mutObj.getField("fArr");
+        arr[0] = 2.0f;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new float[] {2.0f, 1.0f, 1.0f}, res.fArr, 0);
+    }
+
+    /**
+     *
+     */
+    public void testLongArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.lArr = new long[] {1, 1, 1};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        long[] arr = mutObj.getField("lArr");
+        arr[0] = 2;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new long[] {2, 1, 1}, res.lArr);
+    }
+
+    /**
+     *
+     */
+    public void testIntArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.iArr = new int[] {1, 1, 1};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        int[] arr = mutObj.getField("iArr");
+        arr[0] = 2;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new int[] {2, 1, 1}, res.iArr);
+    }
+
+    /**
+     *
+     */
+    public void testShortArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.sArr = new short[] {1, 1, 1};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        short[] arr = mutObj.getField("sArr");
+        arr[0] = 2;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new short[] {2, 1, 1}, res.sArr);
+    }
+
+    /**
+     *
+     */
+    public void testByteArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.bArr = new byte[] {1, 1, 1};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        byte[] arr = mutObj.getField("bArr");
+        arr[0] = 2;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new byte[] {2, 1, 1}, res.bArr);
+    }
+
+    /**
+     *
+     */
+    public void testStringArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.strArr = new String[] {"a", "a", "a"};
 
         PortableBuilderImpl mutObj = wrap(obj);
 
@@ -249,29 +456,27 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
 
         TestObjectAllTypes res = mutObj.build().deserialize();
 
-        Assert.assertArrayEquals(obj.strArr, res.strArr);
+        Assert.assertArrayEquals(new String[] {"b", "a", "a"}, res.strArr);
     }
 
     /**
      *
      */
     public void testModifyObjectArray() {
-        fail("https://issues.apache.org/jira/browse/IGNITE-1273");
-
         TestObjectContainer obj = new TestObjectContainer();
-        obj.foo = new Object[]{"a"};
+        obj.foo = new Object[] {"a"};
 
         PortableBuilderImpl mutObj = wrap(obj);
 
         Object[] arr = mutObj.getField("foo");
 
-        Assert.assertArrayEquals(new Object[]{"a"}, arr);
+        Assert.assertArrayEquals(new Object[] {"a"}, arr);
 
         arr[0] = "b";
 
         TestObjectContainer res = mutObj.build().deserialize();
 
-        Assert.assertArrayEquals(new Object[] {"a"}, (Object[])res.foo);
+        Assert.assertArrayEquals(new Object[] {"b"}, (Object[])res.foo);
     }
 
     /**
@@ -280,7 +485,7 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
     public void testOverrideObjectArrayField() {
         PortableBuilderImpl mutObj = wrap(new TestObjectContainer());
 
-        Object[] createdArr = {mutObj, "a", 1, new String[] {"s", "s"}, new byte[]{1, 2}, new UUID(3, 0)};
+        Object[] createdArr = {mutObj, "a", 1, new String[] {"s", "s"}, new byte[] {1, 2}, new UUID(3, 0)};
 
         mutObj.setField("foo", createdArr.clone());
 
@@ -296,7 +501,7 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
      */
     public void testDeepArray() {
         TestObjectContainer obj = new TestObjectContainer();
-        obj.foo = new Object[]{new Object[]{"a", obj}};
+        obj.foo = new Object[] {new Object[] {"a", obj}};
 
         PortableBuilderImpl mutObj = wrap(obj);
 
@@ -633,7 +838,7 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
     public void testEnumArrayModification() {
         TestObjectAllTypes obj = new TestObjectAllTypes();
 
-        obj.enumArr = new TestObjectEnum[]{TestObjectEnum.A, TestObjectEnum.B};
+        obj.enumArr = new TestObjectEnum[] {TestObjectEnum.A, TestObjectEnum.B};
 
         PortableBuilderImpl mutObj = wrap(obj);
 
@@ -953,12 +1158,10 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
      *
      */
     public void testCyclicArrays() {
-        fail("https://issues.apache.org/jira/browse/IGNITE-1273");
-
         TestObjectContainer obj = new TestObjectContainer();
 
         Object[] arr1 = new Object[1];
-        Object[] arr2 = new Object[]{arr1};
+        Object[] arr2 = new Object[] {arr1};
 
         arr1[0] = arr2;
 
@@ -976,7 +1179,6 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
      */
     @SuppressWarnings("TypeMayBeWeakened")
     public void testCyclicArrayList() {
-        fail("https://issues.apache.org/jira/browse/IGNITE-1273");
         TestObjectContainer obj = new TestObjectContainer();
 
         List<Object> arr1 = new ArrayList<>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
index 3ba0a92..7f23c1f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
@@ -28,6 +28,7 @@ import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgnitePortables;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.builder.PortableBuilderImpl;
 import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes;
 import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectContainer;
 import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectInner;

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
index 11e316a..c8287a0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
@@ -40,6 +40,7 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListSet;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.portable.builder.PortableBuilderImpl;
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.lang.GridMapEntry;
@@ -68,6 +69,7 @@ import sun.misc.Unsafe;
 
 import static org.apache.ignite.internal.portable.PortableThreadLocalMemoryAllocator.THREAD_LOCAL_ALLOC;
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Portable marshaller tests.
@@ -1547,11 +1549,11 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
 
         PortableObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[]{1, 2, 3}));
 
-        assertArrayEquals(new byte[]{1, 2, 3}, copy.<byte[]>field("bArr"));
+        assertArrayEquals(new byte[] {1, 2, 3}, copy.<byte[]>field("bArr"));
 
         SimpleObject obj0 = copy.deserialize();
 
-        assertArrayEquals(new byte[]{1, 2, 3}, obj0.bArr);
+        assertArrayEquals(new byte[] {1, 2, 3}, obj0.bArr);
     }
 
     /**
@@ -1796,7 +1798,7 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
 
         assertEquals("str555", obj0.str);
         assertEquals(newObj, obj0.inner);
-        assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
+        assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
     }
 
     /**
@@ -1832,7 +1834,7 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         assertEquals("str555", copy.<String>field("str"));
         assertEquals(newObj, copy.<PortableObject>field("inner").deserialize());
         assertEquals((short)2323, copy.<Short>field("s").shortValue());
-        assertArrayEquals(new byte[]{6, 7, 9}, copy.<byte[]>field("bArr"));
+        assertArrayEquals(new byte[] {6, 7, 9}, copy.<byte[]>field("bArr"));
         assertEquals((byte)111, copy.<Byte>field("b").byteValue());
 
         SimpleObject obj0 = copy.deserialize();
@@ -1841,7 +1843,7 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         assertEquals("str555", obj0.str);
         assertEquals(newObj, obj0.inner);
         assertEquals((short)2323, obj0.s);
-        assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
+        assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
         assertEquals((byte)111, obj0.b);
     }
 
@@ -2239,6 +2241,53 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testCyclicReferencesMarshalling() throws Exception {
+        PortableMarshaller marsh = new PortableMarshaller();
+
+        SimpleObject obj = simpleObject();
+
+        obj.bArr = obj.inner.bArr;
+        obj.cArr = obj.inner.cArr;
+        obj.boolArr = obj.inner.boolArr;
+        obj.sArr = obj.inner.sArr;
+        obj.strArr = obj.inner.strArr;
+        obj.iArr = obj.inner.iArr;
+        obj.lArr = obj.inner.lArr;
+        obj.fArr = obj.inner.fArr;
+        obj.dArr = obj.inner.dArr;
+        obj.dateArr = obj.inner.dateArr;
+        obj.uuidArr = obj.inner.uuidArr;
+        obj.objArr = obj.inner.objArr;
+        obj.bdArr = obj.inner.bdArr;
+        obj.map = obj.inner.map;
+        obj.col = obj.inner.col;
+        obj.mEntry = obj.inner.mEntry;
+
+        SimpleObject res = (SimpleObject)marshalUnmarshal(obj, marsh);
+
+        assertEquals(obj, res);
+
+        assertTrue(res.bArr == res.inner.bArr);
+        assertTrue(res.cArr == res.inner.cArr);
+        assertTrue(res.boolArr == res.inner.boolArr);
+        assertTrue(res.sArr == res.inner.sArr);
+        assertTrue(res.strArr == res.inner.strArr);
+        assertTrue(res.iArr == res.inner.iArr);
+        assertTrue(res.lArr == res.inner.lArr);
+        assertTrue(res.fArr == res.inner.fArr);
+        assertTrue(res.dArr == res.inner.dArr);
+        assertTrue(res.dateArr == res.inner.dateArr);
+        assertTrue(res.uuidArr == res.inner.uuidArr);
+        assertTrue(res.objArr == res.inner.objArr);
+        assertTrue(res.bdArr == res.inner.bdArr);
+        assertTrue(res.map == res.inner.map);
+        assertTrue(res.col == res.inner.col);
+        assertTrue(res.mEntry == res.inner.mEntry);
+    }
+
+    /**
      *
      */
     private static class ObjectWithClassFields {
@@ -2424,6 +2473,7 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         inner.map = new HashMap<>();
         inner.enumVal = TestEnum.A;
         inner.enumArr = new TestEnum[] {TestEnum.A, TestEnum.B};
+        inner.bdArr = new BigDecimal[] {new BigDecimal(1000), BigDecimal.ONE};
 
         inner.col.add("str1");
         inner.col.add("str2");
@@ -2433,6 +2483,8 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         inner.map.put(2, "str2");
         inner.map.put(3, "str3");
 
+        inner.mEntry = inner.map.entrySet().iterator().next();
+
         SimpleObject outer = new SimpleObject();
 
         outer.b = 2;
@@ -2464,6 +2516,8 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         outer.enumVal = TestEnum.B;
         outer.enumArr = new TestEnum[] {TestEnum.B, TestEnum.C};
         outer.inner = inner;
+        outer.bdArr = new BigDecimal[] {new BigDecimal(5000), BigDecimal.TEN};
+
 
         outer.col.add("str4");
         outer.col.add("str5");
@@ -2473,6 +2527,8 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         outer.map.put(5, "str5");
         outer.map.put(6, "str6");
 
+        outer.mEntry = outer.map.entrySet().iterator().next();
+
         return outer;
     }
 
@@ -2757,6 +2813,9 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         private Object[] objArr;
 
         /** */
+        private BigDecimal[] bdArr;
+
+        /** */
         private Collection<String> col;
 
         /** */
@@ -2769,6 +2828,9 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         private TestEnum[] enumArr;
 
         /** */
+        private Map.Entry<Integer, String> mEntry;
+
+        /** */
         private SimpleObject inner;
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
index d329818..05df23b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
@@ -20,6 +20,7 @@ import java.util.Arrays;
 import org.apache.ignite.IgnitePortables;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.portable.PortableBuilder;
 import org.apache.ignite.portable.PortableException;
 import org.apache.ignite.portable.PortableMarshalAware;
 import org.apache.ignite.portable.PortableReader;
@@ -68,9 +69,17 @@ public class GridPortableMetaDataDisabledSelfTest extends GridCommonAbstractTest
 
             portables().toPortable(new TestObject1());
             portables().toPortable(new TestObject2());
+            portables().toPortable(new TestObject3());
 
             assertEquals(0, portables().metadata(TestObject1.class).fields().size());
             assertEquals(0, portables().metadata(TestObject2.class).fields().size());
+
+            PortableBuilder bldr = portables().builder("FakeType");
+
+            bldr.setField("field1", 0).setField("field2", "value").build();
+
+            assertNull(portables().metadata("FakeType"));
+            assertNull(portables().metadata(TestObject3.class));
         }
         finally {
             stopGrid();
@@ -218,4 +227,12 @@ public class GridPortableMetaDataDisabledSelfTest extends GridCommonAbstractTest
             // No-op.
         }
     }
+
+    /**
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class TestObject3 {
+        /** */
+        private int field;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
index f6d7627..9054297 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
@@ -147,6 +147,15 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testNoConfiguration() throws Exception {
+        portables().toPortable(new TestObject3());
+
+        assertNotNull(portables().metadata(TestObject3.class));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testReflection() throws Exception {
         PortableMetadata meta = portables().metadata(TestObject1.class);
 
@@ -349,4 +358,12 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
             // No-op.
         }
     }
+
+    /**
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class TestObject3 {
+        /** */
+        private int intVal;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
index ce97a8d..e49514b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.ObjectOutput;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -182,7 +183,6 @@ public class GridPortableTestClasses {
         /** */
         public Date date;
 
-
         /** */
         public byte[] bArr;
 
@@ -208,12 +208,18 @@ public class GridPortableTestClasses {
         public boolean[] zArr;
 
         /** */
+        public BigDecimal[] bdArr;
+
+        /** */
         public String[] strArr;
 
         /** */
         public UUID[] uuidArr;
 
         /** */
+        public Date[] dateArr;
+
+        /** */
         public TestObjectEnum anEnum;
 
         /** */
@@ -222,8 +228,6 @@ public class GridPortableTestClasses {
         /** */
         public Map.Entry entry;
 
-        //public Date[] dateArr; // todo test date array.
-
         /**
          * @return Array.
          */
@@ -270,21 +274,23 @@ public class GridPortableTestClasses {
             uuid = new UUID(1, 1);
             date = new Date(1000000);
 
-            bArr = new byte[]{1, 2, 3};
-            sArr = new short[]{1, 2, 3};
-            iArr = new int[]{1, 2, 3};
-            lArr = new long[]{1, 2, 3};
-            fArr = new float[]{1, 2, 3};
-            dArr = new double[]{1, 2, 3};
-            cArr = new char[]{1, 2, 3};
-            zArr = new boolean[]{true, false};
+            bArr = new byte[] {1, 2, 3};
+            sArr = new short[] {1, 2, 3};
+            iArr = new int[] {1, 2, 3};
+            lArr = new long[] {1, 2, 3};
+            fArr = new float[] {1, 2, 3};
+            dArr = new double[] {1, 2, 3};
+            cArr = new char[] {1, 2, 3};
+            zArr = new boolean[] {true, false};
 
-            strArr = new String[]{"abc", "ab", "a"};
-            uuidArr = new UUID[]{new UUID(1, 1), new UUID(2, 2)};
+            strArr = new String[] {"abc", "ab", "a"};
+            uuidArr = new UUID[] {new UUID(1, 1), new UUID(2, 2)};
+            bdArr = new BigDecimal[] {new BigDecimal(1000), BigDecimal.TEN};
+            dateArr = new Date[] {new Date(1000000), new Date(200000)};
 
             anEnum = TestObjectEnum.A;
 
-            enumArr = new TestObjectEnum[]{TestObjectEnum.B};
+            enumArr = new TestObjectEnum[] {TestObjectEnum.B};
 
             entry = new GridMapEntry<>(1, "a");
         }
@@ -388,7 +394,6 @@ public class GridPortableTestClasses {
         private Map<String, List<Company>> companyByStreet = new TreeMap<>();
 
         /**
-         *
          * @param street Street.
          * @return Company.
          */
@@ -397,7 +402,6 @@ public class GridPortableTestClasses {
         }
 
         /**
-         *
          * @param company Company.
          */
         public void addCompany(Company company) {
@@ -413,7 +417,6 @@ public class GridPortableTestClasses {
         }
 
         /**
-         *
          * @return map
          */
         public Map<String, List<Company>> getCompanyByStreet() {
@@ -421,7 +424,6 @@ public class GridPortableTestClasses {
         }
 
         /**
-         *
          * @param companyByStreet map
          */
         public void setCompanyByStreet(Map<String, List<Company>> companyByStreet) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
index aa67574..1ba3d4d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
@@ -31,6 +31,7 @@ import org.apache.ignite.IgnitePortables;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.portable.PortableMarshaller;
 import org.apache.ignite.portable.PortableBuilder;
@@ -233,6 +234,16 @@ public class GridCacheClientNodePortableMetadataMultinodeTest extends GridCommon
 
             portables = ignite(i).portables();
 
+            final IgnitePortables p0 = portables;
+
+            GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                @Override public boolean apply() {
+                    Collection<PortableMetadata> metaCol = p0.metadata();
+
+                    return metaCol.size() == 1000;
+                }
+            }, getTestTimeout());
+
             Collection<PortableMetadata> metaCol = portables.metadata();
 
             assertEquals(1000, metaCol.size());


[06/50] [abbrv] ignite git commit: ignite-1273: fixed cyclic references processing by PortableMarshaller and ability to modify array fields returned by PortableBuilder

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
new file mode 100644
index 0000000..45355d7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
@@ -0,0 +1,800 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableContext;
+import org.apache.ignite.internal.portable.PortableObjectImpl;
+import org.apache.ignite.internal.portable.PortablePrimitives;
+import org.apache.ignite.internal.portable.PortableReaderExImpl;
+import org.apache.ignite.internal.portable.PortableUtils;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.portable.PortableException;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
+
+/**
+ *
+ */
+class PortableBuilderReader {
+    /** */
+    private static final PortablePrimitives PRIM = PortablePrimitives.get();
+
+    /** */
+    private final Map<Integer, PortableBuilderImpl> objMap = new HashMap<>();
+
+    /** */
+    private final PortableContext ctx;
+
+    /** */
+    private final PortableReaderExImpl reader;
+
+    /** */
+    private byte[] arr;
+
+    /** */
+    private int pos;
+
+    /**
+     * @param objImpl Portable object
+     */
+    PortableBuilderReader(PortableObjectImpl objImpl) {
+        ctx = objImpl.context();
+        arr = objImpl.array();
+        pos = objImpl.start();
+
+        // TODO: IGNITE-1272 - Is class loader needed here?
+        reader = new PortableReaderExImpl(portableContext(), arr, pos, null);
+    }
+
+    /**
+     * @return Portable context.
+     */
+    public PortableContext portableContext() {
+        return ctx;
+    }
+
+    /**
+     * @param obj Mutable portable object.
+     */
+    public void registerObject(PortableBuilderImpl obj) {
+        objMap.put(obj.start(), obj);
+    }
+
+    /**
+     * @return Read int value.
+     */
+    public int readInt() {
+        int res = readInt(0);
+
+        pos += 4;
+
+        return res;
+    }
+
+    /**
+     * @return Read int value.
+     */
+    public byte readByte() {
+        return arr[pos++];
+    }
+
+    /**
+     * @return Read boolean value.
+     */
+    public boolean readBoolean() {
+        return readByte() == 1;
+    }
+
+    /**
+     * @return Read int value.
+     */
+    public byte readByte(int off) {
+        return arr[pos + off];
+    }
+
+    /**
+     * @param off Offset related to {@link #pos}
+     * @return Read int value.
+     */
+    public int readInt(int off) {
+        return PRIM.readInt(arr, pos + off);
+    }
+
+    /**
+     * @param pos Position in the source array.
+     * @return Read int value.
+     */
+    public int readIntAbsolute(int pos) {
+        return PRIM.readInt(arr, pos);
+    }
+
+    /**
+     * @return Read length of array.
+     */
+    public int readLength() {
+        return PRIM.readInt(arr, pos);
+    }
+
+    /**
+     * Read string length.
+     *
+     * @return String length.
+     */
+    public int readStringLength() {
+        boolean utf = PRIM.readBoolean(arr, pos);
+
+        int arrLen = PRIM.readInt(arr, pos + 1);
+
+        return 1 + (utf ? arrLen : arrLen << 1);
+    }
+
+    /**
+     * Reads string.
+     *
+     * @return String.
+     */
+    public String readString() {
+        byte flag = readByte();
+
+        if (flag == NULL)
+            return null;
+
+        if (flag != STRING)
+            throw new PortableException("Failed to deserialize String.");
+
+        boolean convert = readBoolean();
+        int len = readInt();
+
+        String str;
+
+        if (convert) {
+            str = new String(arr, pos, len, UTF_8);
+
+            pos += len;
+        }
+        else {
+            str = String.valueOf(PRIM.readCharArray(arr, pos, len));
+
+            pos += len << 1;
+        }
+
+        return str;
+    }
+
+    /**
+     *
+     */
+    public void skipValue() {
+        byte type = arr[pos++];
+
+        int len;
+
+        switch (type) {
+            case GridPortableMarshaller.NULL:
+                return;
+
+            case GridPortableMarshaller.OBJ:
+                pos += readInt(GridPortableMarshaller.TOTAL_LEN_POS - 1) - 1;
+
+                return;
+
+            case GridPortableMarshaller.BOOLEAN:
+            case GridPortableMarshaller.BYTE:
+                len = 1;
+                break;
+
+            case GridPortableMarshaller.CHAR:
+            case GridPortableMarshaller.SHORT:
+                len = 2;
+
+                break;
+
+            case GridPortableMarshaller.HANDLE:
+            case GridPortableMarshaller.FLOAT:
+            case GridPortableMarshaller.INT:
+                len = 4;
+
+                break;
+
+            case GridPortableMarshaller.ENUM:
+                //skipping type id and ordinal value
+                len = 8;
+
+                break;
+
+            case GridPortableMarshaller.LONG:
+            case GridPortableMarshaller.DOUBLE:
+                len = 8;
+
+                break;
+
+            case GridPortableMarshaller.BYTE_ARR:
+            case GridPortableMarshaller.BOOLEAN_ARR:
+                len = 4 + readLength();
+
+                break;
+
+            case GridPortableMarshaller.STRING:
+                len = 4 + readStringLength();
+
+                break;
+
+            case GridPortableMarshaller.DECIMAL:
+                len = /** scale */ 4  + /** mag len */ 4  + /** mag bytes count */ readInt(4);
+
+                break;
+
+            case GridPortableMarshaller.UUID:
+                len = 8 + 8;
+
+                break;
+
+            case GridPortableMarshaller.DATE:
+                len = 8 + 4;
+
+                break;
+
+            case GridPortableMarshaller.CHAR_ARR:
+            case GridPortableMarshaller.SHORT_ARR:
+                len = 4 + readLength() * 2;
+
+                break;
+
+            case GridPortableMarshaller.INT_ARR:
+            case GridPortableMarshaller.FLOAT_ARR:
+                len = 4 + readLength() * 4;
+
+                break;
+
+            case GridPortableMarshaller.LONG_ARR:
+            case GridPortableMarshaller.DOUBLE_ARR:
+                len = 4 + readLength() * 8;
+
+                break;
+
+            case GridPortableMarshaller.DECIMAL_ARR:
+            case GridPortableMarshaller.DATE_ARR:
+            case GridPortableMarshaller.OBJ_ARR:
+            case GridPortableMarshaller.ENUM_ARR:
+            case GridPortableMarshaller.UUID_ARR:
+            case GridPortableMarshaller.STRING_ARR: {
+                int size = readInt();
+
+                for (int i = 0; i < size; i++)
+                    skipValue();
+
+                return;
+            }
+
+            case GridPortableMarshaller.COL: {
+                int size = readInt();
+
+                pos++; // skip collection type
+
+                for (int i = 0; i < size; i++)
+                    skipValue();
+
+                return;
+            }
+
+            case GridPortableMarshaller.MAP: {
+                int size = readInt();
+
+                pos++; // skip collection type
+
+                for (int i = 0; i < size; i++) {
+                    skipValue(); // skip key.
+                    skipValue(); // skip value.
+                }
+
+                return;
+            }
+
+            case GridPortableMarshaller.MAP_ENTRY:
+                skipValue();
+                skipValue();
+
+                return;
+
+            case GridPortableMarshaller.PORTABLE_OBJ:
+                len = readInt() + 4;
+
+                break;
+
+            default:
+                throw new PortableException("Invalid flag value: " + type);
+        }
+
+        pos += len;
+    }
+
+    /**
+     * @param pos Position.
+     * @param len Length.
+     * @return Object.
+     */
+    public Object getValueQuickly(int pos, int len) {
+        byte type = arr[pos];
+
+        switch (type) {
+            case GridPortableMarshaller.NULL:
+                return null;
+
+            case GridPortableMarshaller.HANDLE: {
+                int objStart = pos - readIntAbsolute(pos + 1);
+
+                PortableBuilderImpl res = objMap.get(objStart);
+
+                if (res == null) {
+                    res = new PortableBuilderImpl(this, objStart);
+
+                    objMap.put(objStart, res);
+                }
+
+                return res;
+            }
+
+            case GridPortableMarshaller.OBJ: {
+                PortableBuilderImpl res = objMap.get(pos);
+
+                if (res == null) {
+                    res = new PortableBuilderImpl(this, pos);
+
+                    objMap.put(pos, res);
+                }
+
+                return res;
+            }
+
+            case GridPortableMarshaller.BYTE:
+                return arr[pos + 1];
+
+            case GridPortableMarshaller.SHORT:
+                return PRIM.readShort(arr, pos + 1);
+
+            case GridPortableMarshaller.INT:
+                return PRIM.readInt(arr, pos + 1);
+
+            case GridPortableMarshaller.LONG:
+                return PRIM.readLong(arr, pos + 1);
+
+            case GridPortableMarshaller.FLOAT:
+                return PRIM.readFloat(arr, pos + 1);
+
+            case GridPortableMarshaller.DOUBLE:
+                return PRIM.readDouble(arr, pos + 1);
+
+            case GridPortableMarshaller.CHAR:
+                return PRIM.readChar(arr, pos + 1);
+
+            case GridPortableMarshaller.BOOLEAN:
+                return arr[pos + 1] != 0;
+
+            case GridPortableMarshaller.DECIMAL:
+            case GridPortableMarshaller.STRING:
+            case GridPortableMarshaller.UUID:
+            case GridPortableMarshaller.DATE:
+                return new PortablePlainLazyValue(this, pos, len);
+
+            case GridPortableMarshaller.BYTE_ARR:
+            case GridPortableMarshaller.SHORT_ARR:
+            case GridPortableMarshaller.INT_ARR:
+            case GridPortableMarshaller.LONG_ARR:
+            case GridPortableMarshaller.FLOAT_ARR:
+            case GridPortableMarshaller.DOUBLE_ARR:
+            case GridPortableMarshaller.CHAR_ARR:
+            case GridPortableMarshaller.BOOLEAN_ARR:
+            case GridPortableMarshaller.DECIMAL_ARR:
+            case GridPortableMarshaller.DATE_ARR:
+            case GridPortableMarshaller.UUID_ARR:
+            case GridPortableMarshaller.STRING_ARR:
+            case GridPortableMarshaller.ENUM_ARR:
+            case GridPortableMarshaller.OBJ_ARR:
+            case GridPortableMarshaller.COL:
+            case GridPortableMarshaller.MAP:
+            case GridPortableMarshaller.MAP_ENTRY:
+                return new LazyCollection(pos);
+
+            case GridPortableMarshaller.ENUM: {
+                if (len == 1) {
+                    assert readByte(pos) == GridPortableMarshaller.NULL;
+
+                    return null;
+                }
+
+                int mark = position();
+                position(pos + 1);
+
+                PortableBuilderEnum builderEnum = new PortableBuilderEnum(this);
+
+                position(mark);
+
+                return builderEnum;
+            }
+
+            case GridPortableMarshaller.PORTABLE_OBJ: {
+                int size = readIntAbsolute(pos + 1);
+
+                int start = readIntAbsolute(pos + 4 + size);
+
+                PortableObjectImpl portableObj = new PortableObjectImpl(ctx, arr, pos + 4 + start);
+
+                return new PortablePlainPortableObject(portableObj);
+            }
+
+            default:
+                throw new PortableException("Invalid flag value: " + type);
+        }
+    }
+
+    /**
+     * @return Parsed value.
+     */
+    public Object parseValue() {
+        int valPos = pos;
+
+        byte type = arr[pos++];
+
+        int plainLazyValLen;
+
+        boolean modifiableLazyVal = false;
+
+        switch (type) {
+            case GridPortableMarshaller.NULL:
+                return null;
+
+            case GridPortableMarshaller.HANDLE: {
+                int objStart = pos - 1 - readInt();
+
+                PortableBuilderImpl res = objMap.get(objStart);
+
+                if (res == null) {
+                    res = new PortableBuilderImpl(this, objStart);
+
+                    objMap.put(objStart, res);
+                }
+
+                return res;
+            }
+
+            case GridPortableMarshaller.OBJ: {
+                pos--;
+
+                PortableBuilderImpl res = objMap.get(pos);
+
+                if (res == null) {
+                    res = new PortableBuilderImpl(this, pos);
+
+                    objMap.put(pos, res);
+                }
+
+                pos += readInt(GridPortableMarshaller.TOTAL_LEN_POS);
+
+                return res;
+            }
+
+            case GridPortableMarshaller.BYTE:
+                return arr[pos++];
+
+            case GridPortableMarshaller.SHORT: {
+                Object res = PRIM.readShort(arr, pos);
+                pos += 2;
+                return res;
+            }
+
+            case GridPortableMarshaller.INT:
+                return readInt();
+
+            case GridPortableMarshaller.LONG:
+                plainLazyValLen = 8;
+
+                break;
+
+            case GridPortableMarshaller.FLOAT:
+                plainLazyValLen = 4;
+
+                break;
+
+            case GridPortableMarshaller.DOUBLE:
+                plainLazyValLen = 8;
+
+                break;
+
+            case GridPortableMarshaller.CHAR:
+                plainLazyValLen = 2;
+
+                break;
+
+            case GridPortableMarshaller.BOOLEAN:
+                return arr[pos++] != 0;
+
+            case GridPortableMarshaller.DECIMAL:
+                plainLazyValLen = /** scale */ 4  + /** mag len */ 4  + /** mag bytes count */ readInt(4);
+
+                break;
+
+            case GridPortableMarshaller.STRING:
+                plainLazyValLen = 4 + readStringLength();
+
+                break;
+
+            case GridPortableMarshaller.UUID:
+                plainLazyValLen = 8 + 8;
+
+                break;
+
+            case GridPortableMarshaller.DATE:
+                plainLazyValLen = 8 + 4;
+
+                break;
+
+            case GridPortableMarshaller.BYTE_ARR:
+                plainLazyValLen = 4 + readLength();
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.SHORT_ARR:
+                plainLazyValLen = 4 + readLength() * 2;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.INT_ARR:
+                plainLazyValLen = 4 + readLength() * 4;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.LONG_ARR:
+                plainLazyValLen = 4 + readLength() * 8;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.FLOAT_ARR:
+                plainLazyValLen = 4 + readLength() * 4;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.DOUBLE_ARR:
+                plainLazyValLen = 4 + readLength() * 8;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.CHAR_ARR:
+                plainLazyValLen = 4 + readLength() * 2;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.BOOLEAN_ARR:
+                plainLazyValLen = 4 + readLength();
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.OBJ_ARR:
+                return new PortableObjectArrayLazyValue(this);
+
+            case GridPortableMarshaller.DATE_ARR: {
+                int size = readInt();
+
+                Date[] res = new Date[size];
+
+                for (int i = 0; i < res.length; i++) {
+                    byte flag = arr[pos++];
+
+                    if (flag == GridPortableMarshaller.NULL) continue;
+
+                    if (flag != GridPortableMarshaller.DATE)
+                        throw new PortableException("Invalid flag value: " + flag);
+
+                    long time = PRIM.readLong(arr, pos);
+
+                    pos += 8;
+
+                    if (ctx.isUseTimestamp()) {
+                        Timestamp ts = new Timestamp(time);
+
+                        ts.setNanos(ts.getNanos() + readInt());
+
+                        res[i] = ts;
+                    }
+                    else {
+                        res[i] = new Date(time);
+
+                        pos += 4;
+                    }
+                }
+
+                return res;
+            }
+
+            case GridPortableMarshaller.UUID_ARR:
+            case GridPortableMarshaller.STRING_ARR:
+            case GridPortableMarshaller.DECIMAL_ARR: {
+                int size = readInt();
+
+                for (int i = 0; i < size; i++) {
+                    byte flag = arr[pos++];
+
+                    if (flag == GridPortableMarshaller.UUID)
+                        pos += 8 + 8;
+                    else if (flag == GridPortableMarshaller.STRING)
+                        pos += 4 + readStringLength();
+                    else if (flag == GridPortableMarshaller.DECIMAL) {
+                        pos += 4; // scale value
+                        pos += 4 + readLength();
+                    }
+                    else
+                        assert flag == GridPortableMarshaller.NULL;
+                }
+
+                return new PortableModifiableLazyValue(this, valPos, pos - valPos);
+            }
+
+            case GridPortableMarshaller.COL: {
+                int size = readInt();
+                byte colType = arr[pos++];
+
+                switch (colType) {
+                    case GridPortableMarshaller.USER_COL:
+                    case GridPortableMarshaller.ARR_LIST:
+                        return new PortableLazyArrayList(this, size);
+
+                    case GridPortableMarshaller.LINKED_LIST:
+                        return new PortableLazyLinkedList(this, size);
+
+                    case GridPortableMarshaller.HASH_SET:
+                    case GridPortableMarshaller.LINKED_HASH_SET:
+                    case GridPortableMarshaller.TREE_SET:
+                    case GridPortableMarshaller.CONC_SKIP_LIST_SET:
+                        return new PortableLazySet(this, size);
+                }
+
+                throw new PortableException("Unknown collection type: " + colType);
+            }
+
+            case GridPortableMarshaller.MAP:
+                return PortableLazyMap.parseMap(this);
+
+            case GridPortableMarshaller.ENUM:
+                return new PortableBuilderEnum(this);
+
+            case GridPortableMarshaller.ENUM_ARR:
+                return new PortableEnumArrayLazyValue(this);
+
+            case GridPortableMarshaller.MAP_ENTRY:
+                return new PortableLazyMapEntry(this);
+
+            case GridPortableMarshaller.PORTABLE_OBJ: {
+                int size = readInt();
+
+                pos += size;
+
+                int start = readInt();
+
+                PortableObjectImpl portableObj = new PortableObjectImpl(ctx, arr,
+                    pos - 4 - size + start);
+
+                return new PortablePlainPortableObject(portableObj);
+            }
+
+
+            default:
+                throw new PortableException("Invalid flag value: " + type);
+        }
+
+        PortableAbstractLazyValue res;
+
+        if (modifiableLazyVal)
+            res = new PortableModifiableLazyValue(this, valPos, 1 + plainLazyValLen);
+        else
+            res = new PortablePlainLazyValue(this, valPos, 1 + plainLazyValLen);
+
+        pos += plainLazyValLen;
+
+        return res;
+    }
+
+    /**
+     * @return Array.
+     */
+    public byte[] array() {
+        return arr;
+    }
+
+    /**
+     * @return Position of reader.
+     */
+    public int position() {
+        return pos;
+    }
+
+    /**
+     * @param pos New pos.
+     */
+    public void position(int pos) {
+        this.pos = pos;
+    }
+
+    /**
+     * @param n Number of bytes to skip.
+     */
+    public void skip(int n) {
+        pos += n;
+    }
+
+    /**
+     * @return Reader.
+     */
+    PortableReaderExImpl reader() {
+        return reader;
+    }
+
+    /**
+     *
+     */
+    private class LazyCollection implements PortableLazyValue {
+        /** */
+        private final int valOff;
+
+        /** */
+        private Object col;
+
+        /**
+         * @param valOff Value.
+         */
+        protected LazyCollection(int valOff) {
+            this.valOff = valOff;
+        }
+
+        /**
+         * @return Object.
+         */
+        private Object wrappedCollection() {
+            if (col == null) {
+                position(valOff);
+
+                col = parseValue();
+            }
+
+            return col;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+            ctx.writeValue(writer, wrappedCollection());
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object value() {
+            return PortableUtils.unwrapLazy(wrappedCollection());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializationAware.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializationAware.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializationAware.java
new file mode 100644
index 0000000..976059a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializationAware.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ *
+ */
+interface PortableBuilderSerializationAware {
+    /**
+     * @param writer Writer.
+     * @param ctx Context.
+     */
+    public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java
new file mode 100644
index 0000000..2d9c961
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableObjectEx;
+import org.apache.ignite.internal.portable.PortableUtils;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.portable.*;
+
+import java.util.*;
+
+/**
+ *
+ */
+class PortableBuilderSerializer {
+    /** */
+    private final Map<PortableBuilderImpl, Integer> objToPos = new IdentityHashMap<>();
+
+    /** */
+    private Map<PortableObject, PortableBuilderImpl> portableObjToWrapper;
+
+    /**
+     * @param obj Mutable object.
+     * @param posInResArr Object position in the array.
+     */
+    public void registerObjectWriting(PortableBuilderImpl obj, int posInResArr) {
+        objToPos.put(obj, posInResArr);
+    }
+
+    /**
+     * @param writer Writer.
+     * @param val Value.
+     */
+    public void writeValue(PortableWriterExImpl writer, Object val) {
+        if (val == null) {
+            writer.writeByte(GridPortableMarshaller.NULL);
+
+            return;
+        }
+
+        if (val instanceof PortableBuilderSerializationAware) {
+            ((PortableBuilderSerializationAware)val).writeTo(writer, this);
+
+            return;
+        }
+
+        if (val instanceof PortableObjectEx) {
+            if (portableObjToWrapper == null)
+                portableObjToWrapper = new IdentityHashMap<>();
+
+            PortableBuilderImpl wrapper = portableObjToWrapper.get(val);
+
+            if (wrapper == null) {
+                wrapper = PortableBuilderImpl.wrap((PortableObject)val);
+
+                portableObjToWrapper.put((PortableObject)val, wrapper);
+            }
+
+            val = wrapper;
+        }
+
+        if (val instanceof PortableBuilderImpl) {
+            PortableBuilderImpl obj = (PortableBuilderImpl)val;
+
+            Integer posInResArr = objToPos.get(obj);
+
+            if (posInResArr == null) {
+                objToPos.put(obj, writer.outputStream().position());
+
+                obj.serializeTo(writer.newWriter(obj.typeId()), this);
+            }
+            else {
+                int handle = writer.outputStream().position() - posInResArr;
+
+                writer.writeByte(GridPortableMarshaller.HANDLE);
+                writer.writeInt(handle);
+            }
+
+            return;
+        }
+
+        if (val.getClass().isEnum()) {
+            writer.writeByte(GridPortableMarshaller.ENUM);
+            writer.writeInt(writer.context().typeId(val.getClass().getName()));
+            writer.writeInt(((Enum)val).ordinal());
+
+            return;
+        }
+
+        if (val instanceof Collection) {
+            Collection<?> c = (Collection<?>)val;
+
+            writer.writeByte(GridPortableMarshaller.COL);
+            writer.writeInt(c.size());
+
+            byte colType;
+
+            if (c instanceof GridConcurrentSkipListSet)
+                colType = GridPortableMarshaller.CONC_SKIP_LIST_SET;
+            else
+                colType = writer.context().collectionType(c.getClass());
+
+
+            writer.writeByte(colType);
+
+            for (Object obj : c)
+                writeValue(writer, obj);
+
+            return;
+        }
+
+        if (val instanceof Map) {
+            Map<?, ?> map = (Map<?, ?>)val;
+
+            writer.writeByte(GridPortableMarshaller.MAP);
+            writer.writeInt(map.size());
+
+            writer.writeByte(writer.context().mapType(map.getClass()));
+
+            for (Map.Entry<?, ?> entry : map.entrySet()) {
+                writeValue(writer, entry.getKey());
+                writeValue(writer, entry.getValue());
+            }
+
+            return;
+        }
+
+        Byte flag = PortableUtils.PLAIN_CLASS_TO_FLAG.get(val.getClass());
+
+        if (flag != null) {
+            PortableUtils.writePlainObject(writer, val);
+
+            return;
+        }
+
+        if (val instanceof Object[]) {
+            int compTypeId = writer.context().typeId(((Object[])val).getClass().getComponentType().getName());
+
+            if (val instanceof PortableBuilderEnum[]) {
+                writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, compTypeId);
+
+                return;
+            }
+
+            if (((Object[])val).getClass().getComponentType().isEnum()) {
+                Enum[] enumArr = (Enum[])val;
+
+                writer.writeByte(GridPortableMarshaller.ENUM_ARR);
+                writer.writeInt(compTypeId);
+                writer.writeInt(enumArr.length);
+
+                for (Enum anEnum : enumArr)
+                    writeValue(writer, anEnum);
+
+                return;
+            }
+
+            writeArray(writer, GridPortableMarshaller.OBJ_ARR, (Object[])val, compTypeId);
+
+            return;
+        }
+
+        writer.doWriteObject(val, false);
+    }
+
+    /**
+     * @param writer Writer.
+     * @param elementType Element type.
+     * @param arr The array.
+     * @param compTypeId Component type ID.
+     */
+    public void writeArray(PortableWriterExImpl writer, byte elementType, Object[] arr, int compTypeId) {
+        writer.writeByte(elementType);
+        writer.writeInt(compTypeId);
+        writer.writeInt(arr.length);
+
+        for (Object obj : arr)
+            writeValue(writer, obj);
+    }
+
+    /**
+     * @param writer Writer.
+     * @param elementType Element type.
+     * @param arr The array.
+     * @param clsName Component class name.
+     */
+    public void writeArray(PortableWriterExImpl writer, byte elementType, Object[] arr, String clsName) {
+        writer.writeByte(elementType);
+        writer.writeInt(GridPortableMarshaller.UNREGISTERED_TYPE_ID);
+        writer.writeString(clsName);
+        writer.writeInt(arr.length);
+
+        for (Object obj : arr)
+            writeValue(writer, obj);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java
new file mode 100644
index 0000000..d864a6e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableInvalidClassException;
+
+/**
+ *
+ */
+class PortableEnumArrayLazyValue extends PortableAbstractLazyValue {
+    /** */
+    private final int len;
+
+    /** */
+    private final int compTypeId;
+
+    /** */
+    private final String clsName;
+
+    /**
+     * @param reader Reader.
+     */
+    protected PortableEnumArrayLazyValue(PortableBuilderReader reader) {
+        super(reader, reader.position() - 1);
+
+        int typeId = reader.readInt();
+
+        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
+            clsName = reader.readString();
+
+            Class cls;
+
+            try {
+                // TODO: IGNITE-1272 - Is class loader needed here?
+                cls = U.forName(reader.readString(), null);
+            }
+            catch (ClassNotFoundException e) {
+                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
+            }
+
+            compTypeId = reader.portableContext().descriptorForClass(cls).typeId();
+        }
+        else {
+            compTypeId = typeId;
+            clsName = null;
+        }
+
+        int size = reader.readInt();
+
+        for (int i = 0; i < size; i++)
+            reader.skipValue();
+
+        len = reader.position() - valOff;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object init() {
+        reader.position(valOff + 1);
+
+        //skipping component type id
+        reader.readInt();
+
+        int size = reader.readInt();
+
+        PortableBuilderEnum[] res = new PortableBuilderEnum[size];
+
+        for (int i = 0; i < size; i++) {
+            byte flag = reader.readByte();
+
+            if (flag == GridPortableMarshaller.NULL)
+                continue;
+
+            if (flag != GridPortableMarshaller.ENUM)
+                throw new PortableException("Invalid flag value: " + flag);
+
+            res[i] = new PortableBuilderEnum(reader);
+        }
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (val != null) {
+            if (clsName != null)
+                ctx.writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, clsName);
+            else
+                ctx.writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, compTypeId);
+
+            return;
+        }
+
+        writer.write(reader.array(), valOff, len);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java
new file mode 100644
index 0000000..a08cfdd
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ *
+ */
+class PortableLazyArrayList extends AbstractList<Object> implements PortableBuilderSerializationAware {
+    /** */
+    private final PortableBuilderReader reader;
+
+    /** */
+    private final int off;
+
+    /** */
+    private List<Object> delegate;
+
+    /**
+     * @param reader Reader.
+     * @param size Size,
+     */
+    PortableLazyArrayList(PortableBuilderReader reader, int size) {
+        this.reader = reader;
+        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
+
+        assert size >= 0;
+
+        for (int i = 0; i < size; i++)
+            reader.skipValue();
+    }
+
+    /**
+     *
+     */
+    private void ensureDelegateInit() {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
+
+            delegate = new ArrayList<>(size);
+
+            for (int i = 0; i < size; i++)
+                delegate.add(reader.parseValue());
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object get(int idx) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.get(idx));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean add(Object o) {
+        ensureDelegateInit();
+
+        return delegate.add(o);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void add(int idx, Object element) {
+        ensureDelegateInit();
+
+        delegate.add(idx, element);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object set(int idx, Object element) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.set(idx, element));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object remove(int idx) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.remove(idx));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear() {
+        if (delegate == null)
+            delegate = new ArrayList<>();
+        else
+            delegate.clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean addAll(int idx, Collection<?> c) {
+        return delegate.addAll(idx, c);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void removeRange(int fromIdx, int toIdx) {
+        ensureDelegateInit();
+
+        delegate.subList(fromIdx, toIdx).clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        if (delegate == null)
+            return reader.readIntAbsolute(off + 1);
+
+        return delegate.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
+
+            writer.write(reader.array(), off, hdrSize);
+
+            reader.position(off + hdrSize);
+
+            for (int i = 0; i < size; i++) {
+                Object o = reader.parseValue();
+
+                ctx.writeValue(writer, o);
+            }
+        }
+        else {
+            writer.writeByte(GridPortableMarshaller.COL);
+            writer.writeInt(delegate.size());
+
+            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
+            writer.writeByte(colType);
+
+            int oldPos = reader.position();
+
+            for (Object o : delegate)
+                ctx.writeValue(writer, o);
+
+            // PortableBuilderImpl might have been written. It could override reader's position.
+            reader.position(oldPos);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java
new file mode 100644
index 0000000..f793d7a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+import java.util.AbstractList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ *
+ */
+class PortableLazyLinkedList extends AbstractList<Object> implements PortableBuilderSerializationAware {
+    /** */
+    private final PortableBuilderReader reader;
+
+    /** */
+    private final int off;
+
+    /** */
+    private List<Object> delegate;
+
+    /**
+     * @param reader Reader.
+     * @param size Size,
+     */
+    PortableLazyLinkedList(PortableBuilderReader reader, int size) {
+        this.reader = reader;
+        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
+
+        assert size >= 0;
+
+        for (int i = 0; i < size; i++)
+            reader.skipValue();
+    }
+
+    /**
+     *
+     */
+    private void ensureDelegateInit() {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
+
+            delegate = new LinkedList<>();
+
+            for (int i = 0; i < size; i++)
+                delegate.add(reader.parseValue());
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object get(int idx) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.get(idx));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean add(Object o) {
+        ensureDelegateInit();
+
+        return delegate.add(o);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void add(int idx, Object element) {
+        ensureDelegateInit();
+
+        delegate.add(idx, element);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object set(int idx, Object element) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.set(idx, element));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object remove(int idx) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.remove(idx));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear() {
+        if (delegate == null)
+            delegate = new LinkedList<>();
+        else
+            delegate.clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean addAll(int idx, Collection<?> c) {
+        ensureDelegateInit();
+
+        return delegate.addAll(idx, c);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void removeRange(int fromIdx, int toIdx) {
+        ensureDelegateInit();
+
+        delegate.subList(fromIdx, toIdx).clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        if (delegate == null)
+            return reader.readIntAbsolute(off + 1);
+
+        return delegate.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public ListIterator<Object> listIterator(final int idx) {
+        ensureDelegateInit();
+
+        return new ListIterator<Object>() {
+            /** */
+            private final ListIterator<Object> delegate = PortableLazyLinkedList.super.listIterator(idx);
+
+            @Override public boolean hasNext() {
+                return delegate.hasNext();
+            }
+
+            @Override public Object next() {
+                return PortableUtils.unwrapLazy(delegate.next());
+            }
+
+            @Override public boolean hasPrevious() {
+                return delegate.hasPrevious();
+            }
+
+            @Override public Object previous() {
+                return PortableUtils.unwrapLazy(delegate.previous());
+            }
+
+            @Override public int nextIndex() {
+                return delegate.nextIndex();
+            }
+
+            @Override public int previousIndex() {
+                return delegate.previousIndex();
+            }
+
+            @Override public void remove() {
+                delegate.remove();
+            }
+
+            @Override public void set(Object o) {
+                delegate.set(o);
+            }
+
+            @Override public void add(Object o) {
+                delegate.add(o);
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterator<Object> iterator() {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazyIterator(super.iterator());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
+            writer.write(reader.array(), off, hdrSize);
+
+            reader.position(off + hdrSize);
+
+            for (int i = 0; i < size; i++) {
+                Object o = reader.parseValue();
+
+                ctx.writeValue(writer, o);
+            }
+        }
+        else {
+            writer.writeByte(GridPortableMarshaller.COL);
+            writer.writeInt(delegate.size());
+
+            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
+            writer.writeByte(colType);
+
+            for (Object o : delegate)
+                ctx.writeValue(writer, o);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java
new file mode 100644
index 0000000..12cbfd6
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ *
+ */
+class PortableLazyMap extends AbstractMap<Object, Object> implements PortableBuilderSerializationAware {
+    /** */
+    private final PortableBuilderReader reader;
+
+    /** */
+    private final int off;
+
+    /** */
+    private Map<Object, Object> delegate;
+
+    /**
+     * @param reader Reader.
+     * @param off Offset.
+     */
+    private PortableLazyMap(PortableBuilderReader reader, int off) {
+        this.reader = reader;
+        this.off = off;
+    }
+
+    /**
+     * @param reader Reader.
+     * @return PortableLazyMap.
+     */
+    @Nullable public static PortableLazyMap parseMap(PortableBuilderReader reader) {
+        int off = reader.position() - 1;
+
+        int size = reader.readInt();
+
+        reader.skip(1); // map type.
+
+        for (int i = 0; i < size; i++) {
+            reader.skipValue(); // skip key
+            reader.skipValue(); // skip value
+        }
+
+        return new PortableLazyMap(reader, off);
+    }
+
+    /**
+     *
+     */
+    private void ensureDelegateInit() {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
+
+            delegate = new LinkedHashMap<>();
+
+            for (int i = 0; i < size; i++)
+                delegate.put(PortableUtils.unwrapLazy(reader.parseValue()), reader.parseValue());
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
+            writer.write(reader.array(), off, hdrSize);
+
+            reader.position(off + hdrSize);
+
+            for (int i = 0; i < size; i++) {
+                ctx.writeValue(writer, reader.parseValue()); // key
+                ctx.writeValue(writer, reader.parseValue()); // value
+            }
+        }
+        else {
+            writer.writeByte(GridPortableMarshaller.MAP);
+            writer.writeInt(delegate.size());
+
+            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
+
+            writer.writeByte(colType);
+
+            for (Entry<Object, Object> entry : delegate.entrySet()) {
+                ctx.writeValue(writer, entry.getKey());
+                ctx.writeValue(writer, entry.getValue());
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        if (delegate == null)
+            return reader.readIntAbsolute(off + 1);
+
+        return delegate.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean containsKey(Object key) {
+        ensureDelegateInit();
+
+        return delegate.containsKey(key);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean containsValue(Object val) {
+        return values().contains(val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Set<Object> keySet() {
+        ensureDelegateInit();
+
+        return delegate.keySet();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear() {
+        if (delegate == null)
+            delegate = new LinkedHashMap<>();
+        else
+            delegate.clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object get(Object key) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.get(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object put(Object key, Object val) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.put(key, val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object remove(Object key) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.remove(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Set<Entry<Object, Object>> entrySet() {
+        ensureDelegateInit();
+
+        return new AbstractSet<Entry<Object, Object>>() {
+            @Override public boolean contains(Object o) {
+                throw new UnsupportedOperationException();
+            }
+
+            @Override public Iterator<Entry<Object, Object>> iterator() {
+                return new Iterator<Entry<Object, Object>>() {
+                    /** */
+                    private final Iterator<Entry<Object, Object>> itr = delegate.entrySet().iterator();
+
+                    @Override public boolean hasNext() {
+                        return itr.hasNext();
+                    }
+
+                    @Override public Entry<Object, Object> next() {
+                        Entry<Object, Object> res = itr.next();
+
+                        final Object val = res.getValue();
+
+                        if (val instanceof PortableLazyValue) {
+                            return new SimpleEntry<Object, Object>(res.getKey(), val) {
+                                private static final long serialVersionUID = 0L;
+
+                                @Override public Object getValue() {
+                                    return ((PortableLazyValue)val).value();
+                                }
+                            };
+                        }
+
+                        return res;
+                    }
+
+                    @Override public void remove() {
+                        itr.remove();
+                    }
+                };
+            }
+
+            @Override public int size() {
+                return delegate.size();
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java
new file mode 100644
index 0000000..bd027f5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+import java.util.Map;
+
+/**
+ *
+ */
+class PortableLazyMapEntry implements Map.Entry<Object, Object>, PortableBuilderSerializationAware {
+    /** */
+    private final Object key;
+
+    /** */
+    private Object val;
+
+    /**
+     * @param reader GridMutablePortableReader
+     */
+    PortableLazyMapEntry(PortableBuilderReader reader) {
+        key = reader.parseValue();
+        val = reader.parseValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object getKey() {
+        return PortableUtils.unwrapLazy(key);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object getValue() {
+        return PortableUtils.unwrapLazy(val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object setValue(Object val) {
+        Object res = getValue();
+
+        this.val = val;
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        writer.writeByte(GridPortableMarshaller.MAP_ENTRY);
+
+        ctx.writeValue(writer, key);
+        ctx.writeValue(writer, val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java
new file mode 100644
index 0000000..16772af
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import java.util.Collection;
+import java.util.Set;
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableUtils;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+/**
+ *
+ */
+class PortableLazySet extends PortableAbstractLazyValue {
+    /** */
+    private final int off;
+
+    /**
+     * @param reader Reader.
+     * @param size Size.
+     */
+    PortableLazySet(PortableBuilderReader reader, int size) {
+        super(reader, reader.position() - 1);
+
+        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
+
+        assert size >= 0;
+
+        for (int i = 0; i < size; i++)
+            reader.skipValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (val == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
+            writer.write(reader.array(), off, hdrSize);
+
+            reader.position(off + hdrSize);
+
+            for (int i = 0; i < size; i++) {
+                Object o = reader.parseValue();
+
+                ctx.writeValue(writer, o);
+            }
+        }
+        else {
+            Collection<Object> c = (Collection<Object>)val;
+
+            writer.writeByte(GridPortableMarshaller.COL);
+            writer.writeInt(c.size());
+
+            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
+            writer.writeByte(colType);
+
+            for (Object o : c)
+                ctx.writeValue(writer, o);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object init() {
+        int size = reader.readIntAbsolute(off + 1);
+
+        reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
+
+        Set<Object> res = U.newLinkedHashSet(size);
+
+        for (int i = 0; i < size; i++)
+            res.add(PortableUtils.unwrapLazy(reader.parseValue()));
+
+        return res;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyValue.java
new file mode 100644
index 0000000..5d8d586
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyValue.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+/**
+ *
+ */
+public interface PortableLazyValue extends PortableBuilderSerializationAware {
+    /**
+     * @return Value.
+     */
+    public Object value();
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableModifiableLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableModifiableLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableModifiableLazyValue.java
new file mode 100644
index 0000000..09fb844
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableModifiableLazyValue.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ *
+ */
+public class PortableModifiableLazyValue extends PortableAbstractLazyValue {
+    /** */
+    protected final int len;
+
+    /**
+     * @param reader
+     * @param valOff
+     * @param len
+     */
+    public PortableModifiableLazyValue(PortableBuilderReader reader, int valOff, int len) {
+        super(reader, valOff);
+
+        this.len = len;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object init() {
+        return reader.reader().unmarshal(valOff);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (val == null)
+            writer.write(reader.array(), valOff, len);
+        else
+            writer.writeObject(val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java
new file mode 100644
index 0000000..1126a3c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.portable.PortableInvalidClassException;
+
+/**
+ *
+ */
+class PortableObjectArrayLazyValue extends PortableAbstractLazyValue {
+    /** */
+    private Object[] lazyValsArr;
+
+    /** */
+    private int compTypeId;
+
+    /** */
+    private String clsName;
+
+    /**
+     * @param reader Reader.
+     */
+    protected PortableObjectArrayLazyValue(PortableBuilderReader reader) {
+        super(reader, reader.position() - 1);
+
+        int typeId = reader.readInt();
+
+        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
+            clsName = reader.readString();
+
+            Class cls;
+
+            try {
+                // TODO: IGNITE-1272 - Is class loader needed here?
+                cls = U.forName(reader.readString(), null);
+            }
+            catch (ClassNotFoundException e) {
+                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
+            }
+
+            compTypeId = reader.portableContext().descriptorForClass(cls).typeId();
+        }
+        else {
+            compTypeId = typeId;
+            clsName = null;
+        }
+
+        int size = reader.readInt();
+
+        lazyValsArr = new Object[size];
+
+        for (int i = 0; i < size; i++)
+            lazyValsArr[i] = reader.parseValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object init() {
+        for (int i = 0; i < lazyValsArr.length; i++) {
+            if (lazyValsArr[i] instanceof PortableLazyValue)
+                lazyValsArr[i] = ((PortableLazyValue)lazyValsArr[i]).value();
+        }
+
+        return lazyValsArr;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (clsName == null)
+            ctx.writeArray(writer, GridPortableMarshaller.OBJ_ARR, lazyValsArr, compTypeId);
+        else
+            ctx.writeArray(writer, GridPortableMarshaller.OBJ_ARR, lazyValsArr, clsName);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainLazyValue.java
new file mode 100644
index 0000000..136958a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainLazyValue.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ *
+ */
+class PortablePlainLazyValue extends PortableAbstractLazyValue {
+    /** */
+    protected final int len;
+
+    /**
+     * @param reader Reader
+     * @param valOff Offset
+     * @param len Length.
+     */
+    protected PortablePlainLazyValue(PortableBuilderReader reader, int valOff, int len) {
+        super(reader, valOff);
+
+        this.len = len;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object init() {
+        return reader.reader().unmarshal(valOff);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        writer.write(reader.array(), valOff, len);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java
new file mode 100644
index 0000000..8743fbe
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.PortableObjectImpl;
+import org.apache.ignite.internal.portable.PortableObjectOffheapImpl;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.portable.PortableObject;
+
+/**
+ *
+ */
+public class PortablePlainPortableObject implements PortableLazyValue {
+    /** */
+    private final PortableObject portableObj;
+
+    /**
+     * @param portableObj Portable object.
+     */
+    public PortablePlainPortableObject(PortableObject portableObj) {
+        this.portableObj = portableObj;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object value() {
+        return portableObj;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        PortableObject val = portableObj;
+
+        if (val instanceof PortableObjectOffheapImpl)
+            val = ((PortableObjectOffheapImpl)val).heapCopy();
+
+        writer.doWritePortableObject((PortableObjectImpl)val);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java
new file mode 100644
index 0000000..2e031f0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ *
+ */
+class PortableValueWithType implements PortableLazyValue {
+    /** */
+    private byte type;
+
+    /** */
+    private Object val;
+
+    /**
+     * @param type Type
+     * @param val Value.
+     */
+    PortableValueWithType(byte type, Object val) {
+        this.type = type;
+        this.val = val;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (val instanceof PortableBuilderSerializationAware)
+            ((PortableBuilderSerializationAware)val).writeTo(writer, ctx);
+        else
+            ctx.writeValue(writer, val);
+    }
+
+    /** {@inheritDoc} */
+    public String typeName() {
+        return CacheObjectPortableProcessorImpl.fieldTypeName(type);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object value() {
+        if (val instanceof PortableLazyValue)
+            return ((PortableLazyValue)val).value();
+
+        return val;
+    }
+
+    /**
+     * @param val New value.
+     */
+    public void value(Object val) {
+        this.val = val;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(PortableValueWithType.class, this);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/package-info.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/package-info.java
new file mode 100644
index 0000000..e069f3e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains classes specific to portable builder API.
+ */
+package org.apache.ignite.internal.portable.builder;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
index b33c643..1be5aea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
@@ -45,13 +45,13 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.portable.GridPortableMarshaller;
-import org.apache.ignite.internal.portable.PortableBuilderImpl;
 import org.apache.ignite.internal.portable.PortableContext;
 import org.apache.ignite.internal.portable.PortableMetaDataHandler;
 import org.apache.ignite.internal.portable.PortableMetaDataImpl;
 import org.apache.ignite.internal.portable.PortableObjectImpl;
 import org.apache.ignite.internal.portable.PortableObjectOffheapImpl;
 import org.apache.ignite.internal.portable.PortableUtils;
+import org.apache.ignite.internal.portable.builder.PortableBuilderImpl;
 import org.apache.ignite.internal.portable.streams.PortableInputStream;
 import org.apache.ignite.internal.portable.streams.PortableOffheapInputStream;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index d80cc49..dd8c3f3 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -281,7 +281,7 @@ org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager$1
 org.apache.ignite.internal.processors.platform.PlatformAwareEventFilter
 org.apache.ignite.internal.portable.PortableClassDescriptor$Mode
 org.apache.ignite.internal.portable.PortableContext
-org.apache.ignite.internal.portable.PortableLazyMap$1$1$1
+org.apache.ignite.internal.portable.builder.PortableLazyMap$1$1$1
 org.apache.ignite.internal.portable.PortableMetaDataImpl
 org.apache.ignite.internal.portable.PortableObjectEx
 org.apache.ignite.internal.portable.PortableObjectImpl


[16/50] [abbrv] ignite git commit: Merge remote-tracking branch 'origin/ignite-1.4' into ignite-1.4

Posted by ak...@apache.org.
Merge remote-tracking branch 'origin/ignite-1.4' into ignite-1.4


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

Branch: refs/heads/ignite-843
Commit: 662bc331ce6e26b72809901bdd6edd64364814f9
Parents: 3de5f98 0b9d7ca
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 3 11:40:07 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 3 11:40:07 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    | 97 ++++++++++++++------
 1 file changed, 69 insertions(+), 28 deletions(-)
----------------------------------------------------------------------



[09/50] [abbrv] ignite git commit: ignite-1273: added ability to modify arrays returned from PortableBuilder and fixed cyclic references processing for arrays and collections in PortableMarshaller

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
index 488361c..61ec714 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
@@ -22,6 +22,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import java.lang.reflect.Field;
+import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -38,6 +39,8 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgnitePortables;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.builder.PortableBuilderEnum;
+import org.apache.ignite.internal.portable.builder.PortableBuilderImpl;
 import org.apache.ignite.internal.portable.mutabletest.GridPortableMarshalerAwareTestClass;
 import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
 import org.apache.ignite.internal.processors.cache.portable.IgnitePortablesImpl;
@@ -237,10 +240,214 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
     /**
      *
      */
-    public void testSimpleArrayModification() {
+    public void testDateArrayModification() {
         TestObjectAllTypes obj = new TestObjectAllTypes();
 
-        obj.strArr = new String[]{"a", "a", "a"};
+        obj.dateArr =  new Date[] {new Date(11111), new Date(11111), new Date(11111)};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        Date[] arr = mutObj.getField("dateArr");
+        arr[0] = new Date(22222);
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new Date[] {new Date(22222), new Date(11111), new Date(11111)}, res.dateArr);
+    }
+
+    /**
+     *
+     */
+    public void testUUIDArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.uuidArr = new UUID[] {new UUID(1, 1), new UUID(1, 1), new UUID(1, 1)};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        UUID[] arr = mutObj.getField("uuidArr");
+        arr[0] = new UUID(2, 2);
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new UUID[] {new UUID(2, 2), new UUID(1, 1), new UUID(1, 1)}, res.uuidArr);
+    }
+
+    /**
+     *
+     */
+    public void testDecimalArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.bdArr = new BigDecimal[] {new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000)};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        BigDecimal[] arr = mutObj.getField("bdArr");
+        arr[0] = new BigDecimal(2000);
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new BigDecimal[] {new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000)},
+            res.bdArr);
+    }
+
+    /**
+     *
+     */
+    public void testBooleanArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.zArr = new boolean[] {false, false, false};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        boolean[] arr = mutObj.getField("zArr");
+        arr[0] = true;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        boolean[] expected = new boolean[] {true, false, false};
+
+        assertEquals(expected.length, res.zArr.length);
+
+        for (int i = 0; i < expected.length; i++)
+            assertEquals(expected[i], res.zArr[i]);
+    }
+
+    /**
+     *
+     */
+    public void testCharArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.cArr = new char[] {'a', 'a', 'a'};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        char[] arr = mutObj.getField("cArr");
+        arr[0] = 'b';
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new char[] {'b', 'a', 'a'}, res.cArr);
+    }
+
+    /**
+     *
+     */
+    public void testDoubleArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.dArr = new double[] {1.0, 1.0, 1.0};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        double[] arr = mutObj.getField("dArr");
+        arr[0] = 2.0;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new double[] {2.0, 1.0, 1.0}, res.dArr, 0);
+    }
+
+    /**
+     *
+     */
+    public void testFloatArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.fArr = new float[] {1.0f, 1.0f, 1.0f};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        float[] arr = mutObj.getField("fArr");
+        arr[0] = 2.0f;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new float[] {2.0f, 1.0f, 1.0f}, res.fArr, 0);
+    }
+
+    /**
+     *
+     */
+    public void testLongArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.lArr = new long[] {1, 1, 1};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        long[] arr = mutObj.getField("lArr");
+        arr[0] = 2;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new long[] {2, 1, 1}, res.lArr);
+    }
+
+    /**
+     *
+     */
+    public void testIntArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.iArr = new int[] {1, 1, 1};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        int[] arr = mutObj.getField("iArr");
+        arr[0] = 2;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new int[] {2, 1, 1}, res.iArr);
+    }
+
+    /**
+     *
+     */
+    public void testShortArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.sArr = new short[] {1, 1, 1};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        short[] arr = mutObj.getField("sArr");
+        arr[0] = 2;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new short[] {2, 1, 1}, res.sArr);
+    }
+
+    /**
+     *
+     */
+    public void testByteArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.bArr = new byte[] {1, 1, 1};
+
+        PortableBuilderImpl mutObj = wrap(obj);
+
+        byte[] arr = mutObj.getField("bArr");
+        arr[0] = 2;
+
+        TestObjectAllTypes res = mutObj.build().deserialize();
+
+        Assert.assertArrayEquals(new byte[] {2, 1, 1}, res.bArr);
+    }
+
+    /**
+     *
+     */
+    public void testStringArrayModification() {
+        TestObjectAllTypes obj = new TestObjectAllTypes();
+
+        obj.strArr = new String[] {"a", "a", "a"};
 
         PortableBuilderImpl mutObj = wrap(obj);
 
@@ -249,29 +456,27 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
 
         TestObjectAllTypes res = mutObj.build().deserialize();
 
-        Assert.assertArrayEquals(obj.strArr, res.strArr);
+        Assert.assertArrayEquals(new String[] {"b", "a", "a"}, res.strArr);
     }
 
     /**
      *
      */
     public void testModifyObjectArray() {
-        fail("https://issues.apache.org/jira/browse/IGNITE-1273");
-
         TestObjectContainer obj = new TestObjectContainer();
-        obj.foo = new Object[]{"a"};
+        obj.foo = new Object[] {"a"};
 
         PortableBuilderImpl mutObj = wrap(obj);
 
         Object[] arr = mutObj.getField("foo");
 
-        Assert.assertArrayEquals(new Object[]{"a"}, arr);
+        Assert.assertArrayEquals(new Object[] {"a"}, arr);
 
         arr[0] = "b";
 
         TestObjectContainer res = mutObj.build().deserialize();
 
-        Assert.assertArrayEquals(new Object[] {"a"}, (Object[])res.foo);
+        Assert.assertArrayEquals(new Object[] {"b"}, (Object[])res.foo);
     }
 
     /**
@@ -280,7 +485,7 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
     public void testOverrideObjectArrayField() {
         PortableBuilderImpl mutObj = wrap(new TestObjectContainer());
 
-        Object[] createdArr = {mutObj, "a", 1, new String[] {"s", "s"}, new byte[]{1, 2}, new UUID(3, 0)};
+        Object[] createdArr = {mutObj, "a", 1, new String[] {"s", "s"}, new byte[] {1, 2}, new UUID(3, 0)};
 
         mutObj.setField("foo", createdArr.clone());
 
@@ -296,7 +501,7 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
      */
     public void testDeepArray() {
         TestObjectContainer obj = new TestObjectContainer();
-        obj.foo = new Object[]{new Object[]{"a", obj}};
+        obj.foo = new Object[] {new Object[] {"a", obj}};
 
         PortableBuilderImpl mutObj = wrap(obj);
 
@@ -633,7 +838,7 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
     public void testEnumArrayModification() {
         TestObjectAllTypes obj = new TestObjectAllTypes();
 
-        obj.enumArr = new TestObjectEnum[]{TestObjectEnum.A, TestObjectEnum.B};
+        obj.enumArr = new TestObjectEnum[] {TestObjectEnum.A, TestObjectEnum.B};
 
         PortableBuilderImpl mutObj = wrap(obj);
 
@@ -953,12 +1158,10 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
      *
      */
     public void testCyclicArrays() {
-        fail("https://issues.apache.org/jira/browse/IGNITE-1273");
-
         TestObjectContainer obj = new TestObjectContainer();
 
         Object[] arr1 = new Object[1];
-        Object[] arr2 = new Object[]{arr1};
+        Object[] arr2 = new Object[] {arr1};
 
         arr1[0] = arr2;
 
@@ -976,7 +1179,6 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
      */
     @SuppressWarnings("TypeMayBeWeakened")
     public void testCyclicArrayList() {
-        fail("https://issues.apache.org/jira/browse/IGNITE-1273");
         TestObjectContainer obj = new TestObjectContainer();
 
         List<Object> arr1 = new ArrayList<>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
index 3ba0a92..7f23c1f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
@@ -28,6 +28,7 @@ import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgnitePortables;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.builder.PortableBuilderImpl;
 import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes;
 import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectContainer;
 import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectInner;

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
index 11e316a..c8287a0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
@@ -40,6 +40,7 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListSet;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.portable.builder.PortableBuilderImpl;
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.lang.GridMapEntry;
@@ -68,6 +69,7 @@ import sun.misc.Unsafe;
 
 import static org.apache.ignite.internal.portable.PortableThreadLocalMemoryAllocator.THREAD_LOCAL_ALLOC;
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Portable marshaller tests.
@@ -1547,11 +1549,11 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
 
         PortableObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[]{1, 2, 3}));
 
-        assertArrayEquals(new byte[]{1, 2, 3}, copy.<byte[]>field("bArr"));
+        assertArrayEquals(new byte[] {1, 2, 3}, copy.<byte[]>field("bArr"));
 
         SimpleObject obj0 = copy.deserialize();
 
-        assertArrayEquals(new byte[]{1, 2, 3}, obj0.bArr);
+        assertArrayEquals(new byte[] {1, 2, 3}, obj0.bArr);
     }
 
     /**
@@ -1796,7 +1798,7 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
 
         assertEquals("str555", obj0.str);
         assertEquals(newObj, obj0.inner);
-        assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
+        assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
     }
 
     /**
@@ -1832,7 +1834,7 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         assertEquals("str555", copy.<String>field("str"));
         assertEquals(newObj, copy.<PortableObject>field("inner").deserialize());
         assertEquals((short)2323, copy.<Short>field("s").shortValue());
-        assertArrayEquals(new byte[]{6, 7, 9}, copy.<byte[]>field("bArr"));
+        assertArrayEquals(new byte[] {6, 7, 9}, copy.<byte[]>field("bArr"));
         assertEquals((byte)111, copy.<Byte>field("b").byteValue());
 
         SimpleObject obj0 = copy.deserialize();
@@ -1841,7 +1843,7 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         assertEquals("str555", obj0.str);
         assertEquals(newObj, obj0.inner);
         assertEquals((short)2323, obj0.s);
-        assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
+        assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
         assertEquals((byte)111, obj0.b);
     }
 
@@ -2239,6 +2241,53 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testCyclicReferencesMarshalling() throws Exception {
+        PortableMarshaller marsh = new PortableMarshaller();
+
+        SimpleObject obj = simpleObject();
+
+        obj.bArr = obj.inner.bArr;
+        obj.cArr = obj.inner.cArr;
+        obj.boolArr = obj.inner.boolArr;
+        obj.sArr = obj.inner.sArr;
+        obj.strArr = obj.inner.strArr;
+        obj.iArr = obj.inner.iArr;
+        obj.lArr = obj.inner.lArr;
+        obj.fArr = obj.inner.fArr;
+        obj.dArr = obj.inner.dArr;
+        obj.dateArr = obj.inner.dateArr;
+        obj.uuidArr = obj.inner.uuidArr;
+        obj.objArr = obj.inner.objArr;
+        obj.bdArr = obj.inner.bdArr;
+        obj.map = obj.inner.map;
+        obj.col = obj.inner.col;
+        obj.mEntry = obj.inner.mEntry;
+
+        SimpleObject res = (SimpleObject)marshalUnmarshal(obj, marsh);
+
+        assertEquals(obj, res);
+
+        assertTrue(res.bArr == res.inner.bArr);
+        assertTrue(res.cArr == res.inner.cArr);
+        assertTrue(res.boolArr == res.inner.boolArr);
+        assertTrue(res.sArr == res.inner.sArr);
+        assertTrue(res.strArr == res.inner.strArr);
+        assertTrue(res.iArr == res.inner.iArr);
+        assertTrue(res.lArr == res.inner.lArr);
+        assertTrue(res.fArr == res.inner.fArr);
+        assertTrue(res.dArr == res.inner.dArr);
+        assertTrue(res.dateArr == res.inner.dateArr);
+        assertTrue(res.uuidArr == res.inner.uuidArr);
+        assertTrue(res.objArr == res.inner.objArr);
+        assertTrue(res.bdArr == res.inner.bdArr);
+        assertTrue(res.map == res.inner.map);
+        assertTrue(res.col == res.inner.col);
+        assertTrue(res.mEntry == res.inner.mEntry);
+    }
+
+    /**
      *
      */
     private static class ObjectWithClassFields {
@@ -2424,6 +2473,7 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         inner.map = new HashMap<>();
         inner.enumVal = TestEnum.A;
         inner.enumArr = new TestEnum[] {TestEnum.A, TestEnum.B};
+        inner.bdArr = new BigDecimal[] {new BigDecimal(1000), BigDecimal.ONE};
 
         inner.col.add("str1");
         inner.col.add("str2");
@@ -2433,6 +2483,8 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         inner.map.put(2, "str2");
         inner.map.put(3, "str3");
 
+        inner.mEntry = inner.map.entrySet().iterator().next();
+
         SimpleObject outer = new SimpleObject();
 
         outer.b = 2;
@@ -2464,6 +2516,8 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         outer.enumVal = TestEnum.B;
         outer.enumArr = new TestEnum[] {TestEnum.B, TestEnum.C};
         outer.inner = inner;
+        outer.bdArr = new BigDecimal[] {new BigDecimal(5000), BigDecimal.TEN};
+
 
         outer.col.add("str4");
         outer.col.add("str5");
@@ -2473,6 +2527,8 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         outer.map.put(5, "str5");
         outer.map.put(6, "str6");
 
+        outer.mEntry = outer.map.entrySet().iterator().next();
+
         return outer;
     }
 
@@ -2757,6 +2813,9 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         private Object[] objArr;
 
         /** */
+        private BigDecimal[] bdArr;
+
+        /** */
         private Collection<String> col;
 
         /** */
@@ -2769,6 +2828,9 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
         private TestEnum[] enumArr;
 
         /** */
+        private Map.Entry<Integer, String> mEntry;
+
+        /** */
         private SimpleObject inner;
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
index d329818..05df23b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
@@ -20,6 +20,7 @@ import java.util.Arrays;
 import org.apache.ignite.IgnitePortables;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.portable.PortableBuilder;
 import org.apache.ignite.portable.PortableException;
 import org.apache.ignite.portable.PortableMarshalAware;
 import org.apache.ignite.portable.PortableReader;
@@ -68,9 +69,17 @@ public class GridPortableMetaDataDisabledSelfTest extends GridCommonAbstractTest
 
             portables().toPortable(new TestObject1());
             portables().toPortable(new TestObject2());
+            portables().toPortable(new TestObject3());
 
             assertEquals(0, portables().metadata(TestObject1.class).fields().size());
             assertEquals(0, portables().metadata(TestObject2.class).fields().size());
+
+            PortableBuilder bldr = portables().builder("FakeType");
+
+            bldr.setField("field1", 0).setField("field2", "value").build();
+
+            assertNull(portables().metadata("FakeType"));
+            assertNull(portables().metadata(TestObject3.class));
         }
         finally {
             stopGrid();
@@ -218,4 +227,12 @@ public class GridPortableMetaDataDisabledSelfTest extends GridCommonAbstractTest
             // No-op.
         }
     }
+
+    /**
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class TestObject3 {
+        /** */
+        private int field;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
index f6d7627..9054297 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
@@ -147,6 +147,15 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testNoConfiguration() throws Exception {
+        portables().toPortable(new TestObject3());
+
+        assertNotNull(portables().metadata(TestObject3.class));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testReflection() throws Exception {
         PortableMetadata meta = portables().metadata(TestObject1.class);
 
@@ -349,4 +358,12 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
             // No-op.
         }
     }
+
+    /**
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class TestObject3 {
+        /** */
+        private int intVal;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
index ce97a8d..e49514b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.ObjectOutput;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -182,7 +183,6 @@ public class GridPortableTestClasses {
         /** */
         public Date date;
 
-
         /** */
         public byte[] bArr;
 
@@ -208,12 +208,18 @@ public class GridPortableTestClasses {
         public boolean[] zArr;
 
         /** */
+        public BigDecimal[] bdArr;
+
+        /** */
         public String[] strArr;
 
         /** */
         public UUID[] uuidArr;
 
         /** */
+        public Date[] dateArr;
+
+        /** */
         public TestObjectEnum anEnum;
 
         /** */
@@ -222,8 +228,6 @@ public class GridPortableTestClasses {
         /** */
         public Map.Entry entry;
 
-        //public Date[] dateArr; // todo test date array.
-
         /**
          * @return Array.
          */
@@ -270,21 +274,23 @@ public class GridPortableTestClasses {
             uuid = new UUID(1, 1);
             date = new Date(1000000);
 
-            bArr = new byte[]{1, 2, 3};
-            sArr = new short[]{1, 2, 3};
-            iArr = new int[]{1, 2, 3};
-            lArr = new long[]{1, 2, 3};
-            fArr = new float[]{1, 2, 3};
-            dArr = new double[]{1, 2, 3};
-            cArr = new char[]{1, 2, 3};
-            zArr = new boolean[]{true, false};
+            bArr = new byte[] {1, 2, 3};
+            sArr = new short[] {1, 2, 3};
+            iArr = new int[] {1, 2, 3};
+            lArr = new long[] {1, 2, 3};
+            fArr = new float[] {1, 2, 3};
+            dArr = new double[] {1, 2, 3};
+            cArr = new char[] {1, 2, 3};
+            zArr = new boolean[] {true, false};
 
-            strArr = new String[]{"abc", "ab", "a"};
-            uuidArr = new UUID[]{new UUID(1, 1), new UUID(2, 2)};
+            strArr = new String[] {"abc", "ab", "a"};
+            uuidArr = new UUID[] {new UUID(1, 1), new UUID(2, 2)};
+            bdArr = new BigDecimal[] {new BigDecimal(1000), BigDecimal.TEN};
+            dateArr = new Date[] {new Date(1000000), new Date(200000)};
 
             anEnum = TestObjectEnum.A;
 
-            enumArr = new TestObjectEnum[]{TestObjectEnum.B};
+            enumArr = new TestObjectEnum[] {TestObjectEnum.B};
 
             entry = new GridMapEntry<>(1, "a");
         }
@@ -388,7 +394,6 @@ public class GridPortableTestClasses {
         private Map<String, List<Company>> companyByStreet = new TreeMap<>();
 
         /**
-         *
          * @param street Street.
          * @return Company.
          */
@@ -397,7 +402,6 @@ public class GridPortableTestClasses {
         }
 
         /**
-         *
          * @param company Company.
          */
         public void addCompany(Company company) {
@@ -413,7 +417,6 @@ public class GridPortableTestClasses {
         }
 
         /**
-         *
          * @return map
          */
         public Map<String, List<Company>> getCompanyByStreet() {
@@ -421,7 +424,6 @@ public class GridPortableTestClasses {
         }
 
         /**
-         *
          * @param companyByStreet map
          */
         public void setCompanyByStreet(Map<String, List<Company>> companyByStreet) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
index aa67574..1ba3d4d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
@@ -31,6 +31,7 @@ import org.apache.ignite.IgnitePortables;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.portable.PortableMarshaller;
 import org.apache.ignite.portable.PortableBuilder;
@@ -233,6 +234,16 @@ public class GridCacheClientNodePortableMetadataMultinodeTest extends GridCommon
 
             portables = ignite(i).portables();
 
+            final IgnitePortables p0 = portables;
+
+            GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                @Override public boolean apply() {
+                    Collection<PortableMetadata> metaCol = p0.metadata();
+
+                    return metaCol.size() == 1000;
+                }
+            }, getTestTimeout());
+
             Collection<PortableMetadata> metaCol = portables.metadata();
 
             assertEquals(1000, metaCol.size());


[46/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_raw_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_raw_test.cpp b/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_raw_test.cpp
new file mode 100644
index 0000000..c3a98aa
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_raw_test.cpp
@@ -0,0 +1,1532 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/portable/portable.h"
+
+#include "ignite/portable_test_defs.h"
+#include "ignite/portable_test_utils.h"
+
+using namespace ignite;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+using namespace ignite::portable;
+using namespace ignite_test::core::portable;
+
+template<typename T>
+void CheckRawPrimitive(T val)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    Write<T>(rawWriter, val);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    T readVal = Read<T>(rawReader);
+    
+    BOOST_REQUIRE(readVal == val);
+}
+
+template<typename T>
+void CheckRawPrimitiveArray(T dflt, T val1, T val2)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+    
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    // 1. Write NULL and see what happens.
+    WriteArray<T>(rawWriter, NULL, 0);
+
+    out.Synchronize();
+    in.Synchronize();
+    
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == -1);
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == -1);
+
+    T arr1[2];
+    arr1[0] = dflt;
+    arr1[1] = dflt;
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == -1);
+
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    // 2. Write empty array.
+    T arr2[2];
+    arr2[0] = val1;
+    arr2[1] = val2;
+
+    out.Position(0);
+    in.Position(0);
+
+    WriteArray<T>(rawWriter, arr2, 0);
+
+    out.Synchronize();
+    in.Synchronize();
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 0);
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 0);
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 0);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 0);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    // 3. Partial array write.
+    out.Position(0);
+    in.Position(0);
+
+    WriteArray<T>(rawWriter, arr2, 1);
+
+    out.Synchronize();
+    in.Synchronize();
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 1);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 1);
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 1);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == 1);
+    BOOST_REQUIRE(arr1[0] == val1);
+    BOOST_REQUIRE(arr1[1] == dflt);
+    arr1[0] = dflt;
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 1);
+    BOOST_REQUIRE(arr1[0] == val1);
+    BOOST_REQUIRE(arr1[1] == dflt);
+    arr1[0] = dflt;
+
+    // 4. Full array write.
+    out.Position(0);
+    in.Position(0);
+
+    WriteArray<T>(rawWriter, arr2, 2);
+
+    out.Synchronize();
+    in.Synchronize();
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 2);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 2);
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 2);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == 2);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 2);
+    BOOST_REQUIRE(arr1[0] == val1);
+    BOOST_REQUIRE(arr1[1] == val2);
+}
+
+void CheckRawWritesRestricted(PortableRawWriter& writer)
+{
+    try
+    {
+        writer.WriteInt8(1);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        int8_t arr[1];
+
+        writer.WriteInt8Array(arr, 1);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        Guid val(1, 1);
+
+        writer.WriteGuid(val);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        writer.WriteString("test");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try 
+    {
+        writer.WriteArray<int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try 
+    {
+        writer.WriteCollection<int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try 
+    {
+        writer.WriteMap<int8_t, int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+}
+
+void CheckRawReadsRestricted(PortableRawReader& reader)
+{
+    try
+    {
+        reader.ReadInt8();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        int8_t arr[1];
+
+        reader.ReadInt8Array(arr, 1);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadGuid();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadString();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadArray<int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadCollection<int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadMap<int8_t, int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+}
+
+void CheckRawCollectionEmpty(CollectionType* colType)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableCollectionWriter<PortableInner> colWriter = colType ?
+        rawWriter.WriteCollection<PortableInner>(*colType) : rawWriter.WriteCollection<PortableInner>();
+
+    CheckRawWritesRestricted(rawWriter);
+
+    colWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        colWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        colWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableCollectionReader<PortableInner> colReader = rawReader.ReadCollection<PortableInner>();
+
+    if (colType)
+        BOOST_REQUIRE(colReader.GetType() == *colType);
+    else
+        BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+    BOOST_REQUIRE(colReader.GetSize() == 0);
+    BOOST_REQUIRE(!colReader.HasNext());
+    BOOST_REQUIRE(!colReader.IsNull());
+
+    try
+    {
+        colReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+void CheckRawCollection(CollectionType* colType)
+{
+    PortableInner writeVal1 = PortableInner(1);
+    PortableInner writeVal2 = PortableInner(0);
+    PortableInner writeVal3 = PortableInner(2);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableCollectionWriter<PortableInner> colWriter = colType ?
+        rawWriter.WriteCollection<PortableInner>(*colType) : rawWriter.WriteCollection<PortableInner>();
+
+    colWriter.Write(writeVal1);
+    colWriter.Write(writeVal2);
+    colWriter.Write(writeVal3);
+
+    CheckRawWritesRestricted(rawWriter);
+
+    colWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        colWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        colWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableCollectionReader<PortableInner> colReader = rawReader.ReadCollection<PortableInner>();
+
+    CheckRawReadsRestricted(rawReader);
+
+    if (colType)
+        BOOST_REQUIRE(colReader.GetType() == *colType);
+    else
+        BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+    BOOST_REQUIRE(colReader.GetSize() == 3);
+    BOOST_REQUIRE(!colReader.IsNull());
+
+    BOOST_REQUIRE(colReader.HasNext());
+    BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal1.GetValue());
+
+    BOOST_REQUIRE(colReader.HasNext());
+    BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal2.GetValue());
+
+    BOOST_REQUIRE(colReader.HasNext());
+    BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal3.GetValue());
+
+    BOOST_REQUIRE(!colReader.HasNext());
+
+    try
+    {
+        colReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+void CheckRawMapEmpty(MapType* mapType)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
+        rawWriter.WriteMap<int8_t, PortableInner>(*mapType) : rawWriter.WriteMap<int8_t, PortableInner>();
+
+    CheckRawWritesRestricted(rawWriter);
+
+    mapWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        mapWriter.Write(1, PortableInner(1));
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        mapWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableMapReader<int8_t, PortableInner> mapReader = rawReader.ReadMap<int8_t, PortableInner>();
+
+    if (mapType)
+        BOOST_REQUIRE(mapReader.GetType() == *mapType);
+    else
+        BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+    BOOST_REQUIRE(mapReader.GetSize() == 0);
+    BOOST_REQUIRE(!mapReader.HasNext());
+    BOOST_REQUIRE(!mapReader.IsNull());
+
+    try
+    {
+        int8_t key;
+        PortableInner val;
+
+        mapReader.GetNext(&key, &val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+void CheckRawMap(MapType* mapType)
+{
+    PortableInner writeVal1 = PortableInner(1);
+    PortableInner writeVal2 = PortableInner(0);
+    PortableInner writeVal3 = PortableInner(2);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
+        rawWriter.WriteMap<int8_t, PortableInner>(*mapType) : rawWriter.WriteMap<int8_t, PortableInner>();
+
+    mapWriter.Write(1, writeVal1);
+    mapWriter.Write(2, writeVal2);
+    mapWriter.Write(3, writeVal3);
+
+    CheckRawWritesRestricted(rawWriter);
+
+    mapWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        mapWriter.Write(4, PortableInner(4));
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        mapWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableMapReader<int8_t, PortableInner> mapReader = rawReader.ReadMap<int8_t, PortableInner>();
+
+    CheckRawReadsRestricted(rawReader);
+
+    if (mapType)
+        BOOST_REQUIRE(mapReader.GetType() == *mapType);
+    else
+        BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+    BOOST_REQUIRE(mapReader.GetSize() == 3);
+    BOOST_REQUIRE(!mapReader.IsNull());
+
+    int8_t key;
+    PortableInner val;
+
+    BOOST_REQUIRE(mapReader.HasNext());
+
+    mapReader.GetNext(&key, &val);
+    BOOST_REQUIRE(key == 1);
+    BOOST_REQUIRE(val.GetValue() == writeVal1.GetValue());
+
+    mapReader.GetNext(&key, &val);
+    BOOST_REQUIRE(key == 2);
+    BOOST_REQUIRE(val.GetValue() == writeVal2.GetValue());
+
+    mapReader.GetNext(&key, &val);
+    BOOST_REQUIRE(key == 3);
+    BOOST_REQUIRE(val.GetValue() == writeVal3.GetValue());
+
+    BOOST_REQUIRE(!mapReader.HasNext());
+
+    try
+    {
+        mapReader.GetNext(&key, &val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_SUITE(PortableReaderWriterRawTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt8)
+{
+    CheckRawPrimitive<int8_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveBool)
+{
+    CheckRawPrimitive<bool>(true);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt16)
+{
+    CheckRawPrimitive<int16_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveUInt16)
+{
+    CheckRawPrimitive<uint16_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt32)
+{
+    CheckRawPrimitive<int32_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt64)
+{
+    CheckRawPrimitive<int64_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveFloat)
+{
+    CheckRawPrimitive<float>(1.1f);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveDouble)
+{
+    CheckRawPrimitive<double>(1.1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveGuid)
+{
+    Guid val(1, 2);
+
+    CheckRawPrimitive<Guid>(val);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt8)
+{
+    CheckRawPrimitiveArray<int8_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayBool)
+{
+    CheckRawPrimitiveArray<bool>(false, true, false);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt16)
+{
+    CheckRawPrimitiveArray<int16_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayUInt16)
+{
+    CheckRawPrimitiveArray<uint16_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt32)
+{
+    CheckRawPrimitiveArray<int32_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt64)
+{
+    CheckRawPrimitiveArray<int64_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayFloat)
+{
+    CheckRawPrimitiveArray<float>(1.1f, 2.2f, 3.3f);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayDouble)
+{
+    CheckRawPrimitiveArray<double>(1.1, 2.2, 3.3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayGuid)
+{
+    Guid dflt(1, 2);
+    Guid val1(3, 4);
+    Guid val2(5, 6);
+
+    CheckRawPrimitiveArray<Guid>(dflt, val1, val2);
+}
+
+BOOST_AUTO_TEST_CASE(TestGuidNull)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteNull();
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    Guid expVal;
+    Guid actualVal = rawReader.ReadGuid();
+
+    BOOST_REQUIRE(actualVal == expVal);
+}
+
+BOOST_AUTO_TEST_CASE(TestString) {
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    const char* writeVal1 = "testtest";
+    const char* writeVal2 = "test";
+    std::string writeVal3 = writeVal1;
+
+    rawWriter.WriteString(writeVal1);
+    rawWriter.WriteString(writeVal1, 4);
+    rawWriter.WriteString(writeVal3);
+    rawWriter.WriteString(NULL);
+    rawWriter.WriteString(NULL, 4);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    char readVal1[9];
+    char readVal2[5];
+    
+    BOOST_REQUIRE(rawReader.ReadString(NULL, 0) == 8);
+    BOOST_REQUIRE(rawReader.ReadString(NULL, 8) == 8);
+    BOOST_REQUIRE(rawReader.ReadString(readVal1, 0) == 8);
+    BOOST_REQUIRE(rawReader.ReadString(readVal1, 4) == 8);
+
+    BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == 8);
+    std::string writeVal1Str = writeVal1;
+    std::string readVal1Str = readVal1;
+    BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+    BOOST_REQUIRE(rawReader.ReadString(readVal2, 5) == 4);
+    std::string writeVal2Str = writeVal2;
+    std::string readVal2Str = readVal2;
+    BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+    std::string readVal3 = rawReader.ReadString();
+    BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+    BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == -1);
+    BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == -1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArrayNull)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteNull();
+    rawWriter.WriteInt8(1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableStringArrayReader arrReader = rawReader.ReadStringArray();
+
+    BOOST_REQUIRE(arrReader.GetSize() == -1);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.IsNull());
+
+    try
+    {
+        char res[100];
+
+        arrReader.GetNext(res, 100);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableStringArrayWriter arrWriter = rawWriter.WriteStringArray();
+
+    CheckRawWritesRestricted(rawWriter);
+
+    arrWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val, 4);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        std::string val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableStringArrayReader arrReader = rawReader.ReadStringArray();
+
+    BOOST_REQUIRE(arrReader.GetSize() == 0);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    try
+    {
+        char res[100];
+
+        arrReader.GetNext(res, 100);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArray)
+{
+    const char* writeVal1 = "testtest";
+    const char* writeVal2 = "test";
+    std::string writeVal3 = "test2";
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableStringArrayWriter arrWriter = rawWriter.WriteStringArray();
+
+    arrWriter.Write(writeVal1);
+    arrWriter.Write(writeVal1, 4);
+    arrWriter.Write(NULL); // NULL value.
+    arrWriter.Write(NULL, 100); // NULL value again.
+    arrWriter.Write(writeVal3);
+
+    CheckRawWritesRestricted(rawWriter);
+
+    arrWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val, 4);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        std::string val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableStringArrayReader arrReader = rawReader.ReadStringArray();
+
+    CheckRawReadsRestricted(rawReader);
+
+    BOOST_REQUIRE(arrReader.GetSize() == 5);
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    // 1. Read first value.
+    BOOST_REQUIRE(arrReader.HasNext());
+        
+    char readVal1[9];
+    
+    BOOST_REQUIRE(arrReader.GetNext(NULL, 0) == 8);
+    BOOST_REQUIRE(arrReader.GetNext(NULL, 8) == 8);
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 0) == 8);
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == 8);
+
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 9) == 8);
+    std::string writeVal1Str = writeVal1;
+    std::string readVal1Str = readVal1;
+    BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+    // 2. Read second value.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    char readVal2[5];
+
+    BOOST_REQUIRE(arrReader.GetNext(readVal2, 5) == 4);
+    std::string writeVal2Str = writeVal2;
+    std::string readVal2Str = readVal2;
+    BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+    // 3. Read NULL.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == -1);
+    readVal1Str = readVal1;
+    BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+    // 4. Read NULL again, this time through another method.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    std::string readNullVal = arrReader.GetNext();
+
+    BOOST_REQUIRE(readNullVal.length() == 0);
+
+    // 5. Read third value.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    std::string readVal3 = arrReader.GetNext();
+    BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+    BOOST_REQUIRE(!arrReader.HasNext());
+
+    try
+    {
+        char res[100];
+
+        arrReader.GetNext(res, 100);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestObject)
+{
+    PortableInner writeVal1(1);
+    PortableInner writeVal2(0);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteObject(writeVal1);
+    rawWriter.WriteObject(writeVal2);
+    rawWriter.WriteNull();
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableInner readVal1 = rawReader.ReadObject<PortableInner>();
+    BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+
+    PortableInner readVal2 = rawReader.ReadObject<PortableInner>();
+    BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+
+    PortableInner readVal3 = rawReader.ReadObject<PortableInner>();
+    BOOST_REQUIRE(0 == readVal3.GetValue());
+}
+
+BOOST_AUTO_TEST_CASE(TestNestedObject)
+{
+    PortableOuter writeVal1(1, 2);
+    PortableOuter writeVal2(0, 0);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteObject(writeVal1);
+    rawWriter.WriteObject(writeVal2);
+    rawWriter.WriteNull();
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableOuter readVal1 = rawReader.ReadObject<PortableOuter>();
+    BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+    BOOST_REQUIRE(writeVal1.GetInner().GetValue() == readVal1.GetInner().GetValue());
+
+    PortableOuter readVal2 = rawReader.ReadObject<PortableOuter>();
+    BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+    BOOST_REQUIRE(writeVal2.GetInner().GetValue() == readVal2.GetInner().GetValue());
+
+    PortableOuter readVal3 = rawReader.ReadObject<PortableOuter>();
+    BOOST_REQUIRE(0 == readVal3.GetValue());
+    BOOST_REQUIRE(0 == readVal3.GetInner().GetValue());
+}
+
+BOOST_AUTO_TEST_CASE(TestArrayNull)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteNull();
+    rawWriter.WriteInt8(1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableArrayReader<PortableInner> arrReader = rawReader.ReadArray<PortableInner>();
+
+    BOOST_REQUIRE(arrReader.GetSize() == -1);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.IsNull());
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestArrayEmpty) 
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableArrayWriter<PortableInner> arrWriter = rawWriter.WriteArray<PortableInner>();
+
+    CheckRawWritesRestricted(rawWriter);
+
+    arrWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        arrWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableArrayReader<PortableInner> arrReader = rawReader.ReadArray<PortableInner>();
+
+    BOOST_REQUIRE(arrReader.GetSize() == 0);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestArray)
+{
+    PortableInner writeVal1 = PortableInner(1);
+    PortableInner writeVal2 = PortableInner(0);
+    PortableInner writeVal3 = PortableInner(2);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableArrayWriter<PortableInner> arrWriter = rawWriter.WriteArray<PortableInner>();
+
+    arrWriter.Write(writeVal1); 
+    arrWriter.Write(writeVal2);
+    arrWriter.Write(writeVal3);
+
+    CheckRawWritesRestricted(rawWriter);
+
+    arrWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        arrWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableArrayReader<PortableInner> arrReader = rawReader.ReadArray<PortableInner>();
+
+    CheckRawReadsRestricted(rawReader);
+
+    BOOST_REQUIRE(arrReader.GetSize() == 3);
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    BOOST_REQUIRE(arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal1.GetValue());
+
+    BOOST_REQUIRE(arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal2.GetValue());
+
+    BOOST_REQUIRE(arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal3.GetValue());
+
+    BOOST_REQUIRE(!arrReader.HasNext());
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionNull)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteNull();
+    rawWriter.WriteInt8(1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableCollectionReader<PortableInner> colReader = rawReader.ReadCollection<PortableInner>();
+
+    BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+    BOOST_REQUIRE(colReader.GetSize() == -1);
+    BOOST_REQUIRE(!colReader.HasNext());
+    BOOST_REQUIRE(colReader.IsNull()); 
+
+    try
+    {
+        colReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionEmpty)
+{
+    CheckRawCollectionEmpty(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionEmptyTyped)
+{
+    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+    CheckRawCollectionEmpty(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollection)
+{
+    CheckRawCollection(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(testCollectionTyped)
+{
+    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+    CheckRawCollection(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapNull)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteNull();
+    rawWriter.WriteInt8(1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableMapReader<int8_t, PortableInner> mapReader = rawReader.ReadMap<int8_t, PortableInner>();
+
+    BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+    BOOST_REQUIRE(mapReader.GetSize() == -1);
+    BOOST_REQUIRE(!mapReader.HasNext());
+    BOOST_REQUIRE(mapReader.IsNull());
+
+    try
+    {
+        int8_t key;
+        PortableInner val;
+
+        mapReader.GetNext(&key, &val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapEmpty)
+{
+    CheckRawMapEmpty(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapEmptyTyped)
+{
+    MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+    CheckRawMapEmpty(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestMap)
+{
+    CheckRawMap(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapTyped)
+{
+    MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+    CheckRawMap(&typ);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_test.cpp b/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_test.cpp
new file mode 100644
index 0000000..aff929b
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_test.cpp
@@ -0,0 +1,1951 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/portable/portable.h"
+
+#include "ignite/portable_test_defs.h"
+#include "ignite/portable_test_utils.h"
+
+using namespace ignite;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+using namespace ignite::portable;
+using namespace ignite_test::core::portable;
+
+template<typename T>
+void CheckPrimitive(T val)
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    out.Position(18);
+
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    try
+    {
+        Write<T>(writer, NULL, val);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    Write<T>(writer, "test", val);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+
+    in.Position(18);
+
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100);
+    PortableReader reader(&readerImpl);
+
+    try
+    {
+        Read<T>(reader, NULL);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    T readVal = Read<T>(reader, "test");
+    
+    BOOST_REQUIRE(readVal == val);
+}
+
+template<typename T>
+void CheckPrimitiveArray(T dflt, T val1, T val2)
+{
+    const char* fieldName = "test";
+
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+    
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100);
+    PortableReader reader(&readerImpl);
+
+    out.Position(18);
+
+    try
+    {
+        T nullFieldArr[2];
+
+        nullFieldArr[0] = val1;
+        nullFieldArr[1] = val2;
+
+        WriteArray<T>(writer, NULL, nullFieldArr, 2);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+    
+    // 1. Write NULL and see what happens.
+    WriteArray<T>(writer, fieldName, NULL, 0);
+
+    out.Synchronize();
+    in.Synchronize();
+    
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == -1);
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == -1);
+
+    T arr1[2];
+    arr1[0] = dflt;
+    arr1[1] = dflt;
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == -1);
+
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    // 2. Write empty array.
+    T arr2[2];
+    arr2[0] = val1;
+    arr2[1] = val2;
+
+    out.Position(18);
+    
+    WriteArray<T>(writer, fieldName, arr2, 0);
+
+    out.Synchronize();
+    in.Synchronize();
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 0);
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 0);
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 0);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 0);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    // 3. Partial array write.
+    out.Position(18);
+    
+    WriteArray<T>(writer, fieldName, arr2, 1);
+
+    out.Synchronize();
+    in.Synchronize();
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 1);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 1);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 1);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == 1);
+    BOOST_REQUIRE(arr1[0] == val1);
+    BOOST_REQUIRE(arr1[1] == dflt);
+    arr1[0] = dflt;
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 1);
+    BOOST_REQUIRE(arr1[0] == val1);
+    BOOST_REQUIRE(arr1[1] == dflt);
+    arr1[0] = dflt;
+
+    // 4. Full array write.
+    out.Position(18);
+    
+    WriteArray<T>(writer, fieldName, arr2, 2);
+
+    out.Synchronize();
+    in.Synchronize();
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 2);
+
+    in.Position(18);
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 2);
+
+    try
+    {
+        ReadArray<T>(reader, NULL, arr1, 2);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 2);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == 2);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 2);
+    BOOST_REQUIRE(arr1[0] == val1);
+    BOOST_REQUIRE(arr1[1] == val2);
+}
+
+void CheckWritesRestricted(PortableWriter& writer)
+{
+    try
+    {
+        writer.WriteInt8("field", 1);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        int8_t arr[1];
+
+        writer.WriteInt8Array("field", arr, 1);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        Guid val(1, 1);
+
+        writer.WriteGuid("field", val);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        writer.WriteString("field", "test");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try 
+    {
+        writer.WriteArray<int8_t>("field");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try 
+    {
+        writer.WriteCollection<int8_t>("field");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try 
+    {
+        writer.WriteMap<int8_t, int8_t>("field");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+}
+
+void CheckReadsRestricted(PortableReader& reader)
+{
+    try
+    {
+        reader.ReadInt8("field");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        int8_t arr[1];
+
+        reader.ReadInt8Array("field", arr, 1);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadGuid("field");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadString("field");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadArray<int8_t>("field");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadCollection<int8_t>("field");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadMap<int8_t, int8_t>("field");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+}
+
+void CheckCollectionEmpty(CollectionType* colType)
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    PortableCollectionWriter<PortableInner> colWriter = colType ?
+        writer.WriteCollection<PortableInner>("field1", *colType) : writer.WriteCollection<PortableInner>("field1");
+
+    CheckWritesRestricted(writer);
+
+    colWriter.Close();
+
+    writer.WriteInt8("field2", 1);
+
+    try
+    {
+        colWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        colWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableCollectionReader<PortableInner> colReader = reader.ReadCollection<PortableInner>("field1");
+
+    if (colType)
+        BOOST_REQUIRE(colReader.GetType() == *colType);
+    else
+        BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+    BOOST_REQUIRE(colReader.GetSize() == 0);
+    BOOST_REQUIRE(!colReader.HasNext());
+    BOOST_REQUIRE(!colReader.IsNull());
+
+    try
+    {
+        colReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+void CheckCollection(CollectionType* colType)
+{
+    PortableInner writeVal1 = PortableInner(1);
+    PortableInner writeVal2 = PortableInner(0);
+    PortableInner writeVal3 = PortableInner(2);
+
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    PortableCollectionWriter<PortableInner> colWriter = colType ?
+        writer.WriteCollection<PortableInner>("field1", *colType) : writer.WriteCollection<PortableInner>("field1");
+
+    colWriter.Write(writeVal1);
+    colWriter.Write(writeVal2);
+    colWriter.Write(writeVal3);
+
+    CheckWritesRestricted(writer);
+
+    colWriter.Close();
+
+    writer.WriteInt8("field2", 1);
+
+    try
+    {
+        colWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        colWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableCollectionReader<PortableInner> colReader = reader.ReadCollection<PortableInner>("field1");
+
+    CheckReadsRestricted(reader);
+
+    if (colType)
+        BOOST_REQUIRE(colReader.GetType() == *colType);
+    else
+        BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+    BOOST_REQUIRE(colReader.GetSize() == 3);
+    BOOST_REQUIRE(!colReader.IsNull());
+
+    BOOST_REQUIRE(colReader.HasNext());
+    BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal1.GetValue());
+
+    BOOST_REQUIRE(colReader.HasNext());
+    BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal2.GetValue());
+
+    BOOST_REQUIRE(colReader.HasNext());
+    BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal3.GetValue());
+
+    BOOST_REQUIRE(!colReader.HasNext());
+
+    try
+    {
+        colReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+void CheckMapEmpty(MapType* mapType)
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
+        writer.WriteMap<int8_t, PortableInner>("field1", *mapType) : writer.WriteMap<int8_t, PortableInner>("field1");
+
+    CheckWritesRestricted(writer);
+
+    mapWriter.Close();
+
+    writer.WriteInt8("field2", 1);
+
+    try
+    {
+        mapWriter.Write(1, PortableInner(1));
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        mapWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableMapReader<int8_t, PortableInner> mapReader = reader.ReadMap<int8_t, PortableInner>("field1");
+
+    if (mapType)
+        BOOST_REQUIRE(mapReader.GetType() == *mapType);
+    else
+        BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+    BOOST_REQUIRE(mapReader.GetSize() == 0);
+    BOOST_REQUIRE(!mapReader.HasNext());
+    BOOST_REQUIRE(!mapReader.IsNull());
+
+    try
+    {
+        int8_t key;
+        PortableInner val;
+
+        mapReader.GetNext(&key, &val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+void CheckMap(MapType* mapType)
+{
+    PortableInner writeVal1 = PortableInner(1);
+    PortableInner writeVal2 = PortableInner(0);
+    PortableInner writeVal3 = PortableInner(2);
+
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
+        writer.WriteMap<int8_t, PortableInner>("field1", *mapType) : writer.WriteMap<int8_t, PortableInner>("field1");
+
+    mapWriter.Write(1, writeVal1);
+    mapWriter.Write(2, writeVal2);
+    mapWriter.Write(3, writeVal3);
+
+    CheckWritesRestricted(writer);
+
+    mapWriter.Close();
+
+    writer.WriteInt8("field2", 1);
+
+    try
+    {
+        mapWriter.Write(4, PortableInner(4));
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        mapWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableMapReader<int8_t, PortableInner> mapReader = reader.ReadMap<int8_t, PortableInner>("field1");
+
+    CheckReadsRestricted(reader);
+
+    if (mapType)
+        BOOST_REQUIRE(mapReader.GetType() == *mapType);
+    else
+        BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+    BOOST_REQUIRE(mapReader.GetSize() == 3);
+    BOOST_REQUIRE(!mapReader.IsNull());
+
+    int8_t key;
+    PortableInner val;
+
+    BOOST_REQUIRE(mapReader.HasNext());
+
+    mapReader.GetNext(&key, &val);
+    BOOST_REQUIRE(key == 1);
+    BOOST_REQUIRE(val.GetValue() == writeVal1.GetValue());
+
+    mapReader.GetNext(&key, &val);
+    BOOST_REQUIRE(key == 2);
+    BOOST_REQUIRE(val.GetValue() == writeVal2.GetValue());
+
+    mapReader.GetNext(&key, &val);
+    BOOST_REQUIRE(key == 3);
+    BOOST_REQUIRE(val.GetValue() == writeVal3.GetValue());
+
+    BOOST_REQUIRE(!mapReader.HasNext());
+
+    try
+    {
+        mapReader.GetNext(&key, &val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_SUITE(PortableReaderWriterTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt8)
+{
+    CheckPrimitive<int8_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveBool)
+{
+    CheckPrimitive<bool>(true);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt16)
+{
+    CheckPrimitive<int16_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveUInt16)
+{
+    CheckPrimitive<uint16_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt32)
+{
+    CheckPrimitive<int32_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt64)
+{
+    CheckPrimitive<int64_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveFloat)
+{
+    CheckPrimitive<float>(1.1f);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveDouble)
+{
+    CheckPrimitive<double>(1.1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveGuid)
+{
+    Guid val(1, 2);
+
+    CheckPrimitive<Guid>(val);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt8)
+{
+    CheckPrimitiveArray<int8_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayBool)
+{
+    CheckPrimitiveArray<bool>(false, true, false);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt16)
+{
+    CheckPrimitiveArray<int16_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayUInt16)
+{
+    CheckPrimitiveArray<uint16_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt32)
+{
+    CheckPrimitiveArray<int32_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt64)
+{
+    CheckPrimitiveArray<int64_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayFloat)
+{
+    CheckPrimitiveArray<float>(1.1f, 2.2f, 3.3f);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayDouble)
+{
+    CheckPrimitiveArray<double>(1.1, 2.2, 3.3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayGuid)
+{
+    Guid dflt(1, 2);
+    Guid val1(3, 4);
+    Guid val2(5, 6);
+
+    CheckPrimitiveArray<Guid>(dflt, val1, val2);
+}
+
+BOOST_AUTO_TEST_CASE(TestGuidNull)
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    try
+    {
+        writer.WriteNull(NULL);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    writer.WriteNull("test");
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100);
+    PortableReader reader(&readerImpl);
+    
+    in.Position(18);
+
+    try
+    {
+        reader.ReadGuid(NULL);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    Guid expVal;
+    Guid actualVal = reader.ReadGuid("test");
+
+    BOOST_REQUIRE(actualVal == expVal);
+}
+
+BOOST_AUTO_TEST_CASE(TestString) {
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    const char* writeVal1 = "testtest";
+    const char* writeVal2 = "test";
+    std::string writeVal3 = writeVal1;
+
+    try
+    {
+        writer.WriteString(NULL, writeVal1);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        writer.WriteString(NULL, writeVal1, 4);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        writer.WriteString(NULL, writeVal3);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    writer.WriteString("field1", writeVal1);
+    writer.WriteString("field2", writeVal1, 4);
+    writer.WriteString("field3", writeVal3);
+    writer.WriteString("field4", NULL);
+    writer.WriteString("field5", NULL, 4);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    try
+    {
+        char nullCheckRes[9];
+
+        reader.ReadString(NULL, nullCheckRes, 9);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadString(NULL);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    char readVal1[9];
+    char readVal2[5];
+    
+    BOOST_REQUIRE(reader.ReadString("field1", NULL, 0) == 8);
+    BOOST_REQUIRE(reader.ReadString("field1", NULL, 8) == 8);
+    BOOST_REQUIRE(reader.ReadString("field1", readVal1, 0) == 8);
+    BOOST_REQUIRE(reader.ReadString("field1", readVal1, 4) == 8);
+
+    BOOST_REQUIRE(reader.ReadString("field1", readVal1, 9) == 8);
+    std::string writeVal1Str = writeVal1;
+    std::string readVal1Str = readVal1;
+    BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+    BOOST_REQUIRE(reader.ReadString("field2", readVal2, 5) == 4);
+    std::string writeVal2Str = writeVal2;
+    std::string readVal2Str = readVal2;
+    BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+    std::string readVal3 = reader.ReadString("field3");
+    BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+    BOOST_REQUIRE(reader.ReadString("field4", readVal1, 9) == -1);
+    BOOST_REQUIRE(reader.ReadString("field5", readVal1, 9) == -1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArrayNull)
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    writer.WriteNull("field1");
+    writer.WriteInt8("field2", 1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableStringArrayReader arrReader = reader.ReadStringArray("field1");
+
+    BOOST_REQUIRE(arrReader.GetSize() == -1);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.IsNull());
+
+    try
+    {
+        char res[100];
+
+        arrReader.GetNext(res, 100);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    PortableStringArrayWriter arrWriter = writer.WriteStringArray("field1");
+    
+    CheckWritesRestricted(writer);
+
+    arrWriter.Close();
+
+    writer.WriteInt8("field2", 1);
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val, 4);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        std::string val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableStringArrayReader arrReader = reader.ReadStringArray("field1");
+
+    BOOST_REQUIRE(arrReader.GetSize() == 0);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    try
+    {
+        char res[100];
+
+        arrReader.GetNext(res, 100);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArray)
+{
+    const char* writeVal1 = "testtest";
+    const char* writeVal2 = "test";
+    std::string writeVal3 = "test2";
+
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    PortableStringArrayWriter arrWriter = writer.WriteStringArray("field1");
+
+    arrWriter.Write(writeVal1);
+    arrWriter.Write(writeVal1, 4);
+    arrWriter.Write(NULL); // NULL value.
+    arrWriter.Write(NULL, 100); // NULL value again.
+    arrWriter.Write(writeVal3);
+
+    CheckWritesRestricted(writer);
+
+    arrWriter.Close();
+
+    writer.WriteInt8("field2", 1);
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val, 4);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        std::string val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableStringArrayReader arrReader = reader.ReadStringArray("field1");
+
+    CheckReadsRestricted(reader);
+
+    BOOST_REQUIRE(arrReader.GetSize() == 5);
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    // 1. Read first value.
+    BOOST_REQUIRE(arrReader.HasNext());
+        
+    char readVal1[9];
+    
+    BOOST_REQUIRE(arrReader.GetNext(NULL, 0) == 8);
+    BOOST_REQUIRE(arrReader.GetNext(NULL, 8) == 8);
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 0) == 8);
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == 8);
+
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 9) == 8);
+    std::string writeVal1Str = writeVal1;
+    std::string readVal1Str = readVal1;
+    BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+    // 2. Read second value.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    char readVal2[5];
+
+    BOOST_REQUIRE(arrReader.GetNext(readVal2, 5) == 4);
+    std::string writeVal2Str = writeVal2;
+    std::string readVal2Str = readVal2;
+    BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+    // 3. Read NULL.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == -1);
+    readVal1Str = readVal1;
+    BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+    // 4. Read NULL again, this time through another method.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    std::string readNullVal = arrReader.GetNext();
+
+    BOOST_REQUIRE(readNullVal.length() == 0);
+
+    // 5. Read third value.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    std::string readVal3 = arrReader.GetNext();
+    BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+    BOOST_REQUIRE(!arrReader.HasNext());
+
+    try
+    {
+        char res[100];
+
+        arrReader.GetNext(res, 100);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestObject)
+{
+    PortableInner writeVal1(1);
+    PortableInner writeVal2(0);
+
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    writer.WriteObject("field1", writeVal1);
+    writer.WriteObject("field2", writeVal2);
+    writer.WriteNull("field3");
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableInner readVal1 = reader.ReadObject<PortableInner>("field1");
+    BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+
+    PortableInner readVal2 = reader.ReadObject<PortableInner>("field2");
+    BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+
+    PortableInner readVal3 = reader.ReadObject<PortableInner>("field3");
+    BOOST_REQUIRE(0 == readVal3.GetValue());
+}
+
+BOOST_AUTO_TEST_CASE(TestNestedObject)
+{
+    PortableOuter writeVal1(1, 2);
+    PortableOuter writeVal2(0, 0);
+
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    writer.WriteObject("field1", writeVal1);
+    writer.WriteObject("field2", writeVal2);
+    writer.WriteNull("field3");
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableOuter readVal1 = reader.ReadObject<PortableOuter>("field1");
+    BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+    BOOST_REQUIRE(writeVal1.GetInner().GetValue() == readVal1.GetInner().GetValue());
+
+    PortableOuter readVal2 = reader.ReadObject<PortableOuter>("field2");
+    BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+    BOOST_REQUIRE(writeVal2.GetInner().GetValue() == readVal2.GetInner().GetValue());
+
+    PortableOuter readVal3 = reader.ReadObject<PortableOuter>("field3");
+    BOOST_REQUIRE(0 == readVal3.GetValue());
+    BOOST_REQUIRE(0 == readVal3.GetInner().GetValue());
+}
+
+BOOST_AUTO_TEST_CASE(TestArrayNull)
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    writer.WriteNull("field1");
+    writer.WriteInt8("field2", 1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableArrayReader<PortableInner> arrReader = reader.ReadArray<PortableInner>("field1");
+
+    BOOST_REQUIRE(arrReader.GetSize() == -1);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.IsNull());
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestArrayEmpty) 
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    PortableArrayWriter<PortableInner> arrWriter = writer.WriteArray<PortableInner>("field1");
+
+    CheckWritesRestricted(writer);
+
+    arrWriter.Close();
+
+    writer.WriteInt8("field2", 1);
+
+    try
+    {
+        arrWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableArrayReader<PortableInner> arrReader = reader.ReadArray<PortableInner>("field1");
+
+    BOOST_REQUIRE(arrReader.GetSize() == 0);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestArray)
+{
+    PortableInner writeVal1 = PortableInner(1);
+    PortableInner writeVal2 = PortableInner(0);
+    PortableInner writeVal3 = PortableInner(2);
+
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    PortableArrayWriter<PortableInner> arrWriter = writer.WriteArray<PortableInner>("field1");
+
+    arrWriter.Write(writeVal1); 
+    arrWriter.Write(writeVal2);
+    arrWriter.Write(writeVal3);
+
+    CheckWritesRestricted(writer);
+
+    arrWriter.Close();
+
+    writer.WriteInt8("field2", 1);
+
+    try
+    {
+        arrWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableArrayReader<PortableInner> arrReader = reader.ReadArray<PortableInner>("field1");
+
+    CheckReadsRestricted(reader);
+
+    BOOST_REQUIRE(arrReader.GetSize() == 3);
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    BOOST_REQUIRE(arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal1.GetValue());
+
+    BOOST_REQUIRE(arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal2.GetValue());
+
+    BOOST_REQUIRE(arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal3.GetValue());
+
+    BOOST_REQUIRE(!arrReader.HasNext());
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionNull)
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    writer.WriteNull("field1");
+    writer.WriteInt8("field2", 1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableCollectionReader<PortableInner> colReader = reader.ReadCollection<PortableInner>("field1");
+
+    BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+    BOOST_REQUIRE(colReader.GetSize() == -1);
+    BOOST_REQUIRE(!colReader.HasNext());
+    BOOST_REQUIRE(colReader.IsNull()); 
+
+    try
+    {
+        colReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionEmpty)
+{
+    CheckCollectionEmpty(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionEmptyTyped)
+{
+    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+    CheckCollectionEmpty(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollection)
+{
+    CheckCollection(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(testCollectionTyped)
+{
+    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+    CheckCollection(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapNull)
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    writer.WriteNull("field1");
+    writer.WriteInt8("field2", 1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 1000);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableMapReader<int8_t, PortableInner> mapReader = reader.ReadMap<int8_t, PortableInner>("field1");
+
+    BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+    BOOST_REQUIRE(mapReader.GetSize() == -1);
+    BOOST_REQUIRE(!mapReader.HasNext());
+    BOOST_REQUIRE(mapReader.IsNull());
+
+    try
+    {
+        int8_t key;
+        PortableInner val;
+
+        mapReader.GetNext(&key, &val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapEmpty)
+{
+    CheckMapEmpty(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapEmptyTyped)
+{
+    MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+    CheckMapEmpty(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestMap)
+{
+    CheckMap(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapTyped)
+{
+    MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+    CheckMap(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestRawMode)
+{
+    TemplatedPortableIdResolver<PortableDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL);
+    PortableWriter writer(&writerImpl);
+
+    out.Position(18);
+
+    PortableRawWriter rawWriter = writer.RawWriter();
+
+    try
+    {
+        writer.RawWriter();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    rawWriter.WriteInt8(1);
+
+    CheckWritesRestricted(writer);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, 18);
+    PortableReader reader(&readerImpl);
+
+    in.Position(18);
+
+    PortableRawReader rawReader = reader.RawReader();
+
+    try
+    {
+        reader.RawReader();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+
+    CheckReadsRestricted(reader);
+}
+
+BOOST_AUTO_TEST_CASE(TestFieldSeek)
+{
+    TemplatedPortableIdResolver<PortableFields> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+
+    PortableFields writeVal(1, 2, 3, 4);
+
+    writer.WriteTopObject<PortableFields>(writeVal);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+
+    int32_t pos = in.Position();
+    in.ReadInt8(); // We do not need a header here.
+    bool usrType = in.ReadBool();
+    int32_t typeId = in.ReadInt32();
+    int32_t hashCode = in.ReadInt32();
+    int32_t len = in.ReadInt32();
+    int32_t rawOff = in.ReadInt32();
+
+    PortableReaderImpl readerImpl(&in, &idRslvr, pos, usrType, typeId, hashCode, len, rawOff);
+    PortableReader reader(&readerImpl);
+
+    // 1. Clockwise.
+    BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+    BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+    BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+    BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
+    // 2. Counter closkwise.
+    in.Position(18);
+    BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+    BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+    BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+    BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+    // 3. Same field twice.
+    in.Position(18);
+    BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+    BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+    in.Position(18);
+    BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+    BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+    
+    // 4. Read missing field in between.
+    in.Position(18);
+    BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+    BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
+    BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
+    in.Position(18);
+    BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+    BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
+    BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+    // 5. Invalid field type.
+    in.Position(18);
+    BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+    try
+    {
+        reader.ReadInt64("val2");
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
+    // 6. Read missing primitive fields.
+    BOOST_REQUIRE(reader.ReadInt8("missing") == 0);
+    BOOST_REQUIRE(reader.ReadBool("missing") == false);
+    BOOST_REQUIRE(reader.ReadInt16("missing") == 0);
+    BOOST_REQUIRE(reader.ReadUInt16("missing") == 0);
+    BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
+    BOOST_REQUIRE(reader.ReadInt64("missing") == 0);
+    BOOST_REQUIRE(reader.ReadFloat("missing") == 0);
+    BOOST_REQUIRE(reader.ReadDouble("missing") == 0);
+
+    BOOST_REQUIRE(reader.ReadGuid("missing").GetMostSignificantBits() == 0);
+    BOOST_REQUIRE(reader.ReadGuid("missing").GetLeastSignificantBits() == 0);
+
+    // 7. Read missing primitive array fields.
+    BOOST_REQUIRE(reader.ReadInt8Array("missing", NULL, 1) == -1);
+    BOOST_REQUIRE(reader.ReadBoolArray("missing", NULL, 1) == -1);
+    BOOST_REQUIRE(reader.ReadInt16Array("missing", NULL, 1) == -1);
+    BOOST_REQUIRE(reader.ReadUInt16Array("missing", NULL, 1) == -1);
+    BOOST_REQUIRE(reader.ReadInt32Array("missing", NULL, 1) == -1);
+    BOOST_REQUIRE(reader.ReadInt64Array("missing", NULL, 1) == -1);
+    BOOST_REQUIRE(reader.ReadFloatArray("missing", NULL, 1) == -1);
+    BOOST_REQUIRE(reader.ReadDoubleArray("missing", NULL, 1) == -1);
+
+    BOOST_REQUIRE(reader.ReadGuidArray("missing", NULL, 1) == -1);
+
+    // 8. Read missing string fields.
+    BOOST_REQUIRE(reader.ReadString("missing", NULL, 1) == -1);
+    BOOST_REQUIRE(reader.ReadString("missing").length() == 0);
+
+    // 9. Read missing object fields.
+    BOOST_REQUIRE(reader.ReadObject<PortableFields*>("missing") == NULL);
+    
+    // 10. Read missing container fields.
+    PortableStringArrayReader stringArrReader = reader.ReadStringArray("missing");
+    BOOST_REQUIRE(stringArrReader.IsNull());
+
+    PortableArrayReader<PortableFields> arrReader = reader.ReadArray<PortableFields>("missing");
+    BOOST_REQUIRE(arrReader.IsNull());
+
+    PortableCollectionReader<PortableFields> colReader = reader.ReadCollection<PortableFields>("missing");
+    BOOST_REQUIRE(colReader.IsNull());
+
+    PortableMapReader<int32_t, PortableFields> mapReader = reader.ReadMap<int32_t, PortableFields>("missing");
+    BOOST_REQUIRE(mapReader.IsNull());
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file


[36/50] [abbrv] ignite git commit: IGNITE-1333 - SQL Group index can return wrong restult in half-bounded conditions - Fixes #50.

Posted by ak...@apache.org.
IGNITE-1333 - SQL Group index can return wrong restult in half-bounded conditions - Fixes #50.

Signed-off-by: S.Vladykin <sv...@gridgain.com>


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

Branch: refs/heads/ignite-843
Commit: 94039ecd1a9b122eee0f50fe4ccd693a307451d6
Parents: a007210
Author: S.Vladykin <sv...@gridgain.com>
Authored: Fri Sep 4 10:48:03 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Fri Sep 4 10:48:03 2015 +0300

----------------------------------------------------------------------
 .../query/h2/opt/GridH2IndexBase.java           | 42 ++++++++++++++++++++
 .../query/IgniteSqlSplitterSelfTest.java        | 35 ++++++++++++++--
 2 files changed, 74 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/94039ecd/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
index ff9aa23..39664ff 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
@@ -27,6 +27,8 @@ import org.h2.index.BaseIndex;
 import org.h2.message.DbException;
 import org.h2.result.Row;
 import org.h2.result.SearchRow;
+import org.h2.result.SortOrder;
+import org.h2.value.Value;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -106,6 +108,46 @@ public abstract class GridH2IndexBase extends BaseIndex {
         // No-op.
     }
 
+    /** {@inheritDoc} */
+    @Override public int compareRows(SearchRow rowData, SearchRow compare) {
+        if (rowData == compare)
+            return 0;
+
+        for (int i = 0, len = indexColumns.length; i < len; i++) {
+            int index = columnIds[i];
+
+            Value v1 = rowData.getValue(index);
+            Value v2 = compare.getValue(index);
+
+            if (v1 == null || v2 == null)
+                return 0;
+
+            int c = compareValues(v1, v2, indexColumns[i].sortType);
+
+            if (c != 0)
+                return c;
+        }
+        return 0;
+    }
+
+    /**
+     * @param a First value.
+     * @param b Second value.
+     * @param sortType Sort type.
+     * @return Comparison result.
+     */
+    private int compareValues(Value a, Value b, int sortType) {
+        if (a == b)
+            return 0;
+
+        int comp = table.compareTypeSave(a, b);
+
+        if ((sortType & SortOrder.DESCENDING) != 0)
+            comp = -comp;
+
+        return comp;
+    }
+
     /**
      * Filters rows from expired ones and using predicate.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/94039ecd/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index f70c218..75112fd 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -158,15 +158,44 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
 
             // Check results.
             assertEquals(1, columnQuery(c, qry + "where a = 1 and b = 1").size());
+            assertEquals(0, columnQuery(c, qry + "where a = 1 and b = 2").size());
+            assertEquals(1, columnQuery(c, qry + "where a = 1 and b = 3").size());
             assertEquals(2, columnQuery(c, qry + "where a = 1 and b < 4").size());
             assertEquals(2, columnQuery(c, qry + "where a = 1 and b <= 3").size());
             assertEquals(1, columnQuery(c, qry + "where a = 1 and b < 3").size());
             assertEquals(2, columnQuery(c, qry + "where a = 1 and b > 0").size());
             assertEquals(1, columnQuery(c, qry + "where a = 1 and b > 1").size());
             assertEquals(2, columnQuery(c, qry + "where a = 1 and b >= 1").size());
-            assertEquals(4, columnQuery(c, qry + "where a > 0 and b > 0").size());
-            assertEquals(4, columnQuery(c, qry + "where a > 0 and b >= 1").size());
-            assertEquals(3, columnQuery(c, qry + "where a > 0 and b > 1").size());
+
+            assertEquals(4, columnQuery(c, qry + "where a > 0").size());
+            assertEquals(4, columnQuery(c, qry + "where a >= 1").size());
+            assertEquals(4, columnQuery(c, qry + "where b > 0").size());
+            assertEquals(4, columnQuery(c, qry + "where b >= 1").size());
+
+            assertEquals(4, columnQuery(c, qry + "where a < 2").size());
+            assertEquals(4, columnQuery(c, qry + "where a <= 1").size());
+            assertEquals(4, columnQuery(c, qry + "where b < 3").size());
+            assertEquals(5, columnQuery(c, qry + "where b <= 3").size());
+
+            assertEquals(3, columnQuery(c, qry + "where a > 0 and b > 0").size());
+            assertEquals(2, columnQuery(c, qry + "where a > 0 and b >= 2").size());
+            assertEquals(3, columnQuery(c, qry + "where a >= 1 and b > 0").size());
+            assertEquals(2, columnQuery(c, qry + "where a >= 1 and b >= 2").size());
+
+            assertEquals(3, columnQuery(c, qry + "where a > 0 and b < 3").size());
+            assertEquals(2, columnQuery(c, qry + "where a > 0 and b <= 1").size());
+            assertEquals(3, columnQuery(c, qry + "where a >= 1 and b < 3").size());
+            assertEquals(2, columnQuery(c, qry + "where a >= 1 and b <= 1").size());
+
+            assertEquals(2, columnQuery(c, qry + "where a < 2 and b < 3").size());
+            assertEquals(2, columnQuery(c, qry + "where a < 2 and b <= 1").size());
+            assertEquals(2, columnQuery(c, qry + "where a <= 1 and b < 3").size());
+            assertEquals(2, columnQuery(c, qry + "where a <= 1 and b <= 1").size());
+
+            assertEquals(3, columnQuery(c, qry + "where a < 2 and b > 0").size());
+            assertEquals(2, columnQuery(c, qry + "where a < 2 and b >= 3").size());
+            assertEquals(3, columnQuery(c, qry + "where a <= 1 and b > 0").size());
+            assertEquals(2, columnQuery(c, qry + "where a <= 1 and b >= 3").size());
         }
         finally {
             c.destroy();


[08/50] [abbrv] ignite git commit: ignite-1273: fixed cyclic references processing by PortableMarshaller and ability to modify array fields returned by PortableBuilder

Posted by ak...@apache.org.
ignite-1273: fixed cyclic references processing by PortableMarshaller and ability to modify array fields returned by PortableBuilder


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

Branch: refs/heads/ignite-843
Commit: 6ac9557ef71b7745eff90bcf15a4f7a958fcfa6b
Parents: 8bd8644
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Sep 3 08:30:36 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Sep 3 08:30:36 2015 +0300

----------------------------------------------------------------------
 .../portable/GridPortableMarshaller.java        |  44 +-
 .../portable/PortableAbstractLazyValue.java     |  57 --
 .../internal/portable/PortableBuilderEnum.java  | 114 ---
 .../internal/portable/PortableBuilderImpl.java  | 531 ------------
 .../portable/PortableBuilderReader.java         | 776 ------------------
 .../PortableBuilderSerializationAware.java      |  29 -
 .../portable/PortableBuilderSerializer.java     | 211 -----
 .../portable/PortableClassDescriptor.java       |  57 +-
 .../internal/portable/PortableContext.java      |   6 +-
 .../portable/PortableEnumArrayLazyValue.java    | 112 ---
 .../portable/PortableLazyArrayList.java         | 159 ----
 .../portable/PortableLazyLinkedList.java        | 215 -----
 .../internal/portable/PortableLazyMap.java      | 218 -----
 .../internal/portable/PortableLazyMapEntry.java |  66 --
 .../internal/portable/PortableLazySet.java      |  89 ---
 .../internal/portable/PortableLazyValue.java    |  28 -
 .../portable/PortableObjectArrayLazyValue.java  |  89 ---
 .../portable/PortablePlainLazyValue.java        |  47 --
 .../portable/PortablePlainPortableObject.java   |  50 --
 .../internal/portable/PortableReaderExImpl.java | 154 +++-
 .../ignite/internal/portable/PortableUtils.java |  11 +
 .../portable/PortableValueWithType.java         |  74 --
 .../internal/portable/PortableWriterExImpl.java | 159 +++-
 .../builder/PortableAbstractLazyValue.java      |  57 ++
 .../portable/builder/PortableBuilderEnum.java   | 116 +++
 .../portable/builder/PortableBuilderImpl.java   | 537 +++++++++++++
 .../portable/builder/PortableBuilderReader.java | 800 +++++++++++++++++++
 .../PortableBuilderSerializationAware.java      |  31 +
 .../builder/PortableBuilderSerializer.java      | 214 +++++
 .../builder/PortableEnumArrayLazyValue.java     | 114 +++
 .../portable/builder/PortableLazyArrayList.java | 166 ++++
 .../builder/PortableLazyLinkedList.java         | 217 +++++
 .../portable/builder/PortableLazyMap.java       | 220 +++++
 .../portable/builder/PortableLazyMapEntry.java  |  68 ++
 .../portable/builder/PortableLazySet.java       |  92 +++
 .../portable/builder/PortableLazyValue.java     |  28 +
 .../builder/PortableModifiableLazyValue.java    |  52 ++
 .../builder/PortableObjectArrayLazyValue.java   |  91 +++
 .../builder/PortablePlainLazyValue.java         |  49 ++
 .../builder/PortablePlainPortableObject.java    |  53 ++
 .../portable/builder/PortableValueWithType.java |  75 ++
 .../internal/portable/builder/package-info.java |  22 +
 .../CacheObjectPortableProcessorImpl.java       |   2 +-
 .../resources/META-INF/classnames.properties    |   2 +-
 .../GridPortableBuilderAdditionalSelfTest.java  | 232 +++++-
 .../portable/GridPortableBuilderSelfTest.java   |   1 +
 .../GridPortableMarshallerSelfTest.java         |  72 +-
 .../GridPortableMetaDataDisabledSelfTest.java   |  17 +
 .../portable/GridPortableMetaDataSelfTest.java  |  17 +
 .../mutabletest/GridPortableTestClasses.java    |  38 +-
 ...ClientNodePortableMetadataMultinodeTest.java |  11 +
 51 files changed, 3687 insertions(+), 3003 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
index 3b2357e..c7a9e6f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
@@ -142,67 +142,67 @@ public class GridPortableMarshaller {
     public static final byte OBJ = (byte)103;
 
     /** */
-    static final byte USER_SET = -1;
+    public static final byte USER_SET = -1;
 
     /** */
-    static final byte USER_COL = 0;
+    public static final byte USER_COL = 0;
 
     /** */
-    static final byte ARR_LIST = 1;
+    public static final byte ARR_LIST = 1;
 
     /** */
-    static final byte LINKED_LIST = 2;
+    public static final byte LINKED_LIST = 2;
 
     /** */
-    static final byte HASH_SET = 3;
+    public static final byte HASH_SET = 3;
 
     /** */
-    static final byte LINKED_HASH_SET = 4;
+    public static final byte LINKED_HASH_SET = 4;
 
     /** */
-    static final byte TREE_SET = 5;
+    public static final byte TREE_SET = 5;
 
     /** */
-    static final byte CONC_SKIP_LIST_SET = 6;
+    public static final byte CONC_SKIP_LIST_SET = 6;
 
     /** */
-    static final byte HASH_MAP = 1;
+    public static final byte HASH_MAP = 1;
 
     /** */
-    static final byte LINKED_HASH_MAP = 2;
+    public static final byte LINKED_HASH_MAP = 2;
 
     /** */
-    static final byte TREE_MAP = 3;
+    public static final byte TREE_MAP = 3;
 
     /** */
-    static final byte CONC_HASH_MAP = 4;
+    public static final byte CONC_HASH_MAP = 4;
 
     /** */
-    static final byte PROPERTIES_MAP = 5;
+    public static final byte PROPERTIES_MAP = 5;
 
     /** */
-    static final int OBJECT_TYPE_ID = -1;
+    public static final int OBJECT_TYPE_ID = -1;
 
     /** */
-    static final int UNREGISTERED_TYPE_ID = 0;
+    public static final int UNREGISTERED_TYPE_ID = 0;
 
     /** */
-    static final int TYPE_ID_POS = 2;
+    public static final int TYPE_ID_POS = 2;
 
     /** */
-    static final int HASH_CODE_POS = 6;
+    public static final int HASH_CODE_POS = 6;
 
     /** */
-    static final int TOTAL_LEN_POS = 10;
+    public static final int TOTAL_LEN_POS = 10;
 
     /** */
-    static final byte RAW_DATA_OFF_POS = 14;
+    public static final byte RAW_DATA_OFF_POS = 14;
 
     /** */
-    static final int CLS_NAME_POS = 18;
+    public static final int CLS_NAME_POS = 18;
 
     /** */
-    static final byte DFLT_HDR_LEN = 18;
+    public static final byte DFLT_HDR_LEN = 18;
 
     /** */
     private final PortableContext ctx;
@@ -301,4 +301,4 @@ public class GridPortableMarshaller {
     public PortableContext context() {
         return ctx;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableAbstractLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableAbstractLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableAbstractLazyValue.java
deleted file mode 100644
index 2b1c4b7..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableAbstractLazyValue.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-/**
- *
- */
-abstract class PortableAbstractLazyValue implements PortableLazyValue {
-    /** */
-    protected Object val;
-
-    /** */
-    protected final PortableBuilderReader reader;
-
-    /** */
-    protected final int valOff;
-
-    /**
-     * @param reader Reader.
-     * @param valOff Value.
-     */
-    protected PortableAbstractLazyValue(PortableBuilderReader reader, int valOff) {
-        this.reader = reader;
-        this.valOff = valOff;
-    }
-
-    /**
-     * @return Value.
-     */
-    protected abstract Object init();
-
-    /** {@inheritDoc} */
-    @Override public Object value() {
-        if (val == null) {
-            val = init();
-
-            assert val != null;
-        }
-
-        return val;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderEnum.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderEnum.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderEnum.java
deleted file mode 100644
index b6ace99..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderEnum.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.portable.PortableInvalidClassException;
-
-/**
- *
- */
-public class PortableBuilderEnum implements PortableBuilderSerializationAware {
-    /** */
-    private final int ordinal;
-
-    /** */
-    private final int typeId;
-
-    /** */
-    private final String clsName;
-
-    /**
-     * @param typeId Type ID.
-     * @param anEnum Enum instance.
-     */
-    public PortableBuilderEnum(int typeId, Enum anEnum) {
-        ordinal = anEnum.ordinal();
-        this.typeId = typeId;
-        clsName = null;
-    }
-
-    /**
-     * @param reader PortableBuilderReader.
-     */
-    public PortableBuilderEnum(PortableBuilderReader reader) {
-        int typeId = reader.readInt();
-
-        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
-            clsName = reader.readString();
-
-            Class cls;
-
-            try {
-                // TODO: IGNITE-1272 - Is class loader needed here?
-                cls = U.forName(reader.readString(), null);
-            }
-            catch (ClassNotFoundException e) {
-                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
-            }
-
-            this.typeId = reader.portableContext().descriptorForClass(cls).typeId();
-        }
-        else {
-            this.typeId = typeId;
-            this.clsName = null;
-        }
-
-        ordinal = reader.readInt();
-    }
-
-    /**
-     * @return Ordinal.
-     */
-    public int getOrdinal() {
-        return ordinal;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        writer.writeByte(GridPortableMarshaller.ENUM);
-
-        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
-            writer.writeInt(GridPortableMarshaller.UNREGISTERED_TYPE_ID);
-            writer.writeString(clsName);
-        }
-        else
-            writer.writeInt(typeId);
-
-        writer.writeInt(ordinal);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object o) {
-        if (o == null || getClass() != o.getClass())
-            return false;
-
-        PortableBuilderEnum that = (PortableBuilderEnum)o;
-
-        return ordinal == that.ordinal && typeId == that.typeId;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        int result = ordinal;
-
-        result = 31 * result + typeId;
-
-        return result;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderImpl.java
deleted file mode 100644
index dac199a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderImpl.java
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
-import org.apache.ignite.internal.util.GridArgumentCheck;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.portable.PortableBuilder;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableInvalidClassException;
-import org.apache.ignite.portable.PortableMetadata;
-import org.apache.ignite.portable.PortableObject;
-import org.jetbrains.annotations.Nullable;
-
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLS_NAME_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.HASH_CODE_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.RAW_DATA_OFF_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TYPE_ID_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
-
-/**
- *
- */
-public class PortableBuilderImpl implements PortableBuilder {
-    /** */
-    private static final Object REMOVED_FIELD_MARKER = new Object();
-
-    /** */
-    private final PortableContext ctx;
-
-    /** */
-    private final int typeId;
-
-    /** May be null. */
-    private String typeName;
-
-    /** May be null. */
-    private String clsNameToWrite;
-
-    /** */
-    private boolean registeredType = true;
-
-    /** */
-    private Map<String, Object> assignedVals;
-
-    /** */
-    private Map<Integer, Object> readCache;
-
-    /** Position of object in source array, or -1 if object is not created from PortableObject. */
-    private final int start;
-
-    /** Total header length */
-    private final int hdrLen;
-
-    /**
-     * Context of PortableObject reading process. Or {@code null} if object is not created from PortableObject.
-     */
-    private final PortableBuilderReader reader;
-
-    /** */
-    private int hashCode;
-
-    /**
-     * @param clsName Class name.
-     * @param ctx Portable context.
-     */
-    public PortableBuilderImpl(PortableContext ctx, String clsName) {
-        this(ctx, ctx.typeId(clsName), PortableContext.typeName(clsName));
-    }
-
-    /**
-     * @param typeId Type ID.
-     * @param ctx Portable context.
-     */
-    public PortableBuilderImpl(PortableContext ctx, int typeId) {
-        this(ctx, typeId, null);
-    }
-
-    /**
-     * @param typeName Type name.
-     * @param ctx Context.
-     * @param typeId Type id.
-     */
-    public PortableBuilderImpl(PortableContext ctx, int typeId, String typeName) {
-        this.typeId = typeId;
-        this.typeName = typeName;
-        this.ctx = ctx;
-
-        start = -1;
-        reader = null;
-        hdrLen = DFLT_HDR_LEN;
-
-        readCache = Collections.emptyMap();
-    }
-
-    /**
-     * @param obj Object to wrap.
-     */
-    public PortableBuilderImpl(PortableObjectImpl obj) {
-        this(new PortableBuilderReader(obj), obj.start());
-
-        reader.registerObject(this);
-    }
-
-    /**
-     * @param reader ctx
-     * @param start Start.
-     */
-    PortableBuilderImpl(PortableBuilderReader reader, int start) {
-        this.reader = reader;
-        this.start = start;
-
-        int typeId = reader.readIntAbsolute(start + TYPE_ID_POS);
-        ctx = reader.portableContext();
-        hashCode = reader.readIntAbsolute(start + HASH_CODE_POS);
-
-        if (typeId == UNREGISTERED_TYPE_ID) {
-            int mark = reader.position();
-
-            reader.position(start + CLS_NAME_POS);
-
-            clsNameToWrite = reader.readString();
-
-            Class cls;
-
-            try {
-                // TODO: IGNITE-1272 - Is class loader needed here?
-                cls = U.forName(clsNameToWrite, null);
-            }
-            catch (ClassNotFoundException e) {
-                throw new PortableInvalidClassException("Failed to load the class: " + clsNameToWrite, e);
-            }
-
-            this.typeId = ctx.descriptorForClass(cls).typeId();
-
-            registeredType = false;
-
-            hdrLen = reader.position() - mark;
-
-            reader.position(mark);
-        }
-        else {
-            this.typeId = typeId;
-            hdrLen = DFLT_HDR_LEN;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public PortableObject build() {
-        try (PortableWriterExImpl writer = new PortableWriterExImpl(ctx, 0, typeId, false)) {
-
-            PortableBuilderSerializer serializationCtx = new PortableBuilderSerializer();
-
-            serializationCtx.registerObjectWriting(this, 0);
-
-            serializeTo(writer, serializationCtx);
-
-            byte[] arr = writer.array();
-
-            return new PortableObjectImpl(ctx, arr, 0);
-        }
-    }
-
-    /**
-     * @param writer Writer.
-     * @param serializer Serializer.
-     */
-    void serializeTo(PortableWriterExImpl writer, PortableBuilderSerializer serializer) {
-        writer.doWriteByte(GridPortableMarshaller.OBJ);
-        writer.doWriteBoolean(true);
-        writer.doWriteInt(registeredType ? typeId : UNREGISTERED_TYPE_ID);
-        writer.doWriteInt(hashCode);
-
-        // Length and raw offset.
-        writer.reserve(8);
-
-        if (!registeredType)
-            writer.writeString(clsNameToWrite);
-
-
-        Set<Integer> remainsFlds = null;
-
-        if (reader != null) {
-            Map<Integer, Object> assignedFldsById;
-
-            if (assignedVals != null) {
-                assignedFldsById = U.newHashMap(assignedVals.size());
-
-                for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
-                    int fldId = ctx.fieldId(typeId, entry.getKey());
-
-                    assignedFldsById.put(fldId, entry.getValue());
-                }
-
-                remainsFlds = assignedFldsById.keySet();
-            }
-            else
-                assignedFldsById = Collections.emptyMap();
-
-            int rawOff = start + reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
-
-            reader.position(start + hdrLen);
-
-            int cpStart = -1;
-
-            while (reader.position() < rawOff) {
-                int fldId = reader.readInt();
-
-                int len = reader.readInt();
-
-                if (assignedFldsById.containsKey(fldId)) {
-                    if (cpStart >= 0) {
-                        writer.write(reader.array(), cpStart, reader.position() - 4 - 4 - cpStart);
-
-                        cpStart = -1;
-                    }
-
-                    Object assignedVal = assignedFldsById.remove(fldId);
-
-                    reader.skip(len);
-
-                    if (assignedVal != REMOVED_FIELD_MARKER) {
-                        writer.writeInt(fldId);
-
-                        int lenPos = writer.reserveAndMark(4);
-
-                        serializer.writeValue(writer, assignedVal);
-
-                        writer.writeDelta(lenPos);
-                    }
-                }
-                else {
-                    if (len != 0 && PortableUtils.isPlainType(reader.readByte(0))) {
-                        if (cpStart < 0)
-                            cpStart = reader.position() - 4 - 4;
-
-                        reader.skip(len);
-                    }
-                    else {
-                        if (cpStart >= 0) {
-                            writer.write(reader.array(), cpStart, reader.position() - 4 - cpStart);
-
-                            cpStart = -1;
-                        }
-                        else
-                            writer.writeInt(fldId);
-
-                        Object val;
-
-                        if (len == 0)
-                            val = null;
-                        else if (readCache == null) {
-                            int savedPos = reader.position();
-
-                            val = reader.parseValue();
-
-                            assert reader.position() == savedPos + len;
-                        }
-                        else {
-                            val = readCache.get(fldId);
-
-                            reader.skip(len);
-                        }
-
-                        int lenPos = writer.reserveAndMark(4);
-
-                        serializer.writeValue(writer, val);
-
-                        writer.writeDelta(lenPos);
-                    }
-                }
-            }
-
-            if (cpStart >= 0)
-                writer.write(reader.array(), cpStart, reader.position() - cpStart);
-        }
-
-        if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) {
-            boolean metadataEnabled = ctx.isMetaDataEnabled(typeId);
-
-            PortableMetadata metadata = null;
-
-            if (metadataEnabled)
-                metadata = ctx.metaData(typeId);
-
-            Map<String, String> newFldsMetadata = null;
-
-            for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
-                Object val = entry.getValue();
-
-                if (val == REMOVED_FIELD_MARKER)
-                    continue;
-
-                String name = entry.getKey();
-
-                int fldId = ctx.fieldId(typeId, name);
-
-                if (remainsFlds != null && !remainsFlds.contains(fldId))
-                    continue;
-
-                writer.writeInt(fldId);
-
-                int lenPos = writer.reserveAndMark(4);
-
-                serializer.writeValue(writer, val);
-
-                writer.writeDelta(lenPos);
-
-                if (metadataEnabled) {
-                    String oldFldTypeName = metadata == null ? null : metadata.fieldTypeName(name);
-
-                    String newFldTypeName;
-
-                    if (val instanceof PortableValueWithType)
-                        newFldTypeName = ((PortableValueWithType)val).typeName();
-                    else {
-                        byte type = PortableUtils.typeByClass(val.getClass());
-
-                        newFldTypeName = CacheObjectPortableProcessorImpl.fieldTypeName(type);
-                    }
-
-                    if (oldFldTypeName == null) {
-                        // It's a new field, we have to add it to metadata.
-
-                        if (newFldsMetadata == null)
-                            newFldsMetadata = new HashMap<>();
-
-                        newFldsMetadata.put(name, newFldTypeName);
-                    }
-                    else {
-                        if (!"Object".equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) {
-                            throw new PortableException(
-                                "Wrong value has been set [" +
-                                    "typeName=" + (typeName == null ? metadata.typeName() : typeName) +
-                                    ", fieldName=" + name +
-                                    ", fieldType=" + oldFldTypeName +
-                                    ", assignedValueType=" + newFldTypeName +
-                                    ", assignedValue=" + (((PortableValueWithType)val).value()) + ']'
-                            );
-                        }
-                    }
-                }
-            }
-
-            if (newFldsMetadata != null) {
-                String typeName = this.typeName;
-
-                if (typeName == null)
-                    typeName = metadata.typeName();
-
-                ctx.updateMetaData(typeId, typeName, newFldsMetadata);
-            }
-        }
-
-        writer.writeRawOffsetIfNeeded();
-
-        if (reader != null) {
-            int rawOff = reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
-            int len = reader.readIntAbsolute(start + TOTAL_LEN_POS);
-
-            if (rawOff < len)
-                writer.write(reader.array(), rawOff, len - rawOff);
-        }
-
-        writer.writeLength();
-    }
-
-    /** {@inheritDoc} */
-    @Override public PortableBuilderImpl hashCode(int hashCode) {
-        this.hashCode = hashCode;
-
-        return this;
-    }
-
-    /**
-     *
-     */
-    private void ensureReadCacheInit() {
-        if (readCache == null) {
-            Map<Integer, Object> readCache = new HashMap<>();
-
-            int pos = start + hdrLen;
-            int end = start + reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
-
-            while (pos < end) {
-                int fieldId = reader.readIntAbsolute(pos);
-
-                pos += 4;
-
-                int len = reader.readIntAbsolute(pos);
-
-                pos += 4;
-
-                Object val = reader.getValueQuickly(pos, len);
-
-                readCache.put(fieldId, val);
-
-                pos += len;
-            }
-
-            this.readCache = readCache;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <F> F getField(String name) {
-        Object val;
-
-        if (assignedVals != null && assignedVals.containsKey(name)) {
-            val = assignedVals.get(name);
-
-            if (val == REMOVED_FIELD_MARKER)
-                return null;
-        }
-        else {
-            ensureReadCacheInit();
-
-            int fldId = ctx.fieldId(typeId, name);
-
-            val = readCache.get(fldId);
-        }
-
-        return (F)PortableUtils.unwrapLazy(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public PortableBuilder setField(String name, Object val) {
-        GridArgumentCheck.notNull(val, "val");
-
-        if (assignedVals == null)
-            assignedVals = new LinkedHashMap<>();
-
-        Object oldVal = assignedVals.put(name, val);
-
-        if (oldVal instanceof PortableValueWithType) {
-            ((PortableValueWithType)oldVal).value(val);
-
-            assignedVals.put(name, oldVal);
-        }
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> PortableBuilder setField(String name, @Nullable T val, Class<? super T> type) {
-        if (assignedVals == null)
-            assignedVals = new LinkedHashMap<>();
-
-        //int fldId = ctx.fieldId(typeId, fldName);
-
-        assignedVals.put(name, new PortableValueWithType(PortableUtils.typeByClass(type), val));
-
-        return this;
-    }
-
-    /** {@inheritDoc} */
-    @Override public PortableBuilder setField(String name, @Nullable PortableBuilder builder) {
-        if (builder == null)
-            return setField(name, null, Object.class);
-        else
-            return setField(name, (Object)builder);
-    }
-
-    /**
-     * Removes field from portable object.
-     *
-     * @param name Field name.
-     * @return {@code this} instance for chaining.
-     */
-    @Override public PortableBuilderImpl removeField(String name) {
-        if (assignedVals == null)
-            assignedVals = new LinkedHashMap<>();
-
-        assignedVals.put(name, REMOVED_FIELD_MARKER);
-
-        return this;
-    }
-
-    /**
-     * Creates builder initialized by specified portable object.
-     *
-     * @param obj Portable object to initialize builder.
-     * @return New builder.
-     */
-    public static PortableBuilderImpl wrap(PortableObject obj) {
-        PortableObjectImpl heapObj;
-
-        if (obj instanceof PortableObjectOffheapImpl)
-            heapObj = (PortableObjectImpl)((PortableObjectOffheapImpl)obj).heapCopy();
-        else
-            heapObj = (PortableObjectImpl)obj;
-
-        return new PortableBuilderImpl(heapObj);
-    }
-
-    /**
-     * @return Object start position in source array.
-     */
-    int start() {
-        return start;
-    }
-
-    /**
-     * @return Object type id.
-     */
-    int typeId() {
-        return typeId;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderReader.java
deleted file mode 100644
index 30b31f0..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderReader.java
+++ /dev/null
@@ -1,776 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.portable.PortableException;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
-
-/**
- *
- */
-class PortableBuilderReader {
-    /** */
-    private static final PortablePrimitives PRIM = PortablePrimitives.get();
-
-    /** */
-    private final Map<Integer, PortableBuilderImpl> objMap = new HashMap<>();
-
-    /** */
-    private final PortableContext ctx;
-
-    /** */
-    private final PortableReaderExImpl reader;
-
-    /** */
-    private byte[] arr;
-
-    /** */
-    private int pos;
-
-    /**
-     * @param objImpl Portable object
-     */
-    PortableBuilderReader(PortableObjectImpl objImpl) {
-        ctx = objImpl.context();
-        arr = objImpl.array();
-        pos = objImpl.start();
-
-        // TODO: IGNITE-1272 - Is class loader needed here?
-        reader = new PortableReaderExImpl(portableContext(), arr, pos, null);
-    }
-
-    /**
-     * @return Portable context.
-     */
-    public PortableContext portableContext() {
-        return ctx;
-    }
-
-    /**
-     * @param obj Mutable portable object.
-     */
-    public void registerObject(PortableBuilderImpl obj) {
-        objMap.put(obj.start(), obj);
-    }
-
-    /**
-     * @return Read int value.
-     */
-    public int readInt() {
-        int res = readInt(0);
-
-        pos += 4;
-
-        return res;
-    }
-
-    /**
-     * @return Read int value.
-     */
-    public byte readByte() {
-        return arr[pos++];
-    }
-
-    /**
-     * @return Read boolean value.
-     */
-    public boolean readBoolean() {
-        return readByte() == 1;
-    }
-
-    /**
-     * @return Read int value.
-     */
-    public byte readByte(int off) {
-        return arr[pos + off];
-    }
-
-    /**
-     * @param off Offset related to {@link #pos}
-     * @return Read int value.
-     */
-    public int readInt(int off) {
-        return PRIM.readInt(arr, pos + off);
-    }
-
-    /**
-     * @param pos Position in the source array.
-     * @return Read int value.
-     */
-    public int readIntAbsolute(int pos) {
-        return PRIM.readInt(arr, pos);
-    }
-
-    /**
-     * @return Read length of array.
-     */
-    public int readLength() {
-        return PRIM.readInt(arr, pos);
-    }
-
-    /**
-     * Read string length.
-     *
-     * @return String length.
-     */
-    public int readStringLength() {
-        boolean utf = PRIM.readBoolean(arr, pos);
-
-        int arrLen = PRIM.readInt(arr, pos + 1);
-
-        return 1 + (utf ? arrLen : arrLen << 1);
-    }
-
-    /**
-     * Reads string.
-     *
-     * @return String.
-     */
-    public String readString() {
-        byte flag = readByte();
-
-        if (flag == NULL)
-            return null;
-
-        if (flag != STRING)
-            throw new PortableException("Failed to deserialize String.");
-
-        boolean convert = readBoolean();
-        int len = readInt();
-
-        String str;
-
-        if (convert) {
-            str = new String(arr, pos, len, UTF_8);
-
-            pos += len;
-        }
-        else {
-            str = String.valueOf(PRIM.readCharArray(arr, pos, len));
-
-            pos += len << 1;
-        }
-
-        return str;
-    }
-
-    /**
-     *
-     */
-    public void skipValue() {
-        byte type = arr[pos++];
-
-        int len;
-
-        switch (type) {
-            case GridPortableMarshaller.NULL:
-                return;
-
-            case GridPortableMarshaller.OBJ:
-                pos += readInt(GridPortableMarshaller.TOTAL_LEN_POS - 1) - 1;
-
-                return;
-
-            case GridPortableMarshaller.BOOLEAN:
-            case GridPortableMarshaller.BYTE:
-                len = 1;
-                break;
-
-            case GridPortableMarshaller.CHAR:
-            case GridPortableMarshaller.SHORT:
-                len = 2;
-
-                break;
-
-            case GridPortableMarshaller.HANDLE:
-            case GridPortableMarshaller.FLOAT:
-            case GridPortableMarshaller.INT:
-                len = 4;
-
-                break;
-
-            case GridPortableMarshaller.ENUM:
-                //skipping type id and ordinal value
-                len = 8;
-
-                break;
-
-            case GridPortableMarshaller.LONG:
-            case GridPortableMarshaller.DOUBLE:
-                len = 8;
-
-                break;
-
-            case GridPortableMarshaller.BYTE_ARR:
-            case GridPortableMarshaller.BOOLEAN_ARR:
-                len = 4 + readLength();
-
-                break;
-
-            case GridPortableMarshaller.STRING:
-                len = 4 + readStringLength();
-
-                break;
-
-            case GridPortableMarshaller.DECIMAL:
-                len = /** scale */ 4  + /** mag len */ 4  + /** mag bytes count */ readInt(4);
-
-                break;
-
-            case GridPortableMarshaller.UUID:
-                len = 8 + 8;
-
-                break;
-
-            case GridPortableMarshaller.DATE:
-                len = 8 + 4;
-
-                break;
-
-            case GridPortableMarshaller.CHAR_ARR:
-            case GridPortableMarshaller.SHORT_ARR:
-                len = 4 + readLength() * 2;
-
-                break;
-
-            case GridPortableMarshaller.INT_ARR:
-            case GridPortableMarshaller.FLOAT_ARR:
-                len = 4 + readLength() * 4;
-
-                break;
-
-            case GridPortableMarshaller.LONG_ARR:
-            case GridPortableMarshaller.DOUBLE_ARR:
-                len = 4 + readLength() * 8;
-
-                break;
-
-            case GridPortableMarshaller.DECIMAL_ARR:
-            case GridPortableMarshaller.DATE_ARR:
-            case GridPortableMarshaller.OBJ_ARR:
-            case GridPortableMarshaller.ENUM_ARR:
-            case GridPortableMarshaller.UUID_ARR:
-            case GridPortableMarshaller.STRING_ARR: {
-                int size = readInt();
-
-                for (int i = 0; i < size; i++)
-                    skipValue();
-
-                return;
-            }
-
-            case GridPortableMarshaller.COL: {
-                int size = readInt();
-
-                pos++; // skip collection type
-
-                for (int i = 0; i < size; i++)
-                    skipValue();
-
-                return;
-            }
-
-            case GridPortableMarshaller.MAP: {
-                int size = readInt();
-
-                pos++; // skip collection type
-
-                for (int i = 0; i < size; i++) {
-                    skipValue(); // skip key.
-                    skipValue(); // skip value.
-                }
-
-                return;
-            }
-
-            case GridPortableMarshaller.MAP_ENTRY:
-                skipValue();
-                skipValue();
-
-                return;
-
-            case GridPortableMarshaller.PORTABLE_OBJ:
-                len = readInt() + 4;
-
-                break;
-
-            default:
-                throw new PortableException("Invalid flag value: " + type);
-        }
-
-        pos += len;
-    }
-
-    /**
-     * @param pos Position.
-     * @param len Length.
-     * @return Object.
-     */
-    public Object getValueQuickly(int pos, int len) {
-        byte type = arr[pos];
-
-        switch (type) {
-            case GridPortableMarshaller.NULL:
-                return null;
-
-            case GridPortableMarshaller.HANDLE: {
-                int objStart = pos - readIntAbsolute(pos + 1);
-
-                PortableBuilderImpl res = objMap.get(objStart);
-
-                if (res == null) {
-                    res = new PortableBuilderImpl(this, objStart);
-
-                    objMap.put(objStart, res);
-                }
-
-                return res;
-            }
-
-            case GridPortableMarshaller.OBJ: {
-                PortableBuilderImpl res = objMap.get(pos);
-
-                if (res == null) {
-                    res = new PortableBuilderImpl(this, pos);
-
-                    objMap.put(pos, res);
-                }
-
-                return res;
-            }
-
-            case GridPortableMarshaller.BYTE:
-                return arr[pos + 1];
-
-            case GridPortableMarshaller.SHORT:
-                return PRIM.readShort(arr, pos + 1);
-
-            case GridPortableMarshaller.INT:
-                return PRIM.readInt(arr, pos + 1);
-
-            case GridPortableMarshaller.LONG:
-                return PRIM.readLong(arr, pos + 1);
-
-            case GridPortableMarshaller.FLOAT:
-                return PRIM.readFloat(arr, pos + 1);
-
-            case GridPortableMarshaller.DOUBLE:
-                return PRIM.readDouble(arr, pos + 1);
-
-            case GridPortableMarshaller.CHAR:
-                return PRIM.readChar(arr, pos + 1);
-
-            case GridPortableMarshaller.BOOLEAN:
-                return arr[pos + 1] != 0;
-
-            case GridPortableMarshaller.DECIMAL:
-            case GridPortableMarshaller.STRING:
-            case GridPortableMarshaller.UUID:
-            case GridPortableMarshaller.DATE:
-            case GridPortableMarshaller.BYTE_ARR:
-            case GridPortableMarshaller.SHORT_ARR:
-            case GridPortableMarshaller.INT_ARR:
-            case GridPortableMarshaller.LONG_ARR:
-            case GridPortableMarshaller.FLOAT_ARR:
-            case GridPortableMarshaller.DOUBLE_ARR:
-            case GridPortableMarshaller.CHAR_ARR:
-            case GridPortableMarshaller.BOOLEAN_ARR:
-            case GridPortableMarshaller.DECIMAL_ARR:
-            case GridPortableMarshaller.DATE_ARR:
-            case GridPortableMarshaller.UUID_ARR:
-            case GridPortableMarshaller.STRING_ARR:
-                return new PortablePlainLazyValue(this, pos, len);
-
-            case GridPortableMarshaller.COL:
-            case GridPortableMarshaller.OBJ_ARR:
-            case GridPortableMarshaller.MAP:
-            case GridPortableMarshaller.ENUM_ARR:
-            case GridPortableMarshaller.MAP_ENTRY:
-                return new LazyCollection(pos);
-
-            case GridPortableMarshaller.ENUM: {
-                if (len == 1) {
-                    assert readByte(pos) == GridPortableMarshaller.NULL;
-
-                    return null;
-                }
-
-                int mark = position();
-                position(pos + 1);
-
-                PortableBuilderEnum builderEnum = new PortableBuilderEnum(this);
-
-                position(mark);
-
-                return builderEnum;
-            }
-
-            case GridPortableMarshaller.PORTABLE_OBJ: {
-                int size = readIntAbsolute(pos + 1);
-
-                int start = readIntAbsolute(pos + 4 + size);
-
-                PortableObjectImpl portableObj = new PortableObjectImpl(ctx, arr, pos + 4 + start);
-
-                return new PortablePlainPortableObject(portableObj);
-            }
-
-            default:
-                throw new PortableException("Invalid flag value: " + type);
-        }
-    }
-
-    /**
-     * @return Parsed value.
-     */
-    public Object parseValue() {
-        int valPos = pos;
-
-        byte type = arr[pos++];
-
-        int plainLazyValLen;
-
-        switch (type) {
-            case GridPortableMarshaller.NULL:
-                return null;
-
-            case GridPortableMarshaller.HANDLE: {
-                int objStart = pos - 1 - readInt();
-
-                PortableBuilderImpl res = objMap.get(objStart);
-
-                if (res == null) {
-                    res = new PortableBuilderImpl(this, objStart);
-
-                    objMap.put(objStart, res);
-                }
-
-                return res;
-            }
-
-            case GridPortableMarshaller.OBJ: {
-                pos--;
-
-                PortableBuilderImpl res = objMap.get(pos);
-
-                if (res == null) {
-                    res = new PortableBuilderImpl(this, pos);
-
-                    objMap.put(pos, res);
-                }
-
-                pos += readInt(GridPortableMarshaller.TOTAL_LEN_POS);
-
-                return res;
-            }
-
-            case GridPortableMarshaller.BYTE:
-                return arr[pos++];
-
-            case GridPortableMarshaller.SHORT: {
-                Object res = PRIM.readShort(arr, pos);
-                pos += 2;
-                return res;
-            }
-
-            case GridPortableMarshaller.INT:
-                return readInt();
-
-            case GridPortableMarshaller.LONG:
-                plainLazyValLen = 8;
-
-                break;
-
-            case GridPortableMarshaller.FLOAT:
-                plainLazyValLen = 4;
-
-                break;
-
-            case GridPortableMarshaller.DOUBLE:
-                plainLazyValLen = 8;
-
-                break;
-
-            case GridPortableMarshaller.CHAR:
-                plainLazyValLen = 2;
-
-                break;
-
-            case GridPortableMarshaller.BOOLEAN:
-                return arr[pos++] != 0;
-
-            case GridPortableMarshaller.DECIMAL:
-                plainLazyValLen = /** scale */ 4  + /** mag len */ 4  + /** mag bytes count */ readInt(4);
-
-                break;
-
-            case GridPortableMarshaller.STRING:
-                plainLazyValLen = 4 + readStringLength();
-
-                break;
-
-            case GridPortableMarshaller.UUID:
-                plainLazyValLen = 8 + 8;
-
-                break;
-
-            case GridPortableMarshaller.DATE:
-                plainLazyValLen = 8 + 4;
-
-                break;
-
-            case GridPortableMarshaller.BYTE_ARR:
-                plainLazyValLen = 4 + readLength();
-
-                break;
-
-            case GridPortableMarshaller.SHORT_ARR:
-                plainLazyValLen = 4 + readLength() * 2;
-
-                break;
-
-            case GridPortableMarshaller.INT_ARR:
-                plainLazyValLen = 4 + readLength() * 4;
-
-                break;
-
-            case GridPortableMarshaller.LONG_ARR:
-                plainLazyValLen = 4 + readLength() * 8;
-
-                break;
-
-            case GridPortableMarshaller.FLOAT_ARR:
-                plainLazyValLen = 4 + readLength() * 4;
-
-                break;
-
-            case GridPortableMarshaller.DOUBLE_ARR:
-                plainLazyValLen = 4 + readLength() * 8;
-
-                break;
-
-            case GridPortableMarshaller.CHAR_ARR:
-                plainLazyValLen = 4 + readLength() * 2;
-
-                break;
-
-            case GridPortableMarshaller.BOOLEAN_ARR:
-                plainLazyValLen = 4 + readLength();
-
-                break;
-
-            case GridPortableMarshaller.OBJ_ARR:
-                return new PortableObjectArrayLazyValue(this);
-
-            case GridPortableMarshaller.DATE_ARR: {
-                int size = readInt();
-
-                Date[] res = new Date[size];
-
-                for (int i = 0; i < res.length; i++) {
-                    byte flag = arr[pos++];
-
-                    if (flag == GridPortableMarshaller.NULL) continue;
-
-                    if (flag != GridPortableMarshaller.DATE)
-                        throw new PortableException("Invalid flag value: " + flag);
-
-                    long time = PRIM.readLong(arr, pos);
-
-                    pos += 8;
-
-                    if (ctx.isUseTimestamp()) {
-                        Timestamp ts = new Timestamp(time);
-
-                        ts.setNanos(ts.getNanos() + readInt());
-
-                        res[i] = ts;
-                    }
-                    else {
-                        res[i] = new Date(time);
-
-                        pos += 4;
-                    }
-                }
-
-                return res;
-            }
-
-            case GridPortableMarshaller.UUID_ARR:
-            case GridPortableMarshaller.STRING_ARR:
-            case GridPortableMarshaller.DECIMAL_ARR: {
-                int size = readInt();
-
-                for (int i = 0; i < size; i++) {
-                    byte flag = arr[pos++];
-
-                    if (flag == GridPortableMarshaller.UUID)
-                        pos += 8 + 8;
-                    else if (flag == GridPortableMarshaller.STRING)
-                        pos += 4 + readStringLength();
-                    else if (flag == GridPortableMarshaller.DECIMAL)
-                        pos += 4 + readLength();
-                    else
-                        assert flag == GridPortableMarshaller.NULL;
-                }
-
-                return new PortablePlainLazyValue(this, valPos, pos - valPos);
-            }
-
-            case GridPortableMarshaller.COL: {
-                int size = readInt();
-                byte colType = arr[pos++];
-
-                switch (colType) {
-                    case GridPortableMarshaller.USER_COL:
-                    case GridPortableMarshaller.ARR_LIST:
-                        return new PortableLazyArrayList(this, size);
-
-                    case GridPortableMarshaller.LINKED_LIST:
-                        return new PortableLazyLinkedList(this, size);
-
-                    case GridPortableMarshaller.HASH_SET:
-                    case GridPortableMarshaller.LINKED_HASH_SET:
-                    case GridPortableMarshaller.TREE_SET:
-                    case GridPortableMarshaller.CONC_SKIP_LIST_SET:
-                        return new PortableLazySet(this, size);
-                }
-
-                throw new PortableException("Unknown collection type: " + colType);
-            }
-
-            case GridPortableMarshaller.MAP:
-                return PortableLazyMap.parseMap(this);
-
-            case GridPortableMarshaller.ENUM:
-                return new PortableBuilderEnum(this);
-
-            case GridPortableMarshaller.ENUM_ARR:
-                return new PortableEnumArrayLazyValue(this);
-
-            case GridPortableMarshaller.MAP_ENTRY:
-                return new PortableLazyMapEntry(this);
-
-            case GridPortableMarshaller.PORTABLE_OBJ: {
-                int size = readInt();
-
-                pos += size;
-
-                int start = readInt();
-
-                PortableObjectImpl portableObj = new PortableObjectImpl(ctx, arr,
-                    pos - 4 - size + start);
-
-                return new PortablePlainPortableObject(portableObj);
-            }
-
-
-            default:
-                throw new PortableException("Invalid flag value: " + type);
-        }
-
-        PortablePlainLazyValue res = new PortablePlainLazyValue(this, valPos, 1 + plainLazyValLen);
-
-        pos += plainLazyValLen;
-
-        return res;
-    }
-
-    /**
-     * @return Array.
-     */
-    public byte[] array() {
-        return arr;
-    }
-
-    /**
-     * @return Position of reader.
-     */
-    public int position() {
-        return pos;
-    }
-
-    /**
-     * @param pos New pos.
-     */
-    public void position(int pos) {
-        this.pos = pos;
-    }
-
-    /**
-     * @param n Number of bytes to skip.
-     */
-    public void skip(int n) {
-        pos += n;
-    }
-
-    /**
-     * @return Reader.
-     */
-    PortableReaderExImpl reader() {
-        return reader;
-    }
-
-    /**
-     *
-     */
-    private class LazyCollection implements PortableLazyValue {
-        /** */
-        private final int valOff;
-
-        /** */
-        private Object col;
-
-        /**
-         * @param valOff Value.
-         */
-        protected LazyCollection(int valOff) {
-            this.valOff = valOff;
-        }
-
-        /**
-         * @return Object.
-         */
-        private Object wrappedCollection() {
-            if (col == null) {
-                position(valOff);
-
-                col = parseValue();
-            }
-
-            return col;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-            ctx.writeValue(writer, wrappedCollection());
-        }
-
-        /** {@inheritDoc} */
-        @Override public Object value() {
-            return PortableUtils.unwrapLazy(wrappedCollection());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializationAware.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializationAware.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializationAware.java
deleted file mode 100644
index d75cd7b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializationAware.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-/**
- *
- */
-interface PortableBuilderSerializationAware {
-    /**
-     * @param writer Writer.
-     * @param ctx Context.
-     */
-    public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializer.java
deleted file mode 100644
index 6ce9f4c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableBuilderSerializer.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.Collection;
-import java.util.IdentityHashMap;
-import java.util.Map;
-import org.apache.ignite.internal.util.GridConcurrentSkipListSet;
-import org.apache.ignite.portable.PortableObject;
-
-/**
- *
- */
-class PortableBuilderSerializer {
-    /** */
-    private final Map<PortableBuilderImpl, Integer> objToPos = new IdentityHashMap<>();
-
-    /** */
-    private Map<PortableObject, PortableBuilderImpl> portableObjToWrapper;
-
-    /**
-     * @param obj Mutable object.
-     * @param posInResArr Object position in the array.
-     */
-    public void registerObjectWriting(PortableBuilderImpl obj, int posInResArr) {
-        objToPos.put(obj, posInResArr);
-    }
-
-    /**
-     * @param writer Writer.
-     * @param val Value.
-     */
-    public void writeValue(PortableWriterExImpl writer, Object val) {
-        if (val == null) {
-            writer.writeByte(GridPortableMarshaller.NULL);
-
-            return;
-        }
-
-        if (val instanceof PortableBuilderSerializationAware) {
-            ((PortableBuilderSerializationAware)val).writeTo(writer, this);
-
-            return;
-        }
-
-        if (val instanceof PortableObjectEx) {
-            if (portableObjToWrapper == null)
-                portableObjToWrapper = new IdentityHashMap<>();
-
-            PortableBuilderImpl wrapper = portableObjToWrapper.get(val);
-
-            if (wrapper == null) {
-                wrapper = PortableBuilderImpl.wrap((PortableObject)val);
-
-                portableObjToWrapper.put((PortableObject)val, wrapper);
-            }
-
-            val = wrapper;
-        }
-
-        if (val instanceof PortableBuilderImpl) {
-            PortableBuilderImpl obj = (PortableBuilderImpl)val;
-
-            Integer posInResArr = objToPos.get(obj);
-
-            if (posInResArr == null) {
-                objToPos.put(obj, writer.outputStream().position());
-
-                obj.serializeTo(writer.newWriter(obj.typeId()), this);
-            }
-            else {
-                int handle = writer.outputStream().position() - posInResArr;
-
-                writer.writeByte(GridPortableMarshaller.HANDLE);
-                writer.writeInt(handle);
-            }
-
-            return;
-        }
-
-        if (val.getClass().isEnum()) {
-            writer.writeByte(GridPortableMarshaller.ENUM);
-            writer.writeInt(writer.context().typeId(val.getClass().getName()));
-            writer.writeInt(((Enum)val).ordinal());
-
-            return;
-        }
-
-        if (val instanceof Collection) {
-            Collection<?> c = (Collection<?>)val;
-
-            writer.writeByte(GridPortableMarshaller.COL);
-            writer.writeInt(c.size());
-
-            byte colType;
-
-            if (c instanceof GridConcurrentSkipListSet)
-                colType = GridPortableMarshaller.CONC_SKIP_LIST_SET;
-            else
-                colType = writer.context().collectionType(c.getClass());
-
-
-            writer.writeByte(colType);
-
-            for (Object obj : c)
-                writeValue(writer, obj);
-
-            return;
-        }
-
-        if (val instanceof Map) {
-            Map<?, ?> map = (Map<?, ?>)val;
-
-            writer.writeByte(GridPortableMarshaller.MAP);
-            writer.writeInt(map.size());
-
-            writer.writeByte(writer.context().mapType(map.getClass()));
-
-            for (Map.Entry<?, ?> entry : map.entrySet()) {
-                writeValue(writer, entry.getKey());
-                writeValue(writer, entry.getValue());
-            }
-
-            return;
-        }
-
-        Byte flag = PortableUtils.PLAIN_CLASS_TO_FLAG.get(val.getClass());
-
-        if (flag != null) {
-            PortableUtils.writePlainObject(writer, val);
-
-            return;
-        }
-
-        if (val instanceof Object[]) {
-            int compTypeId = writer.context().typeId(((Object[])val).getClass().getComponentType().getName());
-
-            if (val instanceof PortableBuilderEnum[]) {
-                writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, compTypeId);
-
-                return;
-            }
-
-            if (((Object[])val).getClass().getComponentType().isEnum()) {
-                Enum[] enumArr = (Enum[])val;
-
-                writer.writeByte(GridPortableMarshaller.ENUM_ARR);
-                writer.writeInt(compTypeId);
-                writer.writeInt(enumArr.length);
-
-                for (Enum anEnum : enumArr)
-                    writeValue(writer, anEnum);
-
-                return;
-            }
-
-            writeArray(writer, GridPortableMarshaller.OBJ_ARR, (Object[])val, compTypeId);
-
-            return;
-        }
-
-        writer.doWriteObject(val, false);
-    }
-
-    /**
-     * @param writer Writer.
-     * @param elementType Element type.
-     * @param arr The array.
-     * @param compTypeId Component type ID.
-     */
-    public void writeArray(PortableWriterExImpl writer, byte elementType, Object[] arr, int compTypeId) {
-        writer.writeByte(elementType);
-        writer.writeInt(compTypeId);
-        writer.writeInt(arr.length);
-
-        for (Object obj : arr)
-            writeValue(writer, obj);
-    }
-
-    /**
-     * @param writer Writer.
-     * @param elementType Element type.
-     * @param arr The array.
-     * @param clsName Component class name.
-     */
-    public void writeArray(PortableWriterExImpl writer, byte elementType, Object[] arr, String clsName) {
-        writer.writeByte(elementType);
-        writer.writeInt(GridPortableMarshaller.UNREGISTERED_TYPE_ID);
-        writer.writeString(clsName);
-        writer.writeInt(arr.length);
-
-        for (Object obj : arr)
-            writeValue(writer, obj);
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index 7e4266c..24ad5ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -48,7 +48,7 @@ import static java.lang.reflect.Modifier.isTransient;
 /**
  * Portable class descriptor.
  */
-class PortableClassDescriptor {
+public class PortableClassDescriptor {
     /** */
     private final PortableContext ctx;
 
@@ -123,7 +123,7 @@ class PortableClassDescriptor {
         boolean keepDeserialized
     ) throws PortableException {
         this(ctx, cls, userType, typeId, typeName, idMapper, serializer, useTs, metaDataEnabled, keepDeserialized,
-             true);
+            true);
     }
 
     /**
@@ -285,7 +285,7 @@ class PortableClassDescriptor {
     /**
      * @return Type ID.
      */
-    int typeId() {
+    public int typeId() {
         return typeId;
     }
 
@@ -399,7 +399,7 @@ class PortableClassDescriptor {
                 break;
 
             case DECIMAL:
-                writer.doWriteDecimal((BigDecimal) obj);
+                writer.doWriteDecimal((BigDecimal)obj);
 
                 break;
 
@@ -656,39 +656,32 @@ class PortableClassDescriptor {
      * @return Whether further write is needed.
      */
     private boolean writeHeader(Object obj, PortableWriterExImpl writer) {
-        int handle = writer.handle(obj);
-
-        if (handle >= 0) {
-            writer.doWriteByte(GridPortableMarshaller.HANDLE);
-            writer.doWriteInt(handle);
-
+        if (writer.tryWriteAsHandle(obj))
             return false;
-        }
-        else {
-            int pos = writer.position();
 
-            writer.doWriteByte(GridPortableMarshaller.OBJ);
-            writer.doWriteBoolean(userType);
-            writer.doWriteInt(registered ? typeId : GridPortableMarshaller.UNREGISTERED_TYPE_ID);
-            writer.doWriteInt(obj instanceof CacheObjectImpl ? 0 : obj.hashCode());
+        int pos = writer.position();
 
-            // For length and raw offset.
-            int reserved = writer.reserve(8);
+        writer.doWriteByte(GridPortableMarshaller.OBJ);
+        writer.doWriteBoolean(userType);
+        writer.doWriteInt(registered ? typeId : GridPortableMarshaller.UNREGISTERED_TYPE_ID);
+        writer.doWriteInt(obj instanceof CacheObjectImpl ? 0 : obj.hashCode());
 
-            // Class name in case if typeId registration is failed.
-            if (!registered)
-                writer.doWriteString(cls.getName());
+        // For length and raw offset.
+        int reserved = writer.reserve(8);
 
-            int current = writer.position();
-            int len = current - pos;
+        // Class name in case if typeId registration is failed.
+        if (!registered)
+            writer.doWriteString(cls.getName());
 
-            // Default raw offset (equal to header length).
-            writer.position(reserved + 4);
-            writer.doWriteInt(len);
-            writer.position(current);
+        int current = writer.position();
+        int len = current - pos;
 
-            return true;
-        }
+        // Default raw offset (equal to header length).
+        writer.position(reserved + 4);
+        writer.doWriteInt(len);
+        writer.position(current);
+
+        return true;
     }
 
     /**
@@ -787,7 +780,7 @@ class PortableClassDescriptor {
         else if (cls == PortableObjectImpl.class)
             return Mode.PORTABLE_OBJ;
         else if (PortableMarshalAware.class.isAssignableFrom(cls))
-           return Mode.PORTABLE;
+            return Mode.PORTABLE;
         else if (Externalizable.class.isAssignableFrom(cls))
             return Mode.EXTERNALIZABLE;
         else if (Map.Entry.class.isAssignableFrom(cls))
@@ -1352,4 +1345,4 @@ class PortableClassDescriptor {
             return typeName;
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 15b6433..db7e41e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -794,10 +794,10 @@ public class PortableContext implements Externalizable {
      * @param typeId Type ID.
      * @return Whether meta data is enabled.
      */
-    boolean isMetaDataEnabled(int typeId) {
+    public boolean isMetaDataEnabled(int typeId) {
         Boolean enabled = metaEnabled.get(typeId);
 
-        return enabled != null ? enabled : true;
+        return enabled != null ? enabled : metaDataEnabled;
     }
 
     /**
@@ -827,7 +827,7 @@ public class PortableContext implements Externalizable {
      * @param fields Fields map.
      * @throws PortableException In case of error.
      */
-    void updateMetaData(int typeId, String typeName, Map<String, String> fields) throws PortableException {
+    public void updateMetaData(int typeId, String typeName, Map<String, String> fields) throws PortableException {
         updateMetaData(typeId, new PortableMetaDataImpl(typeName, fields, null));
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableEnumArrayLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableEnumArrayLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableEnumArrayLazyValue.java
deleted file mode 100644
index c953bb3..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableEnumArrayLazyValue.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableInvalidClassException;
-
-/**
- *
- */
-class PortableEnumArrayLazyValue extends PortableAbstractLazyValue {
-    /** */
-    private final int len;
-
-    /** */
-    private final int compTypeId;
-
-    /** */
-    private final String clsName;
-
-    /**
-     * @param reader Reader.
-     */
-    protected PortableEnumArrayLazyValue(PortableBuilderReader reader) {
-        super(reader, reader.position() - 1);
-
-        int typeId = reader.readInt();
-
-        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
-            clsName = reader.readString();
-
-            Class cls;
-
-            try {
-                // TODO: IGNITE-1272 - Is class loader needed here?
-                cls = U.forName(reader.readString(), null);
-            }
-            catch (ClassNotFoundException e) {
-                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
-            }
-
-            compTypeId = reader.portableContext().descriptorForClass(cls).typeId();
-        }
-        else {
-            compTypeId = typeId;
-            clsName = null;
-        }
-
-        int size = reader.readInt();
-
-        for (int i = 0; i < size; i++)
-            reader.skipValue();
-
-        len = reader.position() - valOff;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Object init() {
-        reader.position(valOff + 1);
-
-        //skipping component type id
-        reader.readInt();
-
-        int size = reader.readInt();
-
-        PortableBuilderEnum[] res = new PortableBuilderEnum[size];
-
-        for (int i = 0; i < size; i++) {
-            byte flag = reader.readByte();
-
-            if (flag == GridPortableMarshaller.NULL)
-                continue;
-
-            if (flag != GridPortableMarshaller.ENUM)
-                throw new PortableException("Invalid flag value: " + flag);
-
-            res[i] = new PortableBuilderEnum(reader);
-        }
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (val != null) {
-            if (clsName != null)
-                ctx.writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, clsName);
-            else
-                ctx.writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, compTypeId);
-
-            return;
-        }
-
-        writer.write(reader.array(), valOff, len);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyArrayList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyArrayList.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyArrayList.java
deleted file mode 100644
index 84a0c22..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyArrayList.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- *
- */
-class PortableLazyArrayList extends AbstractList<Object> implements PortableBuilderSerializationAware {
-    /** */
-    private final PortableBuilderReader reader;
-
-    /** */
-    private final int off;
-
-    /** */
-    private List<Object> delegate;
-
-    /**
-     * @param reader Reader.
-     * @param size Size,
-     */
-    PortableLazyArrayList(PortableBuilderReader reader, int size) {
-        this.reader = reader;
-        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
-
-        assert size >= 0;
-
-        for (int i = 0; i < size; i++)
-            reader.skipValue();
-    }
-
-    /**
-     *
-     */
-    private void ensureDelegateInit() {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
-
-            delegate = new ArrayList<>(size);
-
-            for (int i = 0; i < size; i++)
-                delegate.add(reader.parseValue());
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object get(int idx) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.get(idx));
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean add(Object o) {
-        ensureDelegateInit();
-
-        return delegate.add(o);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void add(int idx, Object element) {
-        ensureDelegateInit();
-
-        delegate.add(idx, element);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object set(int idx, Object element) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.set(idx, element));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object remove(int idx) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.remove(idx));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() {
-        if (delegate == null)
-            delegate = new ArrayList<>();
-        else
-            delegate.clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean addAll(int idx, Collection<?> c) {
-        return delegate.addAll(idx, c);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void removeRange(int fromIdx, int toIdx) {
-        ensureDelegateInit();
-
-        delegate.subList(fromIdx, toIdx).clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        if (delegate == null)
-            return reader.readIntAbsolute(off + 1);
-
-        return delegate.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
-
-            writer.write(reader.array(), off, hdrSize);
-
-            reader.position(off + hdrSize);
-
-            for (int i = 0; i < size; i++) {
-                Object o = reader.parseValue();
-
-                ctx.writeValue(writer, o);
-            }
-        }
-        else {
-            writer.writeByte(GridPortableMarshaller.COL);
-            writer.writeInt(delegate.size());
-
-            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
-            writer.writeByte(colType);
-
-            for (Object o : delegate)
-                ctx.writeValue(writer, o);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyLinkedList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyLinkedList.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyLinkedList.java
deleted file mode 100644
index 7b2e15a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyLinkedList.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.AbstractList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- *
- */
-class PortableLazyLinkedList extends AbstractList<Object> implements PortableBuilderSerializationAware {
-    /** */
-    private final PortableBuilderReader reader;
-
-    /** */
-    private final int off;
-
-    /** */
-    private List<Object> delegate;
-
-    /**
-     * @param reader Reader.
-     * @param size Size,
-     */
-    PortableLazyLinkedList(PortableBuilderReader reader, int size) {
-        this.reader = reader;
-        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
-
-        assert size >= 0;
-
-        for (int i = 0; i < size; i++)
-            reader.skipValue();
-    }
-
-    /**
-     *
-     */
-    private void ensureDelegateInit() {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
-
-            delegate = new LinkedList<>();
-
-            for (int i = 0; i < size; i++)
-                delegate.add(reader.parseValue());
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object get(int idx) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.get(idx));
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean add(Object o) {
-        ensureDelegateInit();
-
-        return delegate.add(o);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void add(int idx, Object element) {
-        ensureDelegateInit();
-
-        delegate.add(idx, element);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object set(int idx, Object element) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.set(idx, element));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object remove(int idx) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.remove(idx));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() {
-        if (delegate == null)
-            delegate = new LinkedList<>();
-        else
-            delegate.clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean addAll(int idx, Collection<?> c) {
-        ensureDelegateInit();
-
-        return delegate.addAll(idx, c);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void removeRange(int fromIdx, int toIdx) {
-        ensureDelegateInit();
-
-        delegate.subList(fromIdx, toIdx).clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        if (delegate == null)
-            return reader.readIntAbsolute(off + 1);
-
-        return delegate.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public ListIterator<Object> listIterator(final int idx) {
-        ensureDelegateInit();
-
-        return new ListIterator<Object>() {
-            /** */
-            private final ListIterator<Object> delegate = PortableLazyLinkedList.super.listIterator(idx);
-
-            @Override public boolean hasNext() {
-                return delegate.hasNext();
-            }
-
-            @Override public Object next() {
-                return PortableUtils.unwrapLazy(delegate.next());
-            }
-
-            @Override public boolean hasPrevious() {
-                return delegate.hasPrevious();
-            }
-
-            @Override public Object previous() {
-                return PortableUtils.unwrapLazy(delegate.previous());
-            }
-
-            @Override public int nextIndex() {
-                return delegate.nextIndex();
-            }
-
-            @Override public int previousIndex() {
-                return delegate.previousIndex();
-            }
-
-            @Override public void remove() {
-                delegate.remove();
-            }
-
-            @Override public void set(Object o) {
-                delegate.set(o);
-            }
-
-            @Override public void add(Object o) {
-                delegate.add(o);
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterator<Object> iterator() {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazyIterator(super.iterator());
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
-            writer.write(reader.array(), off, hdrSize);
-
-            reader.position(off + hdrSize);
-
-            for (int i = 0; i < size; i++) {
-                Object o = reader.parseValue();
-
-                ctx.writeValue(writer, o);
-            }
-        }
-        else {
-            writer.writeByte(GridPortableMarshaller.COL);
-            writer.writeInt(delegate.size());
-
-            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
-            writer.writeByte(colType);
-
-            for (Object o : delegate)
-                ctx.writeValue(writer, o);
-        }
-    }
-}
\ No newline at end of file


[32/50] [abbrv] ignite git commit: Uncommented test.

Posted by ak...@apache.org.
Uncommented test.


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

Branch: refs/heads/ignite-843
Commit: 7a69e74ee86c85aef38b60607d91a7469436f542
Parents: 77fc969
Author: sboikov <sb...@gridgain.com>
Authored: Fri Sep 4 10:20:54 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Sep 4 10:20:54 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7a69e74e/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
index 837fb9a..5a2815d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
@@ -73,6 +73,7 @@ import org.apache.ignite.internal.processors.cache.distributed.replicated.preloa
 import org.apache.ignite.internal.processors.cache.distributed.replicated.preloader.GridCacheReplicatedPreloadSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.preloader.GridCacheReplicatedPreloadStartStopEventsSelfTest;
 import org.apache.ignite.internal.processors.cache.local.GridCacheDaemonNodeLocalSelfTest;
+import org.apache.ignite.internal.processors.cache.local.GridCacheLocalByteArrayValuesSelfTest;
 
 /**
  * Test suite.
@@ -132,7 +133,7 @@ public class IgniteCacheTestSuite3 extends TestSuite {
         suite.addTestSuite(GridCacheOrderedPreloadingSelfTest.class);
 
         // Test for byte array value special case.
-//        suite.addTestSuite(GridCacheLocalByteArrayValuesSelfTest.class);
+        suite.addTestSuite(GridCacheLocalByteArrayValuesSelfTest.class);
         suite.addTestSuite(GridCacheNearPartitionedP2PEnabledByteArrayValuesSelfTest.class);
         suite.addTestSuite(GridCacheNearPartitionedP2PDisabledByteArrayValuesSelfTest.class);
         suite.addTestSuite(GridCachePartitionedOnlyP2PEnabledByteArrayValuesSelfTest.class);


[39/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/project/vs/core.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/project/vs/core.vcxproj.filters b/modules/platform/src/main/cpp/core/project/vs/core.vcxproj.filters
new file mode 100644
index 0000000..d18599d
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/project/vs/core.vcxproj.filters
@@ -0,0 +1,246 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <ClCompile Include="..\..\src\impl\cache\cache_impl.cpp">
+      <Filter>Code\impl\cache</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\interop\interop_input_stream.cpp">
+      <Filter>Code\impl\interop</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\interop\interop_memory.cpp">
+      <Filter>Code\impl\interop</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\interop\interop_output_stream.cpp">
+      <Filter>Code\impl\interop</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\ignite_environment.cpp">
+      <Filter>Code\impl</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\ignite_impl.cpp">
+      <Filter>Code\impl</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\portable\portable_containers.cpp">
+      <Filter>Code\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\portable\portable_raw_reader.cpp">
+      <Filter>Code\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\portable\portable_raw_writer.cpp">
+      <Filter>Code\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\portable\portable_reader.cpp">
+      <Filter>Code\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\portable\portable_writer.cpp">
+      <Filter>Code\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\portable\portable_reader_impl.cpp">
+      <Filter>Code\impl\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\portable\portable_utils.cpp">
+      <Filter>Code\impl\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\portable\portable_writer_impl.cpp">
+      <Filter>Code\impl\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\os\win\src\impl\utils.cpp">
+      <Filter>Code\impl</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\ignite.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\ignite_error.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\ignition.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\guid.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\handle_registry.cpp">
+      <Filter>Code\impl</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\cache\query\query_impl.cpp">
+      <Filter>Code\impl\cache\query</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_snapshot.cpp">
+      <Filter>Code\impl\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_handler.cpp">
+      <Filter>Code\impl\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\portable\portable_type.cpp">
+      <Filter>Code\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_manager.cpp">
+      <Filter>Code\impl\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater.cpp">
+      <Filter>Code\impl\portable</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater_impl.cpp">
+      <Filter>Code\impl\portable</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\include\ignite\impl\cache\cache_impl.h">
+      <Filter>Code\impl\cache</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\cache\cache.h">
+      <Filter>Code\cache</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\cache\cache_peek_mode.h">
+      <Filter>Code\cache</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop.h">
+      <Filter>Code\impl\interop</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop_input_stream.h">
+      <Filter>Code\impl\interop</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop_memory.h">
+      <Filter>Code\impl\interop</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop_output_stream.h">
+      <Filter>Code\impl\interop</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\ignite_environment.h">
+      <Filter>Code\impl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\ignite_impl.h">
+      <Filter>Code\impl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\operations.h">
+      <Filter>Code\impl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_common.h">
+      <Filter>Code\impl\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\portable\portable_consts.h">
+      <Filter>Code\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\portable\portable.h">
+      <Filter>Code\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\portable\portable_containers.h">
+      <Filter>Code\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_id_resolver.h">
+      <Filter>Code\impl\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\portable\portable_raw_reader.h">
+      <Filter>Code\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\portable\portable_raw_writer.h">
+      <Filter>Code\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\portable\portable_reader.h">
+      <Filter>Code\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\portable\portable_writer.h">
+      <Filter>Code\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_reader_impl.h">
+      <Filter>Code\impl\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_utils.h">
+      <Filter>Code\impl\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_writer_impl.h">
+      <Filter>Code\impl\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\os\win\include\ignite\impl\utils.h">
+      <Filter>Code\impl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\ignite.h">
+      <Filter>Code</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\ignite_configuration.h">
+      <Filter>Code</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\ignite_error.h">
+      <Filter>Code</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\ignition.h">
+      <Filter>Code</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\guid.h">
+      <Filter>Code</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\handle_registry.h">
+      <Filter>Code\impl</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\cache\cache_entry.h">
+      <Filter>Code\cache</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\cache\query\query_impl.h">
+      <Filter>Code\impl\cache\query</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_snapshot.h">
+      <Filter>Code\impl\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_handler.h">
+      <Filter>Code\impl\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_manager.h">
+      <Filter>Code\impl\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\portable\portable_type.h">
+      <Filter>Code\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater.h">
+      <Filter>Code\impl\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater_impl.h">
+      <Filter>Code\impl\portable</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\cache\query\query_argument.h">
+      <Filter>Code\cache\query</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\cache\query\query_cursor.h">
+      <Filter>Code\cache\query</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\cache\query\query_sql.h">
+      <Filter>Code\cache\query</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\cache\query\query.h">
+      <Filter>Code\cache\query</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\cache\query\query_text.h">
+      <Filter>Code\cache\query</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\include\ignite\cache\query\query_scan.h">
+      <Filter>Code\cache\query</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <Filter Include="Code">
+      <UniqueIdentifier>{91873c79-a64f-4786-ab25-d03ef2db9dc8}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Code\impl">
+      <UniqueIdentifier>{9bede404-e1b1-44d6-b54d-e9b2441c5f13}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Code\impl\cache">
+      <UniqueIdentifier>{b013b0f6-c4b8-4b88-89bc-8b394971788e}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Code\impl\portable">
+      <UniqueIdentifier>{883773bd-085d-4eb5-81ee-f11188134faf}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Code\impl\interop">
+      <UniqueIdentifier>{d4cc8aeb-6e7b-47e6-9b83-cba925844d96}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Code\cache">
+      <UniqueIdentifier>{8b7e32c0-e222-4f3a-af31-19df380c369f}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Code\portable">
+      <UniqueIdentifier>{24b7134c-9335-44e1-9604-4093d0e3bbf5}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Code\cache\query">
+      <UniqueIdentifier>{4658a0ff-0d2d-45a6-b8de-93eeec0cc081}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Code\impl\cache\query">
+      <UniqueIdentifier>{b6e57294-120a-46f2-b0ad-c3595e2cf789}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/project/vs/core.vcxprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/project/vs/core.vcxprojrel b/modules/platform/src/main/cpp/core/project/vs/core.vcxprojrel
new file mode 100644
index 0000000..58fa283
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/project/vs/core.vcxprojrel
@@ -0,0 +1,272 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{E2DEA693-F2EA-43C2-A813-053378F6E4DB}</ProjectGuid>
+    <RootNamespace>core</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <TargetName>ignite.core</TargetName>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <TargetName>ignite.core</TargetName>
+    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <TargetName>ignite.core</TargetName>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <TargetName>ignite.core</TargetName>
+    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include</AdditionalIncludeDirectories>
+      <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+      <IntrinsicFunctions>false</IntrinsicFunctions>
+      <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
+      <OmitFramePointers>false</OmitFramePointers>
+      <StringPooling>true</StringPooling>
+      <MinimalRebuild>false</MinimalRebuild>
+      <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <WholeProgramOptimization>false</WholeProgramOptimization>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <OptimizeReferences>false</OptimizeReferences>
+      <EnableCOMDATFolding>false</EnableCOMDATFolding>
+      <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include</AdditionalIncludeDirectories>
+      <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+      <IntrinsicFunctions>false</IntrinsicFunctions>
+      <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
+      <OmitFramePointers>false</OmitFramePointers>
+      <StringPooling>true</StringPooling>
+      <MinimalRebuild>false</MinimalRebuild>
+      <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <WholeProgramOptimization>false</WholeProgramOptimization>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <OptimizeReferences>false</OptimizeReferences>
+      <EnableCOMDATFolding>false</EnableCOMDATFolding>
+      <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Full</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include</AdditionalIncludeDirectories>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <OmitFramePointers>true</OmitFramePointers>
+      <StringPooling>true</StringPooling>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Full</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include</AdditionalIncludeDirectories>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <OmitFramePointers>true</OmitFramePointers>
+      <StringPooling>true</StringPooling>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\include\ignite\cache\cache.h" />
+    <ClInclude Include="..\..\include\ignite\cache\cache_entry.h" />
+    <ClInclude Include="..\..\include\ignite\cache\cache_peek_mode.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query_argument.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query_cursor.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query_scan.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query_sql.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query_text.h" />
+    <ClInclude Include="..\..\include\ignite\ignite.h" />
+    <ClInclude Include="..\..\include\ignite\ignite_configuration.h" />
+    <ClInclude Include="..\..\include\ignite\ignite_error.h" />
+    <ClInclude Include="..\..\include\ignite\ignition.h" />
+    <ClInclude Include="..\..\include\ignite\guid.h" />
+    <ClInclude Include="..\..\include\ignite\impl\cache\cache_impl.h" />
+    <ClInclude Include="..\..\include\ignite\impl\cache\query\query_impl.h" />
+    <ClInclude Include="..\..\include\ignite\impl\ignite_environment.h" />
+    <ClInclude Include="..\..\include\ignite\impl\ignite_impl.h" />
+    <ClInclude Include="..\..\include\ignite\impl\handle_registry.h" />
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop.h" />
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop_input_stream.h" />
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop_memory.h" />
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop_output_stream.h" />
+    <ClInclude Include="..\..\include\ignite\impl\operations.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_common.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_id_resolver.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_handler.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_manager.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_snapshot.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater_impl.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_reader_impl.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_utils.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_writer_impl.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_consts.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_containers.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_type.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_raw_reader.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_raw_writer.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_reader.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_writer.h" />
+    <ClInclude Include="..\..\os\win\include\ignite\impl\utils.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\os\win\src\impl\utils.cpp" />
+    <ClCompile Include="..\..\src\ignite.cpp" />
+    <ClCompile Include="..\..\src\ignite_error.cpp" />
+    <ClCompile Include="..\..\src\ignition.cpp" />
+    <ClCompile Include="..\..\src\guid.cpp" />
+    <ClCompile Include="..\..\src\impl\cache\cache_impl.cpp" />
+    <ClCompile Include="..\..\src\impl\cache\query\query_impl.cpp" />
+    <ClCompile Include="..\..\src\impl\ignite_environment.cpp" />
+    <ClCompile Include="..\..\src\impl\ignite_impl.cpp" />
+    <ClCompile Include="..\..\src\impl\handle_registry.cpp" />
+    <ClCompile Include="..\..\src\impl\interop\interop_input_stream.cpp" />
+    <ClCompile Include="..\..\src\impl\interop\interop_memory.cpp" />
+    <ClCompile Include="..\..\src\impl\interop\interop_output_stream.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_handler.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_manager.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_snapshot.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater_impl.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_reader_impl.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_utils.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_writer_impl.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_containers.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_type.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_raw_reader.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_raw_writer.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_reader.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_writer.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\common\project\vs\common.vcxproj">
+      <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/guid.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/guid.cpp b/modules/platform/src/main/cpp/core/src/guid.cpp
new file mode 100644
index 0000000..77997e4
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/guid.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#include "ignite/guid.h"
+
+namespace ignite
+{
+    Guid::Guid() : most(0), least(0)
+    {
+        // No-op.
+    }
+
+    Guid::Guid(int64_t most, int64_t least) : most(most), least(least)
+    {
+        // No-op.
+    }
+
+    int64_t Guid::GetMostSignificantBits() const
+    {
+        return most;
+    }
+
+    int64_t Guid::GetLeastSignificantBits() const
+    {
+        return least;
+    }
+
+    int32_t Guid::GetVersion() const
+    {
+        return static_cast<int32_t>((most >> 12) & 0x0f);
+    }
+
+    int32_t Guid::GetVariant() const
+    {
+        uint64_t least0 = static_cast<uint64_t>(least);
+
+        return static_cast<int32_t>((least0 >> (64 - (least0 >> 62))) & (least >> 63));
+    }
+
+    int32_t Guid::GetHashCode() const
+    {
+        int64_t hilo = most ^ least;
+
+        return static_cast<int32_t>(hilo >> 32) ^ static_cast<int32_t>(hilo);
+    }
+
+    bool operator==(Guid& val1, Guid& val2)
+    {
+        return val1.least == val2.least && val1.most == val2.most;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/ignite.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/ignite.cpp b/modules/platform/src/main/cpp/core/src/ignite.cpp
new file mode 100644
index 0000000..665383b
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/ignite.cpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+#include <ignite/common/java.h>
+
+#include "ignite/impl/ignite_impl.h"
+#include "ignite/ignite.h"
+
+using namespace ignite::common::concurrent;
+using namespace ignite::impl;
+
+namespace ignite
+{    
+    Ignite::Ignite() : impl(SharedPointer<IgniteImpl>())
+    {
+        // No-op.
+    }
+
+    Ignite::Ignite(IgniteImpl* impl) : impl(SharedPointer<IgniteImpl>(impl))
+    {
+        // No-op.
+    }
+
+    char* Ignite::GetName()
+    {
+        return impl.Get()->GetName();
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/ignite_error.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/ignite_error.cpp b/modules/platform/src/main/cpp/core/src/ignite_error.cpp
new file mode 100644
index 0000000..65cd291
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/ignite_error.cpp
@@ -0,0 +1,222 @@
+/*
+ * 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.
+ */
+#include <ignite/common/java.h>
+
+#include "ignite/impl/utils.h"
+#include "ignite/ignite_error.h"
+
+using namespace ignite::common::java;
+using namespace ignite::impl::utils;
+
+namespace ignite
+{
+    void IgniteError::ThrowIfNeeded(IgniteError& err)
+    {
+        if (err.code != IGNITE_SUCCESS)
+            throw err;
+    }
+
+    IgniteError::IgniteError() : code(IGNITE_SUCCESS), msg(NULL)
+    {
+        // No-op.
+    }
+
+    IgniteError::IgniteError(int32_t code) : code(code), msg(NULL)
+    {
+        // No-op.
+    }
+
+    IgniteError::IgniteError(int32_t code, const char* msg)
+    {
+        this->code = code;
+        this->msg = CopyChars(msg);
+    }
+
+    IgniteError::IgniteError(const IgniteError& other)
+    {
+        this->code = other.code;
+        this->msg = CopyChars(other.msg);
+    }
+
+    IgniteError& IgniteError::operator=(const IgniteError& other)
+    {
+        if (this != &other)
+        {
+            IgniteError tmp(other);
+
+            int tmpCode = code;
+            char* tmpMsg = msg;
+            
+            code = tmp.code;
+            msg = tmp.msg;
+
+            tmp.code = tmpCode;
+            tmp.msg = tmpMsg;
+        }
+
+        return *this;
+    }
+
+    IgniteError::~IgniteError()
+    {
+        ReleaseChars(msg);
+    }
+
+    int32_t IgniteError::GetCode()
+    {
+        return code;
+    }
+
+    const char* IgniteError::GetText()
+    {
+        if (code == IGNITE_SUCCESS)
+            return "Operation completed successfully.";
+        else if (msg)
+            return msg;
+        else
+            return  "No additional information available.";
+    }
+    
+    void IgniteError::SetError(const int jniCode, const char* jniCls, const char* jniMsg, IgniteError* err)
+    {
+        if (jniCode == IGNITE_JNI_ERR_SUCCESS)
+            *err = IgniteError();
+        else if (jniCode == IGNITE_JNI_ERR_GENERIC)
+        {
+            // The most common case when we have Java exception "in hands" and must map it to respective code.
+            if (jniCls)
+            {
+                std::string jniCls0 = jniCls;
+
+                if (jniCls0.compare("java.lang.NoClassDefFoundError") == 0)
+                {
+                    std::stringstream stream; 
+
+                    stream << "Java class is not found (did you set IGNITE_HOME environment variable?)";
+
+                    if (jniMsg)
+                        stream << ": " << jniMsg;
+                    
+                    *err = IgniteError(IGNITE_ERR_JVM_NO_CLASS_DEF_FOUND, stream.str().c_str());
+                }
+                else if (jniCls0.compare("java.lang.NoSuchMethodError") == 0)
+                {
+                    std::stringstream stream;
+
+                    stream << "Java method is not found (did you set IGNITE_HOME environment variable?)";
+
+                    if (jniMsg)
+                        stream << ": " << jniMsg;
+
+                    *err = IgniteError(IGNITE_ERR_JVM_NO_SUCH_METHOD, stream.str().c_str());
+                }
+                else if (jniCls0.compare("java.lang.IllegalArgumentException") == 0)
+                    *err = IgniteError(IGNITE_ERR_ILLEGAL_ARGUMENT, jniMsg);
+                else if (jniCls0.compare("java.lang.IllegalStateException") == 0)
+                    *err = IgniteError(IGNITE_ERR_ILLEGAL_STATE, jniMsg);
+                else if (jniCls0.compare("java.lang.UnsupportedOperationException") == 0)
+                    *err = IgniteError(IGNITE_ERR_UNSUPPORTED_OPERATION, jniMsg);
+                else if (jniCls0.compare("java.lang.InterruptedException") == 0)
+                    *err = IgniteError(IGNITE_ERR_INTERRUPTED, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.cluster.ClusterGroupEmptyException") == 0)
+                    *err = IgniteError(IGNITE_ERR_CLUSTER_GROUP_EMPTY, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.cluster.ClusterTopologyException") == 0)
+                    *err = IgniteError(IGNITE_ERR_CLUSTER_TOPOLOGY, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.compute.ComputeExecutionRejectedException") == 0)
+                    *err = IgniteError(IGNITE_ERR_COMPUTE_EXECUTION_REJECTED, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.compute.ComputeJobFailoverException") == 0)
+                    *err = IgniteError(IGNITE_ERR_COMPUTE_JOB_FAILOVER, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.compute.ComputeTaskCancelledException") == 0)
+                    *err = IgniteError(IGNITE_ERR_COMPUTE_TASK_CANCELLED, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.compute.ComputeTaskTimeoutException") == 0)
+                    *err = IgniteError(IGNITE_ERR_COMPUTE_TASK_TIMEOUT, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.compute.ComputeUserUndeclaredException") == 0)
+                    *err = IgniteError(IGNITE_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION, jniMsg);
+                else if (jniCls0.compare("javax.cache.CacheException") == 0)
+                    *err = IgniteError(IGNITE_ERR_CACHE, jniMsg);
+                else if (jniCls0.compare("javax.cache.integration.CacheLoaderException") == 0)
+                    *err = IgniteError(IGNITE_ERR_CACHE_LOADER, jniMsg);
+                else if (jniCls0.compare("javax.cache.integration.CacheWriterException") == 0)
+                    *err = IgniteError(IGNITE_ERR_CACHE_WRITER, jniMsg);
+                else if (jniCls0.compare("javax.cache.processor.EntryProcessorException") == 0)
+                    *err = IgniteError(IGNITE_ERR_ENTRY_PROCESSOR, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.cache.CacheAtomicUpdateTimeoutException") == 0)
+                    *err = IgniteError(IGNITE_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.cache.CachePartialUpdateException") == 0)
+                    *err = IgniteError(IGNITE_ERR_CACHE_PARTIAL_UPDATE, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.transactions.TransactionOptimisticException") == 0)
+                    *err = IgniteError(IGNITE_ERR_TX_OPTIMISTIC, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.transactions.TransactionTimeoutException") == 0)
+                    *err = IgniteError(IGNITE_ERR_TX_TIMEOUT, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.transactions.TransactionRollbackException") == 0)
+                    *err = IgniteError(IGNITE_ERR_TX_ROLLBACK, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.transactions.TransactionHeuristicException") == 0)
+                    *err = IgniteError(IGNITE_ERR_TX_HEURISTIC, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.IgniteAuthenticationException") == 0)
+                    *err = IgniteError(IGNITE_ERR_AUTHENTICATION, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.plugin.security.GridSecurityException") == 0)
+                    *err = IgniteError(IGNITE_ERR_SECURITY, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.IgniteException") == 0)
+                    *err = IgniteError(IGNITE_ERR_GENERIC, jniMsg);
+                else if (jniCls0.compare("org.apache.ignite.IgniteCheckedException") == 0)
+                    *err = IgniteError(IGNITE_ERR_GENERIC, jniMsg);
+                else
+                {
+                    std::stringstream stream;
+                    
+                    stream << "Java exception occurred [cls=" << jniCls0;
+
+                    if (jniMsg)
+                        stream << ", msg=" << jniMsg;
+
+                    stream << "]";
+
+                    *err = IgniteError(IGNITE_ERR_UNKNOWN, stream.str().c_str());
+                }                    
+            }
+            else
+            {
+                // JNI class name is not available. Something really weird.
+                *err = IgniteError(IGNITE_ERR_UNKNOWN);
+            }
+        }
+        else if (jniCode == IGNITE_JNI_ERR_JVM_INIT)
+        {
+            std::stringstream stream;
+
+            stream << "Failed to initialize JVM [errCls=";
+
+            if (jniCls)
+                stream << jniCls;
+            else
+                stream << "N/A";
+
+            stream << ", errMsg=";
+
+            if (jniMsg)
+                stream << jniMsg;
+            else
+                stream << "N/A";
+
+            stream << "]";
+
+            *err = IgniteError(IGNITE_ERR_JVM_INIT, stream.str().c_str());
+        }
+        else if (jniCode == IGNITE_JNI_ERR_JVM_ATTACH)
+            *err = IgniteError(IGNITE_ERR_JVM_ATTACH, "Failed to attach to JVM.");
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/ignition.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/ignition.cpp b/modules/platform/src/main/cpp/core/src/ignition.cpp
new file mode 100644
index 0000000..a0e3367
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/ignition.cpp
@@ -0,0 +1,468 @@
+/*
+ * 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.
+ */
+
+#include <sstream>
+
+#include <ignite/common/common.h>
+#include <ignite/common/concurrent.h>
+#include <ignite/common/exports.h>
+#include <ignite/common/java.h>
+
+#include "ignite/impl/ignite_environment.h"
+#include "ignite/impl/ignite_impl.h"
+#include "ignite/impl/utils.h"
+#include "ignite/ignition.h"
+
+using namespace ignite::common::concurrent;
+using namespace ignite::common::java;
+using namespace ignite::impl;
+using namespace ignite::impl::utils;
+
+namespace ignite
+{
+    /** Default configuration. */
+    const char* DFLT_CFG = "config/default-config.xml";
+
+    /** Whether JVM library is loaded to the process. */
+    bool JVM_LIB_LOADED;
+
+    /** Critical section for factory methods. */
+    CriticalSection factoryLock;
+
+    /** Flag indicating that at least one Ignite instance has started. */
+    bool started = false;
+
+    /**
+     * Convert integer value to string.
+     */
+    std::string JvmMemoryString(const std::string& prefix, int32_t val)
+    {
+        std::ostringstream ss;
+        ss << val;
+
+        std::string valStr = ss.str();
+
+        std::string res = std::string(prefix);
+        res.append(valStr);
+        res.append("m");
+
+        return res;
+    }
+
+    /**
+     * Create JVM options.
+     *
+     * @param cfg Configuration.
+     * @param home Optional GG home.
+     * @param cp Classpath.
+     * @param opts Options.
+     * @param optsLen Options length.
+     * @return Options.
+     */
+    char** CreateJvmOptions(const IgniteConfiguration& cfg, const std::string* home, const std::string& cp, int* optsLen)
+    {
+        *optsLen = 3 + (home ? 1 : 0) + cfg.jvmOptsLen;
+        char** opts = new char*[*optsLen];
+
+        int idx = 0;
+
+        // 1. Set classpath.
+        std::string cpFull = std::string("-Djava.class.path=") + cp;
+
+        *(opts + idx++) = CopyChars(cpFull.c_str());
+
+        // 2. Set home.
+        if (home) {
+            std::string homeFull = std::string("-DIGNITE_HOME=") + *home;
+
+            *(opts + idx++) = CopyChars(homeFull.c_str());
+        }
+
+        // 3. Set Xms, Xmx.
+        std::string xmsStr = JvmMemoryString(std::string("-Xms"), cfg.jvmInitMem);
+        std::string xmxStr = JvmMemoryString(std::string("-Xmx"), cfg.jvmMaxMem);
+
+        *(opts + idx++) = CopyChars(xmsStr.c_str());
+        *(opts + idx++) = CopyChars(xmxStr.c_str());
+
+        // 4. Set the rest options.
+        for (int i = 0; i < cfg.jvmOptsLen; i++) {
+            char* optCopy = CopyChars(cfg.jvmOpts[i].opt);
+
+            opts[idx++] = optCopy;
+        }
+
+        return opts;
+    }
+
+    Ignite Ignition::Start(const IgniteConfiguration& cfg)
+    {
+        return Start(cfg, static_cast<const char*>(NULL));
+    }
+
+    Ignite Ignition::Start(const IgniteConfiguration& cfg, IgniteError* err)
+    {
+        return Start(cfg, NULL, err);
+    }
+
+    Ignite Ignition::Start(const IgniteConfiguration& cfg, const char* name)
+    {
+        IgniteError err;
+
+        Ignite res = Start(cfg, name, &err);
+
+        IgniteError::ThrowIfNeeded(err);
+
+        return res;
+    }
+
+    Ignite Ignition::Start(const IgniteConfiguration& cfg, const char* name, IgniteError* err)
+    {
+        bool failed = false;
+
+        SharedPointer<IgniteEnvironment> env;
+        SharedPointer<IgniteEnvironment>* envTarget = NULL;
+
+        jobject javaRef = NULL;
+
+        factoryLock.Enter();
+
+        // 1. Load JVM library if needed.
+        if (!JVM_LIB_LOADED)
+        {
+            bool jvmLibFound;
+            std::string jvmLib;
+
+            if (cfg.jvmLibPath)
+            {
+                std::string jvmLibPath = std::string(cfg.jvmLibPath);
+
+                jvmLib = FindJvmLibrary(&jvmLibPath, &jvmLibFound);
+            }
+            else
+                jvmLib = FindJvmLibrary(NULL, &jvmLibFound);
+
+            if (!jvmLibFound)
+            {
+                *err = IgniteError(IgniteError::IGNITE_ERR_JVM_LIB_NOT_FOUND,
+                    "JVM library is not found (did you set JAVA_HOME environment variable?)");
+
+                failed = true;
+            }
+
+            if (!failed) {
+                if (!LoadJvmLibrary(jvmLib))
+                {
+                    *err = IgniteError(IgniteError::IGNITE_ERR_JVM_LIB_LOAD_FAILED, "Failed to load JVM library.");
+
+                    failed = true;
+                }
+            }
+
+            JVM_LIB_LOADED = true;
+        }
+
+        if (!failed)
+        {
+            // 2. Resolve IGNITE_HOME.
+            bool homeFound;
+            std::string home;
+
+            if (cfg.igniteHome)
+            {
+                std::string homePath = std::string(cfg.igniteHome);
+
+                home = ResolveIgniteHome(&homePath, &homeFound);
+            }
+            else
+                home = ResolveIgniteHome(NULL, &homeFound);
+
+            // 3. Create classpath.
+            std::string cp;
+
+            if (cfg.jvmClassPath)
+            {
+                std::string usrCp = cfg.jvmClassPath;
+
+                cp = CreateIgniteClasspath(&usrCp, homeFound ? &home : NULL);
+            }
+            else
+                cp = CreateIgniteClasspath(NULL, homeFound ? &home : NULL);
+
+            if (!cp.empty())
+            {
+                // 4. Start JVM if needed.
+                JniErrorInfo jniErr;
+
+                env = SharedPointer<IgniteEnvironment>(new IgniteEnvironment());
+
+                int optsLen;
+                char** opts = CreateJvmOptions(cfg, homeFound ? &home : NULL, cp, &optsLen);
+
+                envTarget = new SharedPointer<IgniteEnvironment>(env);
+                
+                SharedPointer<JniContext> ctx(
+                    JniContext::Create(opts, optsLen, env.Get()->GetJniHandlers(envTarget), &jniErr));
+
+                for (int i = 0; i < optsLen; i++)
+                    ReleaseChars(*(opts + i));
+
+                delete[] opts;
+
+                if (!ctx.Get())
+                {
+                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+                    
+                    failed = true;
+                }
+
+                // 5. Start Ignite.
+                if (!failed)
+                {
+                    char* springCfgPath0 = CopyChars(cfg.springCfgPath);
+
+                    if (!springCfgPath0)
+                        springCfgPath0 = CopyChars(DFLT_CFG);
+
+                    char* name0 = CopyChars(name);
+
+                    interop::InteropUnpooledMemory mem(16);
+                    interop::InteropOutputStream stream(&mem);
+                    stream.WriteBool(false);
+                    stream.Synchronize();
+
+                    javaRef = ctx.Get()->IgnitionStart(springCfgPath0, name0, 2, mem.PointerLong(), &jniErr);
+
+                    ReleaseChars(springCfgPath0);
+                    ReleaseChars(name0);
+
+                    if (!javaRef) {
+                        IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+                        
+                        failed = true;
+                    }
+                    else {
+                        // 6. Ignite is started at this point.
+                        env.Get()->Initialize(ctx);
+
+                        started = true;
+                    }
+                }
+            }
+            else {
+                *err = IgniteError(IgniteError::IGNITE_ERR_JVM_NO_CLASSPATH,
+                    "Java classpath is empty (did you set IGNITE_HOME environment variable?)");
+
+                failed = true;
+            }
+        }
+
+        factoryLock.Leave();
+
+        if (failed) 
+        {
+            if (envTarget)
+                delete envTarget;
+
+            return Ignite();
+        }
+        else 
+        {
+            IgniteImpl* impl = new IgniteImpl(env, javaRef);
+
+            return Ignite(impl);
+        }
+    }
+
+    Ignite Ignition::Get()
+    {
+        return Get(static_cast<const char*>(NULL));
+    }
+
+    Ignite Ignition::Get(IgniteError* err)
+    {
+        return Get(NULL, err);
+    }
+
+    Ignite Ignition::Get(const char* name)
+    {
+        IgniteError err;
+
+        Ignite res = Get(name, &err);
+
+        IgniteError::ThrowIfNeeded(err);
+
+        return res;
+    }
+
+    Ignite Ignition::Get(const char* name, IgniteError* err)
+    {
+        Ignite res;
+
+        factoryLock.Enter();
+
+        if (started)
+        {
+            char* name0 = CopyChars(name);
+
+            // 1. Create context for this operation.
+            JniErrorInfo jniErr;
+
+            SharedPointer<JniContext> ctx(JniContext::Create(NULL, 0, JniHandlers(), &jniErr));
+
+            IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+            if (err->GetCode() == IgniteError::IGNITE_SUCCESS)
+            {
+                // 2. Get environment pointer.
+                long long ptr = ctx.Get()->IgnitionEnvironmentPointer(name0, &jniErr);
+
+                IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                if (err->GetCode() == IgniteError::IGNITE_SUCCESS)
+                {
+                    if (ptr != 0)
+                    {
+                        // 3. Obtain real environment for this instance.
+                        JniHandlers* hnds = reinterpret_cast<JniHandlers*>(ptr);
+
+                        SharedPointer<IgniteEnvironment>* env =
+                            static_cast<SharedPointer<IgniteEnvironment>*>(hnds->target);
+
+                        // 4. Get fresh node reference.
+                        jobject ref = ctx.Get()->IgnitionInstance(name0, &jniErr);
+
+                        if (err->GetCode() == IgniteError::IGNITE_SUCCESS) {
+                            if (ref)
+                            {
+                                IgniteImpl* impl = new IgniteImpl(*env, ref);
+
+                                res = Ignite(impl);
+                            }
+                            else
+                                // Error: concurrent node stop.
+                                *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                                    "Failed to get Ignite instance because it was stopped concurrently.");
+
+                        }
+                    }
+                    else
+                        // Error: no node with the given name.
+                        *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                            "Failed to get Ignite instance because it is either not started yet or already stopped.");
+                }
+            }
+
+            ReleaseChars(name0);
+        }
+        else
+            // Error: no node with the given name.
+            *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                "Failed to get Ignite instance because it is either not started yet or already stopped.");
+
+        factoryLock.Leave();
+
+        return res;
+    }
+
+    bool Ignition::Stop(const bool cancel)
+    {
+        return Stop(NULL, cancel);
+    }
+
+    bool Ignition::Stop(const bool cancel, IgniteError* err)
+    {
+        return Stop(NULL, cancel, err);
+    }
+
+    bool Ignition::Stop(const char* name, const bool cancel)
+    {
+        IgniteError err;
+
+        bool res = Stop(name, cancel, &err);
+
+        IgniteError::ThrowIfNeeded(err);
+
+        return res;
+    }
+
+    bool Ignition::Stop(const char* name, const bool cancel, IgniteError* err)
+    {
+        bool res = false;
+
+        factoryLock.Enter();
+
+        if (started)
+        {
+            JniErrorInfo jniErr;
+
+            SharedPointer<JniContext> ctx(JniContext::Create(NULL, 0, JniHandlers(), &jniErr));
+
+            IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+            if (err->GetCode() == IgniteError::IGNITE_SUCCESS)
+            {
+                char* name0 = CopyChars(name);
+
+                bool res0 = ctx.Get()->IgnitionStop(name0, cancel, &jniErr);
+
+                ReleaseChars(name0);
+
+                IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                if (err->GetCode() == IgniteError::IGNITE_SUCCESS)
+                    res = res0;
+            }
+        }
+
+        factoryLock.Leave();
+
+        return res;
+    }
+
+    void Ignition::StopAll(const bool cancel)
+    {
+        IgniteError err;
+
+        StopAll(cancel, &err);
+
+        IgniteError::ThrowIfNeeded(err);
+    }
+
+    void Ignition::StopAll(const bool cancel, IgniteError* err)
+    {
+        factoryLock.Enter();
+
+        if (started)
+        {
+            JniErrorInfo jniErr;
+
+            SharedPointer<JniContext> ctx(JniContext::Create(NULL, 0, JniHandlers(), &jniErr));
+             
+            IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+            if (err->GetCode() == IgniteError::IGNITE_SUCCESS)
+            {
+                ctx.Get()->IgnitionStopAll(cancel, &jniErr);
+
+                IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+            }
+        }
+
+        factoryLock.Leave();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/cache/cache_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/cache/cache_impl.cpp b/modules/platform/src/main/cpp/core/src/impl/cache/cache_impl.cpp
new file mode 100644
index 0000000..2f211e7
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/cache/cache_impl.cpp
@@ -0,0 +1,388 @@
+/*
+ * 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.
+ */
+
+#include "ignite/cache/cache_peek_mode.h"
+#include "ignite/impl/cache/cache_impl.h"
+#include "ignite/impl/interop/interop.h"
+#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/impl/utils.h"
+#include "ignite/impl/portable/portable_metadata_updater_impl.h"
+#include "ignite/portable/portable.h"
+
+using namespace ignite::common::concurrent;
+using namespace ignite::common::java;
+using namespace ignite::cache;
+using namespace ignite::cache::query;
+using namespace ignite::impl;
+using namespace ignite::impl::cache::query;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+using namespace ignite::impl::utils;
+using namespace ignite::portable;
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace cache
+        {
+            /** Operation: Clear. */
+            const int32_t OP_CLEAR = 1;
+
+            /** Operation: ClearAll. */
+            const int32_t OP_CLEAR_ALL = 2;
+
+            /** Operation: ContainsKey. */
+            const int32_t OP_CONTAINS_KEY = 3;
+
+            /** Operation: ContainsKeys. */
+            const int32_t OP_CONTAINS_KEYS = 4;
+
+            /** Operation: Get. */
+            const int32_t OP_GET = 5;
+
+            /** Operation: GetAll. */
+            const int32_t OP_GET_ALL = 6;
+
+            /** Operation: GetAndPut. */
+            const int32_t OP_GET_AND_PUT = 7;
+
+            /** Operation: GetAndPutIfAbsent. */
+            const int32_t OP_GET_AND_PUT_IF_ABSENT = 8;
+
+            /** Operation: GetAndRemove. */
+            const int32_t OP_GET_AND_REMOVE = 9;
+
+            /** Operation: GetAndReplace. */
+            const int32_t OP_GET_AND_REPLACE = 10;
+
+            /** Operation: LocalEvict. */
+            const int32_t OP_LOCAL_EVICT = 16;
+
+            /** Operation: LocalClear. */
+            const int32_t OP_LOCAL_CLEAR = 20;
+
+            /** Operation: LocalClearAll. */
+            const int32_t OP_LOCAL_CLEAR_ALL = 21;
+
+            /** Operation: LocalPeek. */
+            const int32_t OP_LOCAL_PEEK = 25;
+
+            /** Operation: Put. */
+            const int32_t OP_PUT = 26;
+
+            /** Operation: PutAll. */
+            const int32_t OP_PUT_ALL = 27;
+
+            /** Operation: PutIfAbsent. */
+            const int32_t OP_PUT_IF_ABSENT = 28;
+
+            /** Operation: SCAN query. */
+            const int32_t OP_QRY_SCAN = 30;
+
+            /** Operation: SQL query. */
+            const int32_t OP_QRY_SQL = 31;
+
+            /** Operation: SQL fields query. */
+            const int32_t OP_QRY_SQL_FIELDS = 32;
+
+            /** Operation: TEXT query. */
+            const int32_t OP_QRY_TEXT = 33;
+
+            /** Operation: RemoveAll. */
+            const int32_t OP_REMOVE_ALL = 34;
+
+            /** Operation: Remove(K, V). */
+            const int32_t OP_REMOVE_2 = 35;
+
+            /** Operation: Remove(K). */
+            const int32_t OP_REMOVE_1 = 36;
+
+            /** Operation: Replace(K, V). */
+            const int32_t OP_REPLACE_2 = 37;
+
+            /** Operation: Replace(K, V, V). */
+            const int32_t OP_REPLACE_3 = 38;
+
+            CacheImpl::CacheImpl(char* name, SharedPointer<IgniteEnvironment> env, jobject javaRef) :
+                name(name), env(env), javaRef(javaRef)
+            {
+                // No-op.
+            }
+
+            CacheImpl::~CacheImpl()
+            {
+                ReleaseChars(name);
+
+                JniContext::Release(javaRef);
+            }
+
+            char* CacheImpl::GetName()
+            {
+                return name;
+            }
+
+            bool CacheImpl::IsEmpty(IgniteError* err)
+            {
+                return Size(IGNITE_PEEK_MODE_ALL, err) == 0;
+            }
+
+            bool CacheImpl::ContainsKey(InputOperation& inOp, IgniteError* err)
+            {
+                return OutOpInternal(OP_CONTAINS_KEY, inOp, err);
+            }
+
+            bool CacheImpl::ContainsKeys(InputOperation& inOp, IgniteError* err)
+            {
+                return OutOpInternal(OP_CONTAINS_KEYS, inOp, err);
+            }
+
+            void CacheImpl::LocalPeek(InputOperation& inOp, OutputOperation& outOp, int32_t peekModes, IgniteError* err)
+            {
+                OutInOpInternal(OP_LOCAL_PEEK, inOp, outOp, err);
+            }
+
+            void CacheImpl::Get(InputOperation& inOp, OutputOperation& outOp, IgniteError* err)
+            {
+                OutInOpInternal(OP_GET, inOp, outOp, err);
+            }
+
+            void CacheImpl::GetAll(InputOperation& inOp, OutputOperation& outOp, IgniteError* err)
+            {
+                OutInOpInternal(OP_GET_ALL, inOp, outOp, err);
+            }
+
+            void CacheImpl::Put(InputOperation& inOp, IgniteError* err)
+            {
+                OutOpInternal(OP_PUT, inOp, err);
+            }
+
+            void CacheImpl::PutAll(ignite::impl::InputOperation& inOp, IgniteError* err)
+            {
+                OutOpInternal(OP_PUT_ALL, inOp, err);
+            }
+
+            void CacheImpl::GetAndPut(InputOperation& inOp, OutputOperation& outOp, IgniteError* err)
+            {
+                OutInOpInternal(OP_GET_AND_PUT, inOp, outOp, err);
+            }
+
+            void CacheImpl::GetAndReplace(InputOperation& inOp, OutputOperation& outOp, IgniteError* err)
+            {
+                OutInOpInternal(OP_GET_AND_REPLACE, inOp, outOp, err);
+            }
+
+            void CacheImpl::GetAndRemove(InputOperation& inOp, OutputOperation& outOp, IgniteError* err)
+            {
+                OutInOpInternal(OP_GET_AND_REMOVE, inOp, outOp, err);
+            }
+
+            bool CacheImpl::PutIfAbsent(InputOperation& inOp, IgniteError* err)
+            {
+                return OutOpInternal(OP_PUT_IF_ABSENT, inOp, err);
+            }
+
+            void CacheImpl::GetAndPutIfAbsent(InputOperation& inOp, OutputOperation& outOp, IgniteError* err)
+            {
+                OutInOpInternal(OP_GET_AND_PUT_IF_ABSENT, inOp, outOp, err);
+            }
+
+            bool CacheImpl::Replace(InputOperation& inOp, IgniteError* err)
+            {
+                return OutOpInternal(OP_REPLACE_2, inOp, err);
+            }
+
+            bool CacheImpl::ReplaceIfEqual(InputOperation& inOp, IgniteError* err)
+            {
+                return OutOpInternal(OP_REPLACE_3, inOp, err);
+            }
+
+            void CacheImpl::LocalEvict(InputOperation& inOp, IgniteError* err)
+            {
+                OutOpInternal(OP_LOCAL_EVICT, inOp, err);
+            }
+
+            void CacheImpl::Clear(IgniteError* err)
+            {
+                JniErrorInfo jniErr;
+
+                env.Get()->Context()->CacheClear(javaRef, &jniErr);
+
+                IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+            }
+
+            void CacheImpl::Clear(InputOperation& inOp, IgniteError* err)
+            {
+                OutOpInternal(OP_CLEAR, inOp, err);
+            }
+
+            void CacheImpl::ClearAll(InputOperation& inOp, IgniteError* err)
+            {
+                OutOpInternal(OP_CLEAR_ALL, inOp, err);
+            }
+
+            void CacheImpl::LocalClear(InputOperation& inOp, IgniteError* err)
+            {
+                OutOpInternal(OP_LOCAL_CLEAR, inOp, err);
+            }
+
+            void CacheImpl::LocalClearAll(InputOperation& inOp, IgniteError* err)
+            {
+                OutOpInternal(OP_LOCAL_CLEAR_ALL, inOp, err);
+            }
+
+            bool CacheImpl::Remove(InputOperation& inOp, IgniteError* err)
+            {
+                return OutOpInternal(OP_REMOVE_1, inOp, err);
+            }
+
+            bool CacheImpl::RemoveIfEqual(InputOperation& inOp, IgniteError* err)
+            {
+                return OutOpInternal(OP_REMOVE_2, inOp, err);
+            }
+
+            void CacheImpl::RemoveAll(InputOperation& inOp, IgniteError* err)
+            {
+                OutOpInternal(OP_REMOVE_ALL, inOp, err);
+            }
+
+            void CacheImpl::RemoveAll(IgniteError* err)
+            {
+                JniErrorInfo jniErr;
+
+                env.Get()->Context()->CacheRemoveAll(javaRef, &jniErr);
+
+                IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+            }
+
+            int32_t CacheImpl::Size(const int32_t peekModes, IgniteError* err)
+            {
+                return SizeInternal(peekModes, false, err);
+            }
+
+            int32_t CacheImpl::LocalSize(const int32_t peekModes, IgniteError* err)
+            {
+                return SizeInternal(peekModes, true, err);
+            }
+
+            QueryCursorImpl* CacheImpl::QuerySql(const SqlQuery& qry, IgniteError* err)
+            {
+                return QueryInternal(qry, OP_QRY_SQL, err);
+            }
+
+            QueryCursorImpl* CacheImpl::QueryText(const TextQuery& qry, IgniteError* err)
+            {
+                return QueryInternal(qry, OP_QRY_TEXT, err);
+            }
+
+            QueryCursorImpl* CacheImpl::QueryScan(const ScanQuery& qry, IgniteError* err)
+            {
+                return QueryInternal(qry, OP_QRY_SCAN, err);
+            }
+
+            int64_t CacheImpl::WriteTo(InteropMemory* mem, InputOperation& inOp, IgniteError* err)
+            {
+                PortableMetadataManager* metaMgr = env.Get()->GetMetadataManager();
+
+                int32_t metaVer = metaMgr->GetVersion();
+
+                InteropOutputStream out(mem);
+                PortableWriterImpl writer(&out, metaMgr);
+                
+                inOp.ProcessInput(writer);
+
+                out.Synchronize();
+
+                if (metaMgr->IsUpdatedSince(metaVer))
+                {
+                    PortableMetadataUpdaterImpl metaUpdater(env, javaRef);
+
+                    if (!metaMgr->ProcessPendingUpdates(&metaUpdater, err))
+                        return 0;
+                }
+
+                return mem->PointerLong();
+            }
+
+            void CacheImpl::ReadFrom(InteropMemory* mem, OutputOperation& outOp)
+            {
+                InteropInputStream in(mem);
+
+                PortableReaderImpl reader(&in);
+
+                outOp.ProcessOutput(reader);
+            }
+
+            int CacheImpl::SizeInternal(const int32_t peekModes, const bool loc, IgniteError* err)
+            {
+                JniErrorInfo jniErr;
+
+                int res = env.Get()->Context()->CacheSize(javaRef, peekModes, loc, &jniErr);
+
+                IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
+                    return res;
+                else
+                    return -1;
+            }
+
+            bool CacheImpl::OutOpInternal(const int32_t opType, InputOperation& inOp, IgniteError* err)
+            {
+                JniErrorInfo jniErr;
+
+                SharedPointer<InteropMemory> mem = env.Get()->AllocateMemory();
+
+                int64_t outPtr = WriteTo(mem.Get(), inOp, err);
+
+                if (outPtr)
+                {
+                    long long res = env.Get()->Context()->TargetInStreamOutLong(javaRef, opType, outPtr, &jniErr);
+
+                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
+                        return res == 1;
+                }
+
+                return false;
+            }
+
+            void CacheImpl::OutInOpInternal(const int32_t opType, InputOperation& inOp, OutputOperation& outOp, 
+                IgniteError* err)
+            {
+                JniErrorInfo jniErr;
+
+                SharedPointer<InteropMemory> outMem = env.Get()->AllocateMemory();
+                SharedPointer<InteropMemory> inMem = env.Get()->AllocateMemory();
+
+                int64_t outPtr = WriteTo(outMem.Get(), inOp, err);
+
+                if (outPtr)
+                {
+                    env.Get()->Context()->TargetInStreamOutStream(javaRef, opType, WriteTo(outMem.Get(), inOp, err), 
+                        inMem.Get()->PointerLong(), &jniErr);
+
+                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
+                        ReadFrom(inMem.Get(), outOp);
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/cache/query/query_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/cache/query/query_impl.cpp b/modules/platform/src/main/cpp/core/src/impl/cache/query/query_impl.cpp
new file mode 100644
index 0000000..7d89321
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/cache/query/query_impl.cpp
@@ -0,0 +1,193 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/cache/query/query_impl.h"
+
+using namespace ignite::common::concurrent;
+using namespace ignite::common::java;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace cache
+        {
+            namespace query
+            {
+                /** Operation: get all entries. */
+                const int32_t OP_GET_ALL = 1;
+
+                /** Operation: get single entry. */
+                const int32_t OP_GET_SINGLE = 3;
+
+                QueryCursorImpl::QueryCursorImpl(SharedPointer<IgniteEnvironment> env, jobject javaRef) :
+                    env(env), javaRef(javaRef), iterCalled(false), getAllCalled(false), hasNext(false)
+                {
+                    // No-op.
+                }
+
+                QueryCursorImpl::~QueryCursorImpl()
+                {
+                    // 1. Close the cursor.
+                    env.Get()->Context()->QueryCursorClose(javaRef);
+
+                    // 2. Release Java reference.
+                    JniContext::Release(javaRef);
+                }
+
+                bool QueryCursorImpl::HasNext(IgniteError* err)
+                {
+                    // Check whether GetAll() was called earlier.
+                    if (getAllCalled) 
+                    {
+                        *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, 
+                            "Cannot use HasNext() method because GetAll() was called.");
+
+                        return false;
+                    }
+
+                    // Create iterator in Java if needed.
+                    if (!CreateIteratorIfNeeded(err))
+                        return false;
+                    
+                    return hasNext;
+                }
+
+                void QueryCursorImpl::GetNext(OutputOperation& op, IgniteError* err)
+                {
+                    // Check whether GetAll() was called earlier.
+                    if (getAllCalled) 
+                    {
+                        *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, 
+                            "Cannot use GetNext() method because GetAll() was called.");
+
+                        return;
+                    }
+
+                    // Create iterator in Java if needed.
+                    if (!CreateIteratorIfNeeded(err))
+                        return;
+
+                    if (hasNext)
+                    {
+                        JniErrorInfo jniErr;
+
+                        SharedPointer<InteropMemory> inMem = env.Get()->AllocateMemory();
+
+                        env.Get()->Context()->TargetOutStream(javaRef, OP_GET_SINGLE, inMem.Get()->PointerLong(), &jniErr);
+
+                        IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                        if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
+                        {
+                            InteropInputStream in(inMem.Get());
+
+                            portable::PortableReaderImpl reader(&in);
+
+                            op.ProcessOutput(reader);
+
+                            hasNext = IteratorHasNext(err);
+                        }
+                    }
+                    else
+                    {
+                        // Ensure we do not overwrite possible previous error.
+                        if (err->GetCode() == IgniteError::IGNITE_SUCCESS)
+                            *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, "No more elements available.");
+                    }
+                }
+
+                void QueryCursorImpl::GetAll(OutputOperation& op, IgniteError* err)
+                {
+                    // Check whether any of iterator methods were called.
+                    if (iterCalled)
+                    {
+                        *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                            "Cannot use GetAll() method because an iteration method was called.");
+
+                        return;
+                    }
+
+                    // Check whether GetAll was called before.
+                    if (getAllCalled)
+                    {
+                        *err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                            "Cannot use GetNext() method because GetAll() was called.");
+
+                        return;
+                    }
+
+                    // Get data.
+                    JniErrorInfo jniErr;
+
+                    SharedPointer<InteropMemory> inMem = env.Get()->AllocateMemory();
+
+                    env.Get()->Context()->TargetOutStream(javaRef, OP_GET_ALL, inMem.Get()->PointerLong(), &jniErr);
+
+                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
+                    {
+                        getAllCalled = true;
+
+                        InteropInputStream in(inMem.Get());
+
+                        portable::PortableReaderImpl reader(&in);
+
+                        op.ProcessOutput(reader);
+                    }
+                }
+
+                bool QueryCursorImpl::CreateIteratorIfNeeded(IgniteError* err)
+                {
+                    if (!iterCalled)
+                    {
+                        JniErrorInfo jniErr;
+
+                        env.Get()->Context()->QueryCursorIterator(javaRef, &jniErr);
+
+                        IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                        if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
+                        {
+                            iterCalled = true;
+
+                            hasNext = IteratorHasNext(err);
+                        }
+                        else
+                            return false;
+                    }
+                    
+                    return true;
+                }
+
+                bool QueryCursorImpl::IteratorHasNext(IgniteError* err)
+                {
+                    JniErrorInfo jniErr;
+
+                    bool res = env.Get()->Context()->QueryCursorIteratorHasNext(javaRef, &jniErr);
+
+                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    return jniErr.code == IGNITE_JNI_ERR_SUCCESS && res;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/handle_registry.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/handle_registry.cpp b/modules/platform/src/main/cpp/core/src/impl/handle_registry.cpp
new file mode 100644
index 0000000..c447faa
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/handle_registry.cpp
@@ -0,0 +1,234 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/handle_registry.h"
+
+using namespace ignite::common::concurrent;
+
+namespace ignite
+{
+    namespace impl
+    {
+        HandleRegistryEntry::~HandleRegistryEntry()
+        {
+            // No-op.
+        }
+
+        HandleRegistrySegment::HandleRegistrySegment() : 
+            map(new std::map<int64_t, SharedPointer<HandleRegistryEntry>>()), mux(new CriticalSection())
+        {
+            // No-op.
+        }
+
+        HandleRegistrySegment::~HandleRegistrySegment()
+        {
+            delete map;
+            delete mux;
+        }
+
+        SharedPointer<HandleRegistryEntry> HandleRegistrySegment::Get(int64_t hnd)
+        {
+            mux->Enter();
+
+            SharedPointer<HandleRegistryEntry> res = (*map)[hnd];
+
+            mux->Leave();
+
+            return res;
+        }
+
+        void HandleRegistrySegment::Put(int64_t hnd, const SharedPointer<HandleRegistryEntry>& entry)
+        {
+            mux->Enter();
+
+            (*map)[hnd] = entry;
+
+            mux->Leave();
+        }
+
+        void HandleRegistrySegment::Remove(int64_t hnd)
+        {
+            mux->Enter();
+
+            map->erase(hnd);
+
+            mux->Leave();
+        }
+
+        void HandleRegistrySegment::Clear()
+        {
+            mux->Enter();
+
+            map->erase(map->begin(), map->end());
+
+            mux->Leave();
+        }
+
+        HandleRegistry::HandleRegistry(int32_t fastCap, int32_t slowSegmentCnt)
+        {
+            this->fastCap = fastCap;
+
+            fastCtr = 0;
+
+            fast = new SharedPointer<HandleRegistryEntry>[fastCap];
+
+            for (int i = 0; i < fastCap; i++)
+                fast[i] = SharedPointer<HandleRegistryEntry>();
+
+            this->slowSegmentCnt = slowSegmentCnt;
+
+            slowCtr = fastCap;
+
+            slow = new HandleRegistrySegment*[slowSegmentCnt];
+
+            for (int i = 0; i < slowSegmentCnt; i++)
+                slow[i] = new HandleRegistrySegment();
+
+            closed = 0;
+
+            Memory::Fence();
+        }
+
+        HandleRegistry::~HandleRegistry()
+        {
+            Close();
+
+            delete[] fast;
+
+            for (int i = 0; i < slowSegmentCnt; i++)
+                delete slow[i];
+
+            delete[] slow;
+        }
+
+        int64_t HandleRegistry::Allocate(const SharedPointer<HandleRegistryEntry>& target)
+        {
+            return Allocate0(target, false, false);
+        }
+
+        int64_t HandleRegistry::AllocateCritical(const SharedPointer<HandleRegistryEntry>& target)
+        {
+            return Allocate0(target, true, false);
+        }
+
+        int64_t HandleRegistry::AllocateSafe(const SharedPointer<HandleRegistryEntry>& target)
+        {
+            return Allocate0(target, false, true);
+        }
+
+        int64_t HandleRegistry::AllocateCriticalSafe(const SharedPointer<HandleRegistryEntry>& target)
+        {
+            return Allocate0(target, true, true);
+        }
+
+        void HandleRegistry::Release(int64_t hnd)
+        {
+            if (hnd < fastCap)
+                fast[static_cast<int32_t>(hnd)] = SharedPointer<HandleRegistryEntry>();
+            else
+            {
+                HandleRegistrySegment* segment = *(slow + hnd % slowSegmentCnt);
+
+                segment->Remove(hnd);
+            }
+
+            Memory::Fence();
+        }
+
+        SharedPointer<HandleRegistryEntry> HandleRegistry::Get(int64_t hnd)
+        {
+            Memory::Fence();
+
+            if (hnd < fastCap)
+                return fast[static_cast<int32_t>(hnd)];
+            else
+            {
+                HandleRegistrySegment* segment = *(slow + hnd % slowSegmentCnt);
+
+                return segment->Get(hnd);
+            }
+        }
+
+        void HandleRegistry::Close()
+        {
+            if (Atomics::CompareAndSet32(&closed, 0, 1))
+            {
+                // Cleanup fast-path handles.
+                for (int i = 0; i < fastCap; i++)
+                    fast[i] = SharedPointer<HandleRegistryEntry>();
+
+                // Cleanup slow-path handles.
+                for (int i = 0; i < slowSegmentCnt; i++)
+                    (*(slow + i))->Clear();
+            }
+        }
+
+        int64_t HandleRegistry::Allocate0(const SharedPointer<HandleRegistryEntry>& target, bool critical, bool safe)
+        {
+            // Check closed state.
+            Memory::Fence();
+
+            if (closed == 1)
+                return -1;
+
+            // Try allocating entry on critical path.
+            if (critical)
+            {
+                if (fastCtr < fastCap)
+                {
+                    int32_t fastIdx = Atomics::IncrementAndGet32(&fastCtr) - 1;
+
+                    if (fastIdx < fastCap)
+                    {
+                        fast[fastIdx] = target;
+
+                        // Double-check for closed state if safe mode is on.
+                        Memory::Fence();
+
+                        if (safe && closed == 1)
+                        {
+                            fast[fastIdx] = SharedPointer<HandleRegistryEntry>();
+
+                            return -1;
+                        }
+                        else
+                            return fastIdx;
+                    }
+                }
+            }
+
+            // Either allocating on slow-path, or fast-path can no longer accomodate more entries.
+            int64_t slowIdx = Atomics::IncrementAndGet64(&slowCtr) - 1;
+
+            HandleRegistrySegment* segment = *(slow + slowIdx % slowSegmentCnt);
+
+            segment->Put(slowIdx, target);
+
+            // Double-check for closed state if safe mode is on.
+            Memory::Fence();
+
+            if (safe && closed == 1)
+            {
+                segment->Remove(slowIdx);
+
+                return -1;
+            }
+
+            return slowIdx;
+        }
+    }
+}
\ No newline at end of file


[41/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_writer_impl.h b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
new file mode 100644
index 0000000..b38dc1f
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
@@ -0,0 +1,859 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_PORTABLE_WRITER
+#define _IGNITE_IMPL_PORTABLE_WRITER
+
+#include <cstring>
+#include <string>
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+#include <ignite/common/concurrent.h>
+
+#include "ignite/impl/interop/interop_output_stream.h"
+#include "ignite/impl/portable/portable_common.h"
+#include "ignite/impl/portable/portable_id_resolver.h"
+#include "ignite/impl/portable/portable_metadata_manager.h"
+#include "ignite/impl/portable/portable_utils.h"
+#include "ignite/portable/portable_consts.h"
+#include "ignite/portable/portable_type.h"
+#include "ignite/guid.h"
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace portable
+        {
+            /**
+             * Internal implementation of portable reader.
+             */
+            class IGNITE_IMPORT_EXPORT PortableWriterImpl
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param stream Interop stream.
+                 * @param idRslvr Portable ID resolver.
+                 * @param metaMgr Metadata manager.
+                 * @param metaHnd Metadata handler.
+                 */
+                PortableWriterImpl(ignite::impl::interop::InteropOutputStream* stream, PortableIdResolver* idRslvr, 
+                    PortableMetadataManager* metaMgr, PortableMetadataHandler* metaHnd);
+                
+                /**
+                 * Constructor used to construct light-weight writer allowing only raw operations 
+                 * and primitive objects.
+                 *
+                 * @param stream Interop stream.
+                 * @param metaMgr Metadata manager.
+                 */
+                PortableWriterImpl(ignite::impl::interop::InteropOutputStream* stream, PortableMetadataManager* metaMgr);
+
+                /**
+                 * Write 8-byte signed integer. Maps to "byte" type in Java.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt8(const int8_t val);
+
+                /**
+                 * Write array of 8-byte signed integers. Maps to "byte[]" type in Java.
+                 *
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteInt8Array(const int8_t* val, const int32_t len);
+
+                /**
+                 * Write 8-byte signed integer. Maps to "byte" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 */
+                void WriteInt8(const char* fieldName, const int8_t val);
+
+                /**
+                 * Write array of 8-byte signed integers. Maps to "byte[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteInt8Array(const char* fieldName, const int8_t* val, const int32_t len);
+
+                /**
+                 * Write bool. Maps to "short" type in Java.
+                 *
+                 * @param val Value.
+                 */
+                void WriteBool(const bool val);
+
+                /**
+                 * Write array of bools. Maps to "bool[]" type in Java.
+                 *
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteBoolArray(const bool* val, const int32_t len);
+
+                /**
+                 * Write bool. Maps to "short" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 */
+                void WriteBool(const char* fieldName, const bool val);
+
+                /**
+                 * Write array of bools. Maps to "bool[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteBoolArray(const char* fieldName, const bool* val, const int32_t len);
+
+                /**
+                 * Write 16-byte signed integer. Maps to "short" type in Java.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt16(const int16_t val);
+
+                /**
+                 * Write array of 16-byte signed integers. Maps to "short[]" type in Java.
+                 *
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteInt16Array(const int16_t* val, const int32_t len);
+
+                /**
+                 * Write 16-byte signed integer. Maps to "short" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 */
+                void WriteInt16(const char* fieldName, const int16_t val);
+
+                /**
+                 * Write array of 16-byte signed integers. Maps to "short[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteInt16Array(const char* fieldName, const int16_t* val, const int32_t len);
+
+                /**
+                 * Write 16-byte unsigned integer. Maps to "char" type in Java.
+                 *
+                 * @param val Value.
+                 */
+                void WriteUInt16(const uint16_t val);
+
+                /**
+                 * Write array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+                 *
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteUInt16Array(const uint16_t* val, const int32_t len);
+
+                /**
+                 * Write 16-byte unsigned integer. Maps to "char" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 */
+                void WriteUInt16(const char* fieldName, const uint16_t val);
+
+                /**
+                 * Write array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteUInt16Array(const char* fieldName, const uint16_t* val, const int32_t len);
+
+                /**
+                 * Write 32-byte signed integer. Maps to "int" type in Java.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt32(const int32_t val);
+
+                /**
+                 * Write array of 32-byte signed integers. Maps to "int[]" type in Java.
+                 *
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteInt32Array(const int32_t* val, const int32_t len);
+
+                /**
+                 * Write 32-byte signed integer. Maps to "int" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 */
+                void WriteInt32(const char* fieldName, const int32_t val);
+
+                /**
+                 * Write array of 32-byte signed integers. Maps to "int[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteInt32Array(const char* fieldName, const int32_t* val, const int32_t len);
+
+                /**
+                 * Write 64-byte signed integer. Maps to "long" type in Java.
+                 *
+                 * @param val Value.
+                 */
+                void WriteInt64(const int64_t val);
+
+                /**
+                 * Write array of 64-byte signed integers. Maps to "long[]" type in Java.
+                 *
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteInt64Array(const int64_t* val, const int32_t len);
+
+                /**
+                 * Write 64-byte signed integer. Maps to "long" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 */
+                void WriteInt64(const char* fieldName, const int64_t val);
+
+                /**
+                 * Write array of 64-byte signed integers. Maps to "long[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteInt64Array(const char* fieldName, const int64_t* val, const int32_t len);
+
+                /**
+                 * Write float. Maps to "float" type in Java.
+                 *
+                 * @param val Value.
+                 */
+                void WriteFloat(const float val);
+
+                /**
+                 * Write array of floats. Maps to "float[]" type in Java.
+                 *
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteFloatArray(const float* val, const int32_t len);
+
+                /**
+                 * Write float. Maps to "float" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 */
+                void WriteFloat(const char* fieldName, const float val);
+
+                /**
+                 * Write array of floats. Maps to "float[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteFloatArray(const char* fieldName, const float* val, const int32_t len);
+
+                /**
+                 * Write double. Maps to "double" type in Java.
+                 *
+                 * @param val Value.
+                 */
+                void WriteDouble(const double val);
+
+                /**
+                 * Write array of doubles. Maps to "double[]" type in Java.
+                 *
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteDoubleArray(const double* val, const int32_t len);
+
+                /**
+                 * Write double. Maps to "double" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 */
+                void WriteDouble(const char* fieldName, const double val);
+
+                /**
+                 * Write array of doubles. Maps to "double[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteDoubleArray(const char* fieldName, const double* val, const int32_t len);
+
+                /**
+                 * Write Guid. Maps to "UUID" type in Java.
+                 *
+                 * @param val Value.
+                 */
+                void WriteGuid(const Guid val);
+
+                /**
+                 * Write array of Guids. Maps to "UUID[]" type in Java.
+                 *
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteGuidArray(const Guid* val, const int32_t len);
+
+                /**
+                 * Write Guid. Maps to "UUID" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 */
+                void WriteGuid(const char* fieldName, const Guid val);
+
+                /**
+                 * Write array of Guids. Maps to "UUID[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Array.
+                 * @param len Array length.
+                 */
+                void WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len);
+
+                /**
+                 * Write string.
+                 *
+                 * @param val String.
+                 * @param len String length (characters).
+                 */
+                void WriteString(const char* val, const int32_t len);
+
+                /**
+                 * Write string.
+                 *
+                 * @param fieldName Field name.
+                 * @param val String.
+                 * @param len String length (characters).
+                 */
+                void WriteString(const char* fieldName, const char* val, const int32_t len);
+
+                /**
+                 * Start string array write.
+                 *
+                 * @param typ Collection type.
+                 * @return Session ID.
+                 */
+                int32_t WriteStringArray();
+
+                /**
+                 * Start string array write.
+                 *
+                 * @param fieldName Field name.
+                 * @return Session ID.
+                 */
+                int32_t WriteStringArray(const char* fieldName);
+
+                /**
+                 * Write string element.
+                 *
+                 * @param id Session ID.
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                void WriteStringElement(int32_t id, const char* val, int32_t len);
+
+                /**
+                 * Write NULL value.
+                 */
+                void WriteNull();
+
+                /**
+                 * Write NULL value.
+                 *
+                 * @param fieldName Field name.
+                 */
+                void WriteNull(const char* fieldName);
+
+                /**
+                 * Start array write.
+                 *
+                 * @param typ Collection type.
+                 * @return Session ID.
+                 */
+                int32_t WriteArray();
+
+                /**
+                 * Start array write.
+                 *
+                 * @param fieldName Field name.
+                 * @return Session ID.
+                 */
+                int32_t WriteArray(const char* fieldName);
+                                
+                /**
+                 * Start collection write.
+                 *
+                 * @param typ Collection type.
+                 * @return Session ID.
+                 */
+                int32_t WriteCollection(ignite::portable::CollectionType typ);
+
+                /**
+                 * Start collection write.
+                 *
+                 * @param fieldName Field name.
+                 * @param typ Collection type.
+                 * @return Session ID.
+                 */
+                int32_t WriteCollection(const char* fieldName, ignite::portable::CollectionType typ);
+                
+                /**
+                 * Start map write.
+                 *
+                 * @param typ Map type.
+                 * @return Session ID.
+                 */
+                int32_t WriteMap(ignite::portable::MapType typ);
+
+                /**
+                 * Start map write.
+                 *
+                 * @param fieldName Field name.
+                 * @param typ Map type.
+                 * @return Session ID.
+                 */
+                int32_t WriteMap(const char* fieldName, ignite::portable::MapType typ);
+
+                /**
+                 * Write collection element.
+                 *
+                 * @param id Session ID.
+                 * @param val Value.
+                 */
+                template<typename T>
+                void WriteElement(int32_t id, T val)
+                {
+                    CheckSession(id);
+                                        
+                    WriteTopObject<T>(val);
+
+                    elemCnt++;
+                }
+
+                /**
+                 * Write map element.
+                 *
+                 * @param id Session ID.
+                 * @param key Key.
+                 * @param val Value.
+                 */
+                template<typename K, typename V>
+                void WriteElement(int32_t id, K key, V val)
+                {
+                    CheckSession(id);
+                    
+                    WriteTopObject<K>(key);
+                    WriteTopObject<V>(val);
+
+                    elemCnt++;
+                }
+
+                /**
+                 * Commit container write session.
+                 *
+                 * @param id Session ID.
+                 */
+                void CommitContainer(int32_t id);                
+
+                /**
+                 * Write object.
+                 *
+                 * @param val Object.
+                 */
+                template<typename T>
+                void WriteObject(T val)
+                {
+                    CheckRawMode(true);
+
+                    WriteTopObject(val);
+                }
+
+                /**
+                 * Write object.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Object.
+                 */
+                template<typename T>
+                void WriteObject(const char* fieldName, T val)
+                {
+                    CheckRawMode(false); 
+                        
+                    // 1. Write field ID.
+                    WriteFieldId(fieldName, IGNITE_TYPE_OBJECT);
+
+                    // 2. Preserve space for length.
+                    int32_t lenPos = stream->Position();
+                    stream->Position(lenPos + 4);
+
+                    // 3. Actual write.
+                    WriteTopObject(val);
+
+                    // 4. Write field length.
+                    int32_t len = stream->Position() - lenPos - 4;
+                    stream->WriteInt32(lenPos, len);
+                }
+
+                /**
+                 * Set raw mode.
+                 */
+                void SetRawMode();
+
+                /**
+                 * Get raw position.
+                 */
+                int32_t GetRawPosition();
+
+                /**
+                 * Write object.
+                 *
+                 * @param obj Object to write.
+                 */
+                template<typename T>
+                void WriteTopObject(const T& obj)
+                {
+                    ignite::portable::PortableType<T> type;
+
+                    if (type.IsNull(obj))
+                        stream->WriteInt8(IGNITE_HDR_NULL);
+                    else
+                    {
+                        TemplatedPortableIdResolver<T> idRslvr(type);
+                        ignite::common::concurrent::SharedPointer<PortableMetadataHandler> metaHnd;
+
+                        if (metaMgr)                        
+                            metaHnd = metaMgr->GetHandler(idRslvr.GetTypeId());
+
+                        PortableWriterImpl writerImpl(stream, &idRslvr, metaMgr, metaHnd.Get());
+                        ignite::portable::PortableWriter writer(&writerImpl);
+
+                        int32_t pos = stream->Position();
+
+                        stream->WriteInt8(IGNITE_HDR_FULL);
+                        stream->WriteBool(true);
+                        stream->WriteInt32(idRslvr.GetTypeId());
+                        stream->WriteInt32(type.GetHashCode(obj));
+
+                        stream->Position(pos + IGNITE_FULL_HDR_LEN);
+
+                        type.Write(writer, obj);
+
+                        int32_t len = stream->Position() - pos;
+
+                        stream->WriteInt32(pos + 10, len);
+                        stream->WriteInt32(pos + 14, writerImpl.GetRawPosition() - pos);
+
+                        if (metaMgr)
+                            metaMgr->SubmitHandler(type.GetTypeName(), idRslvr.GetTypeId(), metaHnd.Get());
+                    }
+                }
+
+                /**
+                 * Get underlying stream.
+                 *
+                 * @return Stream.
+                 */
+                impl::interop::InteropOutputStream* GetStream();
+            private:
+                /** Underlying stream. */
+                ignite::impl::interop::InteropOutputStream* stream; 
+                
+                /** ID resolver. */
+                PortableIdResolver* idRslvr;                     
+                
+                /** Metadata manager. */
+                PortableMetadataManager* metaMgr;                   
+                
+                /** Metadata handler. */
+                PortableMetadataHandler* metaHnd;                  
+
+                /** Type ID. */
+                int32_t typeId;                                       
+
+                /** Elements write session ID generator. */
+                int32_t elemIdGen;                                   
+                
+                /** Elements write session ID. */
+                int32_t elemId;                                       
+                
+                /** Elements count. */
+                int32_t elemCnt;                                      
+                
+                /** Elements start position. */
+                int32_t elemPos;                                      
+
+                /** Raw data offset. */
+                int32_t rawPos;                                       
+
+                IGNITE_NO_COPY_ASSIGNMENT(PortableWriterImpl)
+
+                /**
+                 * Write a primitive value to stream in raw mode.
+                 *
+                 * @param val Value.
+                 * @param func Stream function.
+                 */
+                template<typename T>
+                void WritePrimitiveRaw(
+                    const T val, 
+                    void(*func)(interop::InteropOutputStream*, T)
+                )
+                {
+                    CheckRawMode(true);
+                    CheckSingleMode(true);
+
+                    func(stream, val);
+                }
+
+                /**
+                 * Write a primitive array to stream in raw mode.
+                 *
+                 * @param val Value.
+                 * @param len Array length.
+                 * @param func Stream function.
+                 * @param hdr Header.
+                 */
+                template<typename T>
+                void WritePrimitiveArrayRaw(
+                    const T* val,
+                    const int32_t len,
+                    void(*func)(interop::InteropOutputStream*, const T*, const int32_t),
+                    const int8_t hdr
+                )
+                {
+                    CheckRawMode(true);
+                    CheckSingleMode(true);
+
+                    if (val)
+                    {
+                        stream->WriteInt8(hdr);
+                        stream->WriteInt32(len);
+                        func(stream, val, len);
+                    }
+                    else
+                        stream->WriteInt8(IGNITE_HDR_NULL);
+                }
+
+                /**
+                 * Write a primitive value to stream.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 * @param func Stream function.
+                 * @param typ Field type ID.
+                 * @param len Field length.
+                 */
+                template<typename T>
+                void WritePrimitive(
+                    const char* fieldName, 
+                    const T val, 
+                    void(*func)(interop::InteropOutputStream*, T), 
+                    const int8_t typ, 
+                    const int32_t len
+                )
+                {
+                    CheckRawMode(false);
+                    CheckSingleMode(true);
+
+                    WriteFieldId(fieldName, typ);
+
+                    stream->WriteInt32(1 + len);
+                    stream->WriteInt8(typ);
+
+                    func(stream, val);
+                }
+
+                /**
+                 * Write a primitive array to stream.
+                 *
+                 * @param fieldName Field name.
+                 * @param val Value.
+                 * @param len Array length.
+                 * @param func Stream function.
+                 * @param hdr Header.
+                 * @param lenShift Length shift.
+                 */
+                template<typename T>
+                void WritePrimitiveArray(
+                    const char* fieldName, 
+                    const T* val, 
+                    const int32_t len, 
+                    void(*func)(interop::InteropOutputStream*, const T*, const int32_t), 
+                    const int8_t hdr, 
+                    const int32_t lenShift
+                )
+                {
+                    CheckRawMode(false);
+                    CheckSingleMode(true);
+
+                    WriteFieldId(fieldName, hdr);
+
+                    if (val)
+                    {
+                        stream->WriteInt32(5 + (len << lenShift));
+                        stream->WriteInt8(hdr);
+                        stream->WriteInt32(len);
+                        func(stream, val, len);
+                    }
+                    else
+                    {
+                        stream->WriteInt32(1);
+                        stream->WriteInt8(IGNITE_HDR_NULL);
+                    }
+                }
+
+                /**
+                 * Check raw mode.
+                 *
+                 * @param expected Expected raw mode of the reader.
+                 */
+                void CheckRawMode(bool expected);
+
+                /**
+                 * Check whether writer is currently operating in single mode.
+                 *
+                 * @param expected Expected value.
+                 */
+                void CheckSingleMode(bool expected);
+
+                /**
+                 * Start new container writer session.
+                 *
+                 * @param expRawMode Expected raw mode.
+                 */
+                void StartContainerSession(bool expRawMode);
+
+                /**
+                 * Check whether session ID matches.
+                 *
+                 * @param ses Expected session ID.
+                 */
+                void CheckSession(int32_t expSes);
+
+                /**
+                 * Write field ID.
+                 *
+                 * @param fieldName Field name.
+                 * @param fieldTypeId Field type ID.
+                 */
+                void WriteFieldId(const char* fieldName, int32_t fieldTypeId);
+
+                /**
+                 * Write field ID and skip field length.
+                 *
+                 * @param fieldName Field name.
+                 * @param fieldTypeId Field type ID.
+                 */
+                void WriteFieldIdSkipLength(const char* fieldName, int32_t fieldTypeId);
+
+                /**
+                 * Write field ID and length.
+                 *
+                 * @param fieldName Field name.
+                 * @param fieldTypeId Field type ID.
+                 * @param len Length.
+                 */
+                void WriteFieldIdAndLength(const char* fieldName, int32_t fieldTypeId, int32_t len);
+
+                /**
+                 * Write primitive value.
+                 *
+                 * @param obj Value.
+                 * @param func Stream function.
+                 * @param hdr Header.
+                 */
+                template<typename T>
+                void WriteTopObject0(const T obj, void(*func)(impl::interop::InteropOutputStream*, T), const int8_t hdr)
+                {
+                    stream->WriteInt8(hdr);
+                    func(stream, obj);
+                }
+            };
+
+            template<>
+            void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int8_t& obj);
+
+            template<>
+            void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const bool& obj);
+
+            template<>
+            void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int16_t& obj);
+
+            template<>
+            void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const uint16_t& obj);
+
+            template<>
+            void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int32_t& obj);
+
+            template<>
+            void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int64_t& obj);
+
+            template<>
+            void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const float& obj);
+
+            template<>
+            void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const double& obj);
+
+            template<>
+            void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const Guid& obj);
+
+            template<>
+            inline void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const std::string& obj)
+            {
+                const char* obj0 = obj.c_str();
+
+                int32_t len = static_cast<int32_t>(strlen(obj0));
+
+                stream->WriteInt8(IGNITE_TYPE_STRING);
+
+                PortableUtils::WriteString(stream, obj0, len);
+            }
+        }
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/portable/portable.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/portable/portable.h b/modules/platform/src/main/cpp/core/include/ignite/portable/portable.h
new file mode 100644
index 0000000..1a7c3dd
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/portable/portable.h
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_PORTABLE
+#define _IGNITE_PORTABLE
+
+#include "ignite/portable/portable_consts.h"
+#include "ignite/portable/portable_containers.h"
+#include "ignite/portable/portable_type.h"
+#include "ignite/portable/portable_raw_reader.h"
+#include "ignite/portable/portable_raw_writer.h"
+#include "ignite/portable/portable_reader.h"
+#include "ignite/portable/portable_writer.h"
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/portable/portable_consts.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/portable/portable_consts.h b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_consts.h
new file mode 100644
index 0000000..ef6db45
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_consts.h
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_PORTABLE_CONSTS
+#define _IGNITE_PORTABLE_CONSTS
+
+#include <ignite/common/common.h>
+
+namespace ignite 
+{
+    namespace portable 
+    {
+        /**
+         * Portable collection types.
+         */
+        enum CollectionType 
+        {
+            /** 
+             * Undefined. Maps to ArrayList in Java.
+             */
+            IGNITE_COLLECTION_UNDEFINED = 0,
+
+            /** 
+             * Array list. Maps to ArrayList in Java.
+             */
+            IGNITE_COLLECTION_ARRAY_LIST = 1,
+            
+            /**
+             * Linked list. Maps to LinkedList in Java.
+             */
+            IGNITE_COLLECTION_LINKED_LIST = 2,
+            
+            /**
+             * Hash set. Maps to HashSet in Java.
+             */
+            IGNITE_COLLECTION_HASH_SET = 3,
+            
+            /**
+             * Linked hash set. Maps to LinkedHashSet in Java.
+             */
+            IGNITE_COLLECTION_LINKED_HASH_SET = 4,
+
+            /**
+             * Tree set. Maps to TreeSet in Java.
+             */
+            IGNITE_COLLECTION_TREE_SET = 5,
+
+            /**
+             * Concurrent skip list set. Maps to ConcurrentSkipListSet in Java.
+             */
+            IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET = 6
+        };
+
+        /**
+         * Portable map types.
+         */
+        enum MapType 
+        {
+            /**
+             * Undefined. Maps to HashMap in Java.
+             */
+            IGNITE_MAP_UNDEFINED = 0,
+            
+            /**
+             * Hash map. Maps to HashMap in Java.
+             */
+            IGNITE_MAP_HASH_MAP = 1,
+            
+            /**
+             * Linked hash map. Maps to LinkedHashMap in Java.
+             */
+            IGNITE_MAP_LINKED_HASH_MAP = 2,
+
+            /**
+             * Tree map. Maps to TreeMap in Java.
+             */
+            IGNITE_MAP_TREE_MAP = 3,
+            
+            /**
+             * Concurrent hash map. Maps to ConcurrentHashMap in Java.
+             */
+            IGNITE_MAP_CONCURRENT_HASH_MAP = 4,
+            
+            /**
+             * Properties map. Maps to Properties in Java.
+             */
+            IGNITE_MAP_PROPERTIES_MAP = 5
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/portable/portable_containers.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/portable/portable_containers.h b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_containers.h
new file mode 100644
index 0000000..f93a11a
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_containers.h
@@ -0,0 +1,525 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_PORTABLE_CONTAINERS
+#define _IGNITE_PORTABLE_CONTAINERS
+
+#include <stdint.h>
+
+#include "ignite/impl/portable/portable_writer_impl.h"
+#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/impl/utils.h"
+#include "ignite/portable/portable_consts.h"
+
+namespace ignite
+{
+    namespace portable
+    {
+        /**
+         * Portable string array writer.
+         */
+        class IGNITE_IMPORT_EXPORT PortableStringArrayWriter
+        {
+        public:
+            /**
+             * Constructor.
+             * 
+             * @param id Identifier.
+             * @param impl Writer.
+             */
+            PortableStringArrayWriter(impl::portable::PortableWriterImpl* impl, const int32_t id);
+
+            /**
+             * Write string.
+             *
+             * @param val Null-terminated character sequence.
+             */
+            void Write(const char* val);
+
+            /**
+             * Write string.
+             *
+             * @param val String.
+             * @param len String length (characters).
+             */
+            void Write(const char* val, const int32_t len);
+
+            /**
+             * Write string.
+             *
+             * @param val String.
+             */
+            void Write(const std::string& val)
+            {
+                Write(val.c_str());
+            }
+
+            /**
+             * Close the writer.
+             */
+            void Close();
+        private:
+            /** Implementation delegate. */
+            impl::portable::PortableWriterImpl* impl; 
+
+            /** Idnetifier. */
+            const int32_t id;    
+        };
+
+        /**
+         * Portable collection writer.
+         */
+        template<typename T>
+        class IGNITE_IMPORT_EXPORT PortableArrayWriter
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Writer.
+             * @param id Identifier.
+             */
+            PortableArrayWriter(impl::portable::PortableWriterImpl* impl, const int32_t id) : impl(impl), id(id)
+            {
+                // No-op.
+            }
+
+            /**
+             * Write a value.
+             *
+             * @param val Value.
+             */
+            void Write(const T& val)
+            {
+                impl->WriteElement<T>(id, val);
+            }
+
+            /**
+             * Close the writer.
+             */
+            void Close()
+            {
+                impl->CommitContainer(id);
+            }
+        private:
+            /** Implementation delegate. */
+            impl::portable::PortableWriterImpl* impl; 
+
+            /** Idnetifier. */
+            const int32_t id;      
+        };
+
+        /**
+         * Portable collection writer.
+         */
+        template<typename T>
+        class IGNITE_IMPORT_EXPORT PortableCollectionWriter
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Writer.
+             * @param id Identifier.
+             */
+            PortableCollectionWriter(impl::portable::PortableWriterImpl* impl, const int32_t id) : impl(impl), id(id)
+            {
+                // No-op.
+            }
+
+            /**
+             * Write a value.
+             *
+             * @param val Value.
+             */
+            void Write(const T& val)
+            {
+                impl->WriteElement<T>(id, val);
+            }
+
+            /**
+             * Close the writer.
+             */
+            void Close()
+            {
+                impl->CommitContainer(id);
+            }
+        private:
+            /** Implementation delegate. */
+            impl::portable::PortableWriterImpl* impl; 
+
+            /** Identifier. */
+            const int32_t id;    
+        };
+
+        /**
+         * Portable map writer.
+         */
+        template<typename K, typename V>
+        class IGNITE_IMPORT_EXPORT PortableMapWriter
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Writer.
+             */
+            PortableMapWriter(impl::portable::PortableWriterImpl* impl, const int32_t id) : impl(impl), id(id)
+            {
+                // No-op.
+            }
+
+            /**
+             * Write a value.
+             *
+             * @param key Key.
+             * @param val Value.
+             */
+            void Write(const K& key, const V& val)
+            {
+                impl->WriteElement<K, V>(id, key, val);
+            }
+
+            /**
+             * Close the writer.
+             */
+            void Close()
+            {
+                impl->CommitContainer(id);
+            }
+        private:
+            /** Implementation delegate. */
+            impl::portable::PortableWriterImpl* impl; 
+
+            /** Identifier. */
+            const int32_t id;      
+        };
+
+        /**
+         * Portable string array reader.
+         */
+        class IGNITE_IMPORT_EXPORT PortableStringArrayReader
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Reader.
+             * @param id Identifier.
+             * @param size Array size.
+             */
+            PortableStringArrayReader(impl::portable::PortableReaderImpl* impl, const int32_t id, const int32_t size);
+
+            /**
+             * Check whether next element is available for read.
+             *
+             * @return True if available.
+             */
+            bool HasNext();
+
+            /**
+             * Get next element.
+             *
+             * @param res Array to store data to. 
+             * @param len Expected length of string. NULL terminator will be set in case len is 
+             *     greater than real string length.
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t GetNext(char* res, const int32_t len);
+
+            /**
+             * Get next element.
+             *
+             * @return String. 
+             */
+            std::string GetNext()
+            {
+                int32_t len = GetNext(NULL, 0);
+
+                if (len != -1)
+                {
+                    impl::utils::SafeArray<char> arr(len + 1);
+
+                    GetNext(arr.target, len + 1);
+
+                    return std::string(arr.target);
+                }
+                else
+                    return std::string();
+            }
+
+            /**
+             * Get array size.
+             *
+             * @return Size or -1 if array is NULL.
+             */
+            int32_t GetSize();
+
+            /**
+             * Whether array is NULL.
+             */
+            bool IsNull();
+        private:
+            /** Implementation delegate. */
+            impl::portable::PortableReaderImpl* impl;  
+
+            /** Identifier. */
+            const int32_t id;    
+
+            /** Size. */
+            const int32_t size;                              
+        };
+
+        /**
+         * Portable array reader.
+         */
+        template<typename T>
+        class PortableArrayReader
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Reader.
+             * @param id Identifier.
+             * @param size Array size.
+             */
+            PortableArrayReader(impl::portable::PortableReaderImpl* impl, const int32_t id, const int32_t size) : 
+                impl(impl), id(id), size(size)
+            {
+                // No-op.
+            }
+
+            /**
+             * Check whether next element is available for read.
+             *
+             * @return True if available.
+             */
+            bool HasNext()
+            {
+                return impl->HasNextElement(id);
+            }
+
+            /**
+             * Read next element.
+             *
+             * @return Next element.
+             */
+            T GetNext()
+            {
+                return impl->ReadElement<T>(id);
+            }
+
+            /**
+             * Get array size.
+             *
+             * @return Size or -1 if array is NULL.
+             */
+            int32_t GetSize()
+            {
+                return size;
+            }
+
+            /**
+             * Whether array is NULL.
+             */
+            bool IsNull()
+            {
+                return size == -1;
+            }
+        private:
+            /** Implementation delegate. */
+            impl::portable::PortableReaderImpl* impl;
+
+            /** Identifier. */
+            const int32_t id;
+
+            /** Size. */
+            const int32_t size;
+        };
+
+        /**
+         * Portable collection reader.
+         */
+        template<typename T>
+        class PortableCollectionReader
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Reader.
+             * @param id Identifier.
+             * @param type Collection type.
+             * @param size Collection size.
+             */
+            PortableCollectionReader(impl::portable::PortableReaderImpl* impl, const int32_t id, 
+                const CollectionType type,  const int32_t size) : impl(impl), id(id), type(type), size(size)
+            {
+                // No-op.
+            }
+
+            /**
+             * Check whether next element is available for read.
+             *
+             * @return True if available.
+             */
+            bool HasNext()
+            {
+                return impl->HasNextElement(id);
+            }
+
+            /**
+             * Read next element.
+             *
+             * @return Next element.
+             */
+            T GetNext()
+            {
+                return impl->ReadElement<T>(id);
+            }
+            
+            /**
+             * Get collection type.
+             *
+             * @return Type.
+             */
+            CollectionType GetType()
+            {
+                return type;
+            }
+
+            /**
+             * Get collection size.
+             *
+             * @return Size or -1 if collection is NULL.
+             */
+            int32_t GetSize()
+            {
+                return size;
+            }
+
+            /**
+             * Whether collection is NULL.
+             */
+            bool IsNull()
+            {
+                return size == -1;
+            }
+        private:
+            /** Implementation delegate. */
+            impl::portable::PortableReaderImpl* impl;  
+
+            /** Identifier. */
+            const int32_t id;     
+            
+            /** Collection type. */
+            const CollectionType type;  
+
+            /** Size. */
+            const int32_t size;                              
+        };    
+
+        /**
+         * Portable map reader.
+         */
+        template<typename K, typename V>
+        class PortableMapReader
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Reader.
+             * @param id Identifier.
+             * @param type Map type.
+             * @param size Map size.
+            */
+            PortableMapReader(impl::portable::PortableReaderImpl* impl, const int32_t id, const MapType type,
+                const int32_t size) : impl(impl), id(id), type(type), size(size)
+            {
+                // No-op.
+            }
+
+            /**
+             * Check whether next element is available for read.
+             *
+             * @return True if available.
+             */
+            bool HasNext()
+            {
+                return impl->HasNextElement(id);
+            }
+
+            /**
+             * Read next element.
+             *
+             * @param key Key.
+             * @param val Value.
+             */
+            void GetNext(K* key, V* val)
+            {
+                return impl->ReadElement<K, V>(id, key, val);
+            }
+
+            /**
+             * Get map type.
+             *
+             * @return Type.
+             */
+            MapType GetType()
+            {
+                return type;
+            }
+
+            /**
+             * Get map size.
+             *
+             * @return Size or -1 if map is NULL.
+             */
+            int32_t GetSize()
+            {
+                return size;
+            }
+
+            /**
+             * Whether map is NULL.
+             */
+            bool IsNull()
+            {
+                return size == -1;
+            }
+        private:
+            /** Implementation delegate. */
+            impl::portable::PortableReaderImpl* impl;  
+
+            /** Identifier. */
+            const int32_t id;     
+
+            /** Map type. */
+            const MapType type;
+
+            /** Size. */
+            const int32_t size;
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/portable/portable_raw_reader.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/portable/portable_raw_reader.h b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_raw_reader.h
new file mode 100644
index 0000000..9f1d74c
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_raw_reader.h
@@ -0,0 +1,324 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_PORTABLE_RAW_READER
+#define _IGNITE_PORTABLE_RAW_READER
+
+#include <stdint.h>
+#include <string>
+
+#include <ignite/common/common.h>
+
+#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/portable/portable_consts.h"
+#include "ignite/portable/portable_containers.h"
+#include "ignite/guid.h"
+
+namespace ignite
+{    
+    namespace portable
+    {
+        /**
+         * Portable raw reader.
+         */
+        class IGNITE_IMPORT_EXPORT PortableRawReader
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Implementation.
+             */
+            PortableRawReader(ignite::impl::portable::PortableReaderImpl* impl);
+                        
+            /**
+             * Read 8-byte signed integer. Maps to "byte" type in Java.
+             *
+             * @return Result.
+             */
+            int8_t ReadInt8();
+
+            /**
+             * Read array of 8-byte signed integers. Maps to "byte[]" type in Java.
+             *
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written 
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadInt8Array(int8_t* res, const int32_t len);
+
+            /**
+             * Read bool. Maps to "boolean" type in Java.
+             *
+             * @return Result.
+             */
+            bool ReadBool();
+
+            /**
+             * Read array of bools. Maps to "boolean[]" type in Java.
+             *
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadBoolArray(bool* res, const int32_t len);
+            
+            /**
+             * Read 16-byte signed integer. Maps to "short" type in Java.
+             *
+             * @return Result.
+             */
+            int16_t ReadInt16();
+
+            /**
+             * Read array of 16-byte signed integers. Maps to "short[]" type in Java.
+             *
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadInt16Array(int16_t* res, const int32_t len);
+
+            /**
+             * Read 16-byte unsigned integer. Maps to "char" type in Java.
+             *
+             * @return Result.
+             */
+            uint16_t ReadUInt16();
+
+            /**
+             * Read array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+             *
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadUInt16Array(uint16_t* res, const int32_t len);
+
+            /**
+             * Read 32-byte signed integer. Maps to "int" type in Java.
+             *
+             * @return Result.
+             */
+            int32_t ReadInt32();
+            
+            /**
+             * Read array of 32-byte signed integers. Maps to "int[]" type in Java.
+             *
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadInt32Array(int32_t* res, const int32_t len);
+
+            /**
+             * Read 64-byte signed integer. Maps to "long" type in Java.
+             *
+             * @return Result.
+             */
+            int64_t ReadInt64();
+
+            /**
+             * Read array of 64-byte signed integers. Maps to "long[]" type in Java.
+             *
+             * @param res Array to store data to.
+             * @param len Expected length of array.
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadInt64Array(int64_t* res, const int32_t len);
+
+            /**
+             * Read float. Maps to "float" type in Java.
+             *
+             * @return Result.
+             */
+            float ReadFloat();
+            
+            /**
+             * Read array of floats. Maps to "float[]" type in Java.
+             *
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadFloatArray(float* res, const int32_t len);
+
+            /**
+             * Read double. Maps to "double" type in Java.
+             *
+             * @return Result.
+             */
+            double ReadDouble();
+            
+            /**
+             * Read array of doubles. Maps to "double[]" type in Java.
+             *
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadDoubleArray(double* res, const int32_t len);
+            
+            /**
+             * Read Guid. Maps to "UUID" type in Java.
+             *
+             * @return Result.
+             */
+            Guid ReadGuid();
+
+            /**
+             * Read array of Guids. Maps to "UUID[]" type in Java.
+             *
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadGuidArray(Guid* res, const int32_t len);
+
+            /**
+             * Read string.
+             *
+             * @param res Array to store data to. 
+             * @param len Expected length of string. NULL terminator will be set in case len is 
+             *     greater than real string length.
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadString(char* res, const int32_t len);
+
+            /**
+             * Read string from the stream.
+             *
+             * @return String. 
+             */
+            std::string ReadString()
+            {
+                int32_t len = ReadString(NULL, 0);
+
+                if (len != -1)
+                {
+                    ignite::impl::utils::SafeArray<char> arr(len + 1);
+
+                    ReadString(arr.target, len + 1);
+
+                    return std::string(arr.target);
+                }
+                else
+                    return std::string();
+            }
+
+            /**
+             * Start string array read.
+             *
+             * @return String array reader.
+             */
+            PortableStringArrayReader ReadStringArray();
+
+            /**
+             * Start array read.
+             *
+             * @return Array reader.
+             */
+            template<typename T>
+            PortableArrayReader<T> ReadArray()
+            {
+                int32_t size;
+
+                int32_t id = impl->ReadArray(&size);
+
+                return PortableArrayReader<T>(impl, id, size);
+            }
+
+            /**
+             * Start collection read.
+             *
+             * @return Collection reader.
+             */
+            template<typename T>
+            PortableCollectionReader<T> ReadCollection()
+            {
+                CollectionType typ;
+                int32_t size;
+
+                int32_t id = impl->ReadCollection(&typ, &size);
+
+                return PortableCollectionReader<T>(impl, id, typ, size);
+            }
+
+            /**
+             * Start map read.
+             *
+             * @return Map reader.
+             */
+            template<typename K, typename V>
+            PortableMapReader<K, V> ReadMap()
+            {
+                MapType typ;
+                int32_t size;
+
+                int32_t id = impl->ReadMap(&typ, &size);
+
+                return PortableMapReader<K, V>(impl, id, typ, size);
+            }
+
+            /**
+             * Read object.
+             *
+             * @return Object.
+             */
+            template<typename T>
+            T ReadObject()
+            {
+                return impl->ReadObject<T>();
+            }
+        private:
+            /** Implementation delegate. */
+            ignite::impl::portable::PortableReaderImpl* impl;  
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/portable/portable_raw_writer.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/portable/portable_raw_writer.h b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_raw_writer.h
new file mode 100644
index 0000000..47b5880
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_raw_writer.h
@@ -0,0 +1,300 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_PORTABLE_RAW_WRITER
+#define _IGNITE_PORTABLE_RAW_WRITER
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#include "ignite/impl/portable/portable_writer_impl.h"
+#include "ignite/portable/portable_consts.h"
+#include "ignite/portable/portable_containers.h"
+#include "ignite/guid.h"
+
+namespace ignite
+{
+    namespace portable
+    {
+        /**
+         * Portable raw writer.
+         */
+        class IGNITE_IMPORT_EXPORT PortableRawWriter
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Implementation.
+             */
+            PortableRawWriter(ignite::impl::portable::PortableWriterImpl* impl);
+
+            /**
+             * Write 8-byte signed integer. Maps to "byte" type in Java.
+             *
+             * @param val Value.
+             */
+            void WriteInt8(const int8_t val);
+
+            /**
+             * Write array of 8-byte signed integers. Maps to "byte[]" type in Java.
+             *
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteInt8Array(const int8_t* val, const int32_t len);
+
+            /**
+             * Write bool. Maps to "short" type in Java.
+             *
+             * @param val Value.
+             */
+            void WriteBool(const bool val);
+
+            /**
+             * Write array of bools. Maps to "bool[]" type in Java.
+             *
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteBoolArray(const bool* val, const int32_t len);
+
+            /**
+             * Write 16-byte signed integer. Maps to "short" type in Java.
+             *
+             * @param val Value.
+             */
+            void WriteInt16(const int16_t val);
+
+            /**
+             * Write array of 16-byte signed integers. Maps to "short[]" type in Java.
+             *
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteInt16Array(const int16_t* val, const int32_t len);
+
+            /**
+             * Write 16-byte unsigned integer. Maps to "char" type in Java.
+             *
+             * @param val Value.
+             */
+            void WriteUInt16(const uint16_t val);
+
+            /**
+             * Write array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+             *
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteUInt16Array(const uint16_t* val, const int32_t len);
+
+            /**
+             * Write 32-byte signed integer. Maps to "int" type in Java.
+             *
+             * @param val Value.
+             */
+            void WriteInt32(const int32_t val);
+
+            /**
+             * Write array of 32-byte signed integers. Maps to "int[]" type in Java.
+             *
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteInt32Array(const int32_t* val, const int32_t len);
+
+            /**
+             * Write 64-byte signed integer. Maps to "long" type in Java.
+             *
+             * @param val Value.
+             */
+            void WriteInt64(const int64_t val);
+
+            /**
+             * Write array of 64-byte signed integers. Maps to "long[]" type in Java.
+             *
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteInt64Array(const int64_t* val, const int32_t len);
+
+            /**
+             * Write float. Maps to "float" type in Java.
+             *
+             * @param val Value.
+             */
+            void WriteFloat(const float val);
+
+            /**
+             * Write array of floats. Maps to "float[]" type in Java.
+             *
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteFloatArray(const float* val, const int32_t len);
+
+            /**
+             * Write double. Maps to "double" type in Java.
+             *
+             * @param val Value.
+             */
+            void WriteDouble(const double val);
+
+            /**
+             * Write array of doubles. Maps to "double[]" type in Java.
+             *
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteDoubleArray(const double* val, const int32_t len);
+
+            /**
+             * Write Guid. Maps to "UUID" type in Java.
+             *
+             * @param val Value.
+             */
+            void WriteGuid(const Guid val);
+
+            /**
+             * Write array of Guids. Maps to "UUID[]" type in Java.
+             *
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteGuidArray(const Guid* val, const int32_t len);
+
+            /**
+             * Write string.
+             *
+             * @param val Null-terminated character array.
+             */
+            void WriteString(const char* val);
+
+            /**
+             * Write string.
+             *
+             * @param val String.
+             * @param len String length (characters).
+             */
+            void WriteString(const char* val, const int32_t len);
+            
+            /**
+             * Write string.
+             *
+             * @param val String.
+             */
+            void WriteString(const std::string& val)
+            {
+                WriteString(val.c_str());
+            }
+            
+            /**
+             * Start string array write.
+             *
+             * @return String array writer.
+             */
+            PortableStringArrayWriter WriteStringArray();
+
+            /**
+             * Write NULL value.
+             */
+            void WriteNull();
+
+            /**
+             * Start array write.
+             *
+             * @return Array writer.
+             */
+            template<typename T>
+            PortableArrayWriter<T> WriteArray()
+            {
+                int32_t id = impl->WriteArray();
+
+                return PortableArrayWriter<T>(impl, id);
+            }
+
+            /**
+             * Start collection write.
+             *
+             * @return Collection writer.
+             */
+            template<typename T>
+            PortableCollectionWriter<T> WriteCollection()
+            {
+                return WriteCollection<T>(IGNITE_COLLECTION_UNDEFINED);
+            }
+
+            /**
+             * Start collection write.
+             *
+             * @param type Collection type.
+             * @return Collection writer.
+             */
+            template<typename T>
+            PortableCollectionWriter<T> WriteCollection(ignite::portable::CollectionType typ)
+            {
+                int32_t id = impl->WriteCollection(typ);
+
+                return PortableCollectionWriter<T>(impl, id);
+            }
+
+            /**
+             * Start map write.
+             *
+             * @param typ Map type.
+             * @return Map writer.
+             */
+            template<typename K, typename V>
+            PortableMapWriter<K, V> WriteMap()
+            {
+                return WriteMap<K, V>(IGNITE_MAP_UNDEFINED);
+            }
+
+            /**
+             * Start map write.
+             *
+             * @param typ Map type.
+             * @return Map writer.
+             */
+            template<typename K, typename V>
+            PortableMapWriter<K, V> WriteMap(ignite::portable::MapType typ)
+            {
+                int32_t id = impl->WriteMap(typ);
+
+                return PortableMapWriter<K, V>(impl, id);
+            }
+
+            /**
+             * Write object.
+             *
+             * @param val Object.
+             */
+            template<typename T>
+            void WriteObject(T val)
+            {
+                impl->WriteObject<T>(val);
+            }
+        private:
+            /** Implementation delegate. */
+            ignite::impl::portable::PortableWriterImpl* impl; 
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/portable/portable_reader.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/portable/portable_reader.h b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_reader.h
new file mode 100644
index 0000000..5e4b7ad
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_reader.h
@@ -0,0 +1,355 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_PORTABLE_READER
+#define _IGNITE_PORTABLE_READER
+
+#include <stdint.h>
+#include <string>
+
+#include <ignite/common/common.h>
+
+#include "ignite/portable/portable_raw_reader.h"
+#include "ignite/guid.h"
+
+namespace ignite
+{    
+    namespace portable
+    {
+        /**
+         * Portable reader.
+         */
+        class IGNITE_IMPORT_EXPORT PortableReader
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Implementation.
+             */
+            PortableReader(ignite::impl::portable::PortableReaderImpl* impl);
+
+            /**
+             * Read 8-byte signed integer. Maps to "byte" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param fieldName Field name.
+             * @return Result.
+             */
+            int8_t ReadInt8(const char* fieldName);
+
+            /**
+             * Read array of 8-byte signed integers. Maps to "byte[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param res Array to store data to.
+             * @param len Expected length of array.
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadInt8Array(const char* fieldName, int8_t* res, const int32_t len);
+
+            /**
+             * Read bool. Maps to "short" type in Java.
+             *
+             * @param fieldName Field name.
+             * @return Result.
+             */
+            bool ReadBool(const char* fieldName);
+
+            /**
+             * Read array of bools. Maps to "bool[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadBoolArray(const char* fieldName, bool* res, const int32_t len);
+
+            /**
+             * Read 16-byte signed integer. Maps to "short" type in Java.
+             *
+             * @param fieldName Field name.
+             * @return Result.
+             */
+            int16_t ReadInt16(const char* fieldName);
+
+            /**
+             * Read array of 16-byte signed integers. Maps to "short[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param res Array to store data to.
+             * @param len Expected length of array.
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadInt16Array(const char* fieldName, int16_t* res, const int32_t len);
+
+            /**
+             * Read 16-byte unsigned integer. Maps to "char" type in Java.
+             *
+             * @param fieldName Field name.
+             * @return Result.
+             */
+            uint16_t ReadUInt16(const char* fieldName);
+
+            /**
+             * Read array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadUInt16Array(const char* fieldName, uint16_t* res, const int32_t len);
+
+            /**
+             * Read 32-byte signed integer. Maps to "int" type in Java.
+             *
+             * @param fieldName Field name.
+             * @return Result.
+             */
+            int32_t ReadInt32(const char* fieldName);
+
+            /**
+             * Read array of 32-byte signed integers. Maps to "int[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadInt32Array(const char* fieldName, int32_t* res, const int32_t len);
+
+            /**
+             * Read 64-byte signed integer. Maps to "long" type in Java.
+             *
+             * @param fieldName Field name.
+             * @return Result.
+             */
+            int64_t ReadInt64(const char* fieldName);
+
+            /**
+             * Read array of 64-byte signed integers. Maps to "long[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadInt64Array(const char* fieldName, int64_t* res, const int32_t len);
+
+            /**
+             * Read float. Maps to "float" type in Java.
+             *
+             * @param fieldName Field name.
+             * @return Result.
+             */
+            float ReadFloat(const char* fieldName);
+
+            /**
+             * Read array of floats. Maps to "float[]" type in Java.
+             * 
+             * @param fieldName Field name.
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadFloatArray(const char* fieldName, float* res, const int32_t len);
+
+            /**
+             * Read double. Maps to "double" type in Java.
+             *
+             * @param fieldName Field name.
+             * @return Result.
+             */
+            double ReadDouble(const char* fieldName);
+
+            /**
+             * Read array of doubles. Maps to "double[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadDoubleArray(const char* fieldName, double* res, const int32_t len);
+
+            /**
+             * Read Guid. Maps to "UUID" type in Java.
+             *
+             * @param fieldName Field name.
+             * @return Result.
+             */
+            Guid ReadGuid(const char* fieldName);
+
+            /**
+             * Read array of Guids. Maps to "UUID[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param res Array to store data to.
+             * @param len Expected length of array.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadGuidArray(const char* fieldName, Guid* res, const int32_t len);
+
+            /**
+             * Read string.
+             *
+             * @param fieldName Field name.
+             * @param res Array to store data to.
+             * @param len Expected length of string. NULL terminator will be set in case len is
+             *     greater than real string length.             
+             * @return Actual amount of elements read. If "len" argument is less than actual
+             *     array size or resulting array is set to null, nothing will be written
+             *     to resulting array and returned value will contain required array length.
+             *     -1 will be returned in case array in stream was null.
+             */
+            int32_t ReadString(const char* fieldName, char* res, const int32_t len);
+
+            /**
+             * Read string from the stream.
+             *
+             * @param fieldName Field name.
+             * @return String.
+             */
+            std::string ReadString(const char* fieldName)
+            {
+                int32_t len = ReadString(fieldName, NULL, 0);
+
+                if (len != -1)
+                {
+                    ignite::impl::utils::SafeArray<char> arr(len + 1);
+
+                    ReadString(fieldName, arr.target, len + 1);
+
+                    return std::string(arr.target);
+                }
+                else
+                    return std::string();
+            }
+
+            /**
+             * Start string array read.
+             *
+             * @param fieldName Field name.
+             * @return String array reader.
+             */
+            PortableStringArrayReader ReadStringArray(const char* fieldName);
+
+            /**
+             * Start array read.
+             *
+             * @param fieldName Field name.
+             * @return Array reader.
+             */
+            template<typename T>
+            PortableArrayReader<T> ReadArray(const char* fieldName)
+            {
+                int32_t size;
+
+                int32_t id = impl->ReadArray(fieldName, &size);
+
+                return PortableArrayReader<T>(impl, id, size);
+            }
+
+            /**
+             * Start collection read.
+             *
+             * @param fieldName Field name.
+             * @return Collection reader.
+             */
+            template<typename T>
+            PortableCollectionReader<T> ReadCollection(const char* fieldName)
+            {
+                CollectionType typ;
+                int32_t size;
+
+                int32_t id = impl->ReadCollection(fieldName, &typ, &size);
+
+                return PortableCollectionReader<T>(impl, id, typ, size);
+            }
+
+            /**
+             * Start map read.
+             *
+             * @param fieldName Field name.
+             * @return Map reader.
+             */
+            template<typename K, typename V>
+            PortableMapReader<K, V> ReadMap(const char* fieldName)
+            {
+                MapType typ;
+                int32_t size;
+
+                int32_t id = impl->ReadMap(fieldName, &typ, &size);
+
+                return PortableMapReader<K, V>(impl, id, typ, size);
+            }
+
+            /**
+             * Read object.
+             *
+             * @param fieldName Field name.
+             * @return Object.
+             */
+            template<typename T>
+            T ReadObject(const char* fieldName)
+            {
+                return impl->ReadObject<T>(fieldName);
+            }
+
+            /**
+             * Get raw reader for this reader.
+             *
+             * @return Raw reader.
+             */
+            PortableRawReader RawReader();
+        private:
+            /** Implementation delegate. */
+            ignite::impl::portable::PortableReaderImpl* impl;
+        };            
+    }
+}
+
+#endif
\ No newline at end of file


[19/50] [abbrv] ignite git commit: 1.5.0-SNAPSHOT

Posted by ak...@apache.org.
1.5.0-SNAPSHOT


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

Branch: refs/heads/ignite-843
Commit: fe1caa6263c4d3b3dc2c35aa93e5d57869b10c43
Parents: 27cd615
Author: Ignite Teamcity <ig...@apache.org>
Authored: Thu Sep 3 14:22:57 2015 +0300
Committer: Ignite Teamcity <ig...@apache.org>
Committed: Thu Sep 3 14:22:57 2015 +0300

----------------------------------------------------------------------
 examples/pom.xml                                   | 2 +-
 modules/aop/pom.xml                                | 2 +-
 modules/apache-license-gen/pom.xml                 | 5 ++---
 modules/aws/pom.xml                                | 2 +-
 modules/clients/pom.xml                            | 2 +-
 modules/cloud/pom.xml                              | 2 +-
 modules/codegen/pom.xml                            | 2 +-
 modules/core/pom.xml                               | 2 +-
 modules/core/src/main/resources/ignite.properties  | 2 +-
 modules/extdata/p2p/pom.xml                        | 2 +-
 modules/extdata/uri/modules/uri-dependency/pom.xml | 2 +-
 modules/extdata/uri/pom.xml                        | 2 +-
 modules/gce/pom.xml                                | 2 +-
 modules/geospatial/pom.xml                         | 2 +-
 modules/hadoop/pom.xml                             | 2 +-
 modules/hibernate/pom.xml                          | 2 +-
 modules/indexing/pom.xml                           | 2 +-
 modules/jcl/pom.xml                                | 2 +-
 modules/jms11/pom.xml                              | 5 ++---
 modules/jta/pom.xml                                | 2 +-
 modules/kafka/pom.xml                              | 2 +-
 modules/log4j/pom.xml                              | 2 +-
 modules/log4j2/pom.xml                             | 2 +-
 modules/mesos/pom.xml                              | 2 +-
 modules/platform/pom.xml                           | 2 +-
 modules/rest-http/pom.xml                          | 2 +-
 modules/scalar-2.10/pom.xml                        | 2 +-
 modules/scalar/pom.xml                             | 2 +-
 modules/schedule/pom.xml                           | 2 +-
 modules/schema-import/pom.xml                      | 2 +-
 modules/slf4j/pom.xml                              | 2 +-
 modules/spark-2.10/pom.xml                         | 2 +-
 modules/spark/pom.xml                              | 2 +-
 modules/spring/pom.xml                             | 2 +-
 modules/ssh/pom.xml                                | 2 +-
 modules/tools/pom.xml                              | 2 +-
 modules/urideploy/pom.xml                          | 2 +-
 modules/visor-console-2.10/pom.xml                 | 2 +-
 modules/visor-console/pom.xml                      | 2 +-
 modules/visor-plugins/pom.xml                      | 2 +-
 modules/web/pom.xml                                | 2 +-
 modules/yardstick/pom.xml                          | 2 +-
 modules/yarn/pom.xml                               | 2 +-
 modules/zookeeper/pom.xml                          | 2 +-
 pom.xml                                            | 2 +-
 45 files changed, 47 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index a2ac452..e4ec73a 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>ignite-examples</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/aop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aop/pom.xml b/modules/aop/pom.xml
index a080b57..bb419fa 100644
--- a/modules/aop/pom.xml
+++ b/modules/aop/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-aop</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/apache-license-gen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/apache-license-gen/pom.xml b/modules/apache-license-gen/pom.xml
index 2d15ad4..fa6a1e2 100644
--- a/modules/apache-license-gen/pom.xml
+++ b/modules/apache-license-gen/pom.xml
@@ -20,8 +20,7 @@
 <!--
     POM file.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -32,7 +31,7 @@
 
     <groupId>org.apache.ignite</groupId>
     <artifactId>ignite-apache-license-gen</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <build>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/aws/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aws/pom.xml b/modules/aws/pom.xml
index 63d454d..8042d33 100644
--- a/modules/aws/pom.xml
+++ b/modules/aws/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-aws</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/clients/pom.xml
----------------------------------------------------------------------
diff --git a/modules/clients/pom.xml b/modules/clients/pom.xml
index 303a274..fe8666b 100644
--- a/modules/clients/pom.xml
+++ b/modules/clients/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-clients</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/cloud/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cloud/pom.xml b/modules/cloud/pom.xml
index e735804..a49625d 100644
--- a/modules/cloud/pom.xml
+++ b/modules/cloud/pom.xml
@@ -29,7 +29,7 @@
     </parent>
 
     <artifactId>ignite-cloud</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/codegen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/codegen/pom.xml b/modules/codegen/pom.xml
index a39da2f..957049b 100644
--- a/modules/codegen/pom.xml
+++ b/modules/codegen/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-codegen</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 57abba0..e02bb23 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-core</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <repositories>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/core/src/main/resources/ignite.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/ignite.properties b/modules/core/src/main/resources/ignite.properties
index c1c2d0f..2cf7d15 100644
--- a/modules/core/src/main/resources/ignite.properties
+++ b/modules/core/src/main/resources/ignite.properties
@@ -15,7 +15,7 @@
 # limitations under the License.
 #
 
-ignite.version=1.4.1-SNAPSHOT
+ignite.version=1.5.0-SNAPSHOT
 ignite.build=0
 ignite.revision=DEV
 ignite.rel.date=01011970

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/extdata/p2p/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/pom.xml b/modules/extdata/p2p/pom.xml
index b48859b..26d1cd2 100644
--- a/modules/extdata/p2p/pom.xml
+++ b/modules/extdata/p2p/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-extdata-p2p</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/extdata/uri/modules/uri-dependency/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/uri/modules/uri-dependency/pom.xml b/modules/extdata/uri/modules/uri-dependency/pom.xml
index f863bed..08edb5b 100644
--- a/modules/extdata/uri/modules/uri-dependency/pom.xml
+++ b/modules/extdata/uri/modules/uri-dependency/pom.xml
@@ -27,7 +27,7 @@
     <artifactId>ignite-extdata-uri-dep</artifactId>
     <packaging>jar</packaging>
 
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <modelVersion>4.0.0</modelVersion>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/extdata/uri/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/uri/pom.xml b/modules/extdata/uri/pom.xml
index 0b4f92f..d9a9297 100644
--- a/modules/extdata/uri/pom.xml
+++ b/modules/extdata/uri/pom.xml
@@ -32,7 +32,7 @@
     </parent>
 
     <artifactId>ignite-extdata-uri</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/gce/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gce/pom.xml b/modules/gce/pom.xml
index b3fbb32..1f8de08 100644
--- a/modules/gce/pom.xml
+++ b/modules/gce/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-gce</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/geospatial/pom.xml
----------------------------------------------------------------------
diff --git a/modules/geospatial/pom.xml b/modules/geospatial/pom.xml
index 1330cf5..39ebdc4 100644
--- a/modules/geospatial/pom.xml
+++ b/modules/geospatial/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-geospatial</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hadoop/pom.xml b/modules/hadoop/pom.xml
index 9fdfd99..c2cb89b 100644
--- a/modules/hadoop/pom.xml
+++ b/modules/hadoop/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-hadoop</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/hibernate/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/pom.xml b/modules/hibernate/pom.xml
index 2d6d893..8a04ab7 100644
--- a/modules/hibernate/pom.xml
+++ b/modules/hibernate/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-hibernate</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/indexing/pom.xml
----------------------------------------------------------------------
diff --git a/modules/indexing/pom.xml b/modules/indexing/pom.xml
index 4bcadc8..d539f6b 100644
--- a/modules/indexing/pom.xml
+++ b/modules/indexing/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-indexing</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/jcl/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jcl/pom.xml b/modules/jcl/pom.xml
index 0b2c48b..c94c906 100644
--- a/modules/jcl/pom.xml
+++ b/modules/jcl/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-jcl</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/jms11/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jms11/pom.xml b/modules/jms11/pom.xml
index ff80007..47a1495 100644
--- a/modules/jms11/pom.xml
+++ b/modules/jms11/pom.xml
@@ -20,8 +20,7 @@
 <!--
     POM file.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -32,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-jms11</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/jta/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jta/pom.xml b/modules/jta/pom.xml
index 7965dd9..78242e7 100644
--- a/modules/jta/pom.xml
+++ b/modules/jta/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-jta</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/kafka/pom.xml
----------------------------------------------------------------------
diff --git a/modules/kafka/pom.xml b/modules/kafka/pom.xml
index ed192ab..89c1550 100644
--- a/modules/kafka/pom.xml
+++ b/modules/kafka/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-kafka</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/log4j/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j/pom.xml b/modules/log4j/pom.xml
index c3c4a84..fe95700 100644
--- a/modules/log4j/pom.xml
+++ b/modules/log4j/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-log4j</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/log4j2/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j2/pom.xml b/modules/log4j2/pom.xml
index 0628b47..eca3b75 100644
--- a/modules/log4j2/pom.xml
+++ b/modules/log4j2/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-log4j2</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/mesos/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mesos/pom.xml b/modules/mesos/pom.xml
index 07bd13d..466805c 100644
--- a/modules/mesos/pom.xml
+++ b/modules/mesos/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-mesos</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/platform/pom.xml
----------------------------------------------------------------------
diff --git a/modules/platform/pom.xml b/modules/platform/pom.xml
index 4bff370..56e1821 100644
--- a/modules/platform/pom.xml
+++ b/modules/platform/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-platform</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/rest-http/pom.xml
----------------------------------------------------------------------
diff --git a/modules/rest-http/pom.xml b/modules/rest-http/pom.xml
index 8156887..58eb1ed 100644
--- a/modules/rest-http/pom.xml
+++ b/modules/rest-http/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-rest-http</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/scalar-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/scalar-2.10/pom.xml b/modules/scalar-2.10/pom.xml
index 42fb9b9..c2046e9 100644
--- a/modules/scalar-2.10/pom.xml
+++ b/modules/scalar-2.10/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-scalar_2.10</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/scalar/pom.xml
----------------------------------------------------------------------
diff --git a/modules/scalar/pom.xml b/modules/scalar/pom.xml
index 982fcaf..1443cc1 100644
--- a/modules/scalar/pom.xml
+++ b/modules/scalar/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-scalar</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/schedule/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schedule/pom.xml b/modules/schedule/pom.xml
index e64059a..3f53df6 100644
--- a/modules/schedule/pom.xml
+++ b/modules/schedule/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-schedule</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import/pom.xml b/modules/schema-import/pom.xml
index 0ba8597..1e63cae 100644
--- a/modules/schema-import/pom.xml
+++ b/modules/schema-import/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-schema-import</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/slf4j/pom.xml
----------------------------------------------------------------------
diff --git a/modules/slf4j/pom.xml b/modules/slf4j/pom.xml
index 5cdf791..b22ae6c 100644
--- a/modules/slf4j/pom.xml
+++ b/modules/slf4j/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-slf4j</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/spark-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spark-2.10/pom.xml b/modules/spark-2.10/pom.xml
index 6c44006..316b13b 100644
--- a/modules/spark-2.10/pom.xml
+++ b/modules/spark-2.10/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-spark_2.10</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/spark/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spark/pom.xml b/modules/spark/pom.xml
index 1fb2753..95e05d8 100644
--- a/modules/spark/pom.xml
+++ b/modules/spark/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-spark</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/spring/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spring/pom.xml b/modules/spring/pom.xml
index 4ed1fd7..8d1f918 100644
--- a/modules/spring/pom.xml
+++ b/modules/spring/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-spring</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/ssh/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ssh/pom.xml b/modules/ssh/pom.xml
index 7922f53..ff3e70d 100644
--- a/modules/ssh/pom.xml
+++ b/modules/ssh/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-ssh</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/tools/pom.xml
----------------------------------------------------------------------
diff --git a/modules/tools/pom.xml b/modules/tools/pom.xml
index 5e3465e..26689760 100644
--- a/modules/tools/pom.xml
+++ b/modules/tools/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-tools</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/urideploy/pom.xml
----------------------------------------------------------------------
diff --git a/modules/urideploy/pom.xml b/modules/urideploy/pom.xml
index 7dd0431..c8fac6e 100644
--- a/modules/urideploy/pom.xml
+++ b/modules/urideploy/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-urideploy</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/visor-console-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console-2.10/pom.xml b/modules/visor-console-2.10/pom.xml
index a0edeaf..73c7a58 100644
--- a/modules/visor-console-2.10/pom.xml
+++ b/modules/visor-console-2.10/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-visor-console_2.10</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/visor-console/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console/pom.xml b/modules/visor-console/pom.xml
index d6f373a..b85cd69 100644
--- a/modules/visor-console/pom.xml
+++ b/modules/visor-console/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-visor-console</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/visor-plugins/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-plugins/pom.xml b/modules/visor-plugins/pom.xml
index 04142fa..05b4ede 100644
--- a/modules/visor-plugins/pom.xml
+++ b/modules/visor-plugins/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-visor-plugins</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/web/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web/pom.xml b/modules/web/pom.xml
index 4432d81..99a356e 100644
--- a/modules/web/pom.xml
+++ b/modules/web/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-web</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index 3f3774a..2f0c5fe 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-yardstick</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/yarn/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yarn/pom.xml b/modules/yarn/pom.xml
index 079a173..2b758dc 100644
--- a/modules/yarn/pom.xml
+++ b/modules/yarn/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-yarn</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/modules/zookeeper/pom.xml
----------------------------------------------------------------------
diff --git a/modules/zookeeper/pom.xml b/modules/zookeeper/pom.xml
index ba10101..9f5bc42 100644
--- a/modules/zookeeper/pom.xml
+++ b/modules/zookeeper/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-zookeeper</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <url>http://ignite.apache.org</url>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ignite/blob/fe1caa62/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 96305a3..a380d13 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
 
     <groupId>org.apache.ignite</groupId>
     <artifactId>apache-ignite</artifactId>
-    <version>1.4.1-SNAPSHOT</version>
+    <version>1.5.0-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <properties>


[27/50] [abbrv] ignite git commit: Topology validator test and javadoc improvement (cherry picked from commit 2fbf328)

Posted by ak...@apache.org.
Topology validator test and javadoc improvement
(cherry picked from commit 2fbf328)


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

Branch: refs/heads/ignite-843
Commit: b1a9771ad992d5810fbe3de79d39ab07ddd51949
Parents: fe1caa6
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Sep 3 18:34:38 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Sep 3 18:41:54 2015 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       | 45 +++++++++++++++++++
 .../ignite/configuration/TopologyValidator.java |  4 +-
 ...gniteTopologyValidatorAbstractCacheTest.java | 46 ++++++++++++++++----
 3 files changed, 85 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b1a9771a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 792bb28..1bbc110 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -20,12 +20,14 @@ package org.apache.ignite.configuration;
 import java.io.Serializable;
 import java.util.Collection;
 import javax.cache.Cache;
+import javax.cache.CacheException;
 import javax.cache.configuration.CompleteConfiguration;
 import javax.cache.configuration.Factory;
 import javax.cache.configuration.MutableConfiguration;
 import javax.cache.expiry.ExpiryPolicy;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheEntryProcessor;
@@ -1788,6 +1790,27 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
 
     /**
      * Gets topology validator.
+     * <p>
+     * Topology validator checks whether the new topology is valid for specific cache at each topology change.
+     * Topology is always valid in case no topology validator used.
+     * <p>
+     * In case topology is valid for specific cache all operations on this cache are allowed.
+     * <p>
+     * In case topology is not valid for specific cache all update operations on this cache are restricted:
+     * <p>{@link CacheException} will be thrown at update operations (put, remove, etc) attempt.
+     * <p>{@link IgniteException} will be thrown at transaction commit attempt.
+     *
+     * <p>
+     * Usage example
+     * <p>
+     * Following validator allows to put data only in case topology contains exactly 2 nodes:
+     * <pre>{@code
+     * new TopologyValidator() {
+     *    @Override public boolean validate(Collection<ClusterNode> nodes) {
+     *       return nodes.size() == 2;
+     *    }
+     * }
+     * }</pre>
      * @return validator.
      */
     public TopologyValidator getTopologyValidator() {
@@ -1796,6 +1819,28 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
 
     /**
      * Sets topology validator.
+     * <p>
+     * Topology validator checks whether the new topology is valid for specific cache at each topology change.
+     * Topology is always valid in case no topology validator used.
+     * <p>
+     * In case topology is valid for specific cache all operations on this cache are allowed.
+     * <p>
+     * In case topology is not valid for specific cache all update operations on this cache are restricted:
+     * <p>{@link CacheException} will be thrown at update operations (put, remove, etc) attempt.
+     * <p>{@link IgniteException} will be thrown at transaction commit attempt.
+     *
+     * <p>
+     * Usage example
+     * <p>
+     * Following validator allows to put data only in case topology contains exactly 2 nodes:
+     * <pre>{@code
+     * new TopologyValidator() {
+     *    @Override public boolean validate(Collection<ClusterNode> nodes) {
+     *       return nodes.size() == 2;
+     *    }
+     * }
+     * }</pre>
+     *
      * @param topValidator validator.
      * @return {@code this} for chaining.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b1a9771a/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java b/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
index ef9284d..49c06a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
@@ -27,8 +27,8 @@ import org.apache.ignite.cluster.ClusterNode;
 public interface TopologyValidator extends Serializable {
     /**
      * Validates topology.
-     * @param nodes nodes collection to be validated.
-     * @return is topology valid or not.
+     * @param nodes Collection of nodes.
+     * @return {@code true} in case topology is valid for specific cache, otherwise {@code false}
      */
     boolean validate(Collection<ClusterNode> nodes);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/b1a9771a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
index deb1fee..65f4694 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
@@ -86,13 +86,11 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
      */
     protected void putInvalid(String cacheName) {
         try {
-            assert grid(0).cache(cacheName).get(KEY_VALUE) == null;
-
             grid(0).cache(cacheName).put(KEY_VALUE, KEY_VALUE);
 
             assert false : "topology validation broken";
         }
-        catch (IgniteException | CacheException ex) {
+        catch (CacheException ex) {
             assert ex.getCause() instanceof IgniteCheckedException &&
                 ex.getCause().getMessage().contains("cache topology is not valid");
         }
@@ -105,18 +103,47 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
      */
     protected void putValid(String cacheName) {
         try {
-            assert grid(0).cache(cacheName).get(KEY_VALUE) == null;
-
             grid(0).cache(cacheName).put(KEY_VALUE, KEY_VALUE);
 
             assert grid(0).cache(cacheName).get(KEY_VALUE).equals(KEY_VALUE);
         }
-        catch (IgniteException | CacheException ex) {
+        catch (CacheException ex) {
+            assert false : "topology validation broken";
+        }
+    }
+
+    /**
+     * Gets when topology is invalid.
+     *
+     * @param cacheName cache name.
+     */
+    protected void getInvalid(String cacheName) {
+        try {
+            assert grid(0).cache(cacheName).get(KEY_VALUE).equals(KEY_VALUE);
+        }
+        catch (CacheException ex) {
             assert false : "topology validation broken";
         }
     }
 
     /**
+     * Remove when topology is invalid.
+     *
+     * @param cacheName cache name.
+     */
+    protected void removeInvalid(String cacheName) {
+        try {
+            grid(0).cache(cacheName).remove(KEY_VALUE);
+
+            assert false : "topology validation broken";
+        }
+        catch (CacheException ex) {
+            assert ex.getCause() instanceof IgniteCheckedException &&
+                ex.getCause().getMessage().contains("cache topology is not valid");
+        }
+    }
+
+    /**
      * Commits with error.
      *
      * @param tx transaction.
@@ -125,7 +152,7 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
         try {
             tx.commit();
         }
-        catch (IgniteException | CacheException ex) {
+        catch (IgniteException ex) {
             assert ex.getCause() instanceof IgniteCheckedException &&
                 ex.getCause().getMessage().contains("cache topology is not valid");
         }
@@ -158,8 +185,10 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
         remove(null);
 
         putInvalid(CACHE_NAME_1);
+        removeInvalid(CACHE_NAME_1);
 
         putInvalid(CACHE_NAME_2);
+        removeInvalid(CACHE_NAME_2);
 
         startGrid(1);
 
@@ -167,7 +196,6 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
         remove(null);
 
         putValid(CACHE_NAME_1);
-        remove(CACHE_NAME_1);
 
         putValid(CACHE_NAME_2);
         remove(CACHE_NAME_2);
@@ -177,7 +205,9 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
         putValid(null);
         remove(null);
 
+        getInvalid(CACHE_NAME_1);
         putInvalid(CACHE_NAME_1);
+        removeInvalid(CACHE_NAME_1);
 
         putValid(CACHE_NAME_2);
         remove(CACHE_NAME_2);


[13/50] [abbrv] ignite git commit: Merge branch 'ignite-1.4' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-1.4

Posted by ak...@apache.org.
Merge branch 'ignite-1.4' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-1.4


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

Branch: refs/heads/ignite-843
Commit: 3a280a0e552c6f474b3112ad74cfa7f9ec9e7c21
Parents: 9057a4c b847148
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Sep 3 09:08:12 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Sep 3 09:08:12 2015 +0300

----------------------------------------------------------------------
 modules/aop/pom.xml                             |   1 +
 modules/apache-license-gen/pom.xml              |   1 +
 modules/aws/pom.xml                             |   1 +
 modules/clients/pom.xml                         |   1 +
 modules/cloud/pom.xml                           |   1 +
 modules/codegen/pom.xml                         |   1 +
 modules/core/pom.xml                            |   1 +
 .../GridCacheLoaderWriterStoreFactory.java      |  20 +++-
 .../processors/cache/GridCacheProcessor.java    |  10 +-
 .../store/StoreResourceInjectionSelfTest.java   | 104 +++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |   4 +-
 modules/gce/pom.xml                             |   1 +
 modules/geospatial/pom.xml                      |   1 +
 modules/hadoop/pom.xml                          |   1 +
 modules/hibernate/pom.xml                       |   1 +
 modules/indexing/pom.xml                        |   1 +
 modules/jcl/pom.xml                             |   1 +
 modules/jms11/pom.xml                           |   1 +
 modules/jta/pom.xml                             |   1 +
 modules/kafka/pom.xml                           |   1 +
 modules/log4j/pom.xml                           |   1 +
 modules/log4j2/pom.xml                          |   1 +
 modules/mesos/pom.xml                           |   1 +
 modules/platform/pom.xml                        |   1 +
 .../platform/cache/PlatformCache.java           |   2 +-
 modules/rest-http/pom.xml                       |   1 +
 modules/scalar-2.10/pom.xml                     |   1 +
 modules/scalar/pom.xml                          |   1 +
 modules/schedule/pom.xml                        |   1 +
 modules/schema-import/pom.xml                   |   1 +
 modules/slf4j/pom.xml                           |   1 +
 modules/spark-2.10/pom.xml                      |   1 +
 modules/spark/pom.xml                           |   1 +
 modules/spring/pom.xml                          |   1 +
 modules/ssh/pom.xml                             |   1 +
 modules/tools/pom.xml                           |   1 +
 modules/urideploy/pom.xml                       |   1 +
 modules/visor-console-2.10/pom.xml              |   1 +
 modules/visor-console/pom.xml                   |   1 +
 modules/visor-plugins/pom.xml                   |   1 +
 modules/web/pom.xml                             |   1 +
 modules/yardstick/pom.xml                       |   1 +
 modules/yarn/pom.xml                            |   1 +
 modules/zookeeper/pom.xml                       |   1 +
 parent/pom.xml                                  |   1 +
 45 files changed, 174 insertions(+), 6 deletions(-)
----------------------------------------------------------------------



[10/50] [abbrv] ignite git commit: ignite-1273: added ability to modify arrays returned from PortableBuilder and fixed cyclic references processing for arrays and collections in PortableMarshaller

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
new file mode 100644
index 0000000..45355d7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
@@ -0,0 +1,800 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableContext;
+import org.apache.ignite.internal.portable.PortableObjectImpl;
+import org.apache.ignite.internal.portable.PortablePrimitives;
+import org.apache.ignite.internal.portable.PortableReaderExImpl;
+import org.apache.ignite.internal.portable.PortableUtils;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.portable.PortableException;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
+
+/**
+ *
+ */
+class PortableBuilderReader {
+    /** */
+    private static final PortablePrimitives PRIM = PortablePrimitives.get();
+
+    /** */
+    private final Map<Integer, PortableBuilderImpl> objMap = new HashMap<>();
+
+    /** */
+    private final PortableContext ctx;
+
+    /** */
+    private final PortableReaderExImpl reader;
+
+    /** */
+    private byte[] arr;
+
+    /** */
+    private int pos;
+
+    /**
+     * @param objImpl Portable object
+     */
+    PortableBuilderReader(PortableObjectImpl objImpl) {
+        ctx = objImpl.context();
+        arr = objImpl.array();
+        pos = objImpl.start();
+
+        // TODO: IGNITE-1272 - Is class loader needed here?
+        reader = new PortableReaderExImpl(portableContext(), arr, pos, null);
+    }
+
+    /**
+     * @return Portable context.
+     */
+    public PortableContext portableContext() {
+        return ctx;
+    }
+
+    /**
+     * @param obj Mutable portable object.
+     */
+    public void registerObject(PortableBuilderImpl obj) {
+        objMap.put(obj.start(), obj);
+    }
+
+    /**
+     * @return Read int value.
+     */
+    public int readInt() {
+        int res = readInt(0);
+
+        pos += 4;
+
+        return res;
+    }
+
+    /**
+     * @return Read int value.
+     */
+    public byte readByte() {
+        return arr[pos++];
+    }
+
+    /**
+     * @return Read boolean value.
+     */
+    public boolean readBoolean() {
+        return readByte() == 1;
+    }
+
+    /**
+     * @return Read int value.
+     */
+    public byte readByte(int off) {
+        return arr[pos + off];
+    }
+
+    /**
+     * @param off Offset related to {@link #pos}
+     * @return Read int value.
+     */
+    public int readInt(int off) {
+        return PRIM.readInt(arr, pos + off);
+    }
+
+    /**
+     * @param pos Position in the source array.
+     * @return Read int value.
+     */
+    public int readIntAbsolute(int pos) {
+        return PRIM.readInt(arr, pos);
+    }
+
+    /**
+     * @return Read length of array.
+     */
+    public int readLength() {
+        return PRIM.readInt(arr, pos);
+    }
+
+    /**
+     * Read string length.
+     *
+     * @return String length.
+     */
+    public int readStringLength() {
+        boolean utf = PRIM.readBoolean(arr, pos);
+
+        int arrLen = PRIM.readInt(arr, pos + 1);
+
+        return 1 + (utf ? arrLen : arrLen << 1);
+    }
+
+    /**
+     * Reads string.
+     *
+     * @return String.
+     */
+    public String readString() {
+        byte flag = readByte();
+
+        if (flag == NULL)
+            return null;
+
+        if (flag != STRING)
+            throw new PortableException("Failed to deserialize String.");
+
+        boolean convert = readBoolean();
+        int len = readInt();
+
+        String str;
+
+        if (convert) {
+            str = new String(arr, pos, len, UTF_8);
+
+            pos += len;
+        }
+        else {
+            str = String.valueOf(PRIM.readCharArray(arr, pos, len));
+
+            pos += len << 1;
+        }
+
+        return str;
+    }
+
+    /**
+     *
+     */
+    public void skipValue() {
+        byte type = arr[pos++];
+
+        int len;
+
+        switch (type) {
+            case GridPortableMarshaller.NULL:
+                return;
+
+            case GridPortableMarshaller.OBJ:
+                pos += readInt(GridPortableMarshaller.TOTAL_LEN_POS - 1) - 1;
+
+                return;
+
+            case GridPortableMarshaller.BOOLEAN:
+            case GridPortableMarshaller.BYTE:
+                len = 1;
+                break;
+
+            case GridPortableMarshaller.CHAR:
+            case GridPortableMarshaller.SHORT:
+                len = 2;
+
+                break;
+
+            case GridPortableMarshaller.HANDLE:
+            case GridPortableMarshaller.FLOAT:
+            case GridPortableMarshaller.INT:
+                len = 4;
+
+                break;
+
+            case GridPortableMarshaller.ENUM:
+                //skipping type id and ordinal value
+                len = 8;
+
+                break;
+
+            case GridPortableMarshaller.LONG:
+            case GridPortableMarshaller.DOUBLE:
+                len = 8;
+
+                break;
+
+            case GridPortableMarshaller.BYTE_ARR:
+            case GridPortableMarshaller.BOOLEAN_ARR:
+                len = 4 + readLength();
+
+                break;
+
+            case GridPortableMarshaller.STRING:
+                len = 4 + readStringLength();
+
+                break;
+
+            case GridPortableMarshaller.DECIMAL:
+                len = /** scale */ 4  + /** mag len */ 4  + /** mag bytes count */ readInt(4);
+
+                break;
+
+            case GridPortableMarshaller.UUID:
+                len = 8 + 8;
+
+                break;
+
+            case GridPortableMarshaller.DATE:
+                len = 8 + 4;
+
+                break;
+
+            case GridPortableMarshaller.CHAR_ARR:
+            case GridPortableMarshaller.SHORT_ARR:
+                len = 4 + readLength() * 2;
+
+                break;
+
+            case GridPortableMarshaller.INT_ARR:
+            case GridPortableMarshaller.FLOAT_ARR:
+                len = 4 + readLength() * 4;
+
+                break;
+
+            case GridPortableMarshaller.LONG_ARR:
+            case GridPortableMarshaller.DOUBLE_ARR:
+                len = 4 + readLength() * 8;
+
+                break;
+
+            case GridPortableMarshaller.DECIMAL_ARR:
+            case GridPortableMarshaller.DATE_ARR:
+            case GridPortableMarshaller.OBJ_ARR:
+            case GridPortableMarshaller.ENUM_ARR:
+            case GridPortableMarshaller.UUID_ARR:
+            case GridPortableMarshaller.STRING_ARR: {
+                int size = readInt();
+
+                for (int i = 0; i < size; i++)
+                    skipValue();
+
+                return;
+            }
+
+            case GridPortableMarshaller.COL: {
+                int size = readInt();
+
+                pos++; // skip collection type
+
+                for (int i = 0; i < size; i++)
+                    skipValue();
+
+                return;
+            }
+
+            case GridPortableMarshaller.MAP: {
+                int size = readInt();
+
+                pos++; // skip collection type
+
+                for (int i = 0; i < size; i++) {
+                    skipValue(); // skip key.
+                    skipValue(); // skip value.
+                }
+
+                return;
+            }
+
+            case GridPortableMarshaller.MAP_ENTRY:
+                skipValue();
+                skipValue();
+
+                return;
+
+            case GridPortableMarshaller.PORTABLE_OBJ:
+                len = readInt() + 4;
+
+                break;
+
+            default:
+                throw new PortableException("Invalid flag value: " + type);
+        }
+
+        pos += len;
+    }
+
+    /**
+     * @param pos Position.
+     * @param len Length.
+     * @return Object.
+     */
+    public Object getValueQuickly(int pos, int len) {
+        byte type = arr[pos];
+
+        switch (type) {
+            case GridPortableMarshaller.NULL:
+                return null;
+
+            case GridPortableMarshaller.HANDLE: {
+                int objStart = pos - readIntAbsolute(pos + 1);
+
+                PortableBuilderImpl res = objMap.get(objStart);
+
+                if (res == null) {
+                    res = new PortableBuilderImpl(this, objStart);
+
+                    objMap.put(objStart, res);
+                }
+
+                return res;
+            }
+
+            case GridPortableMarshaller.OBJ: {
+                PortableBuilderImpl res = objMap.get(pos);
+
+                if (res == null) {
+                    res = new PortableBuilderImpl(this, pos);
+
+                    objMap.put(pos, res);
+                }
+
+                return res;
+            }
+
+            case GridPortableMarshaller.BYTE:
+                return arr[pos + 1];
+
+            case GridPortableMarshaller.SHORT:
+                return PRIM.readShort(arr, pos + 1);
+
+            case GridPortableMarshaller.INT:
+                return PRIM.readInt(arr, pos + 1);
+
+            case GridPortableMarshaller.LONG:
+                return PRIM.readLong(arr, pos + 1);
+
+            case GridPortableMarshaller.FLOAT:
+                return PRIM.readFloat(arr, pos + 1);
+
+            case GridPortableMarshaller.DOUBLE:
+                return PRIM.readDouble(arr, pos + 1);
+
+            case GridPortableMarshaller.CHAR:
+                return PRIM.readChar(arr, pos + 1);
+
+            case GridPortableMarshaller.BOOLEAN:
+                return arr[pos + 1] != 0;
+
+            case GridPortableMarshaller.DECIMAL:
+            case GridPortableMarshaller.STRING:
+            case GridPortableMarshaller.UUID:
+            case GridPortableMarshaller.DATE:
+                return new PortablePlainLazyValue(this, pos, len);
+
+            case GridPortableMarshaller.BYTE_ARR:
+            case GridPortableMarshaller.SHORT_ARR:
+            case GridPortableMarshaller.INT_ARR:
+            case GridPortableMarshaller.LONG_ARR:
+            case GridPortableMarshaller.FLOAT_ARR:
+            case GridPortableMarshaller.DOUBLE_ARR:
+            case GridPortableMarshaller.CHAR_ARR:
+            case GridPortableMarshaller.BOOLEAN_ARR:
+            case GridPortableMarshaller.DECIMAL_ARR:
+            case GridPortableMarshaller.DATE_ARR:
+            case GridPortableMarshaller.UUID_ARR:
+            case GridPortableMarshaller.STRING_ARR:
+            case GridPortableMarshaller.ENUM_ARR:
+            case GridPortableMarshaller.OBJ_ARR:
+            case GridPortableMarshaller.COL:
+            case GridPortableMarshaller.MAP:
+            case GridPortableMarshaller.MAP_ENTRY:
+                return new LazyCollection(pos);
+
+            case GridPortableMarshaller.ENUM: {
+                if (len == 1) {
+                    assert readByte(pos) == GridPortableMarshaller.NULL;
+
+                    return null;
+                }
+
+                int mark = position();
+                position(pos + 1);
+
+                PortableBuilderEnum builderEnum = new PortableBuilderEnum(this);
+
+                position(mark);
+
+                return builderEnum;
+            }
+
+            case GridPortableMarshaller.PORTABLE_OBJ: {
+                int size = readIntAbsolute(pos + 1);
+
+                int start = readIntAbsolute(pos + 4 + size);
+
+                PortableObjectImpl portableObj = new PortableObjectImpl(ctx, arr, pos + 4 + start);
+
+                return new PortablePlainPortableObject(portableObj);
+            }
+
+            default:
+                throw new PortableException("Invalid flag value: " + type);
+        }
+    }
+
+    /**
+     * @return Parsed value.
+     */
+    public Object parseValue() {
+        int valPos = pos;
+
+        byte type = arr[pos++];
+
+        int plainLazyValLen;
+
+        boolean modifiableLazyVal = false;
+
+        switch (type) {
+            case GridPortableMarshaller.NULL:
+                return null;
+
+            case GridPortableMarshaller.HANDLE: {
+                int objStart = pos - 1 - readInt();
+
+                PortableBuilderImpl res = objMap.get(objStart);
+
+                if (res == null) {
+                    res = new PortableBuilderImpl(this, objStart);
+
+                    objMap.put(objStart, res);
+                }
+
+                return res;
+            }
+
+            case GridPortableMarshaller.OBJ: {
+                pos--;
+
+                PortableBuilderImpl res = objMap.get(pos);
+
+                if (res == null) {
+                    res = new PortableBuilderImpl(this, pos);
+
+                    objMap.put(pos, res);
+                }
+
+                pos += readInt(GridPortableMarshaller.TOTAL_LEN_POS);
+
+                return res;
+            }
+
+            case GridPortableMarshaller.BYTE:
+                return arr[pos++];
+
+            case GridPortableMarshaller.SHORT: {
+                Object res = PRIM.readShort(arr, pos);
+                pos += 2;
+                return res;
+            }
+
+            case GridPortableMarshaller.INT:
+                return readInt();
+
+            case GridPortableMarshaller.LONG:
+                plainLazyValLen = 8;
+
+                break;
+
+            case GridPortableMarshaller.FLOAT:
+                plainLazyValLen = 4;
+
+                break;
+
+            case GridPortableMarshaller.DOUBLE:
+                plainLazyValLen = 8;
+
+                break;
+
+            case GridPortableMarshaller.CHAR:
+                plainLazyValLen = 2;
+
+                break;
+
+            case GridPortableMarshaller.BOOLEAN:
+                return arr[pos++] != 0;
+
+            case GridPortableMarshaller.DECIMAL:
+                plainLazyValLen = /** scale */ 4  + /** mag len */ 4  + /** mag bytes count */ readInt(4);
+
+                break;
+
+            case GridPortableMarshaller.STRING:
+                plainLazyValLen = 4 + readStringLength();
+
+                break;
+
+            case GridPortableMarshaller.UUID:
+                plainLazyValLen = 8 + 8;
+
+                break;
+
+            case GridPortableMarshaller.DATE:
+                plainLazyValLen = 8 + 4;
+
+                break;
+
+            case GridPortableMarshaller.BYTE_ARR:
+                plainLazyValLen = 4 + readLength();
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.SHORT_ARR:
+                plainLazyValLen = 4 + readLength() * 2;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.INT_ARR:
+                plainLazyValLen = 4 + readLength() * 4;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.LONG_ARR:
+                plainLazyValLen = 4 + readLength() * 8;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.FLOAT_ARR:
+                plainLazyValLen = 4 + readLength() * 4;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.DOUBLE_ARR:
+                plainLazyValLen = 4 + readLength() * 8;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.CHAR_ARR:
+                plainLazyValLen = 4 + readLength() * 2;
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.BOOLEAN_ARR:
+                plainLazyValLen = 4 + readLength();
+                modifiableLazyVal = true;
+
+                break;
+
+            case GridPortableMarshaller.OBJ_ARR:
+                return new PortableObjectArrayLazyValue(this);
+
+            case GridPortableMarshaller.DATE_ARR: {
+                int size = readInt();
+
+                Date[] res = new Date[size];
+
+                for (int i = 0; i < res.length; i++) {
+                    byte flag = arr[pos++];
+
+                    if (flag == GridPortableMarshaller.NULL) continue;
+
+                    if (flag != GridPortableMarshaller.DATE)
+                        throw new PortableException("Invalid flag value: " + flag);
+
+                    long time = PRIM.readLong(arr, pos);
+
+                    pos += 8;
+
+                    if (ctx.isUseTimestamp()) {
+                        Timestamp ts = new Timestamp(time);
+
+                        ts.setNanos(ts.getNanos() + readInt());
+
+                        res[i] = ts;
+                    }
+                    else {
+                        res[i] = new Date(time);
+
+                        pos += 4;
+                    }
+                }
+
+                return res;
+            }
+
+            case GridPortableMarshaller.UUID_ARR:
+            case GridPortableMarshaller.STRING_ARR:
+            case GridPortableMarshaller.DECIMAL_ARR: {
+                int size = readInt();
+
+                for (int i = 0; i < size; i++) {
+                    byte flag = arr[pos++];
+
+                    if (flag == GridPortableMarshaller.UUID)
+                        pos += 8 + 8;
+                    else if (flag == GridPortableMarshaller.STRING)
+                        pos += 4 + readStringLength();
+                    else if (flag == GridPortableMarshaller.DECIMAL) {
+                        pos += 4; // scale value
+                        pos += 4 + readLength();
+                    }
+                    else
+                        assert flag == GridPortableMarshaller.NULL;
+                }
+
+                return new PortableModifiableLazyValue(this, valPos, pos - valPos);
+            }
+
+            case GridPortableMarshaller.COL: {
+                int size = readInt();
+                byte colType = arr[pos++];
+
+                switch (colType) {
+                    case GridPortableMarshaller.USER_COL:
+                    case GridPortableMarshaller.ARR_LIST:
+                        return new PortableLazyArrayList(this, size);
+
+                    case GridPortableMarshaller.LINKED_LIST:
+                        return new PortableLazyLinkedList(this, size);
+
+                    case GridPortableMarshaller.HASH_SET:
+                    case GridPortableMarshaller.LINKED_HASH_SET:
+                    case GridPortableMarshaller.TREE_SET:
+                    case GridPortableMarshaller.CONC_SKIP_LIST_SET:
+                        return new PortableLazySet(this, size);
+                }
+
+                throw new PortableException("Unknown collection type: " + colType);
+            }
+
+            case GridPortableMarshaller.MAP:
+                return PortableLazyMap.parseMap(this);
+
+            case GridPortableMarshaller.ENUM:
+                return new PortableBuilderEnum(this);
+
+            case GridPortableMarshaller.ENUM_ARR:
+                return new PortableEnumArrayLazyValue(this);
+
+            case GridPortableMarshaller.MAP_ENTRY:
+                return new PortableLazyMapEntry(this);
+
+            case GridPortableMarshaller.PORTABLE_OBJ: {
+                int size = readInt();
+
+                pos += size;
+
+                int start = readInt();
+
+                PortableObjectImpl portableObj = new PortableObjectImpl(ctx, arr,
+                    pos - 4 - size + start);
+
+                return new PortablePlainPortableObject(portableObj);
+            }
+
+
+            default:
+                throw new PortableException("Invalid flag value: " + type);
+        }
+
+        PortableAbstractLazyValue res;
+
+        if (modifiableLazyVal)
+            res = new PortableModifiableLazyValue(this, valPos, 1 + plainLazyValLen);
+        else
+            res = new PortablePlainLazyValue(this, valPos, 1 + plainLazyValLen);
+
+        pos += plainLazyValLen;
+
+        return res;
+    }
+
+    /**
+     * @return Array.
+     */
+    public byte[] array() {
+        return arr;
+    }
+
+    /**
+     * @return Position of reader.
+     */
+    public int position() {
+        return pos;
+    }
+
+    /**
+     * @param pos New pos.
+     */
+    public void position(int pos) {
+        this.pos = pos;
+    }
+
+    /**
+     * @param n Number of bytes to skip.
+     */
+    public void skip(int n) {
+        pos += n;
+    }
+
+    /**
+     * @return Reader.
+     */
+    PortableReaderExImpl reader() {
+        return reader;
+    }
+
+    /**
+     *
+     */
+    private class LazyCollection implements PortableLazyValue {
+        /** */
+        private final int valOff;
+
+        /** */
+        private Object col;
+
+        /**
+         * @param valOff Value.
+         */
+        protected LazyCollection(int valOff) {
+            this.valOff = valOff;
+        }
+
+        /**
+         * @return Object.
+         */
+        private Object wrappedCollection() {
+            if (col == null) {
+                position(valOff);
+
+                col = parseValue();
+            }
+
+            return col;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+            ctx.writeValue(writer, wrappedCollection());
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object value() {
+            return PortableUtils.unwrapLazy(wrappedCollection());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializationAware.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializationAware.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializationAware.java
new file mode 100644
index 0000000..976059a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializationAware.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ *
+ */
+interface PortableBuilderSerializationAware {
+    /**
+     * @param writer Writer.
+     * @param ctx Context.
+     */
+    public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java
new file mode 100644
index 0000000..2d9c961
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableObjectEx;
+import org.apache.ignite.internal.portable.PortableUtils;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.portable.*;
+
+import java.util.*;
+
+/**
+ *
+ */
+class PortableBuilderSerializer {
+    /** */
+    private final Map<PortableBuilderImpl, Integer> objToPos = new IdentityHashMap<>();
+
+    /** */
+    private Map<PortableObject, PortableBuilderImpl> portableObjToWrapper;
+
+    /**
+     * @param obj Mutable object.
+     * @param posInResArr Object position in the array.
+     */
+    public void registerObjectWriting(PortableBuilderImpl obj, int posInResArr) {
+        objToPos.put(obj, posInResArr);
+    }
+
+    /**
+     * @param writer Writer.
+     * @param val Value.
+     */
+    public void writeValue(PortableWriterExImpl writer, Object val) {
+        if (val == null) {
+            writer.writeByte(GridPortableMarshaller.NULL);
+
+            return;
+        }
+
+        if (val instanceof PortableBuilderSerializationAware) {
+            ((PortableBuilderSerializationAware)val).writeTo(writer, this);
+
+            return;
+        }
+
+        if (val instanceof PortableObjectEx) {
+            if (portableObjToWrapper == null)
+                portableObjToWrapper = new IdentityHashMap<>();
+
+            PortableBuilderImpl wrapper = portableObjToWrapper.get(val);
+
+            if (wrapper == null) {
+                wrapper = PortableBuilderImpl.wrap((PortableObject)val);
+
+                portableObjToWrapper.put((PortableObject)val, wrapper);
+            }
+
+            val = wrapper;
+        }
+
+        if (val instanceof PortableBuilderImpl) {
+            PortableBuilderImpl obj = (PortableBuilderImpl)val;
+
+            Integer posInResArr = objToPos.get(obj);
+
+            if (posInResArr == null) {
+                objToPos.put(obj, writer.outputStream().position());
+
+                obj.serializeTo(writer.newWriter(obj.typeId()), this);
+            }
+            else {
+                int handle = writer.outputStream().position() - posInResArr;
+
+                writer.writeByte(GridPortableMarshaller.HANDLE);
+                writer.writeInt(handle);
+            }
+
+            return;
+        }
+
+        if (val.getClass().isEnum()) {
+            writer.writeByte(GridPortableMarshaller.ENUM);
+            writer.writeInt(writer.context().typeId(val.getClass().getName()));
+            writer.writeInt(((Enum)val).ordinal());
+
+            return;
+        }
+
+        if (val instanceof Collection) {
+            Collection<?> c = (Collection<?>)val;
+
+            writer.writeByte(GridPortableMarshaller.COL);
+            writer.writeInt(c.size());
+
+            byte colType;
+
+            if (c instanceof GridConcurrentSkipListSet)
+                colType = GridPortableMarshaller.CONC_SKIP_LIST_SET;
+            else
+                colType = writer.context().collectionType(c.getClass());
+
+
+            writer.writeByte(colType);
+
+            for (Object obj : c)
+                writeValue(writer, obj);
+
+            return;
+        }
+
+        if (val instanceof Map) {
+            Map<?, ?> map = (Map<?, ?>)val;
+
+            writer.writeByte(GridPortableMarshaller.MAP);
+            writer.writeInt(map.size());
+
+            writer.writeByte(writer.context().mapType(map.getClass()));
+
+            for (Map.Entry<?, ?> entry : map.entrySet()) {
+                writeValue(writer, entry.getKey());
+                writeValue(writer, entry.getValue());
+            }
+
+            return;
+        }
+
+        Byte flag = PortableUtils.PLAIN_CLASS_TO_FLAG.get(val.getClass());
+
+        if (flag != null) {
+            PortableUtils.writePlainObject(writer, val);
+
+            return;
+        }
+
+        if (val instanceof Object[]) {
+            int compTypeId = writer.context().typeId(((Object[])val).getClass().getComponentType().getName());
+
+            if (val instanceof PortableBuilderEnum[]) {
+                writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, compTypeId);
+
+                return;
+            }
+
+            if (((Object[])val).getClass().getComponentType().isEnum()) {
+                Enum[] enumArr = (Enum[])val;
+
+                writer.writeByte(GridPortableMarshaller.ENUM_ARR);
+                writer.writeInt(compTypeId);
+                writer.writeInt(enumArr.length);
+
+                for (Enum anEnum : enumArr)
+                    writeValue(writer, anEnum);
+
+                return;
+            }
+
+            writeArray(writer, GridPortableMarshaller.OBJ_ARR, (Object[])val, compTypeId);
+
+            return;
+        }
+
+        writer.doWriteObject(val, false);
+    }
+
+    /**
+     * @param writer Writer.
+     * @param elementType Element type.
+     * @param arr The array.
+     * @param compTypeId Component type ID.
+     */
+    public void writeArray(PortableWriterExImpl writer, byte elementType, Object[] arr, int compTypeId) {
+        writer.writeByte(elementType);
+        writer.writeInt(compTypeId);
+        writer.writeInt(arr.length);
+
+        for (Object obj : arr)
+            writeValue(writer, obj);
+    }
+
+    /**
+     * @param writer Writer.
+     * @param elementType Element type.
+     * @param arr The array.
+     * @param clsName Component class name.
+     */
+    public void writeArray(PortableWriterExImpl writer, byte elementType, Object[] arr, String clsName) {
+        writer.writeByte(elementType);
+        writer.writeInt(GridPortableMarshaller.UNREGISTERED_TYPE_ID);
+        writer.writeString(clsName);
+        writer.writeInt(arr.length);
+
+        for (Object obj : arr)
+            writeValue(writer, obj);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java
new file mode 100644
index 0000000..d864a6e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableInvalidClassException;
+
+/**
+ *
+ */
+class PortableEnumArrayLazyValue extends PortableAbstractLazyValue {
+    /** */
+    private final int len;
+
+    /** */
+    private final int compTypeId;
+
+    /** */
+    private final String clsName;
+
+    /**
+     * @param reader Reader.
+     */
+    protected PortableEnumArrayLazyValue(PortableBuilderReader reader) {
+        super(reader, reader.position() - 1);
+
+        int typeId = reader.readInt();
+
+        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
+            clsName = reader.readString();
+
+            Class cls;
+
+            try {
+                // TODO: IGNITE-1272 - Is class loader needed here?
+                cls = U.forName(reader.readString(), null);
+            }
+            catch (ClassNotFoundException e) {
+                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
+            }
+
+            compTypeId = reader.portableContext().descriptorForClass(cls).typeId();
+        }
+        else {
+            compTypeId = typeId;
+            clsName = null;
+        }
+
+        int size = reader.readInt();
+
+        for (int i = 0; i < size; i++)
+            reader.skipValue();
+
+        len = reader.position() - valOff;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object init() {
+        reader.position(valOff + 1);
+
+        //skipping component type id
+        reader.readInt();
+
+        int size = reader.readInt();
+
+        PortableBuilderEnum[] res = new PortableBuilderEnum[size];
+
+        for (int i = 0; i < size; i++) {
+            byte flag = reader.readByte();
+
+            if (flag == GridPortableMarshaller.NULL)
+                continue;
+
+            if (flag != GridPortableMarshaller.ENUM)
+                throw new PortableException("Invalid flag value: " + flag);
+
+            res[i] = new PortableBuilderEnum(reader);
+        }
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (val != null) {
+            if (clsName != null)
+                ctx.writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, clsName);
+            else
+                ctx.writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, compTypeId);
+
+            return;
+        }
+
+        writer.write(reader.array(), valOff, len);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java
new file mode 100644
index 0000000..a08cfdd
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ *
+ */
+class PortableLazyArrayList extends AbstractList<Object> implements PortableBuilderSerializationAware {
+    /** */
+    private final PortableBuilderReader reader;
+
+    /** */
+    private final int off;
+
+    /** */
+    private List<Object> delegate;
+
+    /**
+     * @param reader Reader.
+     * @param size Size,
+     */
+    PortableLazyArrayList(PortableBuilderReader reader, int size) {
+        this.reader = reader;
+        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
+
+        assert size >= 0;
+
+        for (int i = 0; i < size; i++)
+            reader.skipValue();
+    }
+
+    /**
+     *
+     */
+    private void ensureDelegateInit() {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
+
+            delegate = new ArrayList<>(size);
+
+            for (int i = 0; i < size; i++)
+                delegate.add(reader.parseValue());
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object get(int idx) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.get(idx));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean add(Object o) {
+        ensureDelegateInit();
+
+        return delegate.add(o);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void add(int idx, Object element) {
+        ensureDelegateInit();
+
+        delegate.add(idx, element);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object set(int idx, Object element) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.set(idx, element));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object remove(int idx) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.remove(idx));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear() {
+        if (delegate == null)
+            delegate = new ArrayList<>();
+        else
+            delegate.clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean addAll(int idx, Collection<?> c) {
+        return delegate.addAll(idx, c);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void removeRange(int fromIdx, int toIdx) {
+        ensureDelegateInit();
+
+        delegate.subList(fromIdx, toIdx).clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        if (delegate == null)
+            return reader.readIntAbsolute(off + 1);
+
+        return delegate.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
+
+            writer.write(reader.array(), off, hdrSize);
+
+            reader.position(off + hdrSize);
+
+            for (int i = 0; i < size; i++) {
+                Object o = reader.parseValue();
+
+                ctx.writeValue(writer, o);
+            }
+        }
+        else {
+            writer.writeByte(GridPortableMarshaller.COL);
+            writer.writeInt(delegate.size());
+
+            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
+            writer.writeByte(colType);
+
+            int oldPos = reader.position();
+
+            for (Object o : delegate)
+                ctx.writeValue(writer, o);
+
+            // PortableBuilderImpl might have been written. It could override reader's position.
+            reader.position(oldPos);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java
new file mode 100644
index 0000000..f793d7a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+import java.util.AbstractList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ *
+ */
+class PortableLazyLinkedList extends AbstractList<Object> implements PortableBuilderSerializationAware {
+    /** */
+    private final PortableBuilderReader reader;
+
+    /** */
+    private final int off;
+
+    /** */
+    private List<Object> delegate;
+
+    /**
+     * @param reader Reader.
+     * @param size Size,
+     */
+    PortableLazyLinkedList(PortableBuilderReader reader, int size) {
+        this.reader = reader;
+        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
+
+        assert size >= 0;
+
+        for (int i = 0; i < size; i++)
+            reader.skipValue();
+    }
+
+    /**
+     *
+     */
+    private void ensureDelegateInit() {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
+
+            delegate = new LinkedList<>();
+
+            for (int i = 0; i < size; i++)
+                delegate.add(reader.parseValue());
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object get(int idx) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.get(idx));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean add(Object o) {
+        ensureDelegateInit();
+
+        return delegate.add(o);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void add(int idx, Object element) {
+        ensureDelegateInit();
+
+        delegate.add(idx, element);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object set(int idx, Object element) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.set(idx, element));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object remove(int idx) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.remove(idx));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear() {
+        if (delegate == null)
+            delegate = new LinkedList<>();
+        else
+            delegate.clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean addAll(int idx, Collection<?> c) {
+        ensureDelegateInit();
+
+        return delegate.addAll(idx, c);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void removeRange(int fromIdx, int toIdx) {
+        ensureDelegateInit();
+
+        delegate.subList(fromIdx, toIdx).clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        if (delegate == null)
+            return reader.readIntAbsolute(off + 1);
+
+        return delegate.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public ListIterator<Object> listIterator(final int idx) {
+        ensureDelegateInit();
+
+        return new ListIterator<Object>() {
+            /** */
+            private final ListIterator<Object> delegate = PortableLazyLinkedList.super.listIterator(idx);
+
+            @Override public boolean hasNext() {
+                return delegate.hasNext();
+            }
+
+            @Override public Object next() {
+                return PortableUtils.unwrapLazy(delegate.next());
+            }
+
+            @Override public boolean hasPrevious() {
+                return delegate.hasPrevious();
+            }
+
+            @Override public Object previous() {
+                return PortableUtils.unwrapLazy(delegate.previous());
+            }
+
+            @Override public int nextIndex() {
+                return delegate.nextIndex();
+            }
+
+            @Override public int previousIndex() {
+                return delegate.previousIndex();
+            }
+
+            @Override public void remove() {
+                delegate.remove();
+            }
+
+            @Override public void set(Object o) {
+                delegate.set(o);
+            }
+
+            @Override public void add(Object o) {
+                delegate.add(o);
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterator<Object> iterator() {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazyIterator(super.iterator());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
+            writer.write(reader.array(), off, hdrSize);
+
+            reader.position(off + hdrSize);
+
+            for (int i = 0; i < size; i++) {
+                Object o = reader.parseValue();
+
+                ctx.writeValue(writer, o);
+            }
+        }
+        else {
+            writer.writeByte(GridPortableMarshaller.COL);
+            writer.writeInt(delegate.size());
+
+            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
+            writer.writeByte(colType);
+
+            for (Object o : delegate)
+                ctx.writeValue(writer, o);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java
new file mode 100644
index 0000000..12cbfd6
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ *
+ */
+class PortableLazyMap extends AbstractMap<Object, Object> implements PortableBuilderSerializationAware {
+    /** */
+    private final PortableBuilderReader reader;
+
+    /** */
+    private final int off;
+
+    /** */
+    private Map<Object, Object> delegate;
+
+    /**
+     * @param reader Reader.
+     * @param off Offset.
+     */
+    private PortableLazyMap(PortableBuilderReader reader, int off) {
+        this.reader = reader;
+        this.off = off;
+    }
+
+    /**
+     * @param reader Reader.
+     * @return PortableLazyMap.
+     */
+    @Nullable public static PortableLazyMap parseMap(PortableBuilderReader reader) {
+        int off = reader.position() - 1;
+
+        int size = reader.readInt();
+
+        reader.skip(1); // map type.
+
+        for (int i = 0; i < size; i++) {
+            reader.skipValue(); // skip key
+            reader.skipValue(); // skip value
+        }
+
+        return new PortableLazyMap(reader, off);
+    }
+
+    /**
+     *
+     */
+    private void ensureDelegateInit() {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
+
+            delegate = new LinkedHashMap<>();
+
+            for (int i = 0; i < size; i++)
+                delegate.put(PortableUtils.unwrapLazy(reader.parseValue()), reader.parseValue());
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (delegate == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
+            writer.write(reader.array(), off, hdrSize);
+
+            reader.position(off + hdrSize);
+
+            for (int i = 0; i < size; i++) {
+                ctx.writeValue(writer, reader.parseValue()); // key
+                ctx.writeValue(writer, reader.parseValue()); // value
+            }
+        }
+        else {
+            writer.writeByte(GridPortableMarshaller.MAP);
+            writer.writeInt(delegate.size());
+
+            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
+
+            writer.writeByte(colType);
+
+            for (Entry<Object, Object> entry : delegate.entrySet()) {
+                ctx.writeValue(writer, entry.getKey());
+                ctx.writeValue(writer, entry.getValue());
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size() {
+        if (delegate == null)
+            return reader.readIntAbsolute(off + 1);
+
+        return delegate.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean containsKey(Object key) {
+        ensureDelegateInit();
+
+        return delegate.containsKey(key);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean containsValue(Object val) {
+        return values().contains(val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Set<Object> keySet() {
+        ensureDelegateInit();
+
+        return delegate.keySet();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear() {
+        if (delegate == null)
+            delegate = new LinkedHashMap<>();
+        else
+            delegate.clear();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object get(Object key) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.get(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object put(Object key, Object val) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.put(key, val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object remove(Object key) {
+        ensureDelegateInit();
+
+        return PortableUtils.unwrapLazy(delegate.remove(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Set<Entry<Object, Object>> entrySet() {
+        ensureDelegateInit();
+
+        return new AbstractSet<Entry<Object, Object>>() {
+            @Override public boolean contains(Object o) {
+                throw new UnsupportedOperationException();
+            }
+
+            @Override public Iterator<Entry<Object, Object>> iterator() {
+                return new Iterator<Entry<Object, Object>>() {
+                    /** */
+                    private final Iterator<Entry<Object, Object>> itr = delegate.entrySet().iterator();
+
+                    @Override public boolean hasNext() {
+                        return itr.hasNext();
+                    }
+
+                    @Override public Entry<Object, Object> next() {
+                        Entry<Object, Object> res = itr.next();
+
+                        final Object val = res.getValue();
+
+                        if (val instanceof PortableLazyValue) {
+                            return new SimpleEntry<Object, Object>(res.getKey(), val) {
+                                private static final long serialVersionUID = 0L;
+
+                                @Override public Object getValue() {
+                                    return ((PortableLazyValue)val).value();
+                                }
+                            };
+                        }
+
+                        return res;
+                    }
+
+                    @Override public void remove() {
+                        itr.remove();
+                    }
+                };
+            }
+
+            @Override public int size() {
+                return delegate.size();
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java
new file mode 100644
index 0000000..bd027f5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+import java.util.Map;
+
+/**
+ *
+ */
+class PortableLazyMapEntry implements Map.Entry<Object, Object>, PortableBuilderSerializationAware {
+    /** */
+    private final Object key;
+
+    /** */
+    private Object val;
+
+    /**
+     * @param reader GridMutablePortableReader
+     */
+    PortableLazyMapEntry(PortableBuilderReader reader) {
+        key = reader.parseValue();
+        val = reader.parseValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object getKey() {
+        return PortableUtils.unwrapLazy(key);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object getValue() {
+        return PortableUtils.unwrapLazy(val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object setValue(Object val) {
+        Object res = getValue();
+
+        this.val = val;
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        writer.writeByte(GridPortableMarshaller.MAP_ENTRY);
+
+        ctx.writeValue(writer, key);
+        ctx.writeValue(writer, val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java
new file mode 100644
index 0000000..16772af
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import java.util.Collection;
+import java.util.Set;
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableUtils;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+/**
+ *
+ */
+class PortableLazySet extends PortableAbstractLazyValue {
+    /** */
+    private final int off;
+
+    /**
+     * @param reader Reader.
+     * @param size Size.
+     */
+    PortableLazySet(PortableBuilderReader reader, int size) {
+        super(reader, reader.position() - 1);
+
+        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
+
+        assert size >= 0;
+
+        for (int i = 0; i < size; i++)
+            reader.skipValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (val == null) {
+            int size = reader.readIntAbsolute(off + 1);
+
+            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
+            writer.write(reader.array(), off, hdrSize);
+
+            reader.position(off + hdrSize);
+
+            for (int i = 0; i < size; i++) {
+                Object o = reader.parseValue();
+
+                ctx.writeValue(writer, o);
+            }
+        }
+        else {
+            Collection<Object> c = (Collection<Object>)val;
+
+            writer.writeByte(GridPortableMarshaller.COL);
+            writer.writeInt(c.size());
+
+            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
+            writer.writeByte(colType);
+
+            for (Object o : c)
+                ctx.writeValue(writer, o);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object init() {
+        int size = reader.readIntAbsolute(off + 1);
+
+        reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
+
+        Set<Object> res = U.newLinkedHashSet(size);
+
+        for (int i = 0; i < size; i++)
+            res.add(PortableUtils.unwrapLazy(reader.parseValue()));
+
+        return res;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyValue.java
new file mode 100644
index 0000000..5d8d586
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyValue.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+/**
+ *
+ */
+public interface PortableLazyValue extends PortableBuilderSerializationAware {
+    /**
+     * @return Value.
+     */
+    public Object value();
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableModifiableLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableModifiableLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableModifiableLazyValue.java
new file mode 100644
index 0000000..09fb844
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableModifiableLazyValue.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ *
+ */
+public class PortableModifiableLazyValue extends PortableAbstractLazyValue {
+    /** */
+    protected final int len;
+
+    /**
+     * @param reader
+     * @param valOff
+     * @param len
+     */
+    public PortableModifiableLazyValue(PortableBuilderReader reader, int valOff, int len) {
+        super(reader, valOff);
+
+        this.len = len;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object init() {
+        return reader.reader().unmarshal(valOff);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (val == null)
+            writer.write(reader.array(), valOff, len);
+        else
+            writer.writeObject(val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java
new file mode 100644
index 0000000..1126a3c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.portable.PortableInvalidClassException;
+
+/**
+ *
+ */
+class PortableObjectArrayLazyValue extends PortableAbstractLazyValue {
+    /** */
+    private Object[] lazyValsArr;
+
+    /** */
+    private int compTypeId;
+
+    /** */
+    private String clsName;
+
+    /**
+     * @param reader Reader.
+     */
+    protected PortableObjectArrayLazyValue(PortableBuilderReader reader) {
+        super(reader, reader.position() - 1);
+
+        int typeId = reader.readInt();
+
+        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
+            clsName = reader.readString();
+
+            Class cls;
+
+            try {
+                // TODO: IGNITE-1272 - Is class loader needed here?
+                cls = U.forName(reader.readString(), null);
+            }
+            catch (ClassNotFoundException e) {
+                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
+            }
+
+            compTypeId = reader.portableContext().descriptorForClass(cls).typeId();
+        }
+        else {
+            compTypeId = typeId;
+            clsName = null;
+        }
+
+        int size = reader.readInt();
+
+        lazyValsArr = new Object[size];
+
+        for (int i = 0; i < size; i++)
+            lazyValsArr[i] = reader.parseValue();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object init() {
+        for (int i = 0; i < lazyValsArr.length; i++) {
+            if (lazyValsArr[i] instanceof PortableLazyValue)
+                lazyValsArr[i] = ((PortableLazyValue)lazyValsArr[i]).value();
+        }
+
+        return lazyValsArr;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (clsName == null)
+            ctx.writeArray(writer, GridPortableMarshaller.OBJ_ARR, lazyValsArr, compTypeId);
+        else
+            ctx.writeArray(writer, GridPortableMarshaller.OBJ_ARR, lazyValsArr, clsName);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainLazyValue.java
new file mode 100644
index 0000000..136958a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainLazyValue.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.*;
+
+/**
+ *
+ */
+class PortablePlainLazyValue extends PortableAbstractLazyValue {
+    /** */
+    protected final int len;
+
+    /**
+     * @param reader Reader
+     * @param valOff Offset
+     * @param len Length.
+     */
+    protected PortablePlainLazyValue(PortableBuilderReader reader, int valOff, int len) {
+        super(reader, valOff);
+
+        this.len = len;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object init() {
+        return reader.reader().unmarshal(valOff);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        writer.write(reader.array(), valOff, len);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java
new file mode 100644
index 0000000..8743fbe
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.PortableObjectImpl;
+import org.apache.ignite.internal.portable.PortableObjectOffheapImpl;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.portable.PortableObject;
+
+/**
+ *
+ */
+public class PortablePlainPortableObject implements PortableLazyValue {
+    /** */
+    private final PortableObject portableObj;
+
+    /**
+     * @param portableObj Portable object.
+     */
+    public PortablePlainPortableObject(PortableObject portableObj) {
+        this.portableObj = portableObj;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object value() {
+        return portableObj;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        PortableObject val = portableObj;
+
+        if (val instanceof PortableObjectOffheapImpl)
+            val = ((PortableObjectOffheapImpl)val).heapCopy();
+
+        writer.doWritePortableObject((PortableObjectImpl)val);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java
new file mode 100644
index 0000000..2e031f0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ *
+ */
+class PortableValueWithType implements PortableLazyValue {
+    /** */
+    private byte type;
+
+    /** */
+    private Object val;
+
+    /**
+     * @param type Type
+     * @param val Value.
+     */
+    PortableValueWithType(byte type, Object val) {
+        this.type = type;
+        this.val = val;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        if (val instanceof PortableBuilderSerializationAware)
+            ((PortableBuilderSerializationAware)val).writeTo(writer, ctx);
+        else
+            ctx.writeValue(writer, val);
+    }
+
+    /** {@inheritDoc} */
+    public String typeName() {
+        return CacheObjectPortableProcessorImpl.fieldTypeName(type);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object value() {
+        if (val instanceof PortableLazyValue)
+            return ((PortableLazyValue)val).value();
+
+        return val;
+    }
+
+    /**
+     * @param val New value.
+     */
+    public void value(Object val) {
+        this.val = val;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(PortableValueWithType.class, this);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/package-info.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/package-info.java
new file mode 100644
index 0000000..e069f3e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains classes specific to portable builder API.
+ */
+package org.apache.ignite.internal.portable.builder;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
index b33c643..1be5aea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
@@ -45,13 +45,13 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.portable.GridPortableMarshaller;
-import org.apache.ignite.internal.portable.PortableBuilderImpl;
 import org.apache.ignite.internal.portable.PortableContext;
 import org.apache.ignite.internal.portable.PortableMetaDataHandler;
 import org.apache.ignite.internal.portable.PortableMetaDataImpl;
 import org.apache.ignite.internal.portable.PortableObjectImpl;
 import org.apache.ignite.internal.portable.PortableObjectOffheapImpl;
 import org.apache.ignite.internal.portable.PortableUtils;
+import org.apache.ignite.internal.portable.builder.PortableBuilderImpl;
 import org.apache.ignite.internal.portable.streams.PortableInputStream;
 import org.apache.ignite.internal.portable.streams.PortableOffheapInputStream;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index d80cc49..dd8c3f3 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -281,7 +281,7 @@ org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager$1
 org.apache.ignite.internal.processors.platform.PlatformAwareEventFilter
 org.apache.ignite.internal.portable.PortableClassDescriptor$Mode
 org.apache.ignite.internal.portable.PortableContext
-org.apache.ignite.internal.portable.PortableLazyMap$1$1$1
+org.apache.ignite.internal.portable.builder.PortableLazyMap$1$1$1
 org.apache.ignite.internal.portable.PortableMetaDataImpl
 org.apache.ignite.internal.portable.PortableObjectEx
 org.apache.ignite.internal.portable.PortableObjectImpl


[23/50] [abbrv] ignite git commit: Merge remote-tracking branch 'origin/ignite-1.4' into ignite-1.4

Posted by ak...@apache.org.
Merge remote-tracking branch 'origin/ignite-1.4' into ignite-1.4


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

Branch: refs/heads/ignite-843
Commit: c5d303bac7a9b17f88260b1bde175fbfbc053988
Parents: 66a49d7 7f4c9ac
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 3 15:34:47 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 3 15:34:47 2015 +0300

----------------------------------------------------------------------
 .../java8/datagrid/CacheAffinityExample.java    | 15 +++++++++++++
 .../java8/messaging/MessagingExample.java       | 11 +++++++++-
 .../java8/examples/BasicExamplesSelfTest.java   | 10 ++++++---
 .../java8/examples/CacheExamplesSelfTest.java   |  8 ++++---
 .../examples/CheckpointExamplesSelfTest.java    |  8 +++----
 .../examples/ClusterGroupExampleSelfTest.java   |  4 +++-
 .../examples/ContinuationExamplesSelfTest.java  |  8 ++++---
 .../ContinuousMapperExamplesSelfTest.java       |  8 ++++---
 .../examples/DeploymentExamplesSelfTest.java    |  6 ++++--
 .../java8/examples/EventsExamplesSelfTest.java  |  5 +++--
 .../HibernateL2CacheExampleSelfTest.java        |  8 ++++---
 .../java8/examples/IgfsExamplesSelfTest.java    |  6 ++++--
 .../examples/LifecycleExamplesSelfTest.java     |  8 ++++---
 .../examples/MemcacheRestExamplesSelfTest.java  |  4 +++-
 .../examples/MessagingExamplesSelfTest.java     |  6 ++++--
 .../examples/MonteCarloExamplesSelfTest.java    |  8 ++++---
 .../examples/SpringBeanExamplesSelfTest.java    |  8 ++++---
 .../java8/examples/TaskExamplesSelfTest.java    |  4 +++-
 .../IgniteExamplesJ8SelfTestSuite.java          | 12 +++++++++--
 .../ignite/platform/cpp/package-info.java       | 22 ++++++++++++++++++++
 .../ignite/platform/dotnet/package-info.java    | 22 ++++++++++++++++++++
 .../apache/ignite/platform/package-info.java    | 22 ++++++++++++++++++++
 parent/pom.xml                                  |  4 ++++
 23 files changed, 175 insertions(+), 42 deletions(-)
----------------------------------------------------------------------



[35/50] [abbrv] ignite git commit: Merge branch 'ignite-1.4'

Posted by ak...@apache.org.
Merge branch 'ignite-1.4'


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

Branch: refs/heads/ignite-843
Commit: a007210563c13cf3a6e0db4eb9d4fab59503a7c1
Parents: 5658361 28213a3
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Sep 4 10:29:00 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Sep 4 10:29:00 2015 +0300

----------------------------------------------------------------------
 examples/config/example-default.xml             |  76 +++++
 examples/config/example-ignite.xml              |  56 +---
 .../config/portable/example-ignite-portable.xml |  44 +++
 .../ignite/examples/portable/Address.java       |  72 ++++
 .../ignite/examples/portable/Employee.java      |  93 ++++++
 .../ignite/examples/portable/EmployeeKey.java   |  90 +++++
 .../portable/ExamplePortableNodeStartup.java    |  36 ++
 .../ignite/examples/portable/Organization.java  |  93 ++++++
 .../examples/portable/OrganizationType.java     |  32 ++
 ...mputeClientPortableTaskExecutionExample.java | 154 +++++++++
 .../portable/computegrid/ComputeClientTask.java | 116 +++++++
 .../portable/computegrid/package-info.java      |  21 ++
 .../CacheClientPortablePutGetExample.java       | 230 +++++++++++++
 .../CacheClientPortableQueryExample.java        | 328 +++++++++++++++++++
 .../portable/datagrid/package-info.java         |  21 ++
 .../ignite/examples/portable/package-info.java  |  21 ++
 .../java8/datagrid/CacheAffinityExample.java    |  15 +
 .../java8/messaging/MessagingExample.java       |  11 +-
 .../CacheClientPortableExampleTest.java         |  46 +++
 .../ComputeClientPortableExampleTest.java       |  37 +++
 .../testsuites/IgniteExamplesSelfTestSuite.java |   6 +
 .../java8/examples/BasicExamplesSelfTest.java   |  10 +-
 .../java8/examples/CacheExamplesSelfTest.java   |   8 +-
 .../examples/CheckpointExamplesSelfTest.java    |   8 +-
 .../examples/ClusterGroupExampleSelfTest.java   |   4 +-
 .../examples/ContinuationExamplesSelfTest.java  |   8 +-
 .../ContinuousMapperExamplesSelfTest.java       |   8 +-
 .../examples/DeploymentExamplesSelfTest.java    |   6 +-
 .../java8/examples/EventsExamplesSelfTest.java  |   5 +-
 .../HibernateL2CacheExampleSelfTest.java        |   8 +-
 .../java8/examples/IgfsExamplesSelfTest.java    |   6 +-
 .../examples/LifecycleExamplesSelfTest.java     |   8 +-
 .../examples/MemcacheRestExamplesSelfTest.java  |   4 +-
 .../examples/MessagingExamplesSelfTest.java     |   6 +-
 .../examples/MonteCarloExamplesSelfTest.java    |   8 +-
 .../examples/SpringBeanExamplesSelfTest.java    |   8 +-
 .../java8/examples/TaskExamplesSelfTest.java    |   4 +-
 .../IgniteExamplesJ8SelfTestSuite.java          |  12 +-
 .../apache/ignite/internal/IgniteKernal.java    |   8 +-
 .../IgniteCacheP2pUnmarshallingErrorTest.java   |   5 +
 .../testsuites/IgniteCacheTestSuite3.java       |   3 +-
 .../ignite/logger/log4j2/Log4J2Logger.java      |  20 +-
 .../ignite/platform/cpp/package-info.java       |  22 ++
 .../ignite/platform/dotnet/package-info.java    |  22 ++
 .../apache/ignite/platform/package-info.java    |  22 ++
 parent/pom.xml                                  |   4 +
 46 files changed, 1725 insertions(+), 100 deletions(-)
----------------------------------------------------------------------



[38/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/ignite_environment.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/ignite_environment.cpp b/modules/platform/src/main/cpp/core/src/impl/ignite_environment.cpp
new file mode 100644
index 0000000..b20c543
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/ignite_environment.cpp
@@ -0,0 +1,166 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/impl/ignite_environment.h"
+#include "ignite/portable/portable.h"
+
+using namespace ignite::common::concurrent;
+using namespace ignite::common::java;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+using namespace ignite::portable;
+
+namespace ignite 
+{
+    namespace impl 
+    {
+        /**
+         * OnStart callback.
+         *
+         * @param target Target environment.
+         * @param memPtr Memory pointer.
+         */
+        void IGNITE_CALL OnStart(void* target, long long memPtr)
+        {
+            SharedPointer<IgniteEnvironment>* ptr = static_cast<SharedPointer<IgniteEnvironment>*>(target);
+
+            ptr->Get()->OnStartCallback(memPtr);
+        }
+
+        /**
+         * OnStop callback.
+         *
+         * @param target Target environment.
+         */
+        void IGNITE_CALL OnStop(void* target)
+        {
+            SharedPointer<IgniteEnvironment>* ptr = static_cast<SharedPointer<IgniteEnvironment>*>(target);
+
+            delete ptr;
+        } 
+
+        IgniteEnvironment::IgniteEnvironment() : ctx(SharedPointer<JniContext>()), latch(new SingleLatch), name(NULL),
+            metaMgr(new PortableMetadataManager())
+        {
+            // No-op.
+        }
+
+        IgniteEnvironment::~IgniteEnvironment()
+        {
+            delete latch;
+
+            if (name)
+                delete name;
+
+            delete metaMgr;
+        }
+
+        JniHandlers IgniteEnvironment::GetJniHandlers(SharedPointer<IgniteEnvironment>* target)
+        {
+            JniHandlers hnds = JniHandlers();
+
+            hnds.target = target;
+
+            hnds.onStart = OnStart;
+            hnds.onStop = OnStop;
+
+            hnds.error = NULL;
+
+            return hnds;
+        }
+            
+        void IgniteEnvironment::Initialize(SharedPointer<JniContext> ctx)
+        {
+            this->ctx = ctx;
+                
+            latch->CountDown();
+        }
+        
+        char* IgniteEnvironment::InstanceName()
+        {
+            return name;
+        }
+
+        JniContext* IgniteEnvironment::Context()
+        {
+            return ctx.Get();
+        }
+
+        SharedPointer<InteropMemory> IgniteEnvironment::AllocateMemory()
+        {
+            SharedPointer<InteropMemory> ptr(new InteropUnpooledMemory(1024));
+
+            return ptr;
+        }
+
+        SharedPointer<InteropMemory> IgniteEnvironment::AllocateMemory(int32_t cap)
+        {
+            SharedPointer<InteropMemory> ptr(new InteropUnpooledMemory(cap));
+
+            return ptr;
+        }
+
+        SharedPointer<InteropMemory> IgniteEnvironment::GetMemory(int64_t memPtr)
+        {
+            int8_t* memPtr0 = reinterpret_cast<int8_t*>(memPtr);
+
+            int32_t flags = InteropMemory::Flags(memPtr0);
+
+            if (InteropMemory::IsExternal(flags))
+            {
+                SharedPointer<InteropMemory> ptr(new InteropExternalMemory(memPtr0));
+
+                return ptr;
+            }
+            else
+            {
+                SharedPointer<InteropMemory> ptr(new InteropUnpooledMemory(memPtr0));
+
+                return ptr;
+            }
+        }
+
+        PortableMetadataManager* IgniteEnvironment::GetMetadataManager()
+        {
+            return metaMgr;
+        }
+
+        void IgniteEnvironment::OnStartCallback(long long memPtr)
+        {
+            InteropExternalMemory mem(reinterpret_cast<int8_t*>(memPtr));
+            InteropInputStream stream(&mem);
+
+            PortableReaderImpl reader(&stream);
+            
+            int32_t nameLen = reader.ReadString(NULL, 0);
+
+            if (nameLen >= 0)
+            {
+                name = new char[nameLen + 1];
+                reader.ReadString(name, nameLen + 1);
+            }
+            else
+                name = NULL;
+        }
+    }
+}
+
+
+
+
+

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/ignite_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/ignite_impl.cpp b/modules/platform/src/main/cpp/core/src/impl/ignite_impl.cpp
new file mode 100644
index 0000000..1aad309
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/ignite_impl.cpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/ignite_impl.h"
+
+using namespace ignite::common::concurrent;
+using namespace ignite::common::java;
+
+namespace ignite
+{    
+    namespace impl
+    {
+        IgniteImpl::IgniteImpl(SharedPointer<IgniteEnvironment> env, jobject javaRef) : env(env), javaRef(javaRef)
+        {
+            // No-op.
+        }
+
+        IgniteImpl::~IgniteImpl()
+        {
+            JniContext::Release(javaRef);
+        }
+
+        char* IgniteImpl::GetName()
+        {
+            return env.Get()->InstanceName();
+        }
+    }    
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/interop/interop_input_stream.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/interop/interop_input_stream.cpp b/modules/platform/src/main/cpp/core/src/impl/interop/interop_input_stream.cpp
new file mode 100644
index 0000000..72340ee
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/interop/interop_input_stream.cpp
@@ -0,0 +1,215 @@
+/*
+ * 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.
+ */
+
+#include <cstring>
+
+#include "ignite/impl/interop/interop_input_stream.h"
+#include "ignite/ignite_error.h"
+
+/**
+ * Common macro to read a single value.
+ */
+#define IGNITE_INTEROP_IN_READ(type, len) { \
+    EnsureEnoughData(len); \
+    type res = *reinterpret_cast<type*>(data + pos); \
+    Shift(len); \
+    return res; \
+}
+
+/**
+ * Common macro to read an array.
+ */
+#define IGNITE_INTEROP_IN_READ_ARRAY(len, shift) { \
+    CopyAndShift(reinterpret_cast<int8_t*>(res), 0, len << shift); \
+}
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace interop 
+        {
+            union PortableInt32Float
+            {
+                int32_t i;
+                float f;
+            };
+
+            union PortableInt64Double
+            {
+                int64_t i;
+                double d;
+            };
+
+            InteropInputStream::InteropInputStream(InteropMemory* mem)
+            {
+                this->mem = mem;
+
+                data = mem->Data();
+                len = mem->Length();
+                pos = 0;
+            }
+
+            int8_t InteropInputStream::ReadInt8()
+            {
+                IGNITE_INTEROP_IN_READ(int8_t, 1);
+            }
+
+            void InteropInputStream::ReadInt8Array(int8_t* const res, const int32_t len)
+            {
+                IGNITE_INTEROP_IN_READ_ARRAY(len, 0);
+            }
+
+            bool InteropInputStream::ReadBool()
+            {
+                return ReadInt8() == 1;
+            }
+
+            void InteropInputStream::ReadBoolArray(bool* const res, const int32_t len)
+            {
+                for (int i = 0; i < len; i++)
+                    *(res + i) = ReadBool();
+            }
+                
+            int16_t InteropInputStream::ReadInt16()
+            {
+                IGNITE_INTEROP_IN_READ(int16_t, 2);
+            }
+
+            void InteropInputStream::ReadInt16Array(int16_t* const res, const int32_t len)
+            {
+                IGNITE_INTEROP_IN_READ_ARRAY(len, 1);
+            }
+
+            uint16_t InteropInputStream::ReadUInt16()
+            {
+                IGNITE_INTEROP_IN_READ(uint16_t, 2);
+            }
+
+            void InteropInputStream::ReadUInt16Array(uint16_t* const res, const int32_t len)
+            {
+                IGNITE_INTEROP_IN_READ_ARRAY(len, 1);
+            }
+
+            int32_t InteropInputStream::ReadInt32()
+            {
+                IGNITE_INTEROP_IN_READ(int32_t, 4);
+            }
+
+            int32_t InteropInputStream::ReadInt32(int32_t pos)
+            {
+                int delta = pos + 4 - this->pos;
+
+                if (delta > 0)
+                    EnsureEnoughData(delta);
+
+                return *reinterpret_cast<int32_t*>(data + pos);
+            }
+
+            void InteropInputStream::ReadInt32Array(int32_t* const res, const int32_t len)
+            {
+                IGNITE_INTEROP_IN_READ_ARRAY(len, 2);
+            }
+
+            int64_t InteropInputStream::ReadInt64()
+            {
+                IGNITE_INTEROP_IN_READ(int64_t, 8);
+            }
+
+            void InteropInputStream::ReadInt64Array(int64_t* const res, const int32_t len)
+            {
+                IGNITE_INTEROP_IN_READ_ARRAY(len, 3);
+            }
+
+            float InteropInputStream::ReadFloat()
+            {
+                PortableInt32Float u;
+
+                u.i = ReadInt32();
+
+                return u.f;
+            }
+
+            void InteropInputStream::ReadFloatArray(float* const res, const int32_t len)
+            {
+                IGNITE_INTEROP_IN_READ_ARRAY(len, 2);
+            }
+
+            double InteropInputStream::ReadDouble()
+            {
+                PortableInt64Double u;
+
+                u.i = ReadInt64();
+
+                return u.d;
+            }
+
+            void InteropInputStream::ReadDoubleArray(double* const res, const int32_t len)
+            {
+                IGNITE_INTEROP_IN_READ_ARRAY(len, 3);
+            }
+                
+            int32_t InteropInputStream::Remaining()
+            {
+                return len - pos;
+            }
+
+            int32_t InteropInputStream::Position()
+            {
+                return pos;
+            }
+
+            void InteropInputStream::Position(int32_t pos)
+            {
+                if (pos > len) {
+                    IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_MEMORY, "Requested input stream position is out of bounds",
+                        "memPtr", mem->PointerLong(), "len", len, "pos", pos);
+                }
+
+                this->pos = pos;
+            }
+
+            void InteropInputStream::Synchronize()
+            {
+                data = mem->Data();
+                len = mem->Length();
+            }
+            
+            void InteropInputStream::EnsureEnoughData(int32_t cnt)
+            {
+                if (len - pos < cnt) {
+                    IGNITE_ERROR_FORMATTED_4(IgniteError::IGNITE_ERR_MEMORY, "Not enough data in the stream",
+                        "memPtr", mem->PointerLong(), "len", len, "pos", pos, "requested", cnt);
+                }
+            }
+
+            void InteropInputStream::CopyAndShift(int8_t* dest, int32_t off, int32_t cnt)
+            {
+                EnsureEnoughData(cnt);
+
+                memcpy(dest + off, data + pos, cnt);
+
+                Shift(cnt);
+            }
+
+            void InteropInputStream::Shift(int32_t cnt)
+            {
+                pos += cnt;
+            }
+        }
+    }
+}        

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/interop/interop_memory.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/interop/interop_memory.cpp b/modules/platform/src/main/cpp/core/src/impl/interop/interop_memory.cpp
new file mode 100644
index 0000000..05ba8b6
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/interop/interop_memory.cpp
@@ -0,0 +1,182 @@
+/*
+ * 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.
+ */
+
+#include <ignite/common/java.h>
+
+#include "ignite/impl/interop/interop_memory.h"
+#include "ignite/ignite_error.h"
+
+using namespace ignite::common::java;
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace interop 
+        {
+            int8_t* InteropMemory::Data(int8_t* memPtr)
+            {
+                return reinterpret_cast<int8_t*>(*reinterpret_cast<int64_t*>(memPtr));
+            }
+
+            void InteropMemory::Data(int8_t* memPtr, void* ptr)
+            {
+                *reinterpret_cast<int64_t*>(memPtr) = reinterpret_cast<int64_t>(ptr);
+            }
+
+            int32_t InteropMemory::Capacity(int8_t* memPtr)
+            {
+                return *reinterpret_cast<int32_t*>(memPtr + IGNITE_MEM_HDR_OFF_CAP);
+            }
+
+            void InteropMemory::Capacity(int8_t* memPtr, int32_t val)
+            {
+                *reinterpret_cast<int32_t*>(memPtr + IGNITE_MEM_HDR_OFF_CAP) = val;
+            }
+
+            int32_t InteropMemory::Length(int8_t* memPtr)
+            {
+                return *reinterpret_cast<int32_t*>(memPtr + IGNITE_MEM_HDR_OFF_LEN);
+            }
+
+            void InteropMemory::Length(int8_t* memPtr, int32_t val)
+            {
+                *reinterpret_cast<int32_t*>(memPtr + IGNITE_MEM_HDR_OFF_LEN) = val;
+            }
+
+            int32_t InteropMemory::Flags(int8_t* memPtr)
+            {
+                return *reinterpret_cast<int32_t*>(memPtr + IGNITE_MEM_HDR_OFF_FLAGS);
+            }
+
+            void InteropMemory::Flags(int8_t* memPtr, int32_t val)
+            {
+                *reinterpret_cast<int32_t*>(memPtr + IGNITE_MEM_HDR_OFF_FLAGS) = val;
+            }
+
+            bool InteropMemory::IsExternal(int8_t* memPtr)
+            {
+                return IsExternal(Flags(memPtr));
+            }
+
+            bool InteropMemory::IsExternal(int32_t flags)
+            {
+                return (flags & IGNITE_MEM_FLAG_EXT) != IGNITE_MEM_FLAG_EXT;
+            }
+
+            bool InteropMemory::IsPooled(int8_t* memPtr)
+            {
+                return IsPooled(Flags(memPtr));
+            }
+
+            bool InteropMemory::IsPooled(int32_t flags)
+            {
+                return (flags & IGNITE_MEM_FLAG_POOLED) != 0;
+            }
+
+            bool InteropMemory::IsAcquired(int8_t* memPtr)
+            {
+                return IsAcquired(Flags(memPtr));
+            }
+
+            bool InteropMemory::IsAcquired(int32_t flags)
+            {
+                return (flags & IGNITE_MEM_FLAG_ACQUIRED) != 0;
+            }
+                
+            int8_t* InteropMemory::Pointer()
+            {
+                return memPtr;
+            }
+
+            int64_t InteropMemory::PointerLong()
+            {
+                return reinterpret_cast<int64_t>(memPtr);
+            }
+
+            int8_t* InteropMemory::Data()
+            {
+                return Data(memPtr);
+            }
+
+            int32_t InteropMemory::Capacity()
+            {
+                return Capacity(memPtr);
+            }
+
+            int32_t InteropMemory::Length()
+            {
+                return Length(memPtr);
+            }
+
+            void InteropMemory::Length(int32_t val)
+            {
+                Length(memPtr, val);
+            }
+                
+            InteropUnpooledMemory::InteropUnpooledMemory(int32_t cap)
+            {
+                memPtr = static_cast<int8_t*>(malloc(IGNITE_MEM_HDR_LEN));
+                
+                Data(memPtr, malloc(cap));
+                Capacity(memPtr, cap);
+                Length(memPtr, 0);
+                Flags(memPtr, IGNITE_MEM_FLAG_EXT);
+
+                owning = true;
+            }
+
+            InteropUnpooledMemory::InteropUnpooledMemory(int8_t* memPtr)
+            {
+                this->memPtr = memPtr;
+                this->owning = false;
+            }
+
+            InteropUnpooledMemory::~InteropUnpooledMemory()
+            {
+                if (owning) {
+                    free(Data());
+                    free(memPtr);
+                }
+            }
+
+            void InteropUnpooledMemory::Reallocate(int32_t cap)
+            {
+                int doubledCap = Capacity() << 1;
+
+                if (doubledCap > cap)
+                    cap = doubledCap;
+
+                Data(memPtr, realloc(Data(memPtr), cap));
+                Capacity(memPtr, cap);
+            }
+
+            InteropExternalMemory::InteropExternalMemory(int8_t* memPtr) 
+            {
+                this->memPtr = memPtr;
+            }
+
+            void InteropExternalMemory::Reallocate(int32_t cap)
+            {
+                if (JniContext::Reallocate(reinterpret_cast<int64_t>(memPtr), cap) == -1) {
+                    IGNITE_ERROR_FORMATTED_2(IgniteError::IGNITE_ERR_MEMORY, "Failed to reallocate external memory", 
+                        "memPtr", PointerLong(), "requestedCapacity", cap)
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/interop/interop_output_stream.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/interop/interop_output_stream.cpp b/modules/platform/src/main/cpp/core/src/impl/interop/interop_output_stream.cpp
new file mode 100644
index 0000000..ecdfd42
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/interop/interop_output_stream.cpp
@@ -0,0 +1,215 @@
+/*
+ * 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.
+ */
+
+#include <cstring>
+
+#include "ignite/impl/interop/interop_output_stream.h"
+#include "ignite/ignite_error.h"
+
+/**
+ * Common macro to write a single value.
+ */
+#define IGNITE_INTEROP_OUT_WRITE(val, type, len) { \
+    EnsureCapacity(pos + len); \
+    *reinterpret_cast<type*>(data + pos) = val; \
+    Shift(len); \
+}
+
+/**
+ * Common macro to write an array.
+ */
+#define IGNITE_INTEROP_OUT_WRITE_ARRAY(val, len) { \
+    CopyAndShift(reinterpret_cast<const int8_t*>(val), 0, len); \
+}
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace interop 
+        {
+            union PortableFloatInt32
+            {
+                float f;
+                int32_t i;                
+            };
+
+            union PortableDoubleInt64
+            {
+                double d;
+                int64_t i;                
+            };
+
+            InteropOutputStream::InteropOutputStream(InteropMemory* mem)
+            {
+                this->mem = mem;
+
+                data = mem->Data();
+                cap = mem->Capacity();
+                pos = 0;
+            }
+
+            void InteropOutputStream::WriteInt8(const int8_t val)
+            {
+                IGNITE_INTEROP_OUT_WRITE(val, int8_t, 1);
+            }
+
+            void InteropOutputStream::WriteInt8(const int8_t val, const int32_t pos)
+            {
+                EnsureCapacity(pos + 1);
+
+                *(data + pos) = val;
+            }
+
+            void InteropOutputStream::WriteInt8Array(const int8_t* val, const int32_t len)
+            {
+                IGNITE_INTEROP_OUT_WRITE_ARRAY(val, len);
+            }
+
+            void InteropOutputStream::WriteBool(const bool val)
+            {
+                WriteInt8(val ? 1 : 0);
+            }
+
+            void InteropOutputStream::WriteBoolArray(const bool* val, const int32_t len)
+            {
+                for (int i = 0; i < len; i++)
+                    WriteBool(*(val + i));
+            }
+
+            void InteropOutputStream::WriteInt16(const int16_t val)
+            {
+                IGNITE_INTEROP_OUT_WRITE(val, int16_t, 2);
+            }
+
+            void InteropOutputStream::WriteInt16Array(const int16_t* val, const int32_t len)
+            {
+                IGNITE_INTEROP_OUT_WRITE_ARRAY(val, len << 1);
+            }
+
+            void InteropOutputStream::WriteUInt16(const uint16_t val)
+            {
+                IGNITE_INTEROP_OUT_WRITE(val, uint16_t, 2);
+            }
+
+            void InteropOutputStream::WriteUInt16Array(const uint16_t* val, const int32_t len)
+            {
+                IGNITE_INTEROP_OUT_WRITE_ARRAY(val, len << 1);
+            }
+
+            void InteropOutputStream::WriteInt32(const int32_t val)
+            {
+                IGNITE_INTEROP_OUT_WRITE(val, int32_t, 4);
+            }
+
+            void InteropOutputStream::WriteInt32(const int32_t pos, const int32_t val)
+            {
+                EnsureCapacity(pos + 4);
+
+                *reinterpret_cast<int32_t*>(data + pos) = val;
+            }
+
+            void InteropOutputStream::WriteInt32Array(const int32_t* val, const int32_t len)
+            {
+                IGNITE_INTEROP_OUT_WRITE_ARRAY(val, len << 2);
+            }
+
+            void InteropOutputStream::WriteInt64(const int64_t val)
+            {
+                IGNITE_INTEROP_OUT_WRITE(val, int64_t, 8);
+            }
+
+            void InteropOutputStream::WriteInt64Array(const int64_t* val, const int32_t len)
+            {
+                IGNITE_INTEROP_OUT_WRITE_ARRAY(val, len << 3);
+            }
+
+            void InteropOutputStream::WriteFloat(const float val)
+            {
+                PortableFloatInt32 u;
+
+                u.f = val;
+
+                WriteInt32(u.i);
+            }
+
+            void InteropOutputStream::WriteFloatArray(const float* val, const int32_t len)
+            {
+                for (int i = 0; i < len; i++)
+                    WriteFloat(*(val + i));
+            }
+
+            void InteropOutputStream::WriteDouble(const double val)
+            {
+                PortableDoubleInt64 u;
+
+                u.d = val;
+
+                WriteInt64(u.i);
+            }
+
+            void InteropOutputStream::WriteDoubleArray(const double* val, const int32_t len)
+            {
+                for (int i = 0; i < len; i++)
+                    WriteDouble(*(val + i));
+            }
+
+            int32_t InteropOutputStream::Position()
+            {
+                return pos;
+            }
+
+            void InteropOutputStream::Position(const int32_t val)
+            {
+                EnsureCapacity(val);
+
+                pos = val;
+            }
+
+            void InteropOutputStream::Synchronize()
+            {
+                mem->Length(pos);
+            }
+
+            void InteropOutputStream::EnsureCapacity(int32_t reqCap) {
+                if (reqCap > cap) {
+                    int newCap = cap << 1;
+
+                    if (newCap < reqCap)
+                        newCap = reqCap;
+
+                    mem->Reallocate(newCap);
+                    data = mem->Data();
+                    cap = newCap;
+                }
+            }
+
+            void InteropOutputStream::Shift(int32_t cnt) {
+                pos += cnt;
+            }
+
+            void InteropOutputStream::CopyAndShift(const int8_t* src, int32_t off, int32_t len) {
+                EnsureCapacity(pos + len);
+
+                memcpy(data + pos, src + off, len);
+
+                Shift(len);
+            }
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_handler.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_handler.cpp b/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_handler.cpp
new file mode 100644
index 0000000..5ca91dc
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_handler.cpp
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/portable/portable_metadata_handler.h"
+
+using namespace ignite::common::concurrent;
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            PortableMetadataHandler::PortableMetadataHandler(SPSnap snap) : snap(snap), fieldIds(NULL), fields(NULL)
+            {
+                // No-op.
+            }
+            
+            PortableMetadataHandler::~PortableMetadataHandler()
+            {
+                if (fieldIds)
+                    delete fieldIds;
+
+                if (fields)
+                    delete fields;
+            }
+
+            void PortableMetadataHandler::OnFieldWritten(int32_t fieldId, std::string fieldName, int32_t fieldTypeId)
+            {
+                if (!snap.Get() || !snap.Get()->ContainsFieldId(fieldId))
+                {
+                    if (!HasDifference())
+                    {
+                        fieldIds = new std::set<int32_t>();
+                        fields = new std::map<std::string, int32_t>();
+                    }
+
+                    fieldIds->insert(fieldId);
+                    (*fields)[fieldName] = fieldTypeId;
+                }
+            }
+
+            SPSnap PortableMetadataHandler::GetSnapshot()
+            {
+                return snap;
+            }
+
+            bool PortableMetadataHandler::HasDifference()
+            {
+                return fieldIds ? true : false;
+            }
+
+            std::set<int32_t>* PortableMetadataHandler::GetFieldIds()
+            {
+                return fieldIds;
+            }
+
+            std::map<std::string, int32_t>* PortableMetadataHandler::GetFields()
+            {
+                return fields;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_manager.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_manager.cpp b/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_manager.cpp
new file mode 100644
index 0000000..63e92a9
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_manager.cpp
@@ -0,0 +1,201 @@
+/*
+ * 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.
+ */
+
+#include <ignite/common/concurrent.h>
+
+#include "ignite/impl/portable/portable_metadata_manager.h"
+
+using namespace ignite::common::concurrent;
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            PortableMetadataManager::PortableMetadataManager() : 
+                snapshots(SharedPointer<std::map<int32_t, SPSnap>>(new std::map<int32_t, SPSnap>)),
+                pending(new std::vector<SPSnap>()), 
+                cs(new CriticalSection()), 
+                pendingVer(0), ver(0)
+            {
+                // No-op.
+            }
+
+            PortableMetadataManager::~PortableMetadataManager()
+            {
+                pending->erase(pending->begin(), pending->end());
+
+                delete pending;
+                delete cs;
+            }
+
+            SharedPointer<PortableMetadataHandler> PortableMetadataManager::GetHandler(int32_t typeId)
+            {
+                SharedPointer<std::map<int32_t, SPSnap>> snapshots0 = snapshots;
+
+                SPSnap snapshot = (*snapshots0.Get())[typeId];
+
+                return SharedPointer<PortableMetadataHandler>(new PortableMetadataHandler(snapshot));
+            }
+
+            void PortableMetadataManager::SubmitHandler(std::string typeName, int32_t typeId, 
+                PortableMetadataHandler* hnd)
+            {
+                Snap* snap = hnd->GetSnapshot().Get();
+
+                // If this is the very first write of a class or difference exists, 
+                // we need to enqueue it for write.
+                if (!snap || hnd->HasDifference())
+                {
+                    std::set<int32_t>* newFieldIds = new std::set<int32_t>();
+                    std::map<std::string, int32_t>* newFields = new std::map<std::string, int32_t>();
+                    
+                    CopyFields(snap, newFieldIds, newFields);
+
+                    if (hnd->HasDifference())
+                    {
+                        std::set<int32_t>* diffFieldIds = hnd->GetFieldIds();
+                        std::map<std::string, int32_t>* diffFields = hnd->GetFields();
+
+                        for (std::set<int32_t>::iterator it = diffFieldIds->begin(); it != diffFieldIds->end(); ++it)
+                            newFieldIds->insert(*it);
+
+                        for (std::map<std::string, int32_t>::iterator it = diffFields->begin(); it != diffFields->end(); ++it)
+                            (*newFields)[it->first] = it->second;
+                    }
+
+                    Snap* diffSnap = new Snap(typeName, typeId, newFieldIds, newFields);
+
+                    cs->Enter();
+
+                    pending->push_back(SPSnap(diffSnap));
+
+                    pendingVer++;
+
+                    cs->Leave();
+                }
+            }
+
+            int32_t PortableMetadataManager::GetVersion()
+            {
+                Memory::Fence();
+
+                return ver;
+            }
+
+            bool PortableMetadataManager::IsUpdatedSince(int32_t oldVer)
+            {
+                Memory::Fence();
+
+                return pendingVer > oldVer;
+            }
+
+            bool PortableMetadataManager::ProcessPendingUpdates(PortableMetadataUpdater* updater, IgniteError* err)
+            {
+                bool success = true; // Optimistically assume that all will be fine.
+                
+                cs->Enter();
+
+                for (std::vector<SPSnap>::iterator it = pending->begin(); it != pending->end(); ++it)
+                {
+                    Snap* pendingSnap = (*it).Get();
+
+                    if (updater->Update(pendingSnap, err))
+                    {
+                        // Perform copy-on-write update of snapshot collection.
+                        std::map<int32_t, SPSnap>* newSnapshots = new std::map<int32_t, SPSnap>();
+                        
+                        bool snapshotFound = false;
+
+                        for (std::map<int32_t, SPSnap>::iterator snapIt = snapshots.Get()->begin();
+                            snapIt != snapshots.Get()->end(); ++snapIt)
+                        {
+                            int32_t curTypeId = snapIt->first;
+                            Snap* curSnap = snapIt->second.Get();
+
+                            if (pendingSnap->GetTypeId() == curTypeId)
+                            {
+                                // Have to create snapshot with updated fields.
+                                std::set<int32_t>* newFieldIds = new std::set<int32_t>();
+                                std::map<std::string, int32_t>* newFields = new std::map<std::string, int32_t>();
+
+                                // Add old fields.
+                                CopyFields(curSnap, newFieldIds, newFields);
+
+                                // Add new fields.
+                                CopyFields(pendingSnap, newFieldIds, newFields);
+                                
+                                // Create new snapshot.
+                                Snap* newSnap = new Snap(pendingSnap->GetTypeName(), pendingSnap->GetTypeId(), 
+                                    newFieldIds, newFields);
+
+                                (*newSnapshots)[curTypeId] = SPSnap(newSnap);
+
+                                snapshotFound = true;
+                            }
+                            else 
+                                (*newSnapshots)[curTypeId] = snapIt->second; // Just transfer exising snapshot.
+                        }
+
+                        // Handle situation when completely new snapshot is found.
+                        if (!snapshotFound)
+                            (*newSnapshots)[pendingSnap->GetTypeId()] = *it;
+
+                        snapshots = SharedPointer<std::map<int32_t, SPSnap>>(newSnapshots);
+                    }
+                    else
+                    {
+                        // Stop as we cannot move further.
+                        success = false;
+
+                        break;
+                    }
+                }
+
+                if (success) 
+                {
+                    pending->erase(pending->begin(), pending->end());
+
+                    ver = pendingVer;
+                }
+
+                cs->Leave();
+
+                return success;
+            }
+
+            void PortableMetadataManager::CopyFields(Snap* snap, std::set<int32_t>* fieldIds, 
+                std::map<std::string, int32_t>* fields)
+            {
+                if (snap && snap->HasFields())
+                {
+                    std::set<int32_t>* snapFieldIds = snap->GetFieldIds();
+                    std::map<std::string, int32_t>* snapFields = snap->GetFields();
+
+                    for (std::set<int32_t>::iterator oldIt = snapFieldIds->begin();
+                        oldIt != snapFieldIds->end(); ++oldIt)
+                        fieldIds->insert(*oldIt);
+
+                    for (std::map<std::string, int32_t>::iterator newFieldsIt = snapFields->begin();
+                        newFieldsIt != snapFields->end(); ++newFieldsIt)
+                        (*fields)[newFieldsIt->first] = newFieldsIt->second;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_snapshot.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_snapshot.cpp b/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_snapshot.cpp
new file mode 100644
index 0000000..6ce5ab5
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_snapshot.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/portable/portable_metadata_snapshot.h"
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            PortableMetadataSnapshot::PortableMetadataSnapshot(std::string typeName, int32_t typeId, 
+                std::set<int32_t>* fieldIds, std::map<std::string, int32_t>* fields) : 
+                typeName(typeName), typeId(typeId), fieldIds(fieldIds), fields(fields)
+            {
+                // No-op.
+            }
+
+            PortableMetadataSnapshot::~PortableMetadataSnapshot()
+            {
+                delete fieldIds;
+                delete fields;
+            }
+
+            bool PortableMetadataSnapshot::ContainsFieldId(int32_t fieldId)
+            {
+                return fieldIds && fieldIds->count(fieldId) == 1;
+            }
+
+            std::string PortableMetadataSnapshot::GetTypeName()
+            {
+                return typeName;
+            }
+
+            int32_t PortableMetadataSnapshot::GetTypeId()
+            {
+                return typeId;
+            }
+
+            bool PortableMetadataSnapshot::HasFields()
+            {
+                return !fieldIds->empty();
+            }
+
+            std::set<int32_t>* PortableMetadataSnapshot::GetFieldIds()
+            {
+                return fieldIds;
+            }
+
+            std::map<std::string, int32_t>* PortableMetadataSnapshot::GetFields()
+            {
+                return fields;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_updater.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_updater.cpp b/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_updater.cpp
new file mode 100644
index 0000000..81c96d7
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_updater.cpp
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ignite/impl/portable/portable_metadata_updater.h"
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            PortableMetadataUpdater::~PortableMetadataUpdater()
+            {
+                // No-op.
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_updater_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_updater_impl.cpp b/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_updater_impl.cpp
new file mode 100644
index 0000000..07a1758
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/portable/portable_metadata_updater_impl.cpp
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/portable/portable_metadata_updater_impl.h"
+#include "ignite/impl/interop/interop_output_stream.h"
+#include "ignite/impl/portable/portable_writer_impl.h"
+#include "ignite/portable/portable_raw_writer.h"
+
+using namespace ignite::common::concurrent;
+using namespace ignite::common::java;
+using namespace ignite::impl;
+using namespace ignite::impl::interop;
+using namespace ignite::portable;
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace portable
+        {
+            /** Operation: Clear. */
+            const int32_t OP_METADATA = -1;
+
+            PortableMetadataUpdaterImpl::PortableMetadataUpdaterImpl(SharedPointer<IgniteEnvironment> env,
+                jobject javaRef) :  env(env), javaRef(javaRef)
+            {
+                // No-op.
+            }
+
+            PortableMetadataUpdaterImpl::~PortableMetadataUpdaterImpl()
+            {
+                // No-op.
+            }
+
+            bool PortableMetadataUpdaterImpl::Update(Snap* snap, IgniteError* err)
+            {
+                JniErrorInfo jniErr;
+
+                SharedPointer<InteropMemory> mem = env.Get()->AllocateMemory();
+
+                InteropOutputStream out(mem.Get());
+                PortableWriterImpl writer(&out, NULL);
+                PortableRawWriter rawWriter(&writer);
+
+                // We always pass only one meta at a time in current implementation for simplicity.
+                rawWriter.WriteInt32(1);
+
+                rawWriter.WriteInt32(snap->GetTypeId());
+                rawWriter.WriteString(snap->GetTypeName());
+                rawWriter.WriteString(NULL); // Affinity key is not supported for now.
+                
+                if (snap->HasFields())
+                {
+                    std::map<std::string, int32_t>* fields = snap->GetFields();
+
+                    rawWriter.WriteInt32(static_cast<int32_t>(fields->size()));
+
+                    for (std::map<std::string, int32_t>::iterator it = fields->begin(); it != fields->end(); ++it)
+                    {
+                        rawWriter.WriteString(it->first);
+                        rawWriter.WriteInt32(it->second);
+                    }
+                }
+                else
+                    rawWriter.WriteInt32(0);
+
+                out.Synchronize();
+
+                long long res = env.Get()->Context()->TargetInStreamOutLong(javaRef, OP_METADATA, mem.Get()->PointerLong(), &jniErr);
+
+                IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
+                    return res == 1;
+                else
+                    return false;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/portable/portable_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/portable/portable_reader_impl.cpp b/modules/platform/src/main/cpp/core/src/impl/portable/portable_reader_impl.cpp
new file mode 100644
index 0000000..753ec25
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/portable/portable_reader_impl.cpp
@@ -0,0 +1,683 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/impl/portable/portable_common.h"
+#include "ignite/impl/portable/portable_id_resolver.h"
+#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/impl/portable/portable_utils.h"
+#include "ignite/portable/portable_type.h"
+#include "ignite/ignite_error.h"
+
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+using namespace ignite::portable;
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace portable
+        {
+            PortableReaderImpl::PortableReaderImpl(InteropInputStream* stream, PortableIdResolver* idRslvr,
+                int32_t pos, bool usrType, int32_t typeId, int32_t hashCode, int32_t len, int32_t rawOff) :
+                stream(stream), idRslvr(idRslvr), pos(pos), usrType(usrType), typeId(typeId), 
+                hashCode(hashCode), len(len), rawOff(rawOff), rawMode(false), 
+                elemIdGen(0), elemId(0), elemCnt(-1), elemRead(0)
+            {
+                // No-op.
+            }
+
+            PortableReaderImpl::PortableReaderImpl(InteropInputStream* stream) :
+                stream(stream), idRslvr(NULL), pos(0), usrType(false), typeId(0), hashCode(0), 
+                len(0), rawOff(0), rawMode(true),
+                elemIdGen(0), elemId(0), elemCnt(-1), elemRead(0)
+            {
+                // No-op.
+            }
+
+            int8_t PortableReaderImpl::ReadInt8()
+            {
+                return ReadRaw<int8_t>(PortableUtils::ReadInt8);                
+            }
+            
+            int32_t PortableReaderImpl::ReadInt8Array(int8_t* res, const int32_t len)
+            {
+                return ReadRawArray<int8_t>(res, len, PortableUtils::ReadInt8Array, IGNITE_TYPE_ARRAY_BYTE);
+            }
+
+            int8_t PortableReaderImpl::ReadInt8(const char* fieldName)
+            {
+                return Read(fieldName, PortableUtils::ReadInt8, IGNITE_TYPE_BYTE, static_cast<int8_t>(0));
+            }
+
+            int32_t PortableReaderImpl::ReadInt8Array(const char* fieldName, int8_t* res, const int32_t len)
+            {
+                return ReadArray<int8_t>(fieldName, res, len,PortableUtils::ReadInt8Array, IGNITE_TYPE_ARRAY_BYTE);
+            }
+
+            bool PortableReaderImpl::ReadBool()
+            {
+                return ReadRaw<bool>(PortableUtils::ReadBool);
+            }
+
+            int32_t PortableReaderImpl::ReadBoolArray(bool* res, const int32_t len)
+            {
+                return ReadRawArray<bool>(res, len, PortableUtils::ReadBoolArray, IGNITE_TYPE_ARRAY_BOOL);
+            }
+
+            bool PortableReaderImpl::ReadBool(const char* fieldName)
+            {
+                return Read(fieldName, PortableUtils::ReadBool, IGNITE_TYPE_BOOL, static_cast<bool>(0));
+            }
+
+            int32_t PortableReaderImpl::ReadBoolArray(const char* fieldName, bool* res, const int32_t len)
+            {
+                return ReadArray<bool>(fieldName, res, len,PortableUtils::ReadBoolArray, IGNITE_TYPE_ARRAY_BOOL);
+            }
+
+            int16_t PortableReaderImpl::ReadInt16()
+            {
+                return ReadRaw<int16_t>(PortableUtils::ReadInt16);
+            }
+
+            int32_t PortableReaderImpl::ReadInt16Array(int16_t* res, const int32_t len)
+            {
+                return ReadRawArray<int16_t>(res, len, PortableUtils::ReadInt16Array, IGNITE_TYPE_ARRAY_SHORT);
+            }
+
+            int16_t PortableReaderImpl::ReadInt16(const char* fieldName)
+            {
+                return Read(fieldName, PortableUtils::ReadInt16, IGNITE_TYPE_SHORT, static_cast<int16_t>(0));
+            }
+
+            int32_t PortableReaderImpl::ReadInt16Array(const char* fieldName, int16_t* res, const int32_t len)
+            {
+                return ReadArray<int16_t>(fieldName, res, len, PortableUtils::ReadInt16Array, IGNITE_TYPE_ARRAY_SHORT);
+            }
+
+            uint16_t PortableReaderImpl::ReadUInt16()
+            {
+                return ReadRaw<uint16_t>(PortableUtils::ReadUInt16);
+            }
+
+            int32_t PortableReaderImpl::ReadUInt16Array(uint16_t* res, const int32_t len)
+            {
+                return ReadRawArray<uint16_t>(res, len, PortableUtils::ReadUInt16Array, IGNITE_TYPE_ARRAY_CHAR);
+            }
+
+            uint16_t PortableReaderImpl::ReadUInt16(const char* fieldName)
+            {
+                return Read(fieldName, PortableUtils::ReadUInt16, IGNITE_TYPE_CHAR, static_cast<uint16_t>(0));
+            }
+
+            int32_t PortableReaderImpl::ReadUInt16Array(const char* fieldName, uint16_t* res, const int32_t len)
+            {
+                return ReadArray<uint16_t>(fieldName, res, len,PortableUtils::ReadUInt16Array, IGNITE_TYPE_ARRAY_CHAR);
+            }
+
+            int32_t PortableReaderImpl::ReadInt32()
+            {
+                return ReadRaw<int32_t>(PortableUtils::ReadInt32);
+            }
+
+            int32_t PortableReaderImpl::ReadInt32Array(int32_t* res, const int32_t len)
+            {
+                return ReadRawArray<int32_t>(res, len, PortableUtils::ReadInt32Array, IGNITE_TYPE_ARRAY_INT);
+            }
+
+            int32_t PortableReaderImpl::ReadInt32(const char* fieldName)
+            {
+                return Read(fieldName, PortableUtils::ReadInt32, IGNITE_TYPE_INT, static_cast<int32_t>(0));
+            }
+
+            int32_t PortableReaderImpl::ReadInt32Array(const char* fieldName, int32_t* res, const int32_t len)
+            {
+                return ReadArray<int32_t>(fieldName, res, len,PortableUtils::ReadInt32Array, IGNITE_TYPE_ARRAY_INT);
+            }
+
+            int64_t PortableReaderImpl::ReadInt64()
+            {
+                return ReadRaw<int64_t>(PortableUtils::ReadInt64);
+            }
+
+            int32_t PortableReaderImpl::ReadInt64Array(int64_t* res, const int32_t len)
+            {
+                return ReadRawArray<int64_t>(res, len, PortableUtils::ReadInt64Array, IGNITE_TYPE_ARRAY_LONG);
+            }
+
+            int64_t PortableReaderImpl::ReadInt64(const char* fieldName)
+            {
+                return Read(fieldName, PortableUtils::ReadInt64, IGNITE_TYPE_LONG, static_cast<int64_t>(0));
+            }
+
+            int32_t PortableReaderImpl::ReadInt64Array(const char* fieldName, int64_t* res, const int32_t len)
+            {
+                return ReadArray<int64_t>(fieldName, res, len,PortableUtils::ReadInt64Array, IGNITE_TYPE_ARRAY_LONG);
+            }
+
+            float PortableReaderImpl::ReadFloat()
+            {
+                return ReadRaw<float>(PortableUtils::ReadFloat);
+            }
+
+            int32_t PortableReaderImpl::ReadFloatArray(float* res, const int32_t len)
+            {
+                return ReadRawArray<float>(res, len, PortableUtils::ReadFloatArray, IGNITE_TYPE_ARRAY_FLOAT);
+            }
+
+            float PortableReaderImpl::ReadFloat(const char* fieldName)
+            {
+                return Read(fieldName, PortableUtils::ReadFloat, IGNITE_TYPE_FLOAT, static_cast<float>(0));
+            }
+
+            int32_t PortableReaderImpl::ReadFloatArray(const char* fieldName, float* res, const int32_t len)
+            {
+                return ReadArray<float>(fieldName, res, len,PortableUtils::ReadFloatArray, IGNITE_TYPE_ARRAY_FLOAT);
+            }
+
+            double PortableReaderImpl::ReadDouble()
+            {
+                return ReadRaw<double>(PortableUtils::ReadDouble);
+            }
+
+            int32_t PortableReaderImpl::ReadDoubleArray(double* res, const int32_t len)
+            {
+                return ReadRawArray<double>(res, len, PortableUtils::ReadDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE);
+            }
+
+            double PortableReaderImpl::ReadDouble(const char* fieldName)
+            {
+                return Read(fieldName, PortableUtils::ReadDouble, IGNITE_TYPE_DOUBLE, static_cast<double>(0));
+            }
+
+            int32_t PortableReaderImpl::ReadDoubleArray(const char* fieldName, double* res, const int32_t len)
+            {
+                return ReadArray<double>(fieldName, res, len,PortableUtils::ReadDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE);
+            }
+
+            Guid PortableReaderImpl::ReadGuid()
+            {
+                CheckRawMode(true);
+                CheckSingleMode(true);
+
+                return ReadNullable(stream, PortableUtils::ReadGuid, IGNITE_TYPE_UUID);
+            }
+
+            int32_t PortableReaderImpl::ReadGuidArray(Guid* res, const int32_t len)
+            {
+                CheckRawMode(true);
+                CheckSingleMode(true);
+
+                return ReadArrayInternal<Guid>(res, len, stream, ReadGuidArrayInternal, IGNITE_TYPE_ARRAY_UUID);
+            }
+
+            Guid PortableReaderImpl::ReadGuid(const char* fieldName)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+                int32_t fieldLen = SeekField(fieldId);
+
+                if (fieldLen > 0)
+                    return ReadNullable(stream, PortableUtils::ReadGuid, IGNITE_TYPE_UUID);
+
+                return Guid();
+            }
+
+            int32_t PortableReaderImpl::ReadGuidArray(const char* fieldName, Guid* res, const int32_t len)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                int32_t pos = stream->Position();
+
+                int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+                int32_t fieldLen = SeekField(fieldId);
+
+                if (fieldLen > 0) {
+                    int32_t realLen = ReadArrayInternal<Guid>(res, len, stream, ReadGuidArrayInternal, IGNITE_TYPE_ARRAY_UUID);
+
+                    // If actual read didn't occur return to initial position so that we do not perform 
+                    // N jumps to find the field again, where N is total amount of fields.
+                    if (realLen != -1 && (!res || realLen > len))
+                        stream->Position(pos);
+
+                    return realLen;
+                }
+
+                return -1;
+            }
+
+            void PortableReaderImpl::ReadGuidArrayInternal(InteropInputStream* stream, Guid* res, const int32_t len)
+            {
+                for (int i = 0; i < len; i++)
+                    *(res + i) = ReadNullable<Guid>(stream, PortableUtils::ReadGuid, IGNITE_TYPE_UUID);
+            }
+
+            int32_t PortableReaderImpl::ReadString(char* res, const int32_t len)
+            {
+                CheckRawMode(true);
+                CheckSingleMode(true);
+
+                return ReadStringInternal(res, len);
+            }
+
+            int32_t PortableReaderImpl::ReadString(const char* fieldName, char* res, const int32_t len)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                int32_t pos = stream->Position();
+                
+                int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+                int32_t fieldLen = SeekField(fieldId);
+
+                if (fieldLen > 0) {
+                    int32_t realLen = ReadStringInternal(res, len);
+
+                    // If actual read didn't occur return to initial position so that we do not perform 
+                    // N jumps to find the field again, where N is total amount of fields.
+                    if (realLen != -1 && (!res || realLen > len))
+                        stream->Position(pos);
+
+                    return realLen;
+                }
+
+                return -1;
+            }
+
+            int32_t PortableReaderImpl::ReadStringArray(int32_t* size)
+            {
+                return StartContainerSession(true, IGNITE_TYPE_ARRAY_STRING, size);
+            }
+
+            int32_t PortableReaderImpl::ReadStringArray(const char* fieldName, int32_t* size)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+                int32_t fieldLen = SeekField(fieldId);
+
+                if (fieldLen > 0)
+                    return StartContainerSession(false, IGNITE_TYPE_ARRAY_STRING, size);
+                else {
+                    *size = -1;
+
+                    return ++elemIdGen;
+                }
+            }
+
+            int32_t PortableReaderImpl::ReadStringElement(int32_t id, char* res, const int32_t len)
+            {
+                CheckSession(id);
+
+                int32_t posBefore = stream->Position();
+
+                int32_t realLen = ReadStringInternal(res, len);
+
+                int32_t posAfter = stream->Position();
+
+                if (posAfter > posBefore && ++elemRead == elemCnt) {
+                    elemId = 0;
+                    elemCnt = -1;
+                    elemRead = 0;
+                }
+
+                return realLen;
+            }
+
+            int32_t PortableReaderImpl::ReadStringInternal(char* res, const int32_t len)
+            {
+                int8_t hdr = stream->ReadInt8();
+
+                if (hdr == IGNITE_TYPE_STRING) {
+                    bool utf8Mode = stream->ReadBool();
+                    int32_t realLen = stream->ReadInt32();
+
+                    if (res && len >= realLen) {
+                        if (utf8Mode)
+                        {
+                            for (int i = 0; i < realLen; i++)
+                                *(res + i) = static_cast<char>(stream->ReadInt8());
+                        }
+                        else
+                        {
+                            for (int i = 0; i < realLen; i++)
+                                *(res + i) = static_cast<char>(stream->ReadUInt16());
+                        }
+
+                        if (len > realLen)
+                            *(res + realLen) = 0; // Set NULL terminator if possible.
+                    }
+                    else
+                        stream->Position(stream->Position() - 6);
+
+                    return realLen;
+                }
+                else if (hdr != IGNITE_HDR_NULL)
+                    ThrowOnInvalidHeader(IGNITE_TYPE_ARRAY, hdr);
+
+                return -1;
+            }
+
+            int32_t PortableReaderImpl::ReadArray(int32_t* size)
+            {
+                return StartContainerSession(true, IGNITE_TYPE_ARRAY, size);
+            }
+
+            int32_t PortableReaderImpl::ReadArray(const char* fieldName, int32_t* size)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+                int32_t fieldLen = SeekField(fieldId);
+
+                if (fieldLen > 0)
+                    return StartContainerSession(false, IGNITE_TYPE_ARRAY, size);
+                else {
+                    *size = -1;
+
+                    return ++elemIdGen;
+                }
+            }
+
+            int32_t PortableReaderImpl::ReadCollection(CollectionType* typ, int32_t* size)
+            {
+                int32_t id = StartContainerSession(true, IGNITE_TYPE_COLLECTION, size);
+
+                if (*size == -1)
+                    *typ = IGNITE_COLLECTION_UNDEFINED;
+                else
+                    *typ = static_cast<CollectionType>(stream->ReadInt8());
+
+                return id;
+            }
+
+            int32_t PortableReaderImpl::ReadCollection(const char* fieldName, CollectionType* typ, int32_t* size)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+                int32_t fieldLen = SeekField(fieldId);
+
+                if (fieldLen > 0)
+                {
+                    int32_t id = StartContainerSession(false, IGNITE_TYPE_COLLECTION, size);
+
+                    if (*size == -1)
+                        *typ = IGNITE_COLLECTION_UNDEFINED;
+                    else
+                        *typ = static_cast<CollectionType>(stream->ReadInt8());
+
+                    return id;
+                }                    
+                else {
+                    *typ = IGNITE_COLLECTION_UNDEFINED;
+                    *size = -1;
+
+                    return ++elemIdGen;
+                }
+            }
+
+            int32_t PortableReaderImpl::ReadMap(MapType* typ, int32_t* size)
+            {
+                int32_t id = StartContainerSession(true, IGNITE_TYPE_MAP, size);
+
+                if (*size == -1)
+                    *typ = IGNITE_MAP_UNDEFINED;
+                else
+                    *typ = static_cast<MapType>(stream->ReadInt8());
+
+                return id;
+            }
+
+            int32_t PortableReaderImpl::ReadMap(const char* fieldName, MapType* typ, int32_t* size)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+                int32_t fieldLen = SeekField(fieldId);
+
+                if (fieldLen > 0)
+                {
+                    int32_t id = StartContainerSession(false, IGNITE_TYPE_MAP, size);
+
+                    if (*size == -1)
+                        *typ = IGNITE_MAP_UNDEFINED;
+                    else
+                        *typ = static_cast<MapType>(stream->ReadInt8());
+
+                    return id;
+                }
+                else {
+                    *typ = IGNITE_MAP_UNDEFINED;
+                    *size = -1;
+
+                    return ++elemIdGen;
+                }
+            }
+
+            bool PortableReaderImpl::HasNextElement(int32_t id)
+            {
+                return elemId == id && elemRead < elemCnt;
+            }
+
+            void PortableReaderImpl::SetRawMode()
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                stream->Position(pos + rawOff);
+                rawMode = true;
+            }
+
+            template <>
+            int8_t PortableReaderImpl::ReadTopObject<int8_t>()
+            {
+                return ReadTopObject0(IGNITE_TYPE_BYTE, PortableUtils::ReadInt8, static_cast<int8_t>(0));
+            }
+
+            template <>
+            bool PortableReaderImpl::ReadTopObject<bool>()
+            {
+                return ReadTopObject0(IGNITE_TYPE_BOOL, PortableUtils::ReadBool, static_cast<bool>(0));
+            }
+
+            template <>
+            int16_t PortableReaderImpl::ReadTopObject<int16_t>()
+            {
+                return ReadTopObject0(IGNITE_TYPE_SHORT, PortableUtils::ReadInt16, static_cast<int16_t>(0));
+            }
+
+            template <>
+            uint16_t PortableReaderImpl::ReadTopObject<uint16_t>()
+            {
+                return ReadTopObject0(IGNITE_TYPE_CHAR, PortableUtils::ReadUInt16, static_cast<uint16_t>(0));
+            }
+
+            template <>
+            int32_t PortableReaderImpl::ReadTopObject<int32_t>()
+            {
+                return ReadTopObject0(IGNITE_TYPE_INT, PortableUtils::ReadInt32, static_cast<int32_t>(0));
+            }
+
+            template <>
+            int64_t PortableReaderImpl::ReadTopObject<int64_t>()
+            {
+                return ReadTopObject0(IGNITE_TYPE_LONG, PortableUtils::ReadInt64, static_cast<int64_t>(0));
+            }
+
+            template <>
+            float PortableReaderImpl::ReadTopObject<float>()
+            {
+                return ReadTopObject0(IGNITE_TYPE_FLOAT, PortableUtils::ReadFloat, static_cast<float>(0));
+            }
+
+            template <>
+            double PortableReaderImpl::ReadTopObject<double>()
+            {
+                return ReadTopObject0(IGNITE_TYPE_DOUBLE, PortableUtils::ReadDouble, static_cast<double>(0));
+            }
+
+            template <>
+            Guid PortableReaderImpl::ReadTopObject<Guid>()
+            {
+                int8_t typeId = stream->ReadInt8();
+
+                if (typeId == IGNITE_TYPE_UUID)
+                    return PortableUtils::ReadGuid(stream);
+                else if (typeId == IGNITE_HDR_NULL)
+                    return Guid();
+                else {
+                    int32_t pos = stream->Position() - 1;
+
+                    IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", IGNITE_TYPE_UUID, "actual", typeId)
+                }
+            }
+
+            InteropInputStream* PortableReaderImpl::GetStream()
+            {
+                return stream;
+            }
+
+            int32_t PortableReaderImpl::SeekField(const int32_t fieldId)
+            {
+                // We assume that it is very likely that fields are read in the same
+                // order as they were initially written. So we start seeking field
+                // from current stream position making a "loop" up to this position.
+                int32_t marker = stream->Position();
+
+                for (int32_t curPos = marker; curPos < pos + rawOff;)
+                {
+                    int32_t curFieldId = stream->ReadInt32();
+                    int32_t curFieldLen = stream->ReadInt32();
+
+                    if (fieldId == curFieldId)
+                        return curFieldLen;
+                    else {
+                        curPos = stream->Position() + curFieldLen;
+
+                        stream->Position(curPos);
+                    }
+                }
+
+                stream->Position(pos + IGNITE_FULL_HDR_LEN);
+
+                for (int32_t curPos = stream->Position(); curPos < marker;)
+                {
+                    int32_t curFieldId = stream->ReadInt32();
+                    int32_t curFieldLen = stream->ReadInt32();
+
+                    if (fieldId == curFieldId)
+                        return curFieldLen;
+                    else {
+                        curPos = stream->Position() + curFieldLen;
+
+                        stream->Position(curPos);
+                    }
+                }
+
+                return -1;
+            }
+
+            void PortableReaderImpl::CheckRawMode(bool expected)
+            {
+                if (expected && !rawMode) {
+                    IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation can be performed only in raw mode.")
+                }
+                else if (!expected && rawMode) {
+                    IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation cannot be performed in raw mode.")
+                }
+            }
+
+            void PortableReaderImpl::CheckSingleMode(bool expected)
+            {
+                if (expected && elemId != 0) {
+                    IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation cannot be performed when container is being read.");
+                }
+                else if (!expected && elemId == 0) {
+                    IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation can be performed only when container is being read.");
+                }
+            }
+
+            int32_t PortableReaderImpl::StartContainerSession(bool expRawMode, int8_t expHdr, int32_t* size)
+            {
+                CheckRawMode(expRawMode);
+                CheckSingleMode(true);
+
+                int8_t hdr = stream->ReadInt8();
+
+                if (hdr == expHdr)
+                {
+                    int32_t cnt = stream->ReadInt32();
+
+                    if (cnt != 0) 
+                    {
+                        elemId = ++elemIdGen;
+                        elemCnt = cnt;
+                        elemRead = 0;
+
+                        *size = cnt;
+
+                        return elemId;
+                    }
+                    else
+                    {
+                        *size = 0;
+
+                        return ++elemIdGen;
+                    }
+                }
+                else if (hdr == IGNITE_HDR_NULL) {
+                    *size = -1;
+
+                    return ++elemIdGen;
+                }
+                else {
+                    ThrowOnInvalidHeader(expHdr, hdr);
+
+                    return 0;
+                }
+            }
+
+            void PortableReaderImpl::CheckSession(int32_t expSes)
+            {
+                if (elemId != expSes) {
+                    IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Containter read session has been finished or is not started yet.");
+                }
+            }
+
+            void PortableReaderImpl::ThrowOnInvalidHeader(int32_t pos, int8_t expHdr, int8_t hdr)
+            {
+                IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", expHdr, "actual", hdr)
+            }
+
+            void PortableReaderImpl::ThrowOnInvalidHeader(int8_t expHdr, int8_t hdr)
+            {
+                int32_t pos = stream->Position() - 1;
+
+                ThrowOnInvalidHeader(pos, expHdr, hdr);
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/portable/portable_utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/portable/portable_utils.cpp b/modules/platform/src/main/cpp/core/src/impl/portable/portable_utils.cpp
new file mode 100644
index 0000000..2f9c259
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/portable/portable_utils.cpp
@@ -0,0 +1,214 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/impl/portable/portable_utils.h"
+
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace portable
+        {
+            int8_t PortableUtils::ReadInt8(InteropInputStream* stream)
+            {
+                return stream->ReadInt8();
+            }
+
+            void PortableUtils::WriteInt8(InteropOutputStream* stream, int8_t val)
+            {
+                stream->WriteInt8(val); 
+            }
+
+            void PortableUtils::ReadInt8Array(InteropInputStream* stream, int8_t* res, const int32_t len)
+            {
+                stream->ReadInt8Array(res, len);
+            }
+
+            void PortableUtils::WriteInt8Array(InteropOutputStream* stream, const int8_t* val, const int32_t len)
+            {
+                stream->WriteInt8Array(val, len);
+            }
+
+            bool PortableUtils::ReadBool(InteropInputStream* stream)
+            {
+                return stream->ReadBool();
+            }
+
+            void PortableUtils::WriteBool(InteropOutputStream* stream, bool val)
+            {
+                stream->WriteBool(val);
+            }
+
+            void PortableUtils::ReadBoolArray(InteropInputStream* stream, bool* res, const int32_t len)
+            {
+                stream->ReadBoolArray(res, len);
+            }
+
+            void PortableUtils::WriteBoolArray(InteropOutputStream* stream, const bool* val, const int32_t len)
+            {
+                stream->WriteBoolArray(val, len);
+            }
+
+            int16_t PortableUtils::ReadInt16(InteropInputStream* stream)
+            {
+                return stream->ReadInt16();
+            }
+
+            void PortableUtils::WriteInt16(InteropOutputStream* stream, int16_t val)
+            {
+                stream->WriteInt16(val);
+            }
+
+            void PortableUtils::ReadInt16Array(InteropInputStream* stream, int16_t* res, const int32_t len)
+            {
+                stream->ReadInt16Array(res, len);
+            }
+            
+            void PortableUtils::WriteInt16Array(InteropOutputStream* stream, const int16_t* val, const int32_t len)
+            {
+                stream->WriteInt16Array(val, len);
+            }
+
+            uint16_t PortableUtils::ReadUInt16(InteropInputStream* stream)
+            {
+                return stream->ReadUInt16();
+            }
+
+            void PortableUtils::WriteUInt16(InteropOutputStream* stream, uint16_t val)
+            {
+                stream->WriteUInt16(val);
+            }
+
+            void PortableUtils::ReadUInt16Array(InteropInputStream* stream, uint16_t* res, const int32_t len)
+            {
+                stream->ReadUInt16Array(res, len);
+            }
+
+            void PortableUtils::WriteUInt16Array(InteropOutputStream* stream, const uint16_t* val, const int32_t len)
+            {
+                stream->WriteUInt16Array(val, len);
+            }
+
+            int32_t PortableUtils::ReadInt32(InteropInputStream* stream)
+            {
+                return stream->ReadInt32();
+            }
+
+            void PortableUtils::WriteInt32(InteropOutputStream* stream, int32_t val)
+            {
+                stream->WriteInt32(val);
+            }
+
+            void PortableUtils::ReadInt32Array(InteropInputStream* stream, int32_t* res, const int32_t len)
+            {
+                stream->ReadInt32Array(res, len);
+            }
+
+            void PortableUtils::WriteInt32Array(InteropOutputStream* stream, const int32_t* val, const int32_t len)
+            {
+                stream->WriteInt32Array(val, len);
+            }
+
+            int64_t PortableUtils::ReadInt64(InteropInputStream* stream)
+            {
+                return stream->ReadInt64();
+            }
+
+            void PortableUtils::WriteInt64(InteropOutputStream* stream, int64_t val)
+            {
+                stream->WriteInt64(val);
+            }
+
+            void PortableUtils::ReadInt64Array(InteropInputStream* stream, int64_t* res, const int32_t len)
+            {
+                stream->ReadInt64Array(res, len);
+            }
+
+            void PortableUtils::WriteInt64Array(InteropOutputStream* stream, const int64_t* val, const int32_t len)
+            {
+                stream->WriteInt64Array(val, len);
+            }
+
+            float PortableUtils::ReadFloat(InteropInputStream* stream)
+            {
+                return stream->ReadFloat();
+            }
+
+            void PortableUtils::WriteFloat(InteropOutputStream* stream, float val)
+            {
+                stream->WriteFloat(val);
+            }
+
+            void PortableUtils::ReadFloatArray(InteropInputStream* stream, float* res, const int32_t len)
+            {
+                stream->ReadFloatArray(res, len);
+            }
+
+            void PortableUtils::WriteFloatArray(InteropOutputStream* stream, const float* val, const int32_t len)
+            {
+                stream->WriteFloatArray(val, len);
+            }
+
+            double PortableUtils::ReadDouble(InteropInputStream* stream)
+            {
+                return stream->ReadDouble();
+            }
+
+            void PortableUtils::WriteDouble(InteropOutputStream* stream, double val)
+            {
+                stream->WriteDouble(val);
+            }
+
+            void PortableUtils::ReadDoubleArray(InteropInputStream* stream, double* res, const int32_t len)
+            {
+                stream->ReadDoubleArray(res, len);
+            }
+
+            void PortableUtils::WriteDoubleArray(InteropOutputStream* stream, const double* val, const int32_t len)
+            {
+                stream->WriteDoubleArray(val, len);
+            }
+
+            Guid PortableUtils::ReadGuid(interop::InteropInputStream* stream)
+            {
+                int64_t most = stream->ReadInt64();
+                int64_t least = stream->ReadInt64();
+
+                return Guid(most, least);
+            }
+
+            void PortableUtils::WriteGuid(interop::InteropOutputStream* stream, const Guid val)
+            {
+                stream->WriteInt64(val.GetMostSignificantBits());
+                stream->WriteInt64(val.GetLeastSignificantBits());
+            }
+
+            void PortableUtils::WriteString(interop::InteropOutputStream* stream, const char* val, const int32_t len)
+            {
+                stream->WriteBool(false);
+                stream->WriteInt32(len);
+
+                for (int i = 0; i < len; i++)
+                    stream->WriteUInt16(*(val + i));
+            }
+        }
+    }
+}
\ No newline at end of file


[42/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_reader_impl.h b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
new file mode 100644
index 0000000..7d82aa2
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
@@ -0,0 +1,1130 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_PORTABLE_READER
+#define _IGNITE_IMPL_PORTABLE_READER
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#include "ignite/impl/interop/interop_input_stream.h"
+#include "ignite/impl/portable/portable_common.h"
+#include "ignite/impl/portable/portable_id_resolver.h"
+#include "ignite/impl/portable/portable_utils.h"
+#include "ignite/impl/utils.h"
+#include "ignite/portable/portable_consts.h"
+#include "ignite/portable/portable_type.h"
+#include "ignite/guid.h"
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace portable
+        {
+            /**
+             * Internal implementation of portable reader.
+             */
+            class IGNITE_IMPORT_EXPORT PortableReaderImpl
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param stream Interop stream.
+                 * @param idRslvr Portable ID resolver.
+                 * @param pos Object position in the stream.
+                 * @param usrType user type flag.
+                 * @param typeId Type ID.
+                 * @param hashcode Hash code.
+                 * @param len Length in bytes.
+                 * @param rawOff Raw data offset.
+                 */
+                PortableReaderImpl(interop::InteropInputStream* stream, PortableIdResolver* idRslvr,                     
+                    int32_t pos, bool usrType, int32_t typeId, int32_t hashCode, int32_t len, int32_t rawOff);
+
+                /**
+                 * Constructor used to construct light-weight reader allowing only raw operations 
+                 * and read of primitives.
+                 *
+                 * @param stream Interop stream.
+                 */
+                PortableReaderImpl(interop::InteropInputStream* stream);
+
+                /**
+                 * Read 8-byte signed integer. Maps to "byte" type in Java.
+                 *
+                 * @return Result.
+                 */
+                int8_t ReadInt8();
+
+                /**
+                 * Read array of 8-byte signed integers. Maps to "byte[]" type in Java.
+                 *
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadInt8Array(int8_t* res, const int32_t len);
+
+                /**
+                 * Read 8-byte signed integer. Maps to "byte" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @return Result.
+                 */
+                int8_t ReadInt8(const char* fieldName);
+
+                /**
+                 * Read array of 8-byte signed integers. Maps to "byte[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadInt8Array(const char* fieldName, int8_t* res, const int32_t len);
+
+                /**
+                 * Read bool. Maps to "boolean" type in Java.
+                 *
+                 * @return Result.
+                 */
+                bool ReadBool();
+
+                /**
+                 * Read bool array. Maps to "boolean[]" type in Java.
+                 *
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadBoolArray(bool* res, const int32_t len);
+
+                /**
+                 * Read bool. Maps to "short" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @return Result.
+                 */
+                bool ReadBool(const char* fieldName);
+
+                /**
+                 * Read bool array. Maps to "bool[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadBoolArray(const char* fieldName, bool* res, const int32_t len);
+
+                /**
+                 * Read 16-byte signed integer. Maps to "short" type in Java.
+                 *
+                 * @return Result.
+                 */
+                int16_t ReadInt16();
+
+                /**
+                 * Read array of 16-byte signed integers. Maps to "short[]" type in Java.
+                 *
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadInt16Array(int16_t* res, const int32_t len);
+
+                /**
+                 * Read 16-byte signed integer. Maps to "short" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @return Result.
+                 */
+                int16_t ReadInt16(const char* fieldName);
+
+                /**
+                 * Read array of 16-byte signed integers. Maps to "short[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *      -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadInt16Array(const char* fieldName, int16_t* res, const int32_t len);
+
+                /**
+                 * Read 16-byte unsigned integer. Maps to "char" type in Java.
+                 *
+                 * @return Result.
+                 */
+                uint16_t ReadUInt16();
+
+                /**
+                 * Read array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+                 *
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadUInt16Array(uint16_t* res, const int32_t len);
+
+                /**
+                 * Read 16-byte unsigned integer. Maps to "char" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @return Result.
+                 */
+                uint16_t ReadUInt16(const char* fieldName);
+
+                /**
+                 * Read array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadUInt16Array(const char* fieldName, uint16_t* res, const int32_t len);
+
+                /**
+                 * Read 32-byte signed integer. Maps to "int" type in Java.
+                 *
+                 * @return Result.
+                 */
+                int32_t ReadInt32();
+
+                /**
+                 * Read array of 32-byte signed integers. Maps to "int[]" type in Java.
+                 *
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadInt32Array(int32_t* res, const int32_t len);
+
+                /**
+                 * Read 32-byte signed integer. Maps to "int" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @return Result.
+                 */
+                int32_t ReadInt32(const char* fieldName);
+
+                /**
+                 * Read array of 32-byte signed integers. Maps to "int[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadInt32Array(const char* fieldName, int32_t* res, const int32_t len);
+
+                /**
+                 * Read 64-byte signed integer. Maps to "long" type in Java.
+                 *
+                 * @return Result.
+                 */
+                int64_t ReadInt64();
+
+                /**
+                 * Read array of 64-byte signed integers. Maps to "long[]" type in Java.
+                 *
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadInt64Array(int64_t* res, const int32_t len);
+
+                /**
+                 * Read 64-byte signed integer. Maps to "long" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @return Result.
+                 */
+                int64_t ReadInt64(const char* fieldName);
+
+                /**
+                 * Read array of 64-byte signed integers. Maps to "long[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadInt64Array(const char* fieldName, int64_t* res, const int32_t len);
+
+                /**
+                 * Read float. Maps to "float" type in Java.
+                 *
+                 * @return Result.
+                 */
+                float ReadFloat();
+
+                /**
+                 * Read float array. Maps to "float[]" type in Java.
+                 *
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadFloatArray(float* res, const int32_t len);
+
+                /**
+                 * Read float. Maps to "float" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @return Result.
+                 */
+                float ReadFloat(const char* fieldName);
+
+                /**
+                 * Read float array. Maps to "float[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadFloatArray(const char* fieldName, float* res, const int32_t len);
+
+                /**
+                 * Read double. Maps to "double" type in Java.
+                 *
+                 * @return Result.
+                 */
+                double ReadDouble();
+                
+                /**
+                 * Read double array. Maps to "double[]" type in Java.
+                 *
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadDoubleArray(double* res, const int32_t len);
+
+                /**
+                 * Read double. Maps to "double" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @return Result.
+                 */
+                double ReadDouble(const char* fieldName);
+
+                /**
+                 * Read double array. Maps to "double[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadDoubleArray(const char* fieldName, double* res, const int32_t len);
+
+                /**
+                 * Read Guid. Maps to "UUID" type in Java.
+                 *
+                 * @return Result.
+                 */
+                Guid ReadGuid();
+
+                /**
+                 * Read array of Guids. Maps to "UUID[]" type in Java.
+                 *
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadGuidArray(Guid* res, const int32_t len);
+
+                /**
+                 * Read Guid. Maps to "UUID" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @return Result.
+                 */
+                Guid ReadGuid(const char* fieldName);
+
+                /**
+                 * Read array of Guids. Maps to "UUID[]" type in Java.
+                 *
+                 * @param fieldName Field name.
+                 * @param res Array to store data to.
+                 * @param len Expected length of array.                 
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadGuidArray(const char* fieldName, Guid* res, const int32_t len);
+
+                /**
+                 * Read string.
+                 *
+                 * @param len Expected length of string.
+                 * @param res Array to store data to (should be able to acocmodate null-terminator).
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadString(char* res, const int32_t len);
+
+                /**
+                 * Read string.
+                 *
+                 * @param fieldName Field name.                 
+                 * @param res Array to store data to (should be able to acocmodate null-terminator).
+                 * @param len Expected length of string.
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadString(const char* fieldName, char* res, const int32_t len);
+                
+                /**
+                 * Start string array read.
+                 *
+                 * @param size Array size.
+                 * @return Read session ID.
+                 */
+                int32_t ReadStringArray(int32_t* size);
+
+                /**
+                 * Start string array read.
+                 *
+                 * @param fieldName Field name.
+                 * @param size Array size.
+                 * @return Read session ID.
+                 */
+                int32_t ReadStringArray(const char* fieldName, int32_t* size);
+
+                /**
+                 * Read string element.
+                 *
+                 * @param id Session ID.
+                 * @param len Expected length of string.
+                 * @param res Array to store data to (should be able to acocmodate null-terminator).
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 */
+                int32_t ReadStringElement(int32_t id, char* res, const int32_t len);
+
+                /**
+                 * Start array read.
+                 *
+                 * @param size Array size.
+                 * @return Read session ID.
+                 */
+                int32_t ReadArray(int32_t* size);
+
+                /**
+                 * Start array read.
+                 *
+                 * @param fieldName Field name.
+                 * @param size Array size.
+                 * @return Read session ID.
+                 */
+                int32_t ReadArray(const char* fieldName, int32_t* size);
+
+                /**
+                 * Start collection read.
+                 *
+                 * @param typ Collection type.
+                 * @param size Collection size.
+                 * @return Read session ID.
+                 */
+                int32_t ReadCollection(ignite::portable::CollectionType* typ, int32_t* size);
+
+                /**
+                 * Start collection read.
+                 *
+                 * @param fieldName Field name.
+                 * @param typ Collection type.
+                 * @param size Collection size.
+                 * @return Read session ID.
+                 */
+                int32_t ReadCollection(const char* fieldName, ignite::portable::CollectionType* typ, int32_t* size);
+
+                /**
+                 * Start map read.
+                 *
+                 * @param typ Map type.
+                 * @param size Map size.
+                 * @return Read session ID.
+                 */
+                int32_t ReadMap(ignite::portable::MapType* typ, int32_t* size);
+
+                /**
+                 * Start map read.
+                 *
+                 * @param fieldName Field name.
+                 * @param typ Map type.
+                 * @param size Map size.
+                 * @return Read session ID.
+                 */
+                int32_t ReadMap(const char* fieldName, ignite::portable::MapType* typ, int32_t* size);
+
+                /**
+                 * Check whether next value exists.
+                 *
+                 * @param id Session ID.
+                 * @return True if next element exists for the given session.
+                 */
+                bool HasNextElement(int32_t id);
+
+                /**
+                 * Read element.
+                 *
+                 * @param id Session ID.
+                 * @return Value.
+                 */
+                template<typename T>
+                T ReadElement(const int32_t id)
+                {
+                    CheckSession(id);
+
+                    if (++elemRead == elemCnt) {
+                        elemId = 0;
+                        elemCnt = -1;
+                        elemRead = 0;
+                    }
+
+                    return ReadTopObject<T>();
+                }
+
+                /**
+                 * Read element.
+                 *
+                 * @param id Session ID.
+                 * @param key Key.
+                 * @param val Value.
+                 */
+                template<typename K, typename V>
+                void ReadElement(const int32_t id, K* key, V* val)
+                {
+                    CheckSession(id);
+
+                    if (++elemRead == elemCnt) {
+                        elemId = 0;
+                        elemCnt = -1;
+                        elemRead = 0;
+                    }
+
+                    *key = ReadTopObject<K>();
+                    *val = ReadTopObject<V>();
+                }
+                
+                /**
+                 * Read object.
+                 *
+                 * @return Object.
+                 */
+                template<typename T>
+                T ReadObject()
+                {
+                    CheckRawMode(true);
+
+                    return ReadTopObject<T>();
+                }
+
+                /**
+                 * Read object.
+                 *
+                 * @param fieldName Field name.
+                 * @return Object.
+                 */
+                template<typename T>
+                T ReadObject(const char* fieldName)
+                {
+                    CheckRawMode(false);
+
+                    int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName); 
+                        
+                    int32_t fieldLen = SeekField(fieldId); 
+                        
+                    if (fieldLen > 0) 
+                        return ReadTopObject<T>();
+                    
+                    return GetNull<T>();
+                }
+
+                /**
+                 * Set raw mode.
+                 */
+                void SetRawMode();
+
+                /**
+                 * Read object.
+                 *
+                 * @param obj Object to write.
+                 */
+                template<typename T>
+                T ReadTopObject()
+                {
+                    int32_t pos = stream->Position();
+                    int8_t hdr = stream->ReadInt8();
+
+                    if (hdr == IGNITE_HDR_NULL)
+                        return GetNull<T>();
+                    else if (hdr == IGNITE_HDR_HND) {
+                        IGNITE_ERROR_1(ignite::IgniteError::IGNITE_ERR_PORTABLE, "Circular references are not supported.");
+                    }
+                    else if (hdr == IGNITE_TYPE_PORTABLE)
+                    {
+                        int32_t portLen = stream->ReadInt32(); // Total length of portable object.
+                        int32_t curPos = stream->Position();
+                        int32_t portOff = stream->ReadInt32(curPos + portLen);
+
+                        stream->Position(curPos + portOff); // Position stream right on the object.
+
+                        T val = ReadTopObject<T>();
+
+                        stream->Position(curPos + portLen + 4); // Position stream after portable.
+
+                        return val;
+                    }
+                    else
+                    {
+                        bool usrType = stream->ReadBool();
+                        int32_t typeId = stream->ReadInt32();
+                        int32_t hashCode = stream->ReadInt32();
+                        int32_t len = stream->ReadInt32();
+                        int32_t rawOff = stream->ReadInt32();
+
+                        ignite::portable::PortableType<T> type;
+                        TemplatedPortableIdResolver<T> idRslvr(type);
+                        PortableReaderImpl readerImpl(stream, &idRslvr, pos, usrType, typeId, hashCode, len, rawOff);
+                        ignite::portable::PortableReader reader(&readerImpl);
+
+                        T val = type.Read(reader);
+
+                        stream->Position(pos + len);
+
+                        return val;
+                    }
+                }
+
+                /**
+                 * Get NULL value for the given type.
+                 */
+                template<typename T>
+                T GetNull()
+                {
+                    ignite::portable::PortableType<T> type;
+
+                    return type.GetNull();
+                }
+
+                /**
+                 * Get underlying stream.
+                 *
+                 * @return Stream.
+                 */
+                impl::interop::InteropInputStream* GetStream();
+            private:
+                /** Underlying stream. */
+                interop::InteropInputStream* stream;   
+                
+                /** ID resolver. */
+                PortableIdResolver* idRslvr;           
+
+                /** Position in the stream where this object starts. */
+                int32_t pos;       
+                
+                /** Whether this is user type or system type. */
+                bool usrType;      
+                
+                /** Type ID as defined in the stream. */
+                int32_t typeId;    
+                
+                /** Hash code. */
+                int32_t hashCode;  
+                
+                /** Total object length in the stream. */
+                int32_t len;       
+                
+                /** Raw data offset. */
+                int32_t rawOff;    
+
+                /** Raw mode flag. */
+                bool rawMode;      
+
+                /** Elements read session ID generator. */
+                int32_t elemIdGen; 
+                
+                /** Elements read session ID. */
+                int32_t elemId;    
+                
+                /** Total amount of elements in collection. */
+                int32_t elemCnt;   
+                
+                /** Amount of elements read. */
+                int32_t elemRead;  
+
+                IGNITE_NO_COPY_ASSIGNMENT(PortableReaderImpl)
+
+                /**
+                 * Internal routine to read Guid array.
+                 *
+                 * @param stream Stream.
+                 * @param res Resulting array.
+                 * @param len Length.
+                 */
+                static void ReadGuidArrayInternal(
+                    interop::InteropInputStream* stream, 
+                    Guid* res,
+                    const int32_t len
+                );
+
+                /**
+                 * Read single value in raw mode.
+                 * 
+                 * @param stream Stream.
+                 * @param func Function to be invoked on stream.
+                 * @return Result.
+                 */
+                template<typename T>
+                T ReadRaw(
+                    T(*func) (interop::InteropInputStream*)
+                )
+                {
+                    {
+                        CheckRawMode(true);
+                        CheckSingleMode(true);
+
+                        return func(stream);
+                    }
+                }
+
+                /**
+                 * Read single value.
+                 *
+                 * @param fieldName Field name.
+                 * @param func Function to be invoked on stream.
+                 * @param epxHdr Expected header.
+                 * @param dflt Default value returned if field is not found.
+                 * @return Result.
+                 */
+                template<typename T>
+                T Read(
+                    const char* fieldName, 
+                    T(*func) (interop::InteropInputStream*), 
+                    const int8_t expHdr, 
+                    T dflt
+                )
+                {
+                    {
+                        CheckRawMode(false);
+                        CheckSingleMode(true);
+
+                        int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+                        int32_t fieldLen = SeekField(fieldId);
+
+                        if (fieldLen > 0)
+                        {
+                            int8_t typeId = stream->ReadInt8();
+
+                            if (typeId == expHdr)
+                                return func(stream);
+                            else if (typeId != IGNITE_HDR_NULL)
+                            {
+                                int32_t pos = stream->Position();
+
+                                IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid type ID", 
+                                    "position", pos, "expected", expHdr, "actual", typeId)
+                            }
+                        }
+
+                        return dflt;
+                    }
+                }
+
+                /**
+                 * Read array in raw mode.
+                 *
+                 * @param res Resulting array.
+                 * @param len Length.                 
+                 * @param func Function to be invoked on stream.
+                 * @param expHdr Expected header.
+                 * @return Length.
+                 */
+                template<typename T>
+                int32_t ReadRawArray(
+                    T* res,
+                    const int32_t len,
+                    void(*func)(interop::InteropInputStream*, T* const, const int32_t),
+                    const int8_t expHdr
+                )
+                {
+                    {
+                        CheckRawMode(true);
+                        CheckSingleMode(true);
+
+                        return ReadArrayInternal(res, len, stream, func, expHdr);
+                    }
+                }
+
+                /**
+                 * Read array.
+                 *
+                 * @param fieldName Field name.
+                 * @param res Resulting array.
+                 * @param len Length.
+                 * @param func Function to be invoked on stream.
+                 * @param expHdr Expected header.
+                 * @return Length.
+                 */
+                template<typename T>
+                int32_t ReadArray(
+                    const char* fieldName,
+                    T* res,
+                    const int32_t len,                    
+                    void(*func)(interop::InteropInputStream*, T* const, const int32_t),
+                    const int8_t expHdr
+                )
+                {
+                    {
+                        CheckRawMode(false);
+                        CheckSingleMode(true);
+
+                        int32_t pos = stream->Position();
+
+                        int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+                        int32_t fieldLen = SeekField(fieldId);
+
+                        if (fieldLen > 0) {
+                            int32_t realLen = ReadArrayInternal(res, len, stream, func, expHdr);
+
+                            // If actual read didn't occur return to initial position so that we do not perform 
+                            // N jumps to find the field again, where N is total amount of fields.
+                            if (realLen != -1 && (!res || realLen > len))
+                                stream->Position(pos);
+
+                            return realLen;
+                        }
+
+                        return -1;
+                    }
+                }
+
+                /**
+                 * Internal read array routine.
+                 *
+                 * @param res Resulting array.
+                 * @param len Length.                 
+                 * @param stream Stream.
+                 * @param func Function to be invoked on stream.
+                 * @param expHdr Expected header.
+                 * @return Length.
+                 */
+                template<typename T>
+                static int32_t ReadArrayInternal(
+                    T* res,
+                    const int32_t len,
+                    interop::InteropInputStream* stream,
+                    void(*func)(interop::InteropInputStream*, T* const, const int32_t),
+                    const int8_t expHdr
+                )
+                {
+                    {
+                        int8_t hdr = stream->ReadInt8();
+
+                        if (hdr == expHdr)
+                        {
+                            int32_t realLen = stream->ReadInt32();
+
+                            if (realLen == 0 || (res && len >= realLen))
+                                func(stream, res, realLen);
+                            else
+                                stream->Position(stream->Position() - 5);
+
+                            return realLen;
+                        }
+                        else if (hdr != IGNITE_HDR_NULL)
+                            ThrowOnInvalidHeader(stream->Position() - 1, expHdr, hdr);
+
+                        return -1;
+                    }
+                }
+
+                /**
+                 * Read nullable value.
+                 *
+                 * @param stream Stream.
+                 * @param func Function to be invoked on stream.
+                 * @param expHdr Expected header.
+                 */
+                template<typename T>
+                static T ReadNullable(
+                    interop::InteropInputStream* stream,
+                    T(*func)(interop::InteropInputStream*), 
+                    const int8_t expHdr
+                )
+                {
+                    {
+                        int8_t hdr = stream->ReadInt8();
+
+                        if (hdr == expHdr)
+                            return func(stream);
+                        else if (hdr == IGNITE_HDR_NULL)
+                            return Guid();
+                        else {
+                            ThrowOnInvalidHeader(stream->Position() - 1, expHdr, hdr);
+
+                            return Guid();
+                        }
+                    }
+                }
+
+                /**
+                 * Seek field with the given ID.
+                 *
+                 * @param fieldId Field ID.
+                 * @return Field length or -1 if field is not found.
+                 */
+                int32_t SeekField(const int32_t fieldId);
+
+                /**
+                 * Check raw mode.
+                 * 
+                 * @param expected Expected raw mode of the reader.
+                 */
+                void CheckRawMode(bool expected);
+
+                /**
+                 * Check whether reader is currently operating in single mode.
+                 *
+                 * @param expected Expected value.
+                 */
+                void CheckSingleMode(bool expected);
+
+                /**
+                 * Start new container reader session.
+                 *
+                 * @param expRawMode Expected raw mode.
+                 * @param expHdr Expected header.
+                 * @param size Container size.
+                 * @return Session ID.
+                 */
+                int32_t StartContainerSession(const bool expRawMode, const int8_t expHdr, int32_t* size);
+
+                /**
+                 * Check whether session ID matches.
+                 *
+                 * @param ses Expected session ID.
+                 */
+                void CheckSession(int32_t expSes);
+
+                /**
+                 * Throw an error due to invalid header.
+                 *
+                 * @param pos Position in the stream.
+                 * @param expHdr Expected header.
+                 * @param hdr Actual header.
+                 */
+                static void ThrowOnInvalidHeader(int32_t pos, int8_t expHdr, int8_t hdr);
+
+                /**
+                 * Throw an error due to invalid header.
+                 *
+                 * @param expHdr Expected header.
+                 * @param hdr Actual header.
+                 */
+                void ThrowOnInvalidHeader(int8_t expHdr, int8_t hdr);
+
+                /**
+                 * Internal string read routine.
+                 *
+                 * @param res Resulting array.
+                 * @param len Length of array.
+                 * @return Real array length.
+                 */
+                int32_t ReadStringInternal(char* res, const int32_t len);
+
+                /**
+                 * Read value.
+                 *
+                 * @param expHdr Expected header.
+                 * @param func Function to be applied to the stream.
+                 */
+                template<typename T>
+                T ReadTopObject0(const int8_t expHdr, T(*func) (ignite::impl::interop::InteropInputStream*))
+                {
+                    int8_t typeId = stream->ReadInt8();
+
+                    if (typeId == expHdr)
+                        return func(stream);
+                    else if (typeId == IGNITE_HDR_NULL)
+                        return GetNull<T>();
+                    else {
+                        int32_t pos = stream->Position() - 1;
+
+                        IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", expHdr, "actual", typeId)
+                    }
+                }
+
+                /**
+                 * Read value.
+                 *
+                 * @param expHdr Expected header.
+                 * @param func Function to be applied to the stream.
+                 * @param dflt Default value.
+                 */
+                template<typename T>
+                T ReadTopObject0(const int8_t expHdr, T(*func) (ignite::impl::interop::InteropInputStream*), T dflt)
+                {
+                    int8_t typeId = stream->ReadInt8();
+
+                    if (typeId == expHdr)
+                        return func(stream);
+                    else if (typeId == IGNITE_HDR_NULL)
+                        return dflt;
+                    else {
+                        int32_t pos = stream->Position() - 1;
+
+                        IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", expHdr, "actual", typeId)
+                    }
+                }
+            };
+
+            template<>
+            int8_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int8_t>();
+
+            template<>
+            bool IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<bool>();
+
+            template<>
+            int16_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int16_t>();
+
+            template<>
+            uint16_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<uint16_t>();
+
+            template<>
+            int32_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int32_t>();
+
+            template<>
+            int64_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int64_t>();
+
+            template<>
+            float IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<float>();
+
+            template<>
+            double IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<double>();
+
+            
+            template<>
+            Guid IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<Guid>();
+
+            template<>
+            inline std::string IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<std::string>()
+            {
+                int8_t typeId = stream->ReadInt8();
+
+                if (typeId == IGNITE_TYPE_STRING)
+                {
+                    bool utf8Mode = stream->ReadBool();
+                    int32_t realLen = stream->ReadInt32();
+
+                    ignite::impl::utils::SafeArray<char> arr(realLen + 1);
+
+                    if (utf8Mode)
+                    {
+                        for (int i = 0; i < realLen; i++)
+                            *(arr.target + i) = static_cast<char>(stream->ReadInt8());
+                    }
+                    else
+                    {
+                        for (int i = 0; i < realLen; i++)
+                            *(arr.target + i) = static_cast<char>(stream->ReadUInt16());
+                    }
+
+                    *(arr.target + realLen) = 0;
+
+                    return std::string(arr.target);
+                }
+
+                else if (typeId == IGNITE_HDR_NULL)
+                    return std::string();
+                else {
+                    int32_t pos = stream->Position() - 1;
+
+                    IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", IGNITE_TYPE_STRING, "actual", typeId)
+                }
+            }
+        }
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_utils.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_utils.h b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_utils.h
new file mode 100644
index 0000000..dd16686
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/portable/portable_utils.h
@@ -0,0 +1,344 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL_PORTABLE_UTILS
+#define _IGNITE_IMPL_PORTABLE_UTILS
+
+#include <stdint.h>
+
+#include "ignite/guid.h"
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace interop
+        {
+            class InteropInputStream;
+            class InteropOutputStream;
+        }
+
+        namespace portable
+        {
+            /**
+             * Portable uilts.
+             */
+            class IGNITE_IMPORT_EXPORT PortableUtils
+            {
+            public:
+                /**
+                 * Utility method to read signed 8-bit integer from stream.
+                 *
+                 * @param stream Stream.
+                 * @return Value.
+                 */
+                static int8_t ReadInt8(interop::InteropInputStream* stream);
+
+                /**
+                 * Utility method to write signed 8-bit integer to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 */
+                static void WriteInt8(interop::InteropOutputStream* stream, int8_t val);
+
+                /**
+                 * Utility method to read signed 8-bit integer array from stream.
+                 *
+                 * @param stream Stream.
+                 * @param res Target array.
+                 * @param len Array length.                 
+                 */
+                static void ReadInt8Array(interop::InteropInputStream* stream, int8_t* res, const int32_t len);
+
+                /**
+                 * Utility method to write signed 8-bit integer array to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 * @param len Array length.
+                 */
+                static void WriteInt8Array(interop::InteropOutputStream* stream, const int8_t* val, const int32_t len);
+
+                /**
+                 * Utility method to read boolean from stream.
+                 *
+                 * @param stream Stream.
+                 * @return Value.
+                 */
+                static bool ReadBool(interop::InteropInputStream* stream);
+
+                /**
+                 * Utility method to write bool to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 */
+                static void WriteBool(interop::InteropOutputStream* stream, bool val);
+
+                /**
+                 * Utility method to read bool array from stream.
+                 *
+                 * @param stream Stream.
+                 * @param res Target array.
+                 * @param len Array length.
+                 */
+                static void ReadBoolArray(interop::InteropInputStream* stream, bool* res, const int32_t len);
+
+                /**
+                 * Utility method to write bool array to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 * @param len Array length.
+                 */
+                static void WriteBoolArray(interop::InteropOutputStream* stream, const bool* val, const int32_t len);
+
+                /**
+                 * Utility method to read signed 16-bit integer from stream.
+                 *
+                 * @param stream Stream.
+                 * @return Value.
+                 */
+                static int16_t ReadInt16(interop::InteropInputStream* stream);
+
+                /**
+                 * Utility method to write signed 16-bit integer to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 */
+                static void WriteInt16(interop::InteropOutputStream* stream, int16_t val);
+
+                /**
+                 * Utility method to read signed 16-bit integer array from stream.
+                 *
+                 * @param stream Stream.
+                 * @param res Target array.
+                 * @param len Array length.                 
+                 */
+                static void ReadInt16Array(interop::InteropInputStream* stream, int16_t* res, const int32_t len);
+
+                /**
+                 * Utility method to write signed 16-bit integer array to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 * @param len Array length.
+                 */
+                static void WriteInt16Array(interop::InteropOutputStream* stream, const int16_t* val, const int32_t len);
+
+                /**
+                 * Utility method to read unsigned 16-bit integer from stream.
+                 *
+                 * @param stream Stream.
+                 * @return Value.
+                 */
+                static uint16_t ReadUInt16(interop::InteropInputStream* stream);
+
+                /**
+                 * Utility method to write unsigned 16-bit integer to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 */
+                static void WriteUInt16(interop::InteropOutputStream* stream, uint16_t val);
+
+                /**
+                 * Utility method to read unsigned 16-bit integer array from stream.
+                 *
+                 * @param stream Stream.
+                 * @param res Target array.
+                 * @param len Array length.
+                 */
+                static void ReadUInt16Array(interop::InteropInputStream* stream, uint16_t* res, const int32_t len);
+
+                /**
+                 * Utility method to write unsigned 16-bit integer array to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 * @param len Array length.
+                 */
+                static void WriteUInt16Array(interop::InteropOutputStream* stream, const uint16_t* val, const int32_t len);
+
+                /**
+                 * Utility method to read signed 32-bit integer from stream.
+                 *
+                 * @param stream Stream.
+                 * @return Value.
+                 */
+                static int32_t ReadInt32(interop::InteropInputStream* stream);
+
+                /**
+                 * Utility method to write signed 32-bit integer to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 */
+                static void WriteInt32(interop::InteropOutputStream* stream, int32_t val);
+
+                /**
+                 * Utility method to read signed 32-bit integer array from stream.
+                 *
+                 * @param stream Stream.
+                 * @param res Target array.
+                 * @param len Array length.
+                 */
+                static void ReadInt32Array(interop::InteropInputStream* stream, int32_t* res, const int32_t len);
+
+                /**
+                 * Utility method to write signed 32-bit integer array to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 * @param len Array length.
+                 */
+                static void WriteInt32Array(interop::InteropOutputStream* stream, const int32_t* val, const int32_t len);
+
+                /**
+                 * Utility method to read signed 64-bit integer from stream.
+                 *
+                 * @param stream Stream.
+                 * @return Value.
+                 */
+                static int64_t ReadInt64(interop::InteropInputStream* stream);
+
+                /**
+                 * Utility method to write signed 64-bit integer to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 */
+                static void WriteInt64(interop::InteropOutputStream* stream, int64_t val);
+
+                /**
+                 * Utility method to read signed 64-bit integer array from stream.
+                 *
+                 * @param stream Stream.
+                 * @param res Target array.
+                 * @param len Array length.
+                 */
+                static void ReadInt64Array(interop::InteropInputStream* stream, int64_t* res, const int32_t len);
+
+                /**
+                 * Utility method to write signed 64-bit integer array to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 * @param len Array length.
+                 */
+                static void WriteInt64Array(interop::InteropOutputStream* stream, const int64_t* val, const int32_t len);
+
+                /**
+                 * Utility method to read float from stream.
+                 *
+                 * @param stream Stream.
+                 * @return Value.
+                 */
+                static float ReadFloat(interop::InteropInputStream* stream);
+
+                /**
+                 * Utility method to write float to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 */
+                static void WriteFloat(interop::InteropOutputStream* stream, float val);
+
+                /**
+                 * Utility method to read float array from stream.
+                 *
+                 * @param stream Stream.
+                 * @param res Target array.
+                 * @param len Array length.
+                 */
+                static void ReadFloatArray(interop::InteropInputStream* stream, float* res, const int32_t len);
+
+                /**
+                 * Utility method to write float array to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 * @param len Array length.
+                 */
+                static void WriteFloatArray(interop::InteropOutputStream* stream, const float* val, const int32_t len);
+
+                /**
+                 * Utility method to read double from stream.
+                 *
+                 * @param stream Stream.
+                 * @return Value.
+                 */
+                static double ReadDouble(interop::InteropInputStream* stream);
+
+                /**
+                 * Utility method to write double to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 */
+                static void WriteDouble(interop::InteropOutputStream* stream, double val);
+
+                /**
+                 * Utility method to read double array from stream.
+                 *
+                 * @param stream Stream.
+                 * @param res Target array.
+                 * @param len Array length.
+                 */
+                static void ReadDoubleArray(interop::InteropInputStream* stream, double* res, const int32_t len);
+
+                /**
+                 * Utility method to write double array to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 * @param len Array length.
+                 */
+                static void WriteDoubleArray(interop::InteropOutputStream* stream, const double* val, const int32_t len);
+
+                /**
+                 * Utility method to read Guid from stream.
+                 *
+                 * @param stream Stream.
+                 * @param res Value.
+                 */
+                static Guid ReadGuid(interop::InteropInputStream* stream);
+
+                /**
+                 * Utility method to write Guid to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 */
+                static void WriteGuid(interop::InteropOutputStream* stream, const Guid val);
+
+                /**
+                 * Utility method to write string to stream.
+                 *
+                 * @param stream Stream.
+                 * @param val Value.
+                 * @param len Length.
+                 */
+                static void WriteString(interop::InteropOutputStream* stream, const char* val, const int32_t len);
+            };
+        }
+    }
+}
+
+#endif
\ No newline at end of file


[14/50] [abbrv] ignite git commit: IGNITE-1362: Fixed IgniteKernal instance leak to update notifier.

Posted by ak...@apache.org.
IGNITE-1362: Fixed IgniteKernal instance leak to update notifier.


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

Branch: refs/heads/ignite-843
Commit: 0b9d7cab98dddeabdc05e4981457a960c332b26d
Parents: 3a280a0
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Sep 3 11:25:00 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Sep 3 11:25:00 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    | 97 ++++++++++++++------
 1 file changed, 69 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0b9d7cab/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index d9fef86..9a724df 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -28,6 +28,7 @@ import java.io.ObjectStreamException;
 import java.io.Serializable;
 import java.lang.management.ManagementFactory;
 import java.lang.management.RuntimeMXBean;
+import java.lang.ref.WeakReference;
 import java.lang.reflect.Constructor;
 import java.text.DateFormat;
 import java.text.DecimalFormat;
@@ -820,34 +821,8 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                     updateNtfTimer = new Timer("ignite-update-notifier-timer", true);
 
                     // Setup periodic version check.
-                    updateNtfTimer.scheduleAtFixedRate(new GridTimerTask() {
-                        private boolean first = true;
-
-                        @Override public void safeRun() throws InterruptedException {
-                            if (!first)
-                                verChecker.topologySize(cluster().nodes().size());
-
-                            verChecker.checkForNewVersion(execSvc, log);
-
-                            // Just wait for 10 secs.
-                            Thread.sleep(PERIODIC_VER_CHECK_CONN_TIMEOUT);
-
-                            // Just wait another 60 secs in order to get
-                            // version info even on slow connection.
-                            for (int i = 0; i < 60 && verChecker.latestVersion() == null; i++)
-                                Thread.sleep(1000);
-
-                            // Report status if one is available.
-                            // No-op if status is NOT available.
-                            verChecker.reportStatus(log);
-
-                            if (first) {
-                                first = false;
-
-                                verChecker.reportOnlyNew(true);
-                            }
-                        }
-                    }, 0, PERIODIC_VER_CHECK_DELAY);
+                    updateNtfTimer.scheduleAtFixedRate(new UpdateNotifierTimerTask(this, verChecker),
+                        0, PERIODIC_VER_CHECK_DELAY);
                 }
                 catch (IgniteCheckedException e) {
                     if (log.isDebugEnabled())
@@ -3194,4 +3169,70 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
     @Override public String toString() {
         return S.toString(IgniteKernal.class, this);
     }
+
+    /**
+     * Update notifier timer task.
+     */
+    private static class UpdateNotifierTimerTask extends GridTimerTask {
+        /** Reference to kernal. */
+        private final WeakReference<IgniteKernal> kernalRef;
+
+        /** Logger. */
+        private final IgniteLogger log;
+
+        /** Executor service. */
+        private final ExecutorService execSvc;
+
+        /** Version checker. */
+        private final GridUpdateNotifier verChecker;
+
+        /** Whether this is the first run. */
+        private boolean first = true;
+
+        /**
+         * Constructor.
+         *
+         * @param kernal Kernal.
+         * @param verChecker Version checker.
+         */
+        private UpdateNotifierTimerTask(IgniteKernal kernal, GridUpdateNotifier verChecker) {
+            kernalRef = new WeakReference<>(kernal);
+
+            log = kernal.log.getLogger(UpdateNotifierTimerTask.class);
+
+            execSvc = kernal.executorService();
+
+            this.verChecker = verChecker;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void safeRun() throws InterruptedException {
+            if (!first) {
+                IgniteKernal kernal = kernalRef.get();
+
+                if (kernal != null)
+                    verChecker.topologySize(kernal.cluster().nodes().size());
+            }
+
+            verChecker.checkForNewVersion(execSvc, log);
+
+            // Just wait for 10 secs.
+            Thread.sleep(PERIODIC_VER_CHECK_CONN_TIMEOUT);
+
+            // Just wait another 60 secs in order to get
+            // version info even on slow connection.
+            for (int i = 0; i < 60 && verChecker.latestVersion() == null; i++)
+                Thread.sleep(1000);
+
+            // Report status if one is available.
+            // No-op if status is NOT available.
+            verChecker.reportStatus(log);
+
+            if (first) {
+                first = false;
+
+                verChecker.reportOnlyNew(true);
+            }
+        }
+    }
 }


[31/50] [abbrv] ignite git commit: ignite-1369: fixed failing portable example tests

Posted by ak...@apache.org.
ignite-1369: fixed failing portable example tests


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

Branch: refs/heads/ignite-843
Commit: ca1523ec5c28286ac75f9fedd51cd53eb7870ff1
Parents: 77fc969
Author: Denis Magda <dm...@gridgain.com>
Authored: Fri Sep 4 09:05:55 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Sep 4 09:05:55 2015 +0300

----------------------------------------------------------------------
 .../portable/datagrid/CacheClientPortablePutGetExample.java     | 4 ++++
 .../portable/datagrid/CacheClientPortableQueryExample.java      | 5 +++++
 2 files changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ca1523ec/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java
index 19c5685..77c5d95 100644
--- a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java
@@ -86,6 +86,10 @@ public class CacheClientPortablePutGetExample {
 
                 System.out.println();
             }
+            finally {
+                // Delete cache with its content completely.
+                ignite.destroyCache(CACHE_NAME);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca1523ec/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java
index 1eb43b3..b0048fa 100644
--- a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java
@@ -117,6 +117,11 @@ public class CacheClientPortableQueryExample {
 
                 System.out.println();
             }
+            finally {
+                // Delete caches with their content completely.
+                ignite.destroyCache(ORGANIZATION_CACHE_NAME);
+                ignite.destroyCache(EMPLOYEE_CACHE_NAME);
+            }
         }
     }
 


[07/50] [abbrv] ignite git commit: ignite-1273: fixed cyclic references processing by PortableMarshaller and ability to modify array fields returned by PortableBuilder

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMap.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMap.java
deleted file mode 100644
index eed8121..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMap.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.AbstractMap;
-import java.util.AbstractSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-import org.jetbrains.annotations.Nullable;
-
-/**
- *
- */
-class PortableLazyMap extends AbstractMap<Object, Object> implements PortableBuilderSerializationAware {
-    /** */
-    private final PortableBuilderReader reader;
-
-    /** */
-    private final int off;
-
-    /** */
-    private Map<Object, Object> delegate;
-
-    /**
-     * @param reader Reader.
-     * @param off Offset.
-     */
-    private PortableLazyMap(PortableBuilderReader reader, int off) {
-        this.reader = reader;
-        this.off = off;
-    }
-
-    /**
-     * @param reader Reader.
-     * @return PortableLazyMap.
-     */
-    @Nullable public static PortableLazyMap parseMap(PortableBuilderReader reader) {
-        int off = reader.position() - 1;
-
-        int size = reader.readInt();
-
-        reader.skip(1); // map type.
-
-        for (int i = 0; i < size; i++) {
-            reader.skipValue(); // skip key
-            reader.skipValue(); // skip value
-        }
-
-        return new PortableLazyMap(reader, off);
-    }
-
-    /**
-     *
-     */
-    private void ensureDelegateInit() {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
-
-            delegate = new LinkedHashMap<>();
-
-            for (int i = 0; i < size; i++)
-                delegate.put(PortableUtils.unwrapLazy(reader.parseValue()), reader.parseValue());
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
-            writer.write(reader.array(), off, hdrSize);
-
-            reader.position(off + hdrSize);
-
-            for (int i = 0; i < size; i++) {
-                ctx.writeValue(writer, reader.parseValue()); // key
-                ctx.writeValue(writer, reader.parseValue()); // value
-            }
-        }
-        else {
-            writer.writeByte(GridPortableMarshaller.MAP);
-            writer.writeInt(delegate.size());
-
-            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
-
-            writer.writeByte(colType);
-
-            for (Entry<Object, Object> entry : delegate.entrySet()) {
-                ctx.writeValue(writer, entry.getKey());
-                ctx.writeValue(writer, entry.getValue());
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        if (delegate == null)
-            return reader.readIntAbsolute(off + 1);
-
-        return delegate.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean containsKey(Object key) {
-        ensureDelegateInit();
-
-        return delegate.containsKey(key);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean containsValue(Object val) {
-        return values().contains(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Set<Object> keySet() {
-        ensureDelegateInit();
-
-        return delegate.keySet();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() {
-        if (delegate == null)
-            delegate = new LinkedHashMap<>();
-        else
-            delegate.clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object get(Object key) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.get(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object put(Object key, Object val) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.put(key, val));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object remove(Object key) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.remove(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Set<Entry<Object, Object>> entrySet() {
-        ensureDelegateInit();
-
-        return new AbstractSet<Entry<Object, Object>>() {
-            @Override public boolean contains(Object o) {
-                throw new UnsupportedOperationException();
-            }
-
-            @Override public Iterator<Entry<Object, Object>> iterator() {
-                return new Iterator<Entry<Object, Object>>() {
-                    /** */
-                    private final Iterator<Entry<Object, Object>> itr = delegate.entrySet().iterator();
-
-                    @Override public boolean hasNext() {
-                        return itr.hasNext();
-                    }
-
-                    @Override public Entry<Object, Object> next() {
-                        Entry<Object, Object> res = itr.next();
-
-                        final Object val = res.getValue();
-
-                        if (val instanceof PortableLazyValue) {
-                            return new SimpleEntry<Object, Object>(res.getKey(), val) {
-                                private static final long serialVersionUID = 0L;
-
-                                @Override public Object getValue() {
-                                    return ((PortableLazyValue)val).value();
-                                }
-                            };
-                        }
-
-                        return res;
-                    }
-
-                    @Override public void remove() {
-                        itr.remove();
-                    }
-                };
-            }
-
-            @Override public int size() {
-                return delegate.size();
-            }
-        };
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMapEntry.java
deleted file mode 100644
index 1970d21..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMapEntry.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.Map;
-
-/**
- *
- */
-class PortableLazyMapEntry implements Map.Entry<Object, Object>, PortableBuilderSerializationAware {
-    /** */
-    private final Object key;
-
-    /** */
-    private Object val;
-
-    /**
-     * @param reader GridMutablePortableReader
-     */
-    PortableLazyMapEntry(PortableBuilderReader reader) {
-        key = reader.parseValue();
-        val = reader.parseValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object getKey() {
-        return PortableUtils.unwrapLazy(key);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object getValue() {
-        return PortableUtils.unwrapLazy(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object setValue(Object val) {
-        Object res = getValue();
-
-        this.val = val;
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        writer.writeByte(GridPortableMarshaller.MAP_ENTRY);
-
-        ctx.writeValue(writer, key);
-        ctx.writeValue(writer, val);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazySet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazySet.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazySet.java
deleted file mode 100644
index 3e1dc92..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazySet.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.Collection;
-import java.util.Set;
-import org.apache.ignite.internal.util.typedef.internal.U;
-
-/**
- *
- */
-class PortableLazySet extends PortableAbstractLazyValue {
-    /** */
-    private final int off;
-
-    /**
-     * @param reader Reader.
-     * @param size Size.
-     */
-    PortableLazySet(PortableBuilderReader reader, int size) {
-        super(reader, reader.position() - 1);
-
-        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
-
-        assert size >= 0;
-
-        for (int i = 0; i < size; i++)
-            reader.skipValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (val == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
-            writer.write(reader.array(), off, hdrSize);
-
-            reader.position(off + hdrSize);
-
-            for (int i = 0; i < size; i++) {
-                Object o = reader.parseValue();
-
-                ctx.writeValue(writer, o);
-            }
-        }
-        else {
-            Collection<Object> c = (Collection<Object>)val;
-
-            writer.writeByte(GridPortableMarshaller.COL);
-            writer.writeInt(c.size());
-
-            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
-            writer.writeByte(colType);
-
-            for (Object o : c)
-                ctx.writeValue(writer, o);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Object init() {
-        int size = reader.readIntAbsolute(off + 1);
-
-        reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
-
-        Set<Object> res = U.newLinkedHashSet(size);
-
-        for (int i = 0; i < size; i++)
-            res.add(PortableUtils.unwrapLazy(reader.parseValue()));
-
-        return res;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyValue.java
deleted file mode 100644
index 43728b7..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyValue.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-/**
- *
- */
-interface PortableLazyValue extends PortableBuilderSerializationAware {
-    /**
-     * @return Value.
-     */
-    public Object value();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectArrayLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectArrayLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectArrayLazyValue.java
deleted file mode 100644
index 897e8e8..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectArrayLazyValue.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.portable.PortableInvalidClassException;
-
-/**
- *
- */
-class PortableObjectArrayLazyValue extends PortableAbstractLazyValue {
-    /** */
-    private Object[] lazyValsArr;
-
-    /** */
-    private int compTypeId;
-
-    /** */
-    private String clsName;
-
-    /**
-     * @param reader Reader.
-     */
-    protected PortableObjectArrayLazyValue(PortableBuilderReader reader) {
-        super(reader, reader.position() - 1);
-
-        int typeId = reader.readInt();
-
-        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
-            clsName = reader.readString();
-
-            Class cls;
-
-            try {
-                // TODO: IGNITE-1272 - Is class loader needed here?
-                cls = U.forName(reader.readString(), null);
-            }
-            catch (ClassNotFoundException e) {
-                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
-            }
-
-            compTypeId = reader.portableContext().descriptorForClass(cls).typeId();
-        }
-        else {
-            compTypeId = typeId;
-            clsName = null;
-        }
-
-        int size = reader.readInt();
-
-        lazyValsArr = new Object[size];
-
-        for (int i = 0; i < size; i++)
-            lazyValsArr[i] = reader.parseValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Object init() {
-        for (int i = 0; i < lazyValsArr.length; i++) {
-            if (lazyValsArr[i] instanceof PortableLazyValue)
-                lazyValsArr[i] = ((PortableLazyValue)lazyValsArr[i]).value();
-        }
-
-        return lazyValsArr;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (clsName == null)
-            ctx.writeArray(writer, GridPortableMarshaller.OBJ_ARR, lazyValsArr, compTypeId);
-        else
-            ctx.writeArray(writer, GridPortableMarshaller.OBJ_ARR, lazyValsArr, clsName);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainLazyValue.java
deleted file mode 100644
index d08d09b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainLazyValue.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-/**
- *
- */
-class PortablePlainLazyValue extends PortableAbstractLazyValue {
-    /** */
-    protected final int len;
-
-    /**
-     * @param reader Reader
-     * @param valOff Offset
-     * @param len Length.
-     */
-    protected PortablePlainLazyValue(PortableBuilderReader reader, int valOff, int len) {
-        super(reader, valOff);
-
-        this.len = len;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Object init() {
-        return reader.reader().unmarshal(valOff);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        writer.write(reader.array(), valOff, len);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainPortableObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainPortableObject.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainPortableObject.java
deleted file mode 100644
index cfaa04f..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainPortableObject.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.portable.PortableObject;
-
-/**
- *
- */
-public class PortablePlainPortableObject implements PortableLazyValue {
-    /** */
-    private final PortableObject portableObj;
-
-    /**
-     * @param portableObj Portable object.
-     */
-    public PortablePlainPortableObject(PortableObject portableObj) {
-        this.portableObj = portableObj;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object value() {
-        return portableObj;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        PortableObject val = portableObj;
-
-        if (val instanceof PortableObjectOffheapImpl)
-            val = ((PortableObjectOffheapImpl)val).heapCopy();
-
-        writer.doWritePortableObject((PortableObjectImpl)val);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
index f702e06..83ccb65 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
@@ -156,7 +156,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @param start Start.
      * @param ldr Class loader.
      */
-    PortableReaderExImpl(PortableContext ctx, byte[] arr, int start, ClassLoader ldr) {
+    public PortableReaderExImpl(PortableContext ctx, byte[] arr, int start, ClassLoader ldr) {
         this(ctx, new PortableHeapInputStream(arr), start, ldr, new PortableReaderContext());
     }
 
@@ -256,7 +256,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Unmarshalled value.
      * @throws PortableException In case of error.
      */
-    Object unmarshal(int offset) throws PortableException {
+    public Object unmarshal(int offset) throws PortableException {
         off = offset;
 
         return off >= 0 ? unmarshal(false) : null;
@@ -586,6 +586,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != BYTE_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -609,6 +612,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != SHORT_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -632,6 +638,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != INT_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -655,6 +664,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != LONG_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -678,6 +690,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != FLOAT_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -701,6 +716,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != DOUBLE_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -724,6 +742,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != CHAR_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -747,6 +768,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != BOOLEAN_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -770,6 +794,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != DECIMAL_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -793,6 +820,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != STRING_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -816,6 +846,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != UUID_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -839,6 +872,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != DATE_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -862,6 +898,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != OBJ_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -887,6 +926,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != COL)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -912,6 +954,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != MAP)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -935,10 +980,13 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != MAP_ENTRY)
                 throw new PortableException("Invalid flag value: " + flag);
 
-            return new GridMapEntry<>(doReadObject(false), doReadObject(false));
+            return doReadMapEntry(false, true);
         }
         else
             return null;
@@ -1059,6 +1107,33 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
         rCtx.setObjectHandler(start, obj);
     }
 
+    /**
+     * @param obj Object.
+     * @param pos Position.
+     */
+    void setHandler(Object obj, int pos) {
+        rCtx.setObjectHandler(pos, obj);
+    }
+
+    /**
+     * Recreating field value from a handle.
+     *
+     * @param <T> Field type.
+     * @return Field.
+     */
+    private <T> T readHandleField() {
+        int handle = (off - 1) - doReadInt(false);
+
+        Object obj = rCtx.getObjectByHandle(handle);
+
+        if (obj == null) {
+            off = handle;
+
+            obj = doReadObject(false);
+        }
+
+        return (T)obj;
+    }
     /** {@inheritDoc} */
     @Override public byte readByte(String fieldName) throws PortableException {
         Byte val = readByte(fieldId(fieldName));
@@ -1676,7 +1751,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
                 else
                     po = in.offheapPointer() > 0
                         ? new PortableObjectOffheapImpl(ctx, in.offheapPointer(), start,
-                                                            in.remaining() + in.position())
+                        in.remaining() + in.position())
                         : new PortableObjectImpl(ctx, in.array(), start);
 
                 rCtx.setPortableHandler(start, po);
@@ -1805,7 +1880,6 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
 
                 return obj;
 
-
             default:
                 throw new PortableException("Invalid flag value: " + flag);
         }
@@ -2306,12 +2380,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private byte[] doReadByteArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         byte[] arr = in.readByteArray(len);
 
+        setHandler(arr, hPos);
+
         if (raw)
             rawOff += len;
         else
@@ -2325,12 +2403,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private short[] doReadShortArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         short[] arr = in.readShortArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 1;
 
         if (raw)
@@ -2346,12 +2428,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private int[] doReadIntArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         int[] arr = in.readIntArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 2;
 
         if (raw)
@@ -2367,12 +2453,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private long[] doReadLongArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         long[] arr = in.readLongArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 3;
 
         if (raw)
@@ -2388,12 +2478,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private float[] doReadFloatArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         float[] arr = in.readFloatArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 2;
 
         if (raw)
@@ -2409,12 +2503,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private double[] doReadDoubleArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         double[] arr = in.readDoubleArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 3;
 
         if (raw)
@@ -2430,12 +2528,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private char[] doReadCharArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         char[] arr = in.readCharArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 1;
 
         if (raw)
@@ -2451,12 +2553,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private boolean[] doReadBooleanArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         boolean[] arr = in.readBooleanArray(len);
 
+        setHandler(arr, hPos);
+
         if (raw)
             rawOff += len;
         else
@@ -2471,10 +2577,14 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private BigDecimal[] doReadDecimalArray(boolean raw) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         BigDecimal[] arr = new BigDecimal[len];
 
+        setHandler(arr, hPos);
+
         for (int i = 0; i < len; i++) {
             byte flag = doReadByte(raw);
 
@@ -2497,10 +2607,14 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private String[] doReadStringArray(boolean raw) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         String[] arr = new String[len];
 
+        setHandler(arr, hPos);
+
         for (int i = 0; i < len; i++) {
             byte flag = doReadByte(raw);
 
@@ -2523,10 +2637,14 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private UUID[] doReadUuidArray(boolean raw) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         UUID[] arr = new UUID[len];
 
+        setHandler(arr, hPos);
+
         for (int i = 0; i < len; i++) {
             byte flag = doReadByte(raw);
 
@@ -2549,10 +2667,14 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private Date[] doReadDateArray(boolean raw) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         Date[] arr = new Date[len];
 
+        setHandler(arr, hPos);
+
         for (int i = 0; i < len; i++) {
             byte flag = doReadByte(raw);
 
@@ -2576,12 +2698,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private Object[] doReadObjectArray(boolean raw, boolean deep) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         Class compType = doReadClass(raw);
 
         int len = doReadInt(raw);
 
         Object[] arr = deep ? (Object[])Array.newInstance(compType, len) : new Object[len];
 
+        setHandler(arr, hPos);
+
         for (int i = 0; i < len; i++)
             arr[i] = deep ? doReadObject(raw) : unmarshal(raw);
 
@@ -2598,6 +2724,8 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
     @SuppressWarnings("unchecked")
     private Collection<?> doReadCollection(boolean raw, boolean deep, @Nullable Class<? extends Collection> cls)
         throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int size = doReadInt(raw);
 
         assert size >= 0;
@@ -2667,6 +2795,8 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             }
         }
 
+        setHandler(col, hPos);
+
         for (int i = 0; i < size; i++)
             col.add(deep ? doReadObject(raw) : unmarshal(raw));
 
@@ -2683,6 +2813,8 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
     @SuppressWarnings("unchecked")
     private Map<?, ?> doReadMap(boolean raw, boolean deep, @Nullable Class<? extends Map> cls)
         throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int size = doReadInt(raw);
 
         assert size >= 0;
@@ -2742,6 +2874,8 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             }
         }
 
+        setHandler(map, hPos);
+
         for (int i = 0; i < size; i++)
             map.put(deep ? doReadObject(raw) : unmarshal(raw), deep ? doReadObject(raw) : unmarshal(raw));
 
@@ -2755,10 +2889,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private Map.Entry<?, ?> doReadMapEntry(boolean raw, boolean deep) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         Object val1 = deep ? doReadObject(raw) : unmarshal(raw);
         Object val2 = deep ? doReadObject(raw) : unmarshal(raw);
 
-        return new GridMapEntry<>(val1, val2);
+        GridMapEntry entry = new GridMapEntry<>(val1, val2);
+
+        setHandler(entry, hPos);
+
+        return entry;
     }
 
     /**
@@ -3017,4 +3157,4 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
     @Override public void close() throws IOException {
         // No-op.
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index ce77783..7259cc9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -33,6 +33,7 @@ import java.util.TreeSet;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListSet;
+import org.apache.ignite.internal.portable.builder.PortableLazyValue;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.portable.PortableObject;
 import org.jetbrains.annotations.Nullable;
@@ -359,6 +360,16 @@ public class PortableUtils {
     }
 
     /**
+     * Checks whether an array type values can or can not contain references to other object.
+     *
+     * @param type Array type.
+     * @return {@code true} if content of serialized array value cannot contain references to other object.
+     */
+    public static boolean isPlainArrayType(int type) {
+        return type >= BYTE_ARR && type <= DATE_ARR;
+    }
+
+    /**
      * @param cls Class.
      * @return Portable field type.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableValueWithType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableValueWithType.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableValueWithType.java
deleted file mode 100644
index ebc68c1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableValueWithType.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- *
- */
-class PortableValueWithType implements PortableLazyValue {
-    /** */
-    private byte type;
-
-    /** */
-    private Object val;
-
-    /**
-     * @param type Type
-     * @param val Value.
-     */
-    PortableValueWithType(byte type, Object val) {
-        this.type = type;
-        this.val = val;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (val instanceof PortableBuilderSerializationAware)
-            ((PortableBuilderSerializationAware)val).writeTo(writer, ctx);
-        else
-            ctx.writeValue(writer, val);
-    }
-
-    /** {@inheritDoc} */
-    public String typeName() {
-        return CacheObjectPortableProcessorImpl.fieldTypeName(type);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object value() {
-        if (val instanceof PortableLazyValue)
-            return ((PortableLazyValue)val).value();
-
-        return val;
-    }
-
-    /**
-     * @param val New value.
-     */
-    public void value(Object val) {
-        this.val = val;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(PortableValueWithType.class, this);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
index 6bcce2b..364d5f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
@@ -156,7 +156,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      * @param off Start offset.
      * @param typeId Type ID.
      */
-    PortableWriterExImpl(PortableContext ctx, int off, int typeId, boolean metaEnabled) {
+    public PortableWriterExImpl(PortableContext ctx, int off, int typeId, boolean metaEnabled) {
         this(ctx, off);
 
         this.typeId = typeId;
@@ -320,14 +320,14 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @return Array.
      */
-    byte[] array() {
+    public byte[] array() {
         return wCtx.out.arrayCopy();
     }
 
     /**
      * @return Output stream.
      */
-    PortableOutputStream outputStream() {
+    public PortableOutputStream outputStream() {
         return wCtx.out;
     }
 
@@ -351,7 +351,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      * @param bytes Number of bytes to reserve.
      * @return Offset.
      */
-    int reserve(int bytes) {
+    public int reserve(int bytes) {
         int pos = wCtx.out.position();
 
         wCtx.out.position(pos + bytes);
@@ -363,7 +363,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      * @param bytes Number of bytes to reserve.
      * @return Offset.
      */
-    int reserveAndMark(int bytes) {
+    public int reserveAndMark(int bytes) {
         int off0 = reserve(bytes);
 
         mark = wCtx.out.position();
@@ -374,21 +374,21 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param off Offset.
      */
-    void writeDelta(int off) {
+    public void writeDelta(int off) {
         wCtx.out.writeInt(off, wCtx.out.position() - mark);
     }
 
     /**
      *
      */
-    void writeLength() {
+    public void writeLength() {
         wCtx.out.writeInt(start + TOTAL_LEN_POS, wCtx.out.position() - start);
     }
 
     /**
      *
      */
-    void writeRawOffsetIfNeeded() {
+    public void writeRawOffsetIfNeeded() {
         if (allowFields)
             wCtx.out.writeInt(start + RAW_DATA_OFF_POS, wCtx.out.position() - start);
     }
@@ -416,63 +416,63 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param val Value.
      */
-    void doWriteByte(byte val) {
+    public void doWriteByte(byte val) {
         wCtx.out.writeByte(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteShort(short val) {
+    public void doWriteShort(short val) {
         wCtx.out.writeShort(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteInt(int val) {
+    public void doWriteInt(int val) {
         wCtx.out.writeInt(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteLong(long val) {
+    public void doWriteLong(long val) {
         wCtx.out.writeLong(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteFloat(float val) {
+    public void doWriteFloat(float val) {
         wCtx.out.writeFloat(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteDouble(double val) {
+    public void doWriteDouble(double val) {
         wCtx.out.writeDouble(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteChar(char val) {
+    public void doWriteChar(char val) {
         wCtx.out.writeChar(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteBoolean(boolean val) {
+    public void doWriteBoolean(boolean val) {
         wCtx.out.writeBoolean(val);
     }
 
     /**
      * @param val String value.
      */
-    void doWriteDecimal(@Nullable BigDecimal val) {
+    public void doWriteDecimal(@Nullable BigDecimal val) {
         if (val == null)
             doWriteByte(NULL);
         else {
@@ -498,7 +498,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param val String value.
      */
-    void doWriteString(@Nullable String val) {
+    public void doWriteString(@Nullable String val) {
         if (val == null)
             doWriteByte(NULL);
         else {
@@ -528,7 +528,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param uuid UUID.
      */
-    void doWriteUuid(@Nullable UUID uuid) {
+    public void doWriteUuid(@Nullable UUID uuid) {
         if (uuid == null)
             doWriteByte(NULL);
         else {
@@ -541,7 +541,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param date Date.
      */
-    void doWriteDate(@Nullable Date date) {
+    public void doWriteDate(@Nullable Date date) {
         if (date == null)
             doWriteByte(NULL);
         else {
@@ -554,7 +554,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param ts Timestamp.
      */
-    void doWriteTimestamp(@Nullable Timestamp ts) {
+    public void doWriteTimestamp(@Nullable Timestamp ts) {
         if (ts == null)
             doWriteByte(NULL);
         else {
@@ -569,7 +569,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      * @param detached Detached or not.
      * @throws PortableException In case of error.
      */
-    void doWriteObject(@Nullable Object obj, boolean detached) throws PortableException {
+    public void doWriteObject(@Nullable Object obj, boolean detached) throws PortableException {
         if (obj == null)
             doWriteByte(NULL);
         else {
@@ -591,6 +591,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(BYTE_ARR);
             doWriteInt(val.length);
 
@@ -605,6 +608,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(SHORT_ARR);
             doWriteInt(val.length);
 
@@ -619,6 +625,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(INT_ARR);
             doWriteInt(val.length);
 
@@ -633,6 +642,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(LONG_ARR);
             doWriteInt(val.length);
 
@@ -647,6 +659,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(FLOAT_ARR);
             doWriteInt(val.length);
 
@@ -661,6 +676,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(DOUBLE_ARR);
             doWriteInt(val.length);
 
@@ -675,6 +693,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(CHAR_ARR);
             doWriteInt(val.length);
 
@@ -689,6 +710,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(BOOLEAN_ARR);
             doWriteInt(val.length);
 
@@ -703,6 +727,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(DECIMAL_ARR);
             doWriteInt(val.length);
 
@@ -718,6 +745,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(STRING_ARR);
             doWriteInt(val.length);
 
@@ -733,6 +763,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(UUID_ARR);
             doWriteInt(val.length);
 
@@ -748,6 +781,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(DATE_ARR);
             doWriteInt(val.length);
 
@@ -764,6 +800,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             PortableContext.Type type = ctx.typeId(val.getClass().getComponentType());
 
             doWriteByte(OBJ_ARR);
@@ -790,6 +829,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (col == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(col))
+                return;
+
             doWriteByte(COL);
             doWriteInt(col.size());
             doWriteByte(ctx.collectionType(col.getClass()));
@@ -807,6 +849,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (map == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(map))
+                return;
+
             doWriteByte(MAP);
             doWriteInt(map.size());
             doWriteByte(ctx.mapType(map.getClass()));
@@ -826,6 +871,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (e == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(e))
+                return;
+
             doWriteByte(MAP_ENTRY);
             doWriteObject(e.getKey(), false);
             doWriteObject(e.getValue(), false);
@@ -905,7 +953,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param po Portable object.
      */
-    void doWritePortableObject(@Nullable PortableObjectImpl po) {
+    public void doWritePortableObject(@Nullable PortableObjectImpl po) {
         if (po == null)
             doWriteByte(NULL);
         else {
@@ -1106,64 +1154,88 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      * @param val Value.
      */
     void writeByteArrayField(@Nullable byte[] val) {
-        doWriteInt(val != null ? 5 + val.length : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteByteArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeShortArrayField(@Nullable short[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 1) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteShortArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeIntArrayField(@Nullable int[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 2) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteIntArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeLongArrayField(@Nullable long[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 3) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteLongArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeFloatArrayField(@Nullable float[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 2) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteFloatArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeDoubleArrayField(@Nullable double[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 3) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteDoubleArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeCharArrayField(@Nullable char[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 1) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteCharArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeBooleanArrayField(@Nullable boolean[] val) {
-        doWriteInt(val != null ? 5 + val.length : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteBooleanArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
@@ -1739,12 +1811,31 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         doWriteInt(id);
     }
 
+     /**
+      * Attempts to write the object as a handle.
+      *
+      * @param obj Object to write.
+      * @return {@code true} if the object has been written as a handle.
+      */
+     boolean tryWriteAsHandle(Object obj) {
+         int handle = handle(obj);
+
+         if (handle >= 0) {
+             doWriteByte(GridPortableMarshaller.HANDLE);
+             doWriteInt(handle);
+
+             return true;
+         }
+
+         return false;
+     }
+
     /**
      * Create new writer with same context.
      * @param typeId type
      * @return New writer.
      */
-    PortableWriterExImpl newWriter(int typeId) {
+    public PortableWriterExImpl newWriter(int typeId) {
         PortableWriterExImpl res = new PortableWriterExImpl(ctx, wCtx);
 
         res.typeId = typeId;
@@ -1755,7 +1846,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @return Portable context.
      */
-    PortableContext context() {
+    public PortableContext context() {
         return ctx;
     }
 
@@ -1803,4 +1894,4 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
             handles = new IdentityHashMap<>();
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableAbstractLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableAbstractLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableAbstractLazyValue.java
new file mode 100644
index 0000000..1f521ac
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableAbstractLazyValue.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+/**
+ *
+ */
+abstract class PortableAbstractLazyValue implements PortableLazyValue {
+    /** */
+    protected Object val;
+
+    /** */
+    protected final PortableBuilderReader reader;
+
+    /** */
+    protected final int valOff;
+
+    /**
+     * @param reader Reader.
+     * @param valOff Value.
+     */
+    protected PortableAbstractLazyValue(PortableBuilderReader reader, int valOff) {
+        this.reader = reader;
+        this.valOff = valOff;
+    }
+
+    /**
+     * @return Value.
+     */
+    protected abstract Object init();
+
+    /** {@inheritDoc} */
+    @Override public Object value() {
+        if (val == null) {
+            val = init();
+
+            assert val != null;
+        }
+
+        return val;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java
new file mode 100644
index 0000000..1472d56
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.portable.PortableInvalidClassException;
+
+/**
+ *
+ */
+public class PortableBuilderEnum implements PortableBuilderSerializationAware {
+    /** */
+    private final int ordinal;
+
+    /** */
+    private final int typeId;
+
+    /** */
+    private final String clsName;
+
+    /**
+     * @param typeId Type ID.
+     * @param anEnum Enum instance.
+     */
+    public PortableBuilderEnum(int typeId, Enum anEnum) {
+        ordinal = anEnum.ordinal();
+        this.typeId = typeId;
+        clsName = null;
+    }
+
+    /**
+     * @param reader PortableBuilderReader.
+     */
+    public PortableBuilderEnum(PortableBuilderReader reader) {
+        int typeId = reader.readInt();
+
+        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
+            clsName = reader.readString();
+
+            Class cls;
+
+            try {
+                // TODO: IGNITE-1272 - Is class loader needed here?
+                cls = U.forName(reader.readString(), null);
+            }
+            catch (ClassNotFoundException e) {
+                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
+            }
+
+            this.typeId = reader.portableContext().descriptorForClass(cls).typeId();
+        }
+        else {
+            this.typeId = typeId;
+            this.clsName = null;
+        }
+
+        ordinal = reader.readInt();
+    }
+
+    /**
+     * @return Ordinal.
+     */
+    public int getOrdinal() {
+        return ordinal;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        writer.writeByte(GridPortableMarshaller.ENUM);
+
+        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
+            writer.writeInt(GridPortableMarshaller.UNREGISTERED_TYPE_ID);
+            writer.writeString(clsName);
+        }
+        else
+            writer.writeInt(typeId);
+
+        writer.writeInt(ordinal);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        PortableBuilderEnum that = (PortableBuilderEnum)o;
+
+        return ordinal == that.ordinal && typeId == that.typeId;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int result = ordinal;
+
+        result = 31 * result + typeId;
+
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ac9557e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
new file mode 100644
index 0000000..b2e4c0d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
@@ -0,0 +1,537 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
+import org.apache.ignite.internal.util.GridArgumentCheck;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.portable.PortableBuilder;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableInvalidClassException;
+import org.apache.ignite.portable.PortableMetadata;
+import org.apache.ignite.portable.PortableObject;
+import org.jetbrains.annotations.Nullable;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.cache.portable.*;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.portable.*;
+
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLS_NAME_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.HASH_CODE_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.RAW_DATA_OFF_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TYPE_ID_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
+
+/**
+ *
+ */
+public class PortableBuilderImpl implements PortableBuilder {
+    /** */
+    private static final Object REMOVED_FIELD_MARKER = new Object();
+
+    /** */
+    private final PortableContext ctx;
+
+    /** */
+    private final int typeId;
+
+    /** May be null. */
+    private String typeName;
+
+    /** May be null. */
+    private String clsNameToWrite;
+
+    /** */
+    private boolean registeredType = true;
+
+    /** */
+    private Map<String, Object> assignedVals;
+
+    /** */
+    private Map<Integer, Object> readCache;
+
+    /** Position of object in source array, or -1 if object is not created from PortableObject. */
+    private final int start;
+
+    /** Total header length */
+    private final int hdrLen;
+
+    /**
+     * Context of PortableObject reading process. Or {@code null} if object is not created from PortableObject.
+     */
+    private final PortableBuilderReader reader;
+
+    /** */
+    private int hashCode;
+
+    /**
+     * @param clsName Class name.
+     * @param ctx Portable context.
+     */
+    public PortableBuilderImpl(PortableContext ctx, String clsName) {
+        this(ctx, ctx.typeId(clsName), PortableContext.typeName(clsName));
+    }
+
+    /**
+     * @param typeId Type ID.
+     * @param ctx Portable context.
+     */
+    public PortableBuilderImpl(PortableContext ctx, int typeId) {
+        this(ctx, typeId, null);
+    }
+
+    /**
+     * @param typeName Type name.
+     * @param ctx Context.
+     * @param typeId Type id.
+     */
+    public PortableBuilderImpl(PortableContext ctx, int typeId, String typeName) {
+        this.typeId = typeId;
+        this.typeName = typeName;
+        this.ctx = ctx;
+
+        start = -1;
+        reader = null;
+        hdrLen = DFLT_HDR_LEN;
+
+        readCache = Collections.emptyMap();
+    }
+
+    /**
+     * @param obj Object to wrap.
+     */
+    public PortableBuilderImpl(PortableObjectImpl obj) {
+        this(new PortableBuilderReader(obj), obj.start());
+
+        reader.registerObject(this);
+    }
+
+    /**
+     * @param reader ctx
+     * @param start Start.
+     */
+    PortableBuilderImpl(PortableBuilderReader reader, int start) {
+        this.reader = reader;
+        this.start = start;
+
+        int typeId = reader.readIntAbsolute(start + TYPE_ID_POS);
+        ctx = reader.portableContext();
+        hashCode = reader.readIntAbsolute(start + HASH_CODE_POS);
+
+        if (typeId == UNREGISTERED_TYPE_ID) {
+            int mark = reader.position();
+
+            reader.position(start + CLS_NAME_POS);
+
+            clsNameToWrite = reader.readString();
+
+            Class cls;
+
+            try {
+                // TODO: IGNITE-1272 - Is class loader needed here?
+                cls = U.forName(clsNameToWrite, null);
+            }
+            catch (ClassNotFoundException e) {
+                throw new PortableInvalidClassException("Failed to load the class: " + clsNameToWrite, e);
+            }
+
+            this.typeId = ctx.descriptorForClass(cls).typeId();
+
+            registeredType = false;
+
+            hdrLen = reader.position() - mark;
+
+            reader.position(mark);
+        }
+        else {
+            this.typeId = typeId;
+            hdrLen = DFLT_HDR_LEN;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public PortableObject build() {
+        try (PortableWriterExImpl writer = new PortableWriterExImpl(ctx, 0, typeId, false)) {
+
+            PortableBuilderSerializer serializationCtx = new PortableBuilderSerializer();
+
+            serializationCtx.registerObjectWriting(this, 0);
+
+            serializeTo(writer, serializationCtx);
+
+            byte[] arr = writer.array();
+
+            return new PortableObjectImpl(ctx, arr, 0);
+        }
+    }
+
+    /**
+     * @param writer Writer.
+     * @param serializer Serializer.
+     */
+    void serializeTo(PortableWriterExImpl writer, PortableBuilderSerializer serializer) {
+        writer.doWriteByte(GridPortableMarshaller.OBJ);
+        writer.doWriteBoolean(true);
+        writer.doWriteInt(registeredType ? typeId : UNREGISTERED_TYPE_ID);
+        writer.doWriteInt(hashCode);
+
+        // Length and raw offset.
+        writer.reserve(8);
+
+        if (!registeredType)
+            writer.writeString(clsNameToWrite);
+
+        Set<Integer> remainsFlds = null;
+
+        if (reader != null) {
+            Map<Integer, Object> assignedFldsById;
+
+            if (assignedVals != null) {
+                assignedFldsById = U.newHashMap(assignedVals.size());
+
+                for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
+                    int fldId = ctx.fieldId(typeId, entry.getKey());
+
+                    assignedFldsById.put(fldId, entry.getValue());
+                }
+
+                remainsFlds = assignedFldsById.keySet();
+            }
+            else
+                assignedFldsById = Collections.emptyMap();
+
+            int rawOff = start + reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
+
+            reader.position(start + hdrLen);
+
+            int cpStart = -1;
+
+            while (reader.position() < rawOff) {
+                int fldId = reader.readInt();
+
+                int len = reader.readInt();
+
+                if (assignedFldsById.containsKey(fldId)) {
+                    if (cpStart >= 0) {
+                        writer.write(reader.array(), cpStart, reader.position() - 4 - 4 - cpStart);
+
+                        cpStart = -1;
+                    }
+
+                    Object assignedVal = assignedFldsById.remove(fldId);
+
+                    reader.skip(len);
+
+                    if (assignedVal != REMOVED_FIELD_MARKER) {
+                        writer.writeInt(fldId);
+
+                        int lenPos = writer.reserveAndMark(4);
+
+                        serializer.writeValue(writer, assignedVal);
+
+                        writer.writeDelta(lenPos);
+                    }
+                }
+                else {
+                    int type = len != 0 ? reader.readByte(0) : 0;
+
+                    if (len != 0 && !PortableUtils.isPlainArrayType(type) && PortableUtils.isPlainType(type)) {
+                        if (cpStart < 0)
+                            cpStart = reader.position() - 4 - 4;
+
+                        reader.skip(len);
+                    }
+                    else {
+                        if (cpStart >= 0) {
+                            writer.write(reader.array(), cpStart, reader.position() - 4 - cpStart);
+
+                            cpStart = -1;
+                        }
+                        else
+                            writer.writeInt(fldId);
+
+                        Object val;
+
+                        if (len == 0)
+                            val = null;
+                        else if (readCache == null) {
+                            int savedPos = reader.position();
+
+                            val = reader.parseValue();
+
+                            assert reader.position() == savedPos + len;
+                        }
+                        else {
+                            val = readCache.get(fldId);
+
+                            reader.skip(len);
+                        }
+
+                        int lenPos = writer.reserveAndMark(4);
+
+                        serializer.writeValue(writer, val);
+
+                        writer.writeDelta(lenPos);
+                    }
+                }
+            }
+
+            if (cpStart >= 0)
+                writer.write(reader.array(), cpStart, reader.position() - cpStart);
+        }
+
+        if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) {
+            boolean metadataEnabled = ctx.isMetaDataEnabled(typeId);
+
+            PortableMetadata metadata = null;
+
+            if (metadataEnabled)
+                metadata = ctx.metaData(typeId);
+
+            Map<String, String> newFldsMetadata = null;
+
+            for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
+                Object val = entry.getValue();
+
+                if (val == REMOVED_FIELD_MARKER)
+                    continue;
+
+                String name = entry.getKey();
+
+                int fldId = ctx.fieldId(typeId, name);
+
+                if (remainsFlds != null && !remainsFlds.contains(fldId))
+                    continue;
+
+                writer.writeInt(fldId);
+
+                int lenPos = writer.reserveAndMark(4);
+
+                serializer.writeValue(writer, val);
+
+                writer.writeDelta(lenPos);
+
+                if (metadataEnabled) {
+                    String oldFldTypeName = metadata == null ? null : metadata.fieldTypeName(name);
+
+                    String newFldTypeName;
+
+                    if (val instanceof PortableValueWithType)
+                        newFldTypeName = ((PortableValueWithType)val).typeName();
+                    else {
+                        byte type = PortableUtils.typeByClass(val.getClass());
+
+                        newFldTypeName = CacheObjectPortableProcessorImpl.fieldTypeName(type);
+                    }
+
+                    if (oldFldTypeName == null) {
+                        // It's a new field, we have to add it to metadata.
+
+                        if (newFldsMetadata == null)
+                            newFldsMetadata = new HashMap<>();
+
+                        newFldsMetadata.put(name, newFldTypeName);
+                    }
+                    else {
+                        if (!"Object".equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) {
+                            throw new PortableException(
+                                "Wrong value has been set [" +
+                                    "typeName=" + (typeName == null ? metadata.typeName() : typeName) +
+                                    ", fieldName=" + name +
+                                    ", fieldType=" + oldFldTypeName +
+                                    ", assignedValueType=" + newFldTypeName +
+                                    ", assignedValue=" + (((PortableValueWithType)val).value()) + ']'
+                            );
+                        }
+                    }
+                }
+            }
+
+            if (newFldsMetadata != null) {
+                String typeName = this.typeName;
+
+                if (typeName == null)
+                    typeName = metadata.typeName();
+
+                ctx.updateMetaData(typeId, typeName, newFldsMetadata);
+            }
+        }
+
+        writer.writeRawOffsetIfNeeded();
+
+        if (reader != null) {
+            int rawOff = reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
+            int len = reader.readIntAbsolute(start + TOTAL_LEN_POS);
+
+            if (rawOff < len)
+                writer.write(reader.array(), rawOff, len - rawOff);
+        }
+
+        writer.writeLength();
+    }
+
+    /** {@inheritDoc} */
+    @Override public PortableBuilderImpl hashCode(int hashCode) {
+        this.hashCode = hashCode;
+
+        return this;
+    }
+
+    /**
+     *
+     */
+    private void ensureReadCacheInit() {
+        if (readCache == null) {
+            Map<Integer, Object> readCache = new HashMap<>();
+
+            int pos = start + hdrLen;
+            int end = start + reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
+
+            while (pos < end) {
+                int fieldId = reader.readIntAbsolute(pos);
+
+                pos += 4;
+
+                int len = reader.readIntAbsolute(pos);
+
+                pos += 4;
+
+                Object val = reader.getValueQuickly(pos, len);
+
+                readCache.put(fieldId, val);
+
+                pos += len;
+            }
+
+            this.readCache = readCache;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <F> F getField(String name) {
+        Object val;
+
+        if (assignedVals != null && assignedVals.containsKey(name)) {
+            val = assignedVals.get(name);
+
+            if (val == REMOVED_FIELD_MARKER)
+                return null;
+        }
+        else {
+            ensureReadCacheInit();
+
+            int fldId = ctx.fieldId(typeId, name);
+
+            val = readCache.get(fldId);
+        }
+
+        return (F)PortableUtils.unwrapLazy(val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public PortableBuilder setField(String name, Object val) {
+        GridArgumentCheck.notNull(val, name);
+
+        if (assignedVals == null)
+            assignedVals = new LinkedHashMap<>();
+
+        Object oldVal = assignedVals.put(name, val);
+
+        if (oldVal instanceof PortableValueWithType) {
+            ((PortableValueWithType)oldVal).value(val);
+
+            assignedVals.put(name, oldVal);
+        }
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> PortableBuilder setField(String name, @Nullable T val, Class<? super T> type) {
+        if (assignedVals == null)
+            assignedVals = new LinkedHashMap<>();
+
+        //int fldId = ctx.fieldId(typeId, fldName);
+
+        assignedVals.put(name, new PortableValueWithType(PortableUtils.typeByClass(type), val));
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public PortableBuilder setField(String name, @Nullable PortableBuilder builder) {
+        if (builder == null)
+            return setField(name, null, Object.class);
+        else
+            return setField(name, (Object)builder);
+    }
+
+    /**
+     * Removes field from portable object.
+     *
+     * @param name Field name.
+     * @return {@code this} instance for chaining.
+     */
+    @Override public PortableBuilderImpl removeField(String name) {
+        if (assignedVals == null)
+            assignedVals = new LinkedHashMap<>();
+
+        assignedVals.put(name, REMOVED_FIELD_MARKER);
+
+        return this;
+    }
+
+    /**
+     * Creates builder initialized by specified portable object.
+     *
+     * @param obj Portable object to initialize builder.
+     * @return New builder.
+     */
+    public static PortableBuilderImpl wrap(PortableObject obj) {
+        PortableObjectImpl heapObj;
+
+        if (obj instanceof PortableObjectOffheapImpl)
+            heapObj = (PortableObjectImpl)((PortableObjectOffheapImpl)obj).heapCopy();
+        else
+            heapObj = (PortableObjectImpl)obj;
+
+        return new PortableBuilderImpl(heapObj);
+    }
+
+    /**
+     * @return Object start position in source array.
+     */
+    int start() {
+        return start;
+    }
+
+    /**
+     * @return Object type id.
+     */
+    public int typeId() {
+        return typeId;
+    }
+}
\ No newline at end of file


[26/50] [abbrv] ignite git commit: Merge remote-tracking branch 'origin/ignite-1.4' into ignite-1.4

Posted by ak...@apache.org.
Merge remote-tracking branch 'origin/ignite-1.4' into ignite-1.4


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

Branch: refs/heads/ignite-843
Commit: 154f18588e01943bfde60ade49262837bb670204
Parents: 2fbf328 6a5a48a
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Sep 3 18:35:06 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Sep 3 18:35:06 2015 +0300

----------------------------------------------------------------------
 examples/config/example-default.xml             |  76 +++++
 examples/config/example-ignite.xml              |  56 +---
 .../config/portable/example-ignite-portable.xml |  44 +++
 .../ignite/examples/portable/Address.java       |  72 +++++
 .../ignite/examples/portable/Employee.java      |  93 ++++++
 .../ignite/examples/portable/EmployeeKey.java   |  90 ++++++
 .../portable/ExamplePortableNodeStartup.java    |  36 +++
 .../ignite/examples/portable/Organization.java  |  93 ++++++
 .../examples/portable/OrganizationType.java     |  32 ++
 ...mputeClientPortableTaskExecutionExample.java | 154 +++++++++
 .../portable/computegrid/ComputeClientTask.java | 116 +++++++
 .../portable/computegrid/package-info.java      |  21 ++
 .../CacheClientPortablePutGetExample.java       | 226 +++++++++++++
 .../CacheClientPortableQueryExample.java        | 323 +++++++++++++++++++
 .../portable/datagrid/package-info.java         |  21 ++
 .../ignite/examples/portable/package-info.java  |  21 ++
 .../CacheClientPortableExampleTest.java         |  46 +++
 .../ComputeClientPortableExampleTest.java       |  37 +++
 .../testsuites/IgniteExamplesSelfTestSuite.java |   6 +
 19 files changed, 1513 insertions(+), 50 deletions(-)
----------------------------------------------------------------------



[20/50] [abbrv] ignite git commit: Fixing platform JavaDocs.

Posted by ak...@apache.org.
Fixing platform JavaDocs.


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

Branch: refs/heads/ignite-843
Commit: 5463df29a5e7c5d2ad7e583fc77d5c1ed38cc5f2
Parents: 27cd615
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Sep 3 14:28:07 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Sep 3 14:28:07 2015 +0300

----------------------------------------------------------------------
 .../ignite/platform/cpp/package-info.java       | 22 ++++++++++++++++++++
 .../ignite/platform/dotnet/package-info.java    | 22 ++++++++++++++++++++
 .../apache/ignite/platform/package-info.java    | 22 ++++++++++++++++++++
 parent/pom.xml                                  |  4 ++++
 4 files changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5463df29/modules/platform/src/main/java/org/apache/ignite/platform/cpp/package-info.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/platform/cpp/package-info.java b/modules/platform/src/main/java/org/apache/ignite/platform/cpp/package-info.java
new file mode 100644
index 0000000..6d745a7
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/platform/cpp/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains C++ platform-related classes.
+ */
+package org.apache.ignite.platform.cpp;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5463df29/modules/platform/src/main/java/org/apache/ignite/platform/dotnet/package-info.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/platform/dotnet/package-info.java b/modules/platform/src/main/java/org/apache/ignite/platform/dotnet/package-info.java
new file mode 100644
index 0000000..0765e01
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/platform/dotnet/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains .Net platform-related classes.
+ */
+package org.apache.ignite.platform.dotnet;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5463df29/modules/platform/src/main/java/org/apache/ignite/platform/package-info.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/platform/package-info.java b/modules/platform/src/main/java/org/apache/ignite/platform/package-info.java
new file mode 100644
index 0000000..ac89b58
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/platform/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains platform-related classes.
+ */
+package org.apache.ignite.platform;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5463df29/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index ebe691f..eba7390 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -339,6 +339,10 @@
                                 <packages>org.apache.ignite.yarn*</packages>
                             </group>
                             <group>
+                                <title>Platforms</title>
+                                <packages>org.apache.ignite.platform*</packages>
+                            </group>
+                            <group>
                                 <title>Spark Integration</title>
                                 <packages>org.apache.ignite.spark.examples.java</packages>
                             </group>


[48/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
IGNITE-1364: Moved CPP module to Ignite.


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

Branch: refs/heads/ignite-843
Commit: 58a665aa101ca11f3bfb2177948950052b6afd20
Parents: 94039ec
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Sep 4 12:42:38 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Sep 4 12:42:39 2015 +0300

----------------------------------------------------------------------
 modules/platform/licenses/apache-2.0.txt        |  202 ++
 .../platform/src/main/cpp/common/configure.ac   |    2 +-
 .../src/main/cpp/common/ignite-common.pc.in     |    2 +-
 .../cpp/common/include/ignite/common/exports.h  |    8 +-
 .../cpp/common/include/ignite/common/java.h     |   16 +-
 .../src/main/cpp/common/src/exports.cpp         |   16 +-
 .../platform/src/main/cpp/common/src/java.cpp   |   45 +-
 .../platform/src/main/cpp/core-test/Makefile.am |   49 +
 .../main/cpp/core-test/config/cache-query.xml   |   91 +
 .../main/cpp/core-test/config/cache-test.xml    |  129 ++
 .../src/main/cpp/core-test/configure.ac         |   62 +
 .../src/main/cpp/core-test/include/Makefile.am  |   22 +
 .../include/ignite/portable_test_defs.h         |  320 +++
 .../include/ignite/portable_test_utils.h        |  516 +++++
 .../cpp/core-test/include/teamcity_messages.h   |   55 +
 .../src/main/cpp/core-test/project/README.TXT   |    1 +
 .../main/cpp/core-test/project/vs/README.TXT    |    1 +
 .../cpp/core-test/project/vs/core-test.vcxproj  |  174 ++
 .../project/vs/core-test.vcxproj.filters        |   68 +
 .../main/cpp/core-test/src/cache_query_test.cpp |  651 ++++++
 .../src/main/cpp/core-test/src/cache_test.cpp   |  481 +++++
 .../main/cpp/core-test/src/concurrent_test.cpp  |  186 ++
 .../cpp/core-test/src/handle_registry_test.cpp  |  176 ++
 .../main/cpp/core-test/src/ignition_test.cpp    |   97 +
 .../src/portable_reader_writer_raw_test.cpp     | 1532 ++++++++++++++
 .../src/portable_reader_writer_test.cpp         | 1951 ++++++++++++++++++
 .../cpp/core-test/src/portable_session_test.cpp |  257 +++
 .../cpp/core-test/src/portable_test_defs.cpp    |   65 +
 .../main/cpp/core-test/src/teamcity_boost.cpp   |  159 ++
 .../cpp/core-test/src/teamcity_messages.cpp     |  150 ++
 modules/platform/src/main/cpp/core/Makefile.am  |   66 +
 modules/platform/src/main/cpp/core/configure.ac |   62 +
 modules/platform/src/main/cpp/core/ignite.pc.in |    9 +
 .../src/main/cpp/core/include/Makefile.am       |   61 +
 .../main/cpp/core/include/ignite/cache/cache.h  | 1153 +++++++++++
 .../cpp/core/include/ignite/cache/cache_entry.h |  118 ++
 .../core/include/ignite/cache/cache_peek_mode.h |   71 +
 .../cpp/core/include/ignite/cache/query/query.h |   27 +
 .../include/ignite/cache/query/query_argument.h |  125 ++
 .../include/ignite/cache/query/query_cursor.h   |  191 ++
 .../include/ignite/cache/query/query_scan.h     |  151 ++
 .../core/include/ignite/cache/query/query_sql.h |  253 +++
 .../include/ignite/cache/query/query_text.h     |  159 ++
 .../src/main/cpp/core/include/ignite/guid.h     |  112 +
 .../src/main/cpp/core/include/ignite/ignite.h   |  154 ++
 .../core/include/ignite/ignite_configuration.h  |   92 +
 .../main/cpp/core/include/ignite/ignite_error.h |  260 +++
 .../src/main/cpp/core/include/ignite/ignition.h |  195 ++
 .../core/include/ignite/impl/cache/cache_impl.h |  418 ++++
 .../ignite/impl/cache/query/query_impl.h        |  115 ++
 .../core/include/ignite/impl/handle_registry.h  |  202 ++
 .../include/ignite/impl/ignite_environment.h    |  130 ++
 .../cpp/core/include/ignite/impl/ignite_impl.h  |  146 ++
 .../core/include/ignite/impl/interop/interop.h  |   25 +
 .../ignite/impl/interop/interop_input_stream.h  |  234 +++
 .../ignite/impl/interop/interop_memory.h        |  280 +++
 .../ignite/impl/interop/interop_output_stream.h |  234 +++
 .../cpp/core/include/ignite/impl/operations.h   |  452 ++++
 .../ignite/impl/portable/portable_common.h      |  146 ++
 .../ignite/impl/portable/portable_id_resolver.h |  106 +
 .../impl/portable/portable_metadata_handler.h   |  102 +
 .../impl/portable/portable_metadata_manager.h   |  120 ++
 .../impl/portable/portable_metadata_snapshot.h  |  122 ++
 .../impl/portable/portable_metadata_updater.h   |   53 +
 .../portable/portable_metadata_updater_impl.h   |   65 +
 .../ignite/impl/portable/portable_reader_impl.h | 1130 ++++++++++
 .../ignite/impl/portable/portable_utils.h       |  344 +++
 .../ignite/impl/portable/portable_writer_impl.h |  859 ++++++++
 .../cpp/core/include/ignite/portable/portable.h |   29 +
 .../include/ignite/portable/portable_consts.h   |  106 +
 .../ignite/portable/portable_containers.h       |  525 +++++
 .../ignite/portable/portable_raw_reader.h       |  324 +++
 .../ignite/portable/portable_raw_writer.h       |  300 +++
 .../include/ignite/portable/portable_reader.h   |  355 ++++
 .../include/ignite/portable/portable_type.h     |  293 +++
 .../include/ignite/portable/portable_writer.h   |  335 +++
 .../main/cpp/core/os/linux/include/Makefile.am  |   20 +
 .../core/os/linux/include/ignite/impl/utils.h   |  155 ++
 .../main/cpp/core/os/linux/src/impl/utils.cpp   |  439 ++++
 .../cpp/core/os/win/include/ignite/impl/utils.h |  155 ++
 .../src/main/cpp/core/os/win/src/impl/utils.cpp |  453 ++++
 .../src/main/cpp/core/project/README.TXT        |    1 +
 .../src/main/cpp/core/project/vs/README.TXT     |    1 +
 .../src/main/cpp/core/project/vs/core.vcxproj   |  272 +++
 .../cpp/core/project/vs/core.vcxproj.filters    |  246 +++
 .../main/cpp/core/project/vs/core.vcxprojrel    |  272 +++
 modules/platform/src/main/cpp/core/src/guid.cpp |   65 +
 .../platform/src/main/cpp/core/src/ignite.cpp   |   43 +
 .../src/main/cpp/core/src/ignite_error.cpp      |  222 ++
 .../platform/src/main/cpp/core/src/ignition.cpp |  468 +++++
 .../main/cpp/core/src/impl/cache/cache_impl.cpp |  388 ++++
 .../core/src/impl/cache/query/query_impl.cpp    |  193 ++
 .../main/cpp/core/src/impl/handle_registry.cpp  |  234 +++
 .../cpp/core/src/impl/ignite_environment.cpp    |  166 ++
 .../src/main/cpp/core/src/impl/ignite_impl.cpp  |   42 +
 .../src/impl/interop/interop_input_stream.cpp   |  215 ++
 .../core/src/impl/interop/interop_memory.cpp    |  182 ++
 .../src/impl/interop/interop_output_stream.cpp  |  215 ++
 .../impl/portable/portable_metadata_handler.cpp |   78 +
 .../impl/portable/portable_metadata_manager.cpp |  201 ++
 .../portable/portable_metadata_snapshot.cpp     |   70 +
 .../impl/portable/portable_metadata_updater.cpp |   32 +
 .../portable/portable_metadata_updater_impl.cpp |   94 +
 .../src/impl/portable/portable_reader_impl.cpp  |  683 ++++++
 .../core/src/impl/portable/portable_utils.cpp   |  214 ++
 .../src/impl/portable/portable_writer_impl.cpp  |  600 ++++++
 .../core/src/portable/portable_containers.cpp   |   76 +
 .../core/src/portable/portable_raw_reader.cpp   |  135 ++
 .../core/src/portable/portable_raw_writer.cpp   |  147 ++
 .../cpp/core/src/portable/portable_reader.cpp   |  142 ++
 .../cpp/core/src/portable/portable_type.cpp     |   51 +
 .../cpp/core/src/portable/portable_writer.cpp   |  154 ++
 parent/pom.xml                                  |   10 +-
 113 files changed, 25382 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/licenses/apache-2.0.txt
----------------------------------------------------------------------
diff --git a/modules/platform/licenses/apache-2.0.txt b/modules/platform/licenses/apache-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/modules/platform/licenses/apache-2.0.txt
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/common/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/configure.ac b/modules/platform/src/main/cpp/common/configure.ac
index 7706737..b34d7d8 100644
--- a/modules/platform/src/main/cpp/common/configure.ac
+++ b/modules/platform/src/main/cpp/common/configure.ac
@@ -19,7 +19,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.69])
-AC_INIT([Ignite JNI bridge for C++], [7.4.1], [dev@ignite.apache.org], [ignite-common], [ignite.apache.org])
+AC_INIT([Apache Ignite JNI bridge for C++], [1.4.0], [dev@ignite.apache.org], [ignite-common], [ignite.apache.org])
 AC_CONFIG_SRCDIR(src)
 
 AC_CANONICAL_SYSTEM

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/common/ignite-common.pc.in
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/ignite-common.pc.in b/modules/platform/src/main/cpp/common/ignite-common.pc.in
index 3cd3cec..b8c40d2 100644
--- a/modules/platform/src/main/cpp/common/ignite-common.pc.in
+++ b/modules/platform/src/main/cpp/common/ignite-common.pc.in
@@ -4,6 +4,6 @@ libdir=@libdir@
 includedir=@includedir@
 
 Name: ignite-common
-Description: Ignite JNI bridge for C++.
+Description: Apache Ignite JNI bridge for C++.
 Version: @PACKAGE_VERSION@
 Libs: -L${libdir} -lignite-common

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/common/include/ignite/common/exports.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/include/ignite/common/exports.h b/modules/platform/src/main/cpp/common/include/ignite/common/exports.h
index 48e86f0..930fad3 100644
--- a/modules/platform/src/main/cpp/common/include/ignite/common/exports.h
+++ b/modules/platform/src/main/cpp/common/include/ignite/common/exports.h
@@ -25,10 +25,10 @@ namespace gcj = ignite::common::java;
 extern "C" {
     int IGNITE_CALL IgniteReallocate(long long memPtr, int cap);
 
-    void* IGNITE_CALL IgniteIgnitionStart(gcj::JniContext* ctx, char* cfgPath, char* gridName, int factoryId, long long dataPtr);
-    void* IGNITE_CALL IgniteIgnitionInstance(gcj::JniContext* ctx, char* gridName);
-    long long IGNITE_CALL IgniteIgnitionEnvironmentPointer(gcj::JniContext* ctx, char* gridName);
-    bool IGNITE_CALL IgniteIgnitionStop(gcj::JniContext* ctx, char* gridName, bool cancel);
+    void* IGNITE_CALL IgniteIgnitionStart(gcj::JniContext* ctx, char* cfgPath, char* name, int factoryId, long long dataPtr);
+    void* IGNITE_CALL IgniteIgnitionInstance(gcj::JniContext* ctx, char* name);
+    long long IGNITE_CALL IgniteIgnitionEnvironmentPointer(gcj::JniContext* ctx, char* name);
+    bool IGNITE_CALL IgniteIgnitionStop(gcj::JniContext* ctx, char* name, bool cancel);
     void IGNITE_CALL IgniteIgnitionStopAll(gcj::JniContext* ctx, bool cancel);
 
     void IGNITE_CALL IgniteProcessorReleaseStart(gcj::JniContext* ctx, void* obj);

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/common/include/ignite/common/java.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/include/ignite/common/java.h b/modules/platform/src/main/cpp/common/include/ignite/common/java.h
index 426ac68..e2d23b2 100644
--- a/modules/platform/src/main/cpp/common/include/ignite/common/java.h
+++ b/modules/platform/src/main/cpp/common/include/ignite/common/java.h
@@ -449,14 +449,14 @@ namespace ignite
                 static void Detach();
                 static void Release(jobject obj);
 
-                jobject IgnitionStart(char* cfgPath, char* gridName, int factoryId, long long dataPtr);
-                jobject IgnitionStart(char* cfgPath, char* gridName, int factoryId, long long dataPtr, JniErrorInfo* errInfo);
-                jobject IgnitionInstance(char* gridName);
-                jobject IgnitionInstance(char* gridName, JniErrorInfo* errInfo);
-                long long IgnitionEnvironmentPointer(char* gridName);
-                long long IgnitionEnvironmentPointer(char* gridName, JniErrorInfo* errInfo);
-                bool IgnitionStop(char* gridName, bool cancel);
-                bool IgnitionStop(char* gridName, bool cancel, JniErrorInfo* errInfo);
+                jobject IgnitionStart(char* cfgPath, char* name, int factoryId, long long dataPtr);
+                jobject IgnitionStart(char* cfgPath, char* name, int factoryId, long long dataPtr, JniErrorInfo* errInfo);
+                jobject IgnitionInstance(char* name);
+                jobject IgnitionInstance(char* name, JniErrorInfo* errInfo);
+                long long IgnitionEnvironmentPointer(char* name);
+                long long IgnitionEnvironmentPointer(char* name, JniErrorInfo* errInfo);
+                bool IgnitionStop(char* name, bool cancel);
+                bool IgnitionStop(char* name, bool cancel, JniErrorInfo* errInfo);
                 void IgnitionStopAll(bool cancel);
                 void IgnitionStopAll(bool cancel, JniErrorInfo* errInfo);
                 

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/common/src/exports.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/src/exports.cpp b/modules/platform/src/main/cpp/common/src/exports.cpp
index 10e4801..2ac3340 100644
--- a/modules/platform/src/main/cpp/common/src/exports.cpp
+++ b/modules/platform/src/main/cpp/common/src/exports.cpp
@@ -26,20 +26,20 @@ extern "C" {
         return gcj::JniContext::Reallocate(memPtr, cap);
     }
 
-    void* IGNITE_CALL IgniteIgnitionStart(gcj::JniContext* ctx, char* cfgPath, char* gridName, int factoryId, long long dataPtr) {
-        return ctx->IgnitionStart(cfgPath, gridName, factoryId, dataPtr);
+    void* IGNITE_CALL IgniteIgnitionStart(gcj::JniContext* ctx, char* cfgPath, char* name, int factoryId, long long dataPtr) {
+        return ctx->IgnitionStart(cfgPath, name, factoryId, dataPtr);
     }
 
-	void* IGNITE_CALL IgniteIgnitionInstance(gcj::JniContext* ctx, char* gridName) {
-        return ctx->IgnitionInstance(gridName);
+	void* IGNITE_CALL IgniteIgnitionInstance(gcj::JniContext* ctx, char* name) {
+        return ctx->IgnitionInstance(name);
     }
 
-    long long IGNITE_CALL IgniteIgnitionEnvironmentPointer(gcj::JniContext* ctx, char* gridName) {
-        return ctx->IgnitionEnvironmentPointer(gridName);
+    long long IGNITE_CALL IgniteIgnitionEnvironmentPointer(gcj::JniContext* ctx, char* name) {
+        return ctx->IgnitionEnvironmentPointer(name);
     }
 
-	bool IGNITE_CALL IgniteIgnitionStop(gcj::JniContext* ctx, char* gridName, bool cancel) {
-        return ctx->IgnitionStop(gridName, cancel);
+	bool IGNITE_CALL IgniteIgnitionStop(gcj::JniContext* ctx, char* name, bool cancel) {
+        return ctx->IgnitionStop(name, cancel);
     }
 
 	void IGNITE_CALL IgniteIgnitionStopAll(gcj::JniContext* ctx, bool cancel) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/common/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/src/java.cpp b/modules/platform/src/main/cpp/common/src/java.cpp
index 0c6524b..5c5911a 100644
--- a/modules/platform/src/main/cpp/common/src/java.cpp
+++ b/modules/platform/src/main/cpp/common/src/java.cpp
@@ -919,22 +919,22 @@ namespace ignite
                 }
             }
 
-            jobject JniContext::IgnitionStart(char* cfgPath, char* gridName, int factoryId, long long dataPtr) {
-                return IgnitionStart(cfgPath, gridName, factoryId, dataPtr, NULL);
+            jobject JniContext::IgnitionStart(char* cfgPath, char* name, int factoryId, long long dataPtr) {
+                return IgnitionStart(cfgPath, name, factoryId, dataPtr, NULL);
             }
             
-            jobject JniContext::IgnitionStart(char* cfgPath, char* gridName, int factoryId, long long dataPtr, JniErrorInfo* errInfo)
+            jobject JniContext::IgnitionStart(char* cfgPath, char* name, int factoryId, long long dataPtr, JniErrorInfo* errInfo)
             {
                 JNIEnv* env = Attach();
 
                 jstring cfgPath0 = env->NewStringUTF(cfgPath);
-                jstring gridName0 = env->NewStringUTF(gridName);
+                jstring name0 = env->NewStringUTF(name);
 
                 jobject interop = env->CallStaticObjectMethod(
                     jvm->GetMembers().c_PlatformIgnition,
                     jvm->GetMembers().m_PlatformIgnition_start,
                     cfgPath0,
-                    gridName0,
+                    name0,
                     factoryId,
                     reinterpret_cast<long long>(&hnds),
                     dataPtr
@@ -946,57 +946,57 @@ namespace ignite
             }
 
 
-            jobject JniContext::IgnitionInstance(char* gridName)
+            jobject JniContext::IgnitionInstance(char* name)
             {
-                return IgnitionInstance(gridName, NULL);
+                return IgnitionInstance(name, NULL);
             }
 
-            jobject JniContext::IgnitionInstance(char* gridName, JniErrorInfo* errInfo)
+            jobject JniContext::IgnitionInstance(char* name, JniErrorInfo* errInfo)
             {
                 JNIEnv* env = Attach();
 
-                jstring gridName0 = env->NewStringUTF(gridName);
+                jstring name0 = env->NewStringUTF(name);
 
                 jobject interop = env->CallStaticObjectMethod(jvm->GetMembers().c_PlatformIgnition,
-                    jvm->GetMembers().m_PlatformIgnition_instance, gridName0);
+                    jvm->GetMembers().m_PlatformIgnition_instance, name0);
 
                 ExceptionCheck(env, errInfo);
 
                 return LocalToGlobal(env, interop);
             }
 
-            long long JniContext::IgnitionEnvironmentPointer(char* gridName)
+            long long JniContext::IgnitionEnvironmentPointer(char* name)
             {
-                return IgnitionEnvironmentPointer(gridName, NULL);
+                return IgnitionEnvironmentPointer(name, NULL);
             }
 
-            long long JniContext::IgnitionEnvironmentPointer(char* gridName, JniErrorInfo* errInfo)
+            long long JniContext::IgnitionEnvironmentPointer(char* name, JniErrorInfo* errInfo)
             {
                 JNIEnv* env = Attach();
 
-                jstring gridName0 = env->NewStringUTF(gridName);
+                jstring name0 = env->NewStringUTF(name);
 
                 long long res = env->CallStaticLongMethod(jvm->GetMembers().c_PlatformIgnition,
-                    jvm->GetMembers().m_PlatformIgnition_environmentPointer, gridName0);
+                    jvm->GetMembers().m_PlatformIgnition_environmentPointer, name0);
 
                 ExceptionCheck(env, errInfo);
 
                 return res;
             }
 
-            bool JniContext::IgnitionStop(char* gridName, bool cancel)
+            bool JniContext::IgnitionStop(char* name, bool cancel)
             {
-                return IgnitionStop(gridName, cancel, NULL);
+                return IgnitionStop(name, cancel, NULL);
             }
 
-            bool JniContext::IgnitionStop(char* gridName, bool cancel, JniErrorInfo* errInfo)
+            bool JniContext::IgnitionStop(char* name, bool cancel, JniErrorInfo* errInfo)
             {
                 JNIEnv* env = Attach();
 
-                jstring gridName0 = env->NewStringUTF(gridName);
+                jstring name0 = env->NewStringUTF(name);
 
-                jboolean res = env->CallStaticBooleanMethod(jvm->GetMembers().c_PlatformIgnition, jvm->GetMembers().m_PlatformIgnition_stop,
-                    gridName0, cancel);
+                jboolean res = env->CallStaticBooleanMethod(jvm->GetMembers().c_PlatformIgnition,
+                    jvm->GetMembers().m_PlatformIgnition_stop, name0, cancel);
 
                 ExceptionCheck(env, errInfo);
 
@@ -1012,7 +1012,8 @@ namespace ignite
             {
                 JNIEnv* env = Attach();
 
-                env->CallStaticVoidMethod(jvm->GetMembers().c_PlatformIgnition, jvm->GetMembers().m_PlatformIgnition_stopAll, cancel);
+                env->CallStaticVoidMethod(jvm->GetMembers().c_PlatformIgnition,
+                    jvm->GetMembers().m_PlatformIgnition_stopAll, cancel);
 
                 ExceptionCheck(env, errInfo);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/Makefile.am b/modules/platform/src/main/cpp/core-test/Makefile.am
new file mode 100644
index 0000000..9ed3111
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/Makefile.am
@@ -0,0 +1,49 @@
+##
+## 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.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+SUBDIRS = . include
+DIST_SUBDIRS = . include
+
+AM_CPPFLAGS = -I$(srcdir)/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -DIGNITE_IMPL
+AM_CXXFLAGS = -Wall -std=c++0x
+
+noinst_PROGRAMS = ignite-tests
+
+ignite_tests_SOURCES = src/cache_test.cpp \
+                         src/cache_query_test.cpp \
+                         src/concurrent_test.cpp \
+                         src/ignition_test.cpp \
+                         src/handle_registry_test.cpp \
+                         src/portable_test_defs.cpp \
+                         src/portable_reader_writer_raw_test.cpp \
+                         src/portable_reader_writer_test.cpp \
+                         src/portable_session_test.cpp \
+                         src/teamcity_messages.cpp \
+                         src/teamcity_boost.cpp
+
+ignite_tests_LDFLAGS = -static-libtool-libs -L/usr/local/lib -lignite
+
+run-check: check
+	./ignite-tests -p
+
+clean-local: clean-check
+	$(RM) *.gcno *.gcda
+
+clean-check:
+	$(RM) $(ignite_tests_OBJECTS)

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/config/cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/config/cache-query.xml b/modules/platform/src/main/cpp/core-test/config/cache-query.xml
new file mode 100644
index 0000000..160fe49
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/config/cache-query.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    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.
+-->
+
+<!--
+    Ignite Spring configuration file to startup grid cache.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="localHost" value="127.0.0.1"/>
+        <property name="connectorConfiguration"><null/></property>
+
+        <property name="cacheConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="cache"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
+                    <property name="affinity">
+                        <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+                            <property name="partitions" value="256"/>
+                        </bean>
+                    </property>
+                    
+                    <property name="typeMetadata">
+                        <list>
+                            <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+                                <property name="valueType" value="QueryPerson"/>
+                                <property name="ascendingFields">
+                                    <map>
+                                        <entry key="age" value="java.lang.Integer"/>
+                                    </map>
+                                </property>
+                                <property name="queryFields">
+                                    <map>
+                                        <entry key="name" value="java.lang.String"/>
+                                        <entry key="age" value="java.lang.Integer"/>
+                                    </map>
+                                </property>
+                                <property name="textFields">
+                                    <list>
+                                        <value>name</value>
+                                    </list>
+                                </property>
+                            </bean>
+                        </list>
+                    </property>
+                </bean>
+            </list>
+        </property>
+
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47501</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/config/cache-test.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/config/cache-test.xml b/modules/platform/src/main/cpp/core-test/config/cache-test.xml
new file mode 100644
index 0000000..f239ba9
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/config/cache-test.xml
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    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.
+-->
+
+<!--
+    Ignite Spring configuration file to startup grid cache.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="localHost" value="127.0.0.1"/>
+        <property name="connectorConfiguration"><null/></property>
+
+        <property name="includeEventTypes">
+            <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+        </property>
+
+        <property name="cacheConfiguration">
+            <list>
+                <bean parent="cache-template">
+                    <property name="name" value="local"/>
+                    <property name="cacheMode" value="LOCAL"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="local_atomic"/>
+                    <property name="cacheMode" value="LOCAL"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="partitioned"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="partitioned_atomic"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="atomicWriteOrderMode" value="PRIMARY"/>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="partitioned_near"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="nearConfiguration">
+                        <bean class="org.apache.ignite.configuration.NearCacheConfiguration" />
+                    </property>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="partitioned_atomic_near"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="atomicWriteOrderMode" value="PRIMARY"/>
+                    <property name="nearConfiguration">
+                        <bean class="org.apache.ignite.configuration.NearCacheConfiguration" />
+                    </property>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="replicated"/>
+                    <property name="cacheMode" value="REPLICATED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="replicated_atomic"/>
+                    <property name="cacheMode" value="REPLICATED"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="atomicWriteOrderMode" value="PRIMARY"/>
+                </bean>
+            </list>
+        </property>
+
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47501</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+
+        <property name="transactionConfiguration">
+            <bean class="org.apache.ignite.configuration.TransactionConfiguration">
+                <property name="txSerializableEnabled" value="true"/>
+            </bean>
+        </property>
+    </bean>
+
+    <bean id="cache-template" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
+        <property name="rebalanceMode" value="SYNC"/>
+        <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+        <property name="swapEnabled" value="true"/>
+        <property name="backups" value="1"/>
+        <property name="eagerTtl" value="true"/>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/configure.ac b/modules/platform/src/main/cpp/core-test/configure.ac
new file mode 100644
index 0000000..3a1b660
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/configure.ac
@@ -0,0 +1,62 @@
+#
+# 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.
+#
+
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([Apache Ignite C++ Test], [1.4.0], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_CONFIG_SRCDIR(src)
+
+AC_CANONICAL_SYSTEM
+AC_CONFIG_MACRO_DIR([m4])
+AC_LANG([C++])
+
+# Initialize automake
+AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
+AC_CONFIG_HEADER(config.h)
+
+AM_PROG_AR
+
+# Checks for programs.
+GXX="-g -O2"
+
+AC_PROG_CXX
+
+# Initialize Libtool
+LT_INIT
+
+# Checks for libraries.
+AC_CHECK_LIB([pthread], [pthread_mutex_lock])
+
+# Checks for header files.
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_FUNC_ERROR_AT_LINE
+
+AC_CONFIG_FILES(Makefile include/Makefile)
+
+AC_OUTPUT

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/include/Makefile.am b/modules/platform/src/main/cpp/core-test/include/Makefile.am
new file mode 100644
index 0000000..c43103e
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/include/Makefile.am
@@ -0,0 +1,22 @@
+##
+## 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.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+nobase_include_HEADERS = teamcity_messages.h \
+                         ignite/portable_test_defs.h \
+                         ignite/portable_test_utils.h

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/include/ignite/portable_test_defs.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/include/ignite/portable_test_defs.h b/modules/platform/src/main/cpp/core-test/include/ignite/portable_test_defs.h
new file mode 100644
index 0000000..bae0118
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/include/ignite/portable_test_defs.h
@@ -0,0 +1,320 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_PORTABLE_TEST_DEFS
+#define _IGNITE_PORTABLE_TEST_DEFS
+
+#include <stdexcept>
+#include <stdint.h>
+
+#include "ignite/portable/portable.h"
+
+namespace ignite_test
+{
+    namespace core
+    {
+        namespace portable 
+        {
+            class PortableDummy
+            {
+                // No-op.
+            };
+
+            class PortableInner 
+            {
+            public:
+                PortableInner();
+
+                PortableInner(int32_t val);
+
+                int32_t GetValue() const;
+            private:
+                int32_t val;
+            };
+
+            class PortableOuter
+            {
+            public:
+                PortableOuter(int32_t valIn, int32_t valOut);
+
+                PortableInner GetInner() const;
+
+                int32_t GetValue() const;
+            private:
+                PortableInner inner;
+                int32_t val;
+            };
+
+            struct PortableFields
+            {
+                int32_t val1;
+                int32_t val2;
+                int32_t rawVal1;
+                int32_t rawVal2;
+
+                PortableFields() : val1(0), val2(0), rawVal1(0), rawVal2(0)
+                {
+                    // No-op.
+                }
+
+                PortableFields(int32_t val1, int32_t val2, int32_t rawVal1, int32_t rawVal2) :
+                    val1(val1), val2(val2), rawVal1(rawVal1), rawVal2(rawVal2)
+                {
+                    // No-op.   
+                }
+            };
+        }
+    }
+}
+
+namespace ignite
+{
+    namespace portable
+    {
+        namespace gt = ignite_test::core::portable;
+
+        template<>
+        struct PortableType<gt::PortableDummy>
+        {
+            /** <inheritdoc /> */
+            int32_t GetTypeId()
+            {
+                return GetPortableStringHashCode("PortableDummy");
+            }
+
+            /** <inheritdoc /> */
+            std::string GetTypeName()
+            {
+                return "PortableDummy";
+            }
+
+            /** <inheritdoc /> */
+            int32_t GetFieldId(const char* name)
+            {
+                return GetPortableStringHashCode(name);
+            }
+
+            /** <inheritdoc /> */
+            int32_t GetHashCode(const gt::PortableInner& obj)
+            {
+                return obj.GetValue();
+            }
+
+            /** <inheritdoc /> */
+            bool IsNull(const gt::PortableInner& obj)
+            {
+                return obj.GetValue() == 0;
+            }
+
+            /** <inheritdoc /> */
+            gt::PortableInner GetNull()
+            {
+                return gt::PortableInner(0);
+            }
+
+            /** <inheritdoc /> */
+            void Write(PortableWriter& writer, const gt::PortableDummy& obj)
+            {
+                // No-op.
+            }
+
+            /** <inheritdoc /> */
+            gt::PortableDummy Read(PortableReader& reader)
+            {
+                return gt::PortableDummy();
+            }
+        };
+
+        template<> 
+        struct PortableType<gt::PortableInner>
+        {
+            /** <inheritdoc /> */
+            int32_t GetTypeId() 
+            { 
+                return GetPortableStringHashCode("PortableInner"); 
+            }
+
+            /** <inheritdoc /> */
+            std::string GetTypeName()
+            {
+                return "PortableInner";
+            }
+
+            /** <inheritdoc /> */
+            int32_t GetFieldId(const char* name) 
+            { 
+                return GetPortableStringHashCode(name); 
+            }
+
+            /** <inheritdoc /> */
+            int32_t GetHashCode(const gt::PortableInner& obj)
+            {
+                return obj.GetValue();
+            }
+
+            /** <inheritdoc /> */
+            bool IsNull(const gt::PortableInner& obj)
+            {
+                return obj.GetValue() == 0;
+            }
+
+            /** <inheritdoc /> */
+            gt::PortableInner GetNull()
+            {
+                return gt::PortableInner(0);
+            }
+
+            /** <inheritdoc /> */
+            void Write(PortableWriter& writer, const gt::PortableInner& obj)
+            {
+                writer.WriteInt32("val", obj.GetValue());
+            }
+
+            /** <inheritdoc /> */
+            gt::PortableInner Read(PortableReader& reader)
+            {
+                int val = reader.ReadInt32("val");
+
+                return gt::PortableInner(val);
+            }
+        };
+
+        template<>
+        struct PortableType<gt::PortableOuter>
+        {
+            /** <inheritdoc /> */
+            int32_t GetTypeId()
+            {
+                return GetPortableStringHashCode("PortableOuter");
+            }
+
+            /** <inheritdoc /> */
+            std::string GetTypeName()
+            {
+                return "PortableOuter";
+            }
+
+            /** <inheritdoc /> */
+            int32_t GetFieldId(const char* name)
+            {
+                return GetPortableStringHashCode(name);
+            }
+
+            /** <inheritdoc /> */
+            int32_t GetHashCode(const gt::PortableOuter& obj)
+            {
+                return obj.GetValue() + obj.GetInner().GetValue();
+            }
+
+            /** <inheritdoc /> */
+            bool IsNull(const gt::PortableOuter& obj)
+            {
+                return obj.GetValue() == 0 && obj.GetInner().GetValue();
+            }
+
+            /** <inheritdoc /> */
+            gt::PortableOuter GetNull()
+            {
+                return gt::PortableOuter(0, 0);
+            }
+
+            /** <inheritdoc /> */
+            void Write(PortableWriter& writer, const gt::PortableOuter& obj)
+            {
+                writer.WriteObject("inner", obj.GetInner());
+                writer.WriteInt32("val", obj.GetValue());                
+            }
+
+            /** <inheritdoc /> */
+            gt::PortableOuter Read(PortableReader& reader)
+            {
+                gt::PortableInner inner = reader.ReadObject<gt::PortableInner>("inner");
+                int val = reader.ReadInt32("val");
+
+                return gt::PortableOuter(inner.GetValue(), val);
+            }
+        };
+
+        template<>
+        struct PortableType<gt::PortableFields>
+        {
+            /** <inheritdoc /> */
+            int32_t GetTypeId()
+            {
+                return GetPortableStringHashCode("PortableFields");
+            }
+
+            /** <inheritdoc /> */
+            std::string GetTypeName()
+            {
+                return "PortableFields";
+            }
+
+            /** <inheritdoc /> */
+            int32_t GetFieldId(const char* name)
+            {
+                return GetPortableStringHashCode(name);
+            }
+
+            /** <inheritdoc /> */
+            int32_t GetHashCode(const gt::PortableFields& obj)
+            {
+                return obj.val1 + obj.val2 + obj.rawVal1 + obj.rawVal2;
+            }
+
+            /** <inheritdoc /> */
+            bool IsNull(const gt::PortableFields& obj)
+            {
+                return false;
+            }
+
+            /** <inheritdoc /> */
+            gt::PortableFields GetNull()
+            {
+                throw std::runtime_error("Must not be called.");
+            }
+
+            /** <inheritdoc /> */
+            void Write(PortableWriter& writer, const gt::PortableFields& obj)
+            {
+                writer.WriteInt32("val1", obj.val1);
+                writer.WriteInt32("val2", obj.val2);
+
+                PortableRawWriter rawWriter = writer.RawWriter();
+
+                rawWriter.WriteInt32(obj.rawVal1);
+                rawWriter.WriteInt32(obj.rawVal2);
+            }
+
+            /** <inheritdoc /> */
+            gt::PortableFields Read(PortableReader& reader)
+            {
+                int32_t val1 = reader.ReadInt32("val1");
+                int32_t val2 = reader.ReadInt32("val2");
+
+                PortableRawReader rawReader = reader.RawReader();
+
+                int32_t rawVal1 = rawReader.ReadInt32();
+                int32_t rawVal2 = rawReader.ReadInt32();
+
+                return gt::PortableFields(val1, val2, rawVal1, rawVal2);
+            }
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/include/ignite/portable_test_utils.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/include/ignite/portable_test_utils.h b/modules/platform/src/main/cpp/core-test/include/ignite/portable_test_utils.h
new file mode 100644
index 0000000..62f99f9
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/include/ignite/portable_test_utils.h
@@ -0,0 +1,516 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_PORTABLE_TEST_UTILS
+#define _IGNITE_PORTABLE_TEST_UTILS
+
+#include "ignite/portable/portable.h"
+
+using namespace ignite;
+using namespace ignite::portable;
+using namespace ignite::impl::portable;
+
+namespace ignite_test
+{
+    namespace core
+    {
+        namespace portable
+        {
+            template<typename T>
+            inline void Write(PortableRawWriter& writer, T val)
+            {
+                throw std::runtime_error("Function is not defined");
+            }
+
+            template<typename T>
+            inline T Read(PortableRawReader& reader)
+            {
+                throw std::runtime_error("Function is not defined");
+            }
+
+            template<>
+            inline void Write(PortableRawWriter& writer, int8_t val)
+            {
+                writer.WriteInt8(val);
+            }
+
+            template<>
+            inline int8_t Read(PortableRawReader& reader)
+            {
+                return reader.ReadInt8();
+            }
+
+            template<>
+            inline void Write(PortableRawWriter& writer, bool val)
+            {
+                writer.WriteBool(val);
+            }
+
+            template<>
+            inline bool Read(PortableRawReader& reader)
+            {
+                return reader.ReadBool();
+            }
+
+            template<>
+            inline void Write(PortableRawWriter& writer, int16_t val)
+            {
+                writer.WriteInt16(val);
+            }
+
+            template<>
+            inline int16_t Read(PortableRawReader& reader)
+            {
+                return reader.ReadInt16();
+            }
+
+            template<>
+            inline void Write(PortableRawWriter& writer, uint16_t val)
+            {
+                writer.WriteUInt16(val);
+            }
+
+            template<>
+            inline uint16_t Read(PortableRawReader& reader)
+            {
+                return reader.ReadUInt16();
+            }
+
+            template<>
+            inline void Write(PortableRawWriter& writer, int32_t val)
+            {
+                writer.WriteInt32(val);
+            }
+
+            template<>
+            inline int32_t Read(PortableRawReader& reader)
+            {
+                return reader.ReadInt32();
+            }
+
+            template<>
+            inline void Write(PortableRawWriter& writer, int64_t val)
+            {
+                writer.WriteInt64(val);
+            }
+
+            template<>
+            inline int64_t Read(PortableRawReader& reader)
+            {
+                return reader.ReadInt64();
+            }
+
+            template<>
+            inline void Write(PortableRawWriter& writer, float val)
+            {
+                writer.WriteFloat(val);
+            }
+
+            template<>
+            inline float Read(PortableRawReader& reader)
+            {
+                return reader.ReadFloat();
+            }
+
+            template<>
+            inline void Write(PortableRawWriter& writer, double val)
+            {
+                writer.WriteDouble(val);
+            }
+
+            template<>
+            inline double Read(PortableRawReader& reader)
+            {
+                return reader.ReadDouble();
+            }
+
+            template<>
+            inline void Write(PortableRawWriter& writer, Guid val)
+            {
+                writer.WriteGuid(val);
+            }
+
+            template<>
+            inline Guid Read(PortableRawReader& reader)
+            {
+                return reader.ReadGuid();
+            }
+
+            template<typename T>
+            inline void WriteArray(PortableRawWriter& writer, T* val, int32_t len)
+            {
+                throw std::runtime_error("Function is not defined");
+            }
+
+            template<typename T>
+            inline int32_t ReadArray(PortableRawReader& reader, T* val, int32_t len)
+            {
+                throw std::runtime_error("Function is not defined");
+            }
+
+            template<>
+            inline void WriteArray(PortableRawWriter& writer, int8_t* val, int32_t len)
+            {
+                writer.WriteInt8Array(val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableRawReader& reader, int8_t* val, int32_t len)
+            {
+                return reader.ReadInt8Array(val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableRawWriter& writer, bool* val, int32_t len)
+            {
+                writer.WriteBoolArray(val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableRawReader& reader, bool* val, int32_t len)
+            {
+                return reader.ReadBoolArray(val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableRawWriter& writer, int16_t* val, int32_t len)
+            {
+                writer.WriteInt16Array(val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableRawReader& reader, int16_t* val, int32_t len)
+            {
+                return reader.ReadInt16Array(val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableRawWriter& writer, uint16_t* val, int32_t len)
+            {
+                writer.WriteUInt16Array(val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableRawReader& reader, uint16_t* val, int32_t len)
+            {
+                return reader.ReadUInt16Array(val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableRawWriter& writer, int32_t* val, int32_t len)
+            {
+                writer.WriteInt32Array(val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableRawReader& reader, int32_t* val, int32_t len)
+            {
+                return reader.ReadInt32Array(val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableRawWriter& writer, int64_t* val, int32_t len)
+            {
+                writer.WriteInt64Array(val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableRawReader& reader, int64_t* val, int32_t len)
+            {
+                return reader.ReadInt64Array(val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableRawWriter& writer, float* val, int32_t len)
+            {
+                writer.WriteFloatArray(val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableRawReader& reader, float* val, int32_t len)
+            {
+                return reader.ReadFloatArray(val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableRawWriter& writer, double* val, int32_t len)
+            {
+                writer.WriteDoubleArray(val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableRawReader& reader, double* val, int32_t len)
+            {
+                return reader.ReadDoubleArray(val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableRawWriter& writer, Guid* val, int32_t len)
+            {
+                writer.WriteGuidArray(val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableRawReader& reader, Guid* val, int32_t len)
+            {
+                return reader.ReadGuidArray(val, len);
+            }
+
+            template<typename T>
+            inline void Write(PortableWriter& writer, const char* fieldName, T val)
+            {
+                throw std::runtime_error("Function is not defined");
+            }
+
+            template<typename T>
+            inline T Read(PortableReader& reader, const char* fieldName)
+            {
+                throw std::runtime_error("Function is not defined");
+            }
+
+            template<>
+            inline void Write(PortableWriter& writer, const char* fieldName, int8_t val)
+            {
+                writer.WriteInt8(fieldName, val);
+            }
+
+            template<>
+            inline int8_t Read(PortableReader& reader, const char* fieldName)
+            {
+                return reader.ReadInt8(fieldName);
+            }
+
+            template<>
+            inline void Write(PortableWriter& writer, const char* fieldName, bool val)
+            {
+                writer.WriteBool(fieldName, val);
+            }
+
+            template<>
+            inline bool Read(PortableReader& reader, const char* fieldName)
+            {
+                return reader.ReadBool(fieldName);
+            }
+
+            template<>
+            inline void Write(PortableWriter& writer, const char* fieldName, int16_t val)
+            {
+                writer.WriteInt16(fieldName, val);
+            }
+
+            template<>
+            inline int16_t Read(PortableReader& reader, const char* fieldName)
+            {
+                return reader.ReadInt16(fieldName);
+            }
+
+            template<>
+            inline void Write(PortableWriter& writer, const char* fieldName, uint16_t val)
+            {
+                writer.WriteUInt16(fieldName, val);
+            }
+
+            template<>
+            inline uint16_t Read(PortableReader& reader, const char* fieldName)
+            {
+                return reader.ReadUInt16(fieldName);
+            }
+
+            template<>
+            inline void Write(PortableWriter& writer, const char* fieldName, int32_t val)
+            {
+                writer.WriteInt32(fieldName, val);
+            }
+
+            template<>
+            inline int32_t Read(PortableReader& reader, const char* fieldName)
+            {
+                return reader.ReadInt32(fieldName);
+            }
+
+            template<>
+            inline void Write(PortableWriter& writer, const char* fieldName, int64_t val)
+            {
+                writer.WriteInt64(fieldName, val);
+            }
+
+            template<>
+            inline int64_t Read(PortableReader& reader, const char* fieldName)
+            {
+                return reader.ReadInt64(fieldName);
+            }
+
+            template<>
+            inline void Write(PortableWriter& writer, const char* fieldName, float val)
+            {
+                writer.WriteFloat(fieldName, val);
+            }
+
+            template<>
+            inline float Read(PortableReader& reader, const char* fieldName)
+            {
+                return reader.ReadFloat(fieldName);
+            }
+
+            template<>
+            inline void Write(PortableWriter& writer, const char* fieldName, double val)
+            {
+                writer.WriteDouble(fieldName, val);
+            }
+
+            template<>
+            inline double Read(PortableReader& reader, const char* fieldName)
+            {
+                return reader.ReadDouble(fieldName);
+            }
+
+            template<>
+            inline void Write(PortableWriter& writer, const char* fieldName, Guid val)
+            {
+                writer.WriteGuid(fieldName, val);
+            }
+
+            template<>
+            inline Guid Read(PortableReader& reader, const char* fieldName)
+            {
+                return reader.ReadGuid(fieldName);
+            }
+
+            template<typename T>
+            inline void WriteArray(PortableWriter& writer, const char* fieldName, T* val, int32_t len)
+            {
+                throw std::runtime_error("Function is not defined");
+            }
+
+            template<typename T>
+            inline int32_t ReadArray(PortableReader& reader, const char* fieldName, T* val, int32_t len)
+            {
+                throw std::runtime_error("Function is not defined");
+            }
+
+            template<>
+            inline void WriteArray(PortableWriter& writer, const char* fieldName, int8_t* val, int32_t len)
+            {
+                writer.WriteInt8Array(fieldName, val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableReader& reader, const char* fieldName, int8_t* val, int32_t len)
+            {
+                return reader.ReadInt8Array(fieldName, val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableWriter& writer, const char* fieldName, bool* val, int32_t len)
+            {
+                writer.WriteBoolArray(fieldName, val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableReader& reader, const char* fieldName, bool* val, int32_t len)
+            {
+                return reader.ReadBoolArray(fieldName, val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableWriter& writer, const char* fieldName, int16_t* val, int32_t len)
+            {
+                writer.WriteInt16Array(fieldName, val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableReader& reader, const char* fieldName, int16_t* val, int32_t len)
+            {
+                return reader.ReadInt16Array(fieldName, val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableWriter& writer, const char* fieldName, uint16_t* val, int32_t len)
+            {
+                writer.WriteUInt16Array(fieldName, val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableReader& reader, const char* fieldName, uint16_t* val, int32_t len)
+            {
+                return reader.ReadUInt16Array(fieldName, val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableWriter& writer, const char* fieldName, int32_t* val, int32_t len)
+            {
+                writer.WriteInt32Array(fieldName, val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableReader& reader, const char* fieldName, int32_t* val, int32_t len)
+            {
+                return reader.ReadInt32Array(fieldName, val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableWriter& writer, const char* fieldName, int64_t* val, int32_t len)
+            {
+                writer.WriteInt64Array(fieldName, val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableReader& reader, const char* fieldName, int64_t* val, int32_t len)
+            {
+                return reader.ReadInt64Array(fieldName, val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableWriter& writer, const char* fieldName, float* val, int32_t len)
+            {
+                writer.WriteFloatArray(fieldName, val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableReader& reader, const char* fieldName, float* val, int32_t len)
+            {
+                return reader.ReadFloatArray(fieldName, val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableWriter& writer, const char* fieldName, double* val, int32_t len)
+            {
+                writer.WriteDoubleArray(fieldName, val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableReader& reader, const char* fieldName, double* val, int32_t len)
+            {
+                return reader.ReadDoubleArray(fieldName, val, len);
+            }
+
+            template<>
+            inline void WriteArray(PortableWriter& writer, const char* fieldName, Guid* val, int32_t len)
+            {
+                writer.WriteGuidArray(fieldName, val, len);
+            }
+
+            template<>
+            inline int32_t ReadArray(PortableReader& reader, const char* fieldName, Guid* val, int32_t len)
+            {
+                return reader.ReadGuidArray(fieldName, val, len);
+            }
+        }
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/include/teamcity_messages.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/include/teamcity_messages.h b/modules/platform/src/main/cpp/core-test/include/teamcity_messages.h
new file mode 100644
index 0000000..8cf23d0
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/include/teamcity_messages.h
@@ -0,0 +1,55 @@
+/* Copyright 2011 JetBrains s.r.o.
+ * 
+ * Licensed 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.
+ *
+ * $Revision: 88625 $
+*/
+
+#ifndef H_TEAMCITY_MESSAGES
+#define H_TEAMCITY_MESSAGES
+
+#include <string>
+#include <iostream>
+
+namespace JetBrains {
+
+std::string getFlowIdFromEnvironment();
+bool underTeamcity();
+
+class TeamcityMessages {
+    std::ostream *m_out;
+    
+protected:
+    std::string escape(std::string s);
+
+    void openMsg(const std::string &name);
+    void writeProperty(std::string name, std::string value);
+    void closeMsg();
+
+public:
+    TeamcityMessages();
+    
+    void setOutput(std::ostream &);
+    
+    void suiteStarted(std::string name, std::string flowid = "");
+    void suiteFinished(std::string name, std::string flowid = "");
+    
+    void testStarted(std::string name, std::string flowid = "");
+    void testFailed(std::string name, std::string message, std::string details, std::string flowid = "");
+    void testIgnored(std::string name, std::string message, std::string flowid = "");
+    void testFinished(std::string name, int durationMs = -1, std::string flowid = "");    
+};
+
+}
+
+#endif /* H_TEAMCITY_MESSAGES */

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/project/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/project/README.TXT b/modules/platform/src/main/cpp/core-test/project/README.TXT
new file mode 100644
index 0000000..97f4c64
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/project/README.TXT
@@ -0,0 +1 @@
+Contains IDE projects artifacts.

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/project/vs/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/project/vs/README.TXT b/modules/platform/src/main/cpp/core-test/project/vs/README.TXT
new file mode 100644
index 0000000..f4fb456
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/project/vs/README.TXT
@@ -0,0 +1 @@
+Contains Visual Studio project artifacts.
\ No newline at end of file


[25/50] [abbrv] ignite git commit: Topology validator test and javadoc improvement

Posted by ak...@apache.org.
Topology validator test and javadoc improvement


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

Branch: refs/heads/ignite-843
Commit: 2fbf328b3f5fd08f7d24d2a0dab6e482192281ad
Parents: c5d303b
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Sep 3 18:34:38 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Sep 3 18:34:38 2015 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       | 45 +++++++++++++++++++
 .../ignite/configuration/TopologyValidator.java |  4 +-
 ...gniteTopologyValidatorAbstractCacheTest.java | 46 ++++++++++++++++----
 3 files changed, 85 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2fbf328b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 792bb28..1bbc110 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -20,12 +20,14 @@ package org.apache.ignite.configuration;
 import java.io.Serializable;
 import java.util.Collection;
 import javax.cache.Cache;
+import javax.cache.CacheException;
 import javax.cache.configuration.CompleteConfiguration;
 import javax.cache.configuration.Factory;
 import javax.cache.configuration.MutableConfiguration;
 import javax.cache.expiry.ExpiryPolicy;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheEntryProcessor;
@@ -1788,6 +1790,27 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
 
     /**
      * Gets topology validator.
+     * <p>
+     * Topology validator checks whether the new topology is valid for specific cache at each topology change.
+     * Topology is always valid in case no topology validator used.
+     * <p>
+     * In case topology is valid for specific cache all operations on this cache are allowed.
+     * <p>
+     * In case topology is not valid for specific cache all update operations on this cache are restricted:
+     * <p>{@link CacheException} will be thrown at update operations (put, remove, etc) attempt.
+     * <p>{@link IgniteException} will be thrown at transaction commit attempt.
+     *
+     * <p>
+     * Usage example
+     * <p>
+     * Following validator allows to put data only in case topology contains exactly 2 nodes:
+     * <pre>{@code
+     * new TopologyValidator() {
+     *    @Override public boolean validate(Collection<ClusterNode> nodes) {
+     *       return nodes.size() == 2;
+     *    }
+     * }
+     * }</pre>
      * @return validator.
      */
     public TopologyValidator getTopologyValidator() {
@@ -1796,6 +1819,28 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
 
     /**
      * Sets topology validator.
+     * <p>
+     * Topology validator checks whether the new topology is valid for specific cache at each topology change.
+     * Topology is always valid in case no topology validator used.
+     * <p>
+     * In case topology is valid for specific cache all operations on this cache are allowed.
+     * <p>
+     * In case topology is not valid for specific cache all update operations on this cache are restricted:
+     * <p>{@link CacheException} will be thrown at update operations (put, remove, etc) attempt.
+     * <p>{@link IgniteException} will be thrown at transaction commit attempt.
+     *
+     * <p>
+     * Usage example
+     * <p>
+     * Following validator allows to put data only in case topology contains exactly 2 nodes:
+     * <pre>{@code
+     * new TopologyValidator() {
+     *    @Override public boolean validate(Collection<ClusterNode> nodes) {
+     *       return nodes.size() == 2;
+     *    }
+     * }
+     * }</pre>
+     *
      * @param topValidator validator.
      * @return {@code this} for chaining.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/2fbf328b/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java b/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
index ef9284d..49c06a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/TopologyValidator.java
@@ -27,8 +27,8 @@ import org.apache.ignite.cluster.ClusterNode;
 public interface TopologyValidator extends Serializable {
     /**
      * Validates topology.
-     * @param nodes nodes collection to be validated.
-     * @return is topology valid or not.
+     * @param nodes Collection of nodes.
+     * @return {@code true} in case topology is valid for specific cache, otherwise {@code false}
      */
     boolean validate(Collection<ClusterNode> nodes);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/2fbf328b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
index deb1fee..65f4694 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java
@@ -86,13 +86,11 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
      */
     protected void putInvalid(String cacheName) {
         try {
-            assert grid(0).cache(cacheName).get(KEY_VALUE) == null;
-
             grid(0).cache(cacheName).put(KEY_VALUE, KEY_VALUE);
 
             assert false : "topology validation broken";
         }
-        catch (IgniteException | CacheException ex) {
+        catch (CacheException ex) {
             assert ex.getCause() instanceof IgniteCheckedException &&
                 ex.getCause().getMessage().contains("cache topology is not valid");
         }
@@ -105,18 +103,47 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
      */
     protected void putValid(String cacheName) {
         try {
-            assert grid(0).cache(cacheName).get(KEY_VALUE) == null;
-
             grid(0).cache(cacheName).put(KEY_VALUE, KEY_VALUE);
 
             assert grid(0).cache(cacheName).get(KEY_VALUE).equals(KEY_VALUE);
         }
-        catch (IgniteException | CacheException ex) {
+        catch (CacheException ex) {
+            assert false : "topology validation broken";
+        }
+    }
+
+    /**
+     * Gets when topology is invalid.
+     *
+     * @param cacheName cache name.
+     */
+    protected void getInvalid(String cacheName) {
+        try {
+            assert grid(0).cache(cacheName).get(KEY_VALUE).equals(KEY_VALUE);
+        }
+        catch (CacheException ex) {
             assert false : "topology validation broken";
         }
     }
 
     /**
+     * Remove when topology is invalid.
+     *
+     * @param cacheName cache name.
+     */
+    protected void removeInvalid(String cacheName) {
+        try {
+            grid(0).cache(cacheName).remove(KEY_VALUE);
+
+            assert false : "topology validation broken";
+        }
+        catch (CacheException ex) {
+            assert ex.getCause() instanceof IgniteCheckedException &&
+                ex.getCause().getMessage().contains("cache topology is not valid");
+        }
+    }
+
+    /**
      * Commits with error.
      *
      * @param tx transaction.
@@ -125,7 +152,7 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
         try {
             tx.commit();
         }
-        catch (IgniteException | CacheException ex) {
+        catch (IgniteException ex) {
             assert ex.getCause() instanceof IgniteCheckedException &&
                 ex.getCause().getMessage().contains("cache topology is not valid");
         }
@@ -158,8 +185,10 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
         remove(null);
 
         putInvalid(CACHE_NAME_1);
+        removeInvalid(CACHE_NAME_1);
 
         putInvalid(CACHE_NAME_2);
+        removeInvalid(CACHE_NAME_2);
 
         startGrid(1);
 
@@ -167,7 +196,6 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
         remove(null);
 
         putValid(CACHE_NAME_1);
-        remove(CACHE_NAME_1);
 
         putValid(CACHE_NAME_2);
         remove(CACHE_NAME_2);
@@ -177,7 +205,9 @@ public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCac
         putValid(null);
         remove(null);
 
+        getInvalid(CACHE_NAME_1);
         putInvalid(CACHE_NAME_1);
+        removeInvalid(CACHE_NAME_1);
 
         putValid(CACHE_NAME_2);
         remove(CACHE_NAME_2);


[49/50] [abbrv] ignite git commit: Merge branches 'ignite-843' and 'master' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-843

Posted by ak...@apache.org.
Merge branches 'ignite-843' and 'master' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-843


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

Branch: refs/heads/ignite-843
Commit: 0f15b83ea3ff35b8271a28fe898034e8cc0bc437
Parents: 316b942 58a665a
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Sep 4 17:24:43 2015 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Sep 4 17:24:43 2015 +0700

----------------------------------------------------------------------
 examples/config/example-default.xml             |   76 +
 examples/config/example-ignite.xml              |   56 +-
 .../config/portable/example-ignite-portable.xml |   44 +
 examples/pom.xml                                |    2 +-
 .../ignite/examples/portable/Address.java       |   72 +
 .../ignite/examples/portable/Employee.java      |   93 +
 .../ignite/examples/portable/EmployeeKey.java   |   90 +
 .../portable/ExamplePortableNodeStartup.java    |   36 +
 .../ignite/examples/portable/Organization.java  |   93 +
 .../examples/portable/OrganizationType.java     |   32 +
 ...mputeClientPortableTaskExecutionExample.java |  154 ++
 .../portable/computegrid/ComputeClientTask.java |  116 ++
 .../portable/computegrid/package-info.java      |   21 +
 .../CacheClientPortablePutGetExample.java       |  230 +++
 .../CacheClientPortableQueryExample.java        |  328 +++
 .../portable/datagrid/package-info.java         |   21 +
 .../ignite/examples/portable/package-info.java  |   21 +
 .../java8/datagrid/CacheAffinityExample.java    |   15 +
 .../java8/messaging/MessagingExample.java       |   11 +-
 .../CacheClientPortableExampleTest.java         |   46 +
 .../ComputeClientPortableExampleTest.java       |   37 +
 .../testsuites/IgniteExamplesSelfTestSuite.java |    6 +
 .../java8/examples/BasicExamplesSelfTest.java   |   10 +-
 .../java8/examples/CacheExamplesSelfTest.java   |    8 +-
 .../examples/CheckpointExamplesSelfTest.java    |    8 +-
 .../examples/ClusterGroupExampleSelfTest.java   |    4 +-
 .../examples/ContinuationExamplesSelfTest.java  |    8 +-
 .../ContinuousMapperExamplesSelfTest.java       |    8 +-
 .../examples/DeploymentExamplesSelfTest.java    |    6 +-
 .../java8/examples/EventsExamplesSelfTest.java  |    5 +-
 .../HibernateL2CacheExampleSelfTest.java        |    8 +-
 .../java8/examples/IgfsExamplesSelfTest.java    |    6 +-
 .../examples/LifecycleExamplesSelfTest.java     |    8 +-
 .../examples/MemcacheRestExamplesSelfTest.java  |    4 +-
 .../examples/MessagingExamplesSelfTest.java     |    6 +-
 .../examples/MonteCarloExamplesSelfTest.java    |    8 +-
 .../examples/SpringBeanExamplesSelfTest.java    |    8 +-
 .../java8/examples/TaskExamplesSelfTest.java    |    4 +-
 .../IgniteExamplesJ8SelfTestSuite.java          |   12 +-
 modules/aop/pom.xml                             |    2 +-
 modules/apache-license-gen/pom.xml              |    5 +-
 modules/aws/pom.xml                             |    2 +-
 modules/clients/pom.xml                         |    2 +-
 modules/cloud/pom.xml                           |    2 +-
 modules/codegen/pom.xml                         |    2 +-
 modules/core/pom.xml                            |    2 +-
 .../configuration/CacheConfiguration.java       |   70 +-
 .../ignite/configuration/TopologyValidator.java |    4 +-
 .../apache/ignite/internal/IgniteKernal.java    |   97 +-
 .../discovery/GridDiscoveryManager.java         |   50 +-
 .../portable/GridPortableMarshaller.java        |   44 +-
 .../portable/PortableAbstractLazyValue.java     |   57 -
 .../internal/portable/PortableBuilderEnum.java  |  114 -
 .../internal/portable/PortableBuilderImpl.java  |  531 -----
 .../portable/PortableBuilderReader.java         |  776 -------
 .../PortableBuilderSerializationAware.java      |   29 -
 .../portable/PortableBuilderSerializer.java     |  211 --
 .../portable/PortableClassDescriptor.java       |   57 +-
 .../internal/portable/PortableContext.java      |    6 +-
 .../portable/PortableEnumArrayLazyValue.java    |  112 -
 .../portable/PortableLazyArrayList.java         |  159 --
 .../portable/PortableLazyLinkedList.java        |  215 --
 .../internal/portable/PortableLazyMap.java      |  218 --
 .../internal/portable/PortableLazyMapEntry.java |   66 -
 .../internal/portable/PortableLazySet.java      |   89 -
 .../internal/portable/PortableLazyValue.java    |   28 -
 .../portable/PortableObjectArrayLazyValue.java  |   89 -
 .../portable/PortablePlainLazyValue.java        |   47 -
 .../portable/PortablePlainPortableObject.java   |   50 -
 .../internal/portable/PortableReaderExImpl.java |  154 +-
 .../ignite/internal/portable/PortableUtils.java |   11 +
 .../portable/PortableValueWithType.java         |   74 -
 .../internal/portable/PortableWriterExImpl.java |  159 +-
 .../builder/PortableAbstractLazyValue.java      |   57 +
 .../portable/builder/PortableBuilderEnum.java   |  116 ++
 .../portable/builder/PortableBuilderImpl.java   |  537 +++++
 .../portable/builder/PortableBuilderReader.java |  800 +++++++
 .../PortableBuilderSerializationAware.java      |   31 +
 .../builder/PortableBuilderSerializer.java      |  214 ++
 .../builder/PortableEnumArrayLazyValue.java     |  114 +
 .../portable/builder/PortableLazyArrayList.java |  166 ++
 .../builder/PortableLazyLinkedList.java         |  217 ++
 .../portable/builder/PortableLazyMap.java       |  220 ++
 .../portable/builder/PortableLazyMapEntry.java  |   68 +
 .../portable/builder/PortableLazySet.java       |   92 +
 .../portable/builder/PortableLazyValue.java     |   28 +
 .../builder/PortableModifiableLazyValue.java    |   52 +
 .../builder/PortableObjectArrayLazyValue.java   |   91 +
 .../builder/PortablePlainLazyValue.java         |   49 +
 .../builder/PortablePlainPortableObject.java    |   53 +
 .../portable/builder/PortableValueWithType.java |   75 +
 .../internal/portable/builder/package-info.java |   22 +
 .../cache/DynamicCacheChangeRequest.java        |   19 +-
 .../cache/DynamicCacheDescriptor.java           |   16 +-
 .../GridCacheLoaderWriterStoreFactory.java      |   20 +-
 .../GridCachePartitionExchangeManager.java      |    4 +-
 .../processors/cache/GridCacheProcessor.java    |  199 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |   15 +-
 .../dht/GridPartitionedGetFuture.java           |   19 +-
 .../distributed/near/GridNearGetFuture.java     |   22 +-
 .../CacheObjectPortableProcessorImpl.java       |    2 +-
 .../ignite/internal/util/lang/GridFunc.java     |    1 +
 .../resources/META-INF/classnames.properties    |    2 +-
 .../core/src/main/resources/ignite.properties   |    2 +-
 .../store/StoreResourceInjectionSelfTest.java   |  104 +
 .../GridPortableBuilderAdditionalSelfTest.java  |  232 ++-
 .../portable/GridPortableBuilderSelfTest.java   |    1 +
 .../GridPortableMarshallerSelfTest.java         |   72 +-
 .../GridPortableMetaDataDisabledSelfTest.java   |   17 +
 .../portable/GridPortableMetaDataSelfTest.java  |   17 +
 .../mutabletest/GridPortableTestClasses.java    |   38 +-
 .../cache/CacheAffinityCallSelfTest.java        |   85 +-
 .../IgniteCacheP2pUnmarshallingErrorTest.java   |    5 +
 .../cache/IgniteDynamicCacheStartSelfTest.java  |    4 +-
 ...gniteTopologyValidatorAbstractCacheTest.java |   46 +-
 .../CachePutAllFailoverAbstractTest.java        |  126 +-
 .../CachePutAllFailoverAtomicTest.java          |   30 +
 ...ridCachePartitionNotLoadedEventSelfTest.java |    6 +-
 ...gniteCachePutRetryTransactionalSelfTest.java |   42 -
 ...ClientNodePortableMetadataMultinodeTest.java |   11 +
 .../junits/common/GridCommonAbstractTest.java   |   41 +
 .../IgniteCacheFailoverTestSuite2.java          |    2 +
 .../ignite/testsuites/IgniteCacheTestSuite.java |    4 +-
 .../testsuites/IgniteCacheTestSuite3.java       |    3 +-
 modules/extdata/p2p/pom.xml                     |    2 +-
 .../extdata/uri/modules/uri-dependency/pom.xml  |    2 +-
 modules/extdata/uri/pom.xml                     |    2 +-
 modules/gce/pom.xml                             |    2 +-
 modules/geospatial/pom.xml                      |    2 +-
 modules/hadoop/pom.xml                          |    2 +-
 modules/hibernate/pom.xml                       |    2 +-
 modules/indexing/pom.xml                        |    2 +-
 .../query/h2/opt/GridH2IndexBase.java           |   42 +
 .../query/IgniteSqlSplitterSelfTest.java        |   35 +-
 modules/jcl/pom.xml                             |    2 +-
 modules/jms11/pom.xml                           |    5 +-
 modules/jta/pom.xml                             |    2 +-
 modules/kafka/pom.xml                           |    2 +-
 modules/log4j/pom.xml                           |    2 +-
 modules/log4j2/pom.xml                          |    2 +-
 .../ignite/logger/log4j2/Log4J2Logger.java      |   20 +-
 modules/mesos/pom.xml                           |    2 +-
 modules/platform/licenses/apache-2.0.txt        |  202 ++
 modules/platform/pom.xml                        |    2 +-
 .../platform/src/main/cpp/common/configure.ac   |    2 +-
 .../src/main/cpp/common/ignite-common.pc.in     |    2 +-
 .../cpp/common/include/ignite/common/exports.h  |    8 +-
 .../cpp/common/include/ignite/common/java.h     |   16 +-
 .../src/main/cpp/common/src/exports.cpp         |   16 +-
 .../platform/src/main/cpp/common/src/java.cpp   |   45 +-
 .../platform/src/main/cpp/core-test/Makefile.am |   49 +
 .../main/cpp/core-test/config/cache-query.xml   |   91 +
 .../main/cpp/core-test/config/cache-test.xml    |  129 ++
 .../src/main/cpp/core-test/configure.ac         |   62 +
 .../src/main/cpp/core-test/include/Makefile.am  |   22 +
 .../include/ignite/portable_test_defs.h         |  320 +++
 .../include/ignite/portable_test_utils.h        |  516 +++++
 .../cpp/core-test/include/teamcity_messages.h   |   55 +
 .../src/main/cpp/core-test/project/README.TXT   |    1 +
 .../main/cpp/core-test/project/vs/README.TXT    |    1 +
 .../cpp/core-test/project/vs/core-test.vcxproj  |  174 ++
 .../project/vs/core-test.vcxproj.filters        |   68 +
 .../main/cpp/core-test/src/cache_query_test.cpp |  651 ++++++
 .../src/main/cpp/core-test/src/cache_test.cpp   |  481 +++++
 .../main/cpp/core-test/src/concurrent_test.cpp  |  186 ++
 .../cpp/core-test/src/handle_registry_test.cpp  |  176 ++
 .../main/cpp/core-test/src/ignition_test.cpp    |   97 +
 .../src/portable_reader_writer_raw_test.cpp     | 1532 ++++++++++++++
 .../src/portable_reader_writer_test.cpp         | 1951 ++++++++++++++++++
 .../cpp/core-test/src/portable_session_test.cpp |  257 +++
 .../cpp/core-test/src/portable_test_defs.cpp    |   65 +
 .../main/cpp/core-test/src/teamcity_boost.cpp   |  159 ++
 .../cpp/core-test/src/teamcity_messages.cpp     |  150 ++
 modules/platform/src/main/cpp/core/Makefile.am  |   66 +
 modules/platform/src/main/cpp/core/configure.ac |   62 +
 modules/platform/src/main/cpp/core/ignite.pc.in |    9 +
 .../src/main/cpp/core/include/Makefile.am       |   61 +
 .../main/cpp/core/include/ignite/cache/cache.h  | 1153 +++++++++++
 .../cpp/core/include/ignite/cache/cache_entry.h |  118 ++
 .../core/include/ignite/cache/cache_peek_mode.h |   71 +
 .../cpp/core/include/ignite/cache/query/query.h |   27 +
 .../include/ignite/cache/query/query_argument.h |  125 ++
 .../include/ignite/cache/query/query_cursor.h   |  191 ++
 .../include/ignite/cache/query/query_scan.h     |  151 ++
 .../core/include/ignite/cache/query/query_sql.h |  253 +++
 .../include/ignite/cache/query/query_text.h     |  159 ++
 .../src/main/cpp/core/include/ignite/guid.h     |  112 +
 .../src/main/cpp/core/include/ignite/ignite.h   |  154 ++
 .../core/include/ignite/ignite_configuration.h  |   92 +
 .../main/cpp/core/include/ignite/ignite_error.h |  260 +++
 .../src/main/cpp/core/include/ignite/ignition.h |  195 ++
 .../core/include/ignite/impl/cache/cache_impl.h |  418 ++++
 .../ignite/impl/cache/query/query_impl.h        |  115 ++
 .../core/include/ignite/impl/handle_registry.h  |  202 ++
 .../include/ignite/impl/ignite_environment.h    |  130 ++
 .../cpp/core/include/ignite/impl/ignite_impl.h  |  146 ++
 .../core/include/ignite/impl/interop/interop.h  |   25 +
 .../ignite/impl/interop/interop_input_stream.h  |  234 +++
 .../ignite/impl/interop/interop_memory.h        |  280 +++
 .../ignite/impl/interop/interop_output_stream.h |  234 +++
 .../cpp/core/include/ignite/impl/operations.h   |  452 ++++
 .../ignite/impl/portable/portable_common.h      |  146 ++
 .../ignite/impl/portable/portable_id_resolver.h |  106 +
 .../impl/portable/portable_metadata_handler.h   |  102 +
 .../impl/portable/portable_metadata_manager.h   |  120 ++
 .../impl/portable/portable_metadata_snapshot.h  |  122 ++
 .../impl/portable/portable_metadata_updater.h   |   53 +
 .../portable/portable_metadata_updater_impl.h   |   65 +
 .../ignite/impl/portable/portable_reader_impl.h | 1130 ++++++++++
 .../ignite/impl/portable/portable_utils.h       |  344 +++
 .../ignite/impl/portable/portable_writer_impl.h |  859 ++++++++
 .../cpp/core/include/ignite/portable/portable.h |   29 +
 .../include/ignite/portable/portable_consts.h   |  106 +
 .../ignite/portable/portable_containers.h       |  525 +++++
 .../ignite/portable/portable_raw_reader.h       |  324 +++
 .../ignite/portable/portable_raw_writer.h       |  300 +++
 .../include/ignite/portable/portable_reader.h   |  355 ++++
 .../include/ignite/portable/portable_type.h     |  293 +++
 .../include/ignite/portable/portable_writer.h   |  335 +++
 .../main/cpp/core/os/linux/include/Makefile.am  |   20 +
 .../core/os/linux/include/ignite/impl/utils.h   |  155 ++
 .../main/cpp/core/os/linux/src/impl/utils.cpp   |  439 ++++
 .../cpp/core/os/win/include/ignite/impl/utils.h |  155 ++
 .../src/main/cpp/core/os/win/src/impl/utils.cpp |  453 ++++
 .../src/main/cpp/core/project/README.TXT        |    1 +
 .../src/main/cpp/core/project/vs/README.TXT     |    1 +
 .../src/main/cpp/core/project/vs/core.vcxproj   |  272 +++
 .../cpp/core/project/vs/core.vcxproj.filters    |  246 +++
 .../main/cpp/core/project/vs/core.vcxprojrel    |  272 +++
 modules/platform/src/main/cpp/core/src/guid.cpp |   65 +
 .../platform/src/main/cpp/core/src/ignite.cpp   |   43 +
 .../src/main/cpp/core/src/ignite_error.cpp      |  222 ++
 .../platform/src/main/cpp/core/src/ignition.cpp |  468 +++++
 .../main/cpp/core/src/impl/cache/cache_impl.cpp |  388 ++++
 .../core/src/impl/cache/query/query_impl.cpp    |  193 ++
 .../main/cpp/core/src/impl/handle_registry.cpp  |  234 +++
 .../cpp/core/src/impl/ignite_environment.cpp    |  166 ++
 .../src/main/cpp/core/src/impl/ignite_impl.cpp  |   42 +
 .../src/impl/interop/interop_input_stream.cpp   |  215 ++
 .../core/src/impl/interop/interop_memory.cpp    |  182 ++
 .../src/impl/interop/interop_output_stream.cpp  |  215 ++
 .../impl/portable/portable_metadata_handler.cpp |   78 +
 .../impl/portable/portable_metadata_manager.cpp |  201 ++
 .../portable/portable_metadata_snapshot.cpp     |   70 +
 .../impl/portable/portable_metadata_updater.cpp |   32 +
 .../portable/portable_metadata_updater_impl.cpp |   94 +
 .../src/impl/portable/portable_reader_impl.cpp  |  683 ++++++
 .../core/src/impl/portable/portable_utils.cpp   |  214 ++
 .../src/impl/portable/portable_writer_impl.cpp  |  600 ++++++
 .../core/src/portable/portable_containers.cpp   |   76 +
 .../core/src/portable/portable_raw_reader.cpp   |  135 ++
 .../core/src/portable/portable_raw_writer.cpp   |  147 ++
 .../cpp/core/src/portable/portable_reader.cpp   |  142 ++
 .../cpp/core/src/portable/portable_type.cpp     |   51 +
 .../cpp/core/src/portable/portable_writer.cpp   |  154 ++
 .../ignite/platform/cpp/package-info.java       |   22 +
 .../ignite/platform/dotnet/package-info.java    |   22 +
 .../apache/ignite/platform/package-info.java    |   22 +
 modules/rest-http/pom.xml                       |    2 +-
 modules/scalar-2.10/pom.xml                     |    2 +-
 modules/scalar/pom.xml                          |    2 +-
 modules/schedule/pom.xml                        |    2 +-
 modules/schema-import/pom.xml                   |    2 +-
 modules/slf4j/pom.xml                           |    2 +-
 modules/spark-2.10/pom.xml                      |    2 +-
 modules/spark/pom.xml                           |    2 +-
 modules/spring/pom.xml                          |    2 +-
 modules/ssh/pom.xml                             |    2 +-
 modules/tools/pom.xml                           |    2 +-
 modules/urideploy/pom.xml                       |    2 +-
 modules/visor-console-2.10/pom.xml              |    2 +-
 modules/visor-console/pom.xml                   |    2 +-
 modules/visor-plugins/pom.xml                   |    2 +-
 modules/web/pom.xml                             |    2 +-
 modules/yardstick/pom.xml                       |    2 +-
 modules/yarn/pom.xml                            |    2 +-
 modules/zookeeper/pom.xml                       |    2 +-
 parent/pom.xml                                  |   14 +-
 pom.xml                                         |    2 +-
 279 files changed, 31654 insertions(+), 3479 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0f15b83e/examples/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/0f15b83e/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/0f15b83e/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/0f15b83e/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/0f15b83e/modules/rest-http/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/0f15b83e/modules/schema-import/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/0f15b83e/parent/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/0f15b83e/pom.xml
----------------------------------------------------------------------


[17/50] [abbrv] ignite git commit: Merge remote-tracking branch 'remotes/upstream/master' into ignite-1.4

Posted by ak...@apache.org.
Merge remote-tracking branch 'remotes/upstream/master' into ignite-1.4


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

Branch: refs/heads/ignite-843
Commit: 27cd6154747155c77e29d194d98f9ba9bf6a1455
Parents: 662bc33 6ac9557
Author: ptupitsyn <pt...@gridgain.com>
Authored: Thu Sep 3 11:42:30 2015 +0300
Committer: ptupitsyn <pt...@gridgain.com>
Committed: Thu Sep 3 11:42:30 2015 +0300

----------------------------------------------------------------------
 .../configuration/PlatformConfiguration.java    |   2 +-
 .../apache/ignite/internal/IgniteKernal.java    |  14 +-
 .../cache/store/CacheOsStoreManager.java        |  32 +-
 .../cache/store/CacheStoreManager.java          |  10 +
 .../store/GridCacheStoreManagerAdapter.java     |   5 -
 .../platform/PlatformNoopProcessor.java         |  11 +-
 .../processors/platform/PlatformProcessor.java  |  10 +
 .../cache/store/PlatformCacheStore.java         |  25 +
 ...processors.platform.PlatformBootstrapFactory |   2 +
 .../PlatformAbstractConfigurationClosure.java   |  61 +++
 .../platform/PlatformConfigurationEx.java       |  48 ++
 .../platform/PlatformProcessorImpl.java         | 360 ++++++++++++++
 .../cache/store/PlatformCacheStore.java         |  25 -
 .../platform/cpp/PlatformCppBootstrap.java      |  31 ++
 .../cpp/PlatformCppBootstrapFactory.java        |  39 ++
 .../cpp/PlatformCppConfigurationClosure.java    |  99 ++++
 .../cpp/PlatformCppConfigurationEx.java         |  82 +++
 .../dotnet/PlatformDotNetBootstrap.java         |  31 ++
 .../dotnet/PlatformDotNetBootstrapFactory.java  |  39 ++
 .../dotnet/PlatformDotNetCacheStore.java        | 497 +++++++++++++++++++
 .../PlatformDotNetConfigurationClosure.java     | 255 ++++++++++
 .../dotnet/PlatformDotNetConfigurationEx.java   |  91 ++++
 .../platform/utils/PlatformUtils.java           |  14 +
 .../platform/cpp/PlatformCppConfiguration.java  |  47 ++
 .../dotnet/PlatformDotNetCacheStoreFactory.java | 139 ++++++
 .../dotnet/PlatformDotNetConfiguration.java     | 119 +++++
 .../dotnet/PlatformDotNetLifecycleBean.java     | 109 ++++
 .../PlatformDotNetPortableConfiguration.java    | 228 +++++++++
 ...PlatformDotNetPortableTypeConfiguration.java | 248 +++++++++
 parent/pom.xml                                  |   1 +
 30 files changed, 2635 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/27cd6154/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------


[30/50] [abbrv] ignite git commit: minor javadoc fix (cherry picked from commit 77fc969)

Posted by ak...@apache.org.
minor javadoc fix
(cherry picked from commit 77fc969)


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

Branch: refs/heads/ignite-843
Commit: 565836113bdbaaa22b33f1a340b41dea2f1c8433
Parents: b1a9771
Author: Anton Vinogradov <av...@gridgain.com>
Authored: Thu Sep 3 23:24:21 2015 +0300
Committer: Anton Vinogradov <av...@gridgain.com>
Committed: Thu Sep 3 23:25:34 2015 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       | 31 ++++++++------------
 1 file changed, 12 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/56583611/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 1bbc110..85eed47 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -17,26 +17,10 @@
 
 package org.apache.ignite.configuration;
 
-import java.io.Serializable;
-import java.util.Collection;
-import javax.cache.Cache;
-import javax.cache.CacheException;
-import javax.cache.configuration.CompleteConfiguration;
-import javax.cache.configuration.Factory;
-import javax.cache.configuration.MutableConfiguration;
-import javax.cache.expiry.ExpiryPolicy;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheEntryProcessor;
-import org.apache.ignite.cache.CacheInterceptor;
-import org.apache.ignite.cache.CacheMemoryMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.CacheRebalanceMode;
-import org.apache.ignite.cache.CacheTypeMetadata;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.AffinityFunction;
 import org.apache.ignite.cache.affinity.AffinityKeyMapper;
 import org.apache.ignite.cache.eviction.EvictionFilter;
@@ -52,6 +36,15 @@ import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.plugin.CachePluginConfiguration;
 import org.jetbrains.annotations.Nullable;
 
+import javax.cache.Cache;
+import javax.cache.CacheException;
+import javax.cache.configuration.CompleteConfiguration;
+import javax.cache.configuration.Factory;
+import javax.cache.configuration.MutableConfiguration;
+import javax.cache.expiry.ExpiryPolicy;
+import java.io.Serializable;
+import java.util.Collection;
+
 /**
  * This class defines grid cache configuration. This configuration is passed to
  * grid via {@link IgniteConfiguration#getCacheConfiguration()} method. It defines all configuration
@@ -1806,7 +1799,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * Following validator allows to put data only in case topology contains exactly 2 nodes:
      * <pre>{@code
      * new TopologyValidator() {
-     *    @Override public boolean validate(Collection<ClusterNode> nodes) {
+     *    public boolean validate(Collection<ClusterNode> nodes) {
      *       return nodes.size() == 2;
      *    }
      * }
@@ -1835,7 +1828,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * Following validator allows to put data only in case topology contains exactly 2 nodes:
      * <pre>{@code
      * new TopologyValidator() {
-     *    @Override public boolean validate(Collection<ClusterNode> nodes) {
+     *    public boolean validate(Collection<ClusterNode> nodes) {
      *       return nodes.size() == 2;
      *    }
      * }


[40/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/portable/portable_type.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/portable/portable_type.h b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_type.h
new file mode 100644
index 0000000..fb086ef
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_type.h
@@ -0,0 +1,293 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_PORTABLE_TYPE
+#define _IGNITE_PORTABLE_TYPE
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#include "ignite/ignite_error.h"
+
+/**
+ * Start portable type definition.
+ */
+#define IGNITE_PORTABLE_TYPE_START(T) \
+template<> \
+struct PortableType<T> \
+{
+
+/**
+ * End portable type definition.
+ */
+#define IGNITE_PORTABLE_TYPE_END \
+};
+
+/**
+ * Implementation of GetTypeId() which returns predefined constant.
+ */
+#define IGNITE_PORTABLE_GET_TYPE_ID_AS_CONST(id) \
+int32_t GetTypeId() \
+{ \
+    return id; \
+}
+
+/**
+ * Implementation of GetTypeId() which returns hash of passed type name.
+ */
+#define IGNITE_PORTABLE_GET_TYPE_ID_AS_HASH(typeName) \
+int32_t GetTypeId() \
+{ \
+    return GetPortableStringHashCode(#typeName); \
+}
+
+/**
+ * Implementation of GetTypeName() which returns type name as is.
+ */
+#define IGNITE_PORTABLE_GET_TYPE_NAME_AS_IS(typeName) \
+std::string GetTypeName() \
+{ \
+    return #typeName; \
+}
+
+/**
+ * Default implementation of GetFieldId() function which returns Java-way hash code of the string.
+ */
+#define IGNITE_PORTABLE_GET_FIELD_ID_AS_HASH \
+int32_t GetFieldId(const char* name) \
+{ \
+    return GetPortableStringHashCode(name); \
+}
+
+/**
+ * Implementation of GetHashCode() function which always returns 0.
+ */
+#define IGNITE_PORTABLE_GET_HASH_CODE_ZERO(T) \
+int32_t GetHashCode(const T& obj) \
+{ \
+    return 0; \
+}
+
+/**
+ * Implementation of IsNull() function which always returns false.
+ */
+#define IGNITE_PORTABLE_IS_NULL_FALSE(T) \
+bool IsNull(const T& obj) \
+{ \
+    return false; \
+}
+
+/**
+ * Implementation of IsNull() function which return true if passed object is null pointer.
+ */
+#define IGNITE_PORTABLE_IS_NULL_IF_NULLPTR(T) \
+bool IsNull(const T& obj) \
+{ \
+    return obj; \
+}
+
+/**
+ * Implementation of GetNull() function which returns an instance created with defult constructor.
+ */
+#define IGNITE_PORTABLE_GET_NULL_DEFAULT_CTOR(T) \
+T GetNull() \
+{ \
+    return T(); \
+}
+
+/**
+ * Implementation of GetNull() function which returns NULL pointer.
+ */
+#define IGNITE_PORTABLE_GET_NULL_NULLPTR(T) \
+T GetNull() \
+{ \
+    return NULL; \
+}
+
+namespace ignite
+{
+    namespace portable
+    {
+        class PortableWriter;
+        class PortableReader;
+
+        /**
+         * Get portable string hash code.
+         *
+         * @param val Value.
+         * @return Hash code.
+         */
+        IGNITE_IMPORT_EXPORT int32_t GetPortableStringHashCode(const char* val);
+
+        /**
+         * Portable type structure. Defines a set of functions required for type to be serialized and deserialized.
+         */
+        template<typename T>
+        struct IGNITE_IMPORT_EXPORT PortableType
+        {
+            /**
+             * Get portable object type ID.
+             *
+             * @return Type ID.
+             */
+            int32_t GetTypeId()
+            {
+                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "GetTypeId function is not defined for portable type.");
+            }
+
+            /**
+             * Get portable object type name.
+             *
+             * @return Type name.
+             */
+            std::string GetTypeName() 
+            {
+                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "GetTypeName function is not defined for portable type.");
+            }
+
+            /**
+             * Get portable object field ID.
+             *
+             * @param name Field name.
+             * @return Field ID.
+             */
+            int32_t GetFieldId(const char* name)
+            {
+                return GetPortableStringHashCode(name);
+            }
+
+            /**
+             * Get portable object hash code.
+             *
+             * @param obj Portable object.
+             * @return Hash code.
+             */
+            int32_t GetHashCode(const T& obj)
+            {
+                return 0;
+            }
+
+            /**
+             * Write portable object.
+             *
+             * @param writer Writer.
+             * @param obj Object.
+             */
+            void Write(PortableWriter& writer, const T& obj)
+            {
+                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Write function is not defined for portable type.");
+            }
+
+            /**
+             * Read portable object.
+             *
+             * @param reader Reader.
+             * @return Object.
+             */
+            T Read(PortableReader& reader)
+            {
+                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Read function is not defined for portable type.");
+            }
+
+            /**
+             * Check whether passed portable object should be interpreted as NULL.
+             *
+             * @param obj Portable object to test.
+             * @return True if portable object should be interpreted as NULL.
+             */
+            bool IsNull(const T& obj)
+            {
+                return false;
+            }
+
+            /**
+             * Get NULL value for the given portable type.
+             *
+             * @return NULL value.
+             */
+            T GetNull()
+            {
+                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "GetNull function is not defined for portable type.");
+            }
+        };
+
+        /*
+         * Templated portable type for pointers.
+         */
+        template <typename T>
+        struct IGNITE_IMPORT_EXPORT PortableType<T*>
+        {
+            /** Actual type. */
+            PortableType<T> typ;
+
+            /**
+             * Constructor.
+             */
+            PortableType()
+            {
+                typ = PortableType<T>();
+            }
+
+            int32_t GetTypeId()
+            {
+                return typ.GetTypeId();
+            }
+
+            std::string GetTypeName()
+            {
+                return typ.GetTypeName();
+            }
+
+            int32_t GetFieldId(const char* name)
+            {
+                return typ.GetFieldId(name);
+            }
+
+            int32_t GetHashCode(T* const& obj)
+            {
+                return typ.GetHashCode(*obj);
+            }
+
+            void Write(PortableWriter& writer, T* const& obj)
+            {
+                typ.Write(writer, *obj);
+            }
+
+            T* Read(PortableReader& reader)
+            {
+                T* res = new T();
+
+                *res = typ.Read(reader);
+
+                return res;
+            }
+
+            bool IsNull(T* const& obj)
+            {
+                return !obj || typ.IsNull(*obj);
+            }
+
+            T* GetNull()
+            {
+                return NULL;
+            }
+        };
+    }
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/portable/portable_writer.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/portable/portable_writer.h b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_writer.h
new file mode 100644
index 0000000..5dc9494
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/portable/portable_writer.h
@@ -0,0 +1,335 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_PORTABLE_WRITER
+#define _IGNITE_PORTABLE_WRITER
+
+#include <string>
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#include "ignite/portable/portable_raw_writer.h"
+
+namespace ignite
+{
+    namespace portable 
+    {
+        /**
+         * Portable writer.
+         */
+        class IGNITE_IMPORT_EXPORT PortableWriter
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param impl Implementation.
+             */
+            PortableWriter(ignite::impl::portable::PortableWriterImpl* impl);
+
+            /**
+             * Write 8-byte signed integer. Maps to "byte" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Value.
+             */
+            void WriteInt8(const char* fieldName, const int8_t val);
+
+            /**
+             * Write array of 8-byte signed integers. Maps to "byte[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteInt8Array(const char* fieldName, const int8_t* val, const int32_t len);
+
+            /**
+             * Write bool. Maps to "short" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Value.
+             */
+            void WriteBool(const char* fieldName, const bool val);
+
+            /**
+             * Write array of bools. Maps to "bool[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteBoolArray(const char* fieldName, const bool* val, const int32_t len);
+
+            /**
+             * Write 16-byte signed integer. Maps to "short" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Value.
+             */
+            void WriteInt16(const char* fieldName, const int16_t val);
+
+            /**
+             * Write array of 16-byte signed integers. Maps to "short[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteInt16Array(const char* fieldName, const int16_t* val, const int32_t len);
+
+            /**
+             * Write 16-byte unsigned integer. Maps to "char" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Value.
+             */
+            void WriteUInt16(const char* fieldName, const uint16_t val);
+
+            /**
+             * Write array of 16-byte unsigned integers. Maps to "char[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteUInt16Array(const char* fieldName, const uint16_t* val, const int32_t len);
+
+            /**
+             * Write 32-byte signed integer. Maps to "int" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Value.
+             */
+            void WriteInt32(const char* fieldName, const int32_t val);
+
+            /**
+             * Write array of 32-byte signed integers. Maps to "int[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteInt32Array(const char* fieldName, const int32_t* val, const int32_t len);
+
+            /**
+             * Write 64-byte signed integer. Maps to "long" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Value.
+             */
+            void WriteInt64(const char* fieldName, const int64_t val);
+
+            /**
+             * Write array of 64-byte signed integers. Maps to "long[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteInt64Array(const char* fieldName, const int64_t* val, const int32_t len);
+
+            /**
+             * Write float. Maps to "float" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Value.
+             */
+            void WriteFloat(const char* fieldName, const float val);
+
+            /**
+             * Write array of floats. Maps to "float[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteFloatArray(const char* fieldName, const float* val, const int32_t len);
+
+            /**
+             * Write double. Maps to "double" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Value.
+             */
+            void WriteDouble(const char* fieldName, const double val);
+
+            /**
+             * Write array of doubles. Maps to "double[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteDoubleArray(const char* fieldName, const double* val, const int32_t len);
+
+            /**
+             * Write Guid. Maps to "UUID" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Value.
+             */
+            void WriteGuid(const char* fieldName, const Guid val);
+
+            /**
+             * Write array of Guids. Maps to "UUID[]" type in Java.
+             *
+             * @param fieldName Field name.
+             * @param val Array.
+             * @param len Array length.
+             */
+            void WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len);
+
+            /**
+             * Write string.
+             *
+             * @param fieldName Field name.
+             * @param val Null-terminated character sequence.
+             */
+            void WriteString(const char* fieldName, const char* val);
+
+            /**
+             * Write string.
+             *
+             * @param fieldName Field name.
+             * @param val String.
+             * @param len String length (characters).
+             */
+            void WriteString(const char* fieldName, const char* val, const int32_t len);
+
+            /**
+             * Write string.
+             *
+             * @param fieldName Field name.
+             * @param val String.
+             */
+            void WriteString(const char* fieldName, const std::string& val)
+            {
+                WriteString(fieldName, val.c_str());
+            }
+
+            /**
+             * Start string array write.
+             *
+             * @param fieldName Field name.
+             * @return String array writer.
+             */
+            PortableStringArrayWriter WriteStringArray(const char* fieldName);
+
+            /**
+             * Write NULL value.
+             *
+             * @param fieldName Field name.
+             */
+            void WriteNull(const char* fieldName);
+
+            /**
+             * Start array write.
+             *
+             * @param fieldName Field name.
+             * @return Array writer.
+             */
+            template<typename T>
+            PortableArrayWriter<T> WriteArray(const char* fieldName)
+            {
+                int32_t id = impl->WriteArray(fieldName);
+
+                return PortableArrayWriter<T>(impl, id);
+            }
+
+            /**
+             * Start collection write.
+             *
+             * @param fieldName Field name.
+             * @return Collection writer.
+             */
+            template<typename T>
+            PortableCollectionWriter<T> WriteCollection(const char* fieldName)
+            {
+                return WriteCollection<T>(fieldName, IGNITE_COLLECTION_UNDEFINED);
+            }
+
+            /**
+             * Start collection write.
+             *
+             * @param fieldName Field name.
+             * @param type Collection type.
+             * @return Collection writer.
+             */
+            template<typename T>
+            PortableCollectionWriter<T> WriteCollection(const char* fieldName, ignite::portable::CollectionType typ)
+            {
+                int32_t id = impl->WriteCollection(fieldName, typ);
+
+                return PortableCollectionWriter<T>(impl, id);
+            }
+
+            /**
+             * Start map write.
+             *
+             * @param fieldName Field name.
+             * @param typ Map type.
+             * @return Map writer.
+             */
+            template<typename K, typename V>
+            PortableMapWriter<K, V> WriteMap(const char* fieldName)
+            {
+                return WriteMap<K, V>(fieldName, IGNITE_MAP_UNDEFINED);
+            }
+
+            /**
+             * Start map write.
+             *
+             * @param fieldName Field name.
+             * @param typ Map type.
+             * @return Map writer.
+             */
+            template<typename K, typename V>
+            PortableMapWriter<K, V> WriteMap(const char* fieldName, ignite::portable::MapType typ)
+            {
+                int32_t id = impl->WriteMap(fieldName, typ);
+
+                return PortableMapWriter<K, V>(impl, id);
+            }
+
+            /**
+             * Write object.
+             *
+             * @param fieldName Field name.
+             * @param val Value.
+             */
+            template<typename T>
+            void WriteObject(const char* fieldName, T val)
+            {
+                impl->WriteObject<T>(fieldName, val);
+            }
+
+            /**
+             * Get raw writer for this reader.
+             *
+             * @return Raw writer.
+             */
+            PortableRawWriter RawWriter();
+        private:
+            /** Implementation delegate. */
+            ignite::impl::portable::PortableWriterImpl* impl;
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/os/linux/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/os/linux/include/Makefile.am b/modules/platform/src/main/cpp/core/os/linux/include/Makefile.am
new file mode 100644
index 0000000..2ee13eff
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/os/linux/include/Makefile.am
@@ -0,0 +1,20 @@
+##
+## 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.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+nobase_include_HEADERS = ignite/impl/utils.h

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/os/linux/include/ignite/impl/utils.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/os/linux/include/ignite/impl/utils.h b/modules/platform/src/main/cpp/core/os/linux/include/ignite/impl/utils.h
new file mode 100644
index 0000000..8bbd2f7
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/os/linux/include/ignite/impl/utils.h
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_UTILS
+#define _IGNITE_UTILS
+
+#include <cstring>
+#include <string>
+
+#include <ignite/common/common.h>
+
+#ifdef IGNITE_FRIEND
+    #define IGNITE_FRIEND_EXPORT IGNITE_EXPORT
+#else
+    #define IGNITE_FRIEND_EXPORT
+#endif
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace utils
+        {                
+            /**
+             * Copy characters.
+             *
+             * @param val Value.
+             * @return Result.
+             */
+            IGNITE_FRIEND_EXPORT char* CopyChars(const char* val);
+
+            /**
+             * Release characters.
+             *
+             * @param val Value.
+             */
+            IGNITE_FRIEND_EXPORT void ReleaseChars(char* val);
+            
+            /**
+             * Read system environment variable taking thread-safety in count.
+             *
+             * @param name Environment variable name.
+             * @param found Whether environment variable with such name was found.
+             * @return Environment variable value.
+             */
+            IGNITE_FRIEND_EXPORT std::string GetEnv(const std::string& name, bool* found);
+                                
+            /**
+             * Ensure that file on the given path exists in the system.
+             *
+             * @param path Path.
+             * @return True if file exists, false otherwise.
+             */
+            IGNITE_FRIEND_EXPORT bool FileExists(const std::string& path);
+
+            /**
+             * Attempts to find JVM library to load it into the process later.
+             * First search is performed using the passed path argument (is not NULL).
+             * Then JRE_HOME is evaluated. Last, JAVA_HOME is evaluated.
+             *
+             * @param Explicitly defined path (optional).
+             * @param found Whether library was found.
+             * @return Path to the file.
+             */
+            IGNITE_FRIEND_EXPORT std::string FindJvmLibrary(const std::string* path, bool* found);
+
+            /**
+             * Load JVM library into the process.
+             *
+             * @param path Optional path to the library.
+             * @return Whether load was successful.
+             */
+            IGNITE_FRIEND_EXPORT bool LoadJvmLibrary(const std::string& path);
+
+            /**
+             * Resolve IGNITE_HOME directory. Resolution is performed in several
+             * steps:
+             * 1) Check for path provided as argument.
+             * 2) Check for environment variable.
+             * 3) Check for current working directory.
+             * Result of these 3 checks are evaluated based on existence of certain
+             * predefined folders inside possible GG home. If they are found, 
+             * IGNITE_HOME is considered resolved.
+             *
+             * @param path Optional path to evaluate.
+             * @param found Whether IGNITE_HOME home was found.
+             * @return Resolved GG home.
+             */
+            IGNITE_FRIEND_EXPORT std::string ResolveIgniteHome(const std::string* path, bool* found);
+
+            /**
+             * Create Ignite classpath based on user input and home directory.
+             *
+             * @param usrCp User's classpath.
+             * @param home Ignite home directory.
+             * @return Classpath.
+             */
+            IGNITE_FRIEND_EXPORT std::string CreateIgniteClasspath(const std::string* usrCp, const std::string* home);
+
+            /**
+             * Create Ignite classpath based on user input and home directory.
+             *
+             * @param usrCp User's classpath.
+             * @param home Ignite home directory.
+             * @param test Whether test classpath must be used.
+             * @return Classpath.
+             */
+            IGNITE_FRIEND_EXPORT std::string CreateIgniteClasspath(const std::string* usrCp, const std::string* home, bool test);
+
+            /**
+             * Safe array which automatically reclaims occupied memory when out of scope.
+             */
+            template<typename T>
+            struct IGNITE_FRIEND_EXPORT SafeArray
+            {
+                /**
+                 * Constructor.
+                 */
+                SafeArray(int cap)
+                {
+                    target = new T[cap];
+                }
+
+                /**
+                 * Destructor.
+                 */
+                ~SafeArray()
+                {
+                    delete[] target;
+                }
+
+                IGNITE_NO_COPY_ASSIGNMENT(SafeArray);
+
+                /** Target array. */
+                T* target;
+            };
+        }
+    }    
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/os/linux/src/impl/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/os/linux/src/impl/utils.cpp b/modules/platform/src/main/cpp/core/os/linux/src/impl/utils.cpp
new file mode 100644
index 0000000..ec45eb6
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/os/linux/src/impl/utils.cpp
@@ -0,0 +1,439 @@
+/*
+ * 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.
+ */
+#include <sys/stat.h>
+#include <dirent.h>
+#include <dlfcn.h>
+
+#include "ignite/impl/utils.h"
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace utils
+        {
+            const char* JAVA_HOME = "JAVA_HOME";
+            const char* JAVA_DLL = "/jre/lib/amd64/server/libjvm.so";
+
+            const char* IGNITE_HOME = "IGNITE_HOME";
+
+            const char* PROBE_BIN = "/bin";
+            const char* PROBE_EXAMPLES = "/examples";
+
+            const char* IGNITE_NATIVE_TEST_CLASSPATH = "IGNITE_NATIVE_TEST_CLASSPATH";
+
+            /**
+             * Helper method to set boolean result to reference with proper NULL-check.
+             *
+             * @param res Result.
+             * @param outRes Where to set the result.
+             */
+            inline void SetBoolResult(bool res, bool* outRes)
+            {
+                if (outRes)
+                    *outRes = res;
+            }
+
+            /**
+             * Check if string ends with the given ending.
+             *
+             * @param str String to check.
+             * @param ending Ending.
+             * @return Result.
+             */
+            inline bool StringEndsWith(const std::string& str, const std::string& ending)
+            {
+                if (str.length() > ending.length())
+                    return str.compare(str.length() - ending.length(), ending.length(), ending) == 0;
+
+                return false;
+            }
+                
+            /**
+             * Helper function for GG home resolution. Checks whether certain folders
+             * exist in the path. Optionally goes upwards in directory hierarchy.
+             *
+             * @param path Path to evaluate.
+             * @param up Whether to go upwards.
+             * @res Resolution result.
+             * @return Resolved directory.
+             */
+            std::string ResolveIgniteHome0(const std::string& path, bool up, bool* res)
+            {
+                struct stat pathStat;
+                
+                if (stat(path.c_str(), &pathStat) != -1 && S_ISDIR(pathStat.st_mode)) 
+                {
+                    // Remove trailing slashes, otherwise we will have an infinite loop.
+                    std::string path0 = path;
+
+                    while (true) {
+                        char lastChar = *path0.rbegin();
+
+                        if (lastChar == '/' || lastChar == ' ') {
+                            size_t off = path0.find_last_of(lastChar);
+
+                            path0.erase(off, 1);
+                        }
+                        else
+                            break;
+                    }
+
+                    std::string binStr = path0 + PROBE_BIN;
+                    struct stat binStat;
+
+                    std::string examplesStr = path0 + PROBE_EXAMPLES;
+                    struct stat examplesStat;
+
+                    if (stat(binStr.c_str(), &binStat) != -1 && S_ISDIR(binStat.st_mode) &&
+                        stat(examplesStr.c_str(), &examplesStat) != -1 && S_ISDIR(examplesStat.st_mode))
+                    {
+                        SetBoolResult(true, res);
+
+                        return std::string(path0);
+                    }
+
+                    if (up)
+                    {
+                        // Evaluate parent directory.
+                        size_t slashPos = path0.find_last_of("/");
+
+                        if (slashPos != std::string::npos)
+                        {
+                            std::string parent = path0.substr(0, slashPos);
+
+                            return ResolveIgniteHome0(parent, true, res);
+                        }
+                    }
+
+                }
+
+                SetBoolResult(false, res);
+
+                return std::string();
+            }
+
+            /**
+             * Create classpath picking JARs from the given path.
+             *
+             * @path Path.
+             * @return Classpath;
+             */
+            std::string ClasspathJars(const std::string& path)
+            {
+                std::string res = std::string();
+
+                DIR* dir = opendir(path.c_str());
+
+                if (dir)
+                {
+                    struct dirent* entry;
+
+                    while ((entry = readdir(dir)) != NULL)
+                    {
+                        if (strstr(entry->d_name, ".jar"))
+                        {
+                            res.append(path);
+                            res.append("/");
+                            res.append(entry->d_name);
+                            res.append(":");
+                        }
+                    }
+
+                    closedir(dir);
+                }
+
+                return res;
+            }
+
+            /**
+             * Create classpath picking compiled classes from the given path.
+             *
+             * @path Path.
+             * @return Classpath;
+             */
+            std::string ClasspathExploded(const std::string& path, bool down)
+            {
+                std::string res = std::string();
+
+                if (FileExists(path))
+                {
+                    // 1. Append "target\classes".
+                    std::string classesPath = path + "/target/classes";
+
+                    if (FileExists(classesPath)) {
+                        res += classesPath;
+                        res += ":";
+                    }
+
+                    // 2. Append "target\test-classes"
+                    std::string testClassesPath = path + "/target/test-classes";
+
+                    if (FileExists(testClassesPath)) {
+                        res += testClassesPath;
+                        res += ":";
+                    }
+
+                    // 3. Append "target\libs"
+                    std::string libsPath = path + "/target/libs";
+
+                    if (FileExists(libsPath)) {
+                        std::string libsCp = ClasspathJars(libsPath);
+                        res += libsCp;
+                    }
+
+                    // 4. Do the same for child if needed.
+                    if (down)
+                    {
+                        DIR* dir = opendir(path.c_str());
+
+                        if (dir)
+                        {
+                            struct dirent* entry;
+
+                            while ((entry = readdir(dir)) != NULL)
+                            {
+                                std::string entryPath = entry->d_name;
+
+                                if (entryPath.compare(".") != 0 && entryPath.compare("..") != 0)
+                                {
+                                    std::string entryFullPath = path + "/" + entryPath;
+
+                                    struct stat entryFullStat;
+
+                                    if (stat(entryFullPath.c_str(), &entryFullStat) != -1 && S_ISDIR(entryFullStat.st_mode))
+                                    {
+                                        std::string childCp = ClasspathExploded(entryFullPath, false);
+
+                                        res += childCp;
+                                    }
+                                }
+                            }
+
+                            closedir(dir);
+                        }
+                    }
+                }
+
+                return res;
+            }
+
+            /**
+             * Helper function to create classpath based on Ignite home directory.
+             *
+             * @param home Home directory; expected to be valid.
+             * @param forceTest Force test classpath.
+             */
+            std::string CreateIgniteHomeClasspath(const std::string& home, bool forceTest)
+            {
+                std::string res = std::string();
+
+                // 1. Add exploded test directories.
+                if (forceTest)
+                {
+                    std::string examplesPath = home + "/examples";
+                    std::string examplesCp = ClasspathExploded(examplesPath, true);
+                    res.append(examplesCp);
+
+                    std::string modulesPath = home + "/modules";
+                    std::string modulesCp = ClasspathExploded(modulesPath, true);
+                    res.append(modulesCp);
+                }
+
+                // 2. Add regular jars from "libs" folder excluding "optional".
+                std::string libsPath = home + "/libs";
+
+                if (FileExists(libsPath))
+                {
+                    res.append(ClasspathJars(libsPath));
+
+                    // Append inner directories.
+                    DIR* dir = opendir(libsPath.c_str());
+
+                    if (dir)
+                    {
+                        struct dirent* entry;
+
+                        while ((entry = readdir(dir)) != NULL)
+                        {
+                            std::string entryPath = entry->d_name;
+
+                            if (entryPath.compare(".") != 0 && entryPath.compare("..") != 0 &&
+                                entryPath.compare("optional") != 0)
+                            {
+                                std::string entryFullPath = libsPath;
+
+                                entryFullPath.append("/");
+                                entryFullPath.append(entryPath);
+
+                                struct stat entryFullStat;
+
+                                if (stat(entryFullPath.c_str(), &entryFullStat) != -1 && 
+                                    S_ISDIR(entryFullStat.st_mode)) 
+                                    res.append(ClasspathJars(entryFullPath));
+                            }                                                              
+                        }
+
+                        closedir(dir);
+                    }
+                }
+
+                // 3. Return.
+                return res;
+            }
+
+            char* CopyChars(const char* val)
+            {
+                if (val) {
+                    size_t len = strlen(val);
+                    char* dest = new char[len + 1];
+                    strcpy(dest, val);
+                    *(dest + len) = 0;
+                    return dest;
+                }
+                else
+                    return NULL;
+            }
+
+            void ReleaseChars(char* val)
+            {
+                if (val)
+                    delete[] val;
+            }
+
+            std::string GetEnv(const std::string& name, bool* found)
+            {
+                char* val = std::getenv(name.c_str());
+                
+                if (val) {
+                    SetBoolResult(true, found);
+                    
+                    return std::string(val);
+                }
+                else {
+                    SetBoolResult(false, found);
+                    
+                    return std::string();
+                }
+            }
+
+            bool FileExists(const std::string& path)
+            {
+                struct stat s;
+                
+                int res = stat(path.c_str(), &s);
+
+                return res != -1;
+            }
+
+            std::string FindJvmLibrary(const std::string* path, bool* found)
+            {
+                SetBoolResult(true, found); // Optimistically assume that we will find it.
+
+                if (path) {
+                    // If path is provided explicitly, then check only it.
+                    if (FileExists(*path))                            
+                        return std::string(path->data());
+                }
+                else
+                {
+                    bool javaEnvFound;
+                    std::string javaEnv = GetEnv(JAVA_HOME, &javaEnvFound);
+
+                    if (javaEnvFound)
+                    {
+                        std::string javaDll = javaEnv + JAVA_DLL;
+
+                        if (FileExists(javaDll))
+                            return std::string(javaDll);
+                    }
+                }
+
+                SetBoolResult(false, found);
+
+                return std::string();
+            }
+
+            bool LoadJvmLibrary(const std::string& path)
+            {
+                void* hnd = dlopen(path.c_str(), RTLD_LAZY);
+                
+                return hnd != NULL;
+            }                
+
+            std::string ResolveIgniteHome(const std::string* path, bool* found)
+            {
+                if (path)
+                    // 1. Check passed argument.
+                    return ResolveIgniteHome0(*path, false, found);
+                else
+                {
+                    // 2. Check environment variable.
+                    bool envFound;
+                    std::string env = GetEnv(IGNITE_HOME, &envFound);
+
+                    if (envFound)
+                        return ResolveIgniteHome0(env, false, found);
+                }
+
+                SetBoolResult(false, found);
+                        
+                return std::string();
+            }
+
+            std::string CreateIgniteClasspath(const std::string* usrCp, const std::string* home)
+            {
+                bool forceTest = false;
+
+                if (home)
+                {
+                    bool envFound;
+                    std::string env = GetEnv(IGNITE_NATIVE_TEST_CLASSPATH, &envFound);
+
+                    forceTest = envFound && env.compare("true") == 0;
+                }
+
+                return CreateIgniteClasspath(usrCp, home, forceTest);
+            }
+
+            std::string CreateIgniteClasspath(const std::string* usrCp, const std::string* home, bool forceTest)
+            {
+                // 1. Append user classpath if it exists.
+                std::string cp = std::string();
+
+                if (usrCp)
+                {
+                    cp.append(*usrCp);
+
+                    if (*cp.rbegin() != ':')
+                        cp.append(":");
+                }
+
+                // 2. Append home classpath if home is defined.
+                if (home)
+                {
+                    std::string homeCp = CreateIgniteHomeClasspath(*home, forceTest);
+
+                    cp.append(homeCp);
+                }
+
+                // 3. Return.
+                return cp;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/os/win/include/ignite/impl/utils.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/os/win/include/ignite/impl/utils.h b/modules/platform/src/main/cpp/core/os/win/include/ignite/impl/utils.h
new file mode 100644
index 0000000..08e76ee
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/os/win/include/ignite/impl/utils.h
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_UTILS
+#define _IGNITE_UTILS
+
+#include <cstring>
+#include <string>
+
+#include <ignite/common/common.h>
+
+#ifdef IGNITE_FRIEND
+    #define IGNITE_FRIEND_EXPORT IGNITE_EXPORT
+#else
+    #define IGNITE_FRIEND_EXPORT
+#endif
+
+namespace ignite
+{    
+    namespace impl
+    {
+        namespace utils
+        {                
+            /**
+             * Copy characters.
+             *
+             * @param val Value.
+             * @return Result.
+             */
+            IGNITE_FRIEND_EXPORT char* CopyChars(const char* val);
+
+            /**
+             * Release characters.
+             *
+             * @param val Value.
+             */
+            IGNITE_FRIEND_EXPORT void ReleaseChars(char* val);
+            
+            /**
+             * Read system environment variable taking thread-safety in count.
+             *
+             * @param name Environment variable name.
+             * @param found Whether environment variable with such name was found.
+             * @return Environment variable value.
+             */
+            IGNITE_FRIEND_EXPORT std::string GetEnv(const std::string& name, bool* found);
+                                
+            /**
+             * Ensure that file on the given path exists in the system.
+             *
+             * @param path Path.
+             * @return True if file exists, false otherwise.
+             */
+            IGNITE_FRIEND_EXPORT bool FileExists(const std::string& path);
+
+            /**
+             * Attempts to find JVM library to load it into the process later.
+             * First search is performed using the passed path argument (is not NULL).
+             * Then JRE_HOME is evaluated. Last, JAVA_HOME is evaluated.
+             *
+             * @param Explicitly defined path (optional).
+             * @param found Whether library was found.
+             * @return Path to the file.
+             */
+            IGNITE_FRIEND_EXPORT std::string FindJvmLibrary(const std::string* path, bool* found);
+
+            /**
+             * Load JVM library into the process.
+             *
+             * @param path Optional path to the library.
+             * @return Whether load was successful.
+             */
+            IGNITE_FRIEND_EXPORT bool LoadJvmLibrary(const std::string& path);
+
+            /**
+             * Resolve IGNITE_HOME directory. Resolution is performed in several
+             * steps:
+             * 1) Check for path provided as argument.
+             * 2) Check for environment variable.
+             * 3) Check for current working directory.
+             * Result of these 3 checks are evaluated based on existence of certain
+             * predefined folders inside possible GG home. If they are found, 
+             * IGNITE_HOME is considered resolved.
+             *
+             * @param path Optional path to evaluate.
+             * @param found Whether IGNITE_HOME home was found.
+             * @return Resolved GG home.
+             */
+            IGNITE_FRIEND_EXPORT std::string ResolveIgniteHome(const std::string* path, bool* found);
+
+            /**
+             * Create Ignite classpath based on user input and home directory.
+             *
+             * @param usrCp User's classpath.
+             * @param home Ignite home directory.
+             * @return Classpath.
+             */
+            IGNITE_FRIEND_EXPORT std::string CreateIgniteClasspath(const std::string* usrCp, const std::string* home);
+
+            /**
+             * Create Ignite classpath based on user input and home directory.
+             *
+             * @param usrCp User's classpath.
+             * @param home Ignite home directory.
+             * @param test Whether test classpath must be used.
+             * @return Classpath.
+             */
+            IGNITE_FRIEND_EXPORT std::string CreateIgniteClasspath(const std::string* usrCp, const std::string* home, bool test);
+
+            /**
+             * Safe array which automatically reclaims occupied memory when out of scope.
+             */
+            template<typename T>
+            struct IGNITE_FRIEND_EXPORT SafeArray
+            {
+                /** Target array. */
+                T* target;
+
+                /**
+                 * Constructor.
+                 */
+                SafeArray(int cap)
+                {
+                    target = new T[cap];
+                }
+
+                /**
+                 * Destructor.
+                 */
+                ~SafeArray()
+                {
+                    delete[] target;
+                }
+
+                IGNITE_NO_COPY_ASSIGNMENT(SafeArray);
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/os/win/src/impl/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/os/win/src/impl/utils.cpp b/modules/platform/src/main/cpp/core/os/win/src/impl/utils.cpp
new file mode 100644
index 0000000..5a450c3
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/os/win/src/impl/utils.cpp
@@ -0,0 +1,453 @@
+/*
+ * 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.
+ */
+
+#include <windows.h>
+
+#include "ignite/impl/utils.h"
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace utils
+        {
+            const char* JAVA_HOME = "JAVA_HOME";
+            const char* JAVA_DLL = "\\jre\\bin\\server\\jvm.dll";
+
+            const char* IGNITE_HOME = "IGNITE_HOME";
+
+            const char* PROBE_BIN = "\\bin";
+            const char* PROBE_EXAMPLES = "\\examples";
+
+            const char* IGNITE_NATIVE_TEST_CLASSPATH = "IGNITE_NATIVE_TEST_CLASSPATH";
+
+            /**
+             * Helper method to set boolean result to reference with proper NULL-check.
+             *
+             * @param res Result.
+             * @param outRes Where to set the result.
+             */
+            inline void SetBoolResult(bool res, bool* outRes)
+            {
+                if (outRes)
+                    *outRes = res;
+            }
+
+            /**
+             * Check if string ends with the given ending.
+             *
+             * @param str String to check.
+             * @param ending Ending.
+             * @return Result.
+             */
+            inline bool StringEndsWith(const std::string& str, const std::string& ending)
+            {
+                if (str.length() > ending.length())
+                    return str.compare(str.length() - ending.length(), ending.length(), ending) == 0;
+
+                return false;
+            }
+                
+            /**
+             * Helper function for GG home resolution. Checks whether certain folders
+             * exist in the path. Optionally goes upwards in directory hierarchy.
+             *
+             * @param path Path to evaluate.
+             * @param up Whether to go upwards.
+             * @res Resolution result.
+             * @return Resolved directory.
+             */
+            std::string ResolveIgniteHome0(const std::string& path, bool up, bool* res)
+            {
+                DWORD attrs = GetFileAttributesA(path.c_str());
+
+                if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
+                {
+                    // Remove trailing slashes, otherwise we will have an infinite loop.
+                    std::string path0 = path;
+
+                    while (true) {
+                        char lastChar = *path0.rbegin();
+
+                        if (lastChar == '/' || lastChar == '\\' || lastChar == ' ') {
+                            size_t off = path0.find_last_of(lastChar);
+
+                            path0.erase(off, 1);
+                        }
+                        else
+                            break;
+                    }
+
+                    std::string binStr = path0 + PROBE_BIN;
+                    DWORD binAttrs = GetFileAttributesA(binStr.c_str());
+
+                    std::string examplesStr = path0 + PROBE_EXAMPLES;
+                    DWORD examplesAttrs = GetFileAttributesA(examplesStr.c_str());
+
+                    if (binAttrs != INVALID_FILE_ATTRIBUTES && (binAttrs & FILE_ATTRIBUTE_DIRECTORY) &&
+                        examplesAttrs != INVALID_FILE_ATTRIBUTES && (examplesAttrs & FILE_ATTRIBUTE_DIRECTORY))
+                    {
+                        SetBoolResult(true, res);
+                        return std::string(path0);
+                    }
+
+                    if (up)
+                    {
+                        // Evaluate parent directory.
+                        size_t slashPos = path0.find_last_of("/\\");
+
+                        if (slashPos != std::string::npos)
+                        {
+                            std::string parent = path0.substr(0, slashPos);
+
+                            return ResolveIgniteHome0(parent, true, res);
+                        }
+                    }
+                }
+
+                SetBoolResult(false, res);
+
+                return std::string();
+            }
+
+            /**
+             * Create classpath picking JARs from the given path.
+             *
+             * @path Path.
+             * @return Classpath;
+             */
+            std::string ClasspathJars(const std::string& path)
+            {
+                std::string searchPath = path + "\\*.jar";
+
+                std::string res = std::string();
+
+                WIN32_FIND_DATAA findData;
+
+                HANDLE hnd = FindFirstFileA(searchPath.c_str(), &findData);
+
+                if (hnd != INVALID_HANDLE_VALUE)
+                {
+                    do
+                    {
+                        res.append(path);
+                        res.append("\\");
+                        res.append(findData.cFileName);
+                        res.append(";");
+                    } while (FindNextFileA(hnd, &findData) != 0);
+
+                    FindClose(hnd);
+                }
+
+                return res;
+            }
+
+            /**
+             * Create classpath picking compiled classes from the given path.
+             *
+             * @path Path.
+             * @return Classpath;
+             */
+            std::string ClasspathExploded(const std::string& path, bool down)
+            {
+                std::string res = std::string();
+
+                if (FileExists(path))
+                {
+                    // 1. Append "target\classes".
+                    std::string classesPath = path + "\\target\\classes";
+
+                    if (FileExists(classesPath)) {
+                        res.append(classesPath);
+                        res.append(";");
+                    }
+
+                    // 2. Append "target\test-classes"
+                    std::string testClassesPath = path + "\\target\\test-classes";
+
+                    if (FileExists(testClassesPath)) {
+                        res.append(testClassesPath);
+                        res.append(";");
+                    }
+
+                    // 3. Append "target\libs"
+                    std::string libsPath = path + "\\target\\libs";
+
+                    if (FileExists(libsPath)) {
+                        std::string libsCp = ClasspathJars(libsPath);
+                        res.append(libsCp);
+                    }
+
+                    // 4. Do the same for child if needed.
+                    if (down)
+                    {
+                        std::string searchPath = path + "\\*";
+
+                        WIN32_FIND_DATAA findData;
+
+                        HANDLE hnd = FindFirstFileA(searchPath.c_str(), &findData);
+
+                        if (hnd != INVALID_HANDLE_VALUE)
+                        {
+                            do
+                            {
+                                if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+                                {
+                                    std::string childPath = findData.cFileName;
+
+                                    if (childPath.compare(".") != 0 &&
+                                        childPath.compare("..") != 0)
+                                    {
+                                        std::string childCp =
+                                            ClasspathExploded(path + "\\" + childPath, false);
+
+                                        res.append(childCp);
+                                    }
+                                }
+                            } while (FindNextFileA(hnd, &findData) != 0);
+
+                            FindClose(hnd);
+                        }
+                    }
+                }
+
+                return res;
+            }
+
+            /**
+             * Helper function to create classpath based on Ignite home directory.
+             *
+             * @param home Home directory; expected to be valid.
+             * @param forceTest Force test classpath.
+             */
+            std::string CreateIgniteHomeClasspath(const std::string& home, bool forceTest)
+            {
+                std::string res = std::string();
+
+                // 1. Add exploded test directories.
+                if (forceTest)
+                {
+                    std::string examplesPath = home + "\\examples";
+                    std::string examplesCp = ClasspathExploded(examplesPath, true);
+                    res.append(examplesCp);
+
+                    std::string modulesPath = home + "\\modules";
+                    std::string modulesCp = ClasspathExploded(modulesPath, true);
+                    res.append(modulesCp);
+                }
+
+                // 2. Add regular jars from "libs" folder excluding "optional".
+                std::string libsPath = home + "\\libs";
+
+                if (FileExists(libsPath))
+                {
+                    res.append(ClasspathJars(libsPath));
+
+                    // Append inner directories.
+                    std::string libsSearchPath = libsPath + "\\*";
+
+                    WIN32_FIND_DATAA libsFindData;
+
+                    HANDLE libsHnd = FindFirstFileA(libsSearchPath.c_str(), &libsFindData);
+
+                    if (libsHnd != INVALID_HANDLE_VALUE)
+                    {
+                        do
+                        {
+                            if (libsFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+                            {
+                                std::string libsChildPath = libsFindData.cFileName;
+
+                                if (libsChildPath.compare(".") != 0 &&
+                                    libsChildPath.compare("..") != 0 &&
+                                    libsChildPath.compare("optional") != 0) {
+                                    std::string libsFolder = libsPath + "\\" + libsChildPath;
+
+                                    res.append(ClasspathJars(libsFolder));
+                                }
+                            }
+                        } while (FindNextFileA(libsHnd, &libsFindData) != 0);
+
+                        FindClose(libsHnd);
+                    }
+                }
+
+                // 3. Return.
+                return res;
+            }
+
+            char* CopyChars(const char* val)
+            {
+                if (val) {
+                    size_t len = strlen(val);
+                    char* dest = new char[len + 1];
+                    strcpy(dest, val);
+                    *(dest + len) = 0;
+                    return dest;
+                }
+                else
+                    return NULL;
+            }
+
+            void ReleaseChars(char* val)
+            {
+                if (val)
+                    delete[] val;
+            }
+
+            std::string GetEnv(const std::string& name, bool* found)
+            {
+                char res0[32767];
+
+                DWORD envRes = GetEnvironmentVariableA(name.c_str(), res0, 32767);
+
+                if (envRes != 0)
+                {
+                    SetBoolResult(true, found);
+
+                    return std::string(res0);
+                }
+                else 
+                {
+                    SetBoolResult(false, found);
+
+                    return std::string();
+                }
+            }
+
+            bool FileExists(const std::string& path)
+            {
+                WIN32_FIND_DATAA findres;
+
+                HANDLE hnd = FindFirstFileA(path.c_str(), &findres);
+
+                if (hnd == INVALID_HANDLE_VALUE)
+                    return false;
+                else
+                {
+                    FindClose(hnd);
+
+                    return true;
+                }
+            }
+
+            std::string FindJvmLibrary(const std::string* path, bool* found)
+            {
+                SetBoolResult(true, found); // Optimistically assume that we will find it.
+
+                if (path) {
+                    // If path is provided explicitly, then check only it.
+                    if (FileExists(*path))                            
+                        return std::string(path->data());
+                }
+                else
+                {
+                    bool javaEnvFound;
+                    std::string javaEnv = GetEnv(JAVA_HOME, &javaEnvFound);
+
+                    if (javaEnvFound)
+                    {
+                        std::string javaDll = javaEnv + JAVA_DLL;
+
+                        if (FileExists(javaDll))
+                            return std::string(javaDll);
+                    }
+                }
+
+                *found = false; 
+
+                return std::string();
+            }
+
+            bool LoadJvmLibrary(const std::string& path)
+            {
+                HMODULE mod = LoadLibraryA(path.c_str());
+
+                return mod != NULL;
+            }                
+
+            std::string ResolveIgniteHome(const std::string* path, bool* found)
+            {
+                if (path)
+                    // 1. Check passed argument.
+                    return ResolveIgniteHome0(*path, false, found);
+                else
+                {
+                    // 2. Check environment variable.
+                    bool envFound;
+                    std::string env = GetEnv(IGNITE_HOME, &envFound);
+
+                    if (envFound)
+                        return ResolveIgniteHome0(env, false, found);
+
+                    // 3. Check current work dir.
+                    const DWORD curDirLen = GetCurrentDirectory(0, NULL);
+                        
+                    char* curDir = new char[curDirLen];
+
+                    GetCurrentDirectoryA(curDirLen, curDir);
+
+                    std::string curDirStr = curDir;
+
+                    delete[] curDir;
+
+                    return ResolveIgniteHome0(curDirStr, true, found);
+                }
+            }
+
+            std::string CreateIgniteClasspath(const std::string* usrCp, const std::string* home)
+            {
+                bool forceTest = false;
+
+                if (home)
+                {
+                    bool envFound;
+                    std::string env = GetEnv(IGNITE_NATIVE_TEST_CLASSPATH, &envFound);
+
+                    forceTest = envFound && env.compare("true") == 0;
+                }
+
+                return CreateIgniteClasspath(usrCp, home, forceTest);
+            }
+
+            std::string CreateIgniteClasspath(const std::string* usrCp, const std::string* home, bool forceTest)
+            {
+                // 1. Append user classpath if it exists.
+                std::string cp = std::string();
+
+                if (usrCp)
+                {
+                    cp.append(*usrCp);
+
+                    if (*cp.rbegin() != ';')
+                        cp.append(";");
+                }
+
+                // 2. Append home classpath if home is defined.
+                if (home)
+                {
+                    std::string homeCp = CreateIgniteHomeClasspath(*home, forceTest);
+
+                    cp.append(homeCp);
+                }
+
+                // 3. Return.
+                return cp;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/project/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/project/README.TXT b/modules/platform/src/main/cpp/core/project/README.TXT
new file mode 100644
index 0000000..97f4c64
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/project/README.TXT
@@ -0,0 +1 @@
+Contains IDE projects artifacts.

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/project/vs/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/project/vs/README.TXT b/modules/platform/src/main/cpp/core/project/vs/README.TXT
new file mode 100644
index 0000000..f4fb456
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/project/vs/README.TXT
@@ -0,0 +1 @@
+Contains Visual Studio project artifacts.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/project/vs/core.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/project/vs/core.vcxproj b/modules/platform/src/main/cpp/core/project/vs/core.vcxproj
new file mode 100644
index 0000000..58fa283
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/project/vs/core.vcxproj
@@ -0,0 +1,272 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{E2DEA693-F2EA-43C2-A813-053378F6E4DB}</ProjectGuid>
+    <RootNamespace>core</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v100</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <TargetName>ignite.core</TargetName>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <TargetName>ignite.core</TargetName>
+    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <TargetName>ignite.core</TargetName>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <TargetName>ignite.core</TargetName>
+    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include</AdditionalIncludeDirectories>
+      <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+      <IntrinsicFunctions>false</IntrinsicFunctions>
+      <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
+      <OmitFramePointers>false</OmitFramePointers>
+      <StringPooling>true</StringPooling>
+      <MinimalRebuild>false</MinimalRebuild>
+      <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <WholeProgramOptimization>false</WholeProgramOptimization>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <OptimizeReferences>false</OptimizeReferences>
+      <EnableCOMDATFolding>false</EnableCOMDATFolding>
+      <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include</AdditionalIncludeDirectories>
+      <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+      <IntrinsicFunctions>false</IntrinsicFunctions>
+      <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
+      <OmitFramePointers>false</OmitFramePointers>
+      <StringPooling>true</StringPooling>
+      <MinimalRebuild>false</MinimalRebuild>
+      <BasicRuntimeChecks>Default</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <WholeProgramOptimization>false</WholeProgramOptimization>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <OptimizeReferences>false</OptimizeReferences>
+      <EnableCOMDATFolding>false</EnableCOMDATFolding>
+      <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Full</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include</AdditionalIncludeDirectories>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <OmitFramePointers>true</OmitFramePointers>
+      <StringPooling>true</StringPooling>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Full</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>false</SDLCheck>
+      <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include</AdditionalIncludeDirectories>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <OmitFramePointers>true</OmitFramePointers>
+      <StringPooling>true</StringPooling>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <BufferSecurityCheck>false</BufferSecurityCheck>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalDependencies>$(JAVA_HOME)\lib\jvm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\include\ignite\cache\cache.h" />
+    <ClInclude Include="..\..\include\ignite\cache\cache_entry.h" />
+    <ClInclude Include="..\..\include\ignite\cache\cache_peek_mode.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query_argument.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query_cursor.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query_scan.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query_sql.h" />
+    <ClInclude Include="..\..\include\ignite\cache\query\query_text.h" />
+    <ClInclude Include="..\..\include\ignite\ignite.h" />
+    <ClInclude Include="..\..\include\ignite\ignite_configuration.h" />
+    <ClInclude Include="..\..\include\ignite\ignite_error.h" />
+    <ClInclude Include="..\..\include\ignite\ignition.h" />
+    <ClInclude Include="..\..\include\ignite\guid.h" />
+    <ClInclude Include="..\..\include\ignite\impl\cache\cache_impl.h" />
+    <ClInclude Include="..\..\include\ignite\impl\cache\query\query_impl.h" />
+    <ClInclude Include="..\..\include\ignite\impl\ignite_environment.h" />
+    <ClInclude Include="..\..\include\ignite\impl\ignite_impl.h" />
+    <ClInclude Include="..\..\include\ignite\impl\handle_registry.h" />
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop.h" />
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop_input_stream.h" />
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop_memory.h" />
+    <ClInclude Include="..\..\include\ignite\impl\interop\interop_output_stream.h" />
+    <ClInclude Include="..\..\include\ignite\impl\operations.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_common.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_id_resolver.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_handler.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_manager.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_snapshot.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater_impl.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_reader_impl.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_utils.h" />
+    <ClInclude Include="..\..\include\ignite\impl\portable\portable_writer_impl.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_consts.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_containers.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_type.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_raw_reader.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_raw_writer.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_reader.h" />
+    <ClInclude Include="..\..\include\ignite\portable\portable_writer.h" />
+    <ClInclude Include="..\..\os\win\include\ignite\impl\utils.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\os\win\src\impl\utils.cpp" />
+    <ClCompile Include="..\..\src\ignite.cpp" />
+    <ClCompile Include="..\..\src\ignite_error.cpp" />
+    <ClCompile Include="..\..\src\ignition.cpp" />
+    <ClCompile Include="..\..\src\guid.cpp" />
+    <ClCompile Include="..\..\src\impl\cache\cache_impl.cpp" />
+    <ClCompile Include="..\..\src\impl\cache\query\query_impl.cpp" />
+    <ClCompile Include="..\..\src\impl\ignite_environment.cpp" />
+    <ClCompile Include="..\..\src\impl\ignite_impl.cpp" />
+    <ClCompile Include="..\..\src\impl\handle_registry.cpp" />
+    <ClCompile Include="..\..\src\impl\interop\interop_input_stream.cpp" />
+    <ClCompile Include="..\..\src\impl\interop\interop_memory.cpp" />
+    <ClCompile Include="..\..\src\impl\interop\interop_output_stream.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_handler.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_manager.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_snapshot.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater_impl.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_reader_impl.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_utils.cpp" />
+    <ClCompile Include="..\..\src\impl\portable\portable_writer_impl.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_containers.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_type.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_raw_reader.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_raw_writer.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_reader.cpp" />
+    <ClCompile Include="..\..\src\portable\portable_writer.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\common\project\vs\common.vcxproj">
+      <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file


[21/50] [abbrv] ignite git commit: Merge remote-tracking branch 'origin/ignite-1.4' into ignite-1.4

Posted by ak...@apache.org.
Merge remote-tracking branch 'origin/ignite-1.4' into ignite-1.4


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

Branch: refs/heads/ignite-843
Commit: 7f4c9ace076ba4e0be5a97bc61a655b8ec11c363
Parents: 5463df2 0cba13c
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Sep 3 14:28:33 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Sep 3 14:28:33 2015 +0300

----------------------------------------------------------------------
 .../java8/datagrid/CacheAffinityExample.java         | 15 +++++++++++++++
 .../examples/java8/messaging/MessagingExample.java   | 11 ++++++++++-
 .../ignite/java8/examples/BasicExamplesSelfTest.java | 10 +++++++---
 .../ignite/java8/examples/CacheExamplesSelfTest.java |  8 +++++---
 .../java8/examples/CheckpointExamplesSelfTest.java   |  8 ++++----
 .../java8/examples/ClusterGroupExampleSelfTest.java  |  4 +++-
 .../java8/examples/ContinuationExamplesSelfTest.java |  8 +++++---
 .../examples/ContinuousMapperExamplesSelfTest.java   |  8 +++++---
 .../java8/examples/DeploymentExamplesSelfTest.java   |  6 ++++--
 .../java8/examples/EventsExamplesSelfTest.java       |  5 +++--
 .../examples/HibernateL2CacheExampleSelfTest.java    |  8 +++++---
 .../ignite/java8/examples/IgfsExamplesSelfTest.java  |  6 ++++--
 .../java8/examples/LifecycleExamplesSelfTest.java    |  8 +++++---
 .../java8/examples/MemcacheRestExamplesSelfTest.java |  4 +++-
 .../java8/examples/MessagingExamplesSelfTest.java    |  6 ++++--
 .../java8/examples/MonteCarloExamplesSelfTest.java   |  8 +++++---
 .../java8/examples/SpringBeanExamplesSelfTest.java   |  8 +++++---
 .../ignite/java8/examples/TaskExamplesSelfTest.java  |  4 +++-
 .../testsuites/IgniteExamplesJ8SelfTestSuite.java    | 12 ++++++++++--
 19 files changed, 105 insertions(+), 42 deletions(-)
----------------------------------------------------------------------



[24/50] [abbrv] ignite git commit: ignite-1351: moved portable API examples to Ignite except cross-platform example

Posted by ak...@apache.org.
ignite-1351: moved portable API examples to Ignite except cross-platform example


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

Branch: refs/heads/ignite-843
Commit: 6a5a48a0c9e379ecf83c8a799d0d8e2397fe5b3c
Parents: c5d303b
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Sep 3 16:59:36 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Sep 3 16:59:36 2015 +0300

----------------------------------------------------------------------
 examples/config/example-default.xml             |  76 +++++
 examples/config/example-ignite.xml              |  56 +---
 .../config/portable/example-ignite-portable.xml |  44 +++
 .../ignite/examples/portable/Address.java       |  72 +++++
 .../ignite/examples/portable/Employee.java      |  93 ++++++
 .../ignite/examples/portable/EmployeeKey.java   |  90 ++++++
 .../portable/ExamplePortableNodeStartup.java    |  36 +++
 .../ignite/examples/portable/Organization.java  |  93 ++++++
 .../examples/portable/OrganizationType.java     |  32 ++
 ...mputeClientPortableTaskExecutionExample.java | 154 +++++++++
 .../portable/computegrid/ComputeClientTask.java | 116 +++++++
 .../portable/computegrid/package-info.java      |  21 ++
 .../CacheClientPortablePutGetExample.java       | 226 +++++++++++++
 .../CacheClientPortableQueryExample.java        | 323 +++++++++++++++++++
 .../portable/datagrid/package-info.java         |  21 ++
 .../ignite/examples/portable/package-info.java  |  21 ++
 .../CacheClientPortableExampleTest.java         |  46 +++
 .../ComputeClientPortableExampleTest.java       |  37 +++
 .../testsuites/IgniteExamplesSelfTestSuite.java |   6 +
 19 files changed, 1513 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/config/example-default.xml
----------------------------------------------------------------------
diff --git a/examples/config/example-default.xml b/examples/config/example-default.xml
new file mode 100644
index 0000000..e6c359d
--- /dev/null
+++ b/examples/config/example-default.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<!--
+    Ignite configuration with all defaults and enabled p2p deployment and enabled events.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean abstract="true" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <!-- Set to true to enable distributed class loading for examples, default is false. -->
+        <property name="peerClassLoadingEnabled" value="true"/>
+
+        <!-- Enable task execution events for examples. -->
+        <property name="includeEventTypes">
+            <list>
+                <!--Task execution events-->
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
+
+                <!--Cache events-->
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
+            </list>
+        </property>
+
+        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <!--
+                        Ignite provides several options for automatic discovery that can be used
+                        instead os static IP based discovery. For information on all options refer
+                        to our documentation: http://apacheignite.readme.io/docs/cluster-config
+                    -->
+                    <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+                    <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47509</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/config/example-ignite.xml
----------------------------------------------------------------------
diff --git a/examples/config/example-ignite.xml b/examples/config/example-ignite.xml
index e7adb54..d842a6d 100644
--- a/examples/config/example-ignite.xml
+++ b/examples/config/example-ignite.xml
@@ -22,62 +22,18 @@
 -->
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:util="http://www.springframework.org/schema/util"
-       xsi:schemaLocation="
-        http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd
-        http://www.springframework.org/schema/util
-        http://www.springframework.org/schema/util/spring-util.xsd">
-    <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
-        <!-- Set to true to enable distributed class loading for examples, default is false. -->
-        <property name="peerClassLoadingEnabled" value="true"/>
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+    <!-- Imports default Ignite configuration -->
+    <import resource="example-default.xml"/>
 
+    <bean parent="ignite.cfg">
+        <!-- Enabled optimized marshaller -->
         <property name="marshaller">
             <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
                 <!-- Set to false to allow non-serializable objects in examples, default is true. -->
                 <property name="requireSerializable" value="false"/>
             </bean>
         </property>
-
-        <!-- Enable task execution events for examples. -->
-        <property name="includeEventTypes">
-            <list>
-                <!--Task execution events-->
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
-
-                <!--Cache events-->
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
-            </list>
-        </property>
-
-        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
-        <property name="discoverySpi">
-            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
-                <property name="ipFinder">
-                    <!--
-                        Ignite provides several options for automatic discovery that can be used
-                        instead os static IP based discovery. For information on all options refer
-                        to our documentation: http://apacheignite.readme.io/docs/cluster-config
-                    -->
-                    <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
-                    <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
-                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
-                        <property name="addresses">
-                            <list>
-                                <!-- In distributed environment, replace with actual host IP address. -->
-                                <value>127.0.0.1:47500..47509</value>
-                            </list>
-                        </property>
-                    </bean>
-                </property>
-            </bean>
-        </property>
     </bean>
 </beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/config/portable/example-ignite-portable.xml
----------------------------------------------------------------------
diff --git a/examples/config/portable/example-ignite-portable.xml b/examples/config/portable/example-ignite-portable.xml
new file mode 100644
index 0000000..cde15ea
--- /dev/null
+++ b/examples/config/portable/example-ignite-portable.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<!--
+    Ignite configuration with all defaults and enabled p2p deployment, events and portable marshaller.
+
+    Use this configuration file when running HTTP REST examples (see 'examples/rest' folder).
+
+    When starting a standalone node, you need to execute the following command:
+    {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/portable/example-ignite-portable.xml
+
+    When starting Ignite from Java IDE, pass path to this file to Ignition:
+    Ignition.start("examples/config/portable/example-ignite-portable.xml");
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+    <!-- Imports default Ignite configuration -->
+    <import resource="../example-default.xml"/>
+
+    <bean parent="ignite.cfg">
+        <!-- Enables portable marshaller -->
+        <property name="marshaller">
+            <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller"/>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/Address.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/Address.java b/examples/src/main/java/org/apache/ignite/examples/portable/Address.java
new file mode 100644
index 0000000..cb08b25
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/Address.java
@@ -0,0 +1,72 @@
+/*
+ * 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.examples.portable;
+
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableMarshalAware;
+import org.apache.ignite.portable.PortableReader;
+import org.apache.ignite.portable.PortableWriter;
+
+/**
+ * Employee address.
+ * <p>
+ * This class implements {@link PortableMarshalAware} only for example purposes,
+ * in order to show how to customize serialization and deserialization of
+ * portable objects.
+ */
+public class Address implements PortableMarshalAware {
+    /** Street. */
+    private String street;
+
+    /** ZIP code. */
+    private int zip;
+
+    /**
+     * Required for portable deserialization.
+     */
+    public Address() {
+        // No-op.
+    }
+
+    /**
+     * @param street Street.
+     * @param zip ZIP code.
+     */
+    public Address(String street, int zip) {
+        this.street = street;
+        this.zip = zip;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writePortable(PortableWriter writer) throws PortableException {
+        writer.writeString("street", street);
+        writer.writeInt("zip", zip);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readPortable(PortableReader reader) throws PortableException {
+        street = reader.readString("street");
+        zip = reader.readInt("zip");
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "Address [street=" + street +
+            ", zip=" + zip + ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java b/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java
new file mode 100644
index 0000000..9614168
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java
@@ -0,0 +1,93 @@
+/*
+ * 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.examples.portable;
+
+import java.util.Collection;
+
+/**
+ * This class represents employee object.
+ */
+public class Employee {
+    /** Name. */
+    private String name;
+
+    /** Salary. */
+    private long salary;
+
+    /** Address. */
+    private Address address;
+
+    /** Departments. */
+    private Collection<String> departments;
+
+    /**
+     * Required for portable deserialization.
+     */
+    public Employee() {
+        // No-op.
+    }
+
+    /**
+     * @param name Name.
+     * @param salary Salary.
+     * @param address Address.
+     * @param departments Departments.
+     */
+    public Employee(String name, long salary, Address address, Collection<String> departments) {
+        this.name = name;
+        this.salary = salary;
+        this.address = address;
+        this.departments = departments;
+    }
+
+    /**
+     * @return Name.
+     */
+    public String name() {
+        return name;
+    }
+
+    /**
+     * @return Salary.
+     */
+    public long salary() {
+        return salary;
+    }
+
+    /**
+     * @return Address.
+     */
+    public Address address() {
+        return address;
+    }
+
+    /**
+     * @return Departments.
+     */
+    public Collection<String> departments() {
+        return departments;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "Employee [name=" + name +
+            ", salary=" + salary +
+            ", address=" + address +
+            ", departments=" + departments + ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/EmployeeKey.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/EmployeeKey.java b/examples/src/main/java/org/apache/ignite/examples/portable/EmployeeKey.java
new file mode 100644
index 0000000..f322167
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/EmployeeKey.java
@@ -0,0 +1,90 @@
+/*
+ * 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.examples.portable;
+
+/**
+ * This class represents key for employee object.
+ * <p>
+ * Used in query example to collocate employees
+ * with their organizations.
+ */
+public class EmployeeKey {
+    /** ID. */
+    private int id;
+
+    /** Organization ID. */
+    private int organizationId;
+
+    /**
+     * Required for portable deserialization.
+     */
+    public EmployeeKey() {
+        // No-op.
+    }
+
+    /**
+     * @param id ID.
+     * @param organizationId Organization ID.
+     */
+    public EmployeeKey(int id, int organizationId) {
+        this.id = id;
+        this.organizationId = organizationId;
+    }
+
+    /**
+     * @return ID.
+     */
+    public int id() {
+        return id;
+    }
+
+    /**
+     * @return Organization ID.
+     */
+    public int organizationId() {
+        return organizationId;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        EmployeeKey key = (EmployeeKey)o;
+
+        return id == key.id && organizationId == key.organizationId;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = id;
+
+        res = 31 * res + organizationId;
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "EmployeeKey [id=" + id +
+            ", organizationId=" + organizationId + ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/ExamplePortableNodeStartup.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/ExamplePortableNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/portable/ExamplePortableNodeStartup.java
new file mode 100644
index 0000000..87a41f7
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/ExamplePortableNodeStartup.java
@@ -0,0 +1,36 @@
+/*
+ * 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.examples.portable;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+
+/**
+ * Starts up an empty node with example configuration and portable marshaller enabled.
+ */
+public class ExamplePortableNodeStartup {
+    /**
+     * Start up an empty node with example configuration and portable marshaller enabled.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        Ignition.start("examples/config/portable/example-ignite-portable.xml");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/Organization.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/Organization.java b/examples/src/main/java/org/apache/ignite/examples/portable/Organization.java
new file mode 100644
index 0000000..f52cac1
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/Organization.java
@@ -0,0 +1,93 @@
+/*
+ * 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.examples.portable;
+
+import java.sql.Timestamp;
+
+/**
+ * This class represents organization object.
+ */
+public class Organization {
+    /** Name. */
+    private String name;
+
+    /** Address. */
+    private Address address;
+
+    /** Type. */
+    private OrganizationType type;
+
+    /** Last update time. */
+    private Timestamp lastUpdated;
+
+    /**
+     * Required for portable deserialization.
+     */
+    public Organization() {
+        // No-op.
+    }
+
+    /**
+     * @param name Name.
+     * @param address Address.
+     * @param type Type.
+     * @param lastUpdated Last update time.
+     */
+    public Organization(String name, Address address, OrganizationType type, Timestamp lastUpdated) {
+        this.name = name;
+        this.address = address;
+        this.type = type;
+        this.lastUpdated = lastUpdated;
+    }
+
+    /**
+     * @return Name.
+     */
+    public String name() {
+        return name;
+    }
+
+    /**
+     * @return Address.
+     */
+    public Address address() {
+        return address;
+    }
+
+    /**
+     * @return Type.
+     */
+    public OrganizationType type() {
+        return type;
+    }
+
+    /**
+     * @return Last update time.
+     */
+    public Timestamp lastUpdated() {
+        return lastUpdated;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "Organization [name=" + name +
+            ", address=" + address +
+            ", type=" + type +
+            ", lastUpdated=" + lastUpdated + ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/OrganizationType.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/OrganizationType.java b/examples/src/main/java/org/apache/ignite/examples/portable/OrganizationType.java
new file mode 100644
index 0000000..c753e2d
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/OrganizationType.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.portable;
+
+/**
+ * Organization type enum.
+ */
+public enum OrganizationType {
+    /** Non-profit organization. */
+    NON_PROFIT,
+
+    /** Private organization. */
+    PRIVATE,
+
+    /** Government organization. */
+    GOVERNMENT
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java
new file mode 100644
index 0000000..34d9cde
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java
@@ -0,0 +1,154 @@
+/*
+ * 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.examples.portable.computegrid;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.portable.Address;
+import org.apache.ignite.examples.portable.Employee;
+import org.apache.ignite.examples.portable.ExamplePortableNodeStartup;
+import org.apache.ignite.portable.PortableObject;
+
+/**
+ * This example demonstrates use of portable objects with task execution.
+ * Specifically it shows that portable objects are simple Java POJOs and do not require any special treatment.
+ * <p>
+ * The example executes map-reduce task that accepts collection of portable objects as an argument.
+ * Since these objects are never deserialized on remote nodes, classes are not required on classpath
+ * of these nodes.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables the portable marshaller: {@code 'ignite.{sh|bat} examples/config/portable/example-ignite-portable.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExamplePortableNodeStartup} in another JVM which will
+ * start node with {@code examples/config/portable/example-ignite-portable.xml} configuration.
+ */
+public class ComputeClientPortableTaskExecutionExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     */
+    public static void main(String[] args) {
+        try (Ignite ignite = Ignition.start("examples/config/portable/example-ignite-portable.xml")) {
+            System.out.println();
+            System.out.println(">>> Portable objects task execution example started.");
+
+            if (ignite.cluster().forRemotes().nodes().isEmpty()) {
+                System.out.println();
+                System.out.println(">>> This example requires remote nodes to be started.");
+                System.out.println(">>> Please start at least 1 remote node.");
+                System.out.println(">>> Refer to example's javadoc for details on configuration.");
+                System.out.println();
+
+                return;
+            }
+
+            // Generate employees to calculate average salary for.
+            Collection<Employee> employees = employees();
+
+            System.out.println();
+            System.out.println(">>> Calculating average salary for employees:");
+
+            for (Employee employee : employees)
+                System.out.println(">>>     " + employee);
+
+            // Convert collection of employees to collection of portable objects.
+            // This allows to send objects across nodes without requiring to have
+            // Employee class on classpath of these nodes.
+            Collection<PortableObject> portables = ignite.portables().toPortable(employees);
+
+            // Execute task and get average salary.
+            Long avgSalary = ignite.compute(ignite.cluster().forRemotes()).execute(new ComputeClientTask(), portables);
+
+            System.out.println();
+            System.out.println(">>> Average salary for all employees: " + avgSalary);
+            System.out.println();
+        }
+    }
+
+    /**
+     * Creates collection of employees.
+     *
+     * @return Collection of employees.
+     */
+    private static Collection<Employee> employees() {
+        Collection<Employee> employees = new ArrayList<>();
+
+        employees.add(new Employee(
+            "James Wilson",
+            12500,
+            new Address("1096 Eddy Street, San Francisco, CA", 94109),
+            Arrays.asList("Human Resources", "Customer Service")
+        ));
+
+        employees.add(new Employee(
+            "Daniel Adams",
+            11000,
+            new Address("184 Fidler Drive, San Antonio, TX", 78205),
+            Arrays.asList("Development", "QA")
+        ));
+
+        employees.add(new Employee(
+            "Cristian Moss",
+            12500,
+            new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+            Arrays.asList("Logistics")
+        ));
+
+        employees.add(new Employee(
+            "Allison Mathis",
+            25300,
+            new Address("2702 Freedom Lane, Hornitos, CA", 95325),
+            Arrays.asList("Development")
+        ));
+
+        employees.add(new Employee(
+            "Breana Robbin",
+            6500,
+            new Address("3960 Sundown Lane, Austin, TX", 78758),
+            Arrays.asList("Sales")
+        ));
+
+        employees.add(new Employee(
+            "Philip Horsley",
+            19800,
+            new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+            Arrays.asList("Sales")
+        ));
+
+        employees.add(new Employee(
+            "Brian Peters",
+            10600,
+            new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+            Arrays.asList("Development", "QA")
+        ));
+
+        employees.add(new Employee(
+            "Jack Yang",
+            12900,
+            new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130),
+            Arrays.asList("Sales")
+        ));
+
+        return employees;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java
new file mode 100644
index 0000000..0eee8c6
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java
@@ -0,0 +1,116 @@
+/*
+ * 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.examples.portable.computegrid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskSplitAdapter;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.portable.PortableObject;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Task that is used for {@link ComputeClientPortableTaskExecutionExample} and
+ * similar examples in .NET and C++.
+ * <p>
+ * This task calculates average salary for provided collection of employees.
+ * It splits the collection into batches of size {@code 3} and creates a job
+ * for each batch. After all jobs are executed, there results are reduced to
+ * get the average salary.
+ */
+public class ComputeClientTask extends ComputeTaskSplitAdapter<Collection<PortableObject>, Long> {
+    /** {@inheritDoc} */
+    @Override protected Collection<? extends ComputeJob> split(
+        int gridSize,
+        Collection<PortableObject> arg
+    ) {
+        Collection<ComputeClientJob> jobs = new ArrayList<>();
+
+        Collection<PortableObject> employees = new ArrayList<>();
+
+        // Split provided collection into batches and
+        // create a job for each batch.
+        for (PortableObject employee : arg) {
+            employees.add(employee);
+
+            if (employees.size() == 3) {
+                jobs.add(new ComputeClientJob(employees));
+
+                employees = new ArrayList<>(3);
+            }
+        }
+
+        if (!employees.isEmpty())
+            jobs.add(new ComputeClientJob(employees));
+
+        return jobs;
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public Long reduce(List<ComputeJobResult> results) {
+        long sum = 0;
+        int cnt = 0;
+
+        for (ComputeJobResult res : results) {
+            IgniteBiTuple<Long, Integer> t = res.getData();
+
+            sum += t.get1();
+            cnt += t.get2();
+        }
+
+        return sum / cnt;
+    }
+
+    /**
+     * Remote job for {@link ComputeClientTask}.
+     */
+    private static class ComputeClientJob extends ComputeJobAdapter {
+        /** Collection of employees. */
+        private final Collection<PortableObject> employees;
+
+        /**
+         * @param employees Collection of employees.
+         */
+        private ComputeClientJob(Collection<PortableObject> employees) {
+            this.employees = employees;
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public Object execute() {
+            long sum = 0;
+            int cnt = 0;
+
+            for (PortableObject employee : employees) {
+                System.out.println(">>> Processing employee: " + employee.field("name"));
+
+                // Get salary from portable object. Note that object
+                // doesn't need to be fully deserialized.
+                long salary = employee.field("salary");
+
+                sum += salary;
+                cnt++;
+            }
+
+            return new IgniteBiTuple<>(sum, cnt);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/package-info.java b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/package-info.java
new file mode 100644
index 0000000..469128c
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Demonstrates the usage of portable objects with task execution.
+ */
+package org.apache.ignite.examples.portable.computegrid;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java
new file mode 100644
index 0000000..19c5685
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java
@@ -0,0 +1,226 @@
+/*
+ * 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.examples.portable.datagrid;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.portable.Address;
+import org.apache.ignite.examples.portable.ExamplePortableNodeStartup;
+import org.apache.ignite.examples.portable.Organization;
+import org.apache.ignite.examples.portable.OrganizationType;
+import org.apache.ignite.portable.PortableObject;
+
+/**
+ * This example demonstrates use of portable objects with Ignite cache.
+ * Specifically it shows that portable objects are simple Java POJOs and do not require any special treatment.
+ * <p>
+ * The example executes several put-get operations on Ignite cache with portable values. Note that
+ * it demonstrates how portable object can be retrieved in fully-deserialized form or in portable object
+ * format using special cache projection.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables the portable marshaller: {@code 'ignite.{sh|bat} examples/config/portable/example-ignite-portable.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExamplePortableNodeStartup} in another JVM which will
+ * start node with {@code examples/config/portable/example-ignite-portable.xml} configuration.
+ */
+public class CacheClientPortablePutGetExample {
+    /** Cache name. */
+    private static final String CACHE_NAME = CacheClientPortablePutGetExample.class.getSimpleName();
+
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     */
+    public static void main(String[] args) {
+        try (Ignite ignite = Ignition.start("examples/config/portable/example-ignite-portable.xml")) {
+            System.out.println();
+            System.out.println(">>> Portable objects cache put-get example started.");
+
+            CacheConfiguration<Integer, Organization> cfg = new CacheConfiguration<>();
+
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
+            cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+
+            try (IgniteCache<Integer, Organization> cache = ignite.createCache(cfg)) {
+                if (ignite.cluster().forDataNodes(cache.getName()).nodes().isEmpty()) {
+                    System.out.println();
+                    System.out.println(">>> This example requires remote cache node nodes to be started.");
+                    System.out.println(">>> Please start at least 1 remote cache node.");
+                    System.out.println(">>> Refer to example's javadoc for details on configuration.");
+                    System.out.println();
+
+                    return;
+                }
+
+                putGet(cache);
+                putGetPortable(cache);
+                putGetAll(cache);
+                putGetAllPortable(cache);
+
+                System.out.println();
+            }
+        }
+    }
+
+    /**
+     * Execute individual put and get.
+     *
+     * @param cache Cache.
+     */
+    private static void putGet(IgniteCache<Integer, Organization> cache) {
+        // Create new Organization portable object to store in cache.
+        Organization org = new Organization(
+            "Microsoft", // Name.
+            new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address.
+            OrganizationType.PRIVATE, // Type.
+            new Timestamp(System.currentTimeMillis())); // Last update time.
+
+        // Put created data entry to cache.
+        cache.put(1, org);
+
+        // Get recently created organization as a strongly-typed fully de-serialized instance.
+        Organization orgFromCache = cache.get(1);
+
+        System.out.println();
+        System.out.println(">>> Retrieved organization instance from cache: " + orgFromCache);
+    }
+
+    /**
+     * Execute individual put and get, getting value in portable format, without de-serializing it.
+     *
+     * @param cache Cache.
+     */
+    private static void putGetPortable(IgniteCache<Integer, Organization> cache) {
+        // Create new Organization portable object to store in cache.
+        Organization org = new Organization(
+            "Microsoft", // Name.
+            new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address.
+            OrganizationType.PRIVATE, // Type.
+            new Timestamp(System.currentTimeMillis())); // Last update time.
+
+        // Put created data entry to cache.
+        cache.put(1, org);
+
+        // Get cache that will get values as portable objects.
+        IgniteCache<Integer, PortableObject> portableCache = cache.withKeepPortable();
+
+        // Get recently created organization as a portable object.
+        PortableObject po = portableCache.get(1);
+
+        // Get organization's name from portable object (note that
+        // object doesn't need to be fully deserialized).
+        String name = po.field("name");
+
+        System.out.println();
+        System.out.println(">>> Retrieved organization name from portable object: " + name);
+    }
+
+    /**
+     * Execute bulk {@code putAll(...)} and {@code getAll(...)} operations.
+     *
+     * @param cache Cache.
+     */
+    private static void putGetAll(IgniteCache<Integer, Organization> cache) {
+        // Create new Organization portable objects to store in cache.
+        Organization org1 = new Organization(
+            "Microsoft", // Name.
+            new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address.
+            OrganizationType.PRIVATE, // Type.
+            new Timestamp(System.currentTimeMillis())); // Last update time.
+
+        Organization org2 = new Organization(
+            "Red Cross", // Name.
+            new Address("184 Fidler Drive, San Antonio, TX", 78205), // Address.
+            OrganizationType.NON_PROFIT, // Type.
+            new Timestamp(System.currentTimeMillis())); // Last update time.
+
+        Map<Integer, Organization> map = new HashMap<>();
+
+        map.put(1, org1);
+        map.put(2, org2);
+
+        // Put created data entries to cache.
+        cache.putAll(map);
+
+        // Get recently created organizations as a strongly-typed fully de-serialized instances.
+        Map<Integer, Organization> mapFromCache = cache.getAll(map.keySet());
+
+        System.out.println();
+        System.out.println(">>> Retrieved organization instances from cache:");
+
+        for (Organization org : mapFromCache.values())
+            System.out.println(">>>     " + org);
+    }
+
+    /**
+     * Execute bulk {@code putAll(...)} and {@code getAll(...)} operations,
+     * getting values in portable format, without de-serializing it.
+     *
+     * @param cache Cache.
+     */
+    private static void putGetAllPortable(IgniteCache<Integer, Organization> cache) {
+        // Create new Organization portable objects to store in cache.
+        Organization org1 = new Organization(
+            "Microsoft", // Name.
+            new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address.
+            OrganizationType.PRIVATE, // Type.
+            new Timestamp(System.currentTimeMillis())); // Last update time.
+
+        Organization org2 = new Organization(
+            "Red Cross", // Name.
+            new Address("184 Fidler Drive, San Antonio, TX", 78205), // Address.
+            OrganizationType.NON_PROFIT, // Type.
+            new Timestamp(System.currentTimeMillis())); // Last update time.
+
+        Map<Integer, Organization> map = new HashMap<>();
+
+        map.put(1, org1);
+        map.put(2, org2);
+
+        // Put created data entries to cache.
+        cache.putAll(map);
+
+        // Get cache that will get values as portable objects.
+        IgniteCache<Integer, PortableObject> portableCache = cache.withKeepPortable();
+
+        // Get recently created organizations as portable objects.
+        Map<Integer, PortableObject> poMap = portableCache.getAll(map.keySet());
+
+        Collection<String> names = new ArrayList<>();
+
+        // Get organizations' names from portable objects (note that
+        // objects don't need to be fully deserialized).
+        for (PortableObject po : poMap.values())
+            names.add(po.<String>field("name"));
+
+        System.out.println();
+        System.out.println(">>> Retrieved organization names from portable objects: " + names);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java
new file mode 100644
index 0000000..1eb43b3
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java
@@ -0,0 +1,323 @@
+/*
+ * 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.examples.portable.datagrid;
+
+import java.sql.Timestamp;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheTypeMetadata;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.cache.query.TextQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.portable.Address;
+import org.apache.ignite.examples.portable.Employee;
+import org.apache.ignite.examples.portable.EmployeeKey;
+import org.apache.ignite.examples.portable.ExamplePortableNodeStartup;
+import org.apache.ignite.examples.portable.Organization;
+import org.apache.ignite.examples.portable.OrganizationType;
+import org.apache.ignite.portable.PortableObject;
+
+/**
+ * This example demonstrates use of portable objects with cache queries.
+ * The example populates cache with sample data and runs several SQL and full text queries over this data.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables the portable marshaller: {@code 'ignite.{sh|bat} examples/config/portable/example-ignite-portable.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExamplePortableNodeStartup} in another JVM which will
+ * start node with {@code examples/config/portable/example-ignite-portable.xml} configuration.
+ */
+public class CacheClientPortableQueryExample {
+    /** Organization cache name. */
+    private static final String ORGANIZATION_CACHE_NAME = CacheClientPortableQueryExample.class.getSimpleName()
+        + "Organizations";
+
+    /** Employee cache name. */
+    private static final String EMPLOYEE_CACHE_NAME = CacheClientPortableQueryExample.class.getSimpleName()
+        + "Employees";
+
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     */
+    public static void main(String[] args) {
+        try (Ignite ignite = Ignition.start("examples/config/portable/example-ignite-portable.xml")) {
+            System.out.println();
+            System.out.println(">>> Portable objects cache query example started.");
+
+            CacheConfiguration<Integer, Organization> orgCacheCfg = new CacheConfiguration<>();
+
+            orgCacheCfg.setCacheMode(CacheMode.PARTITIONED);
+            orgCacheCfg.setName(ORGANIZATION_CACHE_NAME);
+
+            orgCacheCfg.setTypeMetadata(Arrays.asList(createOrganizationTypeMetadata()));
+
+            CacheConfiguration<EmployeeKey, Employee> employeeCacheCfg = new CacheConfiguration<>();
+
+            employeeCacheCfg.setCacheMode(CacheMode.PARTITIONED);
+            employeeCacheCfg.setName(EMPLOYEE_CACHE_NAME);
+
+            employeeCacheCfg.setTypeMetadata(Arrays.asList(createEmployeeTypeMetadata()));
+
+            try (IgniteCache<Integer, Organization> orgCache = ignite.createCache(orgCacheCfg);
+                 IgniteCache<EmployeeKey, Employee> employeeCache = ignite.createCache(employeeCacheCfg)
+            ) {
+                if (ignite.cluster().forDataNodes(orgCache.getName()).nodes().isEmpty()) {
+                    System.out.println();
+                    System.out.println(">>> This example requires remote cache nodes to be started.");
+                    System.out.println(">>> Please start at least 1 remote cache node.");
+                    System.out.println(">>> Refer to example's javadoc for details on configuration.");
+                    System.out.println();
+
+                    return;
+                }
+
+                // Populate cache with sample data entries.
+                populateCache(orgCache, employeeCache);
+
+                // Get cache that will work with portable objects.
+                IgniteCache<PortableObject, PortableObject> portableCache = employeeCache.withKeepPortable();
+
+                // Run SQL query example.
+                sqlQuery(portableCache);
+
+                // Run SQL query with join example.
+                sqlJoinQuery(portableCache);
+
+                // Run SQL fields query example.
+                sqlFieldsQuery(portableCache);
+
+                // Run full text query example.
+                textQuery(portableCache);
+
+                System.out.println();
+            }
+        }
+    }
+
+    /**
+     * Create cache type metadata for {@link Employee}.
+     *
+     * @return Cache type metadata.
+     */
+    private static CacheTypeMetadata createEmployeeTypeMetadata() {
+        CacheTypeMetadata employeeTypeMeta = new CacheTypeMetadata();
+
+        employeeTypeMeta.setValueType(Employee.class);
+
+        employeeTypeMeta.setKeyType(EmployeeKey.class);
+
+        Map<String, Class<?>> ascFields = new HashMap<>();
+
+        ascFields.put("name", String.class);
+        ascFields.put("salary", Long.class);
+        ascFields.put("address.zip", Integer.class);
+        ascFields.put("organizationId", Integer.class);
+
+        employeeTypeMeta.setAscendingFields(ascFields);
+
+        employeeTypeMeta.setTextFields(Arrays.asList("address.street"));
+
+        return employeeTypeMeta;
+    }
+
+    /**
+     * Create cache type metadata for {@link Organization}.
+     *
+     * @return Cache type metadata.
+     */
+    private static CacheTypeMetadata createOrganizationTypeMetadata() {
+        CacheTypeMetadata organizationTypeMeta = new CacheTypeMetadata();
+
+        organizationTypeMeta.setValueType(Organization.class);
+
+        organizationTypeMeta.setKeyType(Integer.class);
+
+        Map<String, Class<?>> ascFields = new HashMap<>();
+
+        ascFields.put("name", String.class);
+
+        Map<String, Class<?>> queryFields = new HashMap<>();
+
+        queryFields.put("address.street", String.class);
+
+        organizationTypeMeta.setAscendingFields(ascFields);
+
+        organizationTypeMeta.setQueryFields(queryFields);
+
+        return organizationTypeMeta;
+    }
+
+    /**
+     * Queries employees that have provided ZIP code in address.
+     *
+     * @param cache Ignite cache.
+     */
+    private static void sqlQuery(IgniteCache<PortableObject, PortableObject> cache) {
+        SqlQuery<PortableObject, PortableObject> query = new SqlQuery<>(Employee.class, "zip = ?");
+
+        int zip = 94109;
+
+        QueryCursor<Cache.Entry<PortableObject, PortableObject>> employees = cache.query(query.setArgs(zip));
+
+        System.out.println();
+        System.out.println(">>> Employees with zip " + zip + ':');
+
+        for (Cache.Entry<PortableObject, PortableObject> e : employees.getAll())
+            System.out.println(">>>     " + e.getValue().deserialize());
+    }
+
+    /**
+     * Queries employees that work for organization with provided name.
+     *
+     * @param cache Ignite cache.
+     */
+    private static void sqlJoinQuery(IgniteCache<PortableObject, PortableObject> cache) {
+        SqlQuery<PortableObject, PortableObject> query = new SqlQuery<>(Employee.class,
+            "from Employee, \"" + ORGANIZATION_CACHE_NAME + "\".Organization as org " +
+                "where Employee.organizationId = org._key and org.name = ?");
+
+        String organizationName = "GridGain";
+
+        QueryCursor<Cache.Entry<PortableObject, PortableObject>> employees =
+            cache.query(query.setArgs(organizationName));
+
+        System.out.println();
+        System.out.println(">>> Employees working for " + organizationName + ':');
+
+        for (Cache.Entry<PortableObject, PortableObject> e : employees.getAll())
+            System.out.println(">>>     " + e.getValue());
+    }
+
+    /**
+     * Queries names and salaries for all employees.
+     *
+     * @param cache Ignite cache.
+     */
+    private static void sqlFieldsQuery(IgniteCache<PortableObject, PortableObject> cache) {
+        SqlFieldsQuery query = new SqlFieldsQuery("select name, salary from Employee");
+
+        QueryCursor<List<?>> employees = cache.query(query);
+
+        System.out.println();
+        System.out.println(">>> Employee names and their salaries:");
+
+        for (List<?> row : employees.getAll())
+            System.out.println(">>>     [Name=" + row.get(0) + ", salary=" + row.get(1) + ']');
+    }
+
+    /**
+     * Queries employees that live in Texas using full-text query API.
+     *
+     * @param cache Ignite cache.
+     */
+    private static void textQuery(IgniteCache<PortableObject, PortableObject> cache) {
+        TextQuery<PortableObject, PortableObject> query = new TextQuery<>(Employee.class, "TX");
+
+        QueryCursor<Cache.Entry<PortableObject, PortableObject>> employees = cache.query(query);
+
+        System.out.println();
+        System.out.println(">>> Employees living in Texas:");
+
+        for (Cache.Entry<PortableObject, PortableObject> e : employees.getAll())
+            System.out.println(">>>     " + e.getValue().deserialize());
+    }
+
+    /**
+     * Populates cache with data.
+     *
+     * @param orgCache Organization cache.
+     * @param employeeCache Employee cache.
+     */
+    private static void populateCache(IgniteCache<Integer, Organization> orgCache,
+        IgniteCache<EmployeeKey, Employee> employeeCache) {
+        orgCache.put(1, new Organization(
+            "GridGain",
+            new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+            OrganizationType.PRIVATE,
+            new Timestamp(System.currentTimeMillis())
+        ));
+
+        orgCache.put(2, new Organization(
+            "Microsoft",
+            new Address("1096 Eddy Street, San Francisco, CA", 94109),
+            OrganizationType.PRIVATE,
+            new Timestamp(System.currentTimeMillis())
+        ));
+
+        employeeCache.put(new EmployeeKey(1, 1), new Employee(
+            "James Wilson",
+            12500,
+            new Address("1096 Eddy Street, San Francisco, CA", 94109),
+            Arrays.asList("Human Resources", "Customer Service")
+        ));
+
+        employeeCache.put(new EmployeeKey(2, 1), new Employee(
+            "Daniel Adams",
+            11000,
+            new Address("184 Fidler Drive, San Antonio, TX", 78130),
+            Arrays.asList("Development", "QA")
+        ));
+
+        employeeCache.put(new EmployeeKey(3, 1), new Employee(
+            "Cristian Moss",
+            12500,
+            new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+            Arrays.asList("Logistics")
+        ));
+
+        employeeCache.put(new EmployeeKey(4, 2), new Employee(
+            "Allison Mathis",
+            25300,
+            new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+            Arrays.asList("Development")
+        ));
+
+        employeeCache.put(new EmployeeKey(5, 2), new Employee(
+            "Breana Robbin",
+            6500,
+            new Address("3960 Sundown Lane, Austin, TX", 78130),
+            Arrays.asList("Sales")
+        ));
+
+        employeeCache.put(new EmployeeKey(6, 2), new Employee(
+            "Philip Horsley",
+            19800,
+            new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+            Arrays.asList("Sales")
+        ));
+
+        employeeCache.put(new EmployeeKey(7, 2), new Employee(
+            "Brian Peters",
+            10600,
+            new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+            Arrays.asList("Development", "QA")
+        ));
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/package-info.java b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/package-info.java
new file mode 100644
index 0000000..b24f233
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Demonstrates the usage of portable objects with cache.
+ */
+package org.apache.ignite.examples.portable.datagrid;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/main/java/org/apache/ignite/examples/portable/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/package-info.java b/examples/src/main/java/org/apache/ignite/examples/portable/package-info.java
new file mode 100644
index 0000000..4301027
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/portable/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Contains portable classes and examples.
+ */
+package org.apache.ignite.examples.portable;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/test/java/org/apache/ignite/examples/CacheClientPortableExampleTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/CacheClientPortableExampleTest.java b/examples/src/test/java/org/apache/ignite/examples/CacheClientPortableExampleTest.java
new file mode 100644
index 0000000..6ea1484
--- /dev/null
+++ b/examples/src/test/java/org/apache/ignite/examples/CacheClientPortableExampleTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.examples;
+
+import org.apache.ignite.examples.portable.datagrid.CacheClientPortablePutGetExample;
+import org.apache.ignite.examples.portable.datagrid.CacheClientPortableQueryExample;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
+/**
+ *
+ */
+public class CacheClientPortableExampleTest extends GridAbstractExamplesTest {
+    /** {@inheritDoc} */
+    @Override protected String defaultConfig() {
+        return "examples/config/portable/example-ignite-portable.xml";
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPortablePutGetExample() throws Exception {
+        CacheClientPortablePutGetExample.main(new String[] {});
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPortableQueryExample() throws Exception {
+        CacheClientPortableQueryExample.main(new String[] {});
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/test/java/org/apache/ignite/examples/ComputeClientPortableExampleTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/ComputeClientPortableExampleTest.java b/examples/src/test/java/org/apache/ignite/examples/ComputeClientPortableExampleTest.java
new file mode 100644
index 0000000..2223aec
--- /dev/null
+++ b/examples/src/test/java/org/apache/ignite/examples/ComputeClientPortableExampleTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.examples;
+
+import org.apache.ignite.examples.portable.computegrid.ComputeClientPortableTaskExecutionExample;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
+/**
+ *
+ */
+public class ComputeClientPortableExampleTest extends GridAbstractExamplesTest {
+    /** {@inheritDoc} */
+    @Override protected String defaultConfig() {
+        return "examples/config/portable/example-ignite-portable.xml";
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPortableTaskExecutionExample() throws Exception {
+        ComputeClientPortableTaskExecutionExample.main(new String[] {});
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a5a48a0/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
index 4669ae4..baa23fc 100644
--- a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
+++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
@@ -20,10 +20,12 @@ package org.apache.ignite.testsuites;
 import junit.framework.TestSuite;
 import org.apache.ignite.examples.BasicExamplesMultiNodeSelfTest;
 import org.apache.ignite.examples.BasicExamplesSelfTest;
+import org.apache.ignite.examples.CacheClientPortableExampleTest;
 import org.apache.ignite.examples.CacheExamplesMultiNodeSelfTest;
 import org.apache.ignite.examples.CacheExamplesSelfTest;
 import org.apache.ignite.examples.CheckpointExamplesSelfTest;
 import org.apache.ignite.examples.ClusterGroupExampleSelfTest;
+import org.apache.ignite.examples.ComputeClientPortableExampleTest;
 import org.apache.ignite.examples.ContinuationExamplesMultiNodeSelfTest;
 import org.apache.ignite.examples.ContinuationExamplesSelfTest;
 import org.apache.ignite.examples.ContinuousMapperExamplesMultiNodeSelfTest;
@@ -93,6 +95,10 @@ public class IgniteExamplesSelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(MonteCarloExamplesMultiNodeSelfTest.class));
         suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class));
 
+        // Portable.
+        suite.addTest(new TestSuite(CacheClientPortableExampleTest.class));
+        suite.addTest(new TestSuite(ComputeClientPortableExampleTest.class));
+
         return suite;
     }
 }
\ No newline at end of file


[03/50] [abbrv] ignite git commit: IGNITE-1083 (cherry picked from commit 0214ea9)

Posted by ak...@apache.org.
IGNITE-1083
(cherry picked from commit 0214ea9)


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

Branch: refs/heads/ignite-843
Commit: 2a4839c52c87ae25024fc7a7b971136eeb698307
Parents: f940db1
Author: Anton Vinogradov <av...@apache.org>
Authored: Wed Sep 2 19:51:41 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Sep 2 20:08:43 2015 +0300

----------------------------------------------------------------------
 modules/aop/pom.xml                | 1 +
 modules/apache-license-gen/pom.xml | 1 +
 modules/aws/pom.xml                | 1 +
 modules/clients/pom.xml            | 1 +
 modules/cloud/pom.xml              | 1 +
 modules/codegen/pom.xml            | 1 +
 modules/core/pom.xml               | 1 +
 modules/gce/pom.xml                | 1 +
 modules/geospatial/pom.xml         | 1 +
 modules/hadoop/pom.xml             | 1 +
 modules/hibernate/pom.xml          | 1 +
 modules/indexing/pom.xml           | 1 +
 modules/jcl/pom.xml                | 1 +
 modules/jms11/pom.xml              | 1 +
 modules/jta/pom.xml                | 1 +
 modules/kafka/pom.xml              | 1 +
 modules/log4j/pom.xml              | 1 +
 modules/log4j2/pom.xml             | 1 +
 modules/mesos/pom.xml              | 1 +
 modules/platform/pom.xml           | 1 +
 modules/rest-http/pom.xml          | 1 +
 modules/scalar-2.10/pom.xml        | 1 +
 modules/scalar/pom.xml             | 1 +
 modules/schedule/pom.xml           | 1 +
 modules/schema-import/pom.xml      | 1 +
 modules/slf4j/pom.xml              | 1 +
 modules/spark-2.10/pom.xml         | 1 +
 modules/spark/pom.xml              | 1 +
 modules/spring/pom.xml             | 1 +
 modules/ssh/pom.xml                | 1 +
 modules/tools/pom.xml              | 1 +
 modules/urideploy/pom.xml          | 1 +
 modules/visor-console-2.10/pom.xml | 1 +
 modules/visor-console/pom.xml      | 1 +
 modules/visor-plugins/pom.xml      | 1 +
 modules/web/pom.xml                | 1 +
 modules/yardstick/pom.xml          | 1 +
 modules/yarn/pom.xml               | 1 +
 modules/zookeeper/pom.xml          | 1 +
 39 files changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/aop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aop/pom.xml b/modules/aop/pom.xml
index ce5cd10..a080b57 100644
--- a/modules/aop/pom.xml
+++ b/modules/aop/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-aop</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/apache-license-gen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/apache-license-gen/pom.xml b/modules/apache-license-gen/pom.xml
index 4054004..2d15ad4 100644
--- a/modules/apache-license-gen/pom.xml
+++ b/modules/apache-license-gen/pom.xml
@@ -33,6 +33,7 @@
     <groupId>org.apache.ignite</groupId>
     <artifactId>ignite-apache-license-gen</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <build>
         <plugins>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/aws/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aws/pom.xml b/modules/aws/pom.xml
index 8c660ab..63d454d 100644
--- a/modules/aws/pom.xml
+++ b/modules/aws/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-aws</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/clients/pom.xml
----------------------------------------------------------------------
diff --git a/modules/clients/pom.xml b/modules/clients/pom.xml
index 0374bdf..303a274 100644
--- a/modules/clients/pom.xml
+++ b/modules/clients/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-clients</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/cloud/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cloud/pom.xml b/modules/cloud/pom.xml
index 47aedd5..e735804 100644
--- a/modules/cloud/pom.xml
+++ b/modules/cloud/pom.xml
@@ -30,6 +30,7 @@
 
     <artifactId>ignite-cloud</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <properties>
         <jcloud.version>1.9.0</jcloud.version>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/codegen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/codegen/pom.xml b/modules/codegen/pom.xml
index 261e588..a39da2f 100644
--- a/modules/codegen/pom.xml
+++ b/modules/codegen/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-codegen</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 698606e..57abba0 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-core</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <repositories>
         <repository>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/gce/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gce/pom.xml b/modules/gce/pom.xml
index 0e545bf..b3fbb32 100644
--- a/modules/gce/pom.xml
+++ b/modules/gce/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-gce</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/geospatial/pom.xml
----------------------------------------------------------------------
diff --git a/modules/geospatial/pom.xml b/modules/geospatial/pom.xml
index ba29dcf..1330cf5 100644
--- a/modules/geospatial/pom.xml
+++ b/modules/geospatial/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-geospatial</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hadoop/pom.xml b/modules/hadoop/pom.xml
index d7f5ac8..9fdfd99 100644
--- a/modules/hadoop/pom.xml
+++ b/modules/hadoop/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-hadoop</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/hibernate/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/pom.xml b/modules/hibernate/pom.xml
index f8f915b..2d6d893 100644
--- a/modules/hibernate/pom.xml
+++ b/modules/hibernate/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-hibernate</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/indexing/pom.xml
----------------------------------------------------------------------
diff --git a/modules/indexing/pom.xml b/modules/indexing/pom.xml
index ddbd1e3..4bcadc8 100644
--- a/modules/indexing/pom.xml
+++ b/modules/indexing/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-indexing</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/jcl/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jcl/pom.xml b/modules/jcl/pom.xml
index 0c405ee..0b2c48b 100644
--- a/modules/jcl/pom.xml
+++ b/modules/jcl/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-jcl</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/jms11/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jms11/pom.xml b/modules/jms11/pom.xml
index c93ea9a..ff80007 100644
--- a/modules/jms11/pom.xml
+++ b/modules/jms11/pom.xml
@@ -33,6 +33,7 @@
 
     <artifactId>ignite-jms11</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <properties>
         <activemq.version>5.11.1</activemq.version>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/jta/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jta/pom.xml b/modules/jta/pom.xml
index 2df9bda..7965dd9 100644
--- a/modules/jta/pom.xml
+++ b/modules/jta/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-jta</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/kafka/pom.xml
----------------------------------------------------------------------
diff --git a/modules/kafka/pom.xml b/modules/kafka/pom.xml
index 9b9d95c..ed192ab 100644
--- a/modules/kafka/pom.xml
+++ b/modules/kafka/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-kafka</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/log4j/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j/pom.xml b/modules/log4j/pom.xml
index fbba149..c3c4a84 100644
--- a/modules/log4j/pom.xml
+++ b/modules/log4j/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-log4j</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/log4j2/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j2/pom.xml b/modules/log4j2/pom.xml
index 58dc05e..0628b47 100644
--- a/modules/log4j2/pom.xml
+++ b/modules/log4j2/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-log4j2</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/mesos/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mesos/pom.xml b/modules/mesos/pom.xml
index 525137f..07bd13d 100644
--- a/modules/mesos/pom.xml
+++ b/modules/mesos/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-mesos</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <properties>
         <mesos.version>0.22.0</mesos.version>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/platform/pom.xml
----------------------------------------------------------------------
diff --git a/modules/platform/pom.xml b/modules/platform/pom.xml
index e583f6a..4bff370 100644
--- a/modules/platform/pom.xml
+++ b/modules/platform/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-platform</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/rest-http/pom.xml
----------------------------------------------------------------------
diff --git a/modules/rest-http/pom.xml b/modules/rest-http/pom.xml
index 4ce41ae..8156887 100644
--- a/modules/rest-http/pom.xml
+++ b/modules/rest-http/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-rest-http</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/scalar-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/scalar-2.10/pom.xml b/modules/scalar-2.10/pom.xml
index e21ba47..42fb9b9 100644
--- a/modules/scalar-2.10/pom.xml
+++ b/modules/scalar-2.10/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-scalar_2.10</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/scalar/pom.xml
----------------------------------------------------------------------
diff --git a/modules/scalar/pom.xml b/modules/scalar/pom.xml
index 81f4427..982fcaf 100644
--- a/modules/scalar/pom.xml
+++ b/modules/scalar/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-scalar</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/schedule/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schedule/pom.xml b/modules/schedule/pom.xml
index b3e1c18..e64059a 100644
--- a/modules/schedule/pom.xml
+++ b/modules/schedule/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-schedule</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import/pom.xml b/modules/schema-import/pom.xml
index 7364e1e..0ba8597 100644
--- a/modules/schema-import/pom.xml
+++ b/modules/schema-import/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-schema-import</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/slf4j/pom.xml
----------------------------------------------------------------------
diff --git a/modules/slf4j/pom.xml b/modules/slf4j/pom.xml
index cf98419..5cdf791 100644
--- a/modules/slf4j/pom.xml
+++ b/modules/slf4j/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-slf4j</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/spark-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spark-2.10/pom.xml b/modules/spark-2.10/pom.xml
index 848d550..6c44006 100644
--- a/modules/spark-2.10/pom.xml
+++ b/modules/spark-2.10/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-spark_2.10</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/spark/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spark/pom.xml b/modules/spark/pom.xml
index 3783a40..1fb2753 100644
--- a/modules/spark/pom.xml
+++ b/modules/spark/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-spark</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/spring/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spring/pom.xml b/modules/spring/pom.xml
index f5563f5..4ed1fd7 100644
--- a/modules/spring/pom.xml
+++ b/modules/spring/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-spring</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/ssh/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ssh/pom.xml b/modules/ssh/pom.xml
index 2d77c80..7922f53 100644
--- a/modules/ssh/pom.xml
+++ b/modules/ssh/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-ssh</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/tools/pom.xml
----------------------------------------------------------------------
diff --git a/modules/tools/pom.xml b/modules/tools/pom.xml
index 30b1a3e..5e3465e 100644
--- a/modules/tools/pom.xml
+++ b/modules/tools/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-tools</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/urideploy/pom.xml
----------------------------------------------------------------------
diff --git a/modules/urideploy/pom.xml b/modules/urideploy/pom.xml
index 94dc956..7dd0431 100644
--- a/modules/urideploy/pom.xml
+++ b/modules/urideploy/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-urideploy</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/visor-console-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console-2.10/pom.xml b/modules/visor-console-2.10/pom.xml
index 167708b..a0edeaf 100644
--- a/modules/visor-console-2.10/pom.xml
+++ b/modules/visor-console-2.10/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-visor-console_2.10</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/visor-console/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console/pom.xml b/modules/visor-console/pom.xml
index 9cadedb..d6f373a 100644
--- a/modules/visor-console/pom.xml
+++ b/modules/visor-console/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-visor-console</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/visor-plugins/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-plugins/pom.xml b/modules/visor-plugins/pom.xml
index ae038cd..04142fa 100644
--- a/modules/visor-plugins/pom.xml
+++ b/modules/visor-plugins/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-visor-plugins</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <!-- Ignite dependencies -->

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/web/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web/pom.xml b/modules/web/pom.xml
index a682210..4432d81 100644
--- a/modules/web/pom.xml
+++ b/modules/web/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-web</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <dependencies>
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index dc4a033..3f3774a 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-yardstick</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <properties>
         <yardstick.version>0.7.0</yardstick.version>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/yarn/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yarn/pom.xml b/modules/yarn/pom.xml
index ad17f6b..079a173 100644
--- a/modules/yarn/pom.xml
+++ b/modules/yarn/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-yarn</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <properties>
         <hadoop.version>2.7.0</hadoop.version>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a4839c5/modules/zookeeper/pom.xml
----------------------------------------------------------------------
diff --git a/modules/zookeeper/pom.xml b/modules/zookeeper/pom.xml
index bf0c578..ba10101 100644
--- a/modules/zookeeper/pom.xml
+++ b/modules/zookeeper/pom.xml
@@ -32,6 +32,7 @@
 
     <artifactId>ignite-zookeeper</artifactId>
     <version>1.4.1-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
 
     <properties>
         <curator.version>2.8.0</curator.version>


[45/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/portable_session_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/portable_session_test.cpp b/modules/platform/src/main/cpp/core-test/src/portable_session_test.cpp
new file mode 100644
index 0000000..9d84e48
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/portable_session_test.cpp
@@ -0,0 +1,257 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/impl/portable/portable_writer_impl.h"
+
+#include "ignite/portable_test_defs.h"
+
+using namespace ignite;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+using namespace ignite::portable;
+using namespace ignite_test::core::portable;
+
+/*
+ * Check primitive value serialization-deserialization.
+ */
+template<typename T>
+void CheckRawPrimitive(T writeVal) 
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem); 
+    PortableWriterImpl writeSes(&out, NULL);
+    writeSes.WriteTopObject<T>(writeVal);
+    out.Synchronize();
+
+    InteropInputStream in(&mem); 
+    PortableReaderImpl reader(&in);
+    T readVal = reader.ReadTopObject<T>();
+
+    BOOST_REQUIRE(readVal == writeVal);
+}
+
+BOOST_AUTO_TEST_SUITE(PortableSessionTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestByte)
+{
+    CheckRawPrimitive<int8_t>(-128);
+    CheckRawPrimitive<int8_t>(-1);
+    CheckRawPrimitive<int8_t>(0);
+    CheckRawPrimitive<int8_t>(1);
+    CheckRawPrimitive<int8_t>(127);
+}
+
+BOOST_AUTO_TEST_CASE(TestBool)
+{
+    CheckRawPrimitive<bool>(true);
+    CheckRawPrimitive<bool>(false);
+}
+
+BOOST_AUTO_TEST_CASE(TestShort)
+{
+    //CheckRawPrimitive<int16_t>(std::numeric_limits<int16_t>::min()); 
+    CheckRawPrimitive<int16_t>(-1);
+    CheckRawPrimitive<int16_t>(0);
+    CheckRawPrimitive<int16_t>(1);
+    //CheckRawPrimitive<int16_t>(std::numeric_limits<int16_t>::max());
+}
+
+BOOST_AUTO_TEST_CASE(TestChar)
+{
+    //CheckRawPrimitive<uint16_t>(std::numeric_limits<uint16_t>::min());
+    CheckRawPrimitive<uint16_t>(1);
+    //CheckRawPrimitive<uint16_t>(std::numeric_limits<uint16_t>::max());
+}
+
+BOOST_AUTO_TEST_CASE(TestInt)
+{
+    //CheckRawPrimitive<int32_t>(std::numeric_limits<int32_t>::min());
+    CheckRawPrimitive<int32_t>(-1);
+    CheckRawPrimitive<int32_t>(0);
+    CheckRawPrimitive<int32_t>(1);
+    //CheckRawPrimitive<int32_t>(std::numeric_limits<int32_t>::max());
+}
+
+BOOST_AUTO_TEST_CASE(TestLong)
+{
+    //CheckRawPrimitive<int64_t>(std::numeric_limits<int64_t>::min());
+    CheckRawPrimitive<int64_t>(-1);
+    CheckRawPrimitive<int64_t>(0);
+    CheckRawPrimitive<int64_t>(1);
+    //CheckRawPrimitive<int64_t>(std::numeric_limits<int64_t>::max());
+}
+
+BOOST_AUTO_TEST_CASE(TestFloat)
+{
+    CheckRawPrimitive<float>(-1.1f);
+    CheckRawPrimitive<float>(0);
+    CheckRawPrimitive<float>(1.1f);
+}
+
+BOOST_AUTO_TEST_CASE(TestDouble)
+{
+    CheckRawPrimitive<double>(-1.1);
+    CheckRawPrimitive<double>(0);
+    CheckRawPrimitive<double>(1.1);
+}
+
+BOOST_AUTO_TEST_CASE(TestGuid)
+{
+    Guid writeVal = Guid(1, 1);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writeSes(&out, NULL);
+    writeSes.WriteTopObject<Guid>(writeVal);
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    Guid readVal = reader.ReadTopObject<Guid>();
+
+    BOOST_REQUIRE(readVal.GetMostSignificantBits() == writeVal.GetMostSignificantBits());
+    BOOST_REQUIRE(readVal.GetLeastSignificantBits() == writeVal.GetLeastSignificantBits());    
+}
+
+BOOST_AUTO_TEST_CASE(TestString)
+{
+    std::string writeVal = "MyString";
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writeSes(&out, NULL);
+    writeSes.WriteTopObject<std::string>(writeVal);
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    std::string readVal = reader.ReadTopObject<std::string>();
+
+    BOOST_REQUIRE(readVal.compare(writeVal) == 0);
+}
+
+BOOST_AUTO_TEST_CASE(TestObject)
+{
+    InteropUnpooledMemory mem(1024);
+    
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+
+    // 1. Test null object.
+    PortableInner writeVal(0);
+    
+    writer.WriteTopObject<PortableInner>(writeVal);
+    out.Synchronize();
+    
+    in.Synchronize();
+    PortableInner readVal = reader.ReadTopObject<PortableInner>();
+
+    BOOST_REQUIRE(readVal.GetValue() == 0);
+
+    // 2. Test non-null object.
+    out.Position(0);
+    in.Position(0);
+
+    writeVal = PortableInner(1);
+
+    writer.WriteTopObject<PortableInner>(writeVal);
+    out.Synchronize();
+
+    in.Synchronize();
+    readVal = reader.ReadTopObject<PortableInner>();
+
+    BOOST_REQUIRE(readVal.GetValue() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestObjectWithRawFields)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+
+    out.Position(0);
+    in.Position(0);
+
+    PortableFields writeVal = PortableFields(1, 2, 3, 4);
+
+    writer.WriteTopObject<PortableFields>(writeVal);
+    out.Synchronize();
+
+    in.Synchronize();
+    PortableFields readVal = reader.ReadTopObject<PortableFields>();
+
+    BOOST_REQUIRE(readVal.val1 == 1);
+    BOOST_REQUIRE(readVal.val2 == 2);
+    BOOST_REQUIRE(readVal.rawVal1 == 3);
+    BOOST_REQUIRE(readVal.rawVal2 == 4);
+}
+
+BOOST_AUTO_TEST_CASE(TestPointer)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+
+    // 1. Test null object.
+    writer.WriteTopObject<PortableInner*>(NULL);
+    out.Synchronize();
+
+    in.Synchronize();
+    PortableInner* readVal = reader.ReadTopObject<PortableInner*>();
+
+    BOOST_REQUIRE(readVal == NULL);
+
+    // 2. Test non-null object.
+    out.Position(0);
+    in.Position(0);
+
+    PortableInner writeVal = PortableInner(1);
+
+    writer.WriteTopObject<PortableInner*>(&writeVal);
+    out.Synchronize();
+
+    in.Synchronize();
+    readVal = reader.ReadTopObject<PortableInner*>();
+
+    BOOST_REQUIRE(readVal->GetValue() == 1);
+
+    delete readVal;
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/portable_test_defs.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/portable_test_defs.cpp b/modules/platform/src/main/cpp/core-test/src/portable_test_defs.cpp
new file mode 100644
index 0000000..e818711
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/portable_test_defs.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/portable/portable.h"
+
+#include "ignite/portable_test_defs.h"
+
+using namespace ignite;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+using namespace ignite::portable;
+
+namespace ignite_test
+{
+    namespace core
+    {
+        namespace portable
+        {
+            PortableInner::PortableInner() : val(0)
+            {
+                // No-op.
+            }
+
+            PortableInner::PortableInner(int32_t val) : val(val)
+            {
+                // No-op.
+            }
+
+            int32_t PortableInner::GetValue() const
+            {
+                return val;
+            }
+
+            PortableOuter::PortableOuter(int32_t valIn, int32_t valOut) : inner(valIn), val(valOut)
+            {
+                // No-op.
+            }
+
+            PortableInner PortableOuter::GetInner() const
+            {
+                return inner;
+            }
+
+            int32_t PortableOuter::GetValue() const
+            {
+                return val;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/teamcity_boost.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/teamcity_boost.cpp b/modules/platform/src/main/cpp/core-test/src/teamcity_boost.cpp
new file mode 100644
index 0000000..45c666d
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/teamcity_boost.cpp
@@ -0,0 +1,159 @@
+/* Copyright 2011 JetBrains s.r.o.
+ * 
+ * Licensed 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.
+ * 
+ * $Revision: 88625 $
+*/
+
+#define BOOST_TEST_MODULE IgniteCoreTest
+
+#include <sstream>
+
+#include <boost/test/unit_test_suite_impl.hpp>
+#include <boost/test/results_collector.hpp>
+#include <boost/test/utils/basic_cstring/io.hpp>
+#include <boost/test/unit_test_log.hpp>
+#include <boost/test/included/unit_test.hpp>
+
+#include "teamcity_messages.h"
+
+using namespace boost::unit_test;
+using namespace std;
+
+namespace JetBrains {
+
+// Custom formatter for TeamCity messages
+class TeamcityBoostLogFormatter: public boost::unit_test::unit_test_log_formatter {
+    TeamcityMessages messages;
+    std::string currentDetails;
+    std::string flowId;
+    
+public:
+    TeamcityBoostLogFormatter(const std::string &_flowId);
+    TeamcityBoostLogFormatter();
+    
+    void log_start(std::ostream&, boost::unit_test::counter_t test_cases_amount);
+    void log_finish(std::ostream&);
+    void log_build_info(std::ostream&);
+
+    void test_unit_start(std::ostream&, boost::unit_test::test_unit const& tu);
+    void test_unit_finish(std::ostream&,
+        boost::unit_test::test_unit const& tu,
+        unsigned long elapsed);
+    void test_unit_skipped(std::ostream&, boost::unit_test::test_unit const& tu);
+
+    void log_exception(std::ostream&,
+        boost::unit_test::log_checkpoint_data const&,
+        boost::unit_test::const_string explanation);
+
+    void log_entry_start(std::ostream&,
+        boost::unit_test::log_entry_data const&,
+        log_entry_types let);
+    void log_entry_value(std::ostream&, boost::unit_test::const_string value);
+    void log_entry_finish(std::ostream&);
+};
+
+// Fake fixture to register formatter
+struct TeamcityFormatterRegistrar {
+    TeamcityFormatterRegistrar() {
+        if (JetBrains::underTeamcity()) {
+            boost::unit_test::unit_test_log.set_formatter(new JetBrains::TeamcityBoostLogFormatter());
+            boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_successful_tests);
+        }
+    }
+};
+BOOST_GLOBAL_FIXTURE(TeamcityFormatterRegistrar);
+
+// Formatter implementation
+string toString(const_string bstr) {
+    stringstream ss;
+    
+    ss << bstr;
+    
+    return ss.str();
+}
+
+TeamcityBoostLogFormatter::TeamcityBoostLogFormatter(const std::string &_flowId)
+: flowId(_flowId)
+{}
+
+TeamcityBoostLogFormatter::TeamcityBoostLogFormatter()
+: flowId(getFlowIdFromEnvironment())
+{}
+
+void TeamcityBoostLogFormatter::log_start(ostream &out, counter_t test_cases_amount)
+{}
+
+void TeamcityBoostLogFormatter::log_finish(ostream &out)
+{}
+
+void TeamcityBoostLogFormatter::log_build_info(ostream &out)
+{}
+
+void TeamcityBoostLogFormatter::test_unit_start(ostream &out, test_unit const& tu) {
+    messages.setOutput(out);
+
+    if (tu.p_type == tut_case) {
+        messages.testStarted(tu.p_name, flowId);
+    } else {
+        messages.suiteStarted(tu.p_name, flowId);
+    }
+    
+    currentDetails.clear();
+}
+
+void TeamcityBoostLogFormatter::test_unit_finish(ostream &out, test_unit const& tu, unsigned long elapsed) {
+    messages.setOutput(out);
+
+    test_results const& tr = results_collector.results(tu.p_id);
+    if (tu.p_type == tut_case) {
+        if(!tr.passed()) {
+            if(tr.p_skipped) {
+                messages.testIgnored(tu.p_name, "ignored", flowId);
+            } else if (tr.p_aborted) {
+                messages.testFailed(tu.p_name, "aborted", currentDetails, flowId);
+            } else {
+                messages.testFailed(tu.p_name, "failed", currentDetails, flowId);
+            }
+        }
+        
+        messages.testFinished(tu.p_name, elapsed / 1000, flowId);
+    } else {
+        messages.suiteFinished(tu.p_name, flowId);
+    }
+}
+
+void TeamcityBoostLogFormatter::test_unit_skipped(ostream &out, test_unit const& tu)
+{}
+
+void TeamcityBoostLogFormatter::log_exception(ostream &out, log_checkpoint_data const&, const_string explanation) {
+    string what = toString(explanation);
+    
+    out << what << endl;
+    currentDetails += what + "\n";
+}
+
+void TeamcityBoostLogFormatter::log_entry_start(ostream&, log_entry_data const&, log_entry_types let)
+{}
+
+void TeamcityBoostLogFormatter::log_entry_value(ostream &out, const_string value) {
+    out << value;
+    currentDetails += toString(value);
+}
+
+void TeamcityBoostLogFormatter::log_entry_finish(ostream &out) {
+    out << endl;
+    currentDetails += "\n";
+}
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core-test/src/teamcity_messages.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/teamcity_messages.cpp b/modules/platform/src/main/cpp/core-test/src/teamcity_messages.cpp
new file mode 100644
index 0000000..087409e
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/teamcity_messages.cpp
@@ -0,0 +1,150 @@
+/* Copyright 2011 JetBrains s.r.o.
+ * 
+ * Licensed 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.
+ *
+ * $Revision: 88625 $
+*/
+
+#include <stdlib.h>
+#include <sstream>
+
+#include "teamcity_messages.h"
+
+using namespace std;
+
+namespace JetBrains {
+
+std::string getFlowIdFromEnvironment() {
+    const char *flowId = getenv("TEAMCITY_PROCESS_FLOW_ID");
+    return flowId == NULL ? "" : flowId;
+}
+
+bool underTeamcity() {
+    return getenv("TEAMCITY_PROJECT_NAME") != NULL;
+}
+
+TeamcityMessages::TeamcityMessages()
+: m_out(&cout)
+{}
+
+void TeamcityMessages::setOutput(ostream &out) {
+    m_out = &out;
+}
+
+string TeamcityMessages::escape(string s) {
+    string result;
+    
+    for (size_t i = 0; i < s.length(); i++) {
+        char c = s[i];
+        
+        switch (c) {
+        case '\n': result.append("|n"); break;
+        case '\r': result.append("|r"); break;
+        case '\'': result.append("|'"); break;
+        case '|':  result.append("||"); break;
+        case ']':  result.append("|]"); break;
+        default:   result.append(&c, 1);
+        }
+    }
+    
+    return result;
+}
+
+void TeamcityMessages::openMsg(const string &name) {
+    // endl for http://jetbrains.net/tracker/issue/TW-4412
+    *m_out << endl << "##teamcity[" << name;
+}
+
+void TeamcityMessages::closeMsg() {
+    *m_out << "]";
+    // endl for http://jetbrains.net/tracker/issue/TW-4412
+    *m_out << endl;
+    m_out->flush();
+}
+
+void TeamcityMessages::writeProperty(string name, string value) {
+    *m_out << " " << name << "='" << escape(value) << "'";
+}
+
+void TeamcityMessages::suiteStarted(string name, string flowid) {
+    openMsg("testSuiteStarted");
+    writeProperty("name", name);
+    if(flowid.length() > 0) {
+        writeProperty("flowId", flowid);
+    }
+    
+    closeMsg();
+}
+
+void TeamcityMessages::suiteFinished(string name, string flowid) {
+    openMsg("testSuiteFinished");
+    writeProperty("name", name);
+    if(flowid.length() > 0) {
+        writeProperty("flowId", flowid);
+    }
+    
+    closeMsg();
+}
+
+void TeamcityMessages::testStarted(string name, string flowid) {
+    openMsg("testStarted");
+    writeProperty("name", name);
+    if(flowid.length() > 0) {
+        writeProperty("flowId", flowid);
+    }
+    
+    closeMsg();
+}
+
+void TeamcityMessages::testFinished(string name, int durationMs, string flowid) {
+    openMsg("testFinished");
+
+    writeProperty("name", name);
+
+    if(flowid.length() > 0) {
+        writeProperty("flowId", flowid);
+    }
+
+    if(durationMs >= 0) {
+        stringstream out;
+        out << durationMs;
+        writeProperty("duration", out.str());
+    }
+    
+    closeMsg();
+}
+
+void TeamcityMessages::testFailed(string name, string message, string details, string flowid) {
+    openMsg("testFailed");
+    writeProperty("name", name);
+    writeProperty("message", message);
+    writeProperty("details", details);
+    if(flowid.length() > 0) {
+        writeProperty("flowId", flowid);
+    }
+    
+    closeMsg();
+}
+
+void TeamcityMessages::testIgnored(std::string name, std::string message, string flowid) {
+    openMsg("testIgnored");
+    writeProperty("name", name);
+    writeProperty("message", message);
+    if(flowid.length() > 0) {
+        writeProperty("flowId", flowid);
+    }
+    
+    closeMsg();
+}
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/Makefile.am b/modules/platform/src/main/cpp/core/Makefile.am
new file mode 100644
index 0000000..db50326
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/Makefile.am
@@ -0,0 +1,66 @@
+##
+## 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.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+SUBDIRS = . include os/linux/include
+DIST_SUBDIRS = . include os/linux/include
+
+AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/os/linux/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -DIGNITE_IMPL
+AM_CXXFLAGS = -Wall -std=c++0x
+LIB_LDFLAGS = -no-undefined -version-info 1
+
+COMMON_SRC = os/linux/src/impl/utils.cpp \
+             src/ignite_error.cpp \
+             src/guid.cpp \
+             src/impl/handle_registry.cpp \
+             src/impl/interop/interop_memory.cpp \
+             src/impl/interop/interop_input_stream.cpp \
+             src/impl/interop/interop_output_stream.cpp \
+             src/portable/portable_type.cpp \
+             src/impl/portable/portable_metadata_snapshot.cpp \
+             src/impl/portable/portable_metadata_handler.cpp \
+             src/impl/portable/portable_metadata_updater.cpp \
+             src/impl/portable/portable_metadata_manager.cpp \
+             src/impl/portable/portable_utils.cpp \
+             src/impl/portable/portable_reader_impl.cpp \
+             src/impl/portable/portable_writer_impl.cpp \
+             src/portable/portable_containers.cpp \
+             src/portable/portable_raw_reader.cpp \
+             src/portable/portable_raw_writer.cpp \
+             src/portable/portable_reader.cpp \
+             src/portable/portable_writer.cpp \
+             src/impl/portable/portable_metadata_updater_impl.cpp \
+             src/impl/ignite_environment.cpp \
+             src/impl/cache/query/query_impl.cpp \
+             src/impl/cache/cache_impl.cpp \
+             src/impl/ignite_impl.cpp \
+             src/ignite.cpp \
+             src/ignition.cpp
+
+lib_LTLIBRARIES = libignite.la
+libignite_la_SOURCES = $(COMMON_SRC)
+libignite_la_LDFLAGS = $(LIB_LDFLAGS) -L/usr/local/lib -lignite-common -ldl -version-info 0:0:0 -release $(PACKAGE_VERSION)
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = ignite.pc
+
+clean-local:
+	$(RM) *.gcno *.gcda
+
+clean-docs:
+	$(RM) $(DX_CLEANFILES)

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/configure.ac b/modules/platform/src/main/cpp/core/configure.ac
new file mode 100644
index 0000000..cdd238f
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/configure.ac
@@ -0,0 +1,62 @@
+#
+# 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.
+#
+
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([Apache Ignite C++], [1.4.0], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_CONFIG_SRCDIR(src)
+
+AC_CANONICAL_SYSTEM
+AC_CONFIG_MACRO_DIR([m4])
+AC_LANG([C++])
+
+# Initialize automake
+AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
+AC_CONFIG_HEADER(config.h)
+
+AM_PROG_AR
+
+# Checks for programs.
+GXX="-g -O2"
+
+AC_PROG_CXX
+
+# Initialize Libtool
+LT_INIT
+
+# Checks for libraries.
+AC_CHECK_LIB([pthread], [pthread_mutex_lock])
+
+# Checks for header files.
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_FUNC_ERROR_AT_LINE
+
+AC_CONFIG_FILES(Makefile include/Makefile os/linux/include/Makefile ignite.pc)
+
+AC_OUTPUT

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/ignite.pc.in
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/ignite.pc.in b/modules/platform/src/main/cpp/core/ignite.pc.in
new file mode 100644
index 0000000..613fd1a
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/ignite.pc.in
@@ -0,0 +1,9 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ignite
+Description: Apache Ignite C++.
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lignite

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/Makefile.am b/modules/platform/src/main/cpp/core/include/Makefile.am
new file mode 100644
index 0000000..da9d95e
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/Makefile.am
@@ -0,0 +1,61 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+nobase_include_HEADERS = ignite/cache/cache.h \
+                         ignite/cache/cache_entry.h \
+                         ignite/cache/cache_peek_mode.h \
+                         ignite/cache/query/query_argument.h \
+                         ignite/cache/query/query_cursor.h \
+                         ignite/cache/query/query_scan.h \
+                         ignite/cache/query/query_sql.h \
+                         ignite/cache/query/query_text.h \
+                         ignite/cache/query/query.h \
+                         ignite/impl/cache/cache_impl.h \
+                         ignite/impl/cache/query/query_impl.h \
+                         ignite/impl/interop/interop.h \
+                         ignite/impl/interop/interop_input_stream.h \
+                         ignite/impl/interop/interop_memory.h \
+                         ignite/impl/interop/interop_output_stream.h \
+                         ignite/impl/portable/portable_metadata_handler.h \
+                         ignite/impl/portable/portable_metadata_manager.h \
+                         ignite/impl/portable/portable_metadata_snapshot.h \
+                         ignite/impl/portable/portable_metadata_updater.h \
+                         ignite/impl/portable/portable_metadata_updater_impl.h \
+                         ignite/impl/portable/portable_common.h \
+                         ignite/impl/portable/portable_id_resolver.h \
+                         ignite/impl/portable/portable_reader_impl.h \
+                         ignite/impl/portable/portable_utils.h \
+                         ignite/impl/portable/portable_writer_impl.h \
+                         ignite/impl/ignite_environment.h \
+                         ignite/impl/ignite_impl.h \
+                         ignite/impl/handle_registry.h \
+                         ignite/impl/operations.h \
+                         ignite/portable/portable.h \
+                         ignite/portable/portable_consts.h \
+                         ignite/portable/portable_containers.h \
+                         ignite/portable/portable_type.h \
+                         ignite/portable/portable_raw_reader.h \
+                         ignite/portable/portable_raw_writer.h \
+                         ignite/portable/portable_reader.h \
+                         ignite/portable/portable_writer.h \
+                         ignite/ignite.h \
+                         ignite/ignite_configuration.h \
+                         ignite/ignite_error.h \
+                         ignite/ignition.h \
+                         ignite/guid.h

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/cache.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/cache.h b/modules/platform/src/main/cpp/core/include/ignite/cache/cache.h
new file mode 100644
index 0000000..dcc837b
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/cache/cache.h
@@ -0,0 +1,1153 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE
+#define _IGNITE_CACHE
+
+#include <map>
+#include <set>
+
+#include <ignite/common/common.h>
+#include <ignite/common/concurrent.h>
+
+#include "ignite/cache/cache_peek_mode.h"
+#include "ignite/cache/query/query_cursor.h"
+#include "ignite/cache/query/query_scan.h"
+#include "ignite/cache/query/query_sql.h"
+#include "ignite/cache/query/query_text.h"
+#include "ignite/impl/cache/cache_impl.h"
+#include "ignite/impl/operations.h"
+#include "ignite/ignite_error.h"
+
+namespace ignite
+{
+    namespace cache
+    {
+        /**
+         * Main entry point for all Data Grid APIs.
+         */
+        template<typename K, typename V>
+        class IGNITE_IMPORT_EXPORT Cache
+        {
+        public:
+            /**
+             * Constructor.
+             */
+            Cache(impl::cache::CacheImpl* impl) : impl(ignite::common::concurrent::SharedPointer<impl::cache::CacheImpl>(impl))
+            {
+                // No-op.
+            }
+
+            /**
+             * Name of this cache (null for default cache).
+             */
+            char* GetName()
+            {
+                return impl.Get()->GetName();
+            }
+
+            /**
+             * Checks whether this cache contains no key-value mappings.
+             * Semantically equals to Cache.Size(IGNITE_PEEK_MODE_PRIMARY) == 0.
+             *
+             * @return True if cache is empty.
+             */
+            bool IsEmpty()
+            {
+                IgniteError err;
+
+                bool res = IsEmpty(err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Checks whether this cache contains no key-value mappings.
+             * Semantically equals to Cache.Size(IGNITE_PEEK_MODE_PRIMARY) == 0.
+             *
+             * @param err Error.
+             * @return True if cache is empty.
+             */
+            bool IsEmpty(IgniteError& err)
+            {
+                return impl.Get()->IsEmpty(&err);
+            }
+
+            /**
+             * Check if cache contains mapping for this key.
+             *
+             * @param key Key.
+             * @return True if cache contains mapping for this key.
+             */
+            bool ContainsKey(const K& key)
+            {
+                IgniteError err;
+
+                bool res = ContainsKey(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Check if cache contains mapping for this key.
+             *
+             * @param key Key.
+             * @param err Error.
+             * @return True if cache contains mapping for this key.
+             */
+            bool ContainsKey(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> op(&key);
+
+                return impl.Get()->ContainsKey(op, &err);
+            }
+
+            /**
+             * Check if cache contains mapping for these keys.
+             *
+             * @param keys Keys.
+             * @return True if cache contains mapping for all these keys.
+             */
+            bool ContainsKeys(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                bool res = ContainsKeys(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Check if cache contains mapping for these keys.
+             *
+             * @param keys Keys.
+             * @param err Error.
+             * @return True if cache contains mapping for all these keys.
+             */
+            bool ContainsKeys(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> op(&keys);
+
+                return impl.Get()->ContainsKeys(op, &err);
+            }
+
+            /**
+             * Peeks at cached value using optional set of peek modes. This method will sequentially
+             * iterate over given peek modes, and try to peek at value using each peek mode. Once a
+             * non-null value is found, it will be immediately returned.
+             * This method does not participate in any transactions, however, it may peek at transactional
+             * value depending on the peek modes used.
+             *
+             * @param key Key.
+             * @param peekModes Peek modes.
+             * @return Value.
+             */
+            V LocalPeek(const K& key, int32_t peekModes)
+            {
+                IgniteError err;
+
+                V res = LocalPeek(key, peekModes, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Peeks at cached value using optional set of peek modes. This method will sequentially
+             * iterate over given peek modes, and try to peek at value using each peek mode. Once a
+             * non-null value is found, it will be immediately returned.
+             * This method does not participate in any transactions, however, it may peek at transactional
+             * value depending on the peek modes used.
+             *
+             * @param key Key.
+             * @param peekModes Peek modes.
+             * @param err Error.
+             * @return Value.
+             */
+            V LocalPeek(const K& key, int32_t peekModes, IgniteError& err)
+            {
+                impl::InCacheLocalPeekOperation<K> inOp(&key, peekModes);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->LocalPeek(inOp, outOp, peekModes, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Retrieves value mapped to the specified key from cache.
+             * If the value is not present in cache, then it will be looked up from swap storage. If
+             * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+             * will be loaded from persistent store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key.
+             * @return Value.
+             */
+            V Get(const K& key)
+            {
+                IgniteError err;
+
+                V res = Get(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Retrieves value mapped to the specified key from cache.
+             * If the value is not present in cache, then it will be looked up from swap storage. If
+             * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+             * will be loaded from persistent store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key.
+             * @param err Error.
+             * @return Value.
+             */
+            V Get(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> inOp(&key);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->Get(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Retrieves values mapped to the specified keys from cache.
+             * If some value is not present in cache, then it will be looked up from swap storage. If
+             * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+             * will be loaded from persistent store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param keys Keys.
+             * @return Map of key-value pairs.
+             */
+            std::map<K, V> GetAll(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                std::map<K, V> res = GetAll(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Retrieves values mapped to the specified keys from cache.
+             * If some value is not present in cache, then it will be looked up from swap storage. If
+             * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+             * will be loaded from persistent store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param keys Keys.
+             * @param err Error.
+             * @return Map of key-value pairs.
+             */
+            std::map<K, V> GetAll(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> inOp(&keys);
+                impl::OutMapOperation<K, V> outOp;
+
+                impl.Get()->GetAll(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Associates the specified value with the specified key in the cache.
+             * If the cache previously contained a mapping for the key,
+             * the old value is replaced by the specified value.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             */
+            void Put(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                Put(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Associates the specified value with the specified key in the cache.
+             * If the cache previously contained a mapping for the key,
+             * the old value is replaced by the specified value.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @param err Error.
+             */
+            void Put(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> op(&key, &val);
+
+                impl.Get()->Put(op, &err);
+            }
+
+            /**
+             * Stores given key-value pairs in cache.
+             * If write-through is enabled, the stored values will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param vals Key-value pairs to store in cache.
+             */
+            void PutAll(const std::map<K, V>& vals)
+            {
+                IgniteError err;
+
+                PutAll(vals, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Stores given key-value pairs in cache.
+             * If write-through is enabled, the stored values will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param vals Key-value pairs to store in cache.
+             * @param err Error.
+             */
+            void PutAll(const std::map<K, V>& vals, IgniteError& err)
+            {
+                impl::InMapOperation<K, V> op(&vals);
+
+                impl.Get()->PutAll(op, &err);
+            }
+
+            /**
+             * Associates the specified value with the specified key in this cache,
+             * returning an existing value if one existed.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @return The value associated with the key at the start of the
+             *     operation or null if none was associated.
+             */
+            V GetAndPut(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                V res = GetAndPut(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Associates the specified value with the specified key in this cache,
+             * returning an existing value if one existed.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @param err Error.
+             * @return The value associated with the key at the start of the
+             *     operation or null if none was associated.
+             */
+            V GetAndPut(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> inOp(&key, &val);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->GetAndPut(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Atomically replaces the value for a given key if and only if there is
+             * a value currently mapped by the key.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @return The previous value associated with the specified key, or
+             *     null if there was no mapping for the key.
+             */
+            V GetAndReplace(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                V res = GetAndReplace(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Atomically replaces the value for a given key if and only if there is
+             * a value currently mapped by the key.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @param err Error.
+             * @return The previous value associated with the specified key, or
+             *     null if there was no mapping for the key.
+             */
+            V GetAndReplace(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> inOp(&key, &val);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->GetAndReplace(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Atomically removes the entry for a key only if currently mapped to some value.
+             *
+             * @param key Key with which the specified value is associated.
+             * @return The value if one existed or null if no mapping existed for this key.
+             */
+            V GetAndRemove(const K& key)
+            {
+                IgniteError err;
+
+                V res = GetAndRemove(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Atomically removes the entry for a key only if currently mapped to some value.
+             *
+             * @param key Key with which the specified value is associated.
+             * @param err Error.
+             * @return The value if one existed or null if no mapping existed for this key.
+             */
+            V GetAndRemove(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> inOp(&key);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->GetAndRemove(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Atomically associates the specified key with the given value if it is not
+             * already associated with a value.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @return True if a value was set.
+             */
+            bool PutIfAbsent(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                bool res = PutIfAbsent(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Atomically associates the specified key with the given value if it is not
+             * already associated with a value.
+             *
+             * @param key Key with which the specified value is to be associated.
+             * @param val Value to be associated with the specified key.
+             * @param err Error.
+             * @return True if a value was set.
+             */
+            bool PutIfAbsent(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> op(&key, &val);
+
+                return impl.Get()->PutIfAbsent(op, &err);
+            }
+
+            /**
+             * Stores given key-value pair in cache only if cache had no previous mapping for it.
+             * If cache previously contained value for the given key, then this value is returned.
+             * In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+             * which in its turn may load the value from the swap storage, and consecutively, if it's not
+             * in swap, from the underlying persistent storage.
+             * If the returned value is not needed, method putxIfAbsent() should be used instead of this one to
+             * avoid the overhead associated with returning of the previous value.
+             * If write-through is enabled, the stored value will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param val Value to be associated with the given key.
+             * @return Previously contained value regardless of whether put happened or not
+             *     (null if there was no previous value).
+             */
+            V GetAndPutIfAbsent(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                V res = GetAndPutIfAbsent(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Stores given key-value pair in cache only if cache had no previous mapping for it.
+             * If cache previously contained value for the given key, then this value is returned.
+             * In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+             * which in its turn may load the value from the swap storage, and consecutively, if it's not
+             * in swap, from the underlying persistent storage.
+             * If the returned value is not needed, method putxIfAbsent() should be used instead of this one to
+             * avoid the overhead associated with returning of the previous value.
+             * If write-through is enabled, the stored value will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param val Value to be associated with the given key.
+             * @param err Error.
+             * @return Previously contained value regardless of whether put happened or not
+             *     (null if there was no previous value).
+             */
+            V GetAndPutIfAbsent(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> inOp(&key, &val);
+                impl::Out1Operation<V> outOp;
+
+                impl.Get()->GetAndPutIfAbsent(inOp, outOp, &err);
+
+                return outOp.GetResult();
+            }
+
+            /**
+             * Stores given key-value pair in cache only if there is a previous mapping for it.
+             * If cache previously contained value for the given key, then this value is returned.
+             * In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+             * which in its turn may load the value from the swap storage, and consecutively, if it's not
+             * in swap, rom the underlying persistent storage.
+             * If write-through is enabled, the stored value will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param val Value to be associated with the given key.
+             * @return True if the value was replaced.
+             */
+            bool Replace(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                bool res = Replace(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Stores given key-value pair in cache only if there is a previous mapping for it.
+             * If cache previously contained value for the given key, then this value is returned.
+             * In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+             * which in its turn may load the value from the swap storage, and consecutively, if it's not
+             * in swap, rom the underlying persistent storage.
+             * If write-through is enabled, the stored value will be persisted to store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param val Value to be associated with the given key.
+             * @param err Error.
+             * @return True if the value was replaced.
+             */
+            bool Replace(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> op(&key, &val);
+
+                return impl.Get()->Replace(op, &err);
+            }
+
+            /**
+             * Stores given key-value pair in cache only if only if the previous value is equal to the
+             * old value passed as argument.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param oldVal Old value to match.
+             * @param newVal Value to be associated with the given key.
+             * @return True if replace happened, false otherwise.
+             */
+            bool Replace(const K& key, const V& oldVal, const V& newVal)
+            {
+                IgniteError err;
+
+                bool res = Replace(key, oldVal, newVal, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Stores given key-value pair in cache only if only if the previous value is equal to the
+             * old value passed as argument.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key to store in cache.
+             * @param oldVal Old value to match.
+             * @param newVal Value to be associated with the given key.
+             * @param err Error.
+             * @return True if replace happened, false otherwise.
+             */
+            bool Replace(const K& key, const V& oldVal, const V& newVal, IgniteError& err)
+            {
+                impl::In3Operation<K, V, V> op(&key, &oldVal, &newVal);
+
+                return impl.Get()->ReplaceIfEqual(op, &err);
+            }
+
+            /**
+             * Attempts to evict all entries associated with keys. Note, that entry will be evicted only
+             * if it's not used (not participating in any locks or transactions).
+             *
+             * @param keys Keys to evict from cache.
+             */
+            void LocalEvict(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                LocalEvict(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Attempts to evict all entries associated with keys. Note, that entry will be evicted only
+             * if it's not used (not participating in any locks or transactions).
+             *
+             * @param keys Keys to evict from cache.
+             * @param err Error.
+             */
+            void LocalEvict(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> op(&keys);
+
+                impl.Get()->LocalEvict(op, &err);
+            }
+
+            /**
+             * Clear cache.
+             */
+            void Clear()
+            {
+                IgniteError err;
+
+                Clear(err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Clear cache.
+             *
+             * @param err Error.
+             */
+            void Clear(IgniteError& err)
+            {
+                impl.Get()->Clear(&err);
+            }
+
+            /**
+             * Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             *
+             * @param key Key to clear.
+             */
+            void Clear(const K& key)
+            {
+                IgniteError err;
+
+                Clear(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             *
+             * @param key Key to clear.
+             * @param err Error.
+             */
+            void Clear(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> op(&key);
+
+                impl.Get()->Clear(op, &err);
+            }
+
+            /**
+             * Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             *
+             * @param keys Keys to clear.
+             */
+            void ClearAll(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                ClearAll(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             *
+             * @param keys Keys to clear.
+             * @param err Error.
+             */
+            void ClearAll(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> op(&keys);
+
+                impl.Get()->ClearAll(op, &err);
+            }
+
+            /**
+             * Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             * Note that this operation is local as it merely clears an entry from local cache, it does not
+             * remove entries from remote caches.
+             *
+             * @param key Key to clear.
+             */
+            void LocalClear(const K& key)
+            {
+                IgniteError err;
+
+                LocalClear(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             * Note that this operation is local as it merely clears an entry from local cache, it does not
+             * remove entries from remote caches.
+             *
+             * @param key Key to clear.
+             * @param err Error.
+             */
+            void LocalClear(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> op(&key);
+
+                impl.Get()->LocalClear(op, &err);
+            }
+
+            /**
+             * Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             * Note that this operation is local as it merely clears entries from local cache, it does not
+             * remove entries from remote caches.
+             *
+             * @param keys Keys to clear.
+             */
+            void LocalClearAll(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                LocalClearAll(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+             * Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+             * Note that this operation is local as it merely clears entries from local cache, it does not
+             * remove entries from remote caches.
+             *
+             * @param keys Keys to clear.
+             * @param err Error.
+             */
+            void LocalClearAll(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> op(&keys);
+
+                impl.Get()->LocalClearAll(op, &err);
+            }
+
+            /**
+             * Removes given key mapping from cache. If cache previously contained value for the given key,
+             * then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be
+             * loaded from the primary node, which in its turn may load the value from the disk-based swap
+             * storage, and consecutively, if it's not in swap, from the underlying persistent storage.
+             * If the returned value is not needed, method removex() should always be used instead of this
+             * one to avoid the overhead associated with returning of the previous value.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key whose mapping is to be removed from cache.
+             * @return False if there was no matching key.
+             */
+            bool Remove(const K& key)
+            {
+                IgniteError err;
+
+                bool res = Remove(key, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Removes given key mapping from cache. If cache previously contained value for the given key,
+             * then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be
+             * loaded from the primary node, which in its turn may load the value from the disk-based swap
+             * storage, and consecutively, if it's not in swap, from the underlying persistent storage.
+             * If the returned value is not needed, method removex() should always be used instead of this
+             * one to avoid the overhead associated with returning of the previous value.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key whose mapping is to be removed from cache.
+             * @param err Error.
+             * @return False if there was no matching key.
+             */
+            bool Remove(const K& key, IgniteError& err)
+            {
+                impl::In1Operation<K> op(&key);
+
+                return impl.Get()->Remove(op, &err);
+            }
+
+            /**
+             * Removes given key mapping from cache if one exists and value is equal to the passed in value.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key whose mapping is to be removed from cache.
+             * @param val Value to match against currently cached value.
+             * @return True if entry was removed, false otherwise.
+             */
+            bool Remove(const K& key, const V& val)
+            {
+                IgniteError err;
+
+                bool res = Remove(key, val, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Removes given key mapping from cache if one exists and value is equal to the passed in value.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param key Key whose mapping is to be removed from cache.
+             * @param val Value to match against currently cached value.
+             * @param err Error.
+             * @return True if entry was removed, false otherwise.
+             */
+            bool Remove(const K& key, const V& val, IgniteError& err)
+            {
+                impl::In2Operation<K, V> op(&key, &val);
+
+                return impl.Get()->RemoveIfEqual(op, &err);
+            }
+
+            /**
+             * Removes given key mappings from cache.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param keys Keys whose mappings are to be removed from cache.
+             */
+            void RemoveAll(const std::set<K>& keys)
+            {
+                IgniteError err;
+
+                RemoveAll(keys, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Removes given key mappings from cache.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param keys Keys whose mappings are to be removed from cache.
+             * @param err Error.
+             */
+            void RemoveAll(const std::set<K>& keys, IgniteError& err)
+            {
+                impl::InSetOperation<K> op(&keys);
+
+                impl.Get()->RemoveAll(op, &err);
+            }
+
+            /**
+             * Removes all mappings from cache.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param err Error.
+             */
+            void RemoveAll()
+            {
+                IgniteError err;
+
+                RemoveAll(err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
+            /**
+             * Removes all mappings from cache.
+             * If write-through is enabled, the value will be removed from store.
+             * This method is transactional and will enlist the entry into ongoing transaction if there is one.
+             *
+             * @param err Error.
+             */
+            void RemoveAll(IgniteError& err)
+            {
+                return impl.Get()->RemoveAll(&err);
+            }
+
+            /**
+             * Gets the number of all entries cached on this node.
+             *
+             * @return Cache size on this node.
+             */
+            int32_t LocalSize()
+            {
+                return LocalSize(IGNITE_PEEK_MODE_ALL);
+            }
+
+            /**
+             * Gets the number of all entries cached on this node.
+             *
+             * @param err Error.
+             * @return Cache size on this node.
+             */
+            int32_t LocalSize(IgniteError& err)
+            {
+                return LocalSize(IGNITE_PEEK_MODE_ALL, err);
+            }
+
+            /**
+             * Gets the number of all entries cached on this node.
+             *
+             * @param Peek modes.
+             * @return Cache size on this node.
+             */
+            int32_t LocalSize(int32_t peekModes)
+            {
+                IgniteError err;
+
+                int32_t res = LocalSize(peekModes, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Gets the number of all entries cached on this node.
+             *
+             * @param Peek modes.
+             * @param err Error.
+             * @return Cache size on this node.
+             */
+            int32_t LocalSize(int32_t peekModes, IgniteError& err)
+            {
+                return impl.Get()->LocalSize(peekModes, &err);
+            }
+
+            /**
+             * Gets the number of all entries cached across all nodes.
+             * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+             *
+             * @return Cache size across all nodes.
+             */
+            int32_t Size()
+            {
+                return Size(ignite::cache::IGNITE_PEEK_MODE_ALL);
+            }
+
+            /**
+             * Gets the number of all entries cached across all nodes.
+             * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+             *
+             * @param err Error.
+             * @return Cache size across all nodes.
+             */
+            int32_t Size(IgniteError& err)
+            {
+                return Size(ignite::cache::IGNITE_PEEK_MODE_ALL, err);
+            }
+
+            /**
+             * Gets the number of all entries cached across all nodes.
+             * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+             *
+             * @param Peek modes.
+             * @return Cache size across all nodes.
+             */
+            int32_t Size(int32_t peekModes)
+            {
+                IgniteError err;
+
+                int32_t res = Size(peekModes, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Gets the number of all entries cached across all nodes.
+             * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+             *
+             * @param Peek modes.
+             * @param err Error.
+             * @return Cache size across all nodes.
+             */
+            int32_t Size(int32_t peekModes, IgniteError& err)
+            {
+                return impl.Get()->Size(peekModes, &err);
+            }
+
+            /**
+             * Perform SQL query.
+             *
+             * @param qry Query.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::SqlQuery& qry)
+            {
+                IgniteError err;
+
+                query::QueryCursor<K, V> res = Query(qry, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /**
+             * Perform SQL query.
+             *
+             * @param qry Query.
+             * @param err Error.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::SqlQuery& qry, IgniteError& err)
+            {
+                impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QuerySql(qry, &err);
+
+                return query::QueryCursor<K, V>(cursorImpl);
+            }
+
+            /*
+             * Perform text query.
+             *
+             * @param qry Query.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::TextQuery& qry)
+            {
+                IgniteError err;
+
+                query::QueryCursor<K, V> res = Query(qry, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /*
+             * Perform text query.
+             *
+             * @param qry Query.
+             * @param err Error.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::TextQuery& qry, IgniteError& err)
+            {
+                impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QueryText(qry, &err);
+
+                return query::QueryCursor<K, V>(cursorImpl);
+            }
+
+            /*
+             * Perform scan query.
+             *
+             * @param qry Query.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::ScanQuery& qry)
+            {
+                IgniteError err;
+
+                query::QueryCursor<K, V> res = Query(qry, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res;
+            }
+
+            /*
+             * Perform scan query.
+             *
+             * @param qry Query.
+             * @param err Error.
+             * @return Query cursor.
+             */
+            query::QueryCursor<K, V> Query(const query::ScanQuery& qry, IgniteError& err)
+            {
+                impl::cache::query::QueryCursorImpl* cursorImpl = impl.Get()->QueryScan(qry, &err);
+
+                return query::QueryCursor<K, V>(cursorImpl);
+            }
+
+        private:
+            /** Implementation delegate. */
+            ignite::common::concurrent::SharedPointer<impl::cache::CacheImpl> impl;
+        };
+    }
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/cache_entry.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/cache_entry.h b/modules/platform/src/main/cpp/core/include/ignite/cache/cache_entry.h
new file mode 100644
index 0000000..2b6c785
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/cache/cache_entry.h
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_ENTRY
+#define _IGNITE_CACHE_ENTRY
+
+#include <ignite/common/common.h>
+
+namespace ignite
+{
+    namespace cache
+    {
+        /**
+         * Cache entry.
+         */
+        template<typename K, typename V>
+        class IGNITE_IMPORT_EXPORT CacheEntry
+        {
+        public:
+            /**
+             * Default constructor.
+             */
+            CacheEntry() : key(K()), val(V())
+            {
+                // No-op.
+            }
+
+            /**
+             * Constructor.
+             *
+             * @param key Key.
+             * @param val Value.
+             */
+            CacheEntry(const K& key, const V& val) : key(key), val(val)
+            {
+                // No-op.
+            }
+
+            /**
+             * Copy constructor.
+             *
+             * @param other Other instance.
+             */
+            CacheEntry(const CacheEntry& other)
+            {
+                key = other.key;
+                val = other.val;
+            }
+
+            /**
+             * Assignment operator.
+             *
+             * @param other Other instance.
+             */
+            CacheEntry& operator=(const CacheEntry& other) 
+            {
+                if (this != &other)
+                {
+                    CacheEntry tmp(other);
+
+                    K& key0 = key;
+                    V& val0 = val;
+
+                    key = tmp.key;
+                    val = tmp.val;
+
+                    tmp.key = key0;
+                    tmp.val = val0;
+                }
+
+                return *this;
+            }
+
+            /**
+             * Get key.
+             * 
+             * @return Key.
+             */
+            K GetKey()
+            {
+                return key;
+            }
+
+            /**
+             * Get value.
+             *
+             * @return Value.
+             */
+            V GetValue()
+            {
+                return val;
+            }
+
+        private:
+            /** Key. */
+            K key; 
+
+            /** Value. */
+            V val; 
+        };
+    }
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/cache_peek_mode.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/cache_peek_mode.h b/modules/platform/src/main/cpp/core/include/ignite/cache/cache_peek_mode.h
new file mode 100644
index 0000000..be61887
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/cache/cache_peek_mode.h
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_PEEK_MODE
+#define _IGNITE_CACHE_PEEK_MODE
+
+namespace ignite
+{
+    namespace cache
+    {
+        /**
+         * Enumeration of all supported cache peek modes.
+         */
+        enum CachePeekMode
+        {
+            /**
+             * Peeks into all available cache storages.
+             */
+            IGNITE_PEEK_MODE_ALL = 0x01,
+
+            /**
+             * Peek into near cache only (don't peek into partitioned cache).
+             * In case of LOCAL cache, behaves as IGNITE_PEEK_MODE_ALL mode.
+             */
+            IGNITE_PEEK_MODE_NEAR = 0x02,
+
+            /**
+             * Peek value from primary copy of partitioned cache only (skip near cache).
+             * In case of LOCAL cache, behaves as IGNITE_PEEK_MODE_ALL mode.
+             */
+            IGNITE_PEEK_MODE_PRIMARY = 0x04,
+
+            /**
+             * Peek value from backup copies of partitioned cache only (skip near cache).
+             * In case of LOCAL cache, behaves as IGNITE_PEEK_MODE_ALL mode.
+             */
+            IGNITE_PEEK_MODE_BACKUP = 0x08,
+
+            /**
+             * Peeks value from the on-heap storage only.
+             */
+            IGNITE_PEEK_MODE_ONHEAP = 0x10,
+
+            /**
+             * Peeks value from the off-heap storage only, without loading off-heap value into cache.
+             */
+            IGNITE_PEEK_MODE_OFFHEAP = 0x20,
+
+            /**
+             * Peeks value from the swap storage only, without loading swapped value into cache.
+             */
+            IGNITE_PEEK_MODE_SWAP = 0x40
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/query/query.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/query/query.h b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query.h
new file mode 100644
index 0000000..f2d19cd
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query.h
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_QUERY
+#define _IGNITE_QUERY
+
+#include "ignite/cache/query/query_argument.h"
+#include "ignite/cache/query/query_cursor.h"
+#include "ignite/cache/query/query_scan.h"
+#include "ignite/cache/query/query_sql.h"
+#include "ignite/cache/query/query_text.h"
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_argument.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_argument.h b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_argument.h
new file mode 100644
index 0000000..0f41c56
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_argument.h
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_ARGUMENT
+#define _IGNITE_CACHE_QUERY_ARGUMENT
+
+#include "ignite/portable/portable_raw_writer.h"
+
+namespace ignite
+{    
+    namespace cache
+    {
+        namespace query
+        {            
+            /**
+             * Base class for all query arguments.
+             */
+            class QueryArgumentBase
+            {
+            public:
+                /**
+                 * Destructor.
+                 */
+                virtual ~QueryArgumentBase()
+                {
+                    // No-op.
+                }
+
+                /**
+                 * Copy argument. 
+                 *
+                 * @return Copy.
+                 */
+                virtual QueryArgumentBase* Copy() = 0;
+
+                /**
+                 * Write argument.
+                 */
+                virtual void Write(ignite::portable::PortableRawWriter& writer) = 0;
+            };
+
+            /**
+             * Query argument.
+             */
+            template<typename T>
+            class QueryArgument : public QueryArgumentBase
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param val Value.
+                 */
+                QueryArgument(const T& val) : val(val)
+                {
+                    // No-op.
+                }
+
+                /**
+                 * Copy constructor.
+                 *
+                 * @param other Other instance.
+                 */
+                QueryArgument(const QueryArgument& other)
+                {
+                    val = other.val;
+                }
+
+                /**
+                 * Assignment operator.
+                 *
+                 * @param other Other instance.
+                 */
+                QueryArgument& operator=(const QueryArgument& other) 
+                {
+                    if (this != &other)
+                    {
+                        QueryArgument tmp(other);
+
+                        T val0 = val;
+                        val = tmp.val;
+                        tmp.val = val0;
+                    }
+
+                    return *this;
+                }
+
+                ~QueryArgument()
+                {
+                    // No-op.
+                }
+
+                QueryArgumentBase* Copy()
+                {
+                    return new QueryArgument(val);
+                }
+
+                void Write(ignite::portable::PortableRawWriter& writer)
+                {
+                    writer.WriteObject<T>(val);
+                }
+
+            private:
+                /** Value. */
+                T val; 
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file


[37/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/impl/portable/portable_writer_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/impl/portable/portable_writer_impl.cpp b/modules/platform/src/main/cpp/core/src/impl/portable/portable_writer_impl.cpp
new file mode 100644
index 0000000..93aacd9
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/impl/portable/portable_writer_impl.cpp
@@ -0,0 +1,600 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/portable/portable_writer_impl.h"
+#include "ignite/ignite_error.h"
+
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+using namespace ignite::portable;
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace portable
+        {
+            PortableWriterImpl::PortableWriterImpl(InteropOutputStream* stream, PortableIdResolver* idRslvr, 
+                PortableMetadataManager* metaMgr, PortableMetadataHandler* metaHnd) :
+                stream(stream), idRslvr(idRslvr), metaMgr(metaMgr), metaHnd(metaHnd), typeId(idRslvr->GetTypeId()),
+                elemIdGen(0), elemId(0), elemCnt(0), elemPos(-1), rawPos(-1)
+            {
+                // No-op.
+            }
+            
+            PortableWriterImpl::PortableWriterImpl(InteropOutputStream* stream, PortableMetadataManager* metaMgr) :
+                stream(stream), idRslvr(NULL), metaMgr(metaMgr), metaHnd(NULL), typeId(0), 
+                elemIdGen(0), elemId(0), elemCnt(0), elemPos(-1), rawPos(0)
+            {
+                // No-op.
+            }
+
+            void PortableWriterImpl::WriteInt8(const int8_t val)
+            {
+                WritePrimitiveRaw<int8_t>(val, PortableUtils::WriteInt8);
+            }
+
+            void PortableWriterImpl::WriteInt8Array(const int8_t* val, const int32_t len)
+            {
+                WritePrimitiveArrayRaw<int8_t>(val, len, PortableUtils::WriteInt8Array, IGNITE_TYPE_ARRAY_BYTE);
+            }
+
+            void PortableWriterImpl::WriteInt8(const char* fieldName, const int8_t val)
+            {
+                WritePrimitive<int8_t>(fieldName, val, PortableUtils::WriteInt8, IGNITE_TYPE_BYTE, 1);
+            }
+
+            void PortableWriterImpl::WriteInt8Array(const char* fieldName, const int8_t* val, const int32_t len)
+            {
+                WritePrimitiveArray<int8_t>(fieldName, val, len, PortableUtils::WriteInt8Array, IGNITE_TYPE_ARRAY_BYTE, 0);
+            }
+
+            void PortableWriterImpl::WriteBool(const bool val)
+            {
+                WritePrimitiveRaw<bool>(val, PortableUtils::WriteBool);
+            }
+
+            void PortableWriterImpl::WriteBoolArray(const bool* val, const int32_t len)
+            {
+                WritePrimitiveArrayRaw<bool>(val, len, PortableUtils::WriteBoolArray, IGNITE_TYPE_ARRAY_BOOL);
+            }
+
+            void PortableWriterImpl::WriteBool(const char* fieldName, const bool val)
+            {
+                WritePrimitive<bool>(fieldName, val, PortableUtils::WriteBool, IGNITE_TYPE_BOOL, 1);
+            }
+
+            void PortableWriterImpl::WriteBoolArray(const char* fieldName, const bool* val, const int32_t len)
+            {
+                WritePrimitiveArray<bool>(fieldName, val, len, PortableUtils::WriteBoolArray, IGNITE_TYPE_ARRAY_BOOL, 0);
+            }
+
+            void PortableWriterImpl::WriteInt16(const int16_t val)
+            {
+                WritePrimitiveRaw<int16_t>(val, PortableUtils::WriteInt16);
+            }
+
+            void PortableWriterImpl::WriteInt16Array(const int16_t* val, const int32_t len)
+            {
+                WritePrimitiveArrayRaw<int16_t>(val, len, PortableUtils::WriteInt16Array, IGNITE_TYPE_ARRAY_SHORT);
+            }
+
+            void PortableWriterImpl::WriteInt16(const char* fieldName, const int16_t val)
+            {
+                WritePrimitive<int16_t>(fieldName, val, PortableUtils::WriteInt16, IGNITE_TYPE_SHORT, 2);
+            }
+
+            void PortableWriterImpl::WriteInt16Array(const char* fieldName, const int16_t* val, const int32_t len)
+            {
+                WritePrimitiveArray<int16_t>(fieldName, val, len, PortableUtils::WriteInt16Array, IGNITE_TYPE_ARRAY_SHORT, 1);
+            }
+
+            void PortableWriterImpl::WriteUInt16(const uint16_t val)
+            {
+                WritePrimitiveRaw<uint16_t>(val, PortableUtils::WriteUInt16);
+            }
+
+            void PortableWriterImpl::WriteUInt16Array(const uint16_t* val, const int32_t len)
+            {
+                WritePrimitiveArrayRaw<uint16_t>(val, len, PortableUtils::WriteUInt16Array, IGNITE_TYPE_ARRAY_CHAR);
+            }
+
+            void PortableWriterImpl::WriteUInt16(const char* fieldName, const uint16_t val)
+            {
+                WritePrimitive<uint16_t>(fieldName, val, PortableUtils::WriteUInt16, IGNITE_TYPE_CHAR, 2);
+            }
+
+            void PortableWriterImpl::WriteUInt16Array(const char* fieldName, const uint16_t* val, const int32_t len)
+            {
+                WritePrimitiveArray<uint16_t>(fieldName, val, len, PortableUtils::WriteUInt16Array, IGNITE_TYPE_ARRAY_CHAR, 1);
+            }
+
+            void PortableWriterImpl::WriteInt32(const int32_t val)
+            {
+                WritePrimitiveRaw<int32_t>(val, PortableUtils::WriteInt32);
+            }
+
+            void PortableWriterImpl::WriteInt32Array(const int32_t* val, const int32_t len)
+            {
+                WritePrimitiveArrayRaw<int32_t>(val, len, PortableUtils::WriteInt32Array, IGNITE_TYPE_ARRAY_INT);
+            }
+
+            void PortableWriterImpl::WriteInt32(const char* fieldName, const int32_t val)
+            {
+                WritePrimitive<int32_t>(fieldName, val, PortableUtils::WriteInt32, IGNITE_TYPE_INT, 4);
+            }
+
+            void PortableWriterImpl::WriteInt32Array(const char* fieldName, const int32_t* val, const int32_t len)
+            {
+                WritePrimitiveArray<int32_t>(fieldName, val, len, PortableUtils::WriteInt32Array, IGNITE_TYPE_ARRAY_INT, 2);
+            }
+
+            void PortableWriterImpl::WriteInt64(const int64_t val)
+            {
+                WritePrimitiveRaw<int64_t>(val, PortableUtils::WriteInt64);
+            }
+
+            void PortableWriterImpl::WriteInt64Array(const int64_t* val, const int32_t len)
+            {
+                WritePrimitiveArrayRaw<int64_t>(val, len, PortableUtils::WriteInt64Array, IGNITE_TYPE_ARRAY_LONG);
+            }
+
+            void PortableWriterImpl::WriteInt64(const char* fieldName, const int64_t val)
+            {
+                WritePrimitive<int64_t>(fieldName, val, PortableUtils::WriteInt64, IGNITE_TYPE_LONG, 8);
+            }
+
+            void PortableWriterImpl::WriteInt64Array(const char* fieldName, const int64_t* val, const int32_t len)
+            {
+                WritePrimitiveArray<int64_t>(fieldName, val, len, PortableUtils::WriteInt64Array, IGNITE_TYPE_ARRAY_LONG, 3);
+            }
+
+            void PortableWriterImpl::WriteFloat(const float val)
+            {
+                WritePrimitiveRaw<float>(val, PortableUtils::WriteFloat);
+            }
+
+            void PortableWriterImpl::WriteFloatArray(const float* val, const int32_t len)
+            {
+                WritePrimitiveArrayRaw<float>(val, len, PortableUtils::WriteFloatArray, IGNITE_TYPE_ARRAY_FLOAT);
+            }
+
+            void PortableWriterImpl::WriteFloat(const char* fieldName, const float val)
+            {
+                WritePrimitive<float>(fieldName, val, PortableUtils::WriteFloat, IGNITE_TYPE_FLOAT, 4);
+            }
+
+            void PortableWriterImpl::WriteFloatArray(const char* fieldName, const float* val, const int32_t len)
+            {
+                WritePrimitiveArray<float>(fieldName, val, len, PortableUtils::WriteFloatArray, IGNITE_TYPE_ARRAY_FLOAT, 2);
+            }
+
+            void PortableWriterImpl::WriteDouble(const double val)
+            {
+                WritePrimitiveRaw<double>(val, PortableUtils::WriteDouble);
+            }
+
+            void PortableWriterImpl::WriteDoubleArray(const double* val, const int32_t len)
+            {
+                WritePrimitiveArrayRaw<double>(val, len, PortableUtils::WriteDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE);
+            }
+
+            void PortableWriterImpl::WriteDouble(const char* fieldName, const double val)
+            {
+                WritePrimitive<double>(fieldName, val, PortableUtils::WriteDouble, IGNITE_TYPE_DOUBLE, 8);
+            }
+
+            void PortableWriterImpl::WriteDoubleArray(const char* fieldName, const double* val, const int32_t len)
+            {
+                WritePrimitiveArray<double>(fieldName, val, len, PortableUtils::WriteDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE, 3);
+            }
+
+            void PortableWriterImpl::WriteGuid(const Guid val)
+            {                
+                CheckRawMode(true);
+                CheckSingleMode(true);
+
+                stream->WriteInt8(IGNITE_TYPE_UUID);
+
+                PortableUtils::WriteGuid(stream, val);
+            }
+
+            void PortableWriterImpl::WriteGuidArray(const Guid* val, const int32_t len)
+            {
+                CheckRawMode(true);
+                CheckSingleMode(true);
+                
+                if (val)
+                {
+                    stream->WriteInt8(IGNITE_TYPE_ARRAY_UUID);
+                    stream->WriteInt32(len);
+
+                    for (int i = 0; i < len; i++)
+                    {
+                        Guid elem = *(val + i);
+
+                        stream->WriteInt8(IGNITE_TYPE_UUID);
+                        PortableUtils::WriteGuid(stream, elem);
+                    }
+                }
+                else
+                    stream->WriteInt8(IGNITE_HDR_NULL);
+            }
+
+            void PortableWriterImpl::WriteGuid(const char* fieldName, const Guid val)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                WriteFieldIdAndLength(fieldName, IGNITE_TYPE_UUID, 1 + 16);
+
+                stream->WriteInt8(IGNITE_TYPE_UUID);
+
+                PortableUtils::WriteGuid(stream, val);
+            }
+
+            void PortableWriterImpl::WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                WriteFieldId(fieldName, IGNITE_TYPE_ARRAY_UUID);
+
+                if (val)
+                {
+                    stream->WriteInt32(5 + len * 17);
+                    stream->WriteInt8(IGNITE_TYPE_ARRAY_UUID);
+                    stream->WriteInt32(len);
+
+                    for (int i = 0; i < len; i++)
+                    {
+                        Guid elem = *(val + i);
+
+                        WriteTopObject(elem);
+                    }
+                }
+                else
+                {
+                    stream->WriteInt32(1);
+                    stream->WriteInt8(IGNITE_HDR_NULL);
+                }
+            }
+
+            void PortableWriterImpl::WriteString(const char* val, const int32_t len)
+            {
+                CheckRawMode(true);
+                CheckSingleMode(true);
+
+                if (val) 
+                {
+                    stream->WriteInt8(IGNITE_TYPE_STRING);
+
+                    PortableUtils::WriteString(stream, val, len);
+                }
+                else
+                    stream->WriteInt8(IGNITE_HDR_NULL);
+            }
+
+            void PortableWriterImpl::WriteString(const char* fieldName, const char* val, const int32_t len)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                WriteFieldId(fieldName, IGNITE_TYPE_STRING);
+                
+                if (val)
+                {
+                    int32_t lenPos = stream->Position();
+                    stream->Position(lenPos + 4);
+
+                    stream->WriteInt8(IGNITE_TYPE_STRING);
+                    stream->WriteBool(false);
+                    stream->WriteInt32(len);
+
+                    for (int i = 0; i < len; i++)
+                        stream->WriteUInt16(*(val + i));
+
+                    stream->WriteInt32(lenPos, stream->Position() - lenPos - 4);
+                }
+                else
+                {
+                    stream->WriteInt32(1);
+                    stream->WriteInt8(IGNITE_HDR_NULL);
+                }
+            }
+
+            int32_t PortableWriterImpl::WriteStringArray()
+            {
+                StartContainerSession(true);
+
+                stream->WriteInt8(IGNITE_TYPE_ARRAY_STRING);
+                stream->Position(stream->Position() + 4);
+
+                return elemId;
+            }
+
+            int32_t PortableWriterImpl::WriteStringArray(const char* fieldName)
+            {
+                StartContainerSession(false);
+
+                WriteFieldIdSkipLength(fieldName, IGNITE_TYPE_ARRAY_STRING);
+
+                stream->WriteInt8(IGNITE_TYPE_ARRAY_STRING);
+                stream->Position(stream->Position() + 4);
+
+                return elemId;
+            }
+
+            void PortableWriterImpl::WriteStringElement(int32_t id, const char* val, int32_t len)
+            {
+                CheckSession(id);
+
+                if (val)
+                {
+                    stream->WriteInt8(IGNITE_TYPE_STRING);
+
+                    PortableUtils::WriteString(stream, val, len);
+                }
+                else
+                    stream->WriteInt8(IGNITE_HDR_NULL);
+
+                elemCnt++;
+            }
+
+            void PortableWriterImpl::WriteNull()
+            {
+                CheckRawMode(true);
+                CheckSingleMode(true);
+
+                stream->WriteInt8(IGNITE_HDR_NULL);
+            }
+
+            void PortableWriterImpl::WriteNull(const char* fieldName)
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                WriteFieldIdAndLength(fieldName, IGNITE_TYPE_OBJECT, 1);
+                stream->WriteInt8(IGNITE_HDR_NULL);
+            }
+
+            int32_t PortableWriterImpl::WriteArray()
+            {
+                StartContainerSession(true);
+                
+                stream->WriteInt8(IGNITE_TYPE_ARRAY);
+                stream->Position(stream->Position() + 4);
+
+                return elemId;
+            }
+
+            int32_t PortableWriterImpl::WriteArray(const char* fieldName)
+            {
+                StartContainerSession(false);
+
+                WriteFieldIdSkipLength(fieldName, IGNITE_TYPE_ARRAY);
+
+                stream->WriteInt8(IGNITE_TYPE_ARRAY);
+                stream->Position(stream->Position() + 4);
+
+                return elemId;
+            }
+
+            int32_t PortableWriterImpl::WriteCollection(CollectionType typ)
+            {
+                StartContainerSession(true);
+
+                stream->WriteInt8(IGNITE_TYPE_COLLECTION);
+                stream->Position(stream->Position() + 4);
+                stream->WriteInt8(typ);
+
+                return elemId;
+            }
+
+            int32_t PortableWriterImpl::WriteCollection(const char* fieldName, CollectionType typ)
+            {
+                StartContainerSession(false);
+                
+                WriteFieldIdSkipLength(fieldName, IGNITE_TYPE_COLLECTION);
+
+                stream->WriteInt8(IGNITE_TYPE_COLLECTION);
+                stream->Position(stream->Position() + 4);
+                stream->WriteInt8(typ);
+
+                return elemId;
+            }
+
+            int32_t PortableWriterImpl::WriteMap(ignite::portable::MapType typ)
+            {
+                StartContainerSession(true);
+
+                stream->WriteInt8(IGNITE_TYPE_MAP);
+                stream->Position(stream->Position() + 4);
+                stream->WriteInt8(typ);
+
+                return elemId;
+            }
+
+            int32_t PortableWriterImpl::WriteMap(const char* fieldName, ignite::portable::MapType typ)
+            {
+                StartContainerSession(false);
+
+                WriteFieldIdSkipLength(fieldName, IGNITE_TYPE_MAP);
+                
+                stream->WriteInt8(IGNITE_TYPE_MAP);
+                stream->Position(stream->Position() + 4);
+                stream->WriteInt8(typ);
+
+                return elemId;
+            }
+
+            void PortableWriterImpl::CommitContainer(int32_t id)
+            {
+                CheckSession(id);
+
+                if (rawPos == -1)
+                {
+                    int32_t len = stream->Position() - elemPos - 4;
+
+                    stream->WriteInt32(elemPos + 4, len);
+                    stream->WriteInt32(elemPos + 9, elemCnt);
+                }
+                else
+                    stream->WriteInt32(elemPos + 1, elemCnt);
+
+                elemId = 0;
+                elemCnt = 0;
+                elemPos = -1;
+            }
+            
+            void PortableWriterImpl::SetRawMode()
+            {
+                CheckRawMode(false);
+                CheckSingleMode(true);
+
+                rawPos = stream->Position();
+            }
+
+            int32_t PortableWriterImpl::GetRawPosition()
+            {
+                return rawPos == -1 ? stream->Position() : rawPos;
+            }
+
+            void PortableWriterImpl::CheckRawMode(bool expected)
+            {
+                bool rawMode = rawPos != -1;
+
+                if (expected && !rawMode) {
+                    IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation can be performed only in raw mode.");
+                }
+                else if (!expected && rawMode) {
+                    IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation cannot be performed in raw mode.");
+                }
+            }
+
+            void PortableWriterImpl::CheckSingleMode(bool expected)
+            {
+                if (expected && elemId != 0) {
+                    IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation cannot be performed when container is being written.");
+                }
+                else if (!expected && elemId == 0) {
+                    IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation can be performed only when container is being written.");
+                }
+            }
+
+            void PortableWriterImpl::StartContainerSession(bool expRawMode)
+            {
+                CheckRawMode(expRawMode);
+                CheckSingleMode(true);
+
+                elemId = ++elemIdGen;
+                elemPos = stream->Position();
+            }
+
+            void PortableWriterImpl::CheckSession(int32_t expSes)
+            {
+                if (elemId != expSes) 
+                {
+                    IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Containter write session has been finished or is not started yet.");
+                }
+            }
+
+            void PortableWriterImpl::WriteFieldId(const char* fieldName, int32_t fieldTypeId)
+            {
+                int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+                
+                stream->WriteInt32(fieldId);
+
+                if (metaHnd)
+                    metaHnd->OnFieldWritten(fieldId, fieldName, fieldTypeId);
+            }
+
+            void PortableWriterImpl::WriteFieldIdSkipLength(const char* fieldName, int32_t fieldTypeId)
+            {
+                WriteFieldId(fieldName, fieldTypeId);
+
+                stream->Position(stream->Position() + 4);
+            }
+
+            void PortableWriterImpl::WriteFieldIdAndLength(const char* fieldName, int32_t fieldTypeId, int32_t len)
+            {
+                WriteFieldId(fieldName, fieldTypeId);
+
+                stream->WriteInt32(len);
+            }
+            
+            template <>
+            void PortableWriterImpl::WriteTopObject<int8_t>(const int8_t& obj)
+            {
+                WriteTopObject0<int8_t>(obj, PortableUtils::WriteInt8, IGNITE_TYPE_BYTE);
+            }
+
+            template <>
+            void PortableWriterImpl::WriteTopObject<bool>(const bool& obj)
+            {
+                WriteTopObject0<bool>(obj, PortableUtils::WriteBool, IGNITE_TYPE_BOOL);
+            }
+
+            template <>
+            void PortableWriterImpl::WriteTopObject<int16_t>(const int16_t& obj)
+            {
+                WriteTopObject0<int16_t>(obj, PortableUtils::WriteInt16, IGNITE_TYPE_SHORT);
+            }
+
+            template <>
+            void PortableWriterImpl::WriteTopObject<uint16_t>(const uint16_t& obj)
+            {
+                WriteTopObject0<uint16_t>(obj, PortableUtils::WriteUInt16, IGNITE_TYPE_CHAR);
+            }
+
+            template <>
+            void PortableWriterImpl::WriteTopObject<int32_t>(const int32_t& obj)
+            {
+                WriteTopObject0<int32_t>(obj, PortableUtils::WriteInt32, IGNITE_TYPE_INT);
+            }
+
+            template <>
+            void PortableWriterImpl::WriteTopObject<int64_t>(const int64_t& obj)
+            {
+                WriteTopObject0<int64_t>(obj, PortableUtils::WriteInt64, IGNITE_TYPE_LONG);
+            }
+
+            template <>
+            void PortableWriterImpl::WriteTopObject<float>(const float& obj)
+            {
+                WriteTopObject0<float>(obj, PortableUtils::WriteFloat, IGNITE_TYPE_FLOAT);
+            }
+
+            template <>
+            void PortableWriterImpl::WriteTopObject<double>(const double& obj)
+            {
+                WriteTopObject0<double>(obj, PortableUtils::WriteDouble, IGNITE_TYPE_DOUBLE);
+            }
+
+            template <>
+            void PortableWriterImpl::WriteTopObject<Guid>(const Guid& obj)
+            {
+                WriteTopObject0<Guid>(obj, PortableUtils::WriteGuid, IGNITE_TYPE_UUID);
+            }
+
+            InteropOutputStream* PortableWriterImpl::GetStream()
+            {
+                return stream;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/portable/portable_containers.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/portable/portable_containers.cpp b/modules/platform/src/main/cpp/core/src/portable/portable_containers.cpp
new file mode 100644
index 0000000..8270a13
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/portable/portable_containers.cpp
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+ 
+#include "ignite/portable/portable_containers.h"
+
+using namespace ignite::impl::portable;
+
+namespace ignite
+{
+    namespace portable
+    {
+        PortableStringArrayWriter::PortableStringArrayWriter(PortableWriterImpl* impl, const int32_t id) : 
+            impl(impl), id(id)
+        {
+            // No-op.
+        }
+
+        void PortableStringArrayWriter::Write(const char* val)
+        {
+            if (val)
+                Write(val, static_cast<int32_t>(strlen(val)));
+            else
+                Write(NULL, -1);
+        }
+
+        void PortableStringArrayWriter::Write(const char* val, const int32_t len)
+        {
+            impl->WriteStringElement(id, val, len);
+        }
+
+        void PortableStringArrayWriter::Close()
+        {
+            impl->CommitContainer(id);
+        }
+
+        PortableStringArrayReader::PortableStringArrayReader(impl::portable::PortableReaderImpl* impl, 
+            int32_t id, int32_t size) : impl(impl), id(id), size(size)
+        {
+            // No-op.
+        }
+
+        bool PortableStringArrayReader::HasNext()
+        {
+            return impl->HasNextElement(id);
+        }
+
+        int32_t PortableStringArrayReader::GetNext(char* res, const int32_t len)
+        {
+            return impl->ReadStringElement(id, res, len);
+        }
+
+        int32_t PortableStringArrayReader::GetSize()
+        {
+            return size;
+        }
+
+        bool PortableStringArrayReader::IsNull()
+        {
+            return size == -1;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/portable/portable_raw_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/portable/portable_raw_reader.cpp b/modules/platform/src/main/cpp/core/src/portable/portable_raw_reader.cpp
new file mode 100644
index 0000000..f659913
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/portable/portable_raw_reader.cpp
@@ -0,0 +1,135 @@
+/*
+ * 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.
+ */
+#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/portable/portable_raw_reader.h"
+
+using namespace ignite::impl::portable;
+
+namespace ignite
+{
+    namespace portable
+    {        
+        PortableRawReader::PortableRawReader(PortableReaderImpl* impl) : impl(impl)
+        {
+            // No-op.
+        }
+        
+        int8_t PortableRawReader::ReadInt8()
+        {
+            return impl->ReadInt8();
+        }
+
+        int32_t PortableRawReader::ReadInt8Array(int8_t* res, const int32_t len)
+        {
+            return impl->ReadInt8Array(res, len);
+        }
+        
+        bool PortableRawReader::ReadBool()
+        {
+            return impl->ReadBool();
+        }
+
+        int32_t PortableRawReader::ReadBoolArray(bool* res, const int32_t len)
+        {
+            return impl->ReadBoolArray(res, len);
+        }
+
+        int16_t PortableRawReader::ReadInt16()
+        {
+            return impl->ReadInt16();
+        }
+        
+        int32_t PortableRawReader::ReadInt16Array(int16_t* res, const int32_t len)
+        {
+            return impl->ReadInt16Array(res, len);
+        }
+
+        uint16_t PortableRawReader::ReadUInt16()
+        {
+            return impl->ReadUInt16();
+        }
+
+        int32_t PortableRawReader::ReadUInt16Array(uint16_t* res, const int32_t len)
+        {
+            return impl->ReadUInt16Array(res, len);
+        }
+
+        int32_t PortableRawReader::ReadInt32()
+        {
+            return impl->ReadInt32();
+        }
+        
+        int32_t PortableRawReader::ReadInt32Array(int32_t* res, const int32_t len)
+        {
+            return impl->ReadInt32Array(res, len);
+        }
+
+        int64_t PortableRawReader::ReadInt64()
+        {
+            return impl->ReadInt64();
+        }
+
+        int32_t PortableRawReader::ReadInt64Array(int64_t* res, const int32_t len)
+        {
+            return impl->ReadInt64Array(res, len);
+        }
+
+        float PortableRawReader::ReadFloat()
+        {
+            return impl->ReadFloat();
+        }
+        
+        int32_t PortableRawReader::ReadFloatArray(float* res, const int32_t len)
+        {
+            return impl->ReadFloatArray(res, len);
+        }
+
+        double PortableRawReader::ReadDouble()
+        {
+            return impl->ReadDouble();
+        }
+        
+        int32_t PortableRawReader::ReadDoubleArray(double* res, const int32_t len)
+        {
+            return impl->ReadDoubleArray(res, len);
+        }
+        
+        Guid PortableRawReader::ReadGuid()
+        {
+            return impl->ReadGuid();
+        }
+
+        int32_t PortableRawReader::ReadGuidArray(Guid* res, const int32_t len)
+        {
+            return impl->ReadGuidArray(res, len);
+        }        
+
+        int32_t PortableRawReader::ReadString(char* res, const int32_t len)
+        {
+            return impl->ReadString(res, len);
+        }
+
+        PortableStringArrayReader PortableRawReader::ReadStringArray()
+        {
+            int32_t size;
+
+            int32_t id = impl->ReadStringArray(&size);
+
+            return PortableStringArrayReader(impl, id, size);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/portable/portable_raw_writer.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/portable/portable_raw_writer.cpp b/modules/platform/src/main/cpp/core/src/portable/portable_raw_writer.cpp
new file mode 100644
index 0000000..c682abe
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/portable/portable_raw_writer.cpp
@@ -0,0 +1,147 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/portable/portable_writer_impl.h"
+#include "ignite/portable/portable_raw_writer.h"
+
+using namespace ignite::impl::portable;
+
+namespace ignite
+{
+    namespace portable
+    {
+        PortableRawWriter::PortableRawWriter(PortableWriterImpl* impl) : impl(impl)
+        {
+            // No-op.
+        }
+
+        void PortableRawWriter::WriteInt8(const int8_t val)
+        {
+            impl->WriteInt8(val);
+        }
+
+        void PortableRawWriter::WriteInt8Array(const int8_t* val, const int32_t len)
+        {
+            impl->WriteInt8Array(val, len);
+        }
+
+        void PortableRawWriter::WriteBool(const bool val)
+        {
+            impl->WriteBool(val);
+        }
+
+        void PortableRawWriter::WriteBoolArray(const bool* val, const int32_t len)
+        {            
+            impl->WriteBoolArray(val, len);
+        }
+
+        void PortableRawWriter::WriteInt16(const int16_t val)
+        {
+            impl->WriteInt16(val);
+        }
+
+        void PortableRawWriter::WriteInt16Array(const int16_t* val, const int32_t len)
+        {
+            impl->WriteInt16Array(val, len);
+        }
+
+        void PortableRawWriter::WriteUInt16(const uint16_t val)
+        {
+            impl->WriteUInt16(val);
+        }
+
+        void PortableRawWriter::WriteUInt16Array(const uint16_t* val, const int32_t len)
+        {
+            impl->WriteUInt16Array(val, len);
+        }
+
+        void PortableRawWriter::WriteInt32(const int32_t val)
+        {
+            impl->WriteInt32(val);
+        }
+
+        void PortableRawWriter::WriteInt32Array(const int32_t* val, const int32_t len)
+        {
+            impl->WriteInt32Array(val, len);
+        }
+
+        void PortableRawWriter::WriteInt64(const int64_t val)
+        {
+            impl->WriteInt64(val);
+        }
+
+        void PortableRawWriter::WriteInt64Array(const int64_t* val, const int32_t len)
+        {
+            impl->WriteInt64Array(val, len);
+        }
+
+        void PortableRawWriter::WriteFloat(const float val)
+        {
+            impl->WriteFloat(val);
+        }
+
+        void PortableRawWriter::WriteFloatArray(const float* val, const int32_t len)
+        {
+            impl->WriteFloatArray(val, len);
+        }
+
+        void PortableRawWriter::WriteDouble(const double val)
+        {
+            impl->WriteDouble(val);
+        }
+
+        void PortableRawWriter::WriteDoubleArray(const double* val, const int32_t len)
+        {
+            impl->WriteDoubleArray(val, len);
+        }
+
+        void PortableRawWriter::WriteGuid(const Guid val)
+        {
+            impl->WriteGuid(val);
+        }
+
+        void PortableRawWriter::WriteGuidArray(const Guid* val, const int32_t len)
+        {
+            impl->WriteGuidArray(val, len);
+        }
+
+        void PortableRawWriter::WriteString(const char* val)
+        {
+            if (val)
+                WriteString(val, static_cast<int32_t>(strlen(val)));
+            else
+                WriteNull();
+        }
+
+        void PortableRawWriter::WriteString(const char* val, const int32_t len)
+        {
+            impl->WriteString(val, len);
+        }
+
+        PortableStringArrayWriter PortableRawWriter::WriteStringArray()
+        {
+            int32_t id = impl->WriteStringArray();
+
+            return PortableStringArrayWriter(impl, id);
+        }
+
+        void PortableRawWriter::WriteNull()
+        {
+            impl->WriteNull();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/portable/portable_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/portable/portable_reader.cpp b/modules/platform/src/main/cpp/core/src/portable/portable_reader.cpp
new file mode 100644
index 0000000..515216d
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/portable/portable_reader.cpp
@@ -0,0 +1,142 @@
+/*
+ * 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.
+ */
+#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/portable/portable_reader.h"
+
+using namespace ignite::impl::portable;
+
+namespace ignite
+{
+    namespace portable
+    {
+        PortableReader::PortableReader(PortableReaderImpl* impl) : impl(impl)
+        {
+            // No-op.
+        }
+        
+        int8_t PortableReader::ReadInt8(const char* fieldName)
+        {
+            return impl->ReadInt8(fieldName);
+        }
+
+        int32_t PortableReader::ReadInt8Array(const char* fieldName, int8_t* res, const int32_t len)
+        {
+            return impl->ReadInt8Array(fieldName, res, len);
+        }
+
+        bool PortableReader::ReadBool(const char* fieldName)
+        {
+            return impl->ReadBool(fieldName);
+        }
+
+        int32_t PortableReader::ReadBoolArray(const char* fieldName, bool* res, const int32_t len)
+        {
+            return impl->ReadBoolArray(fieldName, res, len);
+        }
+
+        int16_t PortableReader::ReadInt16(const char* fieldName)
+        {
+            return impl->ReadInt16(fieldName);
+        }
+
+        int32_t PortableReader::ReadInt16Array(const char* fieldName, int16_t* res, const int32_t len)
+        {
+            return impl->ReadInt16Array(fieldName, res, len);
+        }
+
+        uint16_t PortableReader::ReadUInt16(const char* fieldName)
+        {
+            return impl->ReadUInt16(fieldName);
+        }
+
+        int32_t PortableReader::ReadUInt16Array(const char* fieldName, uint16_t* res, const int32_t len)
+        {
+            return impl->ReadUInt16Array(fieldName, res, len);
+        }
+
+        int32_t PortableReader::ReadInt32(const char* fieldName)
+        {
+            return impl->ReadInt32(fieldName);
+        }
+
+        int32_t PortableReader::ReadInt32Array(const char* fieldName, int32_t* res, const int32_t len)
+        {
+            return impl->ReadInt32Array(fieldName, res, len);
+        }
+
+        int64_t PortableReader::ReadInt64(const char* fieldName)
+        {
+            return impl->ReadInt64(fieldName);
+        }
+
+        int32_t PortableReader::ReadInt64Array(const char* fieldName, int64_t* res, const int32_t len)
+        {
+            return impl->ReadInt64Array(fieldName, res, len);
+        }
+
+        float PortableReader::ReadFloat(const char* fieldName)
+        {
+            return impl->ReadFloat(fieldName);
+        }
+
+        int32_t PortableReader::ReadFloatArray(const char* fieldName, float* res, const int32_t len)
+        {
+            return impl->ReadFloatArray(fieldName, res, len);
+        }
+
+        double PortableReader::ReadDouble(const char* fieldName)
+        {
+            return impl->ReadDouble(fieldName);
+        }
+
+        int32_t PortableReader::ReadDoubleArray(const char* fieldName, double* res, const int32_t len)
+        {
+            return impl->ReadDoubleArray(fieldName, res, len);
+        }
+
+        Guid PortableReader::ReadGuid(const char* fieldName)
+        {
+            return impl->ReadGuid(fieldName);
+        }
+
+        int32_t PortableReader::ReadGuidArray(const char* fieldName, Guid* res, const int32_t len)
+        {
+            return impl->ReadGuidArray(fieldName, res, len);
+        }
+        
+        int32_t PortableReader::ReadString(const char* fieldName, char* res, const int32_t len)
+        {
+            return impl->ReadString(fieldName, res, len);
+        }
+
+        PortableStringArrayReader PortableReader::ReadStringArray(const char* fieldName)
+        {
+            int32_t size;
+
+            int32_t id = impl->ReadStringArray(fieldName, &size);
+
+            return PortableStringArrayReader(impl, id, size);
+        }
+
+        PortableRawReader PortableReader::RawReader()
+        {
+            impl->SetRawMode();
+
+            return PortableRawReader(impl);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/portable/portable_type.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/portable/portable_type.cpp b/modules/platform/src/main/cpp/core/src/portable/portable_type.cpp
new file mode 100644
index 0000000..e22f869
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/portable/portable_type.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+#include "ignite/portable/portable_type.h"
+
+namespace ignite
+{
+    namespace portable
+    {
+        int32_t GetPortableStringHashCode(const char* val)
+        {
+            if (val)
+            {
+                int32_t hash = 0;
+
+                int i = 0;
+
+                while (true)
+                {
+                    char c = *(val + i++);
+
+                    if (c == '\0')
+                        break;
+
+                    if ('A' <= c && c <= 'Z')
+                        c = c | 0x20;
+
+                    hash = 31 * hash + c;
+                }
+
+                return hash;
+            }
+            else
+                return 0;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/src/portable/portable_writer.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/src/portable/portable_writer.cpp b/modules/platform/src/main/cpp/core/src/portable/portable_writer.cpp
new file mode 100644
index 0000000..f31b9dd
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/src/portable/portable_writer.cpp
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/portable/portable_writer_impl.h"
+#include "ignite/portable/portable_writer.h"
+
+using namespace ignite::impl::portable;
+
+namespace ignite
+{
+    namespace portable
+    {
+        PortableWriter::PortableWriter(PortableWriterImpl* impl) : impl(impl)
+        {
+            // No-op.
+        }
+
+        void PortableWriter::WriteInt8(const char* fieldName, const int8_t val)
+        {
+            impl->WriteInt8(fieldName, val);
+        }
+
+        void PortableWriter::WriteInt8Array(const char* fieldName, const int8_t* val, const int32_t len)
+        {
+            impl->WriteInt8Array(fieldName, val, len);
+        }
+
+        void PortableWriter::WriteBool(const char* fieldName, const bool val)
+        {
+            impl->WriteBool(fieldName, val);
+        }
+
+        void PortableWriter::WriteBoolArray(const char* fieldName, const bool* val, const int32_t len)
+        {
+            impl->WriteBoolArray(fieldName, val, len);
+        }
+
+        void PortableWriter::WriteInt16(const char* fieldName, const int16_t val)
+        {
+            impl->WriteInt16(fieldName, val);
+        }
+
+        void PortableWriter::WriteInt16Array(const char* fieldName, const int16_t* val, const int32_t len)
+        {
+            impl->WriteInt16Array(fieldName, val, len);
+        }
+
+        void PortableWriter::WriteUInt16(const char* fieldName, const uint16_t val)
+        {
+            impl->WriteUInt16(fieldName, val);
+        }
+
+        void PortableWriter::WriteUInt16Array(const char* fieldName, const uint16_t* val, const int32_t len)
+        {
+            impl->WriteUInt16Array(fieldName, val, len);
+        }
+
+        void PortableWriter::WriteInt32(const char* fieldName, const int32_t val)
+        {
+            impl->WriteInt32(fieldName, val);
+        }
+
+        void PortableWriter::WriteInt32Array(const char* fieldName, const int32_t* val, const int32_t len)
+        {
+            impl->WriteInt32Array(fieldName, val, len);
+        }
+
+        void PortableWriter::WriteInt64(const char* fieldName, const int64_t val)
+        {
+            impl->WriteInt64(fieldName, val);
+        }
+
+        void PortableWriter::WriteInt64Array(const char* fieldName, const int64_t* val, const int32_t len)
+        {
+            impl->WriteInt64Array(fieldName, val, len);
+        }
+
+        void PortableWriter::WriteFloat(const char* fieldName, const float val)
+        {
+            impl->WriteFloat(fieldName, val);
+        }
+
+        void PortableWriter::WriteFloatArray(const char* fieldName, const float* val, const int32_t len)
+        {
+            impl->WriteFloatArray(fieldName, val, len);
+        }
+
+        void PortableWriter::WriteDouble(const char* fieldName, const double val)
+        {
+            impl->WriteDouble(fieldName, val);
+        }
+
+        void PortableWriter::WriteDoubleArray(const char* fieldName, const double* val, const int32_t len)
+        {
+            impl->WriteDoubleArray(fieldName, val, len);
+        }
+
+        void PortableWriter::WriteGuid(const char* fieldName, const Guid val)
+        {
+            impl->WriteGuid(fieldName, val);
+        }
+
+        void PortableWriter::WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len)
+        {
+            impl->WriteGuidArray(fieldName, val, len);
+        }
+
+        void PortableWriter::WriteString(const char* fieldName, const char* val)
+        {
+            if (val)
+                WriteString(fieldName, val, static_cast<int32_t>(strlen(val)));
+            else
+                WriteNull(fieldName);
+        }
+
+        void PortableWriter::WriteString(const char* fieldName, const char* val, const int32_t len)
+        {
+            impl->WriteString(fieldName, val, len);
+        }
+
+        PortableStringArrayWriter PortableWriter::WriteStringArray(const char* fieldName)
+        {
+            int32_t id = impl->WriteStringArray(fieldName);
+
+            return PortableStringArrayWriter(impl, id);
+        }
+
+        void PortableWriter::WriteNull(const char* fieldName)
+        {
+            impl->WriteNull(fieldName);
+        }
+
+        PortableRawWriter PortableWriter::RawWriter()
+        {
+            impl->SetRawMode();
+
+            return PortableRawWriter(impl);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index eba7390..69b0cd0 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -743,15 +743,23 @@
                                         <exclude>src/main/dotnet/Apache.Ignite.sln</exclude>
                                         <exclude>src/main/dotnet/Apache.Ignite.sln.DotSettings</exclude>
                                         <exclude>src/main/java/META-INF/services/org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory</exclude>
+                                        <exclude>src/main/resources/META-INF/services/org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory</exclude>
                                         <exclude>src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj</exclude>
                                         <exclude>src/test/portables/repo/org/apache/ignite/portable/test1/1.1/test1-1.1.jar</exclude>
                                         <exclude>src/test/portables/repo/org/apache/ignite/portable/test2/1.1/test2-1.1.jar</exclude>
                                         <exclude>**/Makefile.am</exclude>
                                         <exclude>**/configure.ac</exclude>
+                                        <exclude>**/*.pc.in</exclude>
                                         <exclude>**/*.vcxproj</exclude>
+                                        <exclude>**/*.vcxprojrel</exclude>
                                         <exclude>**/*.vcxproj.filters</exclude>
+                                        <exclude>**/*.sln</exclude>
+                                        <exclude>**/*.slnrel</exclude>
+                                        <exclude>**/*.opensdf</exclude>
                                         <exclude>**/module.def</exclude>
-                                        <exclude>**/ignite-common.pc.in</exclude>
+                                        <exclude>**/teamcity_boost.cpp</exclude>
+                                        <exclude>**/teamcity_messages.h</exclude>
+                                        <exclude>**/teamcity_messages.cpp</exclude>
                                     </excludes>
                                 </configuration>
                             </execution>


[33/50] [abbrv] ignite git commit: Merge remote-tracking branch 'origin/ignite-1.4' into ignite-1.4

Posted by ak...@apache.org.
Merge remote-tracking branch 'origin/ignite-1.4' into ignite-1.4


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

Branch: refs/heads/ignite-843
Commit: f1f6be8c750877e636681b07af849418e2919dec
Parents: 7a69e74 ca1523e
Author: sboikov <sb...@gridgain.com>
Authored: Fri Sep 4 10:21:09 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Sep 4 10:21:09 2015 +0300

----------------------------------------------------------------------
 .../portable/datagrid/CacheClientPortablePutGetExample.java     | 4 ++++
 .../portable/datagrid/CacheClientPortableQueryExample.java      | 5 +++++
 2 files changed, 9 insertions(+)
----------------------------------------------------------------------



[44/50] [abbrv] ignite git commit: IGNITE-1364: Moved CPP module to Ignite.

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_cursor.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_cursor.h b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_cursor.h
new file mode 100644
index 0000000..23133e1
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_cursor.h
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_CURSOR
+#define _IGNITE_CACHE_QUERY_CURSOR
+
+#include <vector>
+
+#include <ignite/common/concurrent.h>
+
+#include "ignite/cache/cache_entry.h"
+#include "ignite/ignite_error.h"
+#include "ignite/impl/cache/query/query_impl.h"
+#include "ignite/impl/operations.h"
+
+namespace ignite
+{    
+    namespace cache
+    {
+        namespace query
+        {            
+            /**
+             * Query cursor.
+             */
+            template<typename K, typename V>
+            class QueryCursor
+            {
+            public:
+                /**
+                 * Default constructor.
+                 */
+                QueryCursor() : impl(NULL)
+                {
+                    // No-op.
+                }
+
+                /**
+                 * Constructor.
+                 *
+                 * @param impl Implementation.
+                 */
+                QueryCursor(impl::cache::query::QueryCursorImpl* impl) : 
+                    impl(ignite::common::concurrent::SharedPointer<impl::cache::query::QueryCursorImpl>(impl))
+                {
+                    // No-op.
+                }
+                
+                /**
+                 * Check whether next entry exists.
+                 *
+                 * @return True if next entry exists.
+                 */
+                bool HasNext()
+                {
+                    IgniteError err;
+
+                    bool res = HasNext(err);
+
+                    IgniteError::ThrowIfNeeded(err);
+
+                    return res;
+                }
+
+                /**
+                 * Check whether next entry exists.
+                 *
+                 * @param err Error.
+                 * @return True if next entry exists.
+                 */
+                bool HasNext(IgniteError& err)
+                {
+                    impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
+
+                    if (impl0)
+                        return impl0->HasNext(&err);
+                    else
+                    {
+                        err = IgniteError(IgniteError::IGNITE_ERR_GENERIC, 
+                            "Instance is not usable (did you check for error?).");
+
+                        return false;
+                    }
+                }
+
+                /**
+                 * Get next entry.
+                 *
+                 * @return Next entry.
+                 */
+                CacheEntry<K, V> GetNext()
+                {
+                    IgniteError err;
+
+                    CacheEntry<K, V> res = GetNext(err);
+
+                    IgniteError::ThrowIfNeeded(err);
+
+                    return res;                        
+                }
+
+                /**
+                 * Get next entry.
+                 *
+                 * @param err Error.
+                 * @return Next entry.
+                 */
+                CacheEntry<K, V> GetNext(IgniteError& err)
+                {
+                    impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
+
+                    if (impl0) {
+                        impl::Out2Operation<K, V> outOp;
+
+                        impl0->GetNext(outOp, &err);
+
+                        if (err.GetCode() == IgniteError::IGNITE_SUCCESS) 
+                        {
+                            K& key = outOp.Get1();
+                            V& val = outOp.Get2();
+
+                            return CacheEntry<K, V>(key, val);
+                        }
+                        else 
+                            return CacheEntry<K, V>();
+                    }
+                    else
+                    {
+                        err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                            "Instance is not usable (did you check for error?).");
+
+                        return CacheEntry<K, V>();
+                    }
+                }
+
+                /**
+                 * Get all entries.
+                 * 
+                 * @param Vector where query entries will be stored.
+                 */
+                void GetAll(std::vector<CacheEntry<K, V>>& res)
+                {
+                    IgniteError err;
+
+                    GetAll(res, err);
+
+                    IgniteError::ThrowIfNeeded(err);
+                }
+
+                /**
+                 * Get all entries.
+                 * 
+                 * @param Vector where query entries will be stored.
+                 * @param err Error.                 
+                 */
+                void GetAll(std::vector<CacheEntry<K, V>>& res, IgniteError& err)
+                {
+                    impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
+
+                    if (impl0) {
+                        impl::OutQueryGetAllOperation<K, V> outOp(&res);
+
+                        impl0->GetAll(outOp, &err);
+                    }
+                    else
+                        err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                            "Instance is not usable (did you check for error?).");
+                }
+
+            private:
+                /** Implementation delegate. */
+                ignite::common::concurrent::SharedPointer<impl::cache::query::QueryCursorImpl> impl;
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_scan.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_scan.h b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_scan.h
new file mode 100644
index 0000000..c3ec845
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_scan.h
@@ -0,0 +1,151 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_SCAN
+#define _IGNITE_CACHE_QUERY_SCAN
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/portable/portable_raw_writer.h"
+
+namespace ignite
+{    
+    namespace cache
+    {
+        namespace query
+        {         
+            /*
+             * Scab query.
+             */
+            class ScanQuery
+            {
+            public:
+                /* 
+                 * Constructor.
+                 */
+                ScanQuery() : part(-1), pageSize(1024), loc(false)
+                {
+                    // No-op.
+                }
+                
+                /*
+                 * Constructor.
+                 *
+                 * @param part Partition.
+                 */
+                ScanQuery(int32_t part) : part(part), pageSize(1024), loc(false)
+                {
+                    // No-op.
+                }
+                
+                /*
+                 * Get partition to scan.
+                 *
+                 * @return Partition to scan.
+                 */
+                int32_t GetPartition()
+                {
+                    return part;
+                }
+
+                /*
+                 * Set partition to scan.
+                 *
+                 * @param part Partition to scan.
+                 */
+                void SetPartition(int32_t part)
+                {
+                    this->part = part;
+                }
+
+                /*
+                 * Get page size.
+                 *
+                 * @return Page size.
+                 */
+                int32_t GetPageSize()
+                {
+                    return pageSize;
+                }
+
+                /*
+                 * Set page size.
+                 *
+                 * @param pageSize Page size.
+                 */
+                void SetPageSize(int32_t pageSize)
+                {
+                    this->pageSize = pageSize;
+                }
+
+                /*
+                 * Get local flag.
+                 *
+                 * @return Local flag.
+                 */
+                bool IsLocal()
+                {
+                    return loc;
+                }
+
+                /*
+                 * Set local flag.
+                 *
+                 * @param loc Local flag.
+                 */
+                void SetLocal(bool loc)
+                {
+                    this->loc = loc;
+                }
+                
+                /*
+                 * Write query info to the stream.
+                 *
+                 * @param writer Writer.
+                 */
+                void Write(portable::PortableRawWriter& writer) const
+                {
+                    writer.WriteBool(loc);
+                    writer.WriteInt32(pageSize);
+
+                    if (part < 0)
+                        writer.WriteBool(false);
+                    else
+                    {
+                        writer.WriteBool(true);
+                        writer.WriteInt32(part);
+                    }
+
+                    writer.WriteNull(); // Predicates are not supported yet.
+                }
+
+            private:
+                /* Partition. */
+                int32_t part;
+
+                /* Page size. */
+                int32_t pageSize;
+
+                /* Local flag. */
+                bool loc;
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_sql.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_sql.h b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_sql.h
new file mode 100644
index 0000000..a2e0f33
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_sql.h
@@ -0,0 +1,253 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_SQL
+#define _IGNITE_CACHE_QUERY_SQL
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+
+#include "ignite/cache/query/query_argument.h"
+#include "ignite/portable/portable_raw_writer.h"
+
+namespace ignite
+{    
+    namespace cache
+    {
+        namespace query
+        {         
+            /**
+             * Sql query.
+             */
+            class SqlQuery
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param type Type name.
+                 * @param sql SQL string.
+                 */
+                SqlQuery(std::string type, std::string sql) : type(type), sql(sql), pageSize(1024), 
+                    loc(false), args(NULL)
+                {
+                    // No-op.
+                }
+
+                /**
+                 * Copy constructor.
+                 *
+                 * @param other Other instance.
+                 */
+                SqlQuery(const SqlQuery& other)
+                {
+                    type = other.type;
+                    sql = other.sql;
+                    pageSize = other.pageSize;
+                    loc = other.loc;
+
+                    if (other.args)
+                    {
+                        args = new std::vector<QueryArgumentBase*>();
+
+                        for (std::vector<QueryArgumentBase*>::iterator it = other.args->begin();
+                            it != other.args->end(); ++it)
+                            args->push_back((*it)->Copy());
+                    }
+                    else
+                        args = NULL;
+                }
+
+                /**
+                 * Assignment operator.
+                 *
+                 * @param other Other instance.
+                 */
+                SqlQuery& operator=(const SqlQuery& other) 
+                {
+                    if (this != &other)
+                    {
+                        type = other.type;
+                        sql = other.sql;
+                        pageSize = other.pageSize;
+                        loc = other.loc;
+
+                        SqlQuery tmp(other);
+
+                        std::vector<QueryArgumentBase*>* args0 = args;
+
+                        args = tmp.args;
+
+                        tmp.args = args0; 
+                    }
+
+                    return *this;
+                }
+
+                /**
+                 * Destructor.
+                 */
+                ~SqlQuery()
+                {
+                    if (args) 
+                    {
+                        for (std::vector<QueryArgumentBase*>::iterator it = args->begin(); it != args->end(); ++it)
+                            delete (*it);
+
+                        delete args;
+                    }
+                }
+
+                /**
+                 * Get type name.
+                 *
+                 * @return Type name.
+                 */
+                std::string GetType()
+                {
+                    return type;
+                }
+
+                /**
+                 * Set type name.
+                 *
+                 * @param sql Type name.
+                 */
+                void SetType(std::string type)
+                {
+                    this->type = type;
+                }
+
+                /**
+                 * Get SQL string.
+                 *
+                 * @return SQL string.
+                 */
+                std::string GetSql()
+                {
+                    return sql;
+                }
+
+                /**
+                 * Set SQL string.
+                 *
+                 * @param sql SQL string.
+                 */
+                void SetSql(std::string sql)
+                {
+                    this->sql = sql;
+                }
+
+                /**
+                 * Get page size.
+                 *
+                 * @return Page size.
+                 */
+                int32_t GetPageSize()
+                {
+                    return pageSize;
+                }
+
+                /**
+                 * Set page size.
+                 *
+                 * @param pageSize Page size.
+                 */
+                void SetPageSize(int32_t pageSize)
+                {
+                    this->pageSize = pageSize;
+                }
+
+                /**
+                 * Get local flag.
+                 *
+                 * @return Local flag.
+                 */
+                bool IsLocal()
+                {
+                    return loc;
+                }
+
+                /**
+                 * Set local flag.
+                 *
+                 * @param loc Local flag.
+                 */
+                void SetLocal(bool loc)
+                {
+                    this->loc = loc;
+                }
+
+                /**
+                 * Add argument.
+                 *
+                 * @param arg Argument.
+                 */
+                template<typename T>
+                void AddArgument(const T& arg)
+                {
+                    if (!args)
+                        args = new std::vector<QueryArgumentBase*>();
+
+                    args->push_back(new QueryArgument<T>(arg));
+                }
+
+                /**
+                 * Write query info to the stream.
+                 *
+                 * @param writer Writer.
+                 */
+                void Write(portable::PortableRawWriter& writer) const
+                {
+                    writer.WriteBool(loc);
+                    writer.WriteString(sql);
+                    writer.WriteString(type);
+                    writer.WriteInt32(pageSize);
+
+                    if (args)
+                    {
+                        writer.WriteInt32(static_cast<int32_t>(args->size()));
+
+                        for (std::vector<QueryArgumentBase*>::iterator it = args->begin(); it != args->end(); ++it)
+                            (*it)->Write(writer);
+                    }
+                    else
+                        writer.WriteInt32(0);
+                }
+
+            private:
+                /** Type name. */
+                std::string type;
+
+                /** SQL string. */
+                std::string sql;
+
+                /** Page size. */
+                int32_t pageSize;
+
+                /** Local flag. */
+                bool loc;
+
+                /** Arguments. */
+                std::vector<QueryArgumentBase*>* args;
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_text.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_text.h b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_text.h
new file mode 100644
index 0000000..67d3ecc
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/cache/query/query_text.h
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_TEXT
+#define _IGNITE_CACHE_QUERY_TEXT
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/portable/portable_raw_writer.h"
+
+namespace ignite
+{    
+    namespace cache
+    {
+        namespace query
+        {         
+            /*
+             * Text query.
+             */
+            class TextQuery
+            {
+            public:
+                /*
+                 * Constructor.
+                 *
+                 * @param type Type name.
+                 * @param text Text string.
+                 */
+                TextQuery(std::string type, std::string text) : type(type), text(text), pageSize(1024), loc(false)
+                {
+                    // No-op.
+                }
+                
+                /*
+                 * Get type name.
+                 *
+                 * @return Type name.
+                 */
+                std::string GetType()
+                {
+                    return type;
+                }
+
+                /*
+                 * Set type name.
+                 *
+                 * @param sql Type name.
+                 */
+                void SetType(std::string type)
+                {
+                    this->type = type;
+                }
+
+                /*
+                 * Get text string.
+                 *
+                 * @return text string.
+                 */
+                std::string GetText()
+                {
+                    return text;
+                }
+
+                /*
+                 * Set text string.
+                 *
+                 * @param text Text string.
+                 */
+                void SetText(std::string text)
+                {
+                    this->text = text;
+                }
+
+                /*
+                 * Get page size.
+                 *
+                 * @return Page size.
+                 */
+                int32_t GetPageSize()
+                {
+                    return pageSize;
+                }
+
+                /*
+                 * Set page size.
+                 *
+                 * @param pageSize Page size.
+                 */
+                void SetPageSize(int32_t pageSize)
+                {
+                    this->pageSize = pageSize;
+                }
+
+                /*
+                 * Get local flag.
+                 *
+                 * @return Local flag.
+                 */
+                bool IsLocal()
+                {
+                    return loc;
+                }
+
+                /*
+                    * Set local flag.
+                    *
+                    * @param loc Local flag.
+                    */
+                void SetLocal(bool loc)
+                {
+                    this->loc = loc;
+                }
+                
+                /*
+                 * Write query info to the stream.
+                 *
+                 * @param writer Writer.
+                 */
+                void Write(portable::PortableRawWriter& writer) const
+                {
+                    writer.WriteBool(loc);
+                    writer.WriteString(text);
+                    writer.WriteString(type);
+                    writer.WriteInt32(pageSize);
+                }
+
+            private:
+                /* Type name. */
+                std::string type;
+
+                /* Text string. */
+                std::string text;
+
+                /* Page size. */
+                int32_t pageSize;
+
+                /* Local flag. */
+                bool loc;
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/guid.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/guid.h b/modules/platform/src/main/cpp/core/include/ignite/guid.h
new file mode 100644
index 0000000..9469769
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/guid.h
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_GUID
+#define _IGNITE_GUID
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+namespace ignite
+{
+    /**
+     * Global universally unique identifier (GUID).
+     */
+    class IGNITE_IMPORT_EXPORT Guid
+    {
+    public:
+        /**
+         * Default constructor.
+         */
+        Guid();
+
+        /**
+         * Constructor.
+         *
+         * @param most Most significant bits.
+         * @param least Least significant bits.
+         */
+        Guid(int64_t most, int64_t least);
+
+        /**
+         * Returns the most significant 64 bits of this instance.
+         *
+         * @return The most significant 64 bits of this instance.
+         */
+        int64_t GetMostSignificantBits() const;
+
+        /**
+         * Returns the least significant 64 bits of this instance.
+         *  
+         * @return The least significant 64 bits of this instance.
+         */
+        int64_t GetLeastSignificantBits() const;
+
+        /**
+         * The version number associated with this instance.  The version
+         * number describes how this Guid was generated.
+         *
+         * The version number has the following meaning:
+         * 1    Time-based UUID;
+         * 2    DCE security UUID;
+         * 3    Name-based UUID;
+         * 4    Randomly generated UUID.
+         *
+         * @return The version number of this instance.
+         */
+        int32_t GetVersion() const;
+
+        /**
+         * The variant number associated with this instance. The variant
+         * number describes the layout of the Guid.
+         *
+         * The variant number has the following meaning:
+         * 0    Reserved for NCS backward compatibility;
+         * 2    IETF RFC 4122 (Leach-Salz), used by this class;
+         * 6    Reserved, Microsoft Corporation backward compatibility;
+         * 7    Reserved for future definition.
+         *
+         * @return The variant number of this instance.
+         */
+        int32_t GetVariant() const;
+
+        /**
+         * Get hash code of this instance (used in serialization).
+         *
+         * @return Hash code.
+         */
+        int32_t GetHashCode() const;
+
+        /**
+         * Comparison operator override.
+         *
+         * @param val1 First value.
+         * @param val2 Second value.
+         * @return True if equal.
+         */
+        friend bool IGNITE_IMPORT_EXPORT operator== (Guid& val1, Guid& val2);
+    private:
+        /** Most significant bits. */
+        int64_t most;  
+
+        /** Least significant bits. */
+        int64_t least; 
+    };
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/ignite.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/ignite.h b/modules/platform/src/main/cpp/core/include/ignite/ignite.h
new file mode 100644
index 0000000..6c1263e
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/ignite.h
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE
+#define _IGNITE
+
+#include "ignite/cache/cache.h"
+#include "ignite/impl/ignite_impl.h"
+#include "ignite/ignite_configuration.h"
+
+namespace ignite
+{
+    /**
+     * Main interface to operate with Ignite.
+     */
+    class IGNITE_IMPORT_EXPORT Ignite
+    {
+    public:
+        /**
+         * Default constructor.
+         */
+        Ignite();
+
+        /**
+         * Constructor.
+         */
+        Ignite(impl::IgniteImpl* impl);
+        
+        /**
+         * Get Ignite instance name.
+         *
+         * @return Name.
+         */
+        char* GetName();
+
+        /**
+         * Get cache.
+         *
+         * @param name Cache name.
+         * @return Cache.
+         */
+        template<typename K, typename V>
+        cache::Cache<K, V> GetCache(const char* name)
+        {
+            IgniteError err;
+
+            cache::Cache<K, V> res = GetCache<K, V>(name, &err);
+
+            IgniteError::ThrowIfNeeded(err);
+
+            return res;
+        }
+
+        /**
+         * Get cache.
+         *
+         * @param name Cache name.
+         * @param err Error;
+         * @return Cache.
+         */
+        template<typename K, typename V>
+        cache::Cache<K, V> GetCache(const char* name, IgniteError* err)
+        {
+            impl::cache::CacheImpl* cacheImpl = impl.Get()->GetCache<K, V>(name, err);
+
+            return cache::Cache<K, V>(cacheImpl);
+        }
+
+        /**
+         * Get or create cache.
+         *
+         * @param name Cache name.
+         * @return Cache.
+         */
+        template<typename K, typename V>
+        cache::Cache<K, V> GetOrCreateCache(const char* name)
+        {
+            IgniteError err;
+
+            cache::Cache<K, V> res = GetOrCreateCache<K, V>(name, &err);
+
+            IgniteError::ThrowIfNeeded(err);
+
+            return res;
+        }
+
+        /**
+         * Get or create cache.
+         *
+         * @param name Cache name.
+         * @param err Error;
+         * @return Cache.
+         */
+        template<typename K, typename V>
+        cache::Cache<K, V> GetOrCreateCache(const char* name, IgniteError* err)
+        {
+            impl::cache::CacheImpl* cacheImpl = impl.Get()->GetOrCreateCache<K, V>(name, err);
+
+            return cache::Cache<K, V>(cacheImpl);
+        }
+
+        /**
+         * Create cache.
+         *
+         * @param name Cache name.
+         * @return Cache.
+         */
+        template<typename K, typename V>
+        cache::Cache<K, V> CreateCache(const char* name)
+        {
+            IgniteError err;
+
+            cache::Cache<K, V> res = CreateCache<K, V>(name, &err);
+
+            IgniteError::ThrowIfNeeded(err);
+
+            return res;
+        }
+
+        /**
+         * Create cache.
+         *
+         * @param name Cache name.
+         * @param err Error;
+         * @return Cache.
+         */
+        template<typename K, typename V>
+        cache::Cache<K, V> CreateCache(const char* name, IgniteError* err)
+        {
+            impl::cache::CacheImpl* cacheImpl = impl.Get()->CreateCache<K, V>(name, err);
+
+            return cache::Cache<K, V>(cacheImpl);
+        }
+    private:
+        /** Implementation delegate. */
+        ignite::common::concurrent::SharedPointer<impl::IgniteImpl> impl;
+    };
+}
+
+#endif

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/ignite_configuration.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/ignite_configuration.h b/modules/platform/src/main/cpp/core/include/ignite/ignite_configuration.h
new file mode 100644
index 0000000..ce2d730
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/ignite_configuration.h
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CONFIGURATION
+#define _IGNITE_CONFIGURATION
+
+#include <stdint.h>
+
+namespace ignite
+{    
+    /**
+     * Single JVM option.
+     */
+    struct IgniteJvmOption
+    {
+        /** Option. */
+        char* opt;
+
+        /**
+         * Default constructor.
+         */
+        IgniteJvmOption() : opt(NULL)
+        {
+            // No-op.    
+        }
+
+        /**
+         * Constructor.
+         *
+         * @param opt Option.
+         */
+        IgniteJvmOption(char* opt) : opt(opt)
+        {
+            // No-op.
+        }
+    };
+
+    /**
+     * Ignite configuration.
+     */
+    struct IgniteConfiguration
+    {
+        /** Path to Ignite home. */
+        char* igniteHome;
+
+        /** Path to Spring configuration file. */
+        char* springCfgPath;
+
+        /** Path ot JVM libbrary. */
+        char* jvmLibPath;
+
+        /** JVM classpath. */
+        char* jvmClassPath;
+
+        /** Initial amount of JVM memory. */
+        int32_t jvmInitMem;
+
+        /** Maximum amount of JVM memory. */
+        int32_t jvmMaxMem;
+
+        /** Additional JVM options. */
+        IgniteJvmOption* jvmOpts;
+
+        /** Additional JVM options count. */
+        int32_t jvmOptsLen;
+
+        /**
+         * Constructor.
+         */
+        IgniteConfiguration() : igniteHome(NULL), springCfgPath(NULL), jvmLibPath(NULL), jvmClassPath(NULL),
+            jvmInitMem(512), jvmMaxMem(1024), jvmOpts(NULL), jvmOptsLen(0)
+        {
+            // No-op.
+        }
+    };    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/ignite_error.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/ignite_error.h b/modules/platform/src/main/cpp/core/include/ignite/ignite_error.h
new file mode 100644
index 0000000..4438a0e
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/ignite_error.h
@@ -0,0 +1,260 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ERROR
+#define _IGNITE_ERROR
+
+#include <sstream>
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#define IGNITE_ERROR_1(code, part1) { \
+    std::stringstream stream; \
+    stream << (part1); \
+    throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_2(code, part1, part2) { \
+    std::stringstream stream; \
+    stream << (part1) << (part2); \
+    throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_3(code, part1, part2, part3) { \
+    std::stringstream stream; \
+    stream << (part1) << (part2) << (part3); \
+    throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_FORMATTED_1(code, msg, key1, val1) { \
+    std::stringstream stream; \
+    stream << msg << " [" << key1 << "=" << (val1) << "]"; \
+    throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_FORMATTED_2(code, msg, key1, val1, key2, val2) { \
+    std::stringstream stream; \
+    stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << "]"; \
+    throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_FORMATTED_3(code, msg, key1, val1, key2, val2, key3, val3) { \
+    std::stringstream stream; \
+    stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << "]"; \
+    throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+#define IGNITE_ERROR_FORMATTED_4(code, msg, key1, val1, key2, val2, key3, val3, key4, val4) { \
+    std::stringstream stream; \
+    stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << ", " << key4 << "=" << (val4) << "]"; \
+    throw ignite::IgniteError(code, stream.str().c_str()); \
+}
+
+namespace ignite
+{
+    /**
+     * Ignite error information.
+     */
+    class IGNITE_IMPORT_EXPORT IgniteError
+    {
+    public:
+        /** Success. */
+        static const int IGNITE_SUCCESS = 0;
+
+        /** Failed to initialize JVM. */
+        static const int IGNITE_ERR_JVM_INIT = 1;
+
+        /** Failed to attach to JVM. */
+        static const int IGNITE_ERR_JVM_ATTACH = 2;
+        
+        /** JVM library is not found. */
+        static const int IGNITE_ERR_JVM_LIB_NOT_FOUND = 3;
+
+        /** Failed to load JVM library. */
+        static const int IGNITE_ERR_JVM_LIB_LOAD_FAILED = 4;
+        
+        /** JVM classpath is not provided. */
+        static const int IGNITE_ERR_JVM_NO_CLASSPATH = 5;
+
+        /** JVM error: no class definition found. */
+        static const int IGNITE_ERR_JVM_NO_CLASS_DEF_FOUND = 6;
+
+        /** JVM error: no such method. */
+        static const int IGNITE_ERR_JVM_NO_SUCH_METHOD = 7;
+
+        /** Memory operation error. */
+        static const int IGNITE_ERR_MEMORY = 1001;
+
+        /** Portable error. */
+        static const int IGNITE_ERR_PORTABLE = 1002;
+
+        /** Generic Ignite error. */
+        static const int IGNITE_ERR_GENERIC = 2000;
+
+        /** Illegal argument passed. */
+        static const int IGNITE_ERR_ILLEGAL_ARGUMENT = 2001;
+
+        /** Illegal state. */
+        static const int IGNITE_ERR_ILLEGAL_STATE = 2002;
+
+        /** Unsupported operation. */
+        static const int IGNITE_ERR_UNSUPPORTED_OPERATION = 2003;
+
+        /** Thread has been interrup. */
+        static const int IGNITE_ERR_INTERRUPTED = 2004;
+
+        /** Cluster group is empty. */
+        static const int IGNITE_ERR_CLUSTER_GROUP_EMPTY = 2005;
+
+        /** Cluster topology problem. */
+        static const int IGNITE_ERR_CLUSTER_TOPOLOGY = 2006;
+
+        /** Compute execution rejected. */
+        static const int IGNITE_ERR_COMPUTE_EXECUTION_REJECTED = 2007;
+
+        /** Compute job failover. */
+        static const int IGNITE_ERR_COMPUTE_JOB_FAILOVER = 2008;
+
+        /** Compute task cancelled. */
+        static const int IGNITE_ERR_COMPUTE_TASK_CANCELLED = 2009;
+
+        /** Compute task timeout. */
+        static const int IGNITE_ERR_COMPUTE_TASK_TIMEOUT = 2010;
+
+        /** Compute user undeclared exception. */
+        static const int IGNITE_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION = 2011;
+
+        /** Generic cache error. */
+        static const int IGNITE_ERR_CACHE = 2012;
+
+        /** Generic cache loader error. */
+        static const int IGNITE_ERR_CACHE_LOADER = 2013;
+
+        /** Generic cache writer error. */
+        static const int IGNITE_ERR_CACHE_WRITER = 2014;
+        
+        /** Generic cache entry processor error. */
+        static const int IGNITE_ERR_ENTRY_PROCESSOR = 2015;
+
+        /** Cache atomic update timeout. */
+        static const int IGNITE_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT = 2016;
+
+        /** Cache partial update. */
+        static const int IGNITE_ERR_CACHE_PARTIAL_UPDATE = 2017;
+        
+        /** Transaction optimisitc exception. */
+        static const int IGNITE_ERR_TX_OPTIMISTIC = 2018;
+
+        /** Transaction timeout. */
+        static const int IGNITE_ERR_TX_TIMEOUT = 2019;
+
+        /** Transaction rollback. */
+        static const int IGNITE_ERR_TX_ROLLBACK = 2020;
+
+        /** Transaction heuristic exception. */
+        static const int IGNITE_ERR_TX_HEURISTIC = 2021;
+
+        /** Authentication error. */
+        static const int IGNITE_ERR_AUTHENTICATION = 2022;
+
+        /** Security error. */
+        static const int IGNITE_ERR_SECURITY = 2023;
+        
+        /** Unknown error. */
+        static const int IGNITE_ERR_UNKNOWN = -1;
+
+        /**
+         * Throw an error if code is not IGNITE_SUCCESS.
+         *
+         * @param err Error.
+         */
+        static void ThrowIfNeeded(IgniteError& err);
+
+        /**
+         * Create empty error.
+         */
+        IgniteError();
+
+        /**
+         * Create error with specific code.
+         *
+         * @param code Error code.
+         */
+        IgniteError(const int32_t code);
+
+        /**
+         * Create error with specific code and message.
+         *
+         * @param code Error code.
+         * @param msg Message.
+         */
+        IgniteError(const int32_t code, const char* msg);
+        
+        /**
+         * Copy constructor.
+         *
+         * @param other Other instance.
+         */
+        IgniteError(const IgniteError& other);
+
+        /**
+         * Assignment operator.
+         *
+         * @param other Other instance.
+         * @return Assignment result.
+         */
+        IgniteError& operator=(const IgniteError& other);
+
+        /**
+         * Destructor.
+         */
+        ~IgniteError();
+
+        /**
+         * Get error code.
+         *
+         * @return Error code.
+         */
+        int32_t GetCode();
+
+        /**
+         * Get error message.
+         *
+         * @return Error message.
+         */
+        const char* GetText();
+        
+        /**
+         * Set error.
+         *
+         * @param jniCode Error code.
+         * @param jniCls Error class.
+         * @param jniMsg Error message.
+         * @param err Error.
+         */
+        static void SetError(const int jniCode, const char* jniCls, const char* jniMsg, IgniteError* err);
+    private:
+        /** Error code. */
+        int32_t code;    
+        
+        /** Error message. */
+        char* msg;       
+    };    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/ignition.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/ignition.h b/modules/platform/src/main/cpp/core/include/ignite/ignition.h
new file mode 100644
index 0000000..8d32448
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/ignition.h
@@ -0,0 +1,195 @@
+/*
+ * 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.
+ */
+
+/**
+ * \mainpage Apache Ignite C++ Library
+ *
+ * The Apache Ignite is a proven software solution, which delivers unprecedented speed
+ * and unlimited scale to accelerate your business and time to insights. It enables high-performance transactions,
+ * real-time streaming and fast analytics in a single, comprehensive data access and processing layer. The In-Memory
+ * Data Fabric is designed to easily power both existing and new applications in a distributed, massively
+ * parallel architecture on affordable, industry-standard hardware.
+ * <p>
+ * The Apache Ignite provides a unified API that spans all key types of applications
+ * (Java, .NET, C++) and connects them with multiple data stores containing structured, semi-structured and
+ * unstructured data (SQL, NoSQL, Hadoop). It offers a secure, highly available and manageable data environment
+ * that allows companies to process full ACID transactions and generate valuable insights from real-time,
+ * interactive and batch queries.
+ * <p>
+ * The In-Memory Data Fabric offers a strategic approach to in-memory computing that delivers performance,
+ * scale and comprehensive capabilities far above and beyond what traditional in-memory databases,
+ * data grids or other in-memory-based point solutions can offer by themselves.
+ *
+ * \section ultimate_speed_and_scale Ultimate Speed and Scale
+ *
+ * The Apache Ignite accesses and processes data from distributed enterprise and
+ * cloud-based data stores orders of magnitudes faster, and shares them with today's most demanding transactional,
+ * analytical and hybrid applications. The In-Memory Data Fabric delivers unprecedented throughput
+ * and low latency performance in a virtually unlimited, global scale-out architecture for both new and
+ * existing applications.
+ *
+ * \section comprehensive_and_proven Comprehensive and Proven
+ *
+ * The Apache Ignite is the product of seven years of meticulous research and development,
+ * built from the ground up (i.e. no bolt-on's), and run successfully by hundreds of organizations worldwide.
+ * It is a comprehensive in-memory solution that includes a clustering and compute grid, a database-agnostic data grid,
+ * a real-time streaming engine as well as plug-and-play Hadoop acceleration. The In-Memory Data Fabric
+ * connects multiple data sources (relational, NoSQL, Hadoop) with Java, .NET and C++ applications, and offers
+ * a secure and highly available architecture; it also provides a fully-featured, graphical management interface.
+ * <p>
+ * The Apache Ignite is used today by Fortune 500 companies, top government agencies as well as
+ * innovative mobile and web companies in a broad range of business scenarios, such as automated trading systems,
+ * fraud detection, big data analytics, social networks, online gaming, and bioinformatics.
+ */
+
+#ifndef _IGNITE_IGNITION
+#define _IGNITE_IGNITION
+
+#include "ignite/ignite.h"
+#include "ignite/ignite_configuration.h"
+#include "ignite/ignite_error.h"
+
+namespace ignite
+{
+    /**
+     * This class defines a factory for the main Ignite API.
+     */
+    class IGNITE_IMPORT_EXPORT Ignition
+    {
+    public:
+        /**
+         * Start Ignite instance.
+         *
+         * @param cfg Configuration.
+         * @return Ignite instance or null in case of error.
+         */
+        static Ignite Start(const IgniteConfiguration& cfg);
+
+        /*
+         * Start Ignite instance.
+         *
+         * @param cfg Configuration.
+         * @param err Error.
+         * @return Ignite instance or null in case of error.
+         */
+        static Ignite Start(const IgniteConfiguration& cfg, IgniteError* err);
+
+        /**
+         * Start Ignite instance with specific name.
+         *
+         * @param cfg Configuration.
+         * @param name Ignite name.
+         * @return Ignite instance or null in case of error.
+         */
+        static Ignite Start(const IgniteConfiguration& cfg, const char* name);
+
+        /**
+         * Start Ignite instance with specific name.
+         *
+         * @param cfg Configuration.
+         * @param name Ignite name.
+         * @param err Error.
+         * @return Ignite instance or null in case of error.
+         */
+        static Ignite Start(const IgniteConfiguration& cfg, const char* name, IgniteError* err);
+
+        /**
+         * Get default Ignite instance.
+         *
+         * @return Default Ignite instance.
+         */
+        static Ignite Get();
+
+        /**
+         * Get default Ignite instance.
+         *
+         * @param err Error.
+         * @return Default Ignite instance.
+         */
+        static Ignite Get(IgniteError* err);
+
+        /**
+         * Get Ignite instance with the given name.
+         *
+         * @param name Ignite name.
+         * @return Ignite instance.
+         */
+        static Ignite Get(const char* name);
+
+        /**
+         * Get Ignite instance with the given name.
+         *
+         * @param name Ignite name.
+         * @param err Error.
+         * @return Ignite instance.
+         */
+        static Ignite Get(const char* name, IgniteError* err);
+
+        /**
+         * Stop default Ignite instance.
+         *
+         * @param cancel Cancel flag.
+         * @return True if default Ignite instance was stopped by this call.
+         */
+        static bool Stop(const bool cancel);
+
+        /**
+         * Stop default Ignite instance.
+         *
+         * @param cancel Cancel flag.
+         * @param err Error.
+         * @return True if Ignite instance was stopped by this call.
+         */
+        static bool Stop(const bool cancel, IgniteError* err);
+
+        /**
+         * Stop Ignite instance with the given name.
+         *
+         * @param name Ignite name.
+         * @param cancel Cancel flag.
+         * @return True if Ignite instance was stopped by this call.
+         */
+        static bool Stop(const char* name, const bool cancel);
+
+        /**
+         * Stop Ignite instance with the given name.
+         *
+         * @param name Ignite name.
+         * @param cancel Cancel flag.
+         * @param err Error.
+         * @return True if Ignite instance was stopped by this call.
+         */
+        static bool Stop(const char* name, const bool cancel, IgniteError* err);
+
+        /**
+         * Stop all running Ignite instances.
+         *
+         * @param cancel Cancel flag.
+         */
+        static void StopAll(const bool cancel);
+
+        /**
+         * Stop all running Ignite instances.
+         *
+         * @param cancel Cancel flag.
+         * @param err Error.
+         */
+        static void StopAll(const bool cancel, IgniteError* err);
+    };    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/cache/cache_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/cache/cache_impl.h b/modules/platform/src/main/cpp/core/include/ignite/impl/cache/cache_impl.h
new file mode 100644
index 0000000..8c744e0
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/cache/cache_impl.h
@@ -0,0 +1,418 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_IMPL
+#define _IGNITE_CACHE_IMPL
+
+#include "ignite/cache/query/query_scan.h"
+#include "ignite/cache/query/query_sql.h"
+#include "ignite/cache/query/query_text.h"
+#include "ignite/impl/ignite_environment.h"
+#include "ignite/impl/cache/query/query_impl.h"
+#include "ignite/impl/operations.h"
+
+namespace ignite
+{    
+    namespace impl 
+    {
+        namespace cache
+        {
+            /**
+             * Cache implementation.
+             */
+            class IGNITE_IMPORT_EXPORT CacheImpl
+            {
+            public:
+                /**
+                 * Constructor used to create new instance.
+                 *
+                 * @param name Name.
+                 * @param env Environment.
+                 * @param javaRef Reference to java object.
+                 */
+                CacheImpl(char* name, ignite::common::concurrent::SharedPointer<IgniteEnvironment> env, jobject javaRef);
+                
+                /**
+                 * Destructor.
+                 */
+                ~CacheImpl();
+                
+                /**
+                 * Get name.
+                 *
+                 * @return Cache name.
+                 */
+                char* GetName();
+
+                /**
+                 * Perform IsEmpty.
+                 *
+                 * @param err Error.
+                 * @return Result.
+                 */
+                bool IsEmpty(IgniteError* err);
+
+                /**
+                 * Perform ContainsKey.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                bool ContainsKey(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform ContainsKeys.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                bool ContainsKeys(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform LocalPeek.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param peekModes Peek modes.
+                 * @param err Error.
+                 */
+                void LocalPeek(InputOperation& inOp, OutputOperation& outOp, 
+                    int32_t peekModes, IgniteError* err);
+
+                /**
+                 * Perform Get.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void Get(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+                
+                /**
+                 * Perform GetAll.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void GetAll(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+                /**
+                 * Perform Put.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void Put(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform PutAll.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void PutAll(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform GetAndPut.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void GetAndPut(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+                /**
+                 * Perform GetAndReplace.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void GetAndReplace(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+                /**
+                 * Perform GetAndRemove.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void GetAndRemove(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+                /**
+                 * Perform PutIfAbsent.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result
+                 */
+                bool PutIfAbsent(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform GetAndPutIfAbsent.
+                 *
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void GetAndPutIfAbsent(InputOperation& inOp, OutputOperation& outOp, IgniteError* err);
+
+                /**
+                 * Perform Replace(K, V).
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result
+                 */
+                bool Replace(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform Replace(K, V, V).
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result
+                 */
+                bool ReplaceIfEqual(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform LocalEvict.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void LocalEvict(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform Clear.
+                 *
+                 * @param err Error.
+                 */
+                void Clear(IgniteError* err);
+
+                /**
+                 * Perform Clear.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void Clear(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform ClearAll.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void ClearAll(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform LocalClear.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void LocalClear(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform LocalClearAll.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void LocalClearAll(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform Remove(K).
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result
+                 */
+                bool Remove(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform Remove(K, V).
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result
+                 */
+                bool RemoveIfEqual(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform RemoveAll.
+                 *
+                 * @param inOp Input.
+                 * @param err Error.
+                 */
+                void RemoveAll(InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Perform RemoveAll.
+                 *
+                 * @param err Error.
+                 */
+                void RemoveAll(IgniteError* err);
+
+                /**
+                 * Perform Size.
+                 *
+                 * @param peekModes Peek modes.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                int32_t Size(const int32_t peekModes, IgniteError* err);
+
+                /**
+                 * Perform LocalSize.
+                 * 
+                 * @param peekModes Peek modes.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                int32_t LocalSize(const int32_t peekModes, IgniteError* err);
+
+                /**
+                 * Invoke query.
+                 *
+                 * @param qry Query.
+                 * @param err Error.
+                 * @return Query cursor.
+                 */
+                query::QueryCursorImpl* QuerySql(const ignite::cache::query::SqlQuery& qry, IgniteError* err);
+
+                /*
+                 * Invoke text query.
+                 *
+                 * @param qry Query.
+                 * @param err Error.
+                 * @return Query cursor.
+                 */
+                query::QueryCursorImpl* QueryText(const ignite::cache::query::TextQuery& qry, IgniteError* err);
+
+                /*
+                 * Invoke scan query.
+                 *
+                 * @param qry Query.
+                 * @param err Error.
+                 * @return Query cursor.
+                 */
+                query::QueryCursorImpl* QueryScan(const ignite::cache::query::ScanQuery& qry, IgniteError* err);
+                
+            private:
+                /** Name. */
+                char* name; 
+                
+                /** Environment. */
+                ignite::common::concurrent::SharedPointer<IgniteEnvironment> env;
+                
+                /** Handle to Java object. */
+                jobject javaRef;                     
+
+                IGNITE_NO_COPY_ASSIGNMENT(CacheImpl)
+
+                /**
+                 * Write data to memory.
+                 *
+                 * @param mem Memory.
+                 * @param inOp Input opeartion.
+                 * @param err Error.
+                 * @return Memory pointer.
+                 */
+                int64_t WriteTo(interop::InteropMemory* mem, InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Read data from memory.
+                 *
+                 * @param mem Memory.
+                 * @param outOp Output operation.
+                 */
+                void ReadFrom(interop::InteropMemory* mem, OutputOperation& outOp);
+
+                /**
+                 * Internal cache size routine.
+                 *
+                 * @param peekModes Peek modes.
+                 * @param loc Local flag.
+                 * @param err Error.
+                 * @return Size.
+                 */
+                int SizeInternal(const int32_t peekModes, const bool loc, IgniteError* err);
+
+                /**
+                 * Internal out operation.
+                 *
+                 * @param opType Operation type.
+                 * @param inOp Input.
+                 * @param err Error.
+                 * @return Result.
+                 */
+                bool OutOpInternal(const int32_t opType, InputOperation& inOp, IgniteError* err);
+
+                /**
+                 * Internal out-in operation.
+                 *
+                 * @param opType Operation type.
+                 * @param inOp Input.
+                 * @param outOp Output.
+                 * @param err Error.
+                 */
+                void OutInOpInternal(const int32_t opType, InputOperation& inOp, OutputOperation& outOp, 
+                    IgniteError* err);
+
+                /**
+                 * Internal query execution routine.
+                 *
+                 * @param qry Query.
+                 * @param typ Query type.
+                 * @param err Error.
+                 */
+                template<typename T>
+                query::QueryCursorImpl* QueryInternal(const T& qry, int32_t typ, IgniteError* err)
+                {
+                    ignite::common::java::JniErrorInfo jniErr;
+
+                    ignite::common::concurrent::SharedPointer<interop::InteropMemory> mem = env.Get()->AllocateMemory();
+                    interop::InteropMemory* mem0 = mem.Get();
+                    interop::InteropOutputStream out(mem0);
+                    portable::PortableWriterImpl writer(&out, env.Get()->GetMetadataManager());
+                    ignite::portable::PortableRawWriter rawWriter(&writer);
+
+                    qry.Write(rawWriter);
+
+                    out.Synchronize();
+
+                    jobject qryJavaRef = env.Get()->Context()->CacheOutOpQueryCursor(javaRef, typ, mem.Get()->PointerLong(), 
+                        &jniErr);
+
+                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    if (jniErr.code == ignite::common::java::IGNITE_JNI_ERR_SUCCESS)
+                        return new query::QueryCursorImpl(env, qryJavaRef);
+                    else
+                        return NULL;
+                }
+            };
+        }
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/cache/query/query_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/cache/query/query_impl.h b/modules/platform/src/main/cpp/core/include/ignite/impl/cache/query/query_impl.h
new file mode 100644
index 0000000..e65eeb6
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/cache/query/query_impl.h
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CACHE_QUERY_IMPL
+#define _IGNITE_CACHE_QUERY_IMPL
+
+#include "ignite/ignite_error.h"
+#include "ignite/impl/ignite_environment.h"
+#include "ignite/impl/operations.h"
+
+namespace ignite
+{
+    namespace impl
+    {
+        namespace cache
+        {
+            namespace query
+            {
+                /**
+                 * Query cursor implementation.
+                 */
+                class IGNITE_IMPORT_EXPORT QueryCursorImpl
+                {
+                public:
+                    /**
+                     * Constructor.
+                     * 
+                     * @param env Environment.
+                     * @param javaRef Java reference.
+                     */
+                    QueryCursorImpl(ignite::common::concurrent::SharedPointer<IgniteEnvironment> env, jobject javaRef);
+
+                    /**
+                     * Destructor.
+                     */
+                    ~QueryCursorImpl();
+
+                    /**
+                     * Check whether next result exists.
+                     *
+                     * @param err Error.
+                     * @return True if exists.
+                     */
+                    bool HasNext(IgniteError* err);
+
+                    /**
+                     * Get next object.
+                     * 
+                     * @param op Operation.
+                     * @param err Error.
+                     */
+                    void GetNext(OutputOperation& op, IgniteError* err);
+
+                    /**
+                     * Get all cursor entries.
+                     *
+                     * @param op Operation.
+                     * @param err Error.
+                     */
+                    void GetAll(OutputOperation& op, IgniteError* err);
+
+                private:
+                    /** Environment. */
+                    ignite::common::concurrent::SharedPointer<impl::IgniteEnvironment> env;
+
+                    /** Handle to Java object. */
+                    jobject javaRef;
+
+                    /** Whether iteration methods were called. */
+                    bool iterCalled;
+
+                    /** Whether GetAll() method was called. */
+                    bool getAllCalled;
+
+                    /** Whether next entry is available. */
+                    bool hasNext;
+
+                    IGNITE_NO_COPY_ASSIGNMENT(QueryCursorImpl);
+
+                    /**
+                     * Create Java-side iterator if needed.
+                     *
+                     * @param err Error.
+                     * @return True in case of success, false if an error is thrown.
+                     */
+                    bool CreateIteratorIfNeeded(IgniteError* err);
+
+                    /**
+                     * Check whether Java-side iterator has next element.
+                     *
+                     * @param err Error.
+                     * @return True if the next element is available.
+                     */
+                    bool IteratorHasNext(IgniteError* err);
+                };
+            }
+        }
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/handle_registry.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/handle_registry.h b/modules/platform/src/main/cpp/core/include/ignite/impl/handle_registry.h
new file mode 100644
index 0000000..5e1b60a
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/handle_registry.h
@@ -0,0 +1,202 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_HANDLE_REGISTRY
+#define _IGNITE_HANDLE_REGISTRY
+
+#include <map>
+#include <stdint.h>
+
+#include <ignite/common/concurrent.h>
+
+namespace ignite
+{
+    namespace impl
+    {
+        /**
+         * Something what can be registered inside handle registry.
+         */
+        class IGNITE_IMPORT_EXPORT HandleRegistryEntry
+        {
+        public:
+            /**
+             * Destructor.
+             */
+            virtual ~HandleRegistryEntry();
+        };
+
+        /**
+         * Handle registry segment containing thread-specific data for slow-path access.
+         */
+        class IGNITE_IMPORT_EXPORT HandleRegistrySegment
+        {
+        public:
+            /**
+             * Constructor.
+             */
+            HandleRegistrySegment();
+
+            /**
+             * Destructor.
+             */
+            ~HandleRegistrySegment();
+
+            /**
+             * Get entry from segment.
+             *
+             * @param hnd Handle.
+             * @return Associated entry or NULL if it doesn't exists.
+             */
+            ignite::common::concurrent::SharedPointer<HandleRegistryEntry> Get(int64_t hnd);
+
+            /**
+             * Put entry into segment.
+             *
+             * @param hnd Handle.
+             * @param entry Associated entry (cannot be NULL).
+             */
+            void Put(int64_t hnd, const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& entry);
+
+            /**
+             * Remove entry from the segment.
+             *
+             * @param hnd Handle.
+             */
+            void Remove(int64_t hnd);            
+
+            /**
+             * Clear all entries from the segment.
+             */
+            void Clear();
+        private:
+            /** Map with data. */
+            std::map<int64_t, ignite::common::concurrent::SharedPointer<HandleRegistryEntry>>* map;
+
+            /** Mutex. */
+            ignite::common::concurrent::CriticalSection* mux;
+
+            IGNITE_NO_COPY_ASSIGNMENT(HandleRegistrySegment);
+        };
+
+        /**
+         * Handle registry.
+         */
+        class IGNITE_IMPORT_EXPORT HandleRegistry
+        {
+        public:
+            /**
+             * Constructor.
+             *
+             * @param fastCap Fast-path capacity.
+             * @param segmentCnt Slow-path segments count.
+             */
+            HandleRegistry(int32_t fastCap, int32_t slowSegmentCnt);
+
+            /**
+             * Destructor.
+             */
+            ~HandleRegistry();
+
+            /**
+             * Allocate handle.
+             *
+             * @param target Target.
+             * @return Handle.
+             */
+            int64_t Allocate(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+            /**
+             * Allocate handle in critical mode.
+             *
+             * @param target Target.
+             * @return Handle.
+             */
+            int64_t AllocateCritical(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+            /**
+             * Allocate handle in safe mode.
+             *
+             * @param target Target.
+             * @return Handle.
+             */
+            int64_t AllocateSafe(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+            /**
+             * Allocate handle in critical and safe modes.
+             *
+             * @param target Target.
+             * @return Handle.
+             */
+            int64_t AllocateCriticalSafe(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target);
+
+            /**
+             * Release handle.
+             *
+             * @param hnd Handle.
+             */
+            void Release(int64_t hnd);
+
+            /**
+             * Get target.
+             *
+             * @param hnd Handle.
+             * @param Target.
+             */
+            ignite::common::concurrent::SharedPointer<HandleRegistryEntry> Get(int64_t hnd);
+
+            /**
+             * Close the registry.
+             */
+            void Close();
+        private:
+            /** Fast-path container capacity. */
+            int32_t fastCap;                     
+
+            /** Fast-path counter. */
+            int32_t fastCtr;               
+
+            /** Fast-path container. */
+            ignite::common::concurrent::SharedPointer<HandleRegistryEntry>* fast;
+
+            /** Amount of slow-path segments. */
+            int32_t slowSegmentCnt;            
+
+            /** Slow-path counter. */
+            int64_t slowCtr;                                                         
+            
+            /** Slow-path segments. */
+            HandleRegistrySegment** slow;                                            
+
+            /** Close flag. */
+            int32_t closed;                                                           
+
+            IGNITE_NO_COPY_ASSIGNMENT(HandleRegistry);
+
+            /**
+             * Internal allocation routine.
+             *
+             * @param target Target.
+             * @param Critical mode flag.
+             * @param Safe mode flag.
+             */
+            int64_t Allocate0(const ignite::common::concurrent::SharedPointer<HandleRegistryEntry>& target,
+                bool critical, bool safe);
+        };
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_environment.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_environment.h b/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_environment.h
new file mode 100644
index 0000000..2f195b2
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_environment.h
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ENVIRONMENT
+#define _IGNITE_ENVIRONMENT
+
+#include <ignite/common/concurrent.h>
+#include <ignite/common/java.h>
+
+#include "ignite/impl/interop/interop_memory.h"
+#include "portable/portable_metadata_manager.h"
+
+namespace ignite 
+{    
+    namespace impl 
+    {
+        /**
+         * Defines environment in which Ignite operates.
+         */
+        class IGNITE_IMPORT_EXPORT IgniteEnvironment
+        {                
+        public:
+            /**
+             * Default constructor.
+             */
+            IgniteEnvironment();
+
+            /**
+             * Destructor.
+             */
+            ~IgniteEnvironment();
+
+            /**
+             * Populate callback handlers.
+             *
+             * @param Target (current env wrapped into a shared pointer).
+             * @return JNI handlers.
+             */
+            ignite::common::java::JniHandlers GetJniHandlers(ignite::common::concurrent::SharedPointer<IgniteEnvironment>* target);
+                
+            /**
+             * Perform initialization on successful start.
+             *
+             * @param ctx Context.
+             */
+            void Initialize(ignite::common::concurrent::SharedPointer<ignite::common::java::JniContext> ctx);
+
+            /**
+             * Start callback.
+             *
+             * @param memPtr Memory pointer.
+             */
+            void OnStartCallback(long long memPtr);        
+            
+            /**
+             * Get name of Ignite instance.
+             *
+             * @return Name.
+             */
+            char* InstanceName();
+
+            /**
+             * Get JNI context.
+             *
+             * @return Context.
+             */
+            ignite::common::java::JniContext* Context();
+
+            /**
+             * Get memory for interop operations.
+             *
+             * @return Memory.
+             */
+            ignite::common::concurrent::SharedPointer<interop::InteropMemory> AllocateMemory();
+
+            /**
+             * Get memory chunk for interop operations with desired capacity.
+             *
+             * @param cap Capacity.
+             * @return Memory.
+             */
+            ignite::common::concurrent::SharedPointer<interop::InteropMemory> AllocateMemory(int32_t cap);
+
+            /**
+             * Get memory chunk located at the given pointer.
+             *
+             * @param memPtr Memory pointer.
+             * @retrun Memory.
+             */
+            ignite::common::concurrent::SharedPointer<interop::InteropMemory> GetMemory(int64_t memPtr);
+
+            /**
+             * Get metadata manager.
+             *
+             * @param Metadata manager.
+             */
+            portable::PortableMetadataManager* GetMetadataManager();
+        private:
+            /** Context to access Java. */
+            ignite::common::concurrent::SharedPointer<ignite::common::java::JniContext> ctx;
+
+            /** Startup latch. */
+            ignite::common::concurrent::SingleLatch* latch;
+
+            /** Ignite name. */
+            char* name;
+
+            /** Metadata manager. */
+            portable::PortableMetadataManager* metaMgr;       
+
+            IGNITE_NO_COPY_ASSIGNMENT(IgniteEnvironment);
+        };
+    }    
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/58a665aa/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_impl.h
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_impl.h b/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_impl.h
new file mode 100644
index 0000000..52472c6
--- /dev/null
+++ b/modules/platform/src/main/cpp/core/include/ignite/impl/ignite_impl.h
@@ -0,0 +1,146 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_IMPL
+#define _IGNITE_IMPL
+
+#include <ignite/common/concurrent.h>
+#include <ignite/common/java.h>
+
+#include "ignite/impl/cache/cache_impl.h"
+#include "ignite/impl/ignite_environment.h"
+#include "ignite/impl/utils.h"
+
+namespace ignite 
+{    
+    namespace impl 
+    {            
+        /**
+         * Ignite implementation.
+         */
+        class IgniteImpl
+        {
+            friend class Ignite;
+        public:
+            /**
+             * Constructor used to create new instance.
+             *
+             * @param env Environment.
+             * @param javaRef Reference to java object.
+             */
+            IgniteImpl(ignite::common::concurrent::SharedPointer<IgniteEnvironment> env, jobject javaRef);
+            
+            /**
+             * Destructor.
+             */
+            ~IgniteImpl();
+
+            /**
+             * Get name of the Ignite.
+             *
+             * @param Name.
+             */
+            char* GetName();
+
+            /**
+             * Get cache.
+             *
+             * @param name Cache name.
+             * @param err Error.
+             */
+            template<typename K, typename V> 
+            cache::CacheImpl* GetCache(const char* name, IgniteError* err)
+            {
+                ignite::common::java::JniErrorInfo jniErr;
+
+                jobject cacheJavaRef = env.Get()->Context()->ProcessorCache(javaRef, name, &jniErr);
+
+                if (!cacheJavaRef)
+                {
+                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    return NULL;
+                }
+
+                char* name0 = utils::CopyChars(name);
+
+                return new cache::CacheImpl(name0, env, cacheJavaRef);
+            }
+
+            /**
+             * Get or create cache.
+             *
+             * @param name Cache name.
+             * @param err Error.
+             */
+            template<typename K, typename V>
+            cache::CacheImpl* GetOrCreateCache(const char* name, IgniteError* err)
+            {
+                ignite::common::java::JniErrorInfo jniErr;
+
+                jobject cacheJavaRef = env.Get()->Context()->ProcessorGetOrCreateCache(javaRef, name, &jniErr);
+
+                if (!cacheJavaRef)
+                {
+                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    return NULL;
+                }
+
+                char* name0 = utils::CopyChars(name);
+
+                return new cache::CacheImpl(name0, env, cacheJavaRef);
+            }
+
+            /**
+             * Create cache.
+             *
+             * @param name Cache name.
+             * @param err Error.
+             */
+            template<typename K, typename V>
+            cache::CacheImpl* CreateCache(const char* name, IgniteError* err)
+            {
+                ignite::common::java::JniErrorInfo jniErr;
+
+                jobject cacheJavaRef = env.Get()->Context()->ProcessorCreateCache(javaRef, name, &jniErr);
+
+                if (!cacheJavaRef)
+                {
+                    IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+                    return NULL;
+                }
+
+                char* name0 = utils::CopyChars(name);
+
+                return new cache::CacheImpl(name0, env, cacheJavaRef);
+            }
+        private:
+            /** Environment. */
+            ignite::common::concurrent::SharedPointer<IgniteEnvironment> env;
+            
+            /** Native Java counterpart. */
+            jobject javaRef;   
+            
+            IGNITE_NO_COPY_ASSIGNMENT(IgniteImpl)
+        };
+    }
+    
+}
+
+#endif
\ No newline at end of file


[29/50] [abbrv] ignite git commit: minot javadoc fix

Posted by ak...@apache.org.
minot javadoc fix


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

Branch: refs/heads/ignite-843
Commit: 77fc969262584d82c5193ad347080876832f623f
Parents: 8901575
Author: Anton Vinogradov <av...@gridgain.com>
Authored: Thu Sep 3 23:24:21 2015 +0300
Committer: Anton Vinogradov <av...@gridgain.com>
Committed: Thu Sep 3 23:24:21 2015 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       | 31 ++++++++------------
 1 file changed, 12 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/77fc9692/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 1bbc110..85eed47 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -17,26 +17,10 @@
 
 package org.apache.ignite.configuration;
 
-import java.io.Serializable;
-import java.util.Collection;
-import javax.cache.Cache;
-import javax.cache.CacheException;
-import javax.cache.configuration.CompleteConfiguration;
-import javax.cache.configuration.Factory;
-import javax.cache.configuration.MutableConfiguration;
-import javax.cache.expiry.ExpiryPolicy;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheEntryProcessor;
-import org.apache.ignite.cache.CacheInterceptor;
-import org.apache.ignite.cache.CacheMemoryMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.CacheRebalanceMode;
-import org.apache.ignite.cache.CacheTypeMetadata;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.AffinityFunction;
 import org.apache.ignite.cache.affinity.AffinityKeyMapper;
 import org.apache.ignite.cache.eviction.EvictionFilter;
@@ -52,6 +36,15 @@ import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.plugin.CachePluginConfiguration;
 import org.jetbrains.annotations.Nullable;
 
+import javax.cache.Cache;
+import javax.cache.CacheException;
+import javax.cache.configuration.CompleteConfiguration;
+import javax.cache.configuration.Factory;
+import javax.cache.configuration.MutableConfiguration;
+import javax.cache.expiry.ExpiryPolicy;
+import java.io.Serializable;
+import java.util.Collection;
+
 /**
  * This class defines grid cache configuration. This configuration is passed to
  * grid via {@link IgniteConfiguration#getCacheConfiguration()} method. It defines all configuration
@@ -1806,7 +1799,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * Following validator allows to put data only in case topology contains exactly 2 nodes:
      * <pre>{@code
      * new TopologyValidator() {
-     *    @Override public boolean validate(Collection<ClusterNode> nodes) {
+     *    public boolean validate(Collection<ClusterNode> nodes) {
      *       return nodes.size() == 2;
      *    }
      * }
@@ -1835,7 +1828,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * Following validator allows to put data only in case topology contains exactly 2 nodes:
      * <pre>{@code
      * new TopologyValidator() {
-     *    @Override public boolean validate(Collection<ClusterNode> nodes) {
+     *    public boolean validate(Collection<ClusterNode> nodes) {
      *       return nodes.size() == 2;
      *    }
      * }


[11/50] [abbrv] ignite git commit: ignite-1273: added ability to modify arrays returned from PortableBuilder and fixed cyclic references processing for arrays and collections in PortableMarshaller

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMap.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMap.java
deleted file mode 100644
index eed8121..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMap.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.AbstractMap;
-import java.util.AbstractSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-import org.jetbrains.annotations.Nullable;
-
-/**
- *
- */
-class PortableLazyMap extends AbstractMap<Object, Object> implements PortableBuilderSerializationAware {
-    /** */
-    private final PortableBuilderReader reader;
-
-    /** */
-    private final int off;
-
-    /** */
-    private Map<Object, Object> delegate;
-
-    /**
-     * @param reader Reader.
-     * @param off Offset.
-     */
-    private PortableLazyMap(PortableBuilderReader reader, int off) {
-        this.reader = reader;
-        this.off = off;
-    }
-
-    /**
-     * @param reader Reader.
-     * @return PortableLazyMap.
-     */
-    @Nullable public static PortableLazyMap parseMap(PortableBuilderReader reader) {
-        int off = reader.position() - 1;
-
-        int size = reader.readInt();
-
-        reader.skip(1); // map type.
-
-        for (int i = 0; i < size; i++) {
-            reader.skipValue(); // skip key
-            reader.skipValue(); // skip value
-        }
-
-        return new PortableLazyMap(reader, off);
-    }
-
-    /**
-     *
-     */
-    private void ensureDelegateInit() {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
-
-            delegate = new LinkedHashMap<>();
-
-            for (int i = 0; i < size; i++)
-                delegate.put(PortableUtils.unwrapLazy(reader.parseValue()), reader.parseValue());
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (delegate == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
-            writer.write(reader.array(), off, hdrSize);
-
-            reader.position(off + hdrSize);
-
-            for (int i = 0; i < size; i++) {
-                ctx.writeValue(writer, reader.parseValue()); // key
-                ctx.writeValue(writer, reader.parseValue()); // value
-            }
-        }
-        else {
-            writer.writeByte(GridPortableMarshaller.MAP);
-            writer.writeInt(delegate.size());
-
-            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
-
-            writer.writeByte(colType);
-
-            for (Entry<Object, Object> entry : delegate.entrySet()) {
-                ctx.writeValue(writer, entry.getKey());
-                ctx.writeValue(writer, entry.getValue());
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        if (delegate == null)
-            return reader.readIntAbsolute(off + 1);
-
-        return delegate.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean containsKey(Object key) {
-        ensureDelegateInit();
-
-        return delegate.containsKey(key);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean containsValue(Object val) {
-        return values().contains(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Set<Object> keySet() {
-        ensureDelegateInit();
-
-        return delegate.keySet();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() {
-        if (delegate == null)
-            delegate = new LinkedHashMap<>();
-        else
-            delegate.clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object get(Object key) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.get(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object put(Object key, Object val) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.put(key, val));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object remove(Object key) {
-        ensureDelegateInit();
-
-        return PortableUtils.unwrapLazy(delegate.remove(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Set<Entry<Object, Object>> entrySet() {
-        ensureDelegateInit();
-
-        return new AbstractSet<Entry<Object, Object>>() {
-            @Override public boolean contains(Object o) {
-                throw new UnsupportedOperationException();
-            }
-
-            @Override public Iterator<Entry<Object, Object>> iterator() {
-                return new Iterator<Entry<Object, Object>>() {
-                    /** */
-                    private final Iterator<Entry<Object, Object>> itr = delegate.entrySet().iterator();
-
-                    @Override public boolean hasNext() {
-                        return itr.hasNext();
-                    }
-
-                    @Override public Entry<Object, Object> next() {
-                        Entry<Object, Object> res = itr.next();
-
-                        final Object val = res.getValue();
-
-                        if (val instanceof PortableLazyValue) {
-                            return new SimpleEntry<Object, Object>(res.getKey(), val) {
-                                private static final long serialVersionUID = 0L;
-
-                                @Override public Object getValue() {
-                                    return ((PortableLazyValue)val).value();
-                                }
-                            };
-                        }
-
-                        return res;
-                    }
-
-                    @Override public void remove() {
-                        itr.remove();
-                    }
-                };
-            }
-
-            @Override public int size() {
-                return delegate.size();
-            }
-        };
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMapEntry.java
deleted file mode 100644
index 1970d21..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyMapEntry.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.Map;
-
-/**
- *
- */
-class PortableLazyMapEntry implements Map.Entry<Object, Object>, PortableBuilderSerializationAware {
-    /** */
-    private final Object key;
-
-    /** */
-    private Object val;
-
-    /**
-     * @param reader GridMutablePortableReader
-     */
-    PortableLazyMapEntry(PortableBuilderReader reader) {
-        key = reader.parseValue();
-        val = reader.parseValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object getKey() {
-        return PortableUtils.unwrapLazy(key);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object getValue() {
-        return PortableUtils.unwrapLazy(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object setValue(Object val) {
-        Object res = getValue();
-
-        this.val = val;
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        writer.writeByte(GridPortableMarshaller.MAP_ENTRY);
-
-        ctx.writeValue(writer, key);
-        ctx.writeValue(writer, val);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazySet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazySet.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazySet.java
deleted file mode 100644
index 3e1dc92..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazySet.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.Collection;
-import java.util.Set;
-import org.apache.ignite.internal.util.typedef.internal.U;
-
-/**
- *
- */
-class PortableLazySet extends PortableAbstractLazyValue {
-    /** */
-    private final int off;
-
-    /**
-     * @param reader Reader.
-     * @param size Size.
-     */
-    PortableLazySet(PortableBuilderReader reader, int size) {
-        super(reader, reader.position() - 1);
-
-        off = reader.position() - 1/* flag */ - 4/* size */ - 1/* col type */;
-
-        assert size >= 0;
-
-        for (int i = 0; i < size; i++)
-            reader.skipValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (val == null) {
-            int size = reader.readIntAbsolute(off + 1);
-
-            int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */;
-            writer.write(reader.array(), off, hdrSize);
-
-            reader.position(off + hdrSize);
-
-            for (int i = 0; i < size; i++) {
-                Object o = reader.parseValue();
-
-                ctx.writeValue(writer, o);
-            }
-        }
-        else {
-            Collection<Object> c = (Collection<Object>)val;
-
-            writer.writeByte(GridPortableMarshaller.COL);
-            writer.writeInt(c.size());
-
-            byte colType = reader.array()[off + 1 /* flag */ + 4 /* size */];
-            writer.writeByte(colType);
-
-            for (Object o : c)
-                ctx.writeValue(writer, o);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Object init() {
-        int size = reader.readIntAbsolute(off + 1);
-
-        reader.position(off + 1/* flag */ + 4/* size */ + 1/* col type */);
-
-        Set<Object> res = U.newLinkedHashSet(size);
-
-        for (int i = 0; i < size; i++)
-            res.add(PortableUtils.unwrapLazy(reader.parseValue()));
-
-        return res;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyValue.java
deleted file mode 100644
index 43728b7..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableLazyValue.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-/**
- *
- */
-interface PortableLazyValue extends PortableBuilderSerializationAware {
-    /**
-     * @return Value.
-     */
-    public Object value();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectArrayLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectArrayLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectArrayLazyValue.java
deleted file mode 100644
index 897e8e8..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectArrayLazyValue.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.portable.PortableInvalidClassException;
-
-/**
- *
- */
-class PortableObjectArrayLazyValue extends PortableAbstractLazyValue {
-    /** */
-    private Object[] lazyValsArr;
-
-    /** */
-    private int compTypeId;
-
-    /** */
-    private String clsName;
-
-    /**
-     * @param reader Reader.
-     */
-    protected PortableObjectArrayLazyValue(PortableBuilderReader reader) {
-        super(reader, reader.position() - 1);
-
-        int typeId = reader.readInt();
-
-        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
-            clsName = reader.readString();
-
-            Class cls;
-
-            try {
-                // TODO: IGNITE-1272 - Is class loader needed here?
-                cls = U.forName(reader.readString(), null);
-            }
-            catch (ClassNotFoundException e) {
-                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
-            }
-
-            compTypeId = reader.portableContext().descriptorForClass(cls).typeId();
-        }
-        else {
-            compTypeId = typeId;
-            clsName = null;
-        }
-
-        int size = reader.readInt();
-
-        lazyValsArr = new Object[size];
-
-        for (int i = 0; i < size; i++)
-            lazyValsArr[i] = reader.parseValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Object init() {
-        for (int i = 0; i < lazyValsArr.length; i++) {
-            if (lazyValsArr[i] instanceof PortableLazyValue)
-                lazyValsArr[i] = ((PortableLazyValue)lazyValsArr[i]).value();
-        }
-
-        return lazyValsArr;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (clsName == null)
-            ctx.writeArray(writer, GridPortableMarshaller.OBJ_ARR, lazyValsArr, compTypeId);
-        else
-            ctx.writeArray(writer, GridPortableMarshaller.OBJ_ARR, lazyValsArr, clsName);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainLazyValue.java
deleted file mode 100644
index d08d09b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainLazyValue.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-/**
- *
- */
-class PortablePlainLazyValue extends PortableAbstractLazyValue {
-    /** */
-    protected final int len;
-
-    /**
-     * @param reader Reader
-     * @param valOff Offset
-     * @param len Length.
-     */
-    protected PortablePlainLazyValue(PortableBuilderReader reader, int valOff, int len) {
-        super(reader, valOff);
-
-        this.len = len;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Object init() {
-        return reader.reader().unmarshal(valOff);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        writer.write(reader.array(), valOff, len);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainPortableObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainPortableObject.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainPortableObject.java
deleted file mode 100644
index cfaa04f..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortablePlainPortableObject.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.portable.PortableObject;
-
-/**
- *
- */
-public class PortablePlainPortableObject implements PortableLazyValue {
-    /** */
-    private final PortableObject portableObj;
-
-    /**
-     * @param portableObj Portable object.
-     */
-    public PortablePlainPortableObject(PortableObject portableObj) {
-        this.portableObj = portableObj;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object value() {
-        return portableObj;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        PortableObject val = portableObj;
-
-        if (val instanceof PortableObjectOffheapImpl)
-            val = ((PortableObjectOffheapImpl)val).heapCopy();
-
-        writer.doWritePortableObject((PortableObjectImpl)val);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
index f702e06..83ccb65 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
@@ -156,7 +156,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @param start Start.
      * @param ldr Class loader.
      */
-    PortableReaderExImpl(PortableContext ctx, byte[] arr, int start, ClassLoader ldr) {
+    public PortableReaderExImpl(PortableContext ctx, byte[] arr, int start, ClassLoader ldr) {
         this(ctx, new PortableHeapInputStream(arr), start, ldr, new PortableReaderContext());
     }
 
@@ -256,7 +256,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Unmarshalled value.
      * @throws PortableException In case of error.
      */
-    Object unmarshal(int offset) throws PortableException {
+    public Object unmarshal(int offset) throws PortableException {
         off = offset;
 
         return off >= 0 ? unmarshal(false) : null;
@@ -586,6 +586,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != BYTE_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -609,6 +612,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != SHORT_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -632,6 +638,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != INT_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -655,6 +664,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != LONG_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -678,6 +690,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != FLOAT_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -701,6 +716,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != DOUBLE_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -724,6 +742,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != CHAR_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -747,6 +768,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != BOOLEAN_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -770,6 +794,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != DECIMAL_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -793,6 +820,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != STRING_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -816,6 +846,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != UUID_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -839,6 +872,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != DATE_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -862,6 +898,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != OBJ_ARR)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -887,6 +926,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != COL)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -912,6 +954,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != MAP)
                 throw new PortableException("Invalid flag value: " + flag);
 
@@ -935,10 +980,13 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             if (flag == NULL)
                 return null;
 
+            if (flag == HANDLE)
+                return readHandleField();
+
             if (flag != MAP_ENTRY)
                 throw new PortableException("Invalid flag value: " + flag);
 
-            return new GridMapEntry<>(doReadObject(false), doReadObject(false));
+            return doReadMapEntry(false, true);
         }
         else
             return null;
@@ -1059,6 +1107,33 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
         rCtx.setObjectHandler(start, obj);
     }
 
+    /**
+     * @param obj Object.
+     * @param pos Position.
+     */
+    void setHandler(Object obj, int pos) {
+        rCtx.setObjectHandler(pos, obj);
+    }
+
+    /**
+     * Recreating field value from a handle.
+     *
+     * @param <T> Field type.
+     * @return Field.
+     */
+    private <T> T readHandleField() {
+        int handle = (off - 1) - doReadInt(false);
+
+        Object obj = rCtx.getObjectByHandle(handle);
+
+        if (obj == null) {
+            off = handle;
+
+            obj = doReadObject(false);
+        }
+
+        return (T)obj;
+    }
     /** {@inheritDoc} */
     @Override public byte readByte(String fieldName) throws PortableException {
         Byte val = readByte(fieldId(fieldName));
@@ -1676,7 +1751,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
                 else
                     po = in.offheapPointer() > 0
                         ? new PortableObjectOffheapImpl(ctx, in.offheapPointer(), start,
-                                                            in.remaining() + in.position())
+                        in.remaining() + in.position())
                         : new PortableObjectImpl(ctx, in.array(), start);
 
                 rCtx.setPortableHandler(start, po);
@@ -1805,7 +1880,6 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
 
                 return obj;
 
-
             default:
                 throw new PortableException("Invalid flag value: " + flag);
         }
@@ -2306,12 +2380,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private byte[] doReadByteArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         byte[] arr = in.readByteArray(len);
 
+        setHandler(arr, hPos);
+
         if (raw)
             rawOff += len;
         else
@@ -2325,12 +2403,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private short[] doReadShortArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         short[] arr = in.readShortArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 1;
 
         if (raw)
@@ -2346,12 +2428,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private int[] doReadIntArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         int[] arr = in.readIntArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 2;
 
         if (raw)
@@ -2367,12 +2453,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private long[] doReadLongArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         long[] arr = in.readLongArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 3;
 
         if (raw)
@@ -2388,12 +2478,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private float[] doReadFloatArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         float[] arr = in.readFloatArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 2;
 
         if (raw)
@@ -2409,12 +2503,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private double[] doReadDoubleArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         double[] arr = in.readDoubleArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 3;
 
         if (raw)
@@ -2430,12 +2528,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private char[] doReadCharArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         char[] arr = in.readCharArray(len);
 
+        setHandler(arr, hPos);
+
         int bytes = len << 1;
 
         if (raw)
@@ -2451,12 +2553,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @return Value.
      */
     private boolean[] doReadBooleanArray(boolean raw) {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         in.position(raw ? rawOff : off);
 
         boolean[] arr = in.readBooleanArray(len);
 
+        setHandler(arr, hPos);
+
         if (raw)
             rawOff += len;
         else
@@ -2471,10 +2577,14 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private BigDecimal[] doReadDecimalArray(boolean raw) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         BigDecimal[] arr = new BigDecimal[len];
 
+        setHandler(arr, hPos);
+
         for (int i = 0; i < len; i++) {
             byte flag = doReadByte(raw);
 
@@ -2497,10 +2607,14 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private String[] doReadStringArray(boolean raw) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         String[] arr = new String[len];
 
+        setHandler(arr, hPos);
+
         for (int i = 0; i < len; i++) {
             byte flag = doReadByte(raw);
 
@@ -2523,10 +2637,14 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private UUID[] doReadUuidArray(boolean raw) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         UUID[] arr = new UUID[len];
 
+        setHandler(arr, hPos);
+
         for (int i = 0; i < len; i++) {
             byte flag = doReadByte(raw);
 
@@ -2549,10 +2667,14 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private Date[] doReadDateArray(boolean raw) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int len = doReadInt(raw);
 
         Date[] arr = new Date[len];
 
+        setHandler(arr, hPos);
+
         for (int i = 0; i < len; i++) {
             byte flag = doReadByte(raw);
 
@@ -2576,12 +2698,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private Object[] doReadObjectArray(boolean raw, boolean deep) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         Class compType = doReadClass(raw);
 
         int len = doReadInt(raw);
 
         Object[] arr = deep ? (Object[])Array.newInstance(compType, len) : new Object[len];
 
+        setHandler(arr, hPos);
+
         for (int i = 0; i < len; i++)
             arr[i] = deep ? doReadObject(raw) : unmarshal(raw);
 
@@ -2598,6 +2724,8 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
     @SuppressWarnings("unchecked")
     private Collection<?> doReadCollection(boolean raw, boolean deep, @Nullable Class<? extends Collection> cls)
         throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int size = doReadInt(raw);
 
         assert size >= 0;
@@ -2667,6 +2795,8 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             }
         }
 
+        setHandler(col, hPos);
+
         for (int i = 0; i < size; i++)
             col.add(deep ? doReadObject(raw) : unmarshal(raw));
 
@@ -2683,6 +2813,8 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
     @SuppressWarnings("unchecked")
     private Map<?, ?> doReadMap(boolean raw, boolean deep, @Nullable Class<? extends Map> cls)
         throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         int size = doReadInt(raw);
 
         assert size >= 0;
@@ -2742,6 +2874,8 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             }
         }
 
+        setHandler(map, hPos);
+
         for (int i = 0; i < size; i++)
             map.put(deep ? doReadObject(raw) : unmarshal(raw), deep ? doReadObject(raw) : unmarshal(raw));
 
@@ -2755,10 +2889,16 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
      * @throws PortableException In case of error.
      */
     private Map.Entry<?, ?> doReadMapEntry(boolean raw, boolean deep) throws PortableException {
+        int hPos = (raw ? rawOff : off) - 1;
+
         Object val1 = deep ? doReadObject(raw) : unmarshal(raw);
         Object val2 = deep ? doReadObject(raw) : unmarshal(raw);
 
-        return new GridMapEntry<>(val1, val2);
+        GridMapEntry entry = new GridMapEntry<>(val1, val2);
+
+        setHandler(entry, hPos);
+
+        return entry;
     }
 
     /**
@@ -3017,4 +3157,4 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
     @Override public void close() throws IOException {
         // No-op.
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index ce77783..7259cc9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -33,6 +33,7 @@ import java.util.TreeSet;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListSet;
+import org.apache.ignite.internal.portable.builder.PortableLazyValue;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.portable.PortableObject;
 import org.jetbrains.annotations.Nullable;
@@ -359,6 +360,16 @@ public class PortableUtils {
     }
 
     /**
+     * Checks whether an array type values can or can not contain references to other object.
+     *
+     * @param type Array type.
+     * @return {@code true} if content of serialized array value cannot contain references to other object.
+     */
+    public static boolean isPlainArrayType(int type) {
+        return type >= BYTE_ARR && type <= DATE_ARR;
+    }
+
+    /**
      * @param cls Class.
      * @return Portable field type.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableValueWithType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableValueWithType.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableValueWithType.java
deleted file mode 100644
index ebc68c1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableValueWithType.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- *
- */
-class PortableValueWithType implements PortableLazyValue {
-    /** */
-    private byte type;
-
-    /** */
-    private Object val;
-
-    /**
-     * @param type Type
-     * @param val Value.
-     */
-    PortableValueWithType(byte type, Object val) {
-        this.type = type;
-        this.val = val;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
-        if (val instanceof PortableBuilderSerializationAware)
-            ((PortableBuilderSerializationAware)val).writeTo(writer, ctx);
-        else
-            ctx.writeValue(writer, val);
-    }
-
-    /** {@inheritDoc} */
-    public String typeName() {
-        return CacheObjectPortableProcessorImpl.fieldTypeName(type);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object value() {
-        if (val instanceof PortableLazyValue)
-            return ((PortableLazyValue)val).value();
-
-        return val;
-    }
-
-    /**
-     * @param val New value.
-     */
-    public void value(Object val) {
-        this.val = val;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(PortableValueWithType.class, this);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
index 6bcce2b..364d5f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
@@ -156,7 +156,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      * @param off Start offset.
      * @param typeId Type ID.
      */
-    PortableWriterExImpl(PortableContext ctx, int off, int typeId, boolean metaEnabled) {
+    public PortableWriterExImpl(PortableContext ctx, int off, int typeId, boolean metaEnabled) {
         this(ctx, off);
 
         this.typeId = typeId;
@@ -320,14 +320,14 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @return Array.
      */
-    byte[] array() {
+    public byte[] array() {
         return wCtx.out.arrayCopy();
     }
 
     /**
      * @return Output stream.
      */
-    PortableOutputStream outputStream() {
+    public PortableOutputStream outputStream() {
         return wCtx.out;
     }
 
@@ -351,7 +351,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      * @param bytes Number of bytes to reserve.
      * @return Offset.
      */
-    int reserve(int bytes) {
+    public int reserve(int bytes) {
         int pos = wCtx.out.position();
 
         wCtx.out.position(pos + bytes);
@@ -363,7 +363,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      * @param bytes Number of bytes to reserve.
      * @return Offset.
      */
-    int reserveAndMark(int bytes) {
+    public int reserveAndMark(int bytes) {
         int off0 = reserve(bytes);
 
         mark = wCtx.out.position();
@@ -374,21 +374,21 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param off Offset.
      */
-    void writeDelta(int off) {
+    public void writeDelta(int off) {
         wCtx.out.writeInt(off, wCtx.out.position() - mark);
     }
 
     /**
      *
      */
-    void writeLength() {
+    public void writeLength() {
         wCtx.out.writeInt(start + TOTAL_LEN_POS, wCtx.out.position() - start);
     }
 
     /**
      *
      */
-    void writeRawOffsetIfNeeded() {
+    public void writeRawOffsetIfNeeded() {
         if (allowFields)
             wCtx.out.writeInt(start + RAW_DATA_OFF_POS, wCtx.out.position() - start);
     }
@@ -416,63 +416,63 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param val Value.
      */
-    void doWriteByte(byte val) {
+    public void doWriteByte(byte val) {
         wCtx.out.writeByte(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteShort(short val) {
+    public void doWriteShort(short val) {
         wCtx.out.writeShort(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteInt(int val) {
+    public void doWriteInt(int val) {
         wCtx.out.writeInt(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteLong(long val) {
+    public void doWriteLong(long val) {
         wCtx.out.writeLong(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteFloat(float val) {
+    public void doWriteFloat(float val) {
         wCtx.out.writeFloat(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteDouble(double val) {
+    public void doWriteDouble(double val) {
         wCtx.out.writeDouble(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteChar(char val) {
+    public void doWriteChar(char val) {
         wCtx.out.writeChar(val);
     }
 
     /**
      * @param val Value.
      */
-    void doWriteBoolean(boolean val) {
+    public void doWriteBoolean(boolean val) {
         wCtx.out.writeBoolean(val);
     }
 
     /**
      * @param val String value.
      */
-    void doWriteDecimal(@Nullable BigDecimal val) {
+    public void doWriteDecimal(@Nullable BigDecimal val) {
         if (val == null)
             doWriteByte(NULL);
         else {
@@ -498,7 +498,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param val String value.
      */
-    void doWriteString(@Nullable String val) {
+    public void doWriteString(@Nullable String val) {
         if (val == null)
             doWriteByte(NULL);
         else {
@@ -528,7 +528,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param uuid UUID.
      */
-    void doWriteUuid(@Nullable UUID uuid) {
+    public void doWriteUuid(@Nullable UUID uuid) {
         if (uuid == null)
             doWriteByte(NULL);
         else {
@@ -541,7 +541,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param date Date.
      */
-    void doWriteDate(@Nullable Date date) {
+    public void doWriteDate(@Nullable Date date) {
         if (date == null)
             doWriteByte(NULL);
         else {
@@ -554,7 +554,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param ts Timestamp.
      */
-    void doWriteTimestamp(@Nullable Timestamp ts) {
+    public void doWriteTimestamp(@Nullable Timestamp ts) {
         if (ts == null)
             doWriteByte(NULL);
         else {
@@ -569,7 +569,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      * @param detached Detached or not.
      * @throws PortableException In case of error.
      */
-    void doWriteObject(@Nullable Object obj, boolean detached) throws PortableException {
+    public void doWriteObject(@Nullable Object obj, boolean detached) throws PortableException {
         if (obj == null)
             doWriteByte(NULL);
         else {
@@ -591,6 +591,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(BYTE_ARR);
             doWriteInt(val.length);
 
@@ -605,6 +608,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(SHORT_ARR);
             doWriteInt(val.length);
 
@@ -619,6 +625,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(INT_ARR);
             doWriteInt(val.length);
 
@@ -633,6 +642,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(LONG_ARR);
             doWriteInt(val.length);
 
@@ -647,6 +659,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(FLOAT_ARR);
             doWriteInt(val.length);
 
@@ -661,6 +676,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(DOUBLE_ARR);
             doWriteInt(val.length);
 
@@ -675,6 +693,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(CHAR_ARR);
             doWriteInt(val.length);
 
@@ -689,6 +710,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(BOOLEAN_ARR);
             doWriteInt(val.length);
 
@@ -703,6 +727,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(DECIMAL_ARR);
             doWriteInt(val.length);
 
@@ -718,6 +745,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(STRING_ARR);
             doWriteInt(val.length);
 
@@ -733,6 +763,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(UUID_ARR);
             doWriteInt(val.length);
 
@@ -748,6 +781,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             doWriteByte(DATE_ARR);
             doWriteInt(val.length);
 
@@ -764,6 +800,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (val == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(val))
+                return;
+
             PortableContext.Type type = ctx.typeId(val.getClass().getComponentType());
 
             doWriteByte(OBJ_ARR);
@@ -790,6 +829,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (col == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(col))
+                return;
+
             doWriteByte(COL);
             doWriteInt(col.size());
             doWriteByte(ctx.collectionType(col.getClass()));
@@ -807,6 +849,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (map == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(map))
+                return;
+
             doWriteByte(MAP);
             doWriteInt(map.size());
             doWriteByte(ctx.mapType(map.getClass()));
@@ -826,6 +871,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         if (e == null)
             doWriteByte(NULL);
         else {
+            if (tryWriteAsHandle(e))
+                return;
+
             doWriteByte(MAP_ENTRY);
             doWriteObject(e.getKey(), false);
             doWriteObject(e.getValue(), false);
@@ -905,7 +953,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @param po Portable object.
      */
-    void doWritePortableObject(@Nullable PortableObjectImpl po) {
+    public void doWritePortableObject(@Nullable PortableObjectImpl po) {
         if (po == null)
             doWriteByte(NULL);
         else {
@@ -1106,64 +1154,88 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      * @param val Value.
      */
     void writeByteArrayField(@Nullable byte[] val) {
-        doWriteInt(val != null ? 5 + val.length : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteByteArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeShortArrayField(@Nullable short[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 1) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteShortArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeIntArrayField(@Nullable int[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 2) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteIntArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeLongArrayField(@Nullable long[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 3) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteLongArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeFloatArrayField(@Nullable float[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 2) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteFloatArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeDoubleArrayField(@Nullable double[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 3) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteDoubleArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeCharArrayField(@Nullable char[] val) {
-        doWriteInt(val != null ? 5 + (val.length << 1) : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteCharArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
      * @param val Value.
      */
     void writeBooleanArrayField(@Nullable boolean[] val) {
-        doWriteInt(val != null ? 5 + val.length : 1);
+        int lenPos = reserveAndMark(4);
+
         doWriteBooleanArray(val);
+
+        writeDelta(lenPos);
     }
 
     /**
@@ -1739,12 +1811,31 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
         doWriteInt(id);
     }
 
+     /**
+      * Attempts to write the object as a handle.
+      *
+      * @param obj Object to write.
+      * @return {@code true} if the object has been written as a handle.
+      */
+     boolean tryWriteAsHandle(Object obj) {
+         int handle = handle(obj);
+
+         if (handle >= 0) {
+             doWriteByte(GridPortableMarshaller.HANDLE);
+             doWriteInt(handle);
+
+             return true;
+         }
+
+         return false;
+     }
+
     /**
      * Create new writer with same context.
      * @param typeId type
      * @return New writer.
      */
-    PortableWriterExImpl newWriter(int typeId) {
+    public PortableWriterExImpl newWriter(int typeId) {
         PortableWriterExImpl res = new PortableWriterExImpl(ctx, wCtx);
 
         res.typeId = typeId;
@@ -1755,7 +1846,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     /**
      * @return Portable context.
      */
-    PortableContext context() {
+    public PortableContext context() {
         return ctx;
     }
 
@@ -1803,4 +1894,4 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
             handles = new IdentityHashMap<>();
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableAbstractLazyValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableAbstractLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableAbstractLazyValue.java
new file mode 100644
index 0000000..1f521ac
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableAbstractLazyValue.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+/**
+ *
+ */
+abstract class PortableAbstractLazyValue implements PortableLazyValue {
+    /** */
+    protected Object val;
+
+    /** */
+    protected final PortableBuilderReader reader;
+
+    /** */
+    protected final int valOff;
+
+    /**
+     * @param reader Reader.
+     * @param valOff Value.
+     */
+    protected PortableAbstractLazyValue(PortableBuilderReader reader, int valOff) {
+        this.reader = reader;
+        this.valOff = valOff;
+    }
+
+    /**
+     * @return Value.
+     */
+    protected abstract Object init();
+
+    /** {@inheritDoc} */
+    @Override public Object value() {
+        if (val == null) {
+            val = init();
+
+            assert val != null;
+        }
+
+        return val;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java
new file mode 100644
index 0000000..1472d56
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.portable.PortableInvalidClassException;
+
+/**
+ *
+ */
+public class PortableBuilderEnum implements PortableBuilderSerializationAware {
+    /** */
+    private final int ordinal;
+
+    /** */
+    private final int typeId;
+
+    /** */
+    private final String clsName;
+
+    /**
+     * @param typeId Type ID.
+     * @param anEnum Enum instance.
+     */
+    public PortableBuilderEnum(int typeId, Enum anEnum) {
+        ordinal = anEnum.ordinal();
+        this.typeId = typeId;
+        clsName = null;
+    }
+
+    /**
+     * @param reader PortableBuilderReader.
+     */
+    public PortableBuilderEnum(PortableBuilderReader reader) {
+        int typeId = reader.readInt();
+
+        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
+            clsName = reader.readString();
+
+            Class cls;
+
+            try {
+                // TODO: IGNITE-1272 - Is class loader needed here?
+                cls = U.forName(reader.readString(), null);
+            }
+            catch (ClassNotFoundException e) {
+                throw new PortableInvalidClassException("Failed to load the class: " + clsName, e);
+            }
+
+            this.typeId = reader.portableContext().descriptorForClass(cls).typeId();
+        }
+        else {
+            this.typeId = typeId;
+            this.clsName = null;
+        }
+
+        ordinal = reader.readInt();
+    }
+
+    /**
+     * @return Ordinal.
+     */
+    public int getOrdinal() {
+        return ordinal;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) {
+        writer.writeByte(GridPortableMarshaller.ENUM);
+
+        if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) {
+            writer.writeInt(GridPortableMarshaller.UNREGISTERED_TYPE_ID);
+            writer.writeString(clsName);
+        }
+        else
+            writer.writeInt(typeId);
+
+        writer.writeInt(ordinal);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        PortableBuilderEnum that = (PortableBuilderEnum)o;
+
+        return ordinal == that.ordinal && typeId == that.typeId;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int result = ordinal;
+
+        result = 31 * result + typeId;
+
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9057a4c0/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
new file mode 100644
index 0000000..b2e4c0d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
@@ -0,0 +1,537 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.builder;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
+import org.apache.ignite.internal.util.GridArgumentCheck;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.portable.PortableBuilder;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableInvalidClassException;
+import org.apache.ignite.portable.PortableMetadata;
+import org.apache.ignite.portable.PortableObject;
+import org.jetbrains.annotations.Nullable;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.cache.portable.*;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.portable.*;
+
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLS_NAME_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.HASH_CODE_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.RAW_DATA_OFF_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TYPE_ID_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
+
+/**
+ *
+ */
+public class PortableBuilderImpl implements PortableBuilder {
+    /** */
+    private static final Object REMOVED_FIELD_MARKER = new Object();
+
+    /** */
+    private final PortableContext ctx;
+
+    /** */
+    private final int typeId;
+
+    /** May be null. */
+    private String typeName;
+
+    /** May be null. */
+    private String clsNameToWrite;
+
+    /** */
+    private boolean registeredType = true;
+
+    /** */
+    private Map<String, Object> assignedVals;
+
+    /** */
+    private Map<Integer, Object> readCache;
+
+    /** Position of object in source array, or -1 if object is not created from PortableObject. */
+    private final int start;
+
+    /** Total header length */
+    private final int hdrLen;
+
+    /**
+     * Context of PortableObject reading process. Or {@code null} if object is not created from PortableObject.
+     */
+    private final PortableBuilderReader reader;
+
+    /** */
+    private int hashCode;
+
+    /**
+     * @param clsName Class name.
+     * @param ctx Portable context.
+     */
+    public PortableBuilderImpl(PortableContext ctx, String clsName) {
+        this(ctx, ctx.typeId(clsName), PortableContext.typeName(clsName));
+    }
+
+    /**
+     * @param typeId Type ID.
+     * @param ctx Portable context.
+     */
+    public PortableBuilderImpl(PortableContext ctx, int typeId) {
+        this(ctx, typeId, null);
+    }
+
+    /**
+     * @param typeName Type name.
+     * @param ctx Context.
+     * @param typeId Type id.
+     */
+    public PortableBuilderImpl(PortableContext ctx, int typeId, String typeName) {
+        this.typeId = typeId;
+        this.typeName = typeName;
+        this.ctx = ctx;
+
+        start = -1;
+        reader = null;
+        hdrLen = DFLT_HDR_LEN;
+
+        readCache = Collections.emptyMap();
+    }
+
+    /**
+     * @param obj Object to wrap.
+     */
+    public PortableBuilderImpl(PortableObjectImpl obj) {
+        this(new PortableBuilderReader(obj), obj.start());
+
+        reader.registerObject(this);
+    }
+
+    /**
+     * @param reader ctx
+     * @param start Start.
+     */
+    PortableBuilderImpl(PortableBuilderReader reader, int start) {
+        this.reader = reader;
+        this.start = start;
+
+        int typeId = reader.readIntAbsolute(start + TYPE_ID_POS);
+        ctx = reader.portableContext();
+        hashCode = reader.readIntAbsolute(start + HASH_CODE_POS);
+
+        if (typeId == UNREGISTERED_TYPE_ID) {
+            int mark = reader.position();
+
+            reader.position(start + CLS_NAME_POS);
+
+            clsNameToWrite = reader.readString();
+
+            Class cls;
+
+            try {
+                // TODO: IGNITE-1272 - Is class loader needed here?
+                cls = U.forName(clsNameToWrite, null);
+            }
+            catch (ClassNotFoundException e) {
+                throw new PortableInvalidClassException("Failed to load the class: " + clsNameToWrite, e);
+            }
+
+            this.typeId = ctx.descriptorForClass(cls).typeId();
+
+            registeredType = false;
+
+            hdrLen = reader.position() - mark;
+
+            reader.position(mark);
+        }
+        else {
+            this.typeId = typeId;
+            hdrLen = DFLT_HDR_LEN;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public PortableObject build() {
+        try (PortableWriterExImpl writer = new PortableWriterExImpl(ctx, 0, typeId, false)) {
+
+            PortableBuilderSerializer serializationCtx = new PortableBuilderSerializer();
+
+            serializationCtx.registerObjectWriting(this, 0);
+
+            serializeTo(writer, serializationCtx);
+
+            byte[] arr = writer.array();
+
+            return new PortableObjectImpl(ctx, arr, 0);
+        }
+    }
+
+    /**
+     * @param writer Writer.
+     * @param serializer Serializer.
+     */
+    void serializeTo(PortableWriterExImpl writer, PortableBuilderSerializer serializer) {
+        writer.doWriteByte(GridPortableMarshaller.OBJ);
+        writer.doWriteBoolean(true);
+        writer.doWriteInt(registeredType ? typeId : UNREGISTERED_TYPE_ID);
+        writer.doWriteInt(hashCode);
+
+        // Length and raw offset.
+        writer.reserve(8);
+
+        if (!registeredType)
+            writer.writeString(clsNameToWrite);
+
+        Set<Integer> remainsFlds = null;
+
+        if (reader != null) {
+            Map<Integer, Object> assignedFldsById;
+
+            if (assignedVals != null) {
+                assignedFldsById = U.newHashMap(assignedVals.size());
+
+                for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
+                    int fldId = ctx.fieldId(typeId, entry.getKey());
+
+                    assignedFldsById.put(fldId, entry.getValue());
+                }
+
+                remainsFlds = assignedFldsById.keySet();
+            }
+            else
+                assignedFldsById = Collections.emptyMap();
+
+            int rawOff = start + reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
+
+            reader.position(start + hdrLen);
+
+            int cpStart = -1;
+
+            while (reader.position() < rawOff) {
+                int fldId = reader.readInt();
+
+                int len = reader.readInt();
+
+                if (assignedFldsById.containsKey(fldId)) {
+                    if (cpStart >= 0) {
+                        writer.write(reader.array(), cpStart, reader.position() - 4 - 4 - cpStart);
+
+                        cpStart = -1;
+                    }
+
+                    Object assignedVal = assignedFldsById.remove(fldId);
+
+                    reader.skip(len);
+
+                    if (assignedVal != REMOVED_FIELD_MARKER) {
+                        writer.writeInt(fldId);
+
+                        int lenPos = writer.reserveAndMark(4);
+
+                        serializer.writeValue(writer, assignedVal);
+
+                        writer.writeDelta(lenPos);
+                    }
+                }
+                else {
+                    int type = len != 0 ? reader.readByte(0) : 0;
+
+                    if (len != 0 && !PortableUtils.isPlainArrayType(type) && PortableUtils.isPlainType(type)) {
+                        if (cpStart < 0)
+                            cpStart = reader.position() - 4 - 4;
+
+                        reader.skip(len);
+                    }
+                    else {
+                        if (cpStart >= 0) {
+                            writer.write(reader.array(), cpStart, reader.position() - 4 - cpStart);
+
+                            cpStart = -1;
+                        }
+                        else
+                            writer.writeInt(fldId);
+
+                        Object val;
+
+                        if (len == 0)
+                            val = null;
+                        else if (readCache == null) {
+                            int savedPos = reader.position();
+
+                            val = reader.parseValue();
+
+                            assert reader.position() == savedPos + len;
+                        }
+                        else {
+                            val = readCache.get(fldId);
+
+                            reader.skip(len);
+                        }
+
+                        int lenPos = writer.reserveAndMark(4);
+
+                        serializer.writeValue(writer, val);
+
+                        writer.writeDelta(lenPos);
+                    }
+                }
+            }
+
+            if (cpStart >= 0)
+                writer.write(reader.array(), cpStart, reader.position() - cpStart);
+        }
+
+        if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) {
+            boolean metadataEnabled = ctx.isMetaDataEnabled(typeId);
+
+            PortableMetadata metadata = null;
+
+            if (metadataEnabled)
+                metadata = ctx.metaData(typeId);
+
+            Map<String, String> newFldsMetadata = null;
+
+            for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
+                Object val = entry.getValue();
+
+                if (val == REMOVED_FIELD_MARKER)
+                    continue;
+
+                String name = entry.getKey();
+
+                int fldId = ctx.fieldId(typeId, name);
+
+                if (remainsFlds != null && !remainsFlds.contains(fldId))
+                    continue;
+
+                writer.writeInt(fldId);
+
+                int lenPos = writer.reserveAndMark(4);
+
+                serializer.writeValue(writer, val);
+
+                writer.writeDelta(lenPos);
+
+                if (metadataEnabled) {
+                    String oldFldTypeName = metadata == null ? null : metadata.fieldTypeName(name);
+
+                    String newFldTypeName;
+
+                    if (val instanceof PortableValueWithType)
+                        newFldTypeName = ((PortableValueWithType)val).typeName();
+                    else {
+                        byte type = PortableUtils.typeByClass(val.getClass());
+
+                        newFldTypeName = CacheObjectPortableProcessorImpl.fieldTypeName(type);
+                    }
+
+                    if (oldFldTypeName == null) {
+                        // It's a new field, we have to add it to metadata.
+
+                        if (newFldsMetadata == null)
+                            newFldsMetadata = new HashMap<>();
+
+                        newFldsMetadata.put(name, newFldTypeName);
+                    }
+                    else {
+                        if (!"Object".equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) {
+                            throw new PortableException(
+                                "Wrong value has been set [" +
+                                    "typeName=" + (typeName == null ? metadata.typeName() : typeName) +
+                                    ", fieldName=" + name +
+                                    ", fieldType=" + oldFldTypeName +
+                                    ", assignedValueType=" + newFldTypeName +
+                                    ", assignedValue=" + (((PortableValueWithType)val).value()) + ']'
+                            );
+                        }
+                    }
+                }
+            }
+
+            if (newFldsMetadata != null) {
+                String typeName = this.typeName;
+
+                if (typeName == null)
+                    typeName = metadata.typeName();
+
+                ctx.updateMetaData(typeId, typeName, newFldsMetadata);
+            }
+        }
+
+        writer.writeRawOffsetIfNeeded();
+
+        if (reader != null) {
+            int rawOff = reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
+            int len = reader.readIntAbsolute(start + TOTAL_LEN_POS);
+
+            if (rawOff < len)
+                writer.write(reader.array(), rawOff, len - rawOff);
+        }
+
+        writer.writeLength();
+    }
+
+    /** {@inheritDoc} */
+    @Override public PortableBuilderImpl hashCode(int hashCode) {
+        this.hashCode = hashCode;
+
+        return this;
+    }
+
+    /**
+     *
+     */
+    private void ensureReadCacheInit() {
+        if (readCache == null) {
+            Map<Integer, Object> readCache = new HashMap<>();
+
+            int pos = start + hdrLen;
+            int end = start + reader.readIntAbsolute(start + RAW_DATA_OFF_POS);
+
+            while (pos < end) {
+                int fieldId = reader.readIntAbsolute(pos);
+
+                pos += 4;
+
+                int len = reader.readIntAbsolute(pos);
+
+                pos += 4;
+
+                Object val = reader.getValueQuickly(pos, len);
+
+                readCache.put(fieldId, val);
+
+                pos += len;
+            }
+
+            this.readCache = readCache;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <F> F getField(String name) {
+        Object val;
+
+        if (assignedVals != null && assignedVals.containsKey(name)) {
+            val = assignedVals.get(name);
+
+            if (val == REMOVED_FIELD_MARKER)
+                return null;
+        }
+        else {
+            ensureReadCacheInit();
+
+            int fldId = ctx.fieldId(typeId, name);
+
+            val = readCache.get(fldId);
+        }
+
+        return (F)PortableUtils.unwrapLazy(val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public PortableBuilder setField(String name, Object val) {
+        GridArgumentCheck.notNull(val, name);
+
+        if (assignedVals == null)
+            assignedVals = new LinkedHashMap<>();
+
+        Object oldVal = assignedVals.put(name, val);
+
+        if (oldVal instanceof PortableValueWithType) {
+            ((PortableValueWithType)oldVal).value(val);
+
+            assignedVals.put(name, oldVal);
+        }
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> PortableBuilder setField(String name, @Nullable T val, Class<? super T> type) {
+        if (assignedVals == null)
+            assignedVals = new LinkedHashMap<>();
+
+        //int fldId = ctx.fieldId(typeId, fldName);
+
+        assignedVals.put(name, new PortableValueWithType(PortableUtils.typeByClass(type), val));
+
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    @Override public PortableBuilder setField(String name, @Nullable PortableBuilder builder) {
+        if (builder == null)
+            return setField(name, null, Object.class);
+        else
+            return setField(name, (Object)builder);
+    }
+
+    /**
+     * Removes field from portable object.
+     *
+     * @param name Field name.
+     * @return {@code this} instance for chaining.
+     */
+    @Override public PortableBuilderImpl removeField(String name) {
+        if (assignedVals == null)
+            assignedVals = new LinkedHashMap<>();
+
+        assignedVals.put(name, REMOVED_FIELD_MARKER);
+
+        return this;
+    }
+
+    /**
+     * Creates builder initialized by specified portable object.
+     *
+     * @param obj Portable object to initialize builder.
+     * @return New builder.
+     */
+    public static PortableBuilderImpl wrap(PortableObject obj) {
+        PortableObjectImpl heapObj;
+
+        if (obj instanceof PortableObjectOffheapImpl)
+            heapObj = (PortableObjectImpl)((PortableObjectOffheapImpl)obj).heapCopy();
+        else
+            heapObj = (PortableObjectImpl)obj;
+
+        return new PortableBuilderImpl(heapObj);
+    }
+
+    /**
+     * @return Object start position in source array.
+     */
+    int start() {
+        return start;
+    }
+
+    /**
+     * @return Object type id.
+     */
+    public int typeId() {
+        return typeId;
+    }
+}
\ No newline at end of file


[04/50] [abbrv] ignite git commit: IGNITE-1019 - Cache store factory injection

Posted by ak...@apache.org.
IGNITE-1019 - Cache store factory injection


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

Branch: refs/heads/ignite-843
Commit: b8471482613288d607202e8903185ed10cf15f8d
Parents: 2a4839c
Author: sevdokimov <se...@gridgain.com>
Authored: Wed Sep 2 19:59:57 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Sep 2 19:59:57 2015 -0700

----------------------------------------------------------------------
 .../GridCacheLoaderWriterStoreFactory.java      |  20 +++-
 .../processors/cache/GridCacheProcessor.java    |  10 +-
 .../store/StoreResourceInjectionSelfTest.java   | 104 +++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |   4 +-
 4 files changed, 133 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b8471482/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStoreFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStoreFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStoreFactory.java
index 73573bd..9ba1190 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStoreFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStoreFactory.java
@@ -5,9 +5,9 @@
  * 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.
@@ -56,4 +56,18 @@ class GridCacheLoaderWriterStoreFactory<K, V> implements Factory<CacheStore<K, V
 
         return new GridCacheLoaderWriterStore<>(ldr, writer);
     }
-}
\ No newline at end of file
+
+    /**
+     * @return Loader factory.
+     */
+    Factory<CacheLoader<K, V>> loaderFactory() {
+        return ldrFactory;
+    }
+
+    /**
+     * @return Writer factory.
+     */
+    Factory<CacheWriter<K, V>> writerFactory() {
+        return writerFactory;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b8471482/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index cf8c8d6..75d4c43 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -1252,7 +1252,15 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     {
         assert cfg != null;
 
-        prepare(cfg, cfg.getCacheStoreFactory(), false);
+        if (cfg.getCacheStoreFactory() instanceof GridCacheLoaderWriterStoreFactory) {
+            GridCacheLoaderWriterStoreFactory factory = (GridCacheLoaderWriterStoreFactory)cfg.getCacheStoreFactory();
+
+            prepare(cfg, factory.loaderFactory(), false);
+            prepare(cfg, factory.writerFactory(), false);
+        }
+        else
+            prepare(cfg, cfg.getCacheStoreFactory(), false);
+
 
         CacheStore cfgStore = cfg.getCacheStoreFactory() != null ? cfg.getCacheStoreFactory().create() : null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b8471482/modules/core/src/test/java/org/apache/ignite/cache/store/StoreResourceInjectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/StoreResourceInjectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/StoreResourceInjectionSelfTest.java
new file mode 100644
index 0000000..207cbfb
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/StoreResourceInjectionSelfTest.java
@@ -0,0 +1,104 @@
+package org.apache.ignite.cache.store;/*
+ * 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.
+ */
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import javax.cache.configuration.*;
+
+/**
+ * Test resource injection.
+ */
+public class StoreResourceInjectionSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private CacheConfiguration<Integer, String> cacheCfg = new CacheConfiguration<>();
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cacheCfg.setReadThrough(true);
+        cacheCfg.setWriteThrough(true);
+
+        cfg.setCacheConfiguration(cacheCfg);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     *
+     */
+    public void testResourcesInStoreFactory() throws Exception {
+        cacheCfg.setCacheStoreFactory(new MyCacheStoreFactory());
+
+        startGrid(0);
+    }
+
+    /**
+     *
+     */
+    public void testResourcesInLoaderFactory() throws Exception {
+        cacheCfg.setCacheLoaderFactory(new MyCacheStoreFactory());
+
+        startGrid(0);
+    }
+
+    /**
+     *
+     */
+    public void testResourcesInWriterFactory() throws Exception {
+        cacheCfg.setCacheWriterFactory(new MyCacheStoreFactory());
+
+        startGrid(0);
+    }
+
+    /**
+     *
+     */
+    public static class MyCacheStoreFactory implements Factory<CacheStore<Integer, String>> {
+        /** */
+        @IgniteInstanceResource
+        private Ignite ignite;
+
+        /** {@inheritDoc} */
+        @Override public CacheStore<Integer, String> create() {
+            assert ignite != null;
+
+            return new GridCacheTestStore();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b8471482/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index dac38de..1deb3bc 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -28,6 +28,7 @@ import org.apache.ignite.cache.affinity.fair.GridFairAffinityFunctionSelfTest;
 import org.apache.ignite.cache.affinity.fair.IgniteFairAffinityDynamicCacheSelfTest;
 import org.apache.ignite.cache.store.GridCacheBalancingStoreSelfTest;
 import org.apache.ignite.cache.store.GridCacheLoadOnlyStoreAdapterSelfTest;
+import org.apache.ignite.cache.store.StoreResourceInjectionSelfTest;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreMultitreadedSelfTest;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreTest;
 import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreMultithreadedSelfTest;
@@ -220,6 +221,7 @@ public class IgniteCacheTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheObjectToStringSelfTest.class);
         suite.addTestSuite(GridCacheLoadOnlyStoreAdapterSelfTest.class);
         suite.addTestSuite(GridCacheGetStoreErrorSelfTest.class);
+        suite.addTestSuite(StoreResourceInjectionSelfTest.class);
         suite.addTestSuite(CacheFutureExceptionSelfTest.class);
         suite.addTestSuite(GridCacheAsyncOperationsLimitSelfTest.class);
         suite.addTestSuite(IgniteCacheManyAsyncOperationsTest.class);
@@ -266,4 +268,4 @@ public class IgniteCacheTestSuite extends TestSuite {
 
         return suite;
     }
-}
\ No newline at end of file
+}


[28/50] [abbrv] ignite git commit: Log4j2LoggerSelfTest.testLogFilesTwoNodes test case for Windows.

Posted by ak...@apache.org.
Log4j2LoggerSelfTest.testLogFilesTwoNodes test case for Windows.


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

Branch: refs/heads/ignite-843
Commit: 8901575e14f7334874d630ae685db624d00dcc7f
Parents: 154f185
Author: Artem Shutak <ar...@gmail.com>
Authored: Thu Sep 3 18:57:47 2015 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Thu Sep 3 18:57:47 2015 +0300

----------------------------------------------------------------------
 .../ignite/logger/log4j2/Log4J2Logger.java      | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8901575e/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 5e6ab34..ffe8e1b 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -242,10 +242,10 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
                             Appender innerApp = control.getAppender();
 
                             if (innerApp instanceof FileAppender)
-                                return ((FileAppender)innerApp).getFileName();
+                                return normilize(((FileAppender)innerApp).getFileName());
 
                             if (innerApp instanceof RollingFileAppender)
-                                return ((RollingFileAppender)innerApp).getFileName();
+                                return normilize(((RollingFileAppender)innerApp).getFileName());
                         }
                     }
                     catch (IllegalAccessException | NoSuchFieldException e) {
@@ -259,6 +259,20 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     }
 
     /**
+     * Normalizes given path for windows.
+     * Log4j2 doesn't replace unix directory delimiters which used at 'fileName' to windows.
+     *
+     * @param path Path.
+     * @return Normalized path.
+     */
+    private String normilize(String path) {
+        if (!U.isWindows())
+            return path;
+
+        return path.replace('/', File.separatorChar);
+    }
+
+    /**
      * Adds console appender when needed with some default logging settings.
      *
      * @param initLogClo Optional log implementation init closure.
@@ -495,4 +509,4 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     @Override public String toString() {
         return S.toString(Log4J2Logger.class, this);
     }
-}
\ No newline at end of file
+}


[18/50] [abbrv] ignite git commit: ignite-1344: Fixed imports at java8-examples

Posted by ak...@apache.org.
ignite-1344: Fixed imports at java8-examples


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

Branch: refs/heads/ignite-843
Commit: 0cba13cc0bfcada072925a15e7cdf79752c6b783
Parents: 27cd615
Author: ashutak <as...@gridgain.com>
Authored: Thu Sep 3 13:54:22 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Sep 3 13:54:22 2015 +0300

----------------------------------------------------------------------
 .../java8/datagrid/CacheAffinityExample.java         | 15 +++++++++++++++
 .../examples/java8/messaging/MessagingExample.java   | 11 ++++++++++-
 .../ignite/java8/examples/BasicExamplesSelfTest.java | 10 +++++++---
 .../ignite/java8/examples/CacheExamplesSelfTest.java |  8 +++++---
 .../java8/examples/CheckpointExamplesSelfTest.java   |  8 ++++----
 .../java8/examples/ClusterGroupExampleSelfTest.java  |  4 +++-
 .../java8/examples/ContinuationExamplesSelfTest.java |  8 +++++---
 .../examples/ContinuousMapperExamplesSelfTest.java   |  8 +++++---
 .../java8/examples/DeploymentExamplesSelfTest.java   |  6 ++++--
 .../java8/examples/EventsExamplesSelfTest.java       |  5 +++--
 .../examples/HibernateL2CacheExampleSelfTest.java    |  8 +++++---
 .../ignite/java8/examples/IgfsExamplesSelfTest.java  |  6 ++++--
 .../java8/examples/LifecycleExamplesSelfTest.java    |  8 +++++---
 .../java8/examples/MemcacheRestExamplesSelfTest.java |  4 +++-
 .../java8/examples/MessagingExamplesSelfTest.java    |  6 ++++--
 .../java8/examples/MonteCarloExamplesSelfTest.java   |  8 +++++---
 .../java8/examples/SpringBeanExamplesSelfTest.java   |  8 +++++---
 .../ignite/java8/examples/TaskExamplesSelfTest.java  |  4 +++-
 .../testsuites/IgniteExamplesJ8SelfTestSuite.java    | 12 ++++++++++--
 19 files changed, 105 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
index 6635e7f..9d9bacc 100644
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
@@ -17,6 +17,21 @@
 
 package org.apache.ignite.examples.java8.datagrid;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteRunnable;
+
 /**
  * This example demonstrates the simplest code that populates the distributed cache
  * and co-locates simple closure execution with each key. The goal of this particular

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
index f8f9242..97ec58e 100644
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
@@ -17,6 +17,15 @@
 
 package org.apache.ignite.examples.java8.messaging;
 
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteMessaging;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+
 /**
  * Example that demonstrates how to exchange messages between nodes. Use such
  * functionality for cases when you need to communicate to other nodes outside
@@ -154,4 +163,4 @@ public final class MessagingExample {
             return unorderedLatch.getCount() > 0;
         });
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesSelfTest.java
index a6bd7c9..cc74cef 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/BasicExamplesSelfTest.java
@@ -17,8 +17,12 @@
 
 package org.apache.ignite.java8.examples;
 
-import org.apache.ignite.examples.java8.computegrid.*;
-import org.apache.ignite.examples.java8.datastructures.*;
+import org.apache.ignite.examples.java8.computegrid.ComputeBroadcastExample;
+import org.apache.ignite.examples.java8.computegrid.ComputeCallableExample;
+import org.apache.ignite.examples.java8.computegrid.ComputeClosureExample;
+import org.apache.ignite.examples.java8.computegrid.ComputeRunnableExample;
+import org.apache.ignite.examples.java8.datastructures.IgniteExecutorServiceExample;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
 
 /**
  * Closure examples self test.
@@ -82,4 +86,4 @@ public class BasicExamplesSelfTest extends GridAbstractExamplesTest {
 //    public void testTaskSplitExample() throws Exception {
 //        ComputeTaskSplitExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesSelfTest.java
index 823210b..4446521 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/CacheExamplesSelfTest.java
@@ -17,7 +17,9 @@
 
 package org.apache.ignite.java8.examples;
 
-import org.apache.ignite.examples.java8.datagrid.*;
+import org.apache.ignite.examples.java8.datagrid.CacheAffinityExample;
+import org.apache.ignite.examples.java8.datagrid.CacheApiExample;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
 
 //import org.apache.ignite.examples.java8.datagrid.starschema.*;
 //import org.apache.ignite.examples.java8.datagrid.store.dummy.*;
@@ -34,7 +36,7 @@ public class CacheExamplesSelfTest extends GridAbstractExamplesTest {
         CacheAffinityExample.main(EMPTY_ARGS);
     }
 
-//    TODO: IGNITE-711 next example(s) should be implemented for java 8 
+//    TODO: IGNITE-711 next example(s) should be implemented for java 8
 //    or testing method(s) should be removed if example(s) does not applicable for java 8.
 //    /**
 //     * @throws Exception If failed.
@@ -142,4 +144,4 @@ public class CacheExamplesSelfTest extends GridAbstractExamplesTest {
 //    public void testCacheContinuousQueryExample() throws Exception {
 //        CacheContinuousQueryExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/CheckpointExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/CheckpointExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/CheckpointExamplesSelfTest.java
index d1c5f16..b39fe7f 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/CheckpointExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/CheckpointExamplesSelfTest.java
@@ -17,16 +17,16 @@
 
 package org.apache.ignite.java8.examples;
 
-//import org.apache.ignite.examples.java8.computegrid.failover.*;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
 
 /**
  * Checkpoint examples self test.
  */
 public class CheckpointExamplesSelfTest extends GridAbstractExamplesTest {
     /**
-     * TODO: IGNITE-711 next example(s) should be implemented for java 8 
+     * TODO: IGNITE-711 next example(s) should be implemented for java 8
      * or testing method(s) should be removed if example(s) does not applicable for java 8.
-     *  
+     *
      * Starts remote nodes before each test.
      *
      * Note: using beforeTestsStarted() to start nodes only once won't work.
@@ -44,4 +44,4 @@ public class CheckpointExamplesSelfTest extends GridAbstractExamplesTest {
 //    public void testCheckpointExample() throws Exception {
 //        ComputeFailoverExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/ClusterGroupExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/ClusterGroupExampleSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/ClusterGroupExampleSelfTest.java
index 3dea6ca..34ef68d 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/ClusterGroupExampleSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/ClusterGroupExampleSelfTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.java8.examples;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  *
  */
@@ -35,4 +37,4 @@ public class ClusterGroupExampleSelfTest extends GridAbstractExamplesTest {
 //    public void testComputeClusterGroupsExample() throws Exception {
 //        ClusterGroupExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesSelfTest.java
index 4b4387c..bea6bb6 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuationExamplesSelfTest.java
@@ -19,17 +19,19 @@ package org.apache.ignite.java8.examples;
 
 //import org.apache.ignite.examples.java8.computegrid.*;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  * Continuation example self test.
  */
 public class ContinuationExamplesSelfTest extends GridAbstractExamplesTest {
     /**
-     * TODO: IGNITE-711 next example(s) should be implemented for java 8 
+     * TODO: IGNITE-711 next example(s) should be implemented for java 8
      * or testing method(s) should be removed if example(s) does not applicable for java 8.
-     *  
+     *
      * @throws Exception If failed.
      */
 //    public void testContinuationExample() throws Exception {
 //        ComputeFibonacciContinuationExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesSelfTest.java
index afa1262..f23b6fa 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/ContinuousMapperExamplesSelfTest.java
@@ -17,17 +17,19 @@
 
 package org.apache.ignite.java8.examples;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  * ContinuousMapperExample self test.
  */
 public class ContinuousMapperExamplesSelfTest extends GridAbstractExamplesTest {
     /**
-     * TODO: IGNITE-711 next example(s) should be implemented for java 8 
+     * TODO: IGNITE-711 next example(s) should be implemented for java 8
      * or testing method(s) should be removed if example(s) does not applicable for java 8.
-     *  
+     *
      * @throws Exception If failed.
      */
 //    public void testContinuousMapperExample() throws Exception {
 //        ComputeContinuousMapperExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesSelfTest.java
index f56630d..70bddd5 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/DeploymentExamplesSelfTest.java
@@ -19,11 +19,13 @@ package org.apache.ignite.java8.examples;
 
 //import org.apache.ignite.examples.java8.misc.deployment.*;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  * Deployment examples self test.
  */
 public class DeploymentExamplesSelfTest extends GridAbstractExamplesTest {
-    // TODO: IGNITE-711 next example(s) should be implemented for java 8 
+    // TODO: IGNITE-711 next example(s) should be implemented for java 8
     // or testing method(s) should be removed if example(s) does not applicable for java 8.
     /**
      * @throws Exception If failed.
@@ -31,4 +33,4 @@ public class DeploymentExamplesSelfTest extends GridAbstractExamplesTest {
 //    public void testDeploymentExample() throws Exception {
 //        DeploymentExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesSelfTest.java
index e7b45a1..09784fe 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/EventsExamplesSelfTest.java
@@ -17,7 +17,8 @@
 
 package org.apache.ignite.java8.examples;
 
-import org.apache.ignite.examples.java8.events.*;
+import org.apache.ignite.examples.java8.events.EventsExample;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
 
 /**
  * Events examples self test.
@@ -29,4 +30,4 @@ public class EventsExamplesSelfTest extends GridAbstractExamplesTest {
     public void testEventsExample() throws Exception {
         EventsExample.main(EMPTY_ARGS);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
index f3c36ab..8c7a2de 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
@@ -19,17 +19,19 @@ package org.apache.ignite.java8.examples;
 
 //import org.apache.ignite.examples.java8.datagrid.hibernate.*;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  * Tests the {@link org.apache.ignite.examples.java8.datagrid.hibernate.HibernateL2CacheExample}.
  */
 public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest {
     /**
-     * TODO: IGNITE-711 next example(s) should be implemented for java 8 
+     * TODO: IGNITE-711 next example(s) should be implemented for java 8
      * or testing method(s) should be removed if example(s) does not applicable for java 8.
-     * 
+     *
      * @throws Exception If failed.
      */
 //    public void testHibernateL2CacheExample() throws Exception {
 //        HibernateL2CacheExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/IgfsExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/IgfsExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/IgfsExamplesSelfTest.java
index 424c197..aed11b3 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/IgfsExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/IgfsExamplesSelfTest.java
@@ -20,6 +20,8 @@ package org.apache.ignite.java8.examples;
 //import org.apache.ignite.examples.java8.igfs.*;
 //import org.apache.ignite.internal.util.typedef.internal.*;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  * IGFS examples self test.
  */
@@ -31,7 +33,7 @@ public class IgfsExamplesSelfTest extends GridAbstractExamplesTest {
     private static final String IGFS_LOOPBACK_CFG = "modules/core/src/test/config/igfs-loopback.xml";
 
     /**
-     * TODO: IGNITE-711 next example(s) should be implemented for java 8 
+     * TODO: IGNITE-711 next example(s) should be implemented for java 8
      * or testing method(s) should be removed if example(s) does not applicable for java 8.
      *
      * @throws Exception If failed.
@@ -50,4 +52,4 @@ public class IgfsExamplesSelfTest extends GridAbstractExamplesTest {
 //            stopAllGrids();
 //        }
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/LifecycleExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/LifecycleExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/LifecycleExamplesSelfTest.java
index f132e64..ac60659 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/LifecycleExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/LifecycleExamplesSelfTest.java
@@ -19,17 +19,19 @@ package org.apache.ignite.java8.examples;
 
 //import org.apache.ignite.examples.java8.misc.lifecycle.*;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  * LifecycleExample self test.
  */
 public class LifecycleExamplesSelfTest extends GridAbstractExamplesTest {
     /**
-     * TODO: IGNITE-711 next example(s) should be implemented for java 8 
+     * TODO: IGNITE-711 next example(s) should be implemented for java 8
      * or testing method(s) should be removed if example(s) does not applicable for java 8.
-     * 
+     *
      * @throws Exception If failed.
      */
 //    public void testLifecycleExample() throws Exception {
 //        LifecycleExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesSelfTest.java
index 398451e..80caf1f 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/MemcacheRestExamplesSelfTest.java
@@ -19,6 +19,8 @@ package org.apache.ignite.java8.examples;
 
 //import org.apache.ignite.examples.java8.misc.client.memcache.*;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  * MemcacheRestExample self test.
  */
@@ -39,4 +41,4 @@ public class MemcacheRestExamplesSelfTest extends GridAbstractExamplesTest {
 //    public void testMemcacheRestExample() throws Exception {
 //        MemcacheRestExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/MessagingExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/MessagingExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/MessagingExamplesSelfTest.java
index 92b2190..0948a2a 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/MessagingExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/MessagingExamplesSelfTest.java
@@ -17,7 +17,9 @@
 
 package org.apache.ignite.java8.examples;
 
-import org.apache.ignite.examples.java8.messaging.*;
+import org.apache.ignite.examples.java8.messaging.MessagingExample;
+import org.apache.ignite.examples.java8.messaging.MessagingPingPongExample;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
 
 /**
  * Messaging examples self test.
@@ -51,4 +53,4 @@ public class MessagingExamplesSelfTest extends GridAbstractExamplesTest {
 //    public void testMessagingPingPongListenActorExample() throws Exception {
 //        MessagingPingPongListenActorExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesSelfTest.java
index 2173bd6..c6161de 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/MonteCarloExamplesSelfTest.java
@@ -19,6 +19,8 @@ package org.apache.ignite.java8.examples;
 
 //import org.apache.ignite.examples.java8.computegrid.montecarlo.*;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  * Ignite examples self test. Excludes Ignite Spring tests.
  *
@@ -65,12 +67,12 @@ package org.apache.ignite.java8.examples;
  */
 public class MonteCarloExamplesSelfTest extends GridAbstractExamplesTest {
     /**
-     * TODO: IGNITE-711 next example(s) should be implemented for java 8 
+     * TODO: IGNITE-711 next example(s) should be implemented for java 8
      * or testing method(s) should be removed if example(s) does not applicable for java 8.
-     *  
+     *
      * @throws Exception If failed.
      */
 //    public void testCreditRiskExample() throws Exception {
 //        CreditRiskExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/SpringBeanExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/SpringBeanExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/SpringBeanExamplesSelfTest.java
index 859eb0a..1ea2e22 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/SpringBeanExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/SpringBeanExamplesSelfTest.java
@@ -19,17 +19,19 @@ package org.apache.ignite.java8.examples;
 
 //import org.apache.ignite.examples.java8.misc.springbean.*;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  * Spring bean examples self test.
  */
 public class SpringBeanExamplesSelfTest extends GridAbstractExamplesTest {
     /**
-     * TODO: IGNITE-711 next example(s) should be implemented for java 8 
+     * TODO: IGNITE-711 next example(s) should be implemented for java 8
      * or testing method(s) should be removed if example(s) does not applicable for java 8.
-     *  
+     *
      * @throws Exception If failed.
      */
 //    public void testSpringBeanHelloWorldExample() throws Exception {
 //        SpringBeanExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesSelfTest.java
index a520292..37520c1 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesSelfTest.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/examples/TaskExamplesSelfTest.java
@@ -19,6 +19,8 @@ package org.apache.ignite.java8.examples;
 
 //import org.apache.ignite.examples.java8.computegrid.*;
 
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
 /**
  * Hello world examples self test.
  */
@@ -38,4 +40,4 @@ public class TaskExamplesSelfTest extends GridAbstractExamplesTest {
 //    public void testTaskMapExample() throws Exception {
 //        ComputeTaskMapExample.main(EMPTY_ARGS);
 //    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0cba13cc/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
index 1373abe..57e48f9 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
@@ -17,7 +17,15 @@
 
 package org.apache.ignite.java8.testsuites;
 
-import org.apache.ignite.java8.examples.*;
+import junit.framework.TestSuite;
+import org.apache.ignite.java8.examples.BasicExamplesMultiNodeSelfTest;
+import org.apache.ignite.java8.examples.BasicExamplesSelfTest;
+import org.apache.ignite.java8.examples.CacheExamplesMultiNodeSelfTest;
+import org.apache.ignite.java8.examples.CacheExamplesSelfTest;
+import org.apache.ignite.java8.examples.EventsExamplesMultiNodeSelfTest;
+import org.apache.ignite.java8.examples.EventsExamplesSelfTest;
+import org.apache.ignite.java8.examples.MessagingExamplesSelfTest;
+import org.apache.ignite.testframework.GridTestUtils;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP;
 
@@ -68,4 +76,4 @@ public class IgniteExamplesJ8SelfTestSuite extends TestSuite {
 
         return suite;
     }
-}
\ No newline at end of file
+}