You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/02/03 13:27:56 UTC

[01/28] ignite git commit: IGNITE-1069 Added output of node type (server or client) in Visor commandline for node command. - Fixes #442.

Repository: ignite
Updated Branches:
  refs/heads/ignite-2508 14e837c6b -> dbb014c8e


IGNITE-1069 Added output of node type (server or client) in Visor commandline for node command. - Fixes #442.

Signed-off-by: AKuznetsov <ak...@gridgain.com>


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

Branch: refs/heads/ignite-2508
Commit: 58dce88b8dd0762c413850af2dfeadbdd22c519f
Parents: c3b83fe
Author: kcheng <kc...@gmail.com>
Authored: Mon Feb 1 20:31:34 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Feb 1 20:31:34 2016 +0700

----------------------------------------------------------------------
 .../org/apache/ignite/visor/commands/node/VisorNodeCommand.scala  | 1 +
 .../src/main/scala/org/apache/ignite/visor/visor.scala            | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/58dce88b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
index f4a1f87..9ba0129 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
@@ -157,6 +157,7 @@ class VisorNodeCommand extends VisorConsoleCommand {
 
                         t += ("ID", node.id)
                         t += ("ID8", nid8(node))
+                        t += ("Node Type", if (node.isClient) "Client" else "Server")
                         t += ("Order", node.order)
 
                         (0 /: sortAddresses(node.addresses))((b, a) => { t += ("Address (" + b + ")", a); b + 1 })

http://git-wip-us.apache.org/repos/asf/ignite/blob/58dce88b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index 986089b..a4eed69 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -1800,7 +1800,7 @@ object visor extends VisorTag {
 
         val t = VisorTextTable()
 
-        t #= ("#", "Node ID8(@), IP", "Up Time", "CPUs", "CPU Load", "Free Heap")
+        t #= ("#", "Node ID8(@), IP","Node Type", "Up Time", "CPUs", "CPU Load", "Free Heap")
 
         val nodes = ignite.cluster.nodes().toList
 
@@ -1826,6 +1826,7 @@ object visor extends VisorTag {
                 t += (
                     i,
                     nodeId8Addr(n.id),
+                    if (n.isClient) "Client" else "Server",
                     X.timeSpan2HMS(m.getUpTime),
                     n.metrics.getTotalCpus,
                     safePercent(cpuLoadPct),


[26/28] ignite git commit: IGNITE-2508: Further fixes.

Posted by vo...@apache.org.
IGNITE-2508: Further fixes.


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

Branch: refs/heads/ignite-2508
Commit: cf6974063abb7f602ae24258f7fea69be92a28a0
Parents: 04e705f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Feb 3 15:23:07 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 3 15:23:07 2016 +0300

----------------------------------------------------------------------
 .../affinity/GridAffinityAssignment.java        | 23 +++++++++++---------
 .../affinity/GridAffinityAssignmentCache.java   |  3 +--
 .../cache/GridCacheAffinityManager.java         | 11 ++++++++++
 .../dht/GridDhtPartitionTopologyImpl.java       |  8 +++++--
 4 files changed, 31 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cf697406/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
index ad37ad8..7b2bea3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
@@ -32,7 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 /**
  * Cached affinity calculations.
  */
-class GridAffinityAssignment implements Serializable {
+public class GridAffinityAssignment implements Serializable {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -122,24 +122,27 @@ class GridAffinityAssignment implements Serializable {
      * @return Affinity nodes IDs.
      */
     public HashSet<UUID> getIds(int part) {
-        List<HashSet<UUID>> ids = assignmentIds;
+        assert part >= 0 && part < assignment.size() : "Affinity partition is out of range" +
+            " [part=" + part + ", partitions=" + assignment.size() + ']';
+
+        List<HashSet<UUID>> assignmentIds0 = assignmentIds;
 
-        if (ids == null) {
-            ids = new ArrayList<>();
+        if (assignmentIds0 == null) {
+            assignmentIds0 = new ArrayList<>();
 
-            for (List<ClusterNode> a : assignment) {
+            for (List<ClusterNode> assignmentPart : assignment) {
                 HashSet<UUID> partIds = new HashSet<>();
 
-                for (ClusterNode n : a)
-                    partIds.add(n.id());
+                for (ClusterNode node : assignmentPart)
+                    partIds.add(node.id());
 
-                ids.add(partIds);
+                assignmentIds0.add(partIds);
             }
 
-            assignmentIds = ids;
+            assignmentIds = assignmentIds0;
         }
 
-        return ids.get(part);
+        return assignmentIds0.get(part);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf697406/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index 0b09eea..836183d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -397,7 +397,6 @@ public class GridAffinityAssignmentCache {
      * @return Affinity nodes.
      */
     public HashSet<UUID> nodesIds(int part, AffinityTopologyVersion topVer) {
-        // Resolve cached affinity nodes.
         return cachedAffinity(topVer).getIds(part);
     }
 
@@ -441,7 +440,7 @@ public class GridAffinityAssignmentCache {
      * @param topVer Topology version.
      * @return Cached affinity.
      */
-    private GridAffinityAssignment cachedAffinity(AffinityTopologyVersion topVer) {
+    public GridAffinityAssignment cachedAffinity(AffinityTopologyVersion topVer) {
         if (topVer.equals(AffinityTopologyVersion.NONE))
             topVer = lastVersion();
         else

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf697406/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index de0fa2d..54600ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -30,6 +30,7 @@ import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.affinity.GridAffinityAssignment;
 import org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache;
 import org.apache.ignite.internal.util.GridLeanSet;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -155,6 +156,16 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
     }
 
     /**
+     * Get affinity assignment for the given topology version.
+     *
+     * @param topVer Toplogy version.
+     * @return Affinity affignment.
+     */
+    public GridAffinityAssignment assignment(AffinityTopologyVersion topVer) {
+        return aff.cachedAffinity(topVer);
+    }
+
+    /**
      * @param topVer Topology version.
      * @return Affinity assignments.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf697406/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 6e5e47f..d6fc8f1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -36,6 +36,7 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.affinity.GridAffinityAssignment;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap;
@@ -693,8 +694,9 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
 
     /** {@inheritDoc} */
     @Override public Collection<ClusterNode> nodes(int p, AffinityTopologyVersion topVer) {
-        Collection<ClusterNode> affNodes = cctx.affinity().nodes(p, topVer);
-        HashSet<UUID> affIds = cctx.affinity().nodesIds(p, topVer);
+        GridAffinityAssignment affAssignment = cctx.affinity().assignment(topVer);
+
+        Collection<ClusterNode> affNodes = affAssignment.get(p);
 
         lock.readLock().lock();
 
@@ -710,6 +712,8 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
 
             if (!F.isEmpty(nodeIds)) {
                 for (UUID nodeId : nodeIds) {
+                    HashSet<UUID> affIds = affAssignment.getIds(p);
+
                     if (!affIds.contains(nodeId) && hasState(p, nodeId, OWNING, MOVING, RENTING)) {
                         ClusterNode n = cctx.discovery().node(nodeId);
 


[15/28] ignite git commit: fixed npe - https://issues.apache.org/jira/browse/IGNITE-2532

Posted by vo...@apache.org.
fixed npe - https://issues.apache.org/jira/browse/IGNITE-2532


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

Branch: refs/heads/ignite-2508
Commit: 4035d40f18fa2d829eaa17c0496eeecfad81fee1
Parents: ee20f1d
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Feb 2 16:42:35 2016 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Feb 2 16:42:35 2016 +0300

----------------------------------------------------------------------
 .../multicast/TcpDiscoveryMulticastIpFinder.java        | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4035d40f/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index 8402cbf..75b5f91 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -116,7 +116,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
     private String locAddr;
 
     /** Time to live. */
-    private Integer ttl;
+    private int ttl = -1;
 
     /** */
     @GridToStringExclude
@@ -267,6 +267,8 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
      * <p>
      * If TTL is {@code 0}, packets are not transmitted on the network,
      * but may be delivered locally.
+     * <p>
+     * Default value is {@code -1} which corresponds to system default value.
      *
      * @param ttl Time to live.
      */
@@ -307,7 +309,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
             throw new IgniteSpiException("Invalid number of address request attempts, " +
                 "value greater than zero is expected: " + addrReqAttempts);
 
-        if (ttl != null && (ttl < 0 || ttl > 255))
+        if (ttl != -1 && (ttl < 0 || ttl > 255))
             throw new IgniteSpiException("Time-to-live value is out of 0 <= TTL <= 255 range: " + ttl);
 
         if (F.isEmpty(getRegisteredAddresses()))
@@ -545,7 +547,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
 
                     sock.setSoTimeout(resWaitTime);
 
-                    if (ttl != null)
+                    if (ttl != -1)
                         sock.setTimeToLive(ttl);
 
                     reqPckt.setData(MSG_ADDR_REQ_DATA);
@@ -817,7 +819,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
 
             sock.joinGroup(mcastGrp);
 
-            if (ttl != null)
+            if (ttl != -1)
                 sock.setTimeToLive(ttl);
 
             return sock;
@@ -908,4 +910,4 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
             }
         }
     }
-}
\ No newline at end of file
+}


[13/28] ignite git commit: IGNITE-1906: .NET: Implemented programmatic configuration.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
new file mode 100644
index 0000000..2e6a8a1
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -0,0 +1,538 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Cache.Store;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Discovery.Tcp;
+    using Apache.Ignite.Core.Discovery.Tcp.Static;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests cache configuration propagation.
+    /// </summary>
+    public class CacheConfigurationTest
+    {
+        /** */
+        private IIgnite _ignite;
+
+        /** */
+        private const string CacheName = "cacheName";
+
+        /** */
+        private static int _factoryProp;
+
+
+        /// <summary>
+        /// Fixture set up.
+        /// </summary>
+        [TestFixtureSetUp]
+        public void FixtureSetUp()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                CacheConfiguration = new List<CacheConfiguration>
+                {
+                    new CacheConfiguration(),
+                    GetCustomCacheConfiguration()
+                },
+                JvmClasspath = TestUtils.CreateTestClasspath(),
+                JvmOptions = TestUtils.TestJavaOptions(),
+                GridName = CacheName,
+                BinaryConfiguration = new BinaryConfiguration(typeof(Entity)),
+                DiscoverySpi = new TcpDiscoverySpi
+                {
+                    IpFinder = new TcpDiscoveryStaticIpFinder
+                    {
+                        Endpoints = new[] { "127.0.0.1:47500", "127.0.0.1:47501" }
+                    }
+                }
+            };
+
+            _ignite = Ignition.Start(cfg);
+        }
+
+        /// <summary>
+        /// Fixture tear down.
+        /// </summary>
+        [TestFixtureTearDown]
+        public void FixtureTearDown()
+        {
+            Ignition.StopAll(true);
+        }
+
+        /// <summary>
+        /// Tests the default configuration.
+        /// </summary>
+        [Test]
+        public void TestDefaultConfiguration()
+        {
+            AssertConfigIsDefault(new CacheConfiguration());
+
+            AssertConfigIsDefault(_ignite.GetCache<int, int>(null).GetConfiguration());
+
+            AssertConfigIsDefault(_ignite.GetConfiguration().CacheConfiguration.Single(c => c.Name == null));
+        }
+
+        /// <summary>
+        /// Tests the custom configuration.
+        /// </summary>
+        [Test]
+        public void TestCustomConfiguration()
+        {
+            AssertConfigsAreEqual(GetCustomCacheConfiguration(),
+                _ignite.GetCache<int, int>(CacheName).GetConfiguration());
+
+            AssertConfigsAreEqual(GetCustomCacheConfiguration(),
+                _ignite.GetConfiguration().CacheConfiguration.Single(c => c.Name == CacheName));
+        }
+
+        /// <summary>
+        /// Tests the create from configuration.
+        /// </summary>
+        [Test]
+        public void TestCreateFromConfiguration()
+        {
+            var cacheName = Guid.NewGuid().ToString();
+            var cfg = GetCustomCacheConfiguration(cacheName);
+
+            var cache = _ignite.CreateCache<int, Entity>(cfg);
+            AssertConfigsAreEqual(cfg, cache.GetConfiguration());
+
+            // Can't create existing cache
+            Assert.Throws<IgniteException>(() => _ignite.CreateCache<int, int>(cfg));
+            
+            // Check put-get
+            cache[1] = new Entity { Foo = 1 };
+            Assert.AreEqual(1, cache[1].Foo);
+        }
+
+        /// <summary>
+        /// Tests the get or create from configuration.
+        /// </summary>
+        [Test]
+        public void TestGetOrCreateFromConfiguration()
+        {
+            var cacheName = Guid.NewGuid().ToString();
+            var cfg = GetCustomCacheConfiguration(cacheName);
+
+            var cache = _ignite.GetOrCreateCache<int, Entity>(cfg);
+            AssertConfigsAreEqual(cfg, cache.GetConfiguration());
+
+            var cache2 = _ignite.GetOrCreateCache<int, Entity>(cfg);
+            AssertConfigsAreEqual(cfg, cache2.GetConfiguration());
+
+            // Check put-get
+            cache[1] = new Entity { Foo = 1 };
+            Assert.AreEqual(1, cache[1].Foo);
+        }
+
+        /// <summary>
+        /// Tests the cache store.
+        /// </summary>
+        [Test]
+        public void TestCacheStore()
+        {
+            _factoryProp = 0;
+
+            var factory = new CacheStoreFactoryTest {TestProperty = 15};
+
+            var cache = _ignite.CreateCache<int, int>(new CacheConfiguration("cacheWithStore")
+            {
+                CacheStoreFactory = factory
+            });
+
+            Assert.AreEqual(factory.TestProperty, _factoryProp);
+
+            var factory0 = cache.GetConfiguration().CacheStoreFactory as CacheStoreFactoryTest;
+
+            Assert.IsNotNull(factory0);
+            Assert.AreEqual(factory.TestProperty, factory0.TestProperty);
+        }
+
+        /// <summary>
+        /// Asserts the configuration is default.
+        /// </summary>
+        private static void AssertConfigIsDefault(CacheConfiguration cfg)
+        {
+            Assert.AreEqual(CacheConfiguration.DefaultBackups, cfg.Backups);
+            Assert.AreEqual(CacheConfiguration.DefaultAtomicityMode, cfg.AtomicityMode);
+            Assert.AreEqual(CacheConfiguration.DefaultCacheMode, cfg.CacheMode);
+            Assert.AreEqual(CacheConfiguration.DefaultCopyOnRead, cfg.CopyOnRead);
+            Assert.AreEqual(CacheConfiguration.DefaultStartSize, cfg.StartSize);
+            Assert.AreEqual(CacheConfiguration.DefaultEagerTtl, cfg.EagerTtl);
+            Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronizedKeyBufferSize, cfg.EvictSynchronizedKeyBufferSize);
+            Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronized, cfg.EvictSynchronized);
+            Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronizedConcurrencyLevel, cfg.EvictSynchronizedConcurrencyLevel);
+            Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronizedTimeout, cfg.EvictSynchronizedTimeout);
+            Assert.AreEqual(CacheConfiguration.DefaultInvalidate, cfg.Invalidate);
+            Assert.AreEqual(CacheConfiguration.DefaultKeepVinaryInStore, cfg.KeepBinaryInStore);
+            Assert.AreEqual(CacheConfiguration.DefaultLoadPreviousValue, cfg.LoadPreviousValue);
+            Assert.AreEqual(CacheConfiguration.DefaultLockTimeout, cfg.LockTimeout);
+            Assert.AreEqual(CacheConfiguration.DefaultLongQueryWarningTimeout, cfg.LongQueryWarningTimeout);
+            Assert.AreEqual(CacheConfiguration.DefaultMaxConcurrentAsyncOperations, cfg.MaxConcurrentAsyncOperations);
+            Assert.AreEqual(CacheConfiguration.DefaultMaxEvictionOverflowRatio, cfg.MaxEvictionOverflowRatio);
+            Assert.AreEqual(CacheConfiguration.DefaultMemoryMode, cfg.MemoryMode);
+            Assert.AreEqual(CacheConfiguration.DefaultOffHeapMaxMemory, cfg.OffHeapMaxMemory);
+            Assert.AreEqual(CacheConfiguration.DefaultReadFromBackup, cfg.ReadFromBackup);
+            Assert.AreEqual(CacheConfiguration.DefaultRebalanceBatchSize, cfg.RebalanceBatchSize);
+            Assert.AreEqual(CacheConfiguration.DefaultRebalanceMode, cfg.RebalanceMode);
+            Assert.AreEqual(CacheConfiguration.DefaultRebalanceThrottle, cfg.RebalanceThrottle);
+            Assert.AreEqual(CacheConfiguration.DefaultRebalanceTimeout, cfg.RebalanceTimeout);
+            Assert.AreEqual(CacheConfiguration.DefaultSqlOnheapRowCacheSize, cfg.SqlOnheapRowCacheSize);
+            Assert.AreEqual(CacheConfiguration.DefaultStartSize, cfg.StartSize);
+            Assert.AreEqual(CacheConfiguration.DefaultStartSize, cfg.StartSize);
+            Assert.AreEqual(CacheConfiguration.DefaultEnableSwap, cfg.EnableSwap);
+            Assert.AreEqual(CacheConfiguration.DefaultWriteBehindBatchSize, cfg.WriteBehindBatchSize);
+            Assert.AreEqual(CacheConfiguration.DefaultWriteBehindEnabled, cfg.WriteBehindEnabled);
+            Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushFrequency, cfg.WriteBehindFlushFrequency);
+            Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushSize, cfg.WriteBehindFlushSize);
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(CacheConfiguration x, CacheConfiguration y)
+        {
+            Assert.AreEqual(x.Backups, y.Backups);
+            Assert.AreEqual(x.AtomicityMode, y.AtomicityMode);
+            Assert.AreEqual(x.CacheMode, y.CacheMode);
+            Assert.AreEqual(x.CopyOnRead, y.CopyOnRead);
+            Assert.AreEqual(x.StartSize, y.StartSize);
+            Assert.AreEqual(x.EagerTtl, y.EagerTtl);
+            Assert.AreEqual(x.EvictSynchronizedKeyBufferSize, y.EvictSynchronizedKeyBufferSize);
+            Assert.AreEqual(x.EvictSynchronized, y.EvictSynchronized);
+            Assert.AreEqual(x.EvictSynchronizedConcurrencyLevel, y.EvictSynchronizedConcurrencyLevel);
+            Assert.AreEqual(x.EvictSynchronizedTimeout, y.EvictSynchronizedTimeout);
+            Assert.AreEqual(x.Invalidate, y.Invalidate);
+            Assert.AreEqual(x.KeepBinaryInStore, y.KeepBinaryInStore);
+            Assert.AreEqual(x.LoadPreviousValue, y.LoadPreviousValue);
+            Assert.AreEqual(x.LockTimeout, y.LockTimeout);
+            Assert.AreEqual(x.LongQueryWarningTimeout, y.LongQueryWarningTimeout);
+            Assert.AreEqual(x.MaxConcurrentAsyncOperations, y.MaxConcurrentAsyncOperations);
+            Assert.AreEqual(x.MaxEvictionOverflowRatio, y.MaxEvictionOverflowRatio);
+            Assert.AreEqual(x.MemoryMode, y.MemoryMode);
+            Assert.AreEqual(x.OffHeapMaxMemory, y.OffHeapMaxMemory);
+            Assert.AreEqual(x.ReadFromBackup, y.ReadFromBackup);
+            Assert.AreEqual(x.RebalanceBatchSize, y.RebalanceBatchSize);
+            Assert.AreEqual(x.RebalanceMode, y.RebalanceMode);
+            Assert.AreEqual(x.RebalanceThrottle, y.RebalanceThrottle);
+            Assert.AreEqual(x.RebalanceTimeout, y.RebalanceTimeout);
+            Assert.AreEqual(x.SqlOnheapRowCacheSize, y.SqlOnheapRowCacheSize);
+            Assert.AreEqual(x.StartSize, y.StartSize);
+            Assert.AreEqual(x.StartSize, y.StartSize);
+            Assert.AreEqual(x.EnableSwap, y.EnableSwap);
+            Assert.AreEqual(x.WriteBehindBatchSize, y.WriteBehindBatchSize);
+            Assert.AreEqual(x.WriteBehindEnabled, y.WriteBehindEnabled);
+            Assert.AreEqual(x.WriteBehindFlushFrequency, y.WriteBehindFlushFrequency);
+            Assert.AreEqual(x.WriteBehindFlushSize, y.WriteBehindFlushSize);
+
+            AssertConfigsAreEqual(x.QueryEntities, y.QueryEntities);
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(ICollection<QueryEntity> x, ICollection<QueryEntity> y)
+        {
+            if (x == null)
+            {
+                Assert.IsNull(y);
+                return;
+            }
+
+            Assert.AreEqual(x.Count, y.Count);
+
+            for (var i = 0; i < x.Count; i++)
+                AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(QueryEntity x, QueryEntity y)
+        {
+            Assert.IsNotNull(x);
+            Assert.IsNotNull(y);
+
+            Assert.AreEqual(x.KeyTypeName, y.KeyTypeName);
+            Assert.AreEqual(x.ValueTypeName, y.ValueTypeName);
+
+            AssertConfigsAreEqual(x.Fields, y.Fields);
+            AssertConfigsAreEqual(x.Aliases, y.Aliases);
+
+            AssertConfigsAreEqual(x.Indexes, y.Indexes);
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(ICollection<QueryIndex> x, ICollection<QueryIndex> y)
+        {
+            if (x == null)
+            {
+                Assert.IsNull(y);
+                return;
+            }
+
+            Assert.AreEqual(x.Count, y.Count);
+
+            for (var i = 0; i < x.Count; i++)
+                AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(ICollection<QueryField> x, ICollection<QueryField> y)
+        {
+            if (x == null)
+            {
+                Assert.IsNull(y);
+                return;
+            }
+
+            Assert.AreEqual(x.Count, y.Count);
+
+            for (var i = 0; i < x.Count; i++)
+                AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(ICollection<QueryAlias> x, ICollection<QueryAlias> y)
+        {
+            if (x == null)
+            {
+                Assert.IsNull(y);
+                return;
+            }
+
+            Assert.AreEqual(x.Count, y.Count);
+
+            for (var i = 0; i < x.Count; i++)
+                AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(ICollection<QueryIndexField> x, ICollection<QueryIndexField> y)
+        {
+            if (x == null)
+            {
+                Assert.IsNull(y);
+                return;
+            }
+
+            Assert.AreEqual(x.Count, y.Count);
+
+            for (var i = 0; i < x.Count; i++)
+                AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(QueryIndex x, QueryIndex y)
+        {
+            Assert.IsNotNull(x);
+            Assert.IsNotNull(y);
+
+            Assert.AreEqual(x.Name, y.Name);
+            Assert.AreEqual(x.IndexType, y.IndexType);
+
+            AssertConfigsAreEqual(x.Fields, y.Fields);
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(QueryField x, QueryField y)
+        {
+            Assert.IsNotNull(x);
+            Assert.IsNotNull(y);
+
+            Assert.AreEqual(x.Name, y.Name);
+            Assert.AreEqual(x.FieldTypeName, y.FieldTypeName);
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(QueryAlias x, QueryAlias y)
+        {
+            Assert.IsNotNull(x);
+            Assert.IsNotNull(y);
+
+            Assert.AreEqual(x.FullName, y.FullName);
+            Assert.AreEqual(x.Alias, y.Alias);
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(QueryIndexField x, QueryIndexField y)
+        {
+            Assert.IsNotNull(x);
+            Assert.IsNotNull(y);
+
+            Assert.AreEqual(x.Name, y.Name);
+            Assert.AreEqual(x.IsDescending, y.IsDescending);
+        }
+
+        /// <summary>
+        /// Gets the custom cache configuration.
+        /// </summary>
+        private static CacheConfiguration GetCustomCacheConfiguration(string name = null)
+        {
+            return new CacheConfiguration
+            {
+                Name = name ?? CacheName,
+                OffHeapMaxMemory = 1,
+                StartSize = 2,
+                MaxConcurrentAsyncOperations = 3,
+                WriteBehindFlushThreadCount = 4,
+                LongQueryWarningTimeout = TimeSpan.FromSeconds(5),
+                LoadPreviousValue = true,
+                EvictSynchronizedKeyBufferSize = 6,
+                CopyOnRead = true,
+                WriteBehindFlushFrequency = TimeSpan.FromSeconds(6),
+                WriteBehindFlushSize = 7,
+                EvictSynchronized = true,
+                AtomicWriteOrderMode = CacheAtomicWriteOrderMode.Primary,
+                AtomicityMode = CacheAtomicityMode.Atomic,
+                Backups = 8,
+                CacheMode = CacheMode.Partitioned,
+                EagerTtl = true,
+                EnableSwap = true,
+                EvictSynchronizedConcurrencyLevel = 9,
+                EvictSynchronizedTimeout = TimeSpan.FromSeconds(10),
+                Invalidate = true,
+                KeepBinaryInStore = true,
+                LockTimeout = TimeSpan.FromSeconds(11),
+                MaxEvictionOverflowRatio = 0.5f,
+                MemoryMode = CacheMemoryMode.OnheapTiered,
+                ReadFromBackup = true,
+                RebalanceBatchSize = 12,
+                RebalanceDelay = TimeSpan.FromSeconds(13),
+                RebalanceMode = CacheRebalanceMode.Async,
+                RebalanceThrottle = TimeSpan.FromSeconds(15),
+                RebalanceTimeout = TimeSpan.FromSeconds(16),
+                SqlEscapeAll = true,
+                SqlOnheapRowCacheSize = 17,
+                WriteBehindBatchSize = 18,
+                WriteBehindEnabled = false,
+                WriteSynchronizationMode = CacheWriteSynchronizationMode.PrimarySync,
+                QueryEntities = new[]
+                {
+                    new QueryEntity
+                    {
+                        KeyTypeName = "Integer",
+                        ValueTypeName = "java.lang.String",
+                        Fields = new[]
+                        {
+                            new QueryField("length", typeof(int)), 
+                            new QueryField("name", typeof(string)), 
+                            new QueryField("location", typeof(string)),
+                        },
+                        Aliases = new [] {new QueryAlias("length", "len") },
+                        Indexes = new[]
+                        {
+                            new QueryIndex("name") {Name = "index1" },
+                            new QueryIndex(new QueryIndexField("location", true))
+                            {
+                                Name= "index2",
+                                IndexType = QueryIndexType.FullText
+                            }
+                        }
+                    }
+                }
+            };
+        }
+
+        /// <summary>
+        /// Test factory.
+        /// </summary>
+        [Serializable]
+        private class CacheStoreFactoryTest : IFactory<ICacheStore>
+        {
+            /// <summary>
+            /// Gets or sets the test property.
+            /// </summary>
+            /// <value>
+            /// The test property.
+            /// </value>
+            public int TestProperty { get; set; }
+
+            /// <summary>
+            /// Creates an instance of the cache store.
+            /// </summary>
+            /// <returns>
+            /// New instance of the cache store.
+            /// </returns>
+            public ICacheStore CreateInstance()
+            {
+                _factoryProp = TestProperty;
+
+                return new CacheStoreTest();
+            }
+        }
+
+        /// <summary>
+        /// Test store.
+        /// </summary>
+        private class CacheStoreTest : CacheStoreAdapter
+        {
+            /** <inheritdoc /> */
+            public override object Load(object key)
+            {
+                return null;
+            }
+
+            /** <inheritdoc /> */
+            public override void Write(object key, object val)
+            {
+                // No-op.
+            }
+
+            /** <inheritdoc /> */
+            public override void Delete(object key)
+            {
+                // No-op.
+            }
+        }
+
+        /// <summary>
+        /// Test entity.
+        /// </summary>
+        private class Entity
+        {
+            /// <summary>
+            /// Gets or sets the foo.
+            /// </summary>
+            public int Foo { get; set; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
index 63443b7..7c18a34 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
@@ -79,9 +79,9 @@ namespace Apache.Ignite.Core.Tests.Cache
         /// <param name="name">Grid name.</param>
         /// <param name="springCfg">Spring configuration.</param>
         /// <returns>Configuration.</returns>
-        private static IgniteConfigurationEx CreateConfiguration(string name, string springCfg)
+        private static IgniteConfiguration CreateConfiguration(string name, string springCfg)
         {
-            IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+            var cfg = new IgniteConfiguration();
 
             BinaryConfiguration portCfg = new BinaryConfiguration();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
index 33c9f11..09e57dc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -23,6 +23,7 @@ namespace Apache.Ignite.Core.Tests.Cache
     using System.Diagnostics;
     using System.Threading.Tasks;
     using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Cache.Expiry;
     using Apache.Ignite.Core.Cache.Query;
     using Apache.Ignite.Core.Cache.Query.Continuous;
@@ -58,6 +59,12 @@ namespace Apache.Ignite.Core.Tests.Cache
         }
 
         /** <inheritDoc /> */
+        public CacheConfiguration GetConfiguration()
+        {
+            return _cache.GetConfiguration();
+        }
+
+        /** <inheritDoc /> */
         public bool IsEmpty()
         {
             return _cache.IsEmpty();

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
new file mode 100644
index 0000000..a969127
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
@@ -0,0 +1,295 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable MemberCanBePrivate.Local
+// ReSharper disable UnusedAutoPropertyAccessor.Local
+// ReSharper disable UnusedMember.Local
+namespace Apache.Ignite.Core.Tests.Cache.Query
+{
+    using System;
+    using System.Linq;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Cache.Query;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests queries with in-code configuration.
+    /// </summary>
+    public class CacheQueriesCodeConfigurationTest
+    {
+        const string CacheName = "personCache";
+
+        /// <summary>
+        /// Tests the SQL query.
+        /// </summary>
+        [Test]
+        public void TestQueryEntityConfiguration()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                JvmOptions = TestUtils.TestJavaOptions(),
+                JvmClasspath = TestUtils.CreateTestClasspath(),
+                BinaryConfiguration = new BinaryConfiguration(typeof (QueryPerson)),
+                CacheConfiguration = new[]
+                {
+                    new CacheConfiguration(CacheName, new QueryEntity(typeof (int), typeof (QueryPerson))
+                    {
+                        Fields = new[]
+                        {
+                            new QueryField("Name", typeof (string)),
+                            new QueryField("Age", typeof (int))
+                        },
+                        Indexes = new[]
+                        {
+                            new QueryIndex(false, QueryIndexType.FullText, "Name"), new QueryIndex("Age")
+                        }
+                    })
+                }
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                var cache = ignite.GetCache<int, QueryPerson>(CacheName);
+
+                Assert.IsNotNull(cache);
+
+                cache[1] = new QueryPerson("Arnold", 10);
+                cache[2] = new QueryPerson("John", 20);
+
+                using (var cursor = cache.Query(new SqlQuery(typeof (QueryPerson), "age > 10")))
+                {
+                    Assert.AreEqual(2, cursor.GetAll().Single().Key);
+                }
+
+                using (var cursor = cache.Query(new TextQuery(typeof (QueryPerson), "Ar*")))
+                {
+                    Assert.AreEqual(1, cursor.GetAll().Single().Key);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Tests the attribute configuration.
+        /// </summary>
+        [Test]
+        public void TestAttributeConfiguration()
+        {
+            // ReSharper disable once ObjectCreationAsStatement
+            Assert.Throws<InvalidOperationException>(() => new QueryEntity(typeof (RecursiveQuery)));
+
+            var qe = new QueryEntity {ValueType = typeof(AttributeTest) };
+
+            Assert.AreEqual(typeof(AttributeTest), qe.ValueType);
+
+            var fields = qe.Fields.ToArray();
+
+            CollectionAssert.AreEquivalent(new[]
+            {
+                "SqlField", "IndexedField1", "FullTextField", "Inner", "Inner.Foo",
+                "GroupIndex1", "GroupIndex2", "GroupIndex3"
+            }, fields.Select(x => x.Name));
+
+            var idx = qe.Indexes.ToArray();
+
+            Assert.AreEqual(QueryIndexType.Sorted, idx[0].IndexType);
+            Assert.AreEqual(QueryIndexType.Sorted, idx[1].IndexType);
+            Assert.AreEqual(QueryIndexType.Sorted, idx[2].IndexType);
+            Assert.AreEqual(QueryIndexType.FullText, idx[3].IndexType);
+
+            CollectionAssert.AreEquivalent(new[] {"GroupIndex1", "GroupIndex2"}, idx[0].Fields.Select(f => f.Name));
+            CollectionAssert.AreEquivalent(new[] {"GroupIndex1", "GroupIndex3"}, idx[1].Fields.Select(f => f.Name));
+            CollectionAssert.AreEquivalent(new[] {"IndexedField1"}, idx[2].Fields.Select(f => f.Name));
+            CollectionAssert.AreEquivalent(new[] {"FullTextField"}, idx[3].Fields.Select(f => f.Name));
+        }
+
+        /// <summary>
+        /// Tests the attribute configuration query.
+        /// </summary>
+        [Test]
+        public void TestAttributeConfigurationQuery()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                JvmOptions = TestUtils.TestJavaOptions(),
+                JvmClasspath = TestUtils.CreateTestClasspath(),
+                BinaryConfiguration = new BinaryConfiguration(
+                    typeof (AttributeQueryPerson), typeof (AttributeQueryAddress)),
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                var cache = ignite.GetOrCreateCache<int, AttributeQueryPerson>(new CacheConfiguration(CacheName,
+                        typeof (AttributeQueryPerson)));
+
+                Assert.IsNotNull(cache);
+
+                cache[1] = new AttributeQueryPerson("Arnold", 10)
+                {
+                    Address = new AttributeQueryAddress {Country = "USA", Street = "Pine Tree road"}
+                };
+
+                cache[2] = new AttributeQueryPerson("John", 20);
+
+                using (var cursor = cache.Query(new SqlQuery(typeof(AttributeQueryPerson), "age > ?", 10)))
+                {
+                    Assert.AreEqual(2, cursor.GetAll().Single().Key);
+                }
+
+                using (var cursor = cache.Query(new SqlQuery(typeof(AttributeQueryPerson), "Country = ?", "USA")))
+                {
+                    Assert.AreEqual(1, cursor.GetAll().Single().Key);
+                }
+
+                using (var cursor = cache.Query(new TextQuery(typeof(AttributeQueryPerson), "Ar*")))
+                {
+                    Assert.AreEqual(1, cursor.GetAll().Single().Key);
+                }
+
+                using (var cursor = cache.Query(new TextQuery(typeof(AttributeQueryPerson), "Pin*")))
+                {
+                    Assert.AreEqual(1, cursor.GetAll().Single().Key);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Test person.
+        /// </summary>
+        private class AttributeQueryPerson
+        {
+            /// <summary>
+            /// Initializes a new instance of the <see cref="AttributeQueryPerson"/> class.
+            /// </summary>
+            /// <param name="name">The name.</param>
+            /// <param name="age">The age.</param>
+            public AttributeQueryPerson(string name, int age)
+            {
+                Name = name;
+                Age = age;
+            }
+
+            /// <summary>
+            /// Gets or sets the name.
+            /// </summary>
+            /// <value>
+            /// The name.
+            /// </value>
+            [QueryTextField]
+            public string Name { get; set; }
+
+            /// <summary>
+            /// Gets or sets the age.
+            /// </summary>
+            /// <value>
+            /// The age.
+            /// </value>
+            [QuerySqlField]
+            public int Age { get; set; }
+
+            /// <summary>
+            /// Gets or sets the address.
+            /// </summary>
+            /// <value>
+            /// The address.
+            /// </value>
+            [QuerySqlField]
+            public AttributeQueryAddress Address { get; set; }
+        }
+
+        /// <summary>
+        /// Address.
+        /// </summary>
+        private class AttributeQueryAddress
+        {
+            /// <summary>
+            /// Gets or sets the country.
+            /// </summary>
+            /// <value>
+            /// The country.
+            /// </value>
+            [QuerySqlField]
+            public string Country { get; set; }
+
+            /// <summary>
+            /// Gets or sets the street.
+            /// </summary>
+            /// <value>
+            /// The street.
+            /// </value>
+            [QueryTextField]
+            public string Street { get; set; }
+        }
+
+        /// <summary>
+        /// Query.
+        /// </summary>
+        private class RecursiveQuery
+        {
+            /// <summary>
+            /// Gets or sets the inner.
+            /// </summary>
+            /// <value>
+            /// The inner.
+            /// </value>
+            [QuerySqlField]
+            public RecursiveQuery Inner { get; set; }
+        }
+
+        /// <summary>
+        /// Attribute test class.
+        /// </summary>
+        private class AttributeTest
+        {
+            [QuerySqlField]
+            public double SqlField { get; set; }
+
+            [QuerySqlField(IsIndexed = true, Name = "IndexedField1")]
+            public int IndexedField { get; set; }
+
+            [QueryTextField]
+            public string FullTextField { get; set; }
+
+            [QuerySqlField]
+            public AttributeTestInner Inner { get; set; }
+
+            [QuerySqlField(IsIndexed = true, IndexGroups = new[] {"group1", "group2"})]
+            public string GroupIndex1 { get; set; }
+
+            [QuerySqlField(IsIndexed = true, IndexGroups = new[] {"group1"})]
+            public string GroupIndex2 { get; set; }
+
+            [QuerySqlField(IsIndexed = true, IndexGroups = new[] {"group2"})]
+            public string GroupIndex3 { get; set; }
+        }
+
+        /// <summary>
+        /// Inner class.
+        /// </summary>
+        private class AttributeTestInner
+        {
+            /// <summary>
+            /// Gets or sets the foo.
+            /// </summary>
+            /// <value>
+            /// The foo.
+            /// </value>
+            [QuerySqlField]
+            public string Foo { get; set; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 08a98f6..8020649 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -57,7 +57,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             TestUtils.JvmDebug = true;
             TestUtils.KillProcesses();
 
-            IgniteConfigurationEx cfg = new IgniteConfigurationEx
+            IgniteConfiguration cfg = new IgniteConfiguration
             {
                 BinaryConfiguration = new BinaryConfiguration
                 {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
index bdca918..0036abd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
@@ -95,7 +95,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
             GC.Collect();
             TestUtils.JvmDebug = true;
 
-            IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+            IgniteConfiguration cfg = new IgniteConfiguration();
 
             BinaryConfiguration portCfg = new BinaryConfiguration();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
index 137215e..5cc0849 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
@@ -55,7 +55,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
 
             TestUtils.JvmDebug = true;
 
-            IgniteConfigurationEx cfg = new IgniteConfigurationEx
+            IgniteConfiguration cfg = new IgniteConfiguration
             {
                 GridName = IgniteName,
                 JvmClasspath = TestUtils.CreateTestClasspath(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index 1270138..b48cdc9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -23,7 +23,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Store;
-    using Apache.Ignite.Core.Impl;
     using NUnit.Framework;
 
     /// <summary>
@@ -137,24 +136,18 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
         [TestFixtureSetUp]
         public void BeforeTests()
         {
-            //TestUtils.JVM_DEBUG = true;
-
             TestUtils.KillProcesses();
 
             TestUtils.JvmDebug = true;
 
-            IgniteConfigurationEx cfg = new IgniteConfigurationEx();
-
-            cfg.GridName = GridName;
-            cfg.JvmClasspath = TestUtils.CreateTestClasspath();
-            cfg.JvmOptions = TestUtils.TestJavaOptions();
-            cfg.SpringConfigUrl = "config\\native-client-test-cache-store.xml";
-
-            BinaryConfiguration portCfg = new BinaryConfiguration();
-
-            portCfg.Types = new List<string> { typeof(Key).FullName, typeof(Value).FullName };
-
-            cfg.BinaryConfiguration = portCfg;
+            var cfg = new IgniteConfiguration
+            {
+                GridName = GridName,
+                JvmClasspath = TestUtils.CreateTestClasspath(),
+                JvmOptions = TestUtils.TestJavaOptions(),
+                SpringConfigUrl = "config\\native-client-test-cache-store.xml",
+                BinaryConfiguration = new BinaryConfiguration(typeof (Key), typeof (Value))
+            };
 
             Ignition.Start(cfg);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
index 20ae629..f5a04c1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
@@ -461,9 +461,9 @@ namespace Apache.Ignite.Core.Tests.Dataload
         /// Gets the Ignite configuration.
         /// </summary>
         /// <param name="gridName">Grid name.</param>
-        private static IgniteConfigurationEx GetIgniteConfiguration(string gridName)
+        private static IgniteConfiguration GetIgniteConfiguration(string gridName)
         {
-            return new IgniteConfigurationEx
+            return new IgniteConfiguration
             {
                 GridName = gridName,
                 SpringConfigUrl = "config\\native-client-test-cache.xml",

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
index 79297da..50ecfac 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
@@ -285,7 +285,7 @@ namespace Apache.Ignite.Core.Tests
         /// </summary>
         private static IIgnite StartGrid(string gridName = null)
         {
-            return Ignition.Start(new IgniteConfigurationEx
+            return Ignition.Start(new IgniteConfiguration
             {
                 SpringConfigUrl = "config\\native-client-test-cache.xml",
                 JvmOptions = TestUtils.TestJavaOptions(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
new file mode 100644
index 0000000..15f5804
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -0,0 +1,367 @@
+/*
+ * 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.
+ */
+
+#pragma warning disable 618  // deprecated SpringConfigUrl
+namespace Apache.Ignite.Core.Tests
+{
+    using System;
+    using System.ComponentModel;
+    using System.IO;
+    using System.Linq;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Discovery;
+    using Apache.Ignite.Core.Discovery.Tcp;
+    using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+    using Apache.Ignite.Core.Discovery.Tcp.Static;
+    using Apache.Ignite.Core.Events;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests code-based configuration.
+    /// </summary>
+    public class IgniteConfigurationTest
+    {
+        /// <summary>
+        /// Fixture setup.
+        /// </summary>
+        [TestFixtureSetUp]
+        public void FixtureSetUp()
+        {
+            Ignition.StopAll(true);
+        }
+
+        /// <summary>
+        /// Tests the default configuration properties.
+        /// </summary>
+        [Test]
+        public void TestDefaultConfigurationProperties()
+        {
+            CheckDefaultProperties(new IgniteConfiguration());
+        }
+
+        /// <summary>
+        /// Tests the default value attributes.
+        /// </summary>
+        [Test]
+        public void TestDefaultValueAttributes()
+        {
+            CheckDefaultValueAttributes(new IgniteConfiguration());
+            CheckDefaultValueAttributes(new TcpDiscoverySpi());
+            CheckDefaultValueAttributes(new CacheConfiguration());
+            CheckDefaultValueAttributes(new TcpDiscoveryMulticastIpFinder());
+        }
+
+        /// <summary>
+        /// Tests all configuration properties.
+        /// </summary>
+        [Test]
+        public void TestAllConfigurationProperties()
+        {
+            var cfg = new IgniteConfiguration(GetCustomConfig());
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                var resCfg = ignite.GetConfiguration();
+
+                var disco = (TcpDiscoverySpi) cfg.DiscoverySpi;
+                var resDisco = (TcpDiscoverySpi) resCfg.DiscoverySpi;
+
+                Assert.AreEqual(disco.NetworkTimeout, resDisco.NetworkTimeout);
+                Assert.AreEqual(disco.AckTimeout, resDisco.AckTimeout);
+                Assert.AreEqual(disco.MaxAckTimeout, resDisco.MaxAckTimeout);
+                Assert.AreEqual(disco.SocketTimeout, resDisco.SocketTimeout);
+                Assert.AreEqual(disco.JoinTimeout, resDisco.JoinTimeout);
+
+                var ip = (TcpDiscoveryStaticIpFinder) disco.IpFinder;
+                var resIp = (TcpDiscoveryStaticIpFinder) resDisco.IpFinder;
+
+                // There can be extra IPv6 endpoints
+                Assert.AreEqual(ip.Endpoints, resIp.Endpoints.Take(2).Select(x => x.Trim('/')).ToArray());
+
+                Assert.AreEqual(cfg.GridName, resCfg.GridName);
+                Assert.AreEqual(cfg.IncludedEventTypes, resCfg.IncludedEventTypes);
+                Assert.AreEqual(cfg.MetricsExpireTime, resCfg.MetricsExpireTime);
+                Assert.AreEqual(cfg.MetricsHistorySize, resCfg.MetricsHistorySize);
+                Assert.AreEqual(cfg.MetricsLogFrequency, resCfg.MetricsLogFrequency);
+                Assert.AreEqual(cfg.MetricsUpdateFrequency, resCfg.MetricsUpdateFrequency);
+                Assert.AreEqual(cfg.NetworkSendRetryCount, resCfg.NetworkSendRetryCount);
+                Assert.AreEqual(cfg.NetworkTimeout, resCfg.NetworkTimeout);
+                Assert.AreEqual(cfg.NetworkSendRetryDelay, resCfg.NetworkSendRetryDelay);
+                Assert.AreEqual(cfg.WorkDirectory, resCfg.WorkDirectory);
+                Assert.AreEqual(cfg.JvmClasspath, resCfg.JvmClasspath);
+                Assert.AreEqual(cfg.JvmOptions, resCfg.JvmOptions);
+                Assert.IsTrue(File.Exists(resCfg.JvmDllPath));
+                Assert.AreEqual(cfg.Localhost, resCfg.Localhost);
+            }
+        }
+
+        /// <summary>
+        /// Tests the spring XML.
+        /// </summary>
+        [Test]
+        public void TestSpringXml()
+        {
+            // When Spring XML is used, all properties are ignored.
+            var cfg = GetCustomConfig();
+
+            cfg.SpringConfigUrl = "config\\marshaller-default.xml";
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                var resCfg = ignite.GetConfiguration();
+
+                CheckDefaultProperties(resCfg);
+            }
+        }
+
+        /// <summary>
+        /// Tests the client mode.
+        /// </summary>
+        [Test]
+        public void TestClientMode()
+        {
+            using (var ignite = Ignition.Start(new IgniteConfiguration
+            {
+                Localhost = "127.0.0.1",
+                DiscoverySpi = GetStaticDiscovery()
+            }))
+            using (var ignite2 = Ignition.Start(new IgniteConfiguration
+            {
+                Localhost = "127.0.0.1",
+                DiscoverySpi = GetStaticDiscovery(),
+                GridName = "client",
+                ClientMode = true
+            }))
+            {
+                const string cacheName = "cache";
+
+                ignite.CreateCache<int, int>(cacheName);
+
+                Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count);
+                Assert.AreEqual(1, ignite.GetCluster().ForCacheNodes(cacheName).GetNodes().Count);
+
+                Assert.AreEqual(false, ignite.GetConfiguration().ClientMode);
+                Assert.AreEqual(true, ignite2.GetConfiguration().ClientMode);
+            }
+        }
+
+        /// <summary>
+        /// Tests the default spi.
+        /// </summary>
+        [Test]
+        public void TestDefaultSpi()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                DiscoverySpi =
+                    new TcpDiscoverySpi
+                    {
+                        AckTimeout = TimeSpan.FromDays(2),
+                        MaxAckTimeout = TimeSpan.MaxValue,
+                        JoinTimeout = TimeSpan.MaxValue,
+                        NetworkTimeout = TimeSpan.MaxValue,
+                        SocketTimeout = TimeSpan.MaxValue
+                    },
+                JvmClasspath = TestUtils.CreateTestClasspath(),
+                JvmOptions = TestUtils.TestJavaOptions(),
+                Localhost = "127.0.0.1"
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                cfg.GridName = "ignite2";
+                using (var ignite2 = Ignition.Start(cfg))
+                {
+                    Assert.AreEqual(2, ignite.GetCluster().GetNodes().Count);
+                    Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Tests the invalid timeouts.
+        /// </summary>
+        [Test]
+        public void TestInvalidTimeouts()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                DiscoverySpi =
+                    new TcpDiscoverySpi
+                    {
+                        AckTimeout = TimeSpan.FromMilliseconds(-5),
+                        JoinTimeout = TimeSpan.MinValue,
+                    },
+                JvmClasspath = TestUtils.CreateTestClasspath(),
+                JvmOptions = TestUtils.TestJavaOptions(),
+            };
+
+            Assert.Throws<IgniteException>(() => Ignition.Start(cfg));
+        }
+
+        /// <summary>
+        /// Tests the static ip finder.
+        /// </summary>
+        [Test]
+        public void TestStaticIpFinder()
+        {
+            TestIpFinders(new TcpDiscoveryStaticIpFinder
+            {
+                Endpoints = new[] {"127.0.0.1:47500"}
+            }, new TcpDiscoveryStaticIpFinder
+            {
+                Endpoints = new[] {"127.0.0.1:47501"}
+            });
+        }
+
+        /// <summary>
+        /// Tests the multicast ip finder.
+        /// </summary>
+        [Test]
+        public void TestMulticastIpFinder()
+        {
+            TestIpFinders(
+                new TcpDiscoveryMulticastIpFinder {MulticastGroup = "228.111.111.222", MulticastPort = 54522},
+                new TcpDiscoveryMulticastIpFinder {MulticastGroup = "228.111.111.223", MulticastPort = 54522});
+        }
+
+        /// <summary>
+        /// Tests the ip finders.
+        /// </summary>
+        /// <param name="ipFinder">The ip finder.</param>
+        /// <param name="ipFinder2">The ip finder2.</param>
+        private static void TestIpFinders(TcpDiscoveryIpFinderBase ipFinder, TcpDiscoveryIpFinderBase ipFinder2)
+        {
+            var cfg = new IgniteConfiguration
+            {
+                DiscoverySpi =
+                    new TcpDiscoverySpi
+                    {
+                        IpFinder = ipFinder
+                    },
+                JvmClasspath = TestUtils.CreateTestClasspath(),
+                JvmOptions = TestUtils.TestJavaOptions(),
+                Localhost = "127.0.0.1"
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                // Start with the same endpoint
+                cfg.GridName = "ignite2";
+                using (var ignite2 = Ignition.Start(cfg))
+                {
+                    Assert.AreEqual(2, ignite.GetCluster().GetNodes().Count);
+                    Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count);
+                }
+
+                // Start with incompatible endpoint and check that there are 2 topologies
+                ((TcpDiscoverySpi) cfg.DiscoverySpi).IpFinder = ipFinder2;
+
+                using (var ignite2 = Ignition.Start(cfg))
+                {
+                    Assert.AreEqual(1, ignite.GetCluster().GetNodes().Count);
+                    Assert.AreEqual(1, ignite2.GetCluster().GetNodes().Count);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Checks the default properties.
+        /// </summary>
+        /// <param name="cfg">The CFG.</param>
+        private static void CheckDefaultProperties(IgniteConfiguration cfg)
+        {
+            Assert.AreEqual(IgniteConfiguration.DefaultMetricsExpireTime, cfg.MetricsExpireTime);
+            Assert.AreEqual(IgniteConfiguration.DefaultMetricsHistorySize, cfg.MetricsHistorySize);
+            Assert.AreEqual(IgniteConfiguration.DefaultMetricsLogFrequency, cfg.MetricsLogFrequency);
+            Assert.AreEqual(IgniteConfiguration.DefaultMetricsUpdateFrequency, cfg.MetricsUpdateFrequency);
+            Assert.AreEqual(IgniteConfiguration.DefaultNetworkTimeout, cfg.NetworkTimeout);
+            Assert.AreEqual(IgniteConfiguration.DefaultNetworkSendRetryCount, cfg.NetworkSendRetryCount);
+            Assert.AreEqual(IgniteConfiguration.DefaultNetworkSendRetryDelay, cfg.NetworkSendRetryDelay);
+        }
+
+        /// <summary>
+        /// Checks the default value attributes.
+        /// </summary>
+        /// <param name="obj">The object.</param>
+        private static void CheckDefaultValueAttributes(object obj)
+        {
+            var props = obj.GetType().GetProperties();
+
+            foreach (var prop in props)
+            {
+                var attr = prop.GetCustomAttributes(true).OfType<DefaultValueAttribute>().FirstOrDefault();
+                var propValue = prop.GetValue(obj, null);
+
+                if (attr != null)
+                    Assert.AreEqual(attr.Value, propValue);
+                else if (prop.PropertyType.IsValueType)
+                    Assert.AreEqual(Activator.CreateInstance(prop.PropertyType), propValue);
+                else
+                    Assert.IsNull(propValue);
+            }
+        }
+
+        /// <summary>
+        /// Gets the custom configuration.
+        /// </summary>
+        private static IgniteConfiguration GetCustomConfig()
+        {
+            return new IgniteConfiguration
+            {
+                DiscoverySpi = new TcpDiscoverySpi
+                {
+                    NetworkTimeout = TimeSpan.FromSeconds(1),
+                    AckTimeout = TimeSpan.FromSeconds(2),
+                    MaxAckTimeout = TimeSpan.FromSeconds(3),
+                    SocketTimeout = TimeSpan.FromSeconds(4),
+                    JoinTimeout = TimeSpan.FromSeconds(5),
+                    IpFinder = new TcpDiscoveryStaticIpFinder
+                    {
+                        Endpoints = new[] { "127.0.0.1:47500", "127.0.0.1:47501" }
+                    }
+                },
+                GridName = "gridName1",
+                IncludedEventTypes = EventType.SwapspaceAll,
+                MetricsExpireTime = TimeSpan.FromMinutes(7),
+                MetricsHistorySize = 125,
+                MetricsLogFrequency = TimeSpan.FromMinutes(8),
+                MetricsUpdateFrequency = TimeSpan.FromMinutes(9),
+                NetworkSendRetryCount = 54,
+                NetworkTimeout = TimeSpan.FromMinutes(10),
+                NetworkSendRetryDelay = TimeSpan.FromMinutes(11),
+                WorkDirectory = Path.GetTempPath(),
+                JvmOptions = TestUtils.TestJavaOptions(),
+                JvmClasspath = TestUtils.CreateTestClasspath(),
+                Localhost = "127.0.0.1"
+            };
+        }
+
+        /// <summary>
+        /// Gets the static discovery.
+        /// </summary>
+        /// <returns></returns>
+        private static IDiscoverySpi GetStaticDiscovery()
+        {
+            return new TcpDiscoverySpi
+            {
+                IpFinder = new TcpDiscoveryStaticIpFinder {Endpoints = new[] {"127.0.0.1:47500", "127.0.0.1:47501"}}
+            };
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
index 541de0c..7def56f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
@@ -34,7 +34,7 @@ namespace Apache.Ignite.Core.Tests
         {
             using (var grid = Ignition.Start("config\\marshaller-default.xml"))
             {
-                var cache = grid.GetOrCreateCache<int, int>(null);
+                var cache = grid.GetOrCreateCache<int, int>((string) null);
 
                 cache.Put(1, 1);
 
@@ -51,7 +51,7 @@ namespace Apache.Ignite.Core.Tests
         {
             using (var grid = Ignition.Start("config\\marshaller-explicit.xml"))
             {
-                var cache = grid.GetOrCreateCache<int, int>(null);
+                var cache = grid.GetOrCreateCache<int, int>((string) null);
 
                 cache.Put(1, 1);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
index 07caaf3..a36e30f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
@@ -43,7 +43,7 @@ namespace Apache.Ignite.Core.Tests
         [TestFixtureSetUp]
         public void SetUp()
         {
-            var cfg = new IgniteConfigurationEx
+            var cfg = new IgniteConfiguration
             {
                 GridName = GridName,
                 JvmClasspath = TestUtils.CreateTestClasspath(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
index 2b0ab8e..a1083b6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Tests
     using System;
     using System.Diagnostics;
     using System.Reflection;
+    using Apache.Ignite.Core.Tests.Cache.Query;
     using Apache.Ignite.Core.Tests.Memory;
     using NUnit.ConsoleRunner;
 
@@ -31,9 +32,9 @@ namespace Apache.Ignite.Core.Tests
             Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
             Debug.AutoFlush = true;
 
-            //TestOne(typeof(ContinuousQueryAtomiclBackupTest), "TestInitialQuery");
+            TestOne(typeof(IgniteConfigurationTest), "TestStaticIpFinder");
 
-            TestAll(typeof (ExecutableTest));
+            //TestAll(typeof (CacheQueriesCodeConfigurationTest));
             //TestAllInAssembly();
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 7de8330..1c83168 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -17,6 +17,7 @@
     <OutputPath>bin\x64\Debug\</OutputPath>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <DefineConstants>DEBUG;CODE_ANALYSIS</DefineConstants>
+    <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
     <DocumentationFile>bin\x64\Debug\Apache.Ignite.Core.XML</DocumentationFile>
     <RunCodeAnalysis>true</RunCodeAnalysis>
     <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
@@ -25,6 +26,7 @@
     <PlatformTarget>x64</PlatformTarget>
     <OutputPath>bin\x64\Release\</OutputPath>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
     <Optimize>true</Optimize>
     <DocumentationFile>bin\x64\Release\Apache.Ignite.Core.XML</DocumentationFile>
     <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
@@ -34,6 +36,7 @@
     <OutputPath>bin\x86\Debug\</OutputPath>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <DefineConstants>DEBUG;CODE_ANALYSIS</DefineConstants>
+    <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
     <DocumentationFile>bin\x86\Debug\Apache.Ignite.Core.XML</DocumentationFile>
     <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
@@ -41,6 +44,7 @@
     <PlatformTarget>x86</PlatformTarget>
     <OutputPath>bin\x86\Release\</OutputPath>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
     <Optimize>true</Optimize>
     <DocumentationFile>bin\x86\Release\Apache.Ignite.Core.XML</DocumentationFile>
     <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
@@ -65,6 +69,8 @@
     <Compile Include="Cache\CacheException.cs" />
     <Compile Include="Cache\CachePartialUpdateException.cs" />
     <Compile Include="Cache\CachePeekMode.cs" />
+    <Compile Include="Cache\Configuration\QueryAlias.cs" />
+    <Compile Include="Cache\Configuration\QueryTextFieldAttribute.cs" />
     <Compile Include="Cache\Event\CacheEntryEventType.cs" />
     <Compile Include="Cache\Event\ICacheEntryEvent.cs" />
     <Compile Include="Cache\Event\ICacheEntryEventFilter.cs" />
@@ -98,6 +104,7 @@
     <Compile Include="Cache\Store\CacheStoreAdapter.cs" />
     <Compile Include="Cache\Store\CacheStoreException.cs" />
     <Compile Include="Cache\Store\ICacheStore.cs" />
+    <Compile Include="Common\IFactory.cs" />
     <Compile Include="Cache\Store\ICacheStoreSession.cs" />
     <Compile Include="Cache\Store\Package-Info.cs" />
     <Compile Include="Cluster\ClusterGroupEmptyException.cs" />
@@ -128,6 +135,25 @@
     <Compile Include="Compute\IComputeJobResult.cs" />
     <Compile Include="Compute\IComputeReducer.cs" />
     <Compile Include="Compute\IComputeTask.cs" />
+    <Compile Include="Cache\Configuration\CacheAtomicityMode.cs" />
+    <Compile Include="Cache\Configuration\CacheAtomicWriteOrderMode.cs" />
+    <Compile Include="Cache\Configuration\CacheConfiguration.cs" />
+    <Compile Include="Cache\Configuration\CacheMemoryMode.cs" />
+    <Compile Include="Cache\Configuration\CacheMode.cs" />
+    <Compile Include="Cache\Configuration\CacheRebalanceMode.cs" />
+    <Compile Include="Cache\Configuration\CacheWriteSynchronizationMode.cs" />
+    <Compile Include="Discovery\Tcp\ITcpDiscoveryIpFinder.cs" />
+    <Compile Include="Discovery\Tcp\TcpDiscoverySpi.cs" />
+    <Compile Include="Cache\Configuration\QueryIndexField.cs" />
+    <Compile Include="Discovery\IDiscoverySpi.cs" />
+    <Compile Include="Discovery\Tcp\TcpDiscoveryIpFinderBase.cs" />
+    <Compile Include="Discovery\Tcp\Multicast\TcpDiscoveryMulticastIpFinder.cs" />
+    <Compile Include="Cache\Configuration\QueryEntity.cs" />
+    <Compile Include="Cache\Configuration\QueryField.cs" />
+    <Compile Include="Cache\Configuration\QueryIndex.cs" />
+    <Compile Include="Cache\Configuration\QueryIndexType.cs" />
+    <Compile Include="Cache\Configuration\QuerySqlFieldAttribute.cs" />
+    <Compile Include="Discovery\Tcp\Static\TcpDiscoveryStaticIpFinder.cs" />
     <Compile Include="Compute\Package-Info.cs" />
     <Compile Include="Datastream\IDataStreamer.cs" />
     <Compile Include="Datastream\IStreamReceiver.cs" />
@@ -158,6 +184,7 @@
     <Compile Include="Ignition.cs" />
     <Compile Include="IIgnite.cs" />
     <Compile Include="Impl\Binary\BinaryEnum.cs" />
+    <Compile Include="Impl\Binary\JavaTypes.cs" />
     <Compile Include="Impl\Cache\CacheAffinityImpl.cs" />
     <Compile Include="Impl\Cache\CacheEntry.cs" />
     <Compile Include="Impl\Cache\CacheEntryFilterHolder.cs" />
@@ -235,7 +262,6 @@
     <Compile Include="Impl\Events\Events.cs" />
     <Compile Include="Impl\Events\RemoteListenEventFilter.cs" />
     <Compile Include="Impl\ExceptionUtils.cs" />
-    <Compile Include="Impl\IgniteConfigurationEx.cs" />
     <Compile Include="Impl\Ignite.cs" />
     <Compile Include="Impl\IgniteManager.cs" />
     <Compile Include="Impl\IgniteProxy.cs" />
@@ -405,6 +431,7 @@
     <None Include="Apache.Ignite.Core.ruleset" />
     <None Include="Apache.Ignite.Core.snk" />
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
index 4d82a65..fa2fb1c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
@@ -17,8 +17,10 @@
 
 namespace Apache.Ignite.Core.Binary
 {
+    using System;
     using System.Collections.Generic;
     using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
     using Apache.Ignite.Core.Impl.Common;
 
     /// <summary>
@@ -27,7 +29,7 @@ namespace Apache.Ignite.Core.Binary
     public class BinaryConfiguration
     {
         /// <summary>
-        /// Constructor.
+        /// Initializes a new instance of the <see cref="BinaryConfiguration"/> class.
         /// </summary>
         public BinaryConfiguration()
         {
@@ -35,9 +37,9 @@ namespace Apache.Ignite.Core.Binary
         }
 
         /// <summary>
-        /// Copying constructor.
+        /// Initializes a new instance of the <see cref="BinaryConfiguration" /> class.
         /// </summary>
-        /// <param name="cfg">Configuration to copy.</param>
+        /// <param name="cfg">The binary configuration to copy.</param>
         public BinaryConfiguration(BinaryConfiguration cfg)
         {
             IgniteArgumentCheck.NotNull(cfg, "cfg");
@@ -47,15 +49,20 @@ namespace Apache.Ignite.Core.Binary
             DefaultKeepDeserialized = cfg.DefaultKeepDeserialized;
             DefaultSerializer = cfg.DefaultSerializer;
 
-            Types = cfg.Types != null ? new List<string>(cfg.Types) : null;
+            TypeConfigurations = cfg.TypeConfigurations == null
+                ? null
+                : cfg.TypeConfigurations.Select(x => new BinaryTypeConfiguration(x)).ToList();
 
-            if (cfg.TypeConfigurations != null)
-            {
-                TypeConfigurations = new List<BinaryTypeConfiguration>(cfg.TypeConfigurations.Count);
+            Types = cfg.Types == null ? null : cfg.Types.ToList();
+        }
 
-                foreach (BinaryTypeConfiguration typeCfg in cfg.TypeConfigurations)
-                    TypeConfigurations.Add(new BinaryTypeConfiguration(typeCfg));
-            }
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinaryConfiguration"/> class.
+        /// </summary>
+        /// <param name="binaryTypes">Binary types to register.</param>
+        public BinaryConfiguration(params Type[] binaryTypes)
+        {
+            TypeConfigurations = binaryTypes.Select(t => new BinaryTypeConfiguration(t)).ToList();
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs
new file mode 100644
index 0000000..c9a41e8
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    /// <summary>
+    /// Cache write ordering mode. This enumeration is taken into account only in 
+    /// <see cref="CacheAtomicityMode.Atomic"/> atomicity mode.
+    /// Write ordering mode determines which node assigns the write version, sender or the primary node.
+    /// </summary>
+    public enum CacheAtomicWriteOrderMode
+    {
+        /// <summary>
+        /// In this mode, write versions are assigned on a sender node which generally leads to better
+        /// performance in <see cref="CacheWriteSynchronizationMode.FullSync"/> synchronization mode, 
+        /// since in this case sender can send write requests to primary and backups at the same time.
+        /// <para/>
+        /// This mode will be automatically configured only with <see cref="CacheWriteSynchronizationMode.FullSync"/>
+        /// write synchronization mode, as for other synchronization modes it does not render better performance.
+        /// </summary>
+        Clock,
+
+        /// <summary>
+        /// Cache version is assigned only on primary node. This means that sender will only send write request
+        /// to primary node, which in turn will assign write version and forward it to backups.
+        /// </summary>
+        Primary
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
new file mode 100644
index 0000000..8c36a77
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using Apache.Ignite.Core.Cache;
+
+    /// <summary>
+    /// Cache atomicity mode.
+    /// </summary>
+    public enum CacheAtomicityMode
+    {
+        /// <summary>
+        /// Specifies fully ACID-compliant transactional cache behavior.
+        /// </summary>
+        Transactional,
+
+        /// <summary>
+        /// Specifies atomic-only cache behaviour. In this mode distributed transactions and distributed
+        /// locking are not supported. Disabling transactions and locking allows to achieve much higher
+        /// performance and throughput ratios.
+        /// <para/>
+        /// In addition to transactions and locking, one of the main differences to <see cref="Atomic"/> mode
+        /// is that bulk writes, such as <see cref="ICache{TK,TV}.PutAll"/> 
+        /// and <see cref="ICache{TK,TV}.RemoveAll(System.Collections.Generic.IEnumerable{TK})"/> methods, 
+        /// become simple batch operations which can partially fail. In case of partial
+        /// failure, <see cref="CachePartialUpdateException"/>will be thrown which will contain a list of keys 
+        /// for which the update failed. It is recommended that bulk writes are used
+        /// whenever multiple keys need to be inserted or updated in cache, as they reduce number of network trips and
+        /// provide better performance.
+        /// <para/>
+        /// Note that even without locking and transactions, <see cref="Atomic"/> mode still provides
+        /// full consistency guarantees across all cache nodes.
+        /// <para/>
+        /// Also note that all data modifications in <see cref="Atomic"/> mode are guaranteed to be atomic
+        /// and consistent with writes to the underlying persistent store, if one is configured.        
+        /// </summary>
+        Atomic
+    }
+}
\ No newline at end of file


[14/28] ignite git commit: IGNITE-1906: .NET: Implemented programmatic configuration.

Posted by vo...@apache.org.
IGNITE-1906: .NET: Implemented programmatic configuration.


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

Branch: refs/heads/ignite-2508
Commit: ee20f1d9fb94f792d0b62097499c7c3f976ff6f5
Parents: 28a5247
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Feb 2 16:19:55 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Feb 2 16:19:55 2016 +0300

----------------------------------------------------------------------
 .gitignore                                      |   1 +
 .../internal/binary/GridBinaryMarshaller.java   |  23 +-
 .../processors/cache/GridCacheProcessor.java    |  43 +-
 .../processors/platform/PlatformIgnition.java   |   6 +-
 .../platform/PlatformNoopProcessor.java         |  15 +
 .../processors/platform/PlatformProcessor.java  |  25 +
 .../platform/PlatformProcessorImpl.java         |  34 +-
 .../platform/cache/PlatformCache.java           |  16 +-
 .../dotnet/PlatformDotNetCacheStore.java        |  39 +-
 .../PlatformDotNetConfigurationClosure.java     |  50 +-
 .../utils/PlatformConfigurationUtils.java       | 621 +++++++++++++++++++
 .../platform/utils/PlatformUtils.java           |  52 +-
 .../PlatformDotNetCacheStoreFactoryNative.java  |  58 ++
 .../cpp/common/include/ignite/common/exports.h  |   3 +
 .../cpp/common/include/ignite/common/java.h     |   9 +
 .../platforms/cpp/common/project/vs/module.def  |   5 +-
 modules/platforms/cpp/common/src/exports.cpp    |  12 +
 modules/platforms/cpp/common/src/java.cpp       |  44 ++
 .../Apache.Ignite.Core.Tests.csproj             |   3 +
 .../Binary/BinarySelfTest.cs                    |   9 +
 .../Cache/CacheAbstractTest.cs                  |   2 +-
 .../Cache/CacheAffinityTest.cs                  |   2 +-
 .../Cache/CacheConfigurationTest.cs             | 538 ++++++++++++++++
 .../Cache/CacheDynamicStartTest.cs              |   4 +-
 .../Cache/CacheTestAsyncWrapper.cs              |   7 +
 .../Query/CacheQueriesCodeConfigurationTest.cs  | 295 +++++++++
 .../Cache/Query/CacheQueriesTest.cs             |   2 +-
 .../Continuous/ContinuousQueryAbstractTest.cs   |   2 +-
 .../Cache/Store/CacheStoreSessionTest.cs        |   2 +-
 .../Cache/Store/CacheStoreTest.cs               |  23 +-
 .../Dataload/DataStreamerTest.cs                |   4 +-
 .../Apache.Ignite.Core.Tests/ExceptionsTest.cs  |   2 +-
 .../IgniteConfigurationTest.cs                  | 367 +++++++++++
 .../Apache.Ignite.Core.Tests/MarshallerTest.cs  |   4 +-
 .../SerializationTest.cs                        |   2 +-
 .../Apache.Ignite.Core.Tests/TestRunner.cs      |   5 +-
 .../Apache.Ignite.Core.csproj                   |  29 +-
 .../Binary/BinaryConfiguration.cs               |  27 +-
 .../Configuration/CacheAtomicWriteOrderMode.cs  |  43 ++
 .../Cache/Configuration/CacheAtomicityMode.cs   |  54 ++
 .../Cache/Configuration/CacheConfiguration.cs   | 601 ++++++++++++++++++
 .../Cache/Configuration/CacheMemoryMode.cs      |  60 ++
 .../Cache/Configuration/CacheMode.cs            |  52 ++
 .../Cache/Configuration/CacheRebalanceMode.cs   |  51 ++
 .../CacheWriteSynchronizationMode.cs            |  45 ++
 .../Cache/Configuration/QueryAlias.cs           |  59 ++
 .../Cache/Configuration/QueryEntity.cs          | 401 ++++++++++++
 .../Cache/Configuration/QueryField.cs           | 109 ++++
 .../Cache/Configuration/QueryIndex.cs           | 137 ++++
 .../Cache/Configuration/QueryIndexField.cs      |  66 ++
 .../Cache/Configuration/QueryIndexType.cs       |  40 ++
 .../Configuration/QuerySqlFieldAttribute.cs     |  60 ++
 .../Configuration/QueryTextFieldAttribute.cs    |  36 ++
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |   6 +
 .../Apache.Ignite.Core/Common/IFactory.cs       |  34 +
 .../Discovery/IDiscoverySpi.cs                  |  32 +
 .../Discovery/Tcp/ITcpDiscoveryIpFinder.cs      |  34 +
 .../Multicast/TcpDiscoveryMulticastIpFinder.cs  | 133 ++++
 .../Tcp/Static/TcpDiscoveryStaticIpFinder.cs    |  84 +++
 .../Discovery/Tcp/TcpDiscoveryIpFinderBase.cs   |  78 +++
 .../Discovery/Tcp/TcpDiscoverySpi.cs            | 144 +++++
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |  29 +-
 .../Apache.Ignite.Core/IgniteConfiguration.cs   | 347 ++++++++++-
 .../dotnet/Apache.Ignite.Core/Ignition.cs       |  29 +-
 .../Apache.Ignite.Core/Impl/Binary/Binary.cs    |   3 -
 .../Impl/Binary/BinaryReaderExtensions.cs       |  19 +
 .../Apache.Ignite.Core/Impl/Binary/JavaTypes.cs |  92 +++
 .../Impl/Binary/Marshaller.cs                   |   8 +-
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |   9 +-
 .../Apache.Ignite.Core/Impl/Cache/CacheOp.cs    |   3 +-
 .../Impl/Cache/Store/CacheStore.cs              |  20 +-
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |  48 ++
 .../Impl/IgniteConfigurationEx.cs               |  57 --
 .../Apache.Ignite.Core/Impl/IgniteManager.cs    |   5 +-
 .../Apache.Ignite.Core/Impl/IgniteProxy.cs      |  18 +-
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |   2 +-
 .../Impl/Memory/PlatformRawMemory.cs            |   2 +-
 .../Impl/Transactions/TransactionsImpl.cs       |   2 +-
 .../Impl/Unmanaged/IgniteJniNativeMethods.cs    |  11 +-
 .../Impl/Unmanaged/UnmanagedUtils.cs            |  22 +-
 parent/pom.xml                                  |   1 +
 81 files changed, 5213 insertions(+), 258 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index ef12f3a..e4e061c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ git-patch-prop-local.sh
 *.vcxproj.user
 *.sdf
 *.opensdf
+*.opendb
 **/cpp/**/vs/x64/
 **/cpp/**/vs/Win32/
 **/dotnet/**/obj/

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
index da43558..8e138fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
@@ -299,6 +299,15 @@ public class GridBinaryMarshaller {
     /**
      * Push binary context and return the old one.
      *
+     * @return Old binary context.
+     */
+    public BinaryContext pushContext() {
+        return pushContext(ctx);
+    }
+
+    /**
+     * Push binary context and return the old one.
+     *
      * @param ctx Binary context.
      * @return Old binary context.
      */
@@ -315,11 +324,23 @@ public class GridBinaryMarshaller {
      *
      * @param oldCtx Old binary context.
      */
-    private static void popContext(@Nullable BinaryContext oldCtx) {
+    public static void popContext(@Nullable BinaryContext oldCtx) {
         BINARY_CTX.set(oldCtx);
     }
 
     /**
+     * Creates a reader.
+     *
+     * @param stream Stream.
+     * @return Reader.
+     */
+    public BinaryReaderExImpl reader(BinaryInputStream stream) {
+        assert stream != null;
+
+        return new BinaryReaderExImpl(ctx, stream, null);
+    }
+
+    /**
      * Whether object must be deserialized anyway. I.e. it cannot be converted to BinaryObject.
      *
      * @param obj Object.

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 26d3d4f..5acad6c 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
@@ -69,10 +69,13 @@ import org.apache.ignite.internal.IgniteComponentType;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteNodeAttributes;
 import org.apache.ignite.internal.IgniteTransactionsEx;
+import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
 import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCache;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
@@ -94,6 +97,7 @@ import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTransactionsImpl;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
 import org.apache.ignite.internal.processors.plugin.CachePluginManager;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
 import org.apache.ignite.internal.util.F0;
@@ -3409,23 +3413,38 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (val == null)
             return null;
 
-        if (val.getCacheStoreFactory() != null) {
+        IgniteCacheObjectProcessor objProc = ctx.cacheObjects();
+        BinaryContext oldCtx = null;
+
+        if (objProc instanceof CacheObjectBinaryProcessorImpl) {
+            GridBinaryMarshaller binMarsh = ((CacheObjectBinaryProcessorImpl)objProc).marshaller();
+
+            oldCtx = binMarsh == null ? null : binMarsh.pushContext();
+        }
+
+        try {
+            if (val.getCacheStoreFactory() != null) {
+                try {
+                    marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
+                        val.getCacheStoreFactory().getClass().getClassLoader());
+                }
+                catch (IgniteCheckedException e) {
+                    throw new IgniteCheckedException("Failed to validate cache configuration. " +
+                        "Cache store factory is not serializable. Cache name: " + U.maskName(val.getName()), e);
+                }
+            }
+
             try {
-                marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
-                    val.getCacheStoreFactory().getClass().getClassLoader());
+                return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config().getClassLoader()));
             }
             catch (IgniteCheckedException e) {
-                throw new IgniteCheckedException("Failed to validate cache configuration. " +
-                    "Cache store factory is not serializable. Cache name: " + U.maskName(val.getName()), e);
+                throw new IgniteCheckedException("Failed to validate cache configuration " +
+                    "(make sure all objects in cache configuration are serializable): " + U.maskName(val.getName()), e);
             }
         }
-
-        try {
-            return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config().getClassLoader()));
-        }
-        catch (IgniteCheckedException e) {
-            throw new IgniteCheckedException("Failed to validate cache configuration " +
-                "(make sure all objects in cache configuration are serializable): " + U.maskName(val.getName()), e);
+        finally {
+            if (objProc instanceof CacheObjectBinaryProcessorImpl)
+                GridBinaryMarshaller.popContext(oldCtx);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
index e642b2d..d25acfc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
@@ -142,9 +142,11 @@ public class PlatformIgnition {
      * @return Configuration.
      */
     private static IgniteConfiguration configuration(@Nullable String springCfgPath) {
+        if (springCfgPath == null)
+            return new IgniteConfiguration();
+
         try {
-            URL url = springCfgPath == null ? U.resolveIgniteUrl(IgnitionEx.DFLT_CFG) :
-                U.resolveSpringUrl(springCfgPath);
+            URL url = U.resolveSpringUrl(springCfgPath);
 
             IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> t = IgnitionEx.loadConfiguration(url);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
index fb28008..b25e32e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
@@ -74,6 +74,16 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf
     }
 
     /** {@inheritDoc} */
+    @Override public PlatformTarget createCacheFromConfig(long memPtr) throws IgniteCheckedException {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public PlatformTarget getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException {
+        return null;
+    }
+
+    /** {@inheritDoc} */
     @Override public void destroyCache(@Nullable String name) throws IgniteCheckedException {
         // No-op.
     }
@@ -133,4 +143,9 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf
     @Override public PlatformTarget atomicLong(String name, long initVal, boolean create) throws IgniteException {
         return null;
     }
+
+    /** {@inheritDoc} */
+    @Override public void getIgniteConfiguration(long memPtr) {
+        // No-op.
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
index 8e684e3..b59d93d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
@@ -90,6 +90,24 @@ public interface PlatformProcessor extends GridProcessor {
     public PlatformTarget getOrCreateCache(@Nullable String name) throws IgniteCheckedException;
 
     /**
+     * Create cache.
+     *
+     * @param memPtr Stream with cache config.
+     * @return Cache.
+     * @throws IgniteCheckedException If failed.
+     */
+    public PlatformTarget createCacheFromConfig(long memPtr) throws IgniteCheckedException;
+
+    /**
+     * Get or create cache.
+     *
+     * @param memPtr Stream with cache config.
+     * @return Cache.
+     * @throws IgniteCheckedException If failed.
+     */
+    public PlatformTarget getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException;
+
+    /**
      * Destroy dynamically created cache.
      *
      * @param name Cache name.
@@ -188,4 +206,11 @@ public interface PlatformProcessor extends GridProcessor {
      * @throws IgniteException
      */
     public PlatformTarget atomicLong(String name, long initVal, boolean create) throws IgniteException;
+
+    /**
+     * Gets the configuration of the current Ignite instance.
+     *
+     * @param memPtr Stream to write data to.
+     */
+    public void getIgniteConfiguration(long memPtr);
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
index dc6e0df..4ed8c25 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
@@ -22,11 +22,12 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.PlatformConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteComputeImpl;
+import org.apache.ignite.internal.binary.*;
 import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
-import org.apache.ignite.internal.binary.BinaryRawWriterEx;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
 import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
 import org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl;
@@ -45,6 +46,7 @@ import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStrea
 import org.apache.ignite.internal.processors.platform.messaging.PlatformMessaging;
 import org.apache.ignite.internal.processors.platform.services.PlatformServices;
 import org.apache.ignite.internal.processors.platform.transactions.PlatformTransactions;
+import org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils;
 import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -244,6 +246,26 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
     }
 
     /** {@inheritDoc} */
+    @Override public PlatformTarget createCacheFromConfig(long memPtr) throws IgniteCheckedException {
+        BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
+        CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
+
+        IgniteCacheProxy cache = (IgniteCacheProxy)ctx.grid().createCache(cfg);
+
+        return new PlatformCache(platformCtx, cache.keepBinary(), false);
+    }
+
+    /** {@inheritDoc} */
+    @Override public PlatformTarget getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException {
+        BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
+        CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
+
+        IgniteCacheProxy cache = (IgniteCacheProxy)ctx.grid().getOrCreateCache(cfg);
+
+        return new PlatformCache(platformCtx, cache.keepBinary(), false);
+    }
+
+    /** {@inheritDoc} */
     @Override public void destroyCache(@Nullable String name) throws IgniteCheckedException {
         ctx.grid().destroyCache(name);
     }
@@ -338,6 +360,16 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
         return new PlatformAtomicLong(platformCtx, atomicLong);
     }
 
+    /** {@inheritDoc} */
+    @Override public void getIgniteConfiguration(long memPtr) {
+        PlatformOutputStream stream = platformCtx.memory().get(memPtr).output();
+        BinaryRawWriterEx writer = platformCtx.writer(stream);
+
+        PlatformConfigurationUtils.writeIgniteConfiguration(writer, ignite().configuration());
+
+        stream.synchronize();
+    }
+
     /**
      * Internal store initialization routine.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index 8e7c51d..37fd335 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -28,6 +28,7 @@ import org.apache.ignite.cache.query.ScanQuery;
 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.*;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.binary.BinaryRawReaderEx;
 import org.apache.ignite.internal.binary.BinaryRawWriterEx;
@@ -41,6 +42,7 @@ import org.apache.ignite.internal.processors.platform.PlatformNativeException;
 import org.apache.ignite.internal.processors.platform.cache.query.PlatformContinuousQuery;
 import org.apache.ignite.internal.processors.platform.cache.query.PlatformFieldsQueryCursor;
 import org.apache.ignite.internal.processors.platform.cache.query.PlatformQueryCursor;
+import org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils;
 import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
 import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
 import org.apache.ignite.internal.util.GridConcurrentFactory;
@@ -178,6 +180,9 @@ public class PlatformCache extends PlatformAbstractTarget {
     /** */
     public static final int OP_REPLACE_3 = 38;
 
+    /** */
+    public static final int OP_GET_CONFIG = 39;
+
     /** Underlying JCache. */
     private final IgniteCacheProxy cache;
 
@@ -516,6 +521,14 @@ public class PlatformCache extends PlatformAbstractTarget {
 
                 break;
 
+            case OP_GET_CONFIG:
+                CacheConfiguration ccfg = ((IgniteCache<Object, Object>)cache).
+                        getConfiguration(CacheConfiguration.class);
+
+                PlatformConfigurationUtils.writeCacheConfiguration(writer, ccfg);
+
+                break;
+
             default:
                 super.processOutStream(type, writer);
         }
@@ -705,8 +718,7 @@ public class PlatformCache extends PlatformAbstractTarget {
     }
 
     /**
-     * Clears the contents of the cache, without notifying listeners or
-     * {@ignitelink javax.cache.integration.CacheWriter}s.
+     * Clears the contents of the cache, without notifying listeners or CacheWriters.
      *
      * @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/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
index 47b1110..45d9208 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
@@ -29,11 +29,8 @@ import org.apache.ignite.internal.processors.platform.cache.store.PlatformCacheS
 import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
 import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
 import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
 import org.apache.ignite.internal.util.lang.GridTuple;
 import org.apache.ignite.internal.util.lang.IgniteInClosureX;
-import org.apache.ignite.internal.util.typedef.C1;
-import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiInClosure;
@@ -43,13 +40,9 @@ import org.jetbrains.annotations.Nullable;
 import javax.cache.Cache;
 import javax.cache.integration.CacheLoaderException;
 import javax.cache.integration.CacheWriterException;
-import java.util.AbstractMap;
-import java.util.AbstractSet;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * Wrapper for .NET cache store implementations.
@@ -102,6 +95,9 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
     /** Properties. */
     private Map<String, ?> props;
 
+    /** Native factory. */
+    private final Object nativeFactory;
+
     /** Interop processor. */
     protected PlatformContext platformCtx;
 
@@ -109,6 +105,22 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
     protected long ptr;
 
     /**
+     * Default ctor.
+     */
+    public PlatformDotNetCacheStore() {
+        nativeFactory = null;
+    }
+
+    /**
+     * Native factory ctor.
+     */
+    public PlatformDotNetCacheStore(Object nativeFactory) {
+        assert nativeFactory != null;
+
+        this.nativeFactory = nativeFactory;
+    }
+
+    /**
      * Gets .NET class name.
      *
      * @return .NET class name.
@@ -175,7 +187,7 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
                     writer.writeByte(OP_LOAD_ALL);
                     writer.writeLong(session());
                     writer.writeString(ses.cacheName());
-                    writer.writeCollection((Collection) keys);
+                    writer.writeCollection((Collection)keys);
                 }
             }, new LoadAllCallback<>(platformCtx, loaded));
 
@@ -305,7 +317,8 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
      * @throws org.apache.ignite.IgniteCheckedException
      */
     public void initialize(GridKernalContext ctx, boolean convertBinary) throws IgniteCheckedException {
-        A.notNull(typName, "typName");
+        A.ensure(typName != null || nativeFactory != null,
+                "Either typName or nativeFactory must be set in PlatformDotNetCacheStore");
 
         platformCtx = PlatformUtils.platformContext(ctx.grid());
 
@@ -329,9 +342,13 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
      * @param convertBinary Convert binary flag.
      */
     protected void write(BinaryRawWriterEx writer, boolean convertBinary) {
-        writer.writeString(typName);
         writer.writeBoolean(convertBinary);
-        writer.writeMap(props);
+        writer.writeObjectDetached(nativeFactory);
+
+        if (nativeFactory == null) {
+            writer.writeString(typName);
+            writer.writeMap(props);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index 6b9b441..8728d77 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -19,31 +19,28 @@ package org.apache.ignite.internal.processors.platform.dotnet;
 
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryBasicIdMapper;
-import org.apache.ignite.binary.BinaryNameMapper;
 import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.PlatformConfiguration;
-import org.apache.ignite.internal.MarshallerContextImpl;
-import org.apache.ignite.internal.binary.BinaryNoopMetadataHandler;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.binary.BinaryReaderExImpl;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
 import org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean;
-import org.apache.ignite.internal.processors.platform.memory.PlatformInputStream;
 import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
 import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
 import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
+import org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils;
 import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lifecycle.LifecycleBean;
-import org.apache.ignite.logger.NullLogger;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean;
 
 import java.util.ArrayList;
@@ -177,15 +174,16 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
      */
     @SuppressWarnings("ConstantConditions")
     private void prepare(IgniteConfiguration igniteCfg, PlatformDotNetConfigurationEx interopCfg) {
-        this.cfg = igniteCfg;
+        cfg = igniteCfg;
 
         try (PlatformMemory outMem = memMgr.allocate()) {
             try (PlatformMemory inMem = memMgr.allocate()) {
                 PlatformOutputStream out = outMem.output();
 
-                BinaryRawWriterEx writer = marshaller().writer(out);
+                GridBinaryMarshaller marshaller = PlatformUtils.marshaller();
+                BinaryRawWriterEx writer = marshaller.writer(out);
 
-                PlatformUtils.writeDotNetConfiguration(writer, interopCfg.unwrap());
+                PlatformConfigurationUtils.writeDotNetConfiguration(writer, interopCfg.unwrap());
 
                 List<PlatformDotNetLifecycleBean> beans = beans(igniteCfg);
 
@@ -201,7 +199,7 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
                 gate.extensionCallbackInLongLongOutLong(
                     PlatformUtils.OP_PREPARE_DOT_NET, outMem.pointer(), inMem.pointer());
 
-                processPrepareResult(inMem.input());
+                processPrepareResult(marshaller.reader(inMem.input()));
             }
         }
     }
@@ -211,9 +209,11 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
      *
      * @param in Input stream.
      */
-    private void processPrepareResult(PlatformInputStream in) {
+    private void processPrepareResult(BinaryReaderExImpl in) {
         assert cfg != null;
 
+        PlatformConfigurationUtils.readIgniteConfiguration(in, cfg);
+
         List<PlatformDotNetLifecycleBean> beans = beans(cfg);
         List<PlatformLifecycleBean> newBeans = new ArrayList<>();
 
@@ -265,28 +265,4 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
 
         return res;
     }
-
-    /**
-     * Create binary marshaller.
-     *
-     * @return Marshaller.
-     */
-    @SuppressWarnings("deprecation")
-    private static GridBinaryMarshaller marshaller() {
-        try {
-            BinaryContext ctx =
-                new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger());
-
-            BinaryMarshaller marsh = new BinaryMarshaller();
-
-            marsh.setContext(new MarshallerContextImpl(null));
-
-            ctx.configure(marsh, new IgniteConfiguration());
-
-            return new GridBinaryMarshaller(ctx);
-        }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
new file mode 100644
index 0000000..32ab812
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -0,0 +1,621 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.utils;
+
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.QueryIndexType;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.*;
+import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration;
+import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration;
+import org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactoryNative;
+import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
+import org.apache.ignite.spi.discovery.DiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+
+import java.lang.management.ManagementFactory;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Configuration utils.
+ */
+@SuppressWarnings("unchecked") public class PlatformConfigurationUtils {
+    /**
+     * Write .Net configuration to the stream.
+     *
+     * @param writer Writer.
+     * @param cfg Configuration.
+     */
+    public static void writeDotNetConfiguration(BinaryRawWriterEx writer, PlatformDotNetConfiguration cfg) {
+        // 1. Write assemblies.
+        PlatformUtils.writeNullableCollection(writer, cfg.getAssemblies());
+
+        PlatformDotNetBinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
+
+        if (binaryCfg != null) {
+            writer.writeBoolean(true);
+
+            PlatformUtils.writeNullableCollection(writer, binaryCfg.getTypesConfiguration(),
+                new PlatformWriterClosure<PlatformDotNetBinaryTypeConfiguration>() {
+                    @Override public void write(BinaryRawWriterEx writer, PlatformDotNetBinaryTypeConfiguration typ) {
+                        writer.writeString(typ.getTypeName());
+                        writer.writeString(typ.getNameMapper());
+                        writer.writeString(typ.getIdMapper());
+                        writer.writeString(typ.getSerializer());
+                        writer.writeString(typ.getAffinityKeyFieldName());
+                        writer.writeObject(typ.getKeepDeserialized());
+                        writer.writeBoolean(typ.isEnum());
+                    }
+                });
+
+            PlatformUtils.writeNullableCollection(writer, binaryCfg.getTypes());
+            writer.writeString(binaryCfg.getDefaultNameMapper());
+            writer.writeString(binaryCfg.getDefaultIdMapper());
+            writer.writeString(binaryCfg.getDefaultSerializer());
+            writer.writeBoolean(binaryCfg.isDefaultKeepDeserialized());
+        }
+        else
+            writer.writeBoolean(false);
+    }
+
+    /**
+     * Reads cache configuration from a stream.
+     *
+     * @param in Stream.
+     * @return Cache configuration.
+     */
+    public static CacheConfiguration readCacheConfiguration(BinaryRawReaderEx in) {
+        assert in != null;
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setAtomicityMode(CacheAtomicityMode.fromOrdinal(in.readInt()));
+        ccfg.setAtomicWriteOrderMode(CacheAtomicWriteOrderMode.fromOrdinal((byte)in.readInt()));
+        ccfg.setBackups(in.readInt());
+        ccfg.setCacheMode(CacheMode.fromOrdinal(in.readInt()));
+        ccfg.setCopyOnRead(in.readBoolean());
+        ccfg.setEagerTtl(in.readBoolean());
+        ccfg.setSwapEnabled(in.readBoolean());
+        ccfg.setEvictSynchronized(in.readBoolean());
+        ccfg.setEvictSynchronizedConcurrencyLevel(in.readInt());
+        ccfg.setEvictSynchronizedKeyBufferSize(in.readInt());
+        ccfg.setEvictSynchronizedTimeout(in.readLong());
+        ccfg.setInvalidate(in.readBoolean());
+        ccfg.setStoreKeepBinary(in.readBoolean());
+        ccfg.setLoadPreviousValue(in.readBoolean());
+        ccfg.setDefaultLockTimeout(in.readLong());
+        ccfg.setLongQueryWarningTimeout(in.readLong());
+        ccfg.setMaxConcurrentAsyncOperations(in.readInt());
+        ccfg.setEvictMaxOverflowRatio(in.readFloat());
+        ccfg.setMemoryMode(CacheMemoryMode.values()[in.readInt()]);
+        ccfg.setName(in.readString());
+        ccfg.setOffHeapMaxMemory(in.readLong());
+        ccfg.setReadFromBackup(in.readBoolean());
+        ccfg.setRebalanceBatchSize(in.readInt());
+        ccfg.setRebalanceDelay(in.readLong());
+        ccfg.setRebalanceMode(CacheRebalanceMode.fromOrdinal(in.readInt()));
+        ccfg.setRebalanceThrottle(in.readLong());
+        ccfg.setRebalanceTimeout(in.readLong());
+        ccfg.setSqlEscapeAll(in.readBoolean());
+        ccfg.setSqlOnheapRowCacheSize(in.readInt());
+        ccfg.setStartSize(in.readInt());
+        ccfg.setWriteBehindBatchSize(in.readInt());
+        ccfg.setWriteBehindEnabled(in.readBoolean());
+        ccfg.setWriteBehindFlushFrequency(in.readLong());
+        ccfg.setWriteBehindFlushSize(in.readInt());
+        ccfg.setWriteBehindFlushThreadCount(in.readInt());
+        ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.fromOrdinal(in.readInt()));
+
+        Object storeFactory = in.readObjectDetached();
+
+        if (storeFactory != null)
+            ccfg.setCacheStoreFactory(new PlatformDotNetCacheStoreFactoryNative(storeFactory));
+
+        int qryEntCnt = in.readInt();
+
+        if (qryEntCnt > 0) {
+            Collection<QueryEntity> entities = new ArrayList<>(qryEntCnt);
+
+            for (int i = 0; i < qryEntCnt; i++)
+                entities.add(readQueryEntity(in));
+
+            ccfg.setQueryEntities(entities);
+        }
+
+        return ccfg;
+    }
+
+    /**
+     * Reads the query entity.
+     *
+     * @param in Stream.
+     * @return QueryEntity.
+     */
+    public static QueryEntity readQueryEntity(BinaryRawReader in) {
+        QueryEntity res = new QueryEntity();
+
+        res.setKeyType(in.readString());
+        res.setValueType(in.readString());
+
+        // Fields
+        int cnt = in.readInt();
+
+        if (cnt > 0) {
+            LinkedHashMap<String, String> fields = new LinkedHashMap<>(cnt);
+
+            for (int i = 0; i < cnt; i++)
+                fields.put(in.readString(), in.readString());
+
+            res.setFields(fields);
+        }
+
+        // Aliases
+        cnt = in.readInt();
+
+        if (cnt > 0) {
+            Map<String, String> aliases = new HashMap<>(cnt);
+
+            for (int i = 0; i < cnt; i++)
+                aliases.put(in.readString(), in.readString());
+
+            res.setAliases(aliases);
+        }
+
+        // Indexes
+        cnt = in.readInt();
+
+        if (cnt > 0) {
+            Collection<QueryIndex> indexes = new ArrayList<>(cnt);
+
+            for (int i = 0; i < cnt; i++)
+                indexes.add(readQueryIndex(in));
+
+            res.setIndexes(indexes);
+        }
+
+        return res;
+    }
+
+    /**
+     * Reads the query index.
+     *
+     * @param in Reader.
+     * @return Query index.
+     */
+    public static QueryIndex readQueryIndex(BinaryRawReader in) {
+        QueryIndex res = new QueryIndex();
+
+        res.setName(in.readString());
+        res.setIndexType(QueryIndexType.values()[in.readByte()]);
+
+        int cnt = in.readInt();
+
+        if (cnt > 0) {
+            LinkedHashMap<String, Boolean> fields = new LinkedHashMap<>(cnt);
+
+            for (int i = 0; i < cnt; i++)
+                fields.put(in.readString(), !in.readBoolean());
+
+            res.setFields(fields);
+        }
+
+        return res;
+    }
+
+    /**
+     * Reads Ignite configuration.
+     * @param in Reader.
+     * @param cfg Configuration.
+     */
+    public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfiguration cfg) {
+        if (!in.readBoolean())
+            return;  // there is no config
+
+        cfg.setClientMode(in.readBoolean());
+        cfg.setIncludeEventTypes(in.readIntArray());
+        cfg.setMetricsExpireTime(in.readLong());
+        cfg.setMetricsHistorySize(in.readInt());
+        cfg.setMetricsLogFrequency(in.readLong());
+        cfg.setMetricsUpdateFrequency(in.readLong());
+        cfg.setNetworkSendRetryCount(in.readInt());
+        cfg.setNetworkSendRetryDelay(in.readLong());
+        cfg.setNetworkTimeout(in.readLong());
+        cfg.setWorkDirectory(in.readString());
+        cfg.setLocalHost(in.readString());
+
+        readCacheConfigurations(in, cfg);
+        readDiscoveryConfiguration(in, cfg);
+    }
+
+    /**
+     * Reads cache configurations from a stream and updates provided IgniteConfiguration.
+     *
+     * @param cfg IgniteConfiguration to update.
+     * @param in Reader.
+     */
+    public static void readCacheConfigurations(BinaryRawReaderEx in, IgniteConfiguration cfg) {
+        int len = in.readInt();
+
+        if (len == 0)
+            return;
+
+        List<CacheConfiguration> caches = new ArrayList<>();
+
+        for (int i = 0; i < len; i++)
+            caches.add(readCacheConfiguration(in));
+
+        CacheConfiguration[] oldCaches = cfg.getCacheConfiguration();
+        CacheConfiguration[] caches0 = caches.toArray(new CacheConfiguration[caches.size()]);
+
+        if (oldCaches == null)
+            cfg.setCacheConfiguration(caches0);
+        else {
+            CacheConfiguration[] mergedCaches = new CacheConfiguration[oldCaches.length + caches.size()];
+
+            System.arraycopy(oldCaches, 0, mergedCaches, 0, oldCaches.length);
+            System.arraycopy(caches0, 0, mergedCaches, oldCaches.length, caches.size());
+
+            cfg.setCacheConfiguration(mergedCaches);
+        }
+    }
+
+    /**
+     * Reads discovery configuration from a stream and updates provided IgniteConfiguration.
+     *
+     * @param cfg IgniteConfiguration to update.
+     * @param in Reader.
+     */
+    public static void readDiscoveryConfiguration(BinaryRawReader in, IgniteConfiguration cfg) {
+        boolean hasConfig = in.readBoolean();
+
+        if (!hasConfig)
+            return;
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        boolean hasIpFinder = in.readBoolean();
+
+        if (hasIpFinder) {
+            byte ipFinderType = in.readByte();
+
+            int addrCount = in.readInt();
+
+            ArrayList<String> addrs = null;
+
+            if (addrCount > 0) {
+                addrs = new ArrayList<>(addrCount);
+
+                for (int i = 0; i < addrCount; i++)
+                    addrs.add(in.readString());
+            }
+
+            TcpDiscoveryVmIpFinder finder = null;
+            if (ipFinderType == 1) {
+                finder = new TcpDiscoveryVmIpFinder();
+            }
+            else if (ipFinderType == 2) {
+                TcpDiscoveryMulticastIpFinder finder0 = new TcpDiscoveryMulticastIpFinder();
+
+                finder0.setLocalAddress(in.readString());
+                finder0.setMulticastGroup(in.readString());
+                finder0.setMulticastPort(in.readInt());
+                finder0.setAddressRequestAttempts(in.readInt());
+                finder0.setResponseWaitTime(in.readInt());
+
+                boolean hasTtl = in.readBoolean();
+
+                if (hasTtl)
+                    finder0.setTimeToLive(in.readInt());
+
+                finder = finder0;
+            }
+            else {
+                assert false;
+            }
+
+            finder.setAddresses(addrs);
+
+            disco.setIpFinder(finder);
+        }
+
+        disco.setSocketTimeout(in.readLong());
+        disco.setAckTimeout(in.readLong());
+        disco.setMaxAckTimeout(in.readLong());
+        disco.setNetworkTimeout(in.readLong());
+        disco.setJoinTimeout(in.readLong());
+
+        cfg.setDiscoverySpi(disco);
+    }
+
+    /**
+     * Writes cache configuration.
+     *
+     * @param writer Writer.
+     * @param ccfg Configuration.
+     */
+    public static void writeCacheConfiguration(BinaryRawWriter writer, CacheConfiguration ccfg) {
+        assert writer != null;
+        assert ccfg != null;
+
+        writer.writeInt(ccfg.getAtomicityMode() == null ?
+            CacheConfiguration.DFLT_CACHE_ATOMICITY_MODE.ordinal() : ccfg.getAtomicityMode().ordinal());
+        writer.writeInt(ccfg.getAtomicWriteOrderMode() == null ? 0 : ccfg.getAtomicWriteOrderMode().ordinal());
+        writer.writeInt(ccfg.getBackups());
+        writer.writeInt(ccfg.getCacheMode() == null ?
+            CacheConfiguration.DFLT_CACHE_MODE.ordinal() : ccfg.getCacheMode().ordinal());
+        writer.writeBoolean(ccfg.isCopyOnRead());
+        writer.writeBoolean(ccfg.isEagerTtl());
+        writer.writeBoolean(ccfg.isSwapEnabled());
+        writer.writeBoolean(ccfg.isEvictSynchronized());
+        writer.writeInt(ccfg.getEvictSynchronizedConcurrencyLevel());
+        writer.writeInt(ccfg.getEvictSynchronizedKeyBufferSize());
+        writer.writeLong(ccfg.getEvictSynchronizedTimeout());
+        writer.writeBoolean(ccfg.isInvalidate());
+        writer.writeBoolean(ccfg.isStoreKeepBinary());
+        writer.writeBoolean(ccfg.isLoadPreviousValue());
+        writer.writeLong(ccfg.getDefaultLockTimeout());
+        writer.writeLong(ccfg.getLongQueryWarningTimeout());
+        writer.writeInt(ccfg.getMaxConcurrentAsyncOperations());
+        writer.writeFloat(ccfg.getEvictMaxOverflowRatio());
+        writer.writeInt(ccfg.getMemoryMode() == null ?
+            CacheConfiguration.DFLT_MEMORY_MODE.ordinal() : ccfg.getMemoryMode().ordinal());
+        writer.writeString(ccfg.getName());
+        writer.writeLong(ccfg.getOffHeapMaxMemory());
+        writer.writeBoolean(ccfg.isReadFromBackup());
+        writer.writeInt(ccfg.getRebalanceBatchSize());
+        writer.writeLong(ccfg.getRebalanceDelay());
+        writer.writeInt(ccfg.getRebalanceMode() == null ?
+            CacheConfiguration.DFLT_REBALANCE_MODE.ordinal() : ccfg.getRebalanceMode().ordinal());
+        writer.writeLong(ccfg.getRebalanceThrottle());
+        writer.writeLong(ccfg.getRebalanceTimeout());
+        writer.writeBoolean(ccfg.isSqlEscapeAll());
+        writer.writeInt(ccfg.getSqlOnheapRowCacheSize());
+        writer.writeInt(ccfg.getStartSize());
+        writer.writeInt(ccfg.getWriteBehindBatchSize());
+        writer.writeBoolean(ccfg.isWriteBehindEnabled());
+        writer.writeLong(ccfg.getWriteBehindFlushFrequency());
+        writer.writeInt(ccfg.getWriteBehindFlushSize());
+        writer.writeInt(ccfg.getWriteBehindFlushThreadCount());
+        writer.writeInt(ccfg.getWriteSynchronizationMode() == null ? 0 : ccfg.getWriteSynchronizationMode().ordinal());
+
+        if (ccfg.getCacheStoreFactory() instanceof PlatformDotNetCacheStoreFactoryNative)
+            writer.writeObject(((PlatformDotNetCacheStoreFactoryNative)ccfg.getCacheStoreFactory()).getNativeFactory());
+        else
+            writer.writeObject(null);
+
+        Collection<QueryEntity> qryEntities = ccfg.getQueryEntities();
+
+        if (qryEntities != null)
+        {
+            writer.writeInt(qryEntities.size());
+
+            for (QueryEntity e : qryEntities)
+                writeQueryEntity(writer, e);
+        }
+        else
+            writer.writeInt(0);
+    }
+
+    /**
+     * Write query entity.
+     *
+     * @param writer Writer.
+     * @param queryEntity Query entity.
+     */
+    private static void writeQueryEntity(BinaryRawWriter writer, QueryEntity queryEntity) {
+        assert queryEntity != null;
+
+        writer.writeString(queryEntity.getKeyType());
+        writer.writeString(queryEntity.getValueType());
+
+        // Fields
+        LinkedHashMap<String, String> fields = queryEntity.getFields();
+
+        if (fields != null) {
+            writer.writeInt(fields.size());
+
+            for (Map.Entry<String, String> field : fields.entrySet()) {
+                writer.writeString(field.getKey());
+                writer.writeString(field.getValue());
+            }
+        }
+        else
+            writer.writeInt(0);
+
+        // Aliases
+        Map<String, String> aliases = queryEntity.getAliases();
+
+        if (aliases != null) {
+            writer.writeInt(aliases.size());
+
+            for (Map.Entry<String, String> alias : aliases.entrySet()) {
+                writer.writeString(alias.getKey());
+                writer.writeString(alias.getValue());
+            }
+        }
+        else
+            writer.writeInt(0);
+
+        // Indexes
+        Collection<QueryIndex> indexes = queryEntity.getIndexes();
+
+        if (indexes != null) {
+            writer.writeInt(indexes.size());
+
+            for (QueryIndex index : indexes)
+                writeQueryIndex(writer, index);
+        }
+        else
+            writer.writeInt(0);
+    }
+
+    /**
+     * Writer query index.
+     *
+     * @param writer Writer.
+     * @param index Index.
+     */
+    private static void writeQueryIndex(BinaryRawWriter writer, QueryIndex index) {
+        assert index != null;
+
+        writer.writeString(index.getName());
+        writer.writeByte((byte)index.getIndexType().ordinal());
+
+        LinkedHashMap<String, Boolean> fields = index.getFields();
+
+        if (fields != null) {
+            writer.writeInt(fields.size());
+
+            for (Map.Entry<String, Boolean> field : fields.entrySet()) {
+                writer.writeString(field.getKey());
+                writer.writeBoolean(!field.getValue());
+            }
+        }
+        else
+            writer.writeInt(0);
+    }
+
+    /**
+     * Writes Ignite configuration.
+     *
+     * @param w Writer.
+     * @param cfg Configuration.
+     */
+    public static void writeIgniteConfiguration(BinaryRawWriter w, IgniteConfiguration cfg) {
+        assert w != null;
+        assert cfg != null;
+
+        w.writeBoolean(cfg.isClientMode());
+        w.writeIntArray(cfg.getIncludeEventTypes());
+        w.writeLong(cfg.getMetricsExpireTime());
+        w.writeInt(cfg.getMetricsHistorySize());
+        w.writeLong(cfg.getMetricsLogFrequency());
+        w.writeLong(cfg.getMetricsUpdateFrequency());
+        w.writeInt(cfg.getNetworkSendRetryCount());
+        w.writeLong(cfg.getNetworkSendRetryDelay());
+        w.writeLong(cfg.getNetworkTimeout());
+        w.writeString(cfg.getWorkDirectory());
+        w.writeString(cfg.getLocalHost());
+
+        CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration();
+
+        if (cacheCfg != null) {
+            w.writeInt(cacheCfg.length);
+
+            for (CacheConfiguration ccfg : cacheCfg)
+                writeCacheConfiguration(w, ccfg);
+        }
+        else
+            w.writeInt(0);
+
+        writeDiscoveryConfiguration(w, cfg.getDiscoverySpi());
+
+        w.writeString(cfg.getIgniteHome());
+
+        w.writeLong(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getInit());
+        w.writeLong(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax());
+    }
+
+    /**
+     * Writes discovery configuration.
+     *
+     * @param w Writer.
+     * @param spi Disco.
+     */
+    private static void writeDiscoveryConfiguration(BinaryRawWriter w, DiscoverySpi spi) {
+        assert w != null;
+        assert spi != null;
+
+        if (!(spi instanceof TcpDiscoverySpi)) {
+            w.writeBoolean(false);
+            return;
+        }
+
+        w.writeBoolean(true);
+
+        TcpDiscoverySpi tcp = (TcpDiscoverySpi)spi;
+
+        TcpDiscoveryIpFinder finder = tcp.getIpFinder();
+
+        if (finder instanceof TcpDiscoveryVmIpFinder) {
+            w.writeBoolean(true);
+
+            boolean isMulticast = finder instanceof TcpDiscoveryMulticastIpFinder;
+
+            w.writeByte((byte)(isMulticast ? 2 : 1));
+
+            Collection<InetSocketAddress> addrs = finder.getRegisteredAddresses();
+
+            w.writeInt(addrs.size());
+
+            for (InetSocketAddress a : addrs)
+                w.writeString(a.toString());
+
+            if (isMulticast) {
+                TcpDiscoveryMulticastIpFinder multiFinder = (TcpDiscoveryMulticastIpFinder) finder;
+
+                w.writeString(multiFinder.getLocalAddress());
+                w.writeString(multiFinder.getMulticastGroup());
+                w.writeInt(multiFinder.getMulticastPort());
+                w.writeInt(multiFinder.getAddressRequestAttempts());
+                w.writeInt(multiFinder.getResponseWaitTime());
+
+                Integer ttl = multiFinder.getTimeToLive();
+                w.writeBoolean(ttl != null);
+
+                if (ttl != null)
+                    w.writeInt(ttl);
+            }
+        }
+        else {
+            w.writeBoolean(false);
+        }
+
+        w.writeLong(tcp.getSocketTimeout());
+        w.writeLong(tcp.getAckTimeout());
+        w.writeLong(tcp.getMaxAckTimeout());
+        w.writeLong(tcp.getNetworkTimeout());
+        w.writeLong(tcp.getJoinTimeout());
+    }
+
+    /**
+     * Private constructor.
+     */
+    private PlatformConfigurationUtils() {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index 4a29637..d09b2c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -22,10 +22,16 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.MarshallerContextImpl;
+import org.apache.ignite.internal.binary.BinaryContext;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.binary.BinaryNoopMetadataHandler;
 import org.apache.ignite.internal.binary.BinaryRawReaderEx;
 import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
 import org.apache.ignite.internal.processors.platform.PlatformExtendedException;
 import org.apache.ignite.internal.processors.platform.PlatformNativeException;
@@ -38,9 +44,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
-import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration;
-import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration;
+import org.apache.ignite.logger.NullLogger;
 import org.jetbrains.annotations.Nullable;
 
 import javax.cache.CacheException;
@@ -764,41 +768,27 @@ public class PlatformUtils {
     }
 
     /**
-     * Write .Net configuration to the stream.
+     * Create binary marshaller.
      *
-     * @param writer Writer.
-     * @param cfg Configuration.
+     * @return Marshaller.
      */
-    public static void writeDotNetConfiguration(BinaryRawWriterEx writer, PlatformDotNetConfiguration cfg) {
-        // 1. Write assemblies.
-        writeNullableCollection(writer, cfg.getAssemblies());
+    @SuppressWarnings("deprecation")
+    public static GridBinaryMarshaller marshaller() {
+        try {
+            BinaryContext ctx =
+                new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger());
 
-        PlatformDotNetBinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
+            BinaryMarshaller marsh = new BinaryMarshaller();
 
-        if (binaryCfg != null) {
-            writer.writeBoolean(true);
+            marsh.setContext(new MarshallerContextImpl(null));
 
-            writeNullableCollection(writer, binaryCfg.getTypesConfiguration(),
-                new PlatformWriterClosure<PlatformDotNetBinaryTypeConfiguration>() {
-                @Override public void write(BinaryRawWriterEx writer, PlatformDotNetBinaryTypeConfiguration typ) {
-                    writer.writeString(typ.getTypeName());
-                    writer.writeString(typ.getNameMapper());
-                    writer.writeString(typ.getIdMapper());
-                    writer.writeString(typ.getSerializer());
-                    writer.writeString(typ.getAffinityKeyFieldName());
-                    writer.writeObject(typ.getKeepDeserialized());
-                    writer.writeBoolean(typ.isEnum());
-                }
-            });
+            ctx.configure(marsh, new IgniteConfiguration());
 
-            writeNullableCollection(writer, binaryCfg.getTypes());
-            writer.writeString(binaryCfg.getDefaultNameMapper());
-            writer.writeString(binaryCfg.getDefaultIdMapper());
-            writer.writeString(binaryCfg.getDefaultSerializer());
-            writer.writeBoolean(binaryCfg.isDefaultKeepDeserialized());
+            return new GridBinaryMarshaller(ctx);
+        }
+        catch (IgniteCheckedException e) {
+            throw U.convertException(e);
         }
-        else
-            writer.writeBoolean(false);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java
new file mode 100644
index 0000000..ec01483
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java
@@ -0,0 +1,58 @@
+/*
+ * 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.platform.dotnet;
+
+import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore;
+
+import javax.cache.configuration.Factory;
+
+/**
+ * Cache store factory that wraps native factory object.
+ */
+public class PlatformDotNetCacheStoreFactoryNative implements Factory<PlatformDotNetCacheStore> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** */
+    private final Object nativeFactory;
+
+    /**
+     * Ctor.
+     *
+     * @param nativeFactory Native factory object.
+     */
+    public PlatformDotNetCacheStoreFactoryNative(Object nativeFactory) {
+        assert nativeFactory != null;
+
+        this.nativeFactory = nativeFactory;
+    }
+
+    /**
+     * Gets the wrapped factory object.
+     *
+     * @return Factory object.
+     */
+    public Object getNativeFactory() {
+        return nativeFactory;
+    }
+
+    /** {@inheritDoc} */
+    @Override public PlatformDotNetCacheStore create() {
+        return new PlatformDotNetCacheStore(nativeFactory);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/cpp/common/include/ignite/common/exports.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/exports.h b/modules/platforms/cpp/common/include/ignite/common/exports.h
index 67583ed..66f918f 100644
--- a/modules/platforms/cpp/common/include/ignite/common/exports.h
+++ b/modules/platforms/cpp/common/include/ignite/common/exports.h
@@ -36,6 +36,8 @@ extern "C" {
     void* IGNITE_CALL IgniteProcessorCache(gcj::JniContext* ctx, void* obj, char* name);
     void* IGNITE_CALL IgniteProcessorCreateCache(gcj::JniContext* ctx, void* obj, char* name);
     void* IGNITE_CALL IgniteProcessorGetOrCreateCache(gcj::JniContext* ctx, void* obj, char* name);
+    void* IGNITE_CALL IgniteProcessorCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr);
+    void* IGNITE_CALL IgniteProcessorGetOrCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr);
     void IGNITE_CALL IgniteProcessorDestroyCache(gcj::JniContext* ctx, void* obj, char* name);
     void* IGNITE_CALL IgniteProcessorAffinity(gcj::JniContext* ctx, void* obj, char* name);
     void* IGNITE_CALL IgniteProcessorDataStreamer(gcj::JniContext* ctx, void* obj, char* name, bool keepPortable);
@@ -46,6 +48,7 @@ extern "C" {
     void* IGNITE_CALL IgniteProcessorServices(gcj::JniContext* ctx, void* obj, void* prj);
     void* IGNITE_CALL IgniteProcessorExtensions(gcj::JniContext* ctx, void* obj);
     void* IGNITE_CALL IgniteProcessorAtomicLong(gcj::JniContext* ctx, void* obj, char* name, long long initVal, bool create);
+    void IGNITE_CALL IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long memPtr);
     
     long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
     void IGNITE_CALL IgniteTargetInStreamOutStream(gcj::JniContext* ctx, void* obj, int opType, long long inMemPtr, long long outMemPtr);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/cpp/common/include/ignite/common/java.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/java.h b/modules/platforms/cpp/common/include/ignite/common/java.h
index 572f040..072a8ef 100644
--- a/modules/platforms/cpp/common/include/ignite/common/java.h
+++ b/modules/platforms/cpp/common/include/ignite/common/java.h
@@ -297,6 +297,8 @@ namespace ignite
                 jmethodID m_PlatformProcessor_cache;
                 jmethodID m_PlatformProcessor_createCache;
                 jmethodID m_PlatformProcessor_getOrCreateCache;
+                jmethodID m_PlatformProcessor_createCacheFromConfig;
+                jmethodID m_PlatformProcessor_getOrCreateCacheFromConfig;
                 jmethodID m_PlatformProcessor_destroyCache;
                 jmethodID m_PlatformProcessor_affinity;
                 jmethodID m_PlatformProcessor_dataStreamer;
@@ -308,6 +310,7 @@ namespace ignite
                 jmethodID m_PlatformProcessor_services;
                 jmethodID m_PlatformProcessor_extensions;
                 jmethodID m_PlatformProcessor_atomicLong;
+                jmethodID m_PlatformProcessor_getIgniteConfiguration;
 
                 jclass c_PlatformTarget;
                 jmethodID m_PlatformTarget_inStreamOutLong;
@@ -489,6 +492,10 @@ namespace ignite
                 jobject ProcessorCreateCache(jobject obj, const char* name, JniErrorInfo* errInfo);
                 jobject ProcessorGetOrCreateCache(jobject obj, const char* name);
                 jobject ProcessorGetOrCreateCache(jobject obj, const char* name, JniErrorInfo* errInfo);
+                jobject ProcessorCreateCacheFromConfig(jobject obj, long memPtr);
+                jobject ProcessorCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo);
+                jobject ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr);
+                jobject ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo);
                 void ProcessorDestroyCache(jobject obj, const char* name);
                 void ProcessorDestroyCache(jobject obj, const char* name, JniErrorInfo* errInfo);
                 jobject ProcessorAffinity(jobject obj, const char* name);
@@ -500,6 +507,7 @@ namespace ignite
                 jobject ProcessorServices(jobject obj, jobject prj);
                 jobject ProcessorExtensions(jobject obj);
                 jobject ProcessorAtomicLong(jobject obj, char* name, long long initVal, bool create);
+				void ProcessorGetIgniteConfiguration(jobject obj, long memPtr);
                 
                 long long TargetInStreamOutLong(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
                 void TargetInStreamOutStream(jobject obj, int opType, long long inMemPtr, long long outMemPtr, JniErrorInfo* errInfo = NULL);
@@ -618,6 +626,7 @@ namespace ignite
                 void ExceptionCheck(JNIEnv* env, JniErrorInfo* errInfo);
                 jobject LocalToGlobal(JNIEnv* env, jobject obj);
                 jobject ProcessorCache0(jobject proc, const char* name, jmethodID mthd, JniErrorInfo* errInfo);
+                jobject ProcessorCacheFromConfig0(jobject proc, long memPtr, jmethodID mthd, JniErrorInfo* errInfo);
             };
 
             JNIEXPORT jlong JNICALL JniCacheStoreCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/cpp/common/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/module.def b/modules/platforms/cpp/common/project/vs/module.def
index c947128..81df027 100644
--- a/modules/platforms/cpp/common/project/vs/module.def
+++ b/modules/platforms/cpp/common/project/vs/module.def
@@ -113,4 +113,7 @@ IgniteListenableCancel @110
 IgniteListenableIsCancelled @111
 IgniteTargetListenFutureAndGet @112
 IgniteTargetListenFutureForOperationAndGet @113
-IgniteProcessorDestroyCache @114
\ No newline at end of file
+IgniteProcessorCreateCacheFromConfig @114
+IgniteProcessorGetOrCreateCacheFromConfig @115
+IgniteProcessorGetIgniteConfiguration @116
+IgniteProcessorDestroyCache @117
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/cpp/common/src/exports.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/exports.cpp b/modules/platforms/cpp/common/src/exports.cpp
index d4ffa7e..e9ec519 100644
--- a/modules/platforms/cpp/common/src/exports.cpp
+++ b/modules/platforms/cpp/common/src/exports.cpp
@@ -66,6 +66,14 @@ extern "C" {
         return ctx->ProcessorGetOrCreateCache(static_cast<jobject>(obj), name);
     }
 
+    void* IGNITE_CALL IgniteProcessorCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr) {
+        return ctx->ProcessorCreateCacheFromConfig(static_cast<jobject>(obj), memPtr);
+    }
+
+    void* IGNITE_CALL IgniteProcessorGetOrCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr) {
+        return ctx->ProcessorGetOrCreateCacheFromConfig(static_cast<jobject>(obj), memPtr);
+    }
+
     void IGNITE_CALL IgniteProcessorDestroyCache(gcj::JniContext* ctx, void* obj, char* name) {
         ctx->ProcessorDestroyCache(static_cast<jobject>(obj), name);
     }
@@ -106,6 +114,10 @@ extern "C" {
         return ctx->ProcessorAtomicLong(static_cast<jobject>(obj), name, initVal, create);
     }
 
+	void IGNITE_CALL IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long memPtr) {
+        return ctx->ProcessorGetIgniteConfiguration(static_cast<jobject>(obj), memPtr);
+    }
+
     long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr) {
         return ctx->TargetInStreamOutLong(static_cast<jobject>(obj), opType, memPtr);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/cpp/common/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/java.cpp b/modules/platforms/cpp/common/src/java.cpp
index 9e55742..e36c1e0 100644
--- a/modules/platforms/cpp/common/src/java.cpp
+++ b/modules/platforms/cpp/common/src/java.cpp
@@ -191,6 +191,8 @@ namespace ignite
             JniMethod M_PLATFORM_PROCESSOR_CACHE = JniMethod("cache", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_CREATE_CACHE = JniMethod("createCache", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE = JniMethod("getOrCreateCache", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+            JniMethod M_PLATFORM_PROCESSOR_CREATE_CACHE_FROM_CONFIG = JniMethod("createCacheFromConfig", "(J)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+            JniMethod M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE_FROM_CONFIG = JniMethod("getOrCreateCacheFromConfig", "(J)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_DESTROY_CACHE = JniMethod("destroyCache", "(Ljava/lang/String;)V", false);
             JniMethod M_PLATFORM_PROCESSOR_AFFINITY = JniMethod("affinity", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_DATA_STREAMER = JniMethod("dataStreamer", "(Ljava/lang/String;Z)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
@@ -201,6 +203,7 @@ namespace ignite
             JniMethod M_PLATFORM_PROCESSOR_SERVICES = JniMethod("services", "(Lorg/apache/ignite/internal/processors/platform/PlatformTarget;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_EXTENSIONS = JniMethod("extensions", "()Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_ATOMIC_LONG = JniMethod("atomicLong", "(Ljava/lang/String;JZ)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+            JniMethod M_PLATFORM_PROCESSOR_GET_IGNITE_CONFIGURATION = JniMethod("getIgniteConfiguration", "(J)V", false);
 
             const char* C_PLATFORM_TARGET = "org/apache/ignite/internal/processors/platform/PlatformTarget";
             JniMethod M_PLATFORM_TARGET_IN_STREAM_OUT_LONG = JniMethod("inStreamOutLong", "(IJ)J", false);
@@ -636,6 +639,8 @@ namespace ignite
                 m_PlatformProcessor_cache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CACHE);
                 m_PlatformProcessor_createCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CREATE_CACHE);
                 m_PlatformProcessor_getOrCreateCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE);
+                m_PlatformProcessor_createCacheFromConfig = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CREATE_CACHE_FROM_CONFIG);
+                m_PlatformProcessor_getOrCreateCacheFromConfig = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE_FROM_CONFIG);
                 m_PlatformProcessor_destroyCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_DESTROY_CACHE);
                 m_PlatformProcessor_affinity = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_AFFINITY);
                 m_PlatformProcessor_dataStreamer = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_DATA_STREAMER);
@@ -647,6 +652,7 @@ namespace ignite
                 m_PlatformProcessor_services = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_SERVICES);
                 m_PlatformProcessor_extensions = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_EXTENSIONS);
                 m_PlatformProcessor_atomicLong = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_ATOMIC_LONG);
+				m_PlatformProcessor_getIgniteConfiguration = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_IGNITE_CONFIGURATION);
 
                 c_PlatformTarget = FindClass(env, C_PLATFORM_TARGET);
                 m_PlatformTarget_inStreamOutLong = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_OUT_LONG);
@@ -1120,6 +1126,17 @@ namespace ignite
                 return LocalToGlobal(env, cache);
             }
 
+            jobject JniContext::ProcessorCacheFromConfig0(jobject obj, long memPtr, jmethodID mthd, JniErrorInfo* errInfo)
+            {
+                JNIEnv* env = Attach();
+
+                jobject cache = env->CallObjectMethod(obj, mthd, memPtr);
+
+                ExceptionCheck(env, errInfo);
+
+                return LocalToGlobal(env, cache);
+            }
+
             jobject JniContext::ProcessorCache(jobject obj, const char* name) {
                 return ProcessorCache(obj, name, NULL);
             }
@@ -1164,6 +1181,24 @@ namespace ignite
                 ExceptionCheck(env, errInfo);
             }
 
+            jobject JniContext::ProcessorCreateCacheFromConfig(jobject obj, long memPtr) {
+                return ProcessorCreateCacheFromConfig(obj, memPtr, NULL);
+            }
+
+            jobject JniContext::ProcessorCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo)
+            {
+                return ProcessorCacheFromConfig0(obj, memPtr, jvm->GetMembers().m_PlatformProcessor_createCacheFromConfig, errInfo);
+            }
+
+            jobject JniContext::ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr) {
+                return ProcessorGetOrCreateCacheFromConfig(obj, memPtr, NULL);
+            }
+
+            jobject JniContext::ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo)
+            {
+                return ProcessorCacheFromConfig0(obj, memPtr, jvm->GetMembers().m_PlatformProcessor_getOrCreateCacheFromConfig, errInfo);
+            }
+
             jobject JniContext::ProcessorAffinity(jobject obj, const char* name) {
                 JNIEnv* env = Attach();
 
@@ -1272,6 +1307,15 @@ namespace ignite
                 return LocalToGlobal(env, res);
             }
 
+            void JniContext::ProcessorGetIgniteConfiguration(jobject obj, long memPtr)
+            {
+                JNIEnv* env = Attach();
+
+                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformProcessor_getIgniteConfiguration, memPtr);
+
+                ExceptionCheck(env);
+            }
+
             long long JniContext::TargetInStreamOutLong(jobject obj, int opType, long long memPtr, JniErrorInfo* err) {
                 JNIEnv* env = Attach();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 5a1e176..481adfb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -60,6 +60,7 @@
     <Reference Include="System.XML" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Cache\CacheConfigurationTest.cs" />
     <Compile Include="Cache\CacheDynamicStartTest.cs" />
     <Compile Include="Cache\CacheTestAsyncWrapper.cs" />
     <Compile Include="Cache\CacheAbstractTest.cs" />
@@ -74,6 +75,7 @@
     <Compile Include="Cache\CachePartitionedTest.cs" />
     <Compile Include="Cache\CacheReplicatedAtomicTest.cs" />
     <Compile Include="Cache\CacheReplicatedTest.cs" />
+    <Compile Include="Cache\Query\CacheQueriesCodeConfigurationTest.cs" />
     <Compile Include="Cache\Query\Continuous\ContinuousQueryAbstractTest.cs" />
     <Compile Include="Cache\Query\Continuous\ContinuousQueryAtomicBackupTest.cs" />
     <Compile Include="Cache\Query\Continuous\ContinuousQueryAtomicNoBackupTest.cs" />
@@ -113,6 +115,7 @@
     <Compile Include="ExceptionsTest.cs" />
     <Compile Include="ExecutableTest.cs" />
     <Compile Include="FutureTest.cs" />
+    <Compile Include="IgniteConfigurationTest.cs" />
     <Compile Include="IgniteTestBase.cs" />
     <Compile Include="LifecycleTest.cs" />
     <Compile Include="LoadDllTest.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
index 9232665..44db6f7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
@@ -1341,6 +1341,15 @@ namespace Apache.Ignite.Core.Tests.Binary
             }
         }
 
+        [Test]
+        public void TestBinaryConfigurationValidation()
+        {
+            var cfg = new BinaryConfiguration(typeof (PropertyType)) {Types = new[] {"PropertyType"}};
+
+            // ReSharper disable once ObjectCreationAsStatement
+            Assert.Throws<BinaryObjectException>(() => new Marshaller(cfg));
+        }
+
         private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
         {
             if (cfg.TypeConfigurations == null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index e57df6f..9f0528c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -292,7 +292,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         public virtual void StartGrids() {
             TestUtils.KillProcesses();
 
-            IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+            IgniteConfiguration cfg = new IgniteConfiguration();
 
             BinaryConfiguration portCfg = new BinaryConfiguration();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
index 5a1af03..689804c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
@@ -36,7 +36,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         {
             TestUtils.KillProcesses();
 
-            IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+            IgniteConfiguration cfg = new IgniteConfiguration();
 
             cfg.JvmClasspath = TestUtils.CreateTestClasspath();
             cfg.JvmOptions = TestUtils.TestJavaOptions();


[27/28] ignite git commit: IGNITE-2508: Further fixes.

Posted by vo...@apache.org.
IGNITE-2508: Further fixes.


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

Branch: refs/heads/ignite-2508
Commit: 566598e930e76b5db61792dd609962b14284a25a
Parents: cf69740
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Feb 3 15:26:07 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 3 15:26:07 2016 +0300

----------------------------------------------------------------------
 .../affinity/GridAffinityAssignmentCache.java   | 11 ------
 .../cache/GridCacheAffinityManager.java         | 39 ++++++++------------
 2 files changed, 15 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/566598e9/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index 836183d..0bc503c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -390,17 +390,6 @@ public class GridAffinityAssignmentCache {
     }
 
     /**
-     * Gets affinity nodes IDs for specified partition.
-     *
-     * @param part Partition.
-     * @param topVer Topology version.
-     * @return Affinity nodes.
-     */
-    public HashSet<UUID> nodesIds(int part, AffinityTopologyVersion topVer) {
-        return cachedAffinity(topVer).getIds(part);
-    }
-
-    /**
      * Get primary partitions for specified node ID.
      *
      * @param nodeId Node ID to get primary partitions for.

http://git-wip-us.apache.org/repos/asf/ignite/blob/566598e9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index 54600ab..e3a5439 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -17,12 +17,6 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.cluster.ClusterNode;
@@ -38,6 +32,12 @@ import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.lang.IgniteFuture;
 import org.jetbrains.annotations.Nullable;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
 /**
  * Cache affinity manager.
  */
@@ -162,7 +162,15 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
      * @return Affinity affignment.
      */
     public GridAffinityAssignment assignment(AffinityTopologyVersion topVer) {
-        return aff.cachedAffinity(topVer);
+        if (cctx.isLocal())
+            topVer = new AffinityTopologyVersion(1);
+
+        GridAffinityAssignmentCache aff0 = aff;
+
+        if (aff0 == null)
+            throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + cctx.name());
+
+        return aff0.cachedAffinity(topVer);
     }
 
     /**
@@ -258,23 +266,6 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
     }
 
     /**
-     * @param part Partition.
-     * @param topVer Topology version.
-     * @return Affinity node IDs.
-     */
-    public HashSet<UUID> nodesIds(int part, AffinityTopologyVersion topVer) {
-        if (cctx.isLocal())
-            topVer = new AffinityTopologyVersion(1);
-
-        GridAffinityAssignmentCache aff0 = aff;
-
-        if (aff0 == null)
-            throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + cctx.name());
-
-        return aff0.nodesIds(part, topVer);
-    }
-
-    /**
      * @param key Key to check.
      * @param topVer Topology version.
      * @return Primary node for given key.


[17/28] ignite git commit: ignite-2080 Data alignment issues with Unsafe

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
index 359d36c..3f58447 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
@@ -45,8 +45,23 @@ import static org.apache.ignite.internal.util.offheap.GridOffHeapEvent.REHASH;
  */
 public class GridUnsafeMap implements GridOffHeapMap {
     /** Header size. */
-    private static final int HEADER = 4 /*hash*/ + 4 /*key-size*/  + 4 /*value-size*/ + 8 /*queue-address*/ +
-        8 /*next-address*/;
+    private static final int HEADER_SIZE = 8 /*queue-address*/ + 8 /*next-address*/ + 4 /*hash*/ + 4 /*key-size*/
+        + 4 /*value-size*/;
+
+    /** Header queue address offset. */
+    private static final long HEADER_QUEUE_ADDR_OFF = 0;
+
+    /** Header next address offset. */
+    private static final long HEADER_NEXT_ADDR_OFF = 8;
+
+    /** Header hash offset. */
+    private static final long HEADER_HASH_OFF = 16;
+
+    /** Header key size offset. */
+    private static final long HEADER_KEY_SIZE_OFF = 20;
+
+    /** Header value size. */
+    private static final long HEADER_VALUE_SIZE = 24;
 
     /** Debug flag. */
     private static final boolean DEBUG = false;
@@ -789,7 +804,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
                                 int keyLen = Entry.readKeyLength(entryAddr, mem);
                                 int valLen = Entry.readValueLength(entryAddr, mem);
 
-                                byte[] valBytes =  mem.readBytes(entryAddr + HEADER + keyLen, valLen);
+                                byte[] valBytes =  mem.readBytes(entryAddr + HEADER_SIZE + keyLen, valLen);
 
                                 bin.add(F.t(Entry.readKeyBytes(entryAddr, mem), valBytes));
                             }
@@ -860,9 +875,9 @@ public class GridUnsafeMap implements GridOffHeapMap {
                                 int keyLen = Entry.readKeyLength(entryAddr, mem);
                                 int valLen = Entry.readValueLength(entryAddr, mem);
 
-                                T2<Long, Integer> keyPtr = new T2<>(entryAddr + HEADER, keyLen);
+                                T2<Long, Integer> keyPtr = new T2<>(entryAddr + HEADER_SIZE, keyLen);
 
-                                T2<Long, Integer> valPtr = new T2<>(entryAddr + HEADER + keyLen, valLen);
+                                T2<Long, Integer> valPtr = new T2<>(entryAddr + HEADER_SIZE + keyLen, valLen);
 
                                 T res = c.apply(keyPtr, valPtr);
 
@@ -1033,7 +1048,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
                                 int keyLen = Entry.readKeyLength(cur, mem);
                                 int valLen = Entry.readValueLength(cur, mem);
 
-                                valBytes = mem.readBytes(cur + HEADER + keyLen, valLen);
+                                valBytes = mem.readBytes(cur + HEADER_SIZE + keyLen, valLen);
                             }
 
                             if (rmvEvicted) {
@@ -1101,7 +1116,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
             if (cnt + 1 > threshold)
                 rehash();
 
-            int size = HEADER + keyBytes.length + valBytes.length;
+            int size = HEADER_SIZE + keyBytes.length + valBytes.length;
 
             boolean poll = !mem.reserve(size);
 
@@ -1230,7 +1245,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
                     }
                 }
 
-                size = HEADER + keyBytes.length + valBytes.length;
+                size = HEADER_SIZE + keyBytes.length + valBytes.length;
 
                 poll = !mem.reserve(size);
 
@@ -1332,7 +1347,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
                                 keyLen = Entry.readKeyLength(cur, mem);
                                 valLen = Entry.readValueLength(cur, mem);
 
-                                long valPtr = cur + HEADER + keyLen;
+                                long valPtr = cur + HEADER_SIZE + keyLen;
 
                                 if (!p.apply(valPtr, valLen))
                                     return null;
@@ -1353,7 +1368,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
                                     valLen = Entry.readValueLength(cur, mem);
                                 }
 
-                                valBytes = mem.readBytes(cur + HEADER + keyLen, valLen);
+                                valBytes = mem.readBytes(cur + HEADER_SIZE + keyLen, valLen);
                             }
                             else
                                 valBytes = EMPTY_BYTES;
@@ -1445,7 +1460,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
                         int keyLen = Entry.readKeyLength(addr, mem);
                         int valLen = Entry.readValueLength(addr, mem);
 
-                        return new IgniteBiTuple<>(addr + HEADER + keyLen, valLen);
+                        return new IgniteBiTuple<>(addr + HEADER_SIZE + keyLen, valLen);
                     }
 
                     addr = Entry.nextAddress(addr, mem);
@@ -1510,7 +1525,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
                             int keyLen = Entry.readKeyLength(addr, mem);
                             int valLen = Entry.readValueLength(addr, mem);
 
-                            return mem.readBytes(addr + HEADER + keyLen, valLen);
+                            return mem.readBytes(addr + HEADER_SIZE + keyLen, valLen);
                         }
                     }
 
@@ -1570,7 +1585,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @return Entry memory size.
          */
         static int size(byte[] keyBytes, byte[] valBytes) {
-            return HEADER + keyBytes.length + valBytes.length;
+            return HEADER_SIZE + keyBytes.length + valBytes.length;
         }
 
         /**
@@ -1579,7 +1594,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @return Entry size.
          */
         static int size(long addr, GridUnsafeMemory mem) {
-            return HEADER + readKeyLength(addr, mem) + readValueLength(addr, mem);
+            return HEADER_SIZE + readKeyLength(addr, mem) + readValueLength(addr, mem);
         }
 
         /**
@@ -1588,7 +1603,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @return Hash.
          */
         static int hash(long ptr, GridUnsafeMemory mem) {
-            return mem.readInt(ptr);
+            return mem.readInt(ptr + HEADER_HASH_OFF);
         }
 
         /**
@@ -1597,7 +1612,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @param mem Memory.
          */
         static void hash(long ptr, int hash, GridUnsafeMemory mem) {
-            mem.writeInt(ptr, hash);
+            mem.writeInt(ptr + HEADER_HASH_OFF, hash);
         }
 
         /**
@@ -1606,7 +1621,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @return Key length.
          */
         static int readKeyLength(long ptr, GridUnsafeMemory mem) {
-            int len = mem.readInt(ptr + 4);
+            int len = mem.readInt(ptr + HEADER_KEY_SIZE_OFF);
 
             assert len >= 0 : "Invalid key length [addr=" + String.format("0x%08x", ptr) +
                 ", len=" + Long.toHexString(len) + ']';
@@ -1622,7 +1637,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @param mem Memory.
          */
         static void writeKeyLength(long ptr, int len, GridUnsafeMemory mem) {
-            mem.writeInt(ptr + 4, len);
+            mem.writeInt(ptr + HEADER_KEY_SIZE_OFF, len);
         }
 
         /**
@@ -1631,7 +1646,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @return Value length.
          */
         static int readValueLength(long ptr, GridUnsafeMemory mem) {
-            int len = mem.readInt(ptr + 8);
+            int len = mem.readInt(ptr + HEADER_VALUE_SIZE);
 
             assert len >= 0 : "Invalid value length [addr=" + String.format("0x%08x", ptr) +
                 ", len=" + Integer.toHexString(len) + ']';
@@ -1647,7 +1662,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @param mem Memory.
          */
         static void writeValueLength(long ptr, int len, GridUnsafeMemory mem) {
-            mem.writeInt(ptr + 8, len);
+            mem.writeInt(ptr + HEADER_VALUE_SIZE, len);
         }
 
         /**
@@ -1656,7 +1671,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @return Queue address.
          */
         static long queueAddress(long ptr, GridUnsafeMemory mem) {
-            return mem.readLong(ptr + 12);
+            return mem.readLong(ptr + HEADER_QUEUE_ADDR_OFF);
         }
 
         /**
@@ -1665,7 +1680,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @param mem Memory.
          */
         static void queueAddress(long ptr, long qAddr, GridUnsafeMemory mem) {
-            mem.writeLong(ptr + 12, qAddr);
+            mem.writeLong(ptr + HEADER_QUEUE_ADDR_OFF, qAddr);
         }
 
         /**
@@ -1675,7 +1690,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @return {@code True} if changed to zero.
          */
         static boolean clearQueueAddress(long ptr, long qAddr, GridUnsafeMemory mem) {
-            return mem.casLong(ptr + 12, qAddr, 0);
+            return mem.casLong(ptr + HEADER_QUEUE_ADDR_OFF, qAddr, 0);
         }
 
         /**
@@ -1684,7 +1699,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @return Next address.
          */
         static long nextAddress(long ptr, GridUnsafeMemory mem) {
-            return mem.readLong(ptr + 20);
+            return mem.readLong(ptr + HEADER_NEXT_ADDR_OFF);
         }
 
         /**
@@ -1695,7 +1710,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @param mem Memory.
          */
         static void nextAddress(long ptr, long addr, GridUnsafeMemory mem) {
-            mem.writeLong(ptr + 20, addr);
+            mem.writeLong(ptr + HEADER_NEXT_ADDR_OFF, addr);
         }
 
         /**
@@ -1706,7 +1721,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
         static byte[] readKeyBytes(long ptr, GridUnsafeMemory mem) {
             int keyLen = readKeyLength(ptr, mem);
 
-            return mem.readBytes(ptr + HEADER, keyLen);
+            return mem.readBytes(ptr + HEADER_SIZE, keyLen);
         }
 
         /**
@@ -1715,7 +1730,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @param mem Memory.
          */
         static void writeKeyBytes(long ptr, byte[] keyBytes, GridUnsafeMemory mem) {
-            mem.writeBytes(ptr + HEADER, keyBytes);
+            mem.writeBytes(ptr + HEADER_SIZE, keyBytes);
         }
 
         /**
@@ -1727,7 +1742,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
             int keyLen = readKeyLength(ptr, mem);
             int valLen = readValueLength(ptr, mem);
 
-            return mem.readBytes(ptr + HEADER + keyLen, valLen);
+            return mem.readBytes(ptr + HEADER_SIZE + keyLen, valLen);
         }
 
         /**
@@ -1746,7 +1761,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
          * @param mem Memory.
          */
         static void writeValueBytes(long ptr, int keyLen, byte[] valBytes, GridUnsafeMemory mem) {
-            mem.writeBytes(ptr + HEADER + keyLen, valBytes);
+            mem.writeBytes(ptr + HEADER_SIZE + keyLen, valBytes);
         }
 
         /**
@@ -1799,7 +1814,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
         static boolean keyEquals(long ptr, byte[] keyBytes, GridUnsafeMemory mem) {
             long len = readKeyLength(ptr, mem);
 
-            return len == keyBytes.length && mem.compare(ptr + HEADER, keyBytes);
+            return len == keyBytes.length && GridUnsafeMemory.compare(ptr + HEADER_SIZE, keyBytes);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemory.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemory.java
index cf0cb5c..87ba2f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemory.java
@@ -25,7 +25,6 @@ import org.apache.ignite.internal.util.offheap.GridOffHeapOutOfMemoryException;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteBiTuple;
-import sun.misc.Unsafe;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_OFFHEAP_SAFE_RELEASE;
 import static org.apache.ignite.internal.util.offheap.GridOffHeapEvent.ALLOCATE;
@@ -35,18 +34,9 @@ import static org.apache.ignite.internal.util.offheap.GridOffHeapEvent.RELEASE;
  * Unsafe memory.
  */
 public class GridUnsafeMemory {
-    /** Unsafe handle. */
-    public static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
     /** Free byte. */
     private static final byte FREE = (byte)0;
 
-    /** Byte array offset. */
-    public static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** Address size. */
-    private static final int ADDR_SIZE = UNSAFE.addressSize();
-
     /** Safe offheap release flag. */
     private static final boolean SAFE_RELEASE = IgniteSystemProperties.getBoolean(IGNITE_OFFHEAP_SAFE_RELEASE);
 
@@ -174,7 +164,7 @@ public class GridUnsafeMemory {
             cnt.addAndGet(size);
 
         try {
-            long ptr = UNSAFE.allocateMemory(size);
+            long ptr = GridUnsafe.allocateMemory(size);
 
             if (init)
                 fill(ptr, size, FREE);
@@ -198,7 +188,7 @@ public class GridUnsafeMemory {
      * @param b Value.
      */
     public void fill(long ptr, long size, byte b) {
-        UNSAFE.setMemory(ptr, size, b);
+        GridUnsafe.setMemory(ptr, size, b);
     }
 
     /**
@@ -233,7 +223,7 @@ public class GridUnsafeMemory {
             if (SAFE_RELEASE)
                 fill(ptr, size, (byte)0xAB);
 
-            UNSAFE.freeMemory(ptr);
+            GridUnsafe.freeMemory(ptr);
 
             cnt.addAndGet(-size);
 
@@ -247,7 +237,7 @@ public class GridUnsafeMemory {
      * @return Long value.
      */
     public long readLong(long ptr) {
-        return UNSAFE.getLong(ptr);
+        return GridUnsafe.getLong(ptr);
     }
 
     /**
@@ -255,7 +245,7 @@ public class GridUnsafeMemory {
      * @param v Long value.
      */
     public void writeLong(long ptr, long v) {
-        UNSAFE.putLong(ptr, v);
+        GridUnsafe.putLong(ptr, v);
     }
 
     /**
@@ -263,7 +253,7 @@ public class GridUnsafeMemory {
      * @return Long value.
      */
     public long readLongVolatile(long ptr) {
-        return UNSAFE.getLongVolatile(null, ptr);
+        return GridUnsafe.getLongVolatile(null, ptr);
     }
 
     /**
@@ -271,7 +261,7 @@ public class GridUnsafeMemory {
      * @param v Long value.
      */
     public void writeLongVolatile(long ptr, long v) {
-        UNSAFE.putLongVolatile(null, ptr, v);
+        GridUnsafe.putLongVolatile(null, ptr, v);
     }
 
     /**
@@ -281,7 +271,7 @@ public class GridUnsafeMemory {
      * @return {@code true} If operation succeeded.
      */
     public boolean casLong(long ptr, long exp, long v) {
-        return UNSAFE.compareAndSwapLong(null, ptr, exp, v);
+        return GridUnsafe.compareAndSwapLong(null, ptr, exp, v);
     }
 
     /**
@@ -289,7 +279,7 @@ public class GridUnsafeMemory {
      * @return Integer value.
      */
     public int readInt(long ptr) {
-        return UNSAFE.getInt(ptr);
+        return GridUnsafe.getInt(ptr);
     }
 
     /**
@@ -297,7 +287,7 @@ public class GridUnsafeMemory {
      * @param v Integer value.
      */
     public void writeInt(long ptr, int v) {
-        UNSAFE.putInt(ptr, v);
+        GridUnsafe.putInt(ptr, v);
     }
 
     /**
@@ -305,7 +295,7 @@ public class GridUnsafeMemory {
      * @return Integer value.
      */
     public int readIntVolatile(long ptr) {
-        return UNSAFE.getIntVolatile(null, ptr);
+        return GridUnsafe.getIntVolatile(null, ptr);
     }
 
     /**
@@ -313,7 +303,7 @@ public class GridUnsafeMemory {
      * @param v Integer value.
      */
     public void writeIntVolatile(long ptr, int v) {
-        UNSAFE.putIntVolatile(null, ptr, v);
+        GridUnsafe.putIntVolatile(null, ptr, v);
     }
 
     /**
@@ -323,7 +313,7 @@ public class GridUnsafeMemory {
      * @return {@code true} If operation succeeded.
      */
     public boolean casInt(long ptr, int exp, int v) {
-        return UNSAFE.compareAndSwapInt(null, ptr, exp, v);
+        return GridUnsafe.compareAndSwapInt(null, ptr, exp, v);
     }
 
     /**
@@ -331,7 +321,7 @@ public class GridUnsafeMemory {
      * @return Float value.
      */
     public float readFloat(long ptr) {
-        return UNSAFE.getFloat(ptr);
+        return GridUnsafe.getFloat(ptr);
     }
 
     /**
@@ -339,7 +329,7 @@ public class GridUnsafeMemory {
      * @param v Value.
      */
     public void writeFloat(long ptr, float v) {
-        UNSAFE.putFloat(ptr, v);
+        GridUnsafe.putFloat(ptr, v);
     }
 
     /**
@@ -347,7 +337,7 @@ public class GridUnsafeMemory {
      * @return Double value.
      */
     public double readDouble(long ptr) {
-        return UNSAFE.getDouble(ptr);
+        return GridUnsafe.getDouble(ptr);
     }
 
     /**
@@ -355,7 +345,7 @@ public class GridUnsafeMemory {
      * @param v Value.
      */
     public void writeDouble(long ptr, double v) {
-        UNSAFE.putDouble(ptr, v);
+        GridUnsafe.putDouble(ptr, v);
     }
 
     /**
@@ -363,7 +353,7 @@ public class GridUnsafeMemory {
      * @return Short value.
      */
     public short readShort(long ptr) {
-        return UNSAFE.getShort(ptr);
+        return GridUnsafe.getShort(ptr);
     }
 
     /**
@@ -371,7 +361,7 @@ public class GridUnsafeMemory {
      * @param v Short value.
      */
     public void writeShort(long ptr, short v) {
-        UNSAFE.putShort(ptr, v);
+        GridUnsafe.putShort(ptr, v);
     }
 
     /**
@@ -379,7 +369,7 @@ public class GridUnsafeMemory {
      * @return Integer value.
      */
     public byte readByte(long ptr) {
-        return UNSAFE.getByte(ptr);
+        return GridUnsafe.getByte(ptr);
     }
 
     /**
@@ -387,7 +377,7 @@ public class GridUnsafeMemory {
      * @return Integer value.
      */
     public byte readByteVolatile(long ptr) {
-        return UNSAFE.getByteVolatile(null, ptr);
+        return GridUnsafe.getByteVolatile(null, ptr);
     }
 
     /**
@@ -395,7 +385,7 @@ public class GridUnsafeMemory {
      * @param v Integer value.
      */
     public void writeByte(long ptr, byte v) {
-        UNSAFE.putByte(ptr, v);
+        GridUnsafe.putByte(ptr, v);
     }
 
     /**
@@ -403,7 +393,7 @@ public class GridUnsafeMemory {
      * @param v Integer value.
      */
     public void writeByteVolatile(long ptr, byte v) {
-        UNSAFE.putByteVolatile(null, ptr, v);
+        GridUnsafe.putByteVolatile(null, ptr, v);
     }
 
     /**
@@ -483,8 +473,8 @@ public class GridUnsafeMemory {
         int words = size / 8;
 
         for (int i = 0; i < words; i++) {
-            long w1 = UNSAFE.getLong(ptr1);
-            long w2 = UNSAFE.getLong(ptr2);
+            long w1 = GridUnsafe.getLong(ptr1);
+            long w2 = GridUnsafe.getLong(ptr2);
 
             if (w1 != w2)
                 return false;
@@ -496,8 +486,8 @@ public class GridUnsafeMemory {
         int left = size % 8;
 
         for (int i = 0; i < left; i++) {
-            byte b1 = UNSAFE.getByte(ptr1);
-            byte b2 = UNSAFE.getByte(ptr2);
+            byte b1 = GridUnsafe.getByte(ptr1);
+            byte b2 = GridUnsafe.getByte(ptr2);
 
             if (b1 != b2)
                 return false;
@@ -517,7 +507,7 @@ public class GridUnsafeMemory {
      * @return {@code True} if equals.
      */
     public static boolean compare(long ptr, byte[] bytes) {
-        final int addrSize = ADDR_SIZE;
+        final int addrSize = GridUnsafe.ADDR_SIZE;
 
         // Align reads to address size.
         int off = (int)(ptr % addrSize);
@@ -527,7 +517,7 @@ public class GridUnsafeMemory {
 
         if (align != addrSize) {
             for (int i = 0; i < align && i < len; i++) {
-                if (UNSAFE.getByte(ptr) != bytes[i])
+                if (GridUnsafe.getByte(ptr) != bytes[i])
                     return false;
 
                 ptr++;
@@ -550,19 +540,14 @@ public class GridUnsafeMemory {
                 for (int i = 0; i < words; i++) {
                     int step = i * addrSize + align;
 
-                    int word = UNSAFE.getInt(ptr);
+                    int word = GridUnsafe.getInt(ptr);
 
-                    int comp = 0;
-
-                    comp |= (0xffL & bytes[step + 3]) << 24;
-                    comp |= (0xffL & bytes[step + 2]) << 16;
-                    comp |= (0xffL & bytes[step + 1]) << 8;
-                    comp |= (0xffL & bytes[step]);
+                    int comp = GridUnsafe.getInt(bytes, GridUnsafe.BYTE_ARR_OFF + step);
 
                     if (word != comp)
                         return false;
 
-                    ptr += ADDR_SIZE;
+                    ptr += GridUnsafe.ADDR_SIZE;
                 }
 
                 break;
@@ -571,23 +556,14 @@ public class GridUnsafeMemory {
                 for (int i = 0; i < words; i++) {
                     int step = i * addrSize + align;
 
-                    long word = UNSAFE.getLong(ptr);
-
-                    long comp = 0;
+                    long word = GridUnsafe.getLong(ptr);
 
-                    comp |= (0xffL & bytes[step + 7]) << 56;
-                    comp |= (0xffL & bytes[step + 6]) << 48;
-                    comp |= (0xffL & bytes[step + 5]) << 40;
-                    comp |= (0xffL & bytes[step + 4]) << 32;
-                    comp |= (0xffL & bytes[step + 3]) << 24;
-                    comp |= (0xffL & bytes[step + 2]) << 16;
-                    comp |= (0xffL & bytes[step + 1]) << 8;
-                    comp |= (0xffL & bytes[step]);
+                    long comp = GridUnsafe.getLong(bytes, GridUnsafe.BYTE_ARR_OFF + step);
 
                     if (word != comp)
                         return false;
 
-                    ptr += ADDR_SIZE;
+                    ptr += GridUnsafe.ADDR_SIZE;
                 }
 
                 break;
@@ -596,7 +572,7 @@ public class GridUnsafeMemory {
         if (left != 0) {
             // Compare left overs byte by byte.
             for (int i = 0; i < left; i++)
-                if (UNSAFE.getByte(ptr + i) != bytes[i + align + words * ADDR_SIZE])
+                if (GridUnsafe.getByte(ptr + i) != bytes[i + align + words * GridUnsafe.ADDR_SIZE])
                     return false;
         }
 
@@ -618,7 +594,7 @@ public class GridUnsafeMemory {
      * @return The same array as passed in one.
      */
     public byte[] readBytes(long ptr, byte[] arr) {
-        UNSAFE.copyMemory(null, ptr, arr, BYTE_ARR_OFF, arr.length);
+        GridUnsafe.copyMemory(null, ptr, arr, GridUnsafe.BYTE_ARR_OFF, arr.length);
 
         return arr;
     }
@@ -631,7 +607,7 @@ public class GridUnsafeMemory {
      * @return The same array as passed in one.
      */
     public byte[] readBytes(long ptr, byte[] arr, int off, int len) {
-        UNSAFE.copyMemory(null, ptr, arr, BYTE_ARR_OFF + off, len);
+        GridUnsafe.copyMemory(null, ptr, arr, GridUnsafe.BYTE_ARR_OFF + off, len);
 
         return arr;
     }
@@ -643,7 +619,7 @@ public class GridUnsafeMemory {
      * @param arr Array.
      */
     public void writeBytes(long ptr, byte[] arr) {
-        UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+        GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr, arr.length);
     }
 
     /**
@@ -655,7 +631,7 @@ public class GridUnsafeMemory {
      * @param len Length.
      */
     public void writeBytes(long ptr, byte[] arr, int off, int len) {
-        UNSAFE.copyMemory(arr, BYTE_ARR_OFF + off, null, ptr, len);
+        GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF + off, null, ptr, len);
     }
 
     /**
@@ -666,7 +642,7 @@ public class GridUnsafeMemory {
      * @param len Length in bytes.
      */
     public void copyMemory(long srcPtr, long destPtr, long len) {
-        UNSAFE.copyMemory(srcPtr, destPtr, len);
+        GridUnsafe.copyMemory(srcPtr, destPtr, len);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
index a4f4cdc..c5be139 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
@@ -47,7 +47,6 @@ import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.MarshallerContext;
 import org.apache.ignite.marshaller.MarshallerExclusions;
-import sun.misc.Unsafe;
 
 import static java.lang.reflect.Modifier.isFinal;
 import static java.lang.reflect.Modifier.isPrivate;
@@ -92,9 +91,6 @@ import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.co
  * Class descriptor.
  */
 class OptimizedClassDescriptor {
-    /** Unsafe. */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
     /** Class. */
     private final Class<?> cls;
 
@@ -273,7 +269,7 @@ class OptimizedClassDescriptor {
                 type = PROPS;
 
                 try {
-                    dfltsFieldOff = UNSAFE.objectFieldOffset(Properties.class.getDeclaredField("defaults"));
+                    dfltsFieldOff = GridUnsafe.objectFieldOffset(Properties.class.getDeclaredField("defaults"));
                 }
                 catch (NoSuchFieldException e) {
                     throw new IOException(e);
@@ -285,7 +281,7 @@ class OptimizedClassDescriptor {
                 type = HASH_MAP;
 
                 try {
-                    loadFactorFieldOff = UNSAFE.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
+                    loadFactorFieldOff = GridUnsafe.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
                 }
                 catch (NoSuchFieldException e) {
                     throw new IOException(e);
@@ -295,7 +291,7 @@ class OptimizedClassDescriptor {
                 type = HASH_SET;
 
                 try {
-                    loadFactorFieldOff = UNSAFE.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
+                    loadFactorFieldOff = GridUnsafe.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
                 }
                 catch (NoSuchFieldException e) {
                     throw new IOException(e);
@@ -307,8 +303,10 @@ class OptimizedClassDescriptor {
                 type = LINKED_HASH_MAP;
 
                 try {
-                    loadFactorFieldOff = UNSAFE.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
-                    accessOrderFieldOff = UNSAFE.objectFieldOffset(LinkedHashMap.class.getDeclaredField("accessOrder"));
+                    loadFactorFieldOff =
+                        GridUnsafe.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
+                    accessOrderFieldOff =
+                        GridUnsafe.objectFieldOffset(LinkedHashMap.class.getDeclaredField("accessOrder"));
                 }
                 catch (NoSuchFieldException e) {
                     throw new IOException(e);
@@ -318,7 +316,7 @@ class OptimizedClassDescriptor {
                 type = LINKED_HASH_SET;
 
                 try {
-                    loadFactorFieldOff = UNSAFE.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
+                    loadFactorFieldOff = GridUnsafe.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
                 }
                 catch (NoSuchFieldException e) {
                     throw new IOException(e);
@@ -472,7 +470,7 @@ class OptimizedClassDescriptor {
 
                                         fieldInfo = new FieldInfo(f,
                                             serField.getName(),
-                                            UNSAFE.objectFieldOffset(f),
+                                            GridUnsafe.objectFieldOffset(f),
                                             fieldType(serField.getType()));
                                     }
 
@@ -496,7 +494,7 @@ class OptimizedClassDescriptor {
 
                                 if (!isStatic(mod) && !isTransient(mod)) {
                                     FieldInfo fieldInfo = new FieldInfo(f, f.getName(),
-                                        UNSAFE.objectFieldOffset(f), fieldType(f.getType()));
+                                        GridUnsafe.objectFieldOffset(f), fieldType(f.getType()));
 
                                     clsFields.add(fieldInfo);
                                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
index b2c98b2..b3caca2 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
@@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentMap;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.AbstractMarshaller;
 import org.jetbrains.annotations.Nullable;
@@ -274,9 +273,7 @@ public class OptimizedMarshaller extends AbstractMarshaller {
     @SuppressWarnings({"TypeParameterExtendsFinalClass", "ErrorNotRethrown"})
     public static boolean available() {
         try {
-            Unsafe unsafe = GridUnsafe.unsafe();
-
-            Class<? extends Unsafe> unsafeCls = unsafe.getClass();
+            Class<? extends Unsafe> unsafeCls = Unsafe.class;
 
             unsafeCls.getMethod("allocateInstance", Class.class);
             unsafeCls.getMethod("copyMemory", Object.class, long.class, Object.class, long.class, long.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
index da92b90..fa6f962 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
@@ -34,16 +34,12 @@ import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.marshaller.MarshallerContext;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
-import sun.misc.Unsafe;
 
 /**
  * Miscellaneous utility methods to facilitate {@link OptimizedMarshaller}.
  */
 class OptimizedMarshallerUtils {
     /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
     static final long HASH_SET_MAP_OFF;
 
     /** */
@@ -158,12 +154,12 @@ class OptimizedMarshallerUtils {
         long mapOff;
 
         try {
-            mapOff = UNSAFE.objectFieldOffset(HashSet.class.getDeclaredField("map"));
+            mapOff = GridUnsafe.objectFieldOffset(HashSet.class.getDeclaredField("map"));
         }
         catch (NoSuchFieldException e) {
             try {
                 // Workaround for legacy IBM JRE.
-                mapOff = UNSAFE.objectFieldOffset(HashSet.class.getDeclaredField("backingMap"));
+                mapOff = GridUnsafe.objectFieldOffset(HashSet.class.getDeclaredField("backingMap"));
             }
             catch (NoSuchFieldException e2) {
                 throw new IgniteException("Initialization failure.", e2);
@@ -358,7 +354,7 @@ class OptimizedMarshallerUtils {
      * @return Byte value.
      */
     static byte getByte(Object obj, long off) {
-        return UNSAFE.getByte(obj, off);
+        return GridUnsafe.getByteField(obj, off);
     }
 
     /**
@@ -369,7 +365,7 @@ class OptimizedMarshallerUtils {
      * @param val Value.
      */
     static void setByte(Object obj, long off, byte val) {
-        UNSAFE.putByte(obj, off, val);
+        GridUnsafe.putByteField(obj, off, val);
     }
 
     /**
@@ -380,7 +376,7 @@ class OptimizedMarshallerUtils {
      * @return Short value.
      */
     static short getShort(Object obj, long off) {
-        return UNSAFE.getShort(obj, off);
+        return GridUnsafe.getShortField(obj, off);
     }
 
     /**
@@ -391,7 +387,7 @@ class OptimizedMarshallerUtils {
      * @param val Value.
      */
     static void setShort(Object obj, long off, short val) {
-        UNSAFE.putShort(obj, off, val);
+        GridUnsafe.putShortField(obj, off, val);
     }
 
     /**
@@ -402,7 +398,7 @@ class OptimizedMarshallerUtils {
      * @return Integer value.
      */
     static int getInt(Object obj, long off) {
-        return UNSAFE.getInt(obj, off);
+        return GridUnsafe.getIntField(obj, off);
     }
 
     /**
@@ -413,7 +409,7 @@ class OptimizedMarshallerUtils {
      * @param val Value.
      */
     static void setInt(Object obj, long off, int val) {
-        UNSAFE.putInt(obj, off, val);
+        GridUnsafe.putIntField(obj, off, val);
     }
 
     /**
@@ -424,7 +420,7 @@ class OptimizedMarshallerUtils {
      * @return Long value.
      */
     static long getLong(Object obj, long off) {
-        return UNSAFE.getLong(obj, off);
+        return GridUnsafe.getLongField(obj, off);
     }
 
     /**
@@ -435,7 +431,7 @@ class OptimizedMarshallerUtils {
      * @param val Value.
      */
     static void setLong(Object obj, long off, long val) {
-        UNSAFE.putLong(obj, off, val);
+        GridUnsafe.putLongField(obj, off, val);
     }
 
     /**
@@ -446,7 +442,7 @@ class OptimizedMarshallerUtils {
      * @return Float value.
      */
     static float getFloat(Object obj, long off) {
-        return UNSAFE.getFloat(obj, off);
+        return GridUnsafe.getFloatField(obj, off);
     }
 
     /**
@@ -457,7 +453,7 @@ class OptimizedMarshallerUtils {
      * @param val Value.
      */
     static void setFloat(Object obj, long off, float val) {
-        UNSAFE.putFloat(obj, off, val);
+        GridUnsafe.putFloatField(obj, off, val);
     }
 
     /**
@@ -468,7 +464,7 @@ class OptimizedMarshallerUtils {
      * @return Double value.
      */
     static double getDouble(Object obj, long off) {
-        return UNSAFE.getDouble(obj, off);
+        return GridUnsafe.getDoubleField(obj, off);
     }
 
     /**
@@ -479,7 +475,7 @@ class OptimizedMarshallerUtils {
      * @param val Value.
      */
     static void setDouble(Object obj, long off, double val) {
-        UNSAFE.putDouble(obj, off, val);
+        GridUnsafe.putDoubleField(obj, off, val);
     }
 
     /**
@@ -490,7 +486,7 @@ class OptimizedMarshallerUtils {
      * @return Char value.
      */
     static char getChar(Object obj, long off) {
-        return UNSAFE.getChar(obj, off);
+        return GridUnsafe.getCharField(obj, off);
     }
 
     /**
@@ -501,7 +497,7 @@ class OptimizedMarshallerUtils {
      * @param val Value.
      */
     static void setChar(Object obj, long off, char val) {
-        UNSAFE.putChar(obj, off, val);
+        GridUnsafe.putCharField(obj, off, val);
     }
 
     /**
@@ -512,7 +508,7 @@ class OptimizedMarshallerUtils {
      * @return Boolean value.
      */
     static boolean getBoolean(Object obj, long off) {
-        return UNSAFE.getBoolean(obj, off);
+        return GridUnsafe.getBooleanField(obj, off);
     }
 
     /**
@@ -523,7 +519,7 @@ class OptimizedMarshallerUtils {
      * @param val Value.
      */
     static void setBoolean(Object obj, long off, boolean val) {
-        UNSAFE.putBoolean(obj, off, val);
+        GridUnsafe.putBooleanField(obj, off, val);
     }
 
     /**
@@ -534,7 +530,7 @@ class OptimizedMarshallerUtils {
      * @return Value.
      */
     static Object getObject(Object obj, long off) {
-        return UNSAFE.getObject(obj, off);
+        return GridUnsafe.getObjectField(obj, off);
     }
 
     /**
@@ -545,6 +541,6 @@ class OptimizedMarshallerUtils {
      * @param val Value.
      */
     static void setObject(Object obj, long off, Object val) {
-        UNSAFE.putObject(obj, off, val);
+        GridUnsafe.putObjectField(obj, off, val);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
index ce9ee0b..988a777 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
@@ -45,7 +45,6 @@ import org.apache.ignite.internal.util.io.GridDataInput;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.MarshallerContext;
-import sun.misc.Unsafe;
 
 import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.ARRAY_LIST;
 import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.BOOLEAN;
@@ -98,9 +97,6 @@ import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.se
  * Optimized object input stream.
  */
 class OptimizedObjectInputStream extends ObjectInputStream {
-    /** Unsafe. */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
     /** Dummy object for HashSet. */
     private static final Object DUMMY = new Object();
 
@@ -544,7 +540,7 @@ class OptimizedObjectInputStream extends ObjectInputStream {
         Object obj;
 
         try {
-            obj = UNSAFE.allocateInstance(cls);
+            obj = GridUnsafe.allocateInstance(cls);
         }
         catch (InstantiationException e) {
             throw new IOException(e);
@@ -642,7 +638,7 @@ class OptimizedObjectInputStream extends ObjectInputStream {
     @SuppressWarnings("unchecked")
     HashSet<?> readHashSet(long mapFieldOff) throws ClassNotFoundException, IOException {
         try {
-            HashSet<Object> set = (HashSet<Object>)UNSAFE.allocateInstance(HashSet.class);
+            HashSet<Object> set = (HashSet<Object>)GridUnsafe.allocateInstance(HashSet.class);
 
             handles.assign(set);
 
@@ -714,7 +710,7 @@ class OptimizedObjectInputStream extends ObjectInputStream {
     @SuppressWarnings("unchecked")
     LinkedHashSet<?> readLinkedHashSet(long mapFieldOff) throws ClassNotFoundException, IOException {
         try {
-            LinkedHashSet<Object> set = (LinkedHashSet<Object>)UNSAFE.allocateInstance(LinkedHashSet.class);
+            LinkedHashSet<Object> set = (LinkedHashSet<Object>)GridUnsafe.allocateInstance(LinkedHashSet.class);
 
             handles.assign(set);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java b/modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java
index de09e06..983afde 100644
--- a/modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java
@@ -40,7 +40,6 @@ import static junit.framework.Assert.fail;
  * IO test utilities.
  */
 public final class GridTestIoUtils {
-
     /**
      * Serializes a given object into byte array.
      *
@@ -187,6 +186,122 @@ public final class GridTestIoUtils {
             assertEquals(expSize.longValue(), pos);
     }
 
+    /**
+     * Gets short value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     */
+    public static short getShortByByteLE(byte[] arr) {
+        return getShortByByteLE(arr, 0);
+    }
+
+    /**
+     * Gets short value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     */
+    public static short getShortByByteLE(byte[] arr, int off) {
+        return (short)((arr[off] & 0xff) | arr[off + 1] << 8);
+    }
+
+    /**
+     * Gets char value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     */
+    public static char getCharByByteLE(byte[] arr) {
+        return getCharByByteLE(arr, 0);
+    }
+
+    /**
+     * Gets char value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     */
+    public static char getCharByByteLE(byte[] arr, int off) {
+        return (char)((arr[off] & 0xff) | arr[off + 1] << 8);
+    }
+
+    /**
+     * Gets integer value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     */
+    public static int getIntByByteLE(byte[] arr) {
+        return getIntByByteLE(arr, 0);
+    }
+
+    /**
+     * Gets integer value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     */
+    public static int getIntByByteLE(byte[] arr, int off) {
+        return ((int)arr[off] & 0xff) | ((int)arr[off + 1] & 0xff) << 8 |
+            ((int)arr[off + 2] & 0xff) << 16 | ((int)arr[off + 3] & 0xff) << 24;
+    }
+
+    /**
+     * Gets long value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     */
+    public static long getLongByByteLE(byte[] arr) {
+        return getLongByByteLE(arr, 0);
+    }
+
+    /**
+     * Gets long value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     */
+    public static long getLongByByteLE(byte[] arr, int off) {
+        return ((long)arr[off] & 0xff) | ((long)arr[off + 1] & 0xff) << 8 | ((long)arr[off + 2] & 0xff) << 16 |
+            ((long)arr[off + 3] & 0xff) << 24 | ((long)arr[off + 4] & 0xff) << 32 | ((long)arr[off + 5] & 0xff) << 40 |
+            ((long)arr[off + 6] & 0xff) << 48 | ((long)arr[off + 7] & 0xff) << 56;
+    }
+
+    /**
+     * Gets float value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     */
+    public static float getFloatByByteLE(byte[] arr) {
+        return getFloatByByteLE(arr, 0);
+    }
+
+    /**
+     * Gets float value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     */
+    public static float getFloatByByteLE(byte[] arr, int off) {
+        return Float.intBitsToFloat(getIntByByteLE(arr, off));
+    }
+
+    /**
+     * Gets double value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     */
+    public static double getDoubleByByteLE(byte[] arr) {
+        return getDoubleByByteLE(arr, 0);
+    }
+
+    /**
+     * Gets double value from byte array assuming that value stored in little-endian byte order.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     */
+    public static double getDoubleByByteLE(byte[] arr, int off) {
+        return Double.longBitsToDouble(getLongByByteLE(arr, off));
+    }
 
     /**
      * Closes resource.

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
index 0515685..a75023f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
@@ -116,7 +116,7 @@ public class GridAffinitySelfTest extends GridCommonAbstractTest {
         return F.view(Arrays.asList(g.configuration().getCacheConfiguration()), new IgnitePredicate<CacheConfiguration>() {
             @Override public boolean apply(CacheConfiguration c) {
                 return !CU.MARSH_CACHE_NAME.equals(c.getName()) && !CU.UTILITY_CACHE_NAME.equals(c.getName()) &&
-                    !CU.ATOMICS_CACHE_NAME.equals(c.getName());
+                    !CU.ATOMICS_CACHE_NAME.equals(c.getName()) && !CU.SYS_CACHE_HADOOP_MR.equals(c.getName());
             }
         });
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java
index 87cc527..1546252 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java
@@ -19,18 +19,11 @@ package org.apache.ignite.internal.binary;
 
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.eclipse.jetty.util.ConcurrentHashSet;
-import sun.misc.Unsafe;
 
 /**
  * Field tests for heap-based binaries.
  */
 public class BinaryFieldsOffheapSelfTest extends BinaryFieldsAbstractSelfTest {
-    /** Unsafe instance. */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** Byte array offset for unsafe mechanics. */
-    protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
     /** Allocated unsafe pointer. */
     private final ConcurrentHashSet<Long> ptrs = new ConcurrentHashSet<>();
 
@@ -40,7 +33,7 @@ public class BinaryFieldsOffheapSelfTest extends BinaryFieldsAbstractSelfTest {
 
         // Cleanup allocated objects.
         for (Long ptr : ptrs)
-            UNSAFE.freeMemory(ptr);
+            GridUnsafe.freeMemory(ptr);
 
         ptrs.clear();
     }
@@ -49,11 +42,11 @@ public class BinaryFieldsOffheapSelfTest extends BinaryFieldsAbstractSelfTest {
     @Override protected BinaryObjectExImpl toBinary(BinaryMarshaller marsh, Object obj) throws Exception {
         byte[] arr = marsh.marshal(obj);
 
-        long ptr = UNSAFE.allocateMemory(arr.length);
+        long ptr = GridUnsafe.allocateMemory(arr.length);
 
         ptrs.add(ptr);
 
-        UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+        GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr, arr.length);
 
         return new BinaryObjectOffheapImpl(binaryContext(marsh), ptr, 0, arr.length);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java
index fe9ba17..796c027 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java
@@ -19,18 +19,11 @@ package org.apache.ignite.internal.binary;
 
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.eclipse.jetty.util.ConcurrentHashSet;
-import sun.misc.Unsafe;
 
 /**
  * Compact offsets tests for offheap binary objects.
  */
 public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstractSelfTest {
-    /** Unsafe instance. */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** Byte array offset for unsafe mechanics. */
-    protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
     /** Allocated unsafe pointer. */
     private final ConcurrentHashSet<Long> ptrs = new ConcurrentHashSet<>();
 
@@ -40,7 +33,7 @@ public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstr
 
         // Cleanup allocated objects.
         for (Long ptr : ptrs)
-            UNSAFE.freeMemory(ptr);
+            GridUnsafe.freeMemory(ptr);
 
         ptrs.clear();
     }
@@ -49,11 +42,11 @@ public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstr
     @Override protected BinaryObjectExImpl toBinary(BinaryMarshaller marsh, Object obj) throws Exception {
         byte[] arr = marsh.marshal(obj);
 
-        long ptr = UNSAFE.allocateMemory(arr.length);
+        long ptr = GridUnsafe.allocateMemory(arr.length);
 
         ptrs.add(ptr);
 
-        UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+        GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr, arr.length);
 
         return new BinaryObjectOffheapImpl(ctx, ptr, 0, arr.length);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
index fa0f9a7..37b908a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
@@ -88,7 +88,6 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
-import sun.misc.Unsafe;
 
 import static org.apache.ignite.internal.binary.streams.BinaryMemoryAllocator.INSTANCE;
 import static org.junit.Assert.assertArrayEquals;
@@ -99,12 +98,6 @@ import static org.junit.Assert.assertNotEquals;
  */
 @SuppressWarnings({"OverlyStrongTypeCast", "ArrayHashCode", "ConstantConditions"})
 public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
-    /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
-    protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
     /**
      * @throws Exception If failed.
      */
@@ -2378,13 +2371,13 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
             assertFalse(offheapObj2.equals(offheapObj));
         }
         finally {
-            UNSAFE.freeMemory(ptr);
+            GridUnsafe.freeMemory(ptr);
 
             if (ptr1 > 0)
-                UNSAFE.freeMemory(ptr1);
+                GridUnsafe.freeMemory(ptr1);
 
             if (ptr2 > 0)
-                UNSAFE.freeMemory(ptr2);
+                GridUnsafe.freeMemory(ptr2);
         }
     }
 
@@ -2975,9 +2968,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     private long copyOffheap(BinaryObjectImpl obj) {
         byte[] arr = obj.array();
 
-        long ptr = UNSAFE.allocateMemory(arr.length);
+        long ptr = GridUnsafe.allocateMemory(arr.length);
 
-        UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+        GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr, arr.length);
 
         return ptr;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
index 059703e..990c928 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
@@ -46,7 +46,8 @@ import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import sun.misc.Unsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
 
 /**
  * Binary builder test.
@@ -54,12 +55,6 @@ import sun.misc.Unsafe;
 @SuppressWarnings("ResultOfMethodCallIgnored")
 public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstractTest {
     /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
-    protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** */
     private static IgniteConfiguration cfg;
 
     /** {@inheritDoc} */
@@ -766,16 +761,21 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
 
         byte[] arr = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).marshal(po);
 
-        long ptr = UNSAFE.allocateMemory(arr.length + 5);
+        long ptr = GridUnsafe.allocateMemory(arr.length + 5);
 
         try {
             long ptr0 = ptr;
 
-            UNSAFE.putBoolean(null, ptr0++, false);
+            GridUnsafe.putBoolean(null, ptr0++, false);
+
+            int len = arr.length;
 
-            UNSAFE.putInt(ptr0, arr.length);
+            if (BIG_ENDIAN)
+                GridUnsafe.putIntLE(ptr0, len);
+            else
+                GridUnsafe.putInt(ptr0, len);
 
-            UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr0 + 4, arr.length);
+            GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr0 + 4, arr.length);
 
             BinaryObject offheapObj = (BinaryObject)
                 ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).unmarshal(ptr, false);
@@ -801,7 +801,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
             assertEquals(offheapObj, po);
         }
         finally {
-            UNSAFE.freeMemory(ptr);
+            GridUnsafe.freeMemory(ptr);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/mutabletest/GridBinaryTestClasses.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/mutabletest/GridBinaryTestClasses.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/mutabletest/GridBinaryTestClasses.java
index ae615b1..5ddb87d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/mutabletest/GridBinaryTestClasses.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/mutabletest/GridBinaryTestClasses.java
@@ -31,14 +31,13 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.UUID;
-
 import org.apache.ignite.binary.BinaryMapFactory;
+import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.binary.BinaryReader;
 import org.apache.ignite.binary.BinaryWriter;
 import org.apache.ignite.binary.Binarylizable;
 import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.binary.BinaryObject;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java
new file mode 100644
index 0000000..c68a886
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java
@@ -0,0 +1,464 @@
+/*
+ * 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.binary.streams;
+
+import java.util.Random;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Assert;
+
+import static org.apache.ignite.GridTestIoUtils.getCharByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getDoubleByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getFloatByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getIntByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getLongByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getShortByByteLE;
+
+/**
+ * Binary input/output streams byte order sanity tests.
+ */
+public abstract class AbstractBinaryStreamByteOrderSelfTest extends GridCommonAbstractTest {
+    /** Array length. */
+    protected static final int ARR_LEN = 16;
+
+    /** Rnd. */
+    private static final Random RND = new Random();
+
+    /** Out. */
+    protected BinaryAbstractOutputStream out;
+
+    /** In. */
+    protected BinaryAbstractInputStream in;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        init();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        out.close();
+    }
+
+    /**
+     * Initializes streams.
+     */
+    protected abstract void init();
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testShort() throws Exception {
+        short val = (short)RND.nextLong();
+
+        reset();
+
+        out.unsafeWriteShort(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readShort());
+
+        reset();
+
+        out.unsafeWriteShort(0, val);
+        out.shift(2);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readShortFast());
+
+        reset();
+
+        out.writeShortFast(val);
+        out.shift(2);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readShortPositioned(0));
+
+        reset();
+
+        out.writeShort(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readShortPositioned(0));
+
+        reset();
+
+        out.writeShort(0, val);
+        out.shift(2);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readShortPositioned(0));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testShortArray() throws Exception {
+        short[] arr = new short[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = (short)RND.nextLong();
+
+        out.writeShortArray(arr);
+
+        byte[] outArr = array();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getShortByByteLE(outArr, i * 2));
+
+        Assert.assertArrayEquals(arr, in.readShortArray(ARR_LEN));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testChar() throws Exception {
+        char val = (char)RND.nextLong();
+
+        reset();
+
+        out.unsafeWriteChar(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readChar());
+
+        reset();
+
+        out.writeCharFast(val);
+        out.shift(2);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readCharFast());
+
+        reset();
+
+        out.writeChar(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readChar());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCharArray() throws Exception {
+        char[] arr = new char[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = (char)RND.nextLong();
+
+        out.writeCharArray(arr);
+
+        byte[] outArr = array();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getCharByByteLE(outArr, i * 2));
+
+        Assert.assertArrayEquals(arr, in.readCharArray(ARR_LEN));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInt() throws Exception {
+        int val = RND.nextInt();
+
+        reset();
+
+        out.unsafeWriteInt(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readInt());
+
+        reset();
+
+        out.unsafeWriteInt(0, val);
+        out.shift(4);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readIntFast());
+
+        reset();
+
+        out.writeIntFast(val);
+        out.shift(4);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readIntPositioned(0));
+
+        reset();
+
+        out.writeInt(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readIntPositioned(0));
+
+        reset();
+
+        out.writeInt(0, val);
+        out.shift(4);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readIntPositioned(0));
+
+        reset();
+
+        out.writeIntArray(new int[] {val});
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readIntArray(1)[0]);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testIntArray() throws Exception {
+        int[] arr = new int[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextInt();
+
+        out.writeIntArray(arr);
+
+        byte[] outArr = array();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getIntByByteLE(outArr, i * 4));
+
+        Assert.assertArrayEquals(arr, in.readIntArray(ARR_LEN));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLong() throws Exception {
+        long val = RND.nextLong();
+
+        reset();
+
+        out.unsafeWriteLong(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readLong());
+
+        reset();
+
+        out.writeLongFast(val);
+        out.shift(8);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readLongFast());
+
+        reset();
+
+        out.writeLong(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readLong());
+
+        reset();
+
+        out.writeLongArray(new long[] {val});
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readLongArray(1)[0]);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLongArray() throws Exception {
+        long[] arr = new long[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextLong();
+
+        out.writeLongArray(arr);
+
+        byte[] outArr = array();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getLongByByteLE(outArr, i * 8));
+
+        Assert.assertArrayEquals(arr, in.readLongArray(ARR_LEN));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFloat() throws Exception {
+        float val = RND.nextFloat();
+
+        reset();
+
+        out.unsafeWriteFloat(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readFloat(), 0);
+
+        reset();
+
+        out.writeFloat(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readFloat(), 0);
+
+        reset();
+
+        out.writeFloatArray(new float[] {val});
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readFloatArray(1)[0], 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFloatArray() throws Exception {
+        float[] arr = new float[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextFloat();
+
+        out.writeFloatArray(arr);
+
+        byte[] outArr = array();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getFloatByByteLE(outArr, i * 4), 0);
+
+        Assert.assertArrayEquals(arr, in.readFloatArray(ARR_LEN), 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDouble() throws Exception {
+        double val = RND.nextDouble();
+
+        reset();
+
+        out.unsafeWriteDouble(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readDouble(), 0);
+
+        reset();
+
+        out.writeDouble(val);
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readDouble(), 0);
+
+        reset();
+
+        out.writeDoubleArray(new double[] {val});
+
+        checkValueLittleEndian(val);
+        assertEquals(val, in.readDoubleArray(1)[0], 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDoubleArray() throws Exception {
+        double[] arr = new double[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextDouble();
+
+        out.writeDoubleArray(arr);
+
+        byte[] outArr = array();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getDoubleByByteLE(outArr, i * 8), 0);
+
+        Assert.assertArrayEquals(arr, in.readDoubleArray(ARR_LEN), 0);
+    }
+
+    /**
+     *
+     */
+    private void reset() {
+        in.position(0);
+        out.position(0);
+    }
+
+    /**
+     *
+     */
+    private byte[] array() {
+        return out.array();
+    }
+
+    /**
+     * @param exp Expected.
+     */
+    private void checkValueLittleEndian(short exp) {
+        byte[] arr = array();
+
+        assertEquals(exp, getShortByByteLE(arr));
+    }
+
+    /**
+     * @param exp Expected.
+     */
+    private void checkValueLittleEndian(char exp) {
+        byte[] arr = array();
+
+        assertEquals(exp, getCharByByteLE(arr));
+    }
+
+    /**
+     * @param exp Expected.
+     */
+    private void checkValueLittleEndian(int exp) {
+        byte[] arr = array();
+
+        assertEquals(exp, getIntByByteLE(arr));
+    }
+
+    /**
+     * @param exp Expected.
+     */
+    private void checkValueLittleEndian(long exp) {
+        byte[] arr = array();
+
+        assertEquals(exp, getLongByByteLE(arr));
+    }
+
+    /**
+     * @param exp Expected.
+     */
+    private void checkValueLittleEndian(float exp) {
+        byte[] arr = array();
+
+        assertEquals(exp, getFloatByByteLE(arr), 0);
+    }
+
+    /**
+     * @param exp Expected.
+     */
+    private void checkValueLittleEndian(double exp) {
+        byte[] arr = array();
+
+        assertEquals(exp, getDoubleByByteLE(arr), 0);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryHeapStreamByteOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryHeapStreamByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryHeapStreamByteOrderSelfTest.java
new file mode 100644
index 0000000..4b86748
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryHeapStreamByteOrderSelfTest.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.binary.streams;
+
+/**
+ * Binary heap input/output stream byte order sanity tests.
+ */
+public class BinaryHeapStreamByteOrderSelfTest extends AbstractBinaryStreamByteOrderSelfTest {
+    /** {@inheritDoc} */
+    @Override protected void init() {
+        out = new BinaryHeapOutputStream(ARR_LEN * 8);
+        in = new BinaryHeapInputStream(out.array());
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryOffheapStreamByteOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryOffheapStreamByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryOffheapStreamByteOrderSelfTest.java
new file mode 100644
index 0000000..6e9c41a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryOffheapStreamByteOrderSelfTest.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.binary.streams;
+
+/**
+ * Binary offheap input/output stream byte order sanity tests.
+ */
+public class BinaryOffheapStreamByteOrderSelfTest extends AbstractBinaryStreamByteOrderSelfTest {
+    /** {@inheritDoc} */
+    @Override protected void init() {
+        int cap = ARR_LEN * 8;
+
+        out = new BinaryOffheapOutputStream(cap);
+        in = new BinaryOffheapInputStream(((BinaryOffheapOutputStream)out).pointer(), cap);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java
new file mode 100644
index 0000000..d96f796
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java
@@ -0,0 +1,244 @@
+/*
+ * 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.direct.stream.v2;
+
+import java.nio.ByteBuffer;
+import java.util.Random;
+import junit.framework.TestCase;
+import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.GridTestIoUtils.getCharByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getDoubleByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getFloatByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getIntByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getLongByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getShortByByteLE;
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * {@link DirectByteBufferStreamImplV2} byte order sanity tests.
+ */
+public class DirectByteBufferStreamImplV2ByteOrderSelfTest extends TestCase {
+    /** Array length. */
+    private static final int ARR_LEN = 16;
+
+    /** Length bytes. */
+    private static final int LEN_BYTES = 1;
+
+    /** Rnd. */
+    private static final Random RND = new Random();
+
+    /** Stream. */
+    private DirectByteBufferStream stream;
+
+    /** Buff. */
+    private ByteBuffer buff;
+
+    /** Array. */
+    private byte[] outArr;
+
+    /** {@inheritDoc} */
+    @Override public void setUp() throws Exception {
+        super.setUp();
+
+        stream = new DirectByteBufferStreamImplV2(new MessageFactory() {
+            @Nullable @Override public Message create(byte type) {
+                return null;
+            }
+        });
+
+        outArr = new byte[ARR_LEN * 8 + LEN_BYTES];
+
+        buff = ByteBuffer.wrap(outArr);
+
+        stream.setBuffer(buff);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testShort() throws Exception {
+        short val = (short)RND.nextLong();
+
+        stream.writeShort(val);
+
+        buff.rewind();
+
+        assertEquals(val, getShortByByteLE(outArr));
+        assertEquals(val, stream.readShort());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testShortArray() throws Exception {
+        short[] arr = new short[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = (short)RND.nextLong();
+
+        stream.writeShortArray(arr);
+
+        buff.rewind();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getShortByByteLE(outArr, i * 2 + LEN_BYTES));
+
+        assertArrayEquals(arr, stream.readShortArray());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testChar() throws Exception {
+        char val = (char)RND.nextLong();
+
+        stream.writeChar(val);
+
+        buff.rewind();
+
+        assertEquals(val, getCharByByteLE(outArr));
+        assertEquals(val, stream.readChar());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCharArray() throws Exception {
+        char[] arr = new char[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = (char)RND.nextLong();
+
+        stream.writeCharArray(arr);
+
+        buff.rewind();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getCharByByteLE(outArr, i * 2 + LEN_BYTES));
+
+        assertArrayEquals(arr, stream.readCharArray());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testIntArray() throws Exception {
+        int[] arr = new int[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextInt();
+
+        stream.writeIntArray(arr);
+
+        buff.rewind();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getIntByByteLE(outArr, i * 4 + LEN_BYTES));
+
+        assertArrayEquals(arr, stream.readIntArray());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLongArray() throws Exception {
+        long[] arr = new long[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextLong();
+
+        stream.writeLongArray(arr);
+
+        buff.rewind();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getLongByByteLE(outArr, i * 8 + LEN_BYTES));
+
+        assertArrayEquals(arr, stream.readLongArray());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFloat() throws Exception {
+        float val = RND.nextFloat();
+
+        stream.writeFloat(val);
+
+        buff.rewind();
+
+        assertEquals(val, getFloatByByteLE(outArr), 0);
+        assertEquals(val, stream.readFloat(), 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFloatArray() throws Exception {
+        float[] arr = new float[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextFloat();
+
+        stream.writeFloatArray(arr);
+
+        buff.rewind();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getFloatByByteLE(outArr, i * 4 + LEN_BYTES), 0);
+
+        assertArrayEquals(arr, stream.readFloatArray(), 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDouble() throws Exception {
+        double val = RND.nextDouble();
+
+        stream.writeDouble(val);
+
+        buff.rewind();
+
+        assertEquals(val, getDoubleByByteLE(outArr), 0);
+        assertEquals(val, stream.readDouble(), 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDoubleArray() throws Exception {
+        double[] arr = new double[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextDouble();
+
+        stream.writeDoubleArray(arr);
+
+        buff.rewind();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getDoubleByByteLE(outArr, i * 8 + LEN_BYTES), 0);
+
+        assertArrayEquals(arr, stream.readDoubleArray(), 0);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java
index 5bb6794..4887b79 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java
@@ -27,7 +27,6 @@ import javax.cache.Cache;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -165,17 +164,11 @@ public class GridCacheConcurrentMapSelfTest extends GridCommonAbstractTest {
 
                 Iterator<Cache.Entry<Integer, String>> it = null;
 
-                boolean created = false;
-
                 for (int i = start; i < start + cnt; i++) {
                     int key = i % cnt;
 
-                    if (!created && i >= start + tid * 100) {
-                        if (it == null)
-                            it = c.iterator();
-
-                        created = true;
-                    }
+                    if (it == null && i >= start + tid * 100)
+                        it = c.iterator();
 
                     c.put(key, Integer.toString(key));
 
@@ -342,7 +335,7 @@ public class GridCacheConcurrentMapSelfTest extends GridCommonAbstractTest {
 
                     return null;
                 }
-            }, Runtime.getRuntime().availableProcessors());
+            }, Math.min(16, Runtime.getRuntime().availableProcessors()));
 
             for (int r = 0; r < 10; r++) {
                 System.gc();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
index 5de3d0f..1c65f9b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
@@ -228,6 +228,12 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
             qryClnCache.put(keys.get(0), 100);
         }
 
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                return lsnr.evts.size() == 1;
+            }
+        }, 5000);
+
         assertEquals(lsnr.evts.size(), 1);
     }
 


[28/28] ignite git commit: IGNITE-2508: Further fixes.

Posted by vo...@apache.org.
IGNITE-2508: Further fixes.


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

Branch: refs/heads/ignite-2508
Commit: dbb014c8eb56bc682aeafd7deeb099d5d398a9f2
Parents: 566598e
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Feb 3 15:27:16 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 3 15:27:16 2016 +0300

----------------------------------------------------------------------
 .../affinity/GridAffinityAssignmentCache.java   |  1 -
 .../cache/GridCacheAffinityManager.java         | 36 ++++++++++----------
 2 files changed, 18 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dbb014c8/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index 0bc503c..26e4d98 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.affinity;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;

http://git-wip-us.apache.org/repos/asf/ignite/blob/dbb014c8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index e3a5439..21975da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -156,24 +156,6 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
     }
 
     /**
-     * Get affinity assignment for the given topology version.
-     *
-     * @param topVer Toplogy version.
-     * @return Affinity affignment.
-     */
-    public GridAffinityAssignment assignment(AffinityTopologyVersion topVer) {
-        if (cctx.isLocal())
-            topVer = new AffinityTopologyVersion(1);
-
-        GridAffinityAssignmentCache aff0 = aff;
-
-        if (aff0 == null)
-            throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + cctx.name());
-
-        return aff0.cachedAffinity(topVer);
-    }
-
-    /**
      * @param topVer Topology version.
      * @return Affinity assignments.
      */
@@ -266,6 +248,24 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
     }
 
     /**
+     * Get affinity assignment for the given topology version.
+     *
+     * @param topVer Toplogy version.
+     * @return Affinity affignment.
+     */
+    public GridAffinityAssignment assignment(AffinityTopologyVersion topVer) {
+        if (cctx.isLocal())
+            topVer = new AffinityTopologyVersion(1);
+
+        GridAffinityAssignmentCache aff0 = aff;
+
+        if (aff0 == null)
+            throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + cctx.name());
+
+        return aff0.cachedAffinity(topVer);
+    }
+
+    /**
      * @param key Key to check.
      * @param topVer Topology version.
      * @return Primary node for given key.


[19/28] ignite git commit: ignite-2080 Data alignment issues with Unsafe

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
index 1a4c4bb..7958793 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
@@ -38,41 +38,22 @@ import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemTy
 import org.apache.ignite.plugin.extensions.communication.MessageFactory;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
-import sun.misc.Unsafe;
 import sun.nio.ch.DirectBuffer;
 
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+import static org.apache.ignite.internal.util.GridUnsafe.BYTE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.CHAR_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.DOUBLE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.FLOAT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.INT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.LONG_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.SHORT_ARR_OFF;
+
 /**
  * Direct marshalling I/O stream (version 2).
  */
 public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
-    private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** */
-    private static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
-
-    /** */
-    private static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
-
-    /** */
-    private static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
-
-    /** */
-    private static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
-
-    /** */
-    private static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
-
-    /** */
-    private static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
-    /** */
-    private static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
-
-    /** */
     private static final byte[] BYTE_ARR_EMPTY = new byte[0];
 
     /** */
@@ -343,7 +324,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putByte(heapArr, baseOff + pos, val);
+            GridUnsafe.putByte(heapArr, baseOff + pos, val);
 
             buf.position(pos + 1);
         }
@@ -356,7 +337,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putShort(heapArr, baseOff + pos, val);
+            long off = baseOff + pos;
+
+            if (BIG_ENDIAN)
+                GridUnsafe.putShortLE(heapArr, off, val);
+            else
+                GridUnsafe.putShort(heapArr, off, val);
 
             buf.position(pos + 2);
         }
@@ -377,12 +363,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
             while ((val & 0xFFFF_FF80) != 0) {
                 byte b = (byte)(val | 0x80);
 
-                UNSAFE.putByte(heapArr, baseOff + pos++, b);
+                GridUnsafe.putByte(heapArr, baseOff + pos++, b);
 
                 val >>>= 7;
             }
 
-            UNSAFE.putByte(heapArr, baseOff + pos++, (byte)val);
+            GridUnsafe.putByte(heapArr, baseOff + pos++, (byte)val);
 
             buf.position(pos);
         }
@@ -403,12 +389,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
             while ((val & 0xFFFF_FFFF_FFFF_FF80L) != 0) {
                 byte b = (byte)(val | 0x80);
 
-                UNSAFE.putByte(heapArr, baseOff + pos++, b);
+                GridUnsafe.putByte(heapArr, baseOff + pos++, b);
 
                 val >>>= 7;
             }
 
-            UNSAFE.putByte(heapArr, baseOff + pos++, (byte)val);
+            GridUnsafe.putByte(heapArr, baseOff + pos++, (byte)val);
 
             buf.position(pos);
         }
@@ -421,7 +407,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putFloat(heapArr, baseOff + pos, val);
+            long off = baseOff + pos;
+
+            if (BIG_ENDIAN)
+                GridUnsafe.putFloatLE(heapArr, off, val);
+            else
+                GridUnsafe.putFloat(heapArr, off, val);
 
             buf.position(pos + 4);
         }
@@ -434,7 +425,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putDouble(heapArr, baseOff + pos, val);
+            long off = baseOff + pos;
+
+            if (BIG_ENDIAN)
+                GridUnsafe.putDoubleLE(heapArr, off, val);
+            else
+                GridUnsafe.putDouble(heapArr, off, val);
 
             buf.position(pos + 8);
         }
@@ -447,7 +443,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putChar(heapArr, baseOff + pos, val);
+            long off = baseOff + pos;
+
+            if (BIG_ENDIAN)
+                GridUnsafe.putCharLE(heapArr, off, val);
+            else
+                GridUnsafe.putChar(heapArr, off, val);
 
             buf.position(pos + 2);
         }
@@ -460,7 +461,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putBoolean(heapArr, baseOff + pos, val);
+            GridUnsafe.putBoolean(heapArr, baseOff + pos, val);
 
             buf.position(pos + 1);
         }
@@ -485,7 +486,10 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeShortArray(short[] val) {
         if (val != null)
-            lastFinished = writeArray(val, SHORT_ARR_OFF, val.length, val.length << 1);
+            if (BIG_ENDIAN)
+                lastFinished = writeArrayLE(val, SHORT_ARR_OFF, val.length, 2, 1);
+            else
+                lastFinished = writeArray(val, SHORT_ARR_OFF, val.length, val.length << 1);
         else
             writeInt(-1);
     }
@@ -493,7 +497,10 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeIntArray(int[] val) {
         if (val != null)
-            lastFinished = writeArray(val, INT_ARR_OFF, val.length, val.length << 2);
+            if (BIG_ENDIAN)
+                lastFinished = writeArrayLE(val, INT_ARR_OFF, val.length, 4, 2);
+            else
+                lastFinished = writeArray(val, INT_ARR_OFF, val.length, val.length << 2);
         else
             writeInt(-1);
     }
@@ -501,7 +508,10 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeLongArray(long[] val) {
         if (val != null)
-            lastFinished = writeArray(val, LONG_ARR_OFF, val.length, val.length << 3);
+            if (BIG_ENDIAN)
+                lastFinished = writeArrayLE(val, LONG_ARR_OFF, val.length, 8, 3);
+            else
+                lastFinished = writeArray(val, LONG_ARR_OFF, val.length, val.length << 3);
         else
             writeInt(-1);
     }
@@ -509,7 +519,10 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeFloatArray(float[] val) {
         if (val != null)
-            lastFinished = writeArray(val, FLOAT_ARR_OFF, val.length, val.length << 2);
+            if (BIG_ENDIAN)
+                lastFinished = writeArrayLE(val, FLOAT_ARR_OFF, val.length, 4, 2);
+            else
+                lastFinished = writeArray(val, FLOAT_ARR_OFF, val.length, val.length << 2);
         else
             writeInt(-1);
     }
@@ -517,15 +530,22 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeDoubleArray(double[] val) {
         if (val != null)
-            lastFinished = writeArray(val, DOUBLE_ARR_OFF, val.length, val.length << 3);
+            if (BIG_ENDIAN)
+                lastFinished = writeArrayLE(val, DOUBLE_ARR_OFF, val.length, 8, 3);
+            else
+                lastFinished = writeArray(val, DOUBLE_ARR_OFF, val.length, val.length << 3);
         else
             writeInt(-1);
     }
 
     /** {@inheritDoc} */
     @Override public void writeCharArray(char[] val) {
-        if (val != null)
-            lastFinished = writeArray(val, CHAR_ARR_OFF, val.length, val.length << 1);
+        if (val != null) {
+            if (BIG_ENDIAN)
+                lastFinished = writeArrayLE(val, CHAR_ARR_OFF, val.length, 2, 1);
+            else
+                lastFinished = writeArray(val, CHAR_ARR_OFF, val.length, val.length << 1);
+        }
         else
             writeInt(-1);
     }
@@ -533,7 +553,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeBooleanArray(boolean[] val) {
         if (val != null)
-            lastFinished = writeArray(val, BOOLEAN_ARR_OFF, val.length, val.length);
+            lastFinished = writeArray(val, GridUnsafe.BOOLEAN_ARR_OFF, val.length, val.length);
         else
             writeInt(-1);
     }
@@ -793,7 +813,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
 
             buf.position(pos + 1);
 
-            return UNSAFE.getByte(heapArr, baseOff + pos);
+            return GridUnsafe.getByte(heapArr, baseOff + pos);
         }
         else
             return 0;
@@ -808,7 +828,9 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
 
             buf.position(pos + 2);
 
-            return UNSAFE.getShort(heapArr, baseOff + pos);
+            long off = baseOff + pos;
+
+            return BIG_ENDIAN ? GridUnsafe.getShortLE(heapArr, off) : GridUnsafe.getShort(heapArr, off);
         }
         else
             return 0;
@@ -823,7 +845,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         while (buf.hasRemaining()) {
             int pos = buf.position();
 
-            byte b = UNSAFE.getByte(heapArr, baseOff + pos);
+            byte b = GridUnsafe.getByte(heapArr, baseOff + pos);
 
             buf.position(pos + 1);
 
@@ -860,7 +882,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         while (buf.hasRemaining()) {
             int pos = buf.position();
 
-            byte b = UNSAFE.getByte(heapArr, baseOff + pos);
+            byte b = GridUnsafe.getByte(heapArr, baseOff + pos);
 
             buf.position(pos + 1);
 
@@ -897,7 +919,9 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
 
             buf.position(pos + 4);
 
-            return UNSAFE.getFloat(heapArr, baseOff + pos);
+            long off = baseOff + pos;
+
+            return BIG_ENDIAN ? GridUnsafe.getFloatLE(heapArr, off) : GridUnsafe.getFloat(heapArr, off);
         }
         else
             return 0;
@@ -912,7 +936,9 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
 
             buf.position(pos + 8);
 
-            return UNSAFE.getDouble(heapArr, baseOff + pos);
+            long off = baseOff + pos;
+
+            return BIG_ENDIAN ? GridUnsafe.getDoubleLE(heapArr, off) : GridUnsafe.getDouble(heapArr, off);
         }
         else
             return 0;
@@ -927,7 +953,9 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
 
             buf.position(pos + 2);
 
-            return UNSAFE.getChar(heapArr, baseOff + pos);
+            long off = baseOff + pos;
+
+            return BIG_ENDIAN ? GridUnsafe.getCharLE(heapArr, off) : GridUnsafe.getChar(heapArr, off);
         }
         else
             return 0;
@@ -942,7 +970,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
 
             buf.position(pos + 1);
 
-            return UNSAFE.getBoolean(heapArr, baseOff + pos);
+            return GridUnsafe.getBoolean(heapArr, baseOff + pos);
         }
         else
             return false;
@@ -955,37 +983,55 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
 
     /** {@inheritDoc} */
     @Override public short[] readShortArray() {
-        return readArray(SHORT_ARR_CREATOR, 1, SHORT_ARR_OFF);
+        if (BIG_ENDIAN)
+            return readArrayLE(SHORT_ARR_CREATOR, 2, 1, SHORT_ARR_OFF);
+        else
+            return readArray(SHORT_ARR_CREATOR, 1, SHORT_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public int[] readIntArray() {
-        return readArray(INT_ARR_CREATOR, 2, INT_ARR_OFF);
+        if (BIG_ENDIAN)
+            return readArrayLE(INT_ARR_CREATOR, 4, 2, INT_ARR_OFF);
+        else
+            return readArray(INT_ARR_CREATOR, 2, INT_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public long[] readLongArray() {
-        return readArray(LONG_ARR_CREATOR, 3, LONG_ARR_OFF);
+        if (BIG_ENDIAN)
+            return readArrayLE(LONG_ARR_CREATOR, 8, 3, LONG_ARR_OFF);
+        else
+            return readArray(LONG_ARR_CREATOR, 3, LONG_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public float[] readFloatArray() {
-        return readArray(FLOAT_ARR_CREATOR, 2, FLOAT_ARR_OFF);
+        if (BIG_ENDIAN)
+            return readArrayLE(FLOAT_ARR_CREATOR, 4, 2, FLOAT_ARR_OFF);
+        else
+            return readArray(FLOAT_ARR_CREATOR, 2, FLOAT_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public double[] readDoubleArray() {
-        return readArray(DOUBLE_ARR_CREATOR, 3, DOUBLE_ARR_OFF);
+        if (BIG_ENDIAN)
+            return readArrayLE(DOUBLE_ARR_CREATOR, 8, 3, DOUBLE_ARR_OFF);
+        else
+            return readArray(DOUBLE_ARR_CREATOR, 3, DOUBLE_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public char[] readCharArray() {
-        return readArray(CHAR_ARR_CREATOR, 1, CHAR_ARR_OFF);
+        if (BIG_ENDIAN)
+            return readArrayLE(CHAR_ARR_CREATOR, 2, 1, CHAR_ARR_OFF);
+        else
+            return readArray(CHAR_ARR_CREATOR, 1, CHAR_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public boolean[] readBooleanArray() {
-        return readArray(BOOLEAN_ARR_CREATOR, 0, BOOLEAN_ARR_OFF);
+        return readArray(BOOLEAN_ARR_CREATOR, 0, GridUnsafe.BOOLEAN_ARR_OFF);
     }
 
     /** {@inheritDoc} */
@@ -1274,14 +1320,8 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         assert bytes >= 0;
         assert bytes >= arrOff;
 
-        if (arrOff == -1) {
-            writeInt(len);
-
-            if (!lastFinished)
-                return false;
-
-            arrOff = 0;
-        }
+        if (writeArrayLength(len))
+            return false;
 
         int toWrite = bytes - arrOff;
         int pos = buf.position();
@@ -1289,7 +1329,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
 
         if (toWrite <= remaining) {
             if (toWrite > 0) {
-                UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, toWrite);
+                GridUnsafe.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, toWrite);
 
                 buf.position(pos + toWrite);
             }
@@ -1300,7 +1340,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         }
         else {
             if (remaining > 0) {
-                UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining);
+                GridUnsafe.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining);
 
                 buf.position(pos + remaining);
 
@@ -1312,6 +1352,80 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     }
 
     /**
+     * @param arr Array.
+     * @param off Offset.
+     * @param len Length.
+     * @param typeSize Primitive type size in bytes. Needs for byte reverse.
+     * @return Whether array was fully written.
+     */
+    private boolean writeArrayLE(Object arr, long off, int len, int typeSize, int shiftCnt) {
+        assert arr != null;
+        assert arr.getClass().isArray() && arr.getClass().getComponentType().isPrimitive();
+        assert off > 0;
+        assert len >= 0;
+
+        int bytes = len << shiftCnt;
+
+        assert bytes >= arrOff;
+
+        if (writeArrayLength(len))
+            return false;
+
+        int toWrite = (bytes - arrOff) >> shiftCnt;
+        int remaining = buf.remaining() >> shiftCnt;
+
+        if (toWrite <= remaining) {
+            writeArrayLE(arr, off, toWrite, typeSize);
+
+            arrOff = -1;
+
+            return true;
+        }
+        else {
+            if (remaining > 0)
+                writeArrayLE(arr, off, remaining, typeSize);
+
+            return false;
+        }
+    }
+
+    /**
+     * @param arr Array.
+     * @param off Offset.
+     * @param len Length.
+     * @param typeSize Primitive type size in bytes.
+     */
+    private void writeArrayLE(Object arr, long off, int len, int typeSize) {
+        int pos = buf.position();
+
+        for (int i = 0; i < len; i++) {
+            for (int j = 0; j < typeSize; j++) {
+                byte b = GridUnsafe.getByteField(arr, off + arrOff + (typeSize - j - 1));
+
+                GridUnsafe.putByte(heapArr, baseOff + pos++, b);
+            }
+
+            buf.position(pos);
+            arrOff += typeSize;
+        }
+    }
+
+    /**
+     * @param len Length.
+     */
+    private boolean writeArrayLength(int len) {
+        if (arrOff == -1) {
+            writeInt(len);
+
+            if (!lastFinished)
+                return true;
+
+            arrOff = 0;
+        }
+        return false;
+    }
+
+    /**
      * @param creator Array creator.
      * @param lenShift Array length shift size.
      * @param off Base offset.
@@ -1351,7 +1465,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
         lastFinished = toRead <= remaining;
 
         if (lastFinished) {
-            UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead);
+            GridUnsafe.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead);
 
             buf.position(pos + toRead);
 
@@ -1364,7 +1478,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
             return arr;
         }
         else {
-            UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining);
+            GridUnsafe.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining);
 
             buf.position(pos + remaining);
 
@@ -1375,6 +1489,95 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     }
 
     /**
+     * @param creator Array creator.
+     * @param typeSize Primitive type size in bytes.
+     * @param lenShift Array length shift size.
+     * @param off Base offset.
+     * @return Array or special value if it was not fully read.
+     */
+    @SuppressWarnings("unchecked")
+    private <T> T readArrayLE(ArrayCreator<T> creator, int typeSize, int lenShift, long off) {
+        assert creator != null;
+
+        if (tmpArr == null) {
+            int len = readInt();
+
+            if (!lastFinished)
+                return null;
+
+            switch (len) {
+                case -1:
+                    lastFinished = true;
+
+                    return null;
+
+                case 0:
+                    lastFinished = true;
+
+                    return creator.create(0);
+
+                default:
+                    tmpArr = creator.create(len);
+                    tmpArrBytes = len << lenShift;
+            }
+        }
+
+        int toRead = (tmpArrBytes - tmpArrOff) >> lenShift;
+        int remaining = buf.remaining() >> lenShift;
+
+        lastFinished = toRead <= buf.remaining();
+
+        if (lastFinished) {
+            readArrayLE(typeSize, off, toRead);
+
+            T arr = (T)tmpArr;
+
+            tmpArr = null;
+            tmpArrBytes = 0;
+            tmpArrOff = 0;
+
+            return arr;
+        }
+        else {
+            for (int i = 0; i < remaining; i++) {
+                int pos = buf.position();
+
+                for (int j = 0; j < typeSize; j++) {
+                    byte b = GridUnsafe.getByte(heapArr, baseOff + pos + (typeSize - j - 1));
+
+                    GridUnsafe.putByteField(tmpArr, off + tmpArrOff + j, b);
+                }
+
+                buf.position(pos + typeSize);
+                tmpArrOff += typeSize;
+            }
+
+            tmpArrOff += buf.remaining();
+
+            return null;
+        }
+    }
+
+    /**
+     * @param typeSize Primitive type size in bytes.
+     * @param off Offset.
+     * @param toRead To read.
+     */
+    private void readArrayLE(int typeSize, long off, int toRead) {
+        for (int i = 0; i < toRead; i++) {
+            int pos = buf.position();
+
+            for (int j = 0; j < typeSize; j++) {
+                byte b = GridUnsafe.getByte(heapArr, baseOff + pos + (typeSize - j - 1));
+
+                GridUnsafe.putByteField(tmpArr, off + tmpArrOff++, b);
+            }
+
+            buf.position(pos + typeSize);
+        }
+    }
+
+    /**
      * @param type Type.
      * @param val Value.
      * @param writer Writer.
@@ -1583,7 +1786,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /**
      * Array creator.
      */
-    private static interface ArrayCreator<T> {
+    private interface ArrayCreator<T> {
         /**
          * @param len Array length or {@code -1} if array was not fully read.
          * @return New array.

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index 845e204..3a7bc8e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -103,9 +103,6 @@ import static org.jsr166.ConcurrentLinkedDeque8.Node;
  * Cache eviction manager.
  */
 public class GridCacheEvictionManager extends GridCacheManagerAdapter {
-    /** Unsafe instance. */
-    private static final sun.misc.Unsafe unsafe = GridUnsafe.unsafe();
-
     /** Attribute name used to queue node in entry metadata. */
     private static final int META_KEY = GridMetadataAwareAdapter.EntryKey.CACHE_EVICTION_MANAGER_KEY.key();
 
@@ -985,7 +982,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
                     continue;
 
                 // Lock entry.
-                unsafe.monitorEnter(entry);
+                GridUnsafe.monitorEnter(entry);
 
                 locked.add(entry);
 
@@ -1028,7 +1025,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
             for (ListIterator<GridCacheEntryEx> it = locked.listIterator(locked.size()); it.hasPrevious();) {
                 GridCacheEntryEx e = it.previous();
 
-                unsafe.monitorExit(e);
+                GridUnsafe.monitorExit(e);
             }
 
             // Remove entries and fire events outside the locks.

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapSwapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapSwapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapSwapEntry.java
index ea036af..82e115c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapSwapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapSwapEntry.java
@@ -23,7 +23,6 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
 import org.jetbrains.annotations.Nullable;
-import sun.misc.Unsafe;
 
 /**
  * GridCacheSwapEntry over offheap pointer.
@@ -41,9 +40,6 @@ import sun.misc.Unsafe;
  */
 public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
     /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
     private final long ptr;
 
     /** */
@@ -70,17 +66,17 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
 
         long readPtr = ptr + GridCacheSwapEntryImpl.VERSION_OFFSET;
 
-        boolean verEx = UNSAFE.getByte(readPtr++) != 0;
+        boolean verEx = GridUnsafe.getByte(readPtr++) != 0;
 
         ver = U.readVersion(readPtr, verEx);
 
         readPtr += verEx ? GridCacheSwapEntryImpl.VERSION_EX_SIZE : GridCacheSwapEntryImpl.VERSION_SIZE;
 
-        type = UNSAFE.getByte(readPtr + 4);
+        type = GridUnsafe.getByte(readPtr + 4);
 
         valPtr = readPtr;
 
-        assert (ptr + size) > (UNSAFE.getInt(valPtr) + valPtr + 5);
+        assert (ptr + size) > (GridUnsafe.getInt(valPtr) + valPtr + 5);
     }
 
     /**
@@ -94,11 +90,11 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
 
         ptr += GridCacheSwapEntryImpl.VERSION_OFFSET; // Skip ttl, expire time.
 
-        boolean verEx = UNSAFE.getByte(ptr++) != 0;
+        boolean verEx = GridUnsafe.getByte(ptr++) != 0;
 
         ptr += verEx ? GridCacheSwapEntryImpl.VERSION_EX_SIZE : GridCacheSwapEntryImpl.VERSION_SIZE;
 
-        assert (ptr + size) > (UNSAFE.getInt(ptr) + ptr + 5);
+        assert (ptr + size) > (GridUnsafe.getInt(ptr) + ptr + 5);
 
         return ptr;
     }
@@ -108,7 +104,7 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
      * @return TTL.
      */
     public static long timeToLive(long ptr) {
-        return UNSAFE.getLong(ptr);
+        return GridUnsafe.getLong(ptr);
     }
 
     /**
@@ -116,7 +112,7 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
      * @return Expire time.
      */
     public static long expireTime(long ptr) {
-        return UNSAFE.getLong(ptr + GridCacheSwapEntryImpl.EXPIRE_TIME_OFFSET);
+        return GridUnsafe.getLong(ptr + GridCacheSwapEntryImpl.EXPIRE_TIME_OFFSET);
     }
 
     /**
@@ -126,7 +122,7 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
     public static GridCacheVersion version(long ptr) {
         long addr = ptr + GridCacheSwapEntryImpl.VERSION_OFFSET;
 
-        boolean verEx = UNSAFE.getByte(addr) != 0;
+        boolean verEx = GridUnsafe.getByte(addr) != 0;
 
         addr++;
 
@@ -165,12 +161,12 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
 
     /** {@inheritDoc} */
     @Override public long ttl() {
-        return UNSAFE.getLong(ptr);
+        return GridUnsafe.getLong(ptr);
     }
 
     /** {@inheritDoc} */
     @Override public long expireTime() {
-        return UNSAFE.getLong(ptr + GridCacheSwapEntryImpl.EXPIRE_TIME_OFFSET);
+        return GridUnsafe.getLong(ptr + GridCacheSwapEntryImpl.EXPIRE_TIME_OFFSET);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
index 6b1266f..02f74e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
@@ -26,19 +26,12 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgniteUuid;
 import org.jetbrains.annotations.Nullable;
-import sun.misc.Unsafe;
 
 /**
  * Swap entry.
  */
 public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
     /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
-    private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** */
     static final int EXPIRE_TIME_OFFSET = 8;
 
     /** */
@@ -108,7 +101,7 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
      * @return TTL.
      */
     public static long timeToLive(byte[] bytes) {
-        return UNSAFE.getLong(bytes, BYTE_ARR_OFF);
+        return GridUnsafe.getLong(bytes, GridUnsafe.BYTE_ARR_OFF);
     }
 
     /**
@@ -116,7 +109,7 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
      * @return Expire time.
      */
     public static long expireTime(byte[] bytes) {
-        return UNSAFE.getLong(bytes, BYTE_ARR_OFF + EXPIRE_TIME_OFFSET);
+        return GridUnsafe.getLong(bytes, GridUnsafe.BYTE_ARR_OFF + EXPIRE_TIME_OFFSET);
     }
 
     /**
@@ -124,9 +117,9 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
      * @return Version.
      */
     public static GridCacheVersion version(byte[] bytes) {
-        long off = BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
+        long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
 
-        boolean verEx = UNSAFE.getByte(bytes, off++) != 0;
+        boolean verEx = GridUnsafe.getByte(bytes, off++) != 0;
 
         return U.readVersion(bytes, off, verEx);
     }
@@ -136,21 +129,21 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
      * @return Value if value is byte array, otherwise {@code null}.
      */
     @Nullable public static IgniteBiTuple<byte[], Byte> getValue(byte[] bytes) {
-        long off = BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
+        long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
 
-        boolean verEx = UNSAFE.getByte(bytes, off++) != 0;
+        boolean verEx = GridUnsafe.getByte(bytes, off++) != 0;
 
         off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
 
-        int arrLen = UNSAFE.getInt(bytes, off);
+        int arrLen = GridUnsafe.getInt(bytes, off);
 
         off += 4;
 
-        byte type = UNSAFE.getByte(bytes, off++);
+        byte type = GridUnsafe.getByte(bytes, off++);
 
         byte[] valBytes = new byte[arrLen];
 
-        UNSAFE.copyMemory(bytes, off, valBytes, BYTE_ARR_OFF, arrLen);
+        GridUnsafe.copyMemory(bytes, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
 
         return new IgniteBiTuple<>(valBytes, type);
     }
@@ -235,25 +228,25 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
 
         byte[] arr = new byte[size];
 
-        long off = BYTE_ARR_OFF;
+        long off = GridUnsafe.BYTE_ARR_OFF;
 
-        UNSAFE.putLong(arr, off, ttl);
+        GridUnsafe.putLong(arr, off, ttl);
 
         off += 8;
 
-        UNSAFE.putLong(arr, off, expireTime);
+        GridUnsafe.putLong(arr, off, expireTime);
 
         off += 8;
 
         off = U.writeVersion(arr, off, ver);
 
-        UNSAFE.putInt(arr, off, len);
+        GridUnsafe.putInt(arr, off, len);
 
         off += 4;
 
-        UNSAFE.putByte(arr, off++, type);
+        GridUnsafe.putByte(arr, off++, type);
 
-        UNSAFE.copyMemory(valBytes.array(), BYTE_ARR_OFF, arr, off, len);
+        GridUnsafe.copyMemory(valBytes.array(), GridUnsafe.BYTE_ARR_OFF, arr, off, len);
 
         off += len;
 
@@ -271,21 +264,21 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
      */
     public static GridCacheSwapEntryImpl unmarshal(byte[] arr, boolean valOnly) {
         if (valOnly) {
-            long off = BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
+            long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
 
-            boolean verEx = UNSAFE.getByte(arr, off++) != 0;
+            boolean verEx = GridUnsafe.getByte(arr, off++) != 0;
 
             off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
 
-            int arrLen = UNSAFE.getInt(arr, off);
+            int arrLen = GridUnsafe.getInt(arr, off);
 
             off += 4;
 
-            byte type = UNSAFE.getByte(arr, off++);
+            byte type = GridUnsafe.getByte(arr, off++);
 
             byte[] valBytes = new byte[arrLen];
 
-            UNSAFE.copyMemory(arr, off, valBytes, BYTE_ARR_OFF, arrLen);
+            GridUnsafe.copyMemory(arr, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
 
             return new GridCacheSwapEntryImpl(ByteBuffer.wrap(valBytes),
                 type,
@@ -296,31 +289,31 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
                 null);
         }
 
-        long off = BYTE_ARR_OFF;
+        long off = GridUnsafe.BYTE_ARR_OFF;
 
-        long ttl = UNSAFE.getLong(arr, off);
+        long ttl = GridUnsafe.getLong(arr, off);
 
         off += 8;
 
-        long expireTime = UNSAFE.getLong(arr, off);
+        long expireTime = GridUnsafe.getLong(arr, off);
 
         off += 8;
 
-        boolean verEx = UNSAFE.getBoolean(arr, off++);
+        boolean verEx = GridUnsafe.getBoolean(arr, off++);
 
         GridCacheVersion ver = U.readVersion(arr, off, verEx);
 
         off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
 
-        int arrLen = UNSAFE.getInt(arr, off);
+        int arrLen = GridUnsafe.getInt(arr, off);
 
         off += 4;
 
-        byte type = UNSAFE.getByte(arr, off++);
+        byte type = GridUnsafe.getByte(arr, off++);
 
         byte[] valBytes = new byte[arrLen];
 
-        UNSAFE.copyMemory(arr, off, valBytes, BYTE_ARR_OFF, arrLen);
+        GridUnsafe.copyMemory(arr, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
 
         off += arrLen;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index a21331e..0fef6f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -102,7 +102,6 @@ import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.spi.IgniteNodeValidationResult;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
-import sun.misc.Unsafe;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
 import static org.apache.ignite.IgniteSystemProperties.getBoolean;
@@ -113,9 +112,6 @@ import static org.apache.ignite.IgniteSystemProperties.getBoolean;
 public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorImpl implements
     CacheObjectBinaryProcessor {
     /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
     public static final IgniteProductVersion BINARY_CFG_CHECK_SINCE = IgniteProductVersion.fromString("1.5.6");
 
     /** */
@@ -430,11 +426,11 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     public Object unmarshal(long ptr, boolean forceHeap) throws BinaryObjectException {
         assert ptr > 0 : ptr;
 
-        int size = UNSAFE.getInt(ptr);
+        int size = GridUnsafe.getInt(ptr);
 
         ptr += 4;
 
-        byte type = UNSAFE.getByte(ptr++);
+        byte type = GridUnsafe.getByte(ptr++);
 
         if (type != CacheObject.TYPE_BYTE_ARR) {
             assert size > 0 : size;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index b806906..f6f57ee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -138,9 +138,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     private static final int DEFERRED_UPDATE_RESPONSE_TIMEOUT =
         Integer.getInteger(IGNITE_ATOMIC_DEFERRED_ACK_TIMEOUT, 500);
 
-    /** Unsafe instance. */
-    private static final sun.misc.Unsafe UNSAFE = GridUnsafe.unsafe();
-
     /** Update reply closure. */
     private CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse> updateReplyClos;
 
@@ -2463,10 +2460,10 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                 try {
                     GridDhtCacheEntry entry = entryExx(key, topVer);
 
-                    UNSAFE.monitorEnter(entry);
+                    GridUnsafe.monitorEnter(entry);
 
                     if (entry.obsolete())
-                        UNSAFE.monitorExit(entry);
+                        GridUnsafe.monitorExit(entry);
                     else
                         return Collections.singletonList(entry);
                 }
@@ -2506,13 +2503,13 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                     if (entry == null)
                         continue;
 
-                    UNSAFE.monitorEnter(entry);
+                    GridUnsafe.monitorEnter(entry);
 
                     if (entry.obsolete()) {
                         // Unlock all locked.
                         for (int j = 0; j <= i; j++) {
                             if (locked.get(j) != null)
-                                UNSAFE.monitorExit(locked.get(j));
+                                GridUnsafe.monitorExit(locked.get(j));
                         }
 
                         // Clear entries.
@@ -2561,7 +2558,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             // That's why releasing locks in the finally block..
             for (GridCacheMapEntry entry : locked) {
                 if (entry != null)
-                    UNSAFE.monitorExit(entry);
+                    GridUnsafe.monitorExit(entry);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index fed3e33..8e5fe9e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -89,9 +89,6 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
     /** */
     private static final long serialVersionUID = 0L;
 
-    /** Unsafe instance. */
-    private static final sun.misc.Unsafe UNSAFE = GridUnsafe.unsafe();
-
     /** */
     private GridCachePreloader preldr;
 
@@ -1553,12 +1550,12 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             for (int i = 0; i < locked.size(); i++) {
                 GridCacheEntryEx entry = locked.get(i);
 
-                UNSAFE.monitorEnter(entry);
+                GridUnsafe.monitorEnter(entry);
 
                 if (entry.obsolete()) {
                     // Unlock all locked.
                     for (int j = 0; j <= i; j++)
-                        UNSAFE.monitorExit(locked.get(j));
+                        GridUnsafe.monitorExit(locked.get(j));
 
                     // Clear entries.
                     locked.clear();
@@ -1589,7 +1586,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
      */
     private void unlockEntries(Iterable<GridCacheEntryEx> locked) {
         for (GridCacheEntryEx entry : locked)
-            UNSAFE.monitorExit(entry);
+            GridUnsafe.monitorExit(entry);
 
         AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 5b764b6..54dd69e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -51,9 +51,6 @@ import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
  *
  */
 public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter implements IgniteCacheObjectProcessor {
-    /** */
-    private static final sun.misc.Unsafe UNSAFE = GridUnsafe.unsafe();
-
     /** Immutable classes. */
     private static final Collection<Class<?>> IMMUTABLE_CLS = new HashSet<>();
 
@@ -138,9 +135,9 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
     {
         assert valPtr != 0;
 
-        int size = UNSAFE.getInt(valPtr);
+        int size = GridUnsafe.getInt(valPtr);
 
-        byte type = UNSAFE.getByte(valPtr + 4);
+        byte type = GridUnsafe.getByte(valPtr + 4);
 
         byte[] bytes = U.copyMemory(valPtr + 5, size);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
index e305c71..606a23c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
@@ -17,13 +17,15 @@
 
 package org.apache.ignite.internal.processors.platform.memory;
 
+import org.apache.ignite.internal.util.GridUnsafe;
+
 /**
  * Interop memory chunk abstraction.
  */
 public abstract class PlatformAbstractMemory implements PlatformMemory {
     /** Stream factory. */
-    private static final StreamFactory STREAM_FACTORY = PlatformMemoryUtils.LITTLE_ENDIAN ?
-        new LittleEndianStreamFactory() : new BigEndianStreamFactory();
+    private static final StreamFactory STREAM_FACTORY = GridUnsafe.BIG_ENDIAN ?
+        new BigEndianStreamFactory() : new LittleEndianStreamFactory();
 
     /** Cross-platform memory pointer. */
     protected long memPtr;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
index 2f6ad5c..b16f42f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
@@ -17,7 +17,7 @@
 
 package org.apache.ignite.internal.processors.platform.memory;
 
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.UNSAFE;
+import org.apache.ignite.internal.util.GridUnsafe;
 
 /**
  * Interop output stream implementation working with BIG ENDIAN architecture.
@@ -46,7 +46,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
         long startPos = data + pos;
 
         for (short item : val) {
-            UNSAFE.putShort(startPos, Short.reverseBytes(item));
+            GridUnsafe.putShort(startPos, Short.reverseBytes(item));
 
             startPos += 2;
         }
@@ -68,7 +68,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
         long startPos = data + pos;
 
         for (char item : val) {
-            UNSAFE.putChar(startPos, Character.reverseBytes(item));
+            GridUnsafe.putChar(startPos, Character.reverseBytes(item));
 
             startPos += 2;
         }
@@ -90,7 +90,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
         long startPos = data + pos;
 
         for (int item : val) {
-            UNSAFE.putInt(startPos, Integer.reverseBytes(item));
+            GridUnsafe.putInt(startPos, Integer.reverseBytes(item));
 
             startPos += 4;
         }
@@ -117,7 +117,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
         long startPos = data + pos;
 
         for (float item : val) {
-            UNSAFE.putInt(startPos, Integer.reverseBytes(Float.floatToIntBits(item)));
+            GridUnsafe.putInt(startPos, Integer.reverseBytes(Float.floatToIntBits(item)));
 
             startPos += 4;
         }
@@ -139,7 +139,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
         long startPos = data + pos;
 
         for (long item : val) {
-            UNSAFE.putLong(startPos, Long.reverseBytes(item));
+            GridUnsafe.putLong(startPos, Long.reverseBytes(item));
 
             startPos += 8;
         }
@@ -156,7 +156,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
         long startPos = data + pos;
 
         for (double item : val) {
-            UNSAFE.putLong(startPos, Long.reverseBytes(Double.doubleToLongBits(item)));
+            GridUnsafe.putLong(startPos, Long.reverseBytes(Double.doubleToLongBits(item)));
 
             startPos += 8;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
index 13da8c5..5e26905 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
@@ -18,16 +18,7 @@
 package org.apache.ignite.internal.processors.platform.memory;
 
 import org.apache.ignite.IgniteException;
-
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.BOOLEAN_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.CHAR_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.DOUBLE_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.FLOAT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.INT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.LONG_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.SHORT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.UNSAFE;
+import org.apache.ignite.internal.util.GridUnsafe;
 
 /**
  * Interop input stream implementation.
@@ -64,14 +55,14 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
     @Override public byte readByte() {
         ensureEnoughData(1);
 
-        return UNSAFE.getByte(data + pos++);
+        return GridUnsafe.getByte(data + pos++);
     }
 
     /** {@inheritDoc} */
     @Override public byte[] readByteArray(int cnt) {
         byte[] res = new byte[cnt];
 
-        copyAndShift(res, BYTE_ARR_OFF, cnt);
+        copyAndShift(res, GridUnsafe.BYTE_ARR_OFF, cnt);
 
         return res;
     }
@@ -85,7 +76,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
     @Override public boolean[] readBooleanArray(int cnt) {
         boolean[] res = new boolean[cnt];
 
-        copyAndShift(res, BOOLEAN_ARR_OFF, cnt);
+        copyAndShift(res, GridUnsafe.BOOLEAN_ARR_OFF, cnt);
 
         return res;
     }
@@ -94,7 +85,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
     @Override public short readShort() {
         ensureEnoughData(2);
 
-        short res = UNSAFE.getShort(data + pos);
+        short res = GridUnsafe.getShort(data + pos);
 
         shift(2);
 
@@ -107,7 +98,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
 
         short[] res = new short[cnt];
 
-        copyAndShift(res, SHORT_ARR_OFF, len);
+        copyAndShift(res, GridUnsafe.SHORT_ARR_OFF, len);
 
         return res;
     }
@@ -116,7 +107,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
     @Override public char readChar() {
         ensureEnoughData(2);
 
-        char res = UNSAFE.getChar(data + pos);
+        char res = GridUnsafe.getChar(data + pos);
 
         shift(2);
 
@@ -129,7 +120,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
 
         char[] res = new char[cnt];
 
-        copyAndShift(res, CHAR_ARR_OFF, len);
+        copyAndShift(res, GridUnsafe.CHAR_ARR_OFF, len);
 
         return res;
     }
@@ -138,7 +129,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
     @Override public int readInt() {
         ensureEnoughData(4);
 
-        int res = UNSAFE.getInt(data + pos);
+        int res = GridUnsafe.getInt(data + pos);
 
         shift(4);
 
@@ -152,7 +143,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
         if (delta > 0)
             ensureEnoughData(delta);
 
-        return UNSAFE.getByte(data + pos);
+        return GridUnsafe.getByte(data + pos);
     }
 
     /** {@inheritDoc} */
@@ -162,7 +153,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
         if (delta > 0)
             ensureEnoughData(delta);
 
-        return UNSAFE.getShort(data + pos);
+        return GridUnsafe.getShort(data + pos);
     }
 
     /** {@inheritDoc} */
@@ -172,7 +163,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
         if (delta > 0)
             ensureEnoughData(delta);
 
-        return UNSAFE.getInt(data + pos);
+        return GridUnsafe.getInt(data + pos);
     }
 
     /** {@inheritDoc} */
@@ -181,7 +172,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
 
         int[] res = new int[cnt];
 
-        copyAndShift(res, INT_ARR_OFF, len);
+        copyAndShift(res, GridUnsafe.INT_ARR_OFF, len);
 
         return res;
     }
@@ -190,7 +181,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
     @Override public float readFloat() {
         ensureEnoughData(4);
 
-        float res = UNSAFE.getFloat(data + pos);
+        float res = GridUnsafe.getFloat(data + pos);
 
         shift(4);
 
@@ -203,7 +194,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
 
         float[] res = new float[cnt];
 
-        copyAndShift(res, FLOAT_ARR_OFF, len);
+        copyAndShift(res, GridUnsafe.FLOAT_ARR_OFF, len);
 
         return res;
     }
@@ -212,7 +203,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
     @Override public long readLong() {
         ensureEnoughData(8);
 
-        long res = UNSAFE.getLong(data + pos);
+        long res = GridUnsafe.getLong(data + pos);
 
         shift(8);
 
@@ -225,7 +216,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
 
         long[] res = new long[cnt];
 
-        copyAndShift(res, LONG_ARR_OFF, len);
+        copyAndShift(res, GridUnsafe.LONG_ARR_OFF, len);
 
         return res;
     }
@@ -234,7 +225,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
     @Override public double readDouble() {
         ensureEnoughData(8);
 
-        double res = UNSAFE.getDouble(data + pos);
+        double res = GridUnsafe.getDouble(data + pos);
 
         shift(8);
 
@@ -247,7 +238,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
 
         double[] res = new double[cnt];
 
-        copyAndShift(res, DOUBLE_ARR_OFF, len);
+        copyAndShift(res, GridUnsafe.DOUBLE_ARR_OFF, len);
 
         return res;
     }
@@ -257,7 +248,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
         if (len > remaining())
             len = remaining();
 
-        copyAndShift(arr, BYTE_ARR_OFF + off, len);
+        copyAndShift(arr, GridUnsafe.BYTE_ARR_OFF + off, len);
 
         return len;
     }
@@ -290,7 +281,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
         if (dataCopy == null) {
             dataCopy = new byte[len];
 
-            UNSAFE.copyMemory(null, data, dataCopy, BYTE_ARR_OFF, dataCopy.length);
+            GridUnsafe.copyMemory(null, data, dataCopy, GridUnsafe.BYTE_ARR_OFF, dataCopy.length);
         }
 
         return dataCopy;
@@ -333,7 +324,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
     private void copyAndShift(Object target, long off, int cnt) {
         ensureEnoughData(cnt);
 
-        UNSAFE.copyMemory(null, data + pos, target, off, cnt);
+        GridUnsafe.copyMemory(null, data + pos, target, off, cnt);
 
         shift(cnt);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
index 2520a47..894658c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
@@ -17,44 +17,12 @@
 
 package org.apache.ignite.internal.processors.platform.memory;
 
-import java.nio.ByteOrder;
 import org.apache.ignite.internal.util.GridUnsafe;
-import sun.misc.Unsafe;
 
 /**
  * Utility classes for memory management.
  */
 public class PlatformMemoryUtils {
-    /** Unsafe instance. */
-    public static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** Array offset: boolean. */
-    public static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
-
-    /** Array offset: byte. */
-    public static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** Array offset: short. */
-    public static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
-
-    /** Array offset: char. */
-    public static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
-    /** Array offset: int. */
-    public static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
-
-    /** Array offset: float. */
-    public static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
-
-    /** Array offset: long. */
-    public static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
-
-    /** Array offset: double. */
-    public static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
-
-    /** Whether little endian is used on the platform. */
-    public static final boolean LITTLE_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN;
-
     /** Header length. */
     public static final int POOL_HDR_LEN = 64;
 
@@ -97,7 +65,7 @@ public class PlatformMemoryUtils {
      * @return Data pointer.
      */
     public static long data(long memPtr) {
-        return UNSAFE.getLong(memPtr);
+        return GridUnsafe.getLong(memPtr);
     }
 
     /**
@@ -107,7 +75,7 @@ public class PlatformMemoryUtils {
      * @return Capacity.
      */
     public static int capacity(long memPtr) {
-        return UNSAFE.getInt(memPtr + MEM_HDR_OFF_CAP);
+        return GridUnsafe.getInt(memPtr + MEM_HDR_OFF_CAP);
     }
 
     /**
@@ -119,7 +87,7 @@ public class PlatformMemoryUtils {
     public static void capacity(long memPtr, int cap) {
         assert !isExternal(memPtr) : "Attempt to update external memory chunk capacity: " + memPtr;
 
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+        GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
     }
 
     /**
@@ -129,7 +97,7 @@ public class PlatformMemoryUtils {
      * @return Length.
      */
     public static int length(long memPtr) {
-        return UNSAFE.getInt(memPtr + MEM_HDR_OFF_LEN);
+        return GridUnsafe.getInt(memPtr + MEM_HDR_OFF_LEN);
     }
 
     /**
@@ -139,7 +107,7 @@ public class PlatformMemoryUtils {
      * @param len Length.
      */
     public static void length(long memPtr, int len) {
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_LEN, len);
+        GridUnsafe.putInt(memPtr + MEM_HDR_OFF_LEN, len);
     }
 
     /**
@@ -149,7 +117,7 @@ public class PlatformMemoryUtils {
      * @return Flags.
      */
     public static int flags(long memPtr) {
-        return UNSAFE.getInt(memPtr + MEM_HDR_OFF_FLAGS);
+        return GridUnsafe.getInt(memPtr + MEM_HDR_OFF_FLAGS);
     }
 
     /**
@@ -161,7 +129,7 @@ public class PlatformMemoryUtils {
     public static void flags(long memPtr, int flags) {
         assert !isExternal(memPtr) : "Attempt to update external memory chunk flags: " + memPtr;
 
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_FLAGS, flags);
+        GridUnsafe.putInt(memPtr + MEM_HDR_OFF_FLAGS, flags);
     }
 
     /**
@@ -237,13 +205,13 @@ public class PlatformMemoryUtils {
     public static long allocateUnpooled(int cap) {
         assert cap > 0;
 
-        long memPtr = UNSAFE.allocateMemory(MEM_HDR_LEN);
-        long dataPtr = UNSAFE.allocateMemory(cap);
+        long memPtr = GridUnsafe.allocateMemory(MEM_HDR_LEN);
+        long dataPtr = GridUnsafe.allocateMemory(cap);
 
-        UNSAFE.putLong(memPtr, dataPtr);              // Write address.
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write capacity.
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_LEN, 0);   // Write length.
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_FLAGS, 0); // Write flags.
+        GridUnsafe.putLong(memPtr, dataPtr);              // Write address.
+        GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write capacity.
+        GridUnsafe.putInt(memPtr + MEM_HDR_OFF_LEN, 0);   // Write length.
+        GridUnsafe.putInt(memPtr + MEM_HDR_OFF_FLAGS, 0); // Write flags.
 
         return memPtr;
     }
@@ -262,12 +230,12 @@ public class PlatformMemoryUtils {
 
         long dataPtr = data(memPtr);
 
-        long newDataPtr = UNSAFE.reallocateMemory(dataPtr, cap);
+        long newDataPtr = GridUnsafe.reallocateMemory(dataPtr, cap);
 
         if (dataPtr != newDataPtr)
-            UNSAFE.putLong(memPtr, newDataPtr); // Write new data address if needed.
+            GridUnsafe.putLong(memPtr, newDataPtr); // Write new data address if needed.
 
-        UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write new capacity.
+        GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write new capacity.
     }
 
     /**
@@ -279,8 +247,8 @@ public class PlatformMemoryUtils {
         assert !isExternal(memPtr) : "Attempt to release external memory chunk directly: " + memPtr;
         assert !isPooled(memPtr) : "Attempt to release pooled memory chunk directly: " + memPtr;
 
-        UNSAFE.freeMemory(data(memPtr));
-        UNSAFE.freeMemory(memPtr);
+        GridUnsafe.freeMemory(data(memPtr));
+        GridUnsafe.freeMemory(memPtr);
     }
 
     /** --- POOLED MEMORY MANAGEMENT. --- */
@@ -291,9 +259,9 @@ public class PlatformMemoryUtils {
      * @return Pool pointer.
      */
     public static long allocatePool() {
-        long poolPtr = UNSAFE.allocateMemory(POOL_HDR_LEN);
+        long poolPtr = GridUnsafe.allocateMemory(POOL_HDR_LEN);
 
-        UNSAFE.setMemory(poolPtr, POOL_HDR_LEN, (byte)0);
+        GridUnsafe.setMemory(poolPtr, POOL_HDR_LEN, (byte)0);
 
         flags(poolPtr + POOL_HDR_OFF_MEM_1, FLAG_POOLED);
         flags(poolPtr + POOL_HDR_OFF_MEM_2, FLAG_POOLED);
@@ -309,23 +277,23 @@ public class PlatformMemoryUtils {
      */
     public static void releasePool(long poolPtr) {
         // Clean predefined memory chunks.
-        long mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_1);
+        long mem = GridUnsafe.getLong(poolPtr + POOL_HDR_OFF_MEM_1);
 
         if (mem != 0)
-            UNSAFE.freeMemory(mem);
+            GridUnsafe.freeMemory(mem);
 
-        mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_2);
+        mem = GridUnsafe.getLong(poolPtr + POOL_HDR_OFF_MEM_2);
 
         if (mem != 0)
-            UNSAFE.freeMemory(mem);
+            GridUnsafe.freeMemory(mem);
 
-        mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_3);
+        mem = GridUnsafe.getLong(poolPtr + POOL_HDR_OFF_MEM_3);
 
         if (mem != 0)
-            UNSAFE.freeMemory(mem);
+            GridUnsafe.freeMemory(mem);
 
         // Clean pool chunk.
-        UNSAFE.freeMemory(poolPtr);
+        GridUnsafe.freeMemory(poolPtr);
     }
 
     /**
@@ -376,24 +344,24 @@ public class PlatformMemoryUtils {
         assert isPooled(memPtr);
         assert !isAcquired(memPtr);
 
-        long data = UNSAFE.getLong(memPtr);
+        long data = GridUnsafe.getLong(memPtr);
 
         if (data == 0) {
             // First allocation of the chunk.
-            data = UNSAFE.allocateMemory(cap);
+            data = GridUnsafe.allocateMemory(cap);
 
-            UNSAFE.putLong(memPtr, data);
-            UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+            GridUnsafe.putLong(memPtr, data);
+            GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
         }
         else {
             // Ensure that we have enough capacity.
             int curCap = capacity(memPtr);
 
             if (cap > curCap) {
-                data = UNSAFE.reallocateMemory(data, cap);
+                data = GridUnsafe.reallocateMemory(data, cap);
 
-                UNSAFE.putLong(memPtr, data);
-                UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+                GridUnsafe.putLong(memPtr, data);
+                GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
             }
         }
 
@@ -411,17 +379,17 @@ public class PlatformMemoryUtils {
         assert isPooled(memPtr);
         assert isAcquired(memPtr);
 
-        long data = UNSAFE.getLong(memPtr);
+        long data = GridUnsafe.getLong(memPtr);
 
         assert data != 0;
 
         int curCap = capacity(memPtr);
 
         if (cap > curCap) {
-            data = UNSAFE.reallocateMemory(data, cap);
+            data = GridUnsafe.reallocateMemory(data, cap);
 
-            UNSAFE.putLong(memPtr, data);
-            UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+            GridUnsafe.putLong(memPtr, data);
+            GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
index 59d8981..cb30336 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
@@ -17,15 +17,7 @@
 
 package org.apache.ignite.internal.processors.platform.memory;
 
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.BOOLEAN_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.CHAR_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.DOUBLE_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.FLOAT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.INT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.LONG_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.SHORT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.UNSAFE;
+import org.apache.ignite.internal.util.GridUnsafe;
 
 /**
  * Interop output stream implementation.
@@ -59,12 +51,12 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
     @Override public void writeByte(byte val) {
         ensureCapacity(pos + 1);
 
-        UNSAFE.putByte(data + pos++, val);
+        GridUnsafe.putByte(data + pos++, val);
     }
 
     /** {@inheritDoc} */
     @Override public void writeByteArray(byte[] val) {
-        copyAndShift(val, BYTE_ARR_OFF, val.length);
+        copyAndShift(val, GridUnsafe.BYTE_ARR_OFF, val.length);
     }
 
     /** {@inheritDoc} */
@@ -74,63 +66,63 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
 
     /** {@inheritDoc} */
     @Override public void writeBooleanArray(boolean[] val) {
-        copyAndShift(val, BOOLEAN_ARR_OFF, val.length);
+        copyAndShift(val, GridUnsafe.BOOLEAN_ARR_OFF, val.length);
     }
 
     /** {@inheritDoc} */
     @Override public void writeShort(short val) {
         ensureCapacity(pos + 2);
 
-        UNSAFE.putShort(data + pos, val);
+        GridUnsafe.putShort(data + pos, val);
 
         shift(2);
     }
 
     /** {@inheritDoc} */
     @Override public void writeShortArray(short[] val) {
-        copyAndShift(val, SHORT_ARR_OFF, val.length << 1);
+        copyAndShift(val, GridUnsafe.SHORT_ARR_OFF, val.length << 1);
     }
 
     /** {@inheritDoc} */
     @Override public void writeChar(char val) {
         ensureCapacity(pos + 2);
 
-        UNSAFE.putChar(data + pos, val);
+        GridUnsafe.putChar(data + pos, val);
 
         shift(2);
     }
 
     /** {@inheritDoc} */
     @Override public void writeCharArray(char[] val) {
-        copyAndShift(val, CHAR_ARR_OFF, val.length << 1);
+        copyAndShift(val, GridUnsafe.CHAR_ARR_OFF, val.length << 1);
     }
 
     /** {@inheritDoc} */
     @Override public void writeInt(int val) {
         ensureCapacity(pos + 4);
 
-        UNSAFE.putInt(data + pos, val);
+        GridUnsafe.putInt(data + pos, val);
 
         shift(4);
     }
 
     /** {@inheritDoc} */
     @Override public void writeIntArray(int[] val) {
-        copyAndShift(val, INT_ARR_OFF, val.length << 2);
+        copyAndShift(val, GridUnsafe.INT_ARR_OFF, val.length << 2);
     }
 
     /** {@inheritDoc} */
     @Override public void writeShort(int pos, short val) {
         ensureCapacity(pos + 2);
 
-        UNSAFE.putShort(data + pos, val);
+        GridUnsafe.putShort(data + pos, val);
     }
 
     /** {@inheritDoc} */
     @Override public void writeInt(int pos, int val) {
         ensureCapacity(pos + 4);
 
-        UNSAFE.putInt(data + pos, val);
+        GridUnsafe.putInt(data + pos, val);
     }
 
     /** {@inheritDoc} */
@@ -140,21 +132,21 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
 
     /** {@inheritDoc} */
     @Override public void writeFloatArray(float[] val) {
-        copyAndShift(val, FLOAT_ARR_OFF, val.length << 2);
+        copyAndShift(val, GridUnsafe.FLOAT_ARR_OFF, val.length << 2);
     }
 
     /** {@inheritDoc} */
     @Override public void writeLong(long val) {
         ensureCapacity(pos + 8);
 
-        UNSAFE.putLong(data + pos, val);
+        GridUnsafe.putLong(data + pos, val);
 
         shift(8);
     }
 
     /** {@inheritDoc} */
     @Override public void writeLongArray(long[] val) {
-        copyAndShift(val, LONG_ARR_OFF, val.length << 3);
+        copyAndShift(val, GridUnsafe.LONG_ARR_OFF, val.length << 3);
     }
 
     /** {@inheritDoc} */
@@ -164,12 +156,12 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
 
     /** {@inheritDoc} */
     @Override public void writeDoubleArray(double[] val) {
-        copyAndShift(val, DOUBLE_ARR_OFF, val.length << 3);
+        copyAndShift(val, GridUnsafe.DOUBLE_ARR_OFF, val.length << 3);
     }
 
     /** {@inheritDoc} */
     @Override public void write(byte[] arr, int off, int len) {
-        copyAndShift(arr, BYTE_ARR_OFF + off, len);
+        copyAndShift(arr, GridUnsafe.BYTE_ARR_OFF + off, len);
     }
 
     /** {@inheritDoc} */
@@ -234,7 +226,7 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteByte(byte val) {
-        UNSAFE.putByte(data + pos++, val);
+        GridUnsafe.putByte(data + pos++, val);
     }
 
     /** {@inheritDoc} */
@@ -244,38 +236,38 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteShort(short val) {
-        UNSAFE.putShort(data + pos, val);
+        GridUnsafe.putShort(data + pos, val);
 
         shift(2);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteShort(int pos, short val) {
-        UNSAFE.putShort(data + pos, val);
+        GridUnsafe.putShort(data + pos, val);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteChar(char val) {
-        UNSAFE.putChar(data + pos, val);
+        GridUnsafe.putChar(data + pos, val);
 
         shift(2);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteInt(int val) {
-        UNSAFE.putInt(data + pos, val);
+        GridUnsafe.putInt(data + pos, val);
 
         shift(4);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteInt(int pos, int val) {
-        UNSAFE.putInt(data + pos, val);
+        GridUnsafe.putInt(data + pos, val);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteLong(long val) {
-        UNSAFE.putLong(data + pos, val);
+        GridUnsafe.putLong(data + pos, val);
 
         shift(8);
     }
@@ -335,7 +327,7 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
     private void copyAndShift(Object src, long off, int len) {
         ensureCapacity(pos + len);
 
-        UNSAFE.copyMemory(src, off, null, data + pos, len);
+        GridUnsafe.copyMemory(src, off, null, data + pos, len);
 
         shift(len);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
index 319a633..dd85bcf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
@@ -18,19 +18,14 @@
 package org.apache.ignite.internal.util;
 
 import java.util.Arrays;
-import sun.misc.Unsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.INT_ARR_OFF;
 
 /**
  * Lightweight identity hash table which maps objects to integer handles,
  * assigned in ascending order.
  */
 public class GridHandleTable {
-    /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
-    private static final long intArrOff = UNSAFE.arrayBaseOffset(int[].class);
-
     /** Number of mappings in table/next available handle. */
     private int size;
 
@@ -111,8 +106,8 @@ public class GridHandleTable {
      * Resets table to its initial (empty) state.
      */
     public void clear() {
-        UNSAFE.copyMemory(spineEmpty, intArrOff, spine, intArrOff, spineEmpty.length << 2);
-        UNSAFE.copyMemory(nextEmpty, intArrOff, next, intArrOff, nextEmpty.length << 2);
+        GridUnsafe.copyMemory(spineEmpty, INT_ARR_OFF, spine, INT_ARR_OFF, spineEmpty.length << 2);
+        GridUnsafe.copyMemory(nextEmpty, INT_ARR_OFF, next, INT_ARR_OFF, nextEmpty.length << 2);
 
         Arrays.fill(objs, null);
 
@@ -153,7 +148,7 @@ public class GridHandleTable {
 
         Arrays.fill(spineEmpty, -1);
 
-        UNSAFE.copyMemory(spineEmpty, intArrOff, spine, intArrOff, spineEmpty.length << 2);
+        GridUnsafe.copyMemory(spineEmpty, INT_ARR_OFF, spine, INT_ARR_OFF, spineEmpty.length << 2);
 
         for (int i = 0; i < this.size; i++) {
             Object obj = objs[i];
@@ -171,7 +166,7 @@ public class GridHandleTable {
         int newLen = (next.length << 1) + 1;
         int[] newNext = new int[newLen];
 
-        UNSAFE.copyMemory(next, intArrOff, newNext, intArrOff, size << 2);
+        GridUnsafe.copyMemory(next, INT_ARR_OFF, newNext, INT_ARR_OFF, size << 2);
 
         next = newNext;
         nextEmpty = new int[newLen];

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
index 3371eb8..8a0b0ae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
@@ -128,9 +128,6 @@ public final class GridJavaProcess {
     public static GridJavaProcess exec(String clsName, String params, @Nullable IgniteLogger log,
         @Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC,
         @Nullable String javaHome, @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
-        if (!(U.isLinux() || U.isMacOs() || U.isWindows()))
-            throw new Exception("Your OS is not supported.");
-
         GridJavaProcess gjProc = new GridJavaProcess();
 
         gjProc.log = log;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpinReadWriteLock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpinReadWriteLock.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpinReadWriteLock.java
index a1fa892..4f23979 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpinReadWriteLock.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpinReadWriteLock.java
@@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
 
 /**
  *
@@ -29,9 +28,6 @@ import sun.misc.Unsafe;
 @GridToStringExclude
 public class GridSpinReadWriteLock {
     /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
     private static final long PENDING_WLOCKS_OFFS;
 
     /** */
@@ -42,10 +38,10 @@ public class GridSpinReadWriteLock {
      */
     static {
         try {
-            STATE_OFFS = UNSAFE.objectFieldOffset(GridSpinReadWriteLock.class.getDeclaredField("state"));
+            STATE_OFFS = GridUnsafe.objectFieldOffset(GridSpinReadWriteLock.class.getDeclaredField("state"));
 
             PENDING_WLOCKS_OFFS =
-                UNSAFE.objectFieldOffset(GridSpinReadWriteLock.class.getDeclaredField("pendingWLocks"));
+                GridUnsafe.objectFieldOffset(GridSpinReadWriteLock.class.getDeclaredField("pendingWLocks"));
         }
         catch (NoSuchFieldException e) {
             throw new Error(e);
@@ -403,7 +399,7 @@ public class GridSpinReadWriteLock {
      * @return {@code True} on success.
      */
     private boolean compareAndSet(long offs, int expect, int update) {
-        return UNSAFE.compareAndSwapInt(this, offs, expect, update);
+        return GridUnsafe.compareAndSwapInt(this, offs, expect, update);
     }
 
     /** {@inheritDoc} */


[07/28] ignite git commit: 2224

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 93ff515..3bd87cf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -53,6 +53,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.cache.CacheMemoryMode;
 import org.apache.ignite.cache.CachePeekMode;
@@ -556,6 +557,30 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     /**
      * @throws Exception In case of error.
      */
+    public void testGetEntry() throws Exception {
+        IgniteCache<String, Integer> cache = jcache();
+
+        cache.put("key1", 1);
+        cache.put("key2", 2);
+
+        CacheEntry<String, Integer> key1e =  cache.getEntry("key1");
+        CacheEntry<String, Integer> key2e =  cache.getEntry("key2");
+        CacheEntry<String, Integer> wrongKeye =  cache.getEntry("wrongKey");
+
+        assert key1e.getValue() == 1;
+        assert key1e.getKey().equals("key1");
+        assert key1e.version() != null;
+
+        assert key2e.getValue() == 2;
+        assert key2e.getKey().equals("key2");
+        assert key2e.version() != null;
+
+        assert wrongKeye == null;
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
     public void testGetAsync() throws Exception {
         IgniteCache<String, Integer> cache = jcache();
 
@@ -664,6 +689,122 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     /**
      * @throws Exception In case of error.
      */
+    public void testGetEntries() throws Exception {
+        Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+        final IgniteCache<String, Integer> cache = jcache();
+
+        try {
+            cache.put("key1", 1);
+            cache.put("key2", 2);
+
+            if (tx != null)
+                tx.commit();
+        }
+        finally {
+            if (tx != null)
+                tx.close();
+        }
+
+        GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                cache.getEntries(null).isEmpty();
+
+                return null;
+            }
+        }, NullPointerException.class, null);
+
+        assert cache.getEntries(Collections.<String>emptySet()).isEmpty();
+
+        Collection<CacheEntry<String, Integer>> c1 = cache.getEntries(ImmutableSet.of("key1", "key2", "key9999"));
+
+        info("Retrieved c1: " + c1);
+
+        assert 2 == c1.size() : "Invalid collection: " + c1;
+
+        boolean b1 = false;
+        boolean b2 = false;
+
+        for (CacheEntry<String, Integer> e: c1){
+            if (e.getKey().equals("key1") && e.getValue().equals(1))
+                b1 = true;
+
+            if (e.getKey().equals("key2") && e.getValue().equals(2))
+                b2 = true;
+        }
+
+        assertTrue(b1 && b2);
+
+        Collection<CacheEntry<String, Integer>> c2 = cache.getEntries(ImmutableSet.of("key1", "key2", "key9999"));
+
+        info("Retrieved c2: " + c2);
+
+        assert 2 == c2.size() : "Invalid collection: " + c2;
+
+        b1 = false;
+        b2 = false;
+
+        for (CacheEntry<String, Integer> e: c2){
+            if (e.getKey().equals("key1") && e.getValue().equals(1))
+                b1 = true;
+
+            if (e.getKey().equals("key2") && e.getValue().equals(2))
+                b2 = true;
+        }
+
+        assertTrue(b1 && b2);
+
+        // Now do the same checks but within transaction.
+        if (txShouldBeUsed()) {
+            try (Transaction tx0 = transactions().txStart()) {
+                assert cache.getEntries(Collections.<String>emptySet()).isEmpty();
+
+                c1 = cache.getEntries(ImmutableSet.of("key1", "key2", "key9999"));
+
+                info("Retrieved c1: " + c1);
+
+                assert 2 == c1.size() : "Invalid collection: " + c1;
+
+                b1 = false;
+                b2 = false;
+
+                for (CacheEntry<String, Integer> e : c1) {
+                    if (e.getKey().equals("key1") && e.getValue().equals(1))
+                        b1 = true;
+
+                    if (e.getKey().equals("key2") && e.getValue().equals(2))
+                        b2 = true;
+                }
+
+                assertTrue(b1 && b2);
+
+                c2 = cache.getEntries(ImmutableSet.of("key1", "key2", "key9999"));
+
+                info("Retrieved c2: " + c2);
+
+                assert 2 == c2.size() : "Invalid collection: " + c2;
+
+                b1 = false;
+                b2 = false;
+
+                for (CacheEntry<String, Integer> e : c2) {
+                    if (e.getKey().equals("key1") && e.getValue().equals(1))
+                        b1 = true;
+
+                    if (e.getKey().equals("key2") && e.getValue().equals(2))
+                        b2 = true;
+                }
+
+                assertTrue(b1 && b2);
+
+                tx0.commit();
+            }
+        }
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
     public void testGetAllWithNulls() throws Exception {
         final IgniteCache<String, Integer> cache = jcache();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
index c57869f..f50a3e0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -29,6 +30,7 @@ import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.cache.CacheInterceptor;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.affinity.Affinity;
@@ -152,19 +154,32 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
      * @throws Exception If failed.
      */
     public void testGet() throws Exception {
-        testGet(primaryKey(0));
+        testGet(primaryKey(0), false);
 
         afterTest();
 
         if (cacheMode() != LOCAL)
-            testGet(backupKey(0));
+            testGet(backupKey(0), false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testGetEntry() throws Exception {
+        testGet(primaryKey(0), true);
+
+        afterTest();
+
+        if (cacheMode() != LOCAL)
+            testGet(backupKey(0), true);
     }
 
     /**
      * @param key Key.
+     * @param needVer Need version.
      * @throws Exception If failed.
      */
-    private void testGet(String key) throws Exception {
+    private void testGet(String key, boolean needVer) throws Exception {
         // Try when value is not in cache.
 
         interceptor.retInterceptor = new NullGetInterceptor();
@@ -173,7 +188,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         IgniteCache<String, Integer> cache = jcache(0);
 
-        assertEquals(null, cache.get(key));
+        assertEquals(null, needVer ? cache.getEntry(key) : cache.get(key));
 
         assertEquals(1, interceptor.invokeCnt.get());
 
@@ -185,7 +200,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         log.info("Get 2.");
 
-        assertEquals((Integer)1, cache.get(key));
+        assertEquals((Integer)1, needVer ? cache.getEntry(key).getValue() : cache.get(key));
 
         assertEquals(1, interceptor.invokeCnt.get());
 
@@ -207,7 +222,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         log.info("Get 3.");
 
-        assertEquals(null, cache.get(key));
+        assertEquals(null, needVer ? cache.getEntry(key) : cache.get(key));
 
         assertEquals(1, interceptor.invokeCnt.get());
 
@@ -223,7 +238,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         log.info("Get 4.");
 
-        assertEquals((Integer)101, cache.get(key));
+        assertEquals((Integer)101, needVer ? cache.getEntry(key).getValue() : cache.get(key));
 
         assertEquals(1, interceptor.invokeCnt.get());
 
@@ -241,9 +256,16 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         IgniteCache<String, Integer> cacheAsync = cache.withAsync();
 
-        cacheAsync.get(key);
+        if (needVer) {
+            cacheAsync.getEntry(key);
 
-        assertEquals((Integer)101, cacheAsync.<Integer>future().get());
+            assertEquals((Integer)101, cacheAsync.<CacheEntry<String, Integer>>future().get().getValue());
+        }
+        else {
+            cacheAsync.get(key);
+
+            assertEquals((Integer)101, cacheAsync.<Integer>future().get());
+        }
 
         assertEquals(1, interceptor.invokeCnt.get());
 
@@ -258,6 +280,20 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
      * @throws Exception If failed.
      */
     public void testGetAll() throws Exception {
+        testGetAll(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testGetEntries() throws Exception {
+        testGetAll(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void testGetAll(boolean needVer) throws Exception {
         Set<String> keys = new LinkedHashSet<>();
 
         for (int i = 0; i < 1000; i++)
@@ -269,10 +305,19 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         IgniteCache<String, Integer> cacheAsync = cache.withAsync();
 
-        Map<String, Integer> map = cache.getAll(keys);
+        Collection<CacheEntry<String, Integer>> c;
+        Map<String, Integer> map;
+
+        if (needVer){
+            c = cache.getEntries(keys);
 
-        for (String key : keys)
-            assertEquals(null, map.get(key));
+            assertTrue(c.isEmpty());
+        }else {
+            map = cache.getAll(keys);
+
+            for (String key : keys)
+                assertEquals(null, map.get(key));
+        }
 
         assertEquals(1000, interceptor.invokeCnt.get());
 
@@ -280,15 +325,28 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         interceptor.retInterceptor = new GetAllInterceptor1();
 
-        map = cache.getAll(keys);
+        if (needVer) {
+            c = cache.getEntries(keys);
 
-        for (String key : keys) {
-            int k = Integer.valueOf(key);
+            assertEquals(500, c.size());
 
-            if (k % 2 == 0)
-                assertEquals(null, map.get(key));
-            else
-                assertEquals((Integer)(k * 2), map.get(key));
+            for (CacheEntry<String, Integer> e : c) {
+                int k = Integer.valueOf(e.getKey());
+
+                assertEquals((Integer)(k * 2), e.getValue());
+            }
+        }
+        else {
+            map = cache.getAll(keys);
+
+            for (String key : keys) {
+                int k = Integer.valueOf(key);
+
+                if (k % 2 == 0)
+                    assertEquals(null, map.get(key));
+                else
+                    assertEquals((Integer)(k * 2), map.get(key));
+            }
         }
 
         assertEquals(1000, interceptor.invokeCnt.get());
@@ -307,40 +365,72 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
             interceptor.retInterceptor = new GetAllInterceptor2();
 
-            if (j == 0)
-                map = cache.getAll(keys);
-            else {
-                cacheAsync.getAll(keys);
+            if (needVer) {
+                if (j == 0)
+                    c = cache.getEntries(keys);
+                else {
+                    cacheAsync.getEntries(keys);
+
+                    c = cacheAsync.<Collection<CacheEntry<String, Integer>>>future().get();
+                }
+
+                for (CacheEntry<String, Integer> e : c) {
+                    int k = Integer.valueOf(e.getKey());
+
+                    switch (k % 3) {
+                        case 1:
+                            Integer exp = k < 500 ? k : null;
 
-                map = cacheAsync.<Map<String, Integer>>future().get();
+                            assertEquals(exp, e.getValue());
+
+                            break;
+
+                        case 2:
+                            assertEquals((Integer)(k * 3), e.getValue());
+
+                            break;
+
+                        default:
+                            fail();
+                    }
+                }
             }
+            else {
+                if (j == 0)
+                    map = cache.getAll(keys);
+                else {
+                    cacheAsync.getAll(keys);
 
-            int i = 0;
+                    map = cacheAsync.<Map<String, Integer>>future().get();
+                }
 
-            for (String key : keys) {
-                switch (i % 3) {
-                    case 0:
-                        assertEquals(null, map.get(key));
+                int i = 0;
 
-                        break;
+                for (String key : keys) {
+                    switch (i % 3) {
+                        case 0:
+                            assertEquals(null, map.get(key));
 
-                    case 1:
-                        Integer exp = i < 500 ? i : null;
+                            break;
 
-                        assertEquals(exp, map.get(key));
+                        case 1:
+                            Integer exp = i < 500 ? i : null;
 
-                        break;
+                            assertEquals(exp, map.get(key));
 
-                    case 2:
-                        assertEquals((Integer)(i * 3), map.get(key));
+                            break;
 
-                        break;
+                        case 2:
+                            assertEquals((Integer)(i * 3), map.get(key));
 
-                    default:
-                        fail();
-                }
+                            break;
 
-                i++;
+                        default:
+                            fail();
+                    }
+
+                    i++;
+                }
             }
 
             assertEquals(1000, interceptor.invokeCnt.get());

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
index 6a7416e..293ba1e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
@@ -263,7 +263,7 @@ public class GridCacheDhtEvictionNearReadersSelfTest extends GridCommonAbstractT
             waitForLocalEvent(grid(primary).events(), nodeEvent(primary.id()), EVT_CACHE_ENTRY_EVICTED);
 
         // Get value on other node, it should be loaded to near cache.
-        assertEquals(val, nearOther.get(key, true));
+        assertEquals(val, nearOther.get(key, true, false));
 
         entryPrimary = (GridDhtCacheEntry)dhtPrimary.peekEx(key);
         entryBackup = (GridDhtCacheEntry)dhtBackup.peekEx(key);

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 035f1b0..7286fb3 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -34,6 +34,7 @@ import javax.cache.processor.EntryProcessorResult;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.cache.CacheMetrics;
 import org.apache.ignite.cache.CachePeekMode;
@@ -129,7 +130,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) 
+    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
         throws CacheException {
         throw new UnsupportedOperationException("Method should be supported.");
     }
@@ -224,11 +225,21 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
+    @Override public CacheEntry<K, V> getEntry(K key) {
+        return compute.call(new GetEntryTask<K, V>(cacheName, isAsync, key));
+    }
+
+    /** {@inheritDoc} */
     @Override public Map<K, V> getAll(Set<? extends K> keys) {
         return compute.call(new GetAllTask<K, V>(cacheName, isAsync, keys));
     }
 
     /** {@inheritDoc} */
+    @Override public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys) {
+        return compute.call(new GetEntriesTask<K, V>(cacheName, isAsync, keys));
+    }
+
+    /** {@inheritDoc} */
     @Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
         return compute.call(new GetAllOutTxTask<K, V>(cacheName, isAsync, keys));
     }
@@ -710,6 +721,29 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     /**
      *
      */
+    private static class GetEntryTask<K, V> extends CacheTaskAdapter<K, V, CacheEntry<K, V>> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public GetEntryTask(String cacheName, boolean async, K key) {
+            super(cacheName, async);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public CacheEntry<K, V> call() throws Exception {
+            return cache().getEntry(key);
+        }
+    }
+
+    /**
+     *
+     */
     private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
         /**
          * @param cacheName Cache name.
@@ -973,6 +1007,29 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     /**
      *
      */
+    private static class GetEntriesTask<K, V> extends CacheTaskAdapter<K, V, Collection<CacheEntry<K, V>> > {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public GetEntriesTask(String cacheName, boolean async, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Collection<CacheEntry<K, V>>  call() throws Exception {
+            return cache().getEntries(keys);
+        }
+    }
+
+    /**
+     *
+     */
     private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
         /** Keys. */
         private final Set<? extends K> keys;

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index 68e52df..45679dd 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -19,6 +19,12 @@ package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListenerSelfTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticReadCommittedSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticRepeatableReadSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticSerializableSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticReadCommittedSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticRepeatableReadSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticSerializableSeltTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheGetCustomCollectionsSelfTest;
 import org.apache.ignite.internal.processors.GridCacheTxLoadFromStoreOnLockSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheClientStoreSelfTest;
@@ -241,6 +247,12 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteSystemCacheOnClientTest.class);
 
         suite.addTestSuite(CacheRemoveAllSelfTest.class);
+        suite.addTestSuite(CacheGetEntryOptimisticReadCommittedSeltTest.class);
+        suite.addTestSuite(CacheGetEntryOptimisticRepeatableReadSeltTest.class);
+        suite.addTestSuite(CacheGetEntryOptimisticSerializableSeltTest.class);
+        suite.addTestSuite(CacheGetEntryPessimisticReadCommittedSeltTest.class);
+        suite.addTestSuite(CacheGetEntryPessimisticRepeatableReadSeltTest.class);
+        suite.addTestSuite(CacheGetEntryPessimisticSerializableSeltTest.class);
 
         suite.addTestSuite(CacheStopAndDestroySelfTest.class);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/yardstick/config/benchmark-multicast.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-multicast.properties b/modules/yardstick/config/benchmark-multicast.properties
index c638d94..0428c73 100644
--- a/modules/yardstick/config/benchmark-multicast.properties
+++ b/modules/yardstick/config/benchmark-multicast.properties
@@ -89,10 +89,14 @@ j=10
 CONFIGS="\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutBenchmark -sn IgniteNode -ds ${ver}atomic-put-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetEntryBenchmark -sn IgniteNode -ds ${ver}atomic-put-getEntry-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutTxImplicitBenchmark -sn IgniteNode -ds ${ver}tx-optimistic-put-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc OPTIMISTIC -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-optim-repRead-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc OPTIMISTIC -dn IgnitePutGetEntryTxBenchmark -sn IgniteNode -ds ${ver}tx-optim-repRead-put-getEntry-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc PESSIMISTIC -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-pessim-repRead-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc PESSIMISTIC -dn IgnitePutGetEntryTxBenchmark -sn IgniteNode -ds ${ver}tx-pessim-repRead-put-getEntry-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc OPTIMISTIC -txi SERIALIZABLE -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-opt-serial-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc OPTIMISTIC -txi SERIALIZABLE -dn IgnitePutGetEntryTxBenchmark -sn IgniteNode -ds ${ver}tx-opt-serial-put-getEntry-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryBenchmark -sn IgniteNode -ds ${ver}sql-query-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryJoinBenchmark -sn IgniteNode -ds ${ver}sql-query-join-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryPutBenchmark -sn IgniteNode -ds ${ver}sql-query-put-1-backup,\
@@ -114,6 +118,9 @@ CONFIGS="\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-putAll-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllSerializableTxBenchmark -sn IgniteNode -ds ${ver}tx-putAllSerializable-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc OPTIMISTIC  -dn IgniteGetAllPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-optimistic-getAllPutAll-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc OPTIMISTIC  -dn IgniteGetEntriesPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-optimistic-getEntriesPutAll-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc PESSIMISTIC -dn IgniteGetAllPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-pessimistic-getAllPutAll-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc PESSIMISTIC -dn IgniteGetEntriesPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-pessimistic-getEntriesPutAll-1-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc OPTIMISTIC -txi SERIALIZABLE -dn IgniteGetAllPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-opt-serializable-getAllPutAll-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc OPTIMISTIC -txi SERIALIZABLE -dn IgniteGetEntriesPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-opt-serializable-getEntriesPutAll-1-backup,\
 "

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java
new file mode 100644
index 0000000..501e12d
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java
@@ -0,0 +1,73 @@
+/*
+ * 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.yardstick.cache;
+
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.apache.ignite.yardstick.IgniteBenchmarkUtils.doInTransaction;
+
+/**
+ * Ignite benchmark that performs transactional putAll operations.
+ */
+public class IgniteGetEntriesPutAllTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Integer> {
+    /** */
+    private IgniteTransactions txs;
+
+    /** {@inheritDoc} */
+    @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        txs = ignite().transactions();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        final ThreadRange r = threadRange();
+
+        doInTransaction(txs, args.txConcurrency(), args.txIsolation(), new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                SortedMap<Integer, Integer> vals = new TreeMap<>();
+
+                for (int i = 0; i < args.batch(); i++) {
+                    int key = r.nextRandom();
+
+                    vals.put(key, key);
+                }
+
+                cache.getEntries(vals.keySet());
+
+                cache.putAll(vals);
+
+                return null;
+            }
+        });
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Integer, Integer> cache() {
+        return ignite().cache("tx");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java
new file mode 100644
index 0000000..1289fa1
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java
@@ -0,0 +1,47 @@
+/*
+ * 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.yardstick.cache;
+
+import java.util.Map;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+
+/**
+ * Ignite benchmark that performs put and get operations.
+ */
+public class IgnitePutGetEntryBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        int key = nextRandom(args.range());
+
+        CacheEntry<Integer, Object> val = cache.getEntry(key);
+
+        if (val != null)
+            key = nextRandom(args.range());
+
+        cache.put(key, new SampleValue(key));
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Integer, Object> cache() {
+        return ignite().cache("atomic");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java
new file mode 100644
index 0000000..6e58b41
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java
@@ -0,0 +1,73 @@
+/*
+ * 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.yardstick.cache;
+
+import java.util.Map;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.apache.ignite.yardstick.IgniteBenchmarkUtils.doInTransaction;
+
+/**
+ * Ignite benchmark that performs transactional put and get operations.
+ */
+public class IgnitePutGetEntryTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
+    /** */
+    private IgniteTransactions txs;
+
+    /** */
+    private Callable<Void> clo;
+
+    /** {@inheritDoc} */
+    @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        txs = ignite().transactions();
+
+        clo = new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                int key = nextRandom(0, args.range() / 2);
+
+                CacheEntry<Integer, Object> val = cache.getEntry(key);
+
+                if (val != null)
+                    key = nextRandom(args.range() / 2, args.range());
+
+                cache.put(key, new SampleValue(key));
+
+                return null;
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        doInTransaction(txs, args.txConcurrency(), args.txIsolation(), clo);
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Integer, Object> cache() {
+        return ignite().cache("tx");
+    }
+}


[23/28] ignite git commit: IGNITE-2454 Fixed "Continuous query notification missed if there is only one node".

Posted by vo...@apache.org.
IGNITE-2454 Fixed "Continuous query notification missed if there is only one node".


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

Branch: refs/heads/ignite-2508
Commit: 60c8b072dc08d92e45da2404be09031af165ae48
Parents: e6acce6
Author: Tikhonov Nikolay <ti...@gmail.com>
Authored: Wed Feb 3 13:06:14 2016 +0300
Committer: Tikhonov Nikolay <ti...@gmail.com>
Committed: Wed Feb 3 13:06:14 2016 +0300

----------------------------------------------------------------------
 .../continuous/CacheContinuousQueryHandler.java |   9 +
 ...ntinuousQueryPartitionAtomicOneNodeTest.java |  37 ++++
 ...heContinuousQueryPartitionTxOneNodeTest.java |  37 ++++
 ...tinuousQueryReplicatedAtomicOneNodeTest.java |  31 +++
 ...ontinuousQueryReplicatedOneNodeSelfTest.java | 120 ------------
 ...eContinuousQueryReplicatedTxOneNodeTest.java | 193 +++++++++++++++++++
 .../IgniteCacheQuerySelfTestSuite.java          |  10 +-
 7 files changed, 315 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index fa54a6b..7e66ad3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -754,6 +754,15 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
             List<CacheContinuousQueryEntry> entries;
 
             synchronized (pendingEvts) {
+                // Received first event.
+                if (curTop == AffinityTopologyVersion.NONE) {
+                    lastFiredEvt = entry.updateCounter();
+
+                    curTop = entry.topologyVersion();
+
+                    return F.asList(entry);
+                }
+
                 if (curTop.compareTo(entry.topologyVersion()) < 0) {
                     if (entry.updateCounter() == 1L && !entry.isBackup()) {
                         entries = new ArrayList<>(pendingEvts.size());

http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionAtomicOneNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionAtomicOneNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionAtomicOneNodeTest.java
new file mode 100644
index 0000000..797882b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionAtomicOneNodeTest.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.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+
+/**
+ *
+ */
+public class GridCacheContinuousQueryPartitionAtomicOneNodeTest
+    extends GridCacheContinuousQueryReplicatedTxOneNodeTest {
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicityMode atomicMode() {
+        return CacheAtomicityMode.ATOMIC;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return CacheMode.PARTITIONED;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionTxOneNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionTxOneNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionTxOneNodeTest.java
new file mode 100644
index 0000000..7dd7bd7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionTxOneNodeTest.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.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+
+/**
+ *
+ */
+public class GridCacheContinuousQueryPartitionTxOneNodeTest
+    extends GridCacheContinuousQueryReplicatedTxOneNodeTest {
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicityMode atomicMode() {
+        return CacheAtomicityMode.TRANSACTIONAL;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return CacheMode.PARTITIONED;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicOneNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicOneNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicOneNodeTest.java
new file mode 100644
index 0000000..066afa9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicOneNodeTest.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.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheAtomicityMode;
+
+/**
+ *
+ */
+public class GridCacheContinuousQueryReplicatedAtomicOneNodeTest
+    extends GridCacheContinuousQueryReplicatedTxOneNodeTest {
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicityMode atomicMode() {
+        return CacheAtomicityMode.ATOMIC;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
deleted file mode 100644
index 8152b2a..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.query.continuous;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.cache.event.CacheEntryEvent;
-import javax.cache.event.CacheEntryListenerException;
-import javax.cache.event.CacheEntryUpdatedListener;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.CacheRebalanceMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.cache.query.ContinuousQuery;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- * Test for replicated cache with one node.
- */
-public class GridCacheContinuousQueryReplicatedOneNodeSelfTest extends GridCommonAbstractTest {
-    /** IP finder. */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
-        cacheCfg.setCacheMode(CacheMode.REPLICATED);
-        cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
-        cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-
-        cfg.setCacheConfiguration(cacheCfg);
-
-        TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-        disco.setIpFinder(IP_FINDER);
-
-        cfg.setDiscoverySpi(disco);
-
-        return cfg;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testLocal() throws Exception {
-        doTest(true);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testDistributed() throws Exception {
-        doTest(false);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    private void doTest(boolean loc) throws Exception {
-        try {
-            IgniteCache<String, Integer> cache = startGrid(0).cache(null);
-
-            ContinuousQuery<String, Integer> qry = new ContinuousQuery<>();
-
-            final AtomicInteger cnt = new AtomicInteger();
-            final CountDownLatch latch = new CountDownLatch(10);
-
-            qry.setLocalListener(new CacheEntryUpdatedListener<String, Integer>() {
-                @Override
-                public void onUpdated(Iterable<CacheEntryEvent<? extends String, ? extends Integer>> evts)
-                        throws CacheEntryListenerException {
-                    for (CacheEntryEvent<? extends String, ? extends Integer> evt : evts) {
-                        cnt.incrementAndGet();
-                        latch.countDown();
-                    }
-                }
-            });
-
-            cache.query(qry.setLocal(loc));
-
-            startGrid(1);
-
-            awaitPartitionMapExchange();
-
-            for (int i = 0; i < 10; i++)
-                cache.put("key" + i, i);
-
-            assert latch.await(5000, TimeUnit.MILLISECONDS);
-
-            assertEquals(10, cnt.get());
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java
new file mode 100644
index 0000000..271a8d9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.processors.cache.query.continuous;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test for replicated cache with one node.
+ */
+@SuppressWarnings("Duplicates")
+public class GridCacheContinuousQueryReplicatedTxOneNodeTest extends GridCommonAbstractTest {
+    /** IP finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        CacheConfiguration cacheCfg = defaultCacheConfiguration();
+
+        cacheCfg.setAtomicityMode(atomicMode());
+        cacheCfg.setCacheMode(cacheMode());
+        cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+        cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+        cfg.setCacheConfiguration(cacheCfg);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /**
+     * @return Atomicity mode for a cache.
+     */
+    protected CacheAtomicityMode atomicMode() {
+        return CacheAtomicityMode.TRANSACTIONAL;
+    }
+
+    /**
+     * @return Cache mode.
+     */
+    protected CacheMode cacheMode() {
+        return CacheMode.REPLICATED;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLocal() throws Exception {
+        if (cacheMode() == CacheMode.REPLICATED)
+            doTest(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDistributed() throws Exception {
+        doTest(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLocalOneNode() throws Exception {
+        doTestOneNode(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDistributedOneNode() throws Exception {
+        doTestOneNode(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void doTest(boolean loc) throws Exception {
+        try {
+            IgniteCache<String, Integer> cache = startGrid(0).cache(null);
+
+            ContinuousQuery<String, Integer> qry = new ContinuousQuery<>();
+
+            final AtomicInteger cnt = new AtomicInteger();
+            final CountDownLatch latch = new CountDownLatch(10);
+
+            qry.setLocalListener(new CacheEntryUpdatedListener<String, Integer>() {
+                @Override
+                public void onUpdated(Iterable<CacheEntryEvent<? extends String, ? extends Integer>> evts)
+                        throws CacheEntryListenerException {
+                    for (CacheEntryEvent<? extends String, ? extends Integer> evt : evts) {
+                        cnt.incrementAndGet();
+                        latch.countDown();
+                    }
+                }
+            });
+
+            cache.query(qry.setLocal(loc));
+
+            startGrid(1);
+
+            awaitPartitionMapExchange();
+
+            for (int i = 0; i < 10; i++)
+                cache.put("key" + i, i);
+
+            assert latch.await(5000, TimeUnit.MILLISECONDS);
+
+            assertEquals(10, cnt.get());
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void doTestOneNode(boolean loc) throws Exception {
+        try {
+            IgniteCache<String, Integer> cache = startGrid(0).cache(null);
+
+            ContinuousQuery<String, Integer> qry = new ContinuousQuery<>();
+
+            final AtomicInteger cnt = new AtomicInteger();
+            final CountDownLatch latch = new CountDownLatch(10);
+
+            for (int i = 0; i < 10; i++)
+                cache.put("key" + i, i);
+
+            cache.clear();
+
+            qry.setLocalListener(new CacheEntryUpdatedListener<String, Integer>() {
+                @Override public void onUpdated(Iterable<CacheEntryEvent<? extends String, ? extends Integer>> evts)
+                        throws CacheEntryListenerException {
+                    for (CacheEntryEvent<? extends String, ? extends Integer> evt : evts) {
+                        cnt.incrementAndGet();
+                        latch.countDown();
+                    }
+                }
+            });
+
+            cache.query(qry.setLocal(loc));
+
+            for (int i = 0; i < 10; i++)
+                cache.put("key" + i, i);
+
+            assert latch.await(5000, TimeUnit.MILLISECONDS);
+
+            assertEquals(10, cnt.get());
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 4b1eafa..359cdf3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -79,11 +79,14 @@ import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheCon
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalAtomicSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionAtomicOneNodeTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionTxOneNodeTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedOnlySelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedP2PDisabledSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicOneNodeTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedOneNodeSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedTxOneNodeTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedP2PDisabledSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedSelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryTxSelfTest;
@@ -181,7 +184,10 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheContinuousQueryAtomicSelfTest.class);
         suite.addTestSuite(GridCacheContinuousQueryAtomicNearEnabledSelfTest.class);
         suite.addTestSuite(GridCacheContinuousQueryAtomicP2PDisabledSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryReplicatedOneNodeSelfTest.class);
+        suite.addTestSuite(GridCacheContinuousQueryReplicatedTxOneNodeTest.class);
+        suite.addTestSuite(GridCacheContinuousQueryReplicatedAtomicOneNodeTest.class);
+        suite.addTestSuite(GridCacheContinuousQueryPartitionTxOneNodeTest.class);
+        suite.addTestSuite(GridCacheContinuousQueryPartitionAtomicOneNodeTest.class);
         suite.addTestSuite(IgniteCacheContinuousQueryClientTest.class);
         suite.addTestSuite(IgniteCacheContinuousQueryClientReconnectTest.class);
         suite.addTestSuite(IgniteCacheContinuousQueryClientTxReconnectTest.class);


[21/28] ignite git commit: Minor exception message fix

Posted by vo...@apache.org.
Minor exception message fix


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

Branch: refs/heads/ignite-2508
Commit: 57194e2a6bb82719d63f658f8c1429569003214e
Parents: a87decd
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Tue Feb 2 16:35:42 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Tue Feb 2 16:35:42 2016 -0800

----------------------------------------------------------------------
 .../core/src/main/java/org/apache/ignite/internal/IgnitionEx.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/57194e2a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 8f23b05..193e28e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -118,7 +118,6 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_PUBLIC_KEEP_ALIVE_TIME;
 import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_PUBLIC_THREADPOOL_QUEUE_CAP;
 import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_SYSTEM_KEEP_ALIVE_TIME;
-import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_SYSTEM_MAX_THREAD_CNT;
 import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_SYSTEM_THREADPOOL_QUEUE_CAP;
 import static org.apache.ignite.internal.IgniteComponentType.SPRING;
 import static org.apache.ignite.plugin.segmentation.SegmentationPolicy.RESTART_JVM;
@@ -986,7 +985,7 @@ public class IgnitionEx {
 
         if (old != null) {
             if (name == null)
-                throw new IgniteCheckedException("Default grid instance has already been started.");
+                throw new IgniteCheckedException("Default Ignite instance has already been started.");
             else
                 throw new IgniteCheckedException("Ignite instance with this name has already been started: " + name);
         }


[11/28] ignite git commit: IGNITE-1906: .NET: Implemented programmatic configuration.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
new file mode 100644
index 0000000..25adf56
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
@@ -0,0 +1,133 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Discovery.Tcp.Multicast
+{
+    using System;
+    using System.ComponentModel;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+    /// <summary>
+    /// Multicast-based IP finder.
+    /// <para />
+    /// When TCP discovery starts this finder sends multicast request and waits
+    /// for some time when others nodes reply to this request with messages containing their addresses
+    /// </summary>
+    public class TcpDiscoveryMulticastIpFinder : TcpDiscoveryStaticIpFinder
+    {
+        /// <summary>
+        /// Default multicast port.
+        /// </summary>
+        public const int DefaultMulticastPort = 47400;
+
+        /// <summary>
+        /// Default address request attempts.
+        /// </summary>
+        public const int DefaultAddressRequestAttempts = 2;
+
+        /// <summary>
+        /// Default response timeout.
+        /// </summary>
+        public static readonly TimeSpan DefaultResponseTimeout = TimeSpan.FromMilliseconds(500);
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TcpDiscoveryMulticastIpFinder"/> class.
+        /// </summary>
+        public TcpDiscoveryMulticastIpFinder()
+        {
+            MulticastPort = DefaultMulticastPort;
+            AddressRequestAttempts = DefaultAddressRequestAttempts;
+            ResponseTimeout = DefaultResponseTimeout;
+        }
+
+        /// <summary>
+        /// Gets or sets the local address.
+        /// If provided address is non-loopback then multicast socket is bound to this interface. 
+        /// If local address is not set or is any local address then IP finder
+        /// creates multicast sockets for all found non-loopback addresses.
+        /// </summary>
+        public string LocalAddress { get; set; }
+
+        /// <summary>
+        /// Gets or sets the IP address of the multicast group.
+        /// </summary>
+        public string MulticastGroup { get; set; }
+
+        /// <summary>
+        /// Gets or sets the port number which multicast messages are sent to.
+        /// </summary>
+        [DefaultValue(DefaultMulticastPort)]
+        public int MulticastPort { get; set; }
+
+        /// <summary>
+        /// Gets or sets the number of attempts to send multicast address request. IP finder re-sends
+        /// request only in case if no reply for previous request is received.
+        /// </summary>
+        [DefaultValue(DefaultAddressRequestAttempts)]
+        public int AddressRequestAttempts { get; set; }
+
+        /// <summary>
+        /// Gets or sets the response timeout.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:00.5")]
+        public TimeSpan ResponseTimeout { get; set; }
+
+        /// <summary>
+        /// Gets or sets the time to live for multicast packets sent out on this
+        /// IP finder in order to control the scope of the multicast.
+        /// </summary>
+        public byte? TimeToLive { get; set; }  // TODO: Nullable?
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TcpDiscoveryMulticastIpFinder"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        internal TcpDiscoveryMulticastIpFinder(IBinaryRawReader reader) : base(reader)
+        {
+            LocalAddress = reader.ReadString();
+            MulticastGroup = reader.ReadString();
+            MulticastPort = reader.ReadInt();
+            AddressRequestAttempts = reader.ReadInt();
+            ResponseTimeout = TimeSpan.FromMilliseconds(reader.ReadInt());
+            TimeToLive = reader.ReadBoolean() ? (byte?) reader.ReadInt() : null;
+        }
+
+        /** <inheritdoc /> */
+        internal override void Write(IBinaryRawWriter writer)
+        {
+            base.Write(writer);
+
+            writer.WriteString(LocalAddress);
+            writer.WriteString(MulticastGroup);
+            writer.WriteInt(MulticastPort);
+            writer.WriteInt(AddressRequestAttempts);
+            writer.WriteInt((int) ResponseTimeout.TotalMilliseconds);
+
+            writer.WriteBoolean(TimeToLive.HasValue);
+
+            if (TimeToLive.HasValue)
+                writer.WriteInt(TimeToLive.Value);
+        }
+
+        /** <inheritdoc /> */
+        protected override byte TypeCode
+        {
+            get { return TypeCodeMulticastIpFinder; }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
new file mode 100644
index 0000000..331ca48
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Discovery.Tcp.Static
+{
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// IP Finder which works only with pre-configured list of IP addresses.
+    /// </summary>
+    public class TcpDiscoveryStaticIpFinder : TcpDiscoveryIpFinderBase
+    {
+        /// <summary>
+        /// Gets or sets the end points.
+        /// </summary>
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public ICollection<string> Endpoints { get; set; }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TcpDiscoveryStaticIpFinder"/> class.
+        /// </summary>
+        public TcpDiscoveryStaticIpFinder()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TcpDiscoveryStaticIpFinder"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        internal TcpDiscoveryStaticIpFinder(IBinaryRawReader reader)
+        {
+            var count = reader.ReadInt();
+
+            if (count > 0)
+            {
+                Endpoints = new List<string>(count);
+
+                for (int i = 0; i < count; i++)
+                    Endpoints.Add(reader.ReadString());
+            }
+        }
+
+        /** <inheritdoc /> */
+        internal override void Write(IBinaryRawWriter writer)
+        {
+            base.Write(writer);
+
+            var eps = Endpoints;
+
+            if (eps != null)
+            {
+                writer.WriteInt(eps.Count);
+
+                foreach (var ep in eps)
+                    writer.WriteString(ep);
+            }
+            else
+                writer.WriteInt(0);
+        }
+        
+        /** <inheritdoc /> */
+        protected override byte TypeCode
+        {
+            get { return TypeCodeVmIpFinder; }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs
new file mode 100644
index 0000000..e06a88d
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Discovery.Tcp
+{
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+    using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+    /// <summary>
+    /// Base IpFinder class.
+    /// </summary>
+    public abstract class TcpDiscoveryIpFinderBase : ITcpDiscoveryIpFinder
+    {
+        /** */
+        protected const byte TypeCodeVmIpFinder = 1;
+
+        /** */
+        protected const byte TypeCodeMulticastIpFinder = 2;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TcpDiscoveryIpFinderBase"/> class.
+        /// Prevents user-defined implementations.
+        /// </summary>
+        protected internal TcpDiscoveryIpFinderBase()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Writes this instance to the specified writer.
+        /// </summary>
+        /// <param name="writer">The writer.</param>
+        internal virtual void Write(IBinaryRawWriter writer)
+        {
+            writer.WriteByte(TypeCode);
+        }
+
+        /// <summary>
+        /// Gets the type code to be used in Java to determine ip finder type.
+        /// </summary>
+        protected abstract byte TypeCode { get; }
+
+        /// <summary>
+        /// Reads the instance.
+        /// </summary>
+        internal static TcpDiscoveryIpFinderBase ReadInstance(IBinaryRawReader reader)
+        {
+            var code = reader.ReadByte();
+
+            switch (code)
+            {
+                case TypeCodeVmIpFinder:
+                    return new TcpDiscoveryStaticIpFinder(reader);
+
+                case TypeCodeMulticastIpFinder:
+                    return new TcpDiscoveryMulticastIpFinder(reader);
+
+                default:
+                    return null;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
new file mode 100644
index 0000000..ea946e8
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
@@ -0,0 +1,144 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Discovery.Tcp
+{
+    using System;
+    using System.ComponentModel;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
+
+    /// <summary>
+    /// TCP discover service provider.
+    /// </summary>
+    public class TcpDiscoverySpi : IDiscoverySpi
+    {
+        /// <summary>
+        /// Default socket timeout.
+        /// </summary>
+        public static readonly TimeSpan DefaultSocketTimeout = TimeSpan.FromMilliseconds(5000);
+
+        /// <summary>
+        /// Default acknowledgement timeout.
+        /// </summary>
+        public static readonly TimeSpan DefaultAckTimeout = TimeSpan.FromMilliseconds(5000);
+
+        /// <summary>
+        /// Default maximum acknowledgement timeout.
+        /// </summary>
+        public static readonly TimeSpan DefaultMaxAckTimeout = TimeSpan.FromMinutes(10);
+
+        /// <summary>
+        /// Default network timeout.
+        /// </summary>
+        public static readonly TimeSpan DefaultNetworkTimeout = TimeSpan.FromMilliseconds(5000);
+
+        /// <summary>
+        /// Default join timeout.
+        /// </summary>
+        public static readonly TimeSpan DefaultJoinTimeout = TimeSpan.Zero;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TcpDiscoverySpi"/> class.
+        /// </summary>
+        public TcpDiscoverySpi()
+        {
+            SocketTimeout = DefaultSocketTimeout;
+            AckTimeout = DefaultAckTimeout;
+            MaxAckTimeout = DefaultMaxAckTimeout;
+            NetworkTimeout = DefaultNetworkTimeout;
+            JoinTimeout = DefaultJoinTimeout;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TcpDiscoverySpi"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        internal TcpDiscoverySpi(BinaryReader reader)
+        {
+            IpFinder = reader.ReadBoolean() ? TcpDiscoveryIpFinderBase.ReadInstance(reader) : null;
+
+            SocketTimeout = reader.ReadLongAsTimespan();
+            AckTimeout = reader.ReadLongAsTimespan();
+            MaxAckTimeout = reader.ReadLongAsTimespan();
+            NetworkTimeout = reader.ReadLongAsTimespan();
+            JoinTimeout = reader.ReadLongAsTimespan();
+        }
+
+        /// <summary>
+        /// Gets or sets the IP finder which defines how nodes will find each other on the network.
+        /// </summary>
+        public ITcpDiscoveryIpFinder IpFinder { get; set; }
+
+        /// <summary>
+        /// Gets or sets the socket timeout.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:05")]
+        public TimeSpan SocketTimeout { get; set; }
+
+        /// <summary>
+        /// Gets or sets the timeout for receiving acknowledgement for sent message.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:05")]
+        public TimeSpan AckTimeout { get; set; }
+
+        /// <summary>
+        /// Gets or sets the maximum timeout for receiving acknowledgement for sent message.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:10:00")]
+        public TimeSpan MaxAckTimeout { get; set; }
+
+        /// <summary>
+        /// Gets or sets the network timeout.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:05")]
+        public TimeSpan NetworkTimeout { get; set; }
+        
+        /// <summary>
+        /// Gets or sets the join timeout.
+        /// </summary>
+        public TimeSpan JoinTimeout { get; set; }
+
+        /// <summary>
+        /// Writes this instance to the specified writer.
+        /// </summary>
+        internal void Write(IBinaryRawWriter writer)
+        {
+            var ipFinder = IpFinder;
+
+            if (ipFinder != null)
+            {
+                writer.WriteBoolean(true);
+
+                var finder = ipFinder as TcpDiscoveryIpFinderBase;
+
+                if (finder == null)
+                    throw new InvalidOperationException("Unsupported IP finder: " + ipFinder.GetType());
+
+                finder.Write(writer);
+            }
+            else
+                writer.WriteBoolean(false);
+
+            writer.WriteLong((long) SocketTimeout.TotalMilliseconds);
+            writer.WriteLong((long) AckTimeout.TotalMilliseconds);
+            writer.WriteLong((long) MaxAckTimeout.TotalMilliseconds);
+            writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
+            writer.WriteLong((long) JoinTimeout.TotalMilliseconds);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
index a85e24c..d18e790 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Core
     using System.Diagnostics.CodeAnalysis;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Compute;
@@ -93,6 +94,15 @@ namespace Apache.Ignite.Core
         ICache<TK, TV> GetOrCreateCache<TK, TV>(string name);
 
         /// <summary>
+        /// Gets existing cache with the given name or creates new one using provided configuration.
+        /// </summary>
+        /// <typeparam name="TK">Cache key type.</typeparam>
+        /// <typeparam name="TV">Cache value type.</typeparam>
+        /// <param name="configuration">Cache configuration.</param>
+        /// <returns>Existing or newly created cache.</returns>
+        ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration);
+
+        /// <summary>
         /// Dynamically starts new cache using template configuration.
         /// </summary>
         /// <typeparam name="TK">Cache key type.</typeparam>
@@ -102,8 +112,17 @@ namespace Apache.Ignite.Core
         ICache<TK, TV> CreateCache<TK, TV>(string name);
 
         /// <summary>
-        /// Destroys dynamically created (with <see cref="CreateCache{TK,TV}"/> or 
-        /// <see cref="GetOrCreateCache{TK,TV}"/>) cache.
+        /// Dynamically starts new cache using provided configuration.
+        /// </summary>
+        /// <typeparam name="TK">Cache key type.</typeparam>
+        /// <typeparam name="TV">Cache value type.</typeparam>
+        /// <param name="configuration">Cache configuration.</param>
+        /// <returns>Existing or newly created cache.</returns>
+        ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration);
+
+        /// <summary>
+        /// Destroys dynamically created (with <see cref="CreateCache{TK,TV}(string)"/> or 
+        /// <see cref="GetOrCreateCache{TK,TV}(string)"/>) cache.
         /// </summary>
         /// <param name="name">The name of the cache to stop.</param>
         void DestroyCache(string name);
@@ -171,5 +190,11 @@ namespace Apache.Ignite.Core
         /// or null if it does not exist and <c>create</c> flag is not set.</returns>
         /// <exception cref="IgniteException">If atomic long could not be fetched or created.</exception>
         IAtomicLong GetAtomicLong(string name, long initialValue, bool create);
+
+        /// <summary>
+        /// Gets the configuration of this Ignite instance.
+        /// </summary>
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Semantics.")]
+        IgniteConfiguration GetConfiguration();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
index a4c37d1..1dd22ea 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -15,12 +15,27 @@
  * limitations under the License.
  */
 
-namespace Apache.Ignite.Core
+#pragma warning disable 618  // deprecated SpringConfigUrl
+ namespace Apache.Ignite.Core
 {
+    using System;
     using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.Diagnostics;
     using System.Diagnostics.CodeAnalysis;
+    using System.IO;
+    using System.Linq;
     using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Discovery;
+    using Apache.Ignite.Core.Discovery.Tcp;
+    using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Impl;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Lifecycle;
+    using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader;
+    using BinaryWriter = Apache.Ignite.Core.Impl.Binary.BinaryWriter;
 
     /// <summary>
     /// Grid configuration.
@@ -38,40 +53,238 @@ namespace Apache.Ignite.Core
         public const int DefaultJvmMaxMem = 1024;
 
         /// <summary>
-        /// Default constructor.
+        /// Default metrics expire time.
+        /// </summary>
+        public static readonly TimeSpan DefaultMetricsExpireTime = TimeSpan.MaxValue;
+
+        /// <summary>
+        /// Default metrics history size.
+        /// </summary>
+        public const int DefaultMetricsHistorySize = 10000;
+
+        /// <summary>
+        /// Default metrics log frequency.
+        /// </summary>
+        public static readonly TimeSpan DefaultMetricsLogFrequency = TimeSpan.FromMilliseconds(60000);
+
+        /// <summary>
+        /// Default metrics update frequency.
+        /// </summary>
+        public static readonly TimeSpan DefaultMetricsUpdateFrequency = TimeSpan.FromMilliseconds(2000);
+
+        /// <summary>
+        /// Default network timeout.
+        /// </summary>
+        public static readonly TimeSpan DefaultNetworkTimeout = TimeSpan.FromMilliseconds(5000);
+
+        /// <summary>
+        /// Default network retry delay.
+        /// </summary>
+        public static readonly TimeSpan DefaultNetworkSendRetryDelay = TimeSpan.FromMilliseconds(1000);
+
+        /// <summary>
+        /// Default network retry count.
+        /// </summary>
+        public const int DefaultNetworkSendRetryCount = 3;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class.
         /// </summary>
         public IgniteConfiguration()
         {
             JvmInitialMemoryMb = DefaultJvmInitMem;
             JvmMaxMemoryMb = DefaultJvmMaxMem;
+
+            MetricsExpireTime = DefaultMetricsExpireTime;
+            MetricsHistorySize = DefaultMetricsHistorySize;
+            MetricsLogFrequency = DefaultMetricsLogFrequency;
+            MetricsUpdateFrequency = DefaultMetricsUpdateFrequency;
+            NetworkTimeout = DefaultNetworkTimeout;
+            NetworkSendRetryCount = DefaultNetworkSendRetryCount;
+            NetworkSendRetryDelay = DefaultNetworkSendRetryDelay;
         }
 
         /// <summary>
-        /// Copying constructor.
+        /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class.
         /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        internal IgniteConfiguration(IgniteConfiguration cfg)
+        /// <param name="configuration">The configuration to copy.</param>
+        public IgniteConfiguration(IgniteConfiguration configuration)
         {
-            SpringConfigUrl = cfg.SpringConfigUrl;
-            JvmDllPath = cfg.JvmDllPath;
-            IgniteHome = cfg.IgniteHome;
-            JvmClasspath = cfg.JvmClasspath;
-            SuppressWarnings = cfg.SuppressWarnings;
+            IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+            CopyLocalProperties(configuration);
+
+            using (var stream = IgniteManager.Memory.Allocate().GetStream())
+            {
+                var marsh = new Marshaller(configuration.BinaryConfiguration);
+
+                configuration.WriteCore(marsh.StartMarshal(stream));
+
+                stream.SynchronizeOutput();
+
+                stream.Seek(0, SeekOrigin.Begin);
+
+                ReadCore(marsh.StartUnmarshal(stream));
+            }
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class from a reader.
+        /// </summary>
+        /// <param name="binaryReader">The binary reader.</param>
+        internal IgniteConfiguration(BinaryReader binaryReader)
+        {
+            Read(binaryReader);
+        }
+
+        /// <summary>
+        /// Writes this instance to a writer.
+        /// </summary>
+        /// <param name="writer">The writer.</param>
+        internal void Write(BinaryWriter writer)
+        {
+            Debug.Assert(writer != null);
+
+            if (!string.IsNullOrEmpty(SpringConfigUrl))
+            {
+                // Do not write details when there is Spring config.
+                writer.WriteBoolean(false);
+                return;
+            }
+
+            writer.WriteBoolean(true);  // details are present
+
+            WriteCore(writer);
+        }
+
+        /// <summary>
+        /// Writes this instance to a writer.
+        /// </summary>
+        /// <param name="writer">The writer.</param>
+        private void WriteCore(BinaryWriter writer)
+        {
+            // Simple properties
+            writer.WriteBoolean(ClientMode);
+            writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());
+
+            writer.WriteLong((long) MetricsExpireTime.TotalMilliseconds);
+            writer.WriteInt(MetricsHistorySize);
+            writer.WriteLong((long) MetricsLogFrequency.TotalMilliseconds);
+            var metricsUpdateFreq = (long) MetricsUpdateFrequency.TotalMilliseconds;
+            writer.WriteLong(metricsUpdateFreq >= 0 ? metricsUpdateFreq : -1);
+            writer.WriteInt(NetworkSendRetryCount);
+            writer.WriteLong((long) NetworkSendRetryDelay.TotalMilliseconds);
+            writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
+            writer.WriteString(WorkDirectory);
+            writer.WriteString(Localhost);
+
+            // Cache config
+            var caches = CacheConfiguration;
+
+            if (caches == null)
+                writer.WriteInt(0);
+            else
+            {
+                writer.WriteInt(caches.Count);
+
+                foreach (var cache in caches)
+                    cache.Write(writer);
+            }
+
+            // Discovery config
+            var disco = DiscoverySpi;
+
+            if (disco != null)
+            {
+                writer.WriteBoolean(true);
+
+                var tcpDisco = disco as TcpDiscoverySpi;
+
+                if (tcpDisco == null)
+                    throw new InvalidOperationException("Unsupported discovery SPI: " + disco.GetType());
+
+                tcpDisco.Write(writer);
+            }
+            else
+                writer.WriteBoolean(false);
+        }
+
+        /// <summary>
+        /// Reads data from specified reader into current instance.
+        /// </summary>
+        /// <param name="r">The binary reader.</param>
+        private void ReadCore(BinaryReader r)
+        {
+            // Simple properties
+            ClientMode = r.ReadBoolean();
+            IncludedEventTypes = r.ReadIntArray();
 
-            JvmOptions = cfg.JvmOptions != null ? new List<string>(cfg.JvmOptions) : null;
-            Assemblies = cfg.Assemblies != null ? new List<string>(cfg.Assemblies) : null;
+            MetricsExpireTime = r.ReadLongAsTimespan();
+            MetricsHistorySize = r.ReadInt();
+            MetricsLogFrequency = r.ReadLongAsTimespan();
+            MetricsUpdateFrequency = r.ReadLongAsTimespan();
+            NetworkSendRetryCount = r.ReadInt();
+            NetworkSendRetryDelay = r.ReadLongAsTimespan();
+            NetworkTimeout = r.ReadLongAsTimespan();
+            WorkDirectory = r.ReadString();
+            Localhost = r.ReadString();
 
-            BinaryConfiguration = cfg.BinaryConfiguration != null
-                ? new BinaryConfiguration(cfg.BinaryConfiguration)
-                : null;
+            // Cache config
+            var cacheCfgCount = r.ReadInt();
+            CacheConfiguration = new List<CacheConfiguration>(cacheCfgCount);
+            for (int i = 0; i < cacheCfgCount; i++)
+                CacheConfiguration.Add(new CacheConfiguration(r));
 
-            LifecycleBeans = cfg.LifecycleBeans != null ? new List<ILifecycleBean>(cfg.LifecycleBeans) : null;
+            // Discovery config
+            DiscoverySpi = r.ReadBoolean() ? new TcpDiscoverySpi(r) : null;
+        }
+
+        /// <summary>
+        /// Reads data from specified reader into current instance.
+        /// </summary>
+        /// <param name="binaryReader">The binary reader.</param>
+        private void Read(BinaryReader binaryReader)
+        {
+            var r = binaryReader;
+
+            CopyLocalProperties(r.Marshaller.Ignite.Configuration);
+
+            ReadCore(r);
+
+            // Misc
+            IgniteHome = r.ReadString();
 
-            JvmInitialMemoryMb = cfg.JvmInitialMemoryMb;
-            JvmMaxMemoryMb = cfg.JvmMaxMemoryMb;
+            JvmInitialMemoryMb = (int) (r.ReadLong()/1024/2014);
+            JvmMaxMemoryMb = (int) (r.ReadLong()/1024/2014);
+
+            // Local data (not from reader)
+            JvmDllPath = Process.GetCurrentProcess().Modules.OfType<ProcessModule>()
+                .Single(x => string.Equals(x.ModuleName, IgniteUtils.FileJvmDll, StringComparison.OrdinalIgnoreCase))
+                .FileName;
+        }
+
+        /// <summary>
+        /// Copies the local properties (properties that are not written in Write method).
+        /// </summary>
+        private void CopyLocalProperties(IgniteConfiguration cfg)
+        {
+            GridName = cfg.GridName;
+            BinaryConfiguration = cfg.BinaryConfiguration == null
+                ? null
+                : new BinaryConfiguration(cfg.BinaryConfiguration);
+            JvmClasspath = cfg.JvmClasspath;
+            JvmOptions = cfg.JvmOptions;
+            Assemblies = cfg.Assemblies;
+            SuppressWarnings = cfg.SuppressWarnings;
+            LifecycleBeans = cfg.LifecycleBeans;
         }
 
         /// <summary>
+        /// Grid name which is used if not provided in configuration file.
+        /// </summary>
+        public string GridName { get; set; }
+
+        /// <summary>
         /// Gets or sets the binary configuration.
         /// </summary>
         /// <value>
@@ -80,9 +293,22 @@ namespace Apache.Ignite.Core
         public BinaryConfiguration BinaryConfiguration { get; set; }
 
         /// <summary>
+        /// Gets or sets the cache configuration.
+        /// </summary>
+        /// <value>
+        /// The cache configuration.
+        /// </value>
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public ICollection<CacheConfiguration> CacheConfiguration { get; set; }
+
+        /// <summary>
         /// URL to Spring configuration file.
         /// </summary>
         [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
+        [Obsolete("Ignite.NET can be configured natively without Spring. " +
+                  "Setting this property will ignore all other properties except " +
+                  "IgniteHome, Assemblies, SuppressWarnings, LifecycleBeans, JvmOptions, JvmdllPath, IgniteHome, " +
+                  "JvmInitialMemoryMb, JvmMaxMemoryMb.")]
         public string SpringConfigUrl { get; set; }
 
         /// <summary>
@@ -115,7 +341,7 @@ namespace Apache.Ignite.Core
         /// assemblies reside.
         /// </summary>
         [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
-        public IList<string> Assemblies { get; set; }
+        public ICollection<string> Assemblies { get; set; }
 
         /// <summary>
         /// Whether to suppress warnings.
@@ -132,12 +358,95 @@ namespace Apache.Ignite.Core
         /// Initial amount of memory in megabytes given to JVM. Maps to -Xms Java option.
         /// Defaults to <see cref="DefaultJvmInitMem"/>.
         /// </summary>
+        [DefaultValue(DefaultJvmInitMem)]
         public int JvmInitialMemoryMb { get; set; }
 
         /// <summary>
         /// Maximum amount of memory in megabytes given to JVM. Maps to -Xmx Java option.
         /// Defaults to <see cref="DefaultJvmMaxMem"/>.
         /// </summary>
+        [DefaultValue(DefaultJvmMaxMem)]
         public int JvmMaxMemoryMb { get; set; }
+
+        /// <summary>
+        /// Gets or sets the discovery service provider.
+        /// Null for default discovery.
+        /// </summary>
+        public IDiscoverySpi DiscoverySpi { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether node should start in client mode.
+        /// Client node cannot hold data in the caches.
+        /// Default is null and takes this setting from Spring configuration.
+        /// </summary>
+        public bool ClientMode { get; set; }
+
+        /// <summary>
+        /// Gets or sets a set of event types (<see cref="EventType" />) to be recorded by Ignite. 
+        /// </summary>
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public ICollection<int> IncludedEventTypes { get; set; }
+
+        /// <summary>
+        /// Gets or sets the time after which a certain metric value is considered expired.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "10675199.02:48:05.4775807")]
+        public TimeSpan MetricsExpireTime { get; set; }
+
+        /// <summary>
+        /// Gets or sets the number of metrics kept in history to compute totals and averages.
+        /// </summary>
+        [DefaultValue(DefaultMetricsHistorySize)]
+        public int MetricsHistorySize { get; set; }
+
+        /// <summary>
+        /// Gets or sets the frequency of metrics log print out.
+        /// <see cref="TimeSpan.Zero"/> to disable metrics print out.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:01:00")]
+        public TimeSpan MetricsLogFrequency { get; set; }
+
+        /// <summary>
+        /// Gets or sets the job metrics update frequency.
+        /// <see cref="TimeSpan.Zero"/> to update metrics on job start/finish.
+        /// Negative value to never update metrics.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:02")]
+        public TimeSpan MetricsUpdateFrequency { get; set; }
+
+        /// <summary>
+        /// Gets or sets the network send retry count.
+        /// </summary>
+        [DefaultValue(DefaultNetworkSendRetryCount)]
+        public int NetworkSendRetryCount { get; set; }
+
+        /// <summary>
+        /// Gets or sets the network send retry delay.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:01")]
+        public TimeSpan NetworkSendRetryDelay { get; set; }
+
+        /// <summary>
+        /// Gets or sets the network timeout.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:05")]
+        public TimeSpan NetworkTimeout { get; set; }
+
+        /// <summary>
+        /// Gets or sets the work directory.
+        /// If not provided, a folder under <see cref="IgniteHome"/> will be used.
+        /// </summary>
+        public string WorkDirectory { get; set; }
+
+        /// <summary>
+        /// Gets or sets system-wide local address or host for all Ignite components to bind to. 
+        /// If provided it will override all default local bind settings within Ignite.
+        /// <para />
+        /// If <c>null</c> then Ignite tries to use local wildcard address.That means that all services 
+        /// will be available on all network interfaces of the host machine. 
+        /// <para />
+        /// It is strongly recommended to set this parameter for all production environments.
+        /// </summary>
+        public string Localhost { get; set; }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index 3a27ad1..0549010 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 
+#pragma warning disable 618  // deprecated SpringConfigUrl
 namespace Apache.Ignite.Core 
 {
     using System;
@@ -41,7 +42,7 @@ namespace Apache.Ignite.Core
     /// <summary>
     /// This class defines a factory for the main Ignite API.
     /// <p/>
-    /// Use <see cref="Ignition.Start()"/> method to start Ignite with default configuration.
+    /// Use <see cref="Start()"/> method to start Ignite with default configuration.
     /// <para/>
     /// All members are thread-safe and may be used concurrently from multiple threads.
     /// </summary>
@@ -51,9 +52,6 @@ namespace Apache.Ignite.Core
         internal const string EnvIgniteSpringConfigUrlPrefix = "IGNITE_SPRING_CONFIG_URL_PREFIX";
 
         /** */
-        private const string DefaultCfg = "config/default-config.xml";
-
-        /** */
         private static readonly object SyncRoot = new object();
 
         /** GC warning flag. */
@@ -125,15 +123,6 @@ namespace Apache.Ignite.Core
         {
             IgniteArgumentCheck.NotNull(cfg, "cfg");
 
-            // Copy configuration to avoid changes to user-provided instance.
-            IgniteConfigurationEx cfgEx = cfg as IgniteConfigurationEx;
-
-            cfg = cfgEx == null ? new IgniteConfiguration(cfg) : new IgniteConfigurationEx(cfgEx);
-
-            // Set default Spring config if needed.
-            if (cfg.SpringConfigUrl == null)
-                cfg.SpringConfigUrl = DefaultCfg;
-
             lock (SyncRoot)
             {
                 // 1. Check GC settings.
@@ -146,9 +135,11 @@ namespace Apache.Ignite.Core
 
                 IgniteManager.CreateJvmContext(cfg, cbs);
 
-                var gridName = cfgEx != null ? cfgEx.GridName : null;
+                var gridName = cfg.GridName;
 
-                var cfgPath = Environment.GetEnvironmentVariable(EnvIgniteSpringConfigUrlPrefix) + cfg.SpringConfigUrl;
+                var cfgPath = cfg.SpringConfigUrl == null 
+                    ? null 
+                    : Environment.GetEnvironmentVariable(EnvIgniteSpringConfigUrlPrefix) + cfg.SpringConfigUrl;
 
                 // 3. Create startup object which will guide us through the rest of the process.
                 _startup = new Startup(cfg, cbs);
@@ -229,7 +220,7 @@ namespace Apache.Ignite.Core
             {
                 BinaryReader reader = BinaryUtils.Marshaller.StartUnmarshal(inStream);
 
-                PrepareConfiguration(reader);
+                PrepareConfiguration(reader, outStream);
 
                 PrepareLifecycleBeans(reader, outStream, handleRegistry);
             }
@@ -245,7 +236,8 @@ namespace Apache.Ignite.Core
         /// Preapare configuration.
         /// </summary>
         /// <param name="reader">Reader.</param>
-        private static void PrepareConfiguration(BinaryReader reader)
+        /// <param name="outStream">Response stream.</param>
+        private static void PrepareConfiguration(BinaryReader reader, PlatformMemoryStream outStream)
         {
             // 1. Load assemblies.
             IgniteConfiguration cfg = _startup.Configuration;
@@ -264,6 +256,9 @@ namespace Apache.Ignite.Core
                 cfg.BinaryConfiguration = binaryCfg;
 
             _startup.Marshaller = new Marshaller(cfg.BinaryConfiguration);
+
+            // 3. Send configuration details to Java
+            cfg.Write(_startup.Marshaller.StartMarshal(outStream));
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
index 9b43564..efe1df4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
@@ -104,9 +104,6 @@ namespace Apache.Ignite.Core.Impl.Binary
             if (obj0 == null)
                 throw new ArgumentException("Unsupported object type: " + obj.GetType());
 
-            if (obj0 is BinaryEnum)
-                throw new InvalidOperationException("Builder cannot be created for enum.");
-
             IBinaryTypeDescriptor desc = _marsh.GetDescriptor(true, obj0.TypeId);
             
             return Builder0(null, obj0, desc);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
index c3dcc3a..f3f8457 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
@@ -17,6 +17,7 @@
 
 namespace Apache.Ignite.Core.Impl.Binary
 {
+    using System;
     using System.Collections.Generic;
     using Apache.Ignite.Core.Binary;
 
@@ -48,5 +49,23 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             return (Dictionary<TKey, TValue>) reader.ReadDictionary(size => new Dictionary<TKey, TValue>(size));
         }
+
+        /// <summary>
+        /// Reads long as timespan with range checks.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        /// <returns>TimeSpan.</returns>
+        public static TimeSpan ReadLongAsTimespan(this IBinaryRawReader reader)
+        {
+            long ms = reader.ReadLong();
+
+            if (ms >= TimeSpan.MaxValue.TotalMilliseconds)
+                return TimeSpan.MaxValue;
+
+            if (ms <= TimeSpan.MinValue.TotalMilliseconds)
+                return TimeSpan.MinValue;
+
+            return TimeSpan.FromMilliseconds(ms);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
new file mode 100644
index 0000000..fccbfae
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Binary
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+
+    /// <summary>
+    /// Provides mapping between Java and .NET basic types.
+    /// </summary>
+    internal static class JavaTypes
+    {
+        /** */
+        private static readonly Dictionary<Type, string> NetToJava = new Dictionary<Type, string>
+        {
+            {typeof (bool), "java.lang.Boolean"},
+            {typeof (byte), "java.lang.Byte"},
+            {typeof (sbyte), "java.lang.Byte"},
+            {typeof (short), "java.lang.Short"},
+            {typeof (ushort), "java.lang.Short"},
+            {typeof (char), "java.lang.Character"},
+            {typeof (int), "java.lang.Integer"},
+            {typeof (uint), "java.lang.Integer"},
+            {typeof (long), "java.lang.Long"},
+            {typeof (ulong), "java.lang.Long"},
+            {typeof (float), "java.lang.Float"},
+            {typeof (double), "java.lang.Double"},
+            {typeof (string), "java.lang.String"},
+            {typeof (decimal), "java.math.BigDecimal"},
+            {typeof (Guid), "java.util.UUID"}
+        };
+
+        /** */
+        private static readonly Dictionary<string, Type> JavaToNet =
+            NetToJava.GroupBy(x => x.Value).ToDictionary(g => g.Key, g => g.First().Key);
+
+        /** */
+        private static readonly string MappedTypes = string.Join(", ", NetToJava.Keys.Select(x => x.Name));
+
+        /// <summary>
+        /// Gets the corresponding Java type name.
+        /// </summary>
+        public static string GetJavaTypeName(Type type)
+        {
+            if (type == null)
+                return null;
+
+            string res;
+
+            return NetToJava.TryGetValue(type, out res) ? res : null;
+        }
+
+        /// <summary>
+        /// Gets .NET type that corresponds to specified Java type name.
+        /// </summary>
+        /// <param name="javaTypeName">Name of the java type.</param>
+        /// <returns></returns>
+        public static Type GetDotNetType(string javaTypeName)
+        {
+            if (string.IsNullOrEmpty(javaTypeName))
+                return null;
+
+            Type res;
+
+            return JavaToNet.TryGetValue(javaTypeName, out res) ? res : null;
+        }
+
+        /// <summary>
+        /// Gets the supported types as a comma-separated string.
+        /// </summary>
+        public static string SupportedTypesString
+        {
+            get { return MappedTypes; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index 4274744..73f3618 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -88,11 +88,11 @@ namespace Apache.Ignite.Core.Impl.Binary
                 foreach (BinaryTypeConfiguration typeCfg in typeCfgs)
                     AddUserType(cfg, typeCfg, typeResolver, dfltSerializer);
 
-            ICollection<string> types = cfg.Types;
+            var typeNames = cfg.Types;
 
-            if (types != null)
-                foreach (string type in types)
-                    AddUserType(cfg, new BinaryTypeConfiguration(type), typeResolver, dfltSerializer);
+            if (typeNames != null)
+                foreach (string typeName in typeNames)
+                    AddUserType(cfg, new BinaryTypeConfiguration(typeName), typeResolver, dfltSerializer);
 
             if (cfg.DefaultSerializer == null)
                 cfg.DefaultSerializer = dfltSerializer;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index f55863e..d1296ec 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -25,6 +25,7 @@ namespace Apache.Ignite.Core.Impl.Cache
     using System.Threading.Tasks;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Cache.Expiry;
     using Apache.Ignite.Core.Cache.Query;
     using Apache.Ignite.Core.Cache.Query.Continuous;
@@ -68,7 +69,7 @@ namespace Apache.Ignite.Core.Impl.Cache
 
         /** Async instance. */
         private readonly Lazy<CacheImpl<TK, TV>> _asyncInstance;
-
+        
         /// <summary>
         /// Constructor.
         /// </summary>
@@ -152,6 +153,12 @@ namespace Apache.Ignite.Core.Impl.Cache
         }
 
         /** <inheritDoc /> */
+        public CacheConfiguration GetConfiguration()
+        {
+            return DoInOp((int) CacheOp.GetConfig, stream => new CacheConfiguration(Marshaller.StartUnmarshal(stream)));
+        }
+
+        /** <inheritDoc /> */
         public bool IsEmpty()
         {
             return GetSize() == 0;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
index 1709dc5..61ccb5f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
@@ -59,6 +59,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         RemoveBool = 35,
         RemoveObj = 36,
         Replace2 = 37,
-        Replace3 = 38
+        Replace3 = 38,
+        GetConfig = 39
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
index 5aa806b..7785280 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
@@ -101,15 +101,25 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
         {
             using (var stream = IgniteManager.Memory.Get(memPtr).GetStream())
             {
-                var reader = BinaryUtils.Marshaller.StartUnmarshal(stream, BinaryMode.KeepBinary);
+                var reader = BinaryUtils.Marshaller.StartUnmarshal(stream);
 
-                var className = reader.ReadString();
                 var convertBinary = reader.ReadBoolean();
-                var propertyMap = reader.ReadDictionaryAsGeneric<string, object>();
+                var factory = reader.ReadObject<IFactory<ICacheStore>>();
 
-                var store = IgniteUtils.CreateInstance<ICacheStore>(className);
+                ICacheStore store;
+
+                if (factory != null)
+                    store = factory.CreateInstance();
+                else
+                {
+                    var className = reader.ReadString();
+                    var propertyMap = reader.ReadDictionaryAsGeneric<string, object>();
+
+                    store = IgniteUtils.CreateInstance<ICacheStore>(className);
+
+                    IgniteUtils.SetProperties(store, propertyMap);
+                }
 
-                IgniteUtils.SetProperties(store, propertyMap);
 
                 return new CacheStore(store, convertBinary, registry);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index ffc8be8..9d27117 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -25,6 +25,7 @@ namespace Apache.Ignite.Core.Impl
     using System.Linq;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Compute;
     using Apache.Ignite.Core.Datastream;
@@ -339,12 +340,46 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritdoc /> */
+        public ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration)
+        {
+            IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+            using (var stream = IgniteManager.Memory.Allocate().GetStream())
+            {
+                var writer = Marshaller.StartMarshal(stream);
+
+                configuration.Write(writer);
+
+                stream.SynchronizeOutput();
+
+                return Cache<TK, TV>(UU.ProcessorGetOrCreateCache(_proc, stream.MemoryPointer));
+            }
+        }
+
+        /** <inheritdoc /> */
         public ICache<TK, TV> CreateCache<TK, TV>(string name)
         {
             return Cache<TK, TV>(UU.ProcessorCreateCache(_proc, name));
         }
 
         /** <inheritdoc /> */
+        public ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration)
+        {
+            IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+            using (var stream = IgniteManager.Memory.Allocate().GetStream())
+            {
+                var writer = Marshaller.StartMarshal(stream);
+
+                configuration.Write(writer);
+
+                stream.SynchronizeOutput();
+
+                return Cache<TK, TV>(UU.ProcessorCreateCache(_proc, stream.MemoryPointer));
+            }
+        }
+
+        /** <inheritdoc /> */
         public void DestroyCache(string name)
         {
             UU.ProcessorDestroyCache(_proc, name);
@@ -450,6 +485,19 @@ namespace Apache.Ignite.Core.Impl
             return new AtomicLong(nativeLong, Marshaller, name);
         }
 
+        /** <inheritdoc /> */
+        public IgniteConfiguration GetConfiguration()
+        {
+            using (var stream = IgniteManager.Memory.Allocate(1024).GetStream())
+            {
+                UU.ProcessorGetIgniteConfiguration(_proc, stream.MemoryPointer);
+
+                stream.SynchronizeInput();
+
+                return new IgniteConfiguration(_marsh.StartUnmarshal(stream));
+            }
+        }
+
         /// <summary>
         /// Gets internal projection.
         /// </summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
deleted file mode 100644
index 358e805..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
+++ /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.
- */
-
-namespace Apache.Ignite.Core.Impl
-{
-    /// <summary>
-    /// Internal extensions for IgniteConfiguration.
-    /// </summary>
-    internal class IgniteConfigurationEx : IgniteConfiguration
-    {
-        /// <summary>
-        /// Default constructor.
-        /// </summary>
-        public IgniteConfigurationEx()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Copying constructor.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        public IgniteConfigurationEx(IgniteConfiguration cfg) : base(cfg)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Copying constructor.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        public IgniteConfigurationEx(IgniteConfigurationEx cfg)
-            : this((IgniteConfiguration) cfg)
-        {
-            GridName = cfg.GridName;
-        }
-
-        /// <summary>
-        /// Grid name which is used if not provided in configuration file.
-        /// </summary>
-        public string GridName { get; set; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
index 6803772..a61edf4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
@@ -50,7 +50,7 @@ namespace Apache.Ignite.Core.Impl
         private static JvmConfiguration _jvmCfg;
 
         /** Memory manager. */
-        private static PlatformMemoryManager _mem;
+        private static readonly PlatformMemoryManager Mem = new PlatformMemoryManager(1024);
 
         /// <summary>
         /// Create JVM.
@@ -86,7 +86,6 @@ namespace Apache.Ignite.Core.Impl
                 {
                     _ctx = ctx;
                     _jvmCfg = jvmCfg;
-                    _mem = new PlatformMemoryManager(1024);
                 }
             }
         }
@@ -96,7 +95,7 @@ namespace Apache.Ignite.Core.Impl
         /// </summary>
         internal static PlatformMemoryManager Memory
         {
-            get { return _mem; }
+            get { return Mem; }
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
index 16062e2..46bc3ca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Impl
     using System.Diagnostics.CodeAnalysis;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Compute;
     using Apache.Ignite.Core.Datastream;
@@ -232,19 +233,28 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritdoc /> */
+        public ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration)
+        {
+            return _ignite.GetOrCreateCache<TK, TV>(configuration);
+        }
+
+        /** <inheritdoc /> */
         public ICache<TK, TV> CreateCache<TK, TV>(string name)
         {
             return _ignite.CreateCache<TK, TV>(name);
         }
 
         /** <inheritdoc /> */
+        public ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration)
+        {
+            return _ignite.CreateCache<TK, TV>(configuration);
+        }
         public void DestroyCache(string name)
         {
             _ignite.DestroyCache(name);
         }
 
         /** <inheritdoc /> */
-
         public IClusterNode GetLocalNode()
         {
             return _ignite.GetCluster().GetLocalNode();
@@ -324,6 +334,12 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritdoc /> */
+        public IgniteConfiguration GetConfiguration()
+        {
+            return _ignite.GetConfiguration();
+        }
+
+        /** <inheritdoc /> */
         public void WriteBinary(IBinaryWriter writer)
         {
             // No-op.

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index fe4548c..3206fc8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -47,7 +47,7 @@ namespace Apache.Ignite.Core.Impl
         private static readonly string[] JvmDllLookupPaths = {@"jre\bin\server", @"jre\bin\default"};
 
         /** File: jvm.dll. */
-        private const string FileJvmDll = "jvm.dll";
+        internal const string FileJvmDll = "jvm.dll";
 
         /** File: Ignite.Common.dll. */
         internal const string FileIgniteJniDll = "ignite.common.dll";

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
index 851d24f..8e54261 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
@@ -85,7 +85,7 @@ namespace Apache.Ignite.Core.Impl.Memory
         /** <inheritdoc /> */
         public void Release()
         {
-            throw new NotSupportedException();
+            // Memory can only be released by native platform.
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
index 229ff8c..51a49d0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
@@ -70,7 +70,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
 
                 concurrency = (TransactionConcurrency) reader.ReadInt();
                 isolation = (TransactionIsolation) reader.ReadInt();
-                timeout = TimeSpan.FromMilliseconds(reader.ReadLong());
+                timeout = reader.ReadLongAsTimespan();
             });
 
             _dfltConcurrency = concurrency;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
index 7a73bee..17df94a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
@@ -24,7 +24,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
     /// Ignite JNI native methods.
     /// </summary>
     [SuppressUnmanagedCodeSecurity]
-    internal unsafe static class IgniteJniNativeMethods
+    internal static unsafe class IgniteJniNativeMethods
     {
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteReallocate")]
         public static extern int Reallocate(long memPtr, int cap);
@@ -52,9 +52,15 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorCreateCache")]
         public static extern void* ProcessorCreateCache(void* ctx, void* obj, sbyte* name);
 
+        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorCreateCacheFromConfig")]
+        public static extern void* ProcessorCreateCacheFromConfig(void* ctx, void* obj, long memPtr);
+
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetOrCreateCache")]
         public static extern void* ProcessorGetOrCreateCache(void* ctx, void* obj, sbyte* name);
 
+        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetOrCreateCacheFromConfig")]
+        public static extern void* ProcessorGetOrCreateCacheFromConfig(void* ctx, void* obj, long memPtr);
+
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorDestroyCache")]
         public static extern void ProcessorDestroyCache(void* ctx, void* obj, sbyte* name);
 
@@ -87,6 +93,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         public static extern void* ProcessorAtomicLong(void* ctx, void* obj, sbyte* name, long initVal,
             [MarshalAs(UnmanagedType.U1)] bool create);
 
+        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetIgniteConfiguration")]
+        public static extern void ProcessorGetIgniteConfiguration(void* ctx, void* obj, long memPtr);
+
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetInStreamOutLong")]
         public static extern long TargetInStreamOutLong(void* ctx, void* target, int opType, long memPtr);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index f460c9f..ad62f38 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
     using System.Diagnostics.CodeAnalysis;
     using System.Runtime.InteropServices;
     using Apache.Ignite.Core.Common;
-
     using JNI = IgniteJniNativeMethods;
 
     /// <summary>
@@ -102,7 +101,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         {
             JNI.IgnitionStopAll(ctx, cancel);
         }
-        
+
         internal static void ProcessorReleaseStart(IUnmanagedTarget target)
         {
             JNI.ProcessorReleaseStart(target.Context, target.Target);
@@ -147,6 +146,13 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             }
         }
 
+        internal static IUnmanagedTarget ProcessorCreateCache(IUnmanagedTarget target, long memPtr)
+        {
+            void* res = JNI.ProcessorCreateCacheFromConfig(target.Context, target.Target, memPtr);
+
+            return target.ChangeTarget(res);
+        }
+
         internal static IUnmanagedTarget ProcessorGetOrCreateCache(IUnmanagedTarget target, string name)
         {
             sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
@@ -163,6 +169,13 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             }
         }
 
+        internal static IUnmanagedTarget ProcessorGetOrCreateCache(IUnmanagedTarget target, long memPtr)
+        {
+            void* res = JNI.ProcessorGetOrCreateCacheFromConfig(target.Context, target.Target, memPtr);
+
+            return target.ChangeTarget(res);
+        }
+
         internal static void ProcessorDestroyCache(IUnmanagedTarget target, string name)
         {
             sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
@@ -268,6 +281,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             }
         }
 
+        internal static void ProcessorGetIgniteConfiguration(IUnmanagedTarget target, long memPtr)
+        {
+            JNI.ProcessorGetIgniteConfiguration(target.Context, target.Target, memPtr);
+        }
+
         #endregion
 
         #region NATIVE METHODS: TARGET

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index c0f49c8..53eefdd 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -837,6 +837,7 @@
                                         <exclude>**/*.slnrel</exclude>
                                         <exclude>**/*.DotSettings</exclude>
                                         <exclude>**/*.FxCop</exclude>
+                                        <exclude>**/*.ruleset</exclude>
                                         <exclude>**/*.csproj</exclude>
                                         <exclude>**/*.csprojrel</exclude>
                                         <exclude>**/*.vcxproj</exclude>


[12/28] ignite git commit: IGNITE-1906: .NET: Implemented programmatic configuration.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
new file mode 100644
index 0000000..b319be9
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
@@ -0,0 +1,601 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable MemberCanBePrivate.Global
+// ReSharper disable UnusedMember.Global
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Store;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Binary;
+
+    /// <summary>
+    /// Defines grid cache configuration.
+    /// </summary>
+    public class CacheConfiguration
+    {
+        /// <summary> Default size of rebalance thread pool. </summary>
+        public const int DefaultRebalanceThreadPoolSize = 2;
+
+        /// <summary> Default rebalance timeout.</summary>
+        public static readonly TimeSpan DefaultRebalanceTimeout = TimeSpan.FromMilliseconds(10000);
+
+        /// <summary> Time to wait between rebalance messages to avoid overloading CPU. </summary>
+        public static readonly TimeSpan DefaultRebalanceThrottle = TimeSpan.Zero;
+
+        /// <summary> Default number of backups. </summary>
+        public const int DefaultBackups = 0;
+
+        /// <summary> Default caching mode. </summary>
+        public const CacheMode DefaultCacheMode = CacheMode.Partitioned;
+
+        /// <summary> Default atomicity mode. </summary>
+        public const CacheAtomicityMode DefaultAtomicityMode = CacheAtomicityMode.Atomic;
+
+        /// <summary> Default lock timeout. </summary>
+        public static readonly TimeSpan DefaultLockTimeout = TimeSpan.Zero;
+
+        /// <summary> Initial default cache size. </summary>
+        public const int DefaultStartSize = 1500000;
+
+        /// <summary> Default cache size to use with eviction policy. </summary>
+        public const int DefaultCacheSize = 100000;
+
+        /// <summary> Default value for 'invalidate' flag that indicates if this is invalidation-based cache. </summary>
+        public const bool DefaultInvalidate = false;
+
+        /// <summary> Default rebalance mode for distributed cache. </summary>
+        public const CacheRebalanceMode DefaultRebalanceMode = CacheRebalanceMode.Async;
+
+        /// <summary> Default rebalance batch size in bytes. </summary>
+        public const int DefaultRebalanceBatchSize = 512*1024; // 512K
+
+        /// <summary> Default maximum eviction queue ratio. </summary>
+        public const float DefaultMaxEvictionOverflowRatio = 10;
+
+        /// <summary> Default eviction synchronized flag. </summary>
+        public const bool DefaultEvictSynchronized = false;
+
+        /// <summary> Default eviction key buffer size for batching synchronized evicts. </summary>
+        public const int DefaultEvictSynchronizedKeyBufferSize = 1024;
+
+        /// <summary> Default synchronous eviction timeout. </summary>
+        public static readonly TimeSpan DefaultEvictSynchronizedTimeout = TimeSpan.FromMilliseconds(10000);
+
+        /// <summary> Default synchronous eviction concurrency level. </summary>
+        public const int DefaultEvictSynchronizedConcurrencyLevel = 4;
+
+        /// <summary> Default value for eager ttl flag. </summary>
+        public const bool DefaultEagerTtl = true;
+
+        /// <summary> Default off-heap storage size is {@code -1} which means that off-heap storage is disabled. </summary>
+        public const long DefaultOffHeapMaxMemory = -1;
+
+        /// <summary> Default value for 'swapEnabled' flag. </summary>
+        public const bool DefaultEnableSwap = false;
+
+        /// <summary> Default value for 'maxConcurrentAsyncOps'. </summary>
+        public const int DefaultMaxConcurrentAsyncOperations = 500;
+
+        /// <summary> Default value for 'writeBehindEnabled' flag. </summary>
+        public const bool DefaultWriteBehindEnabled = false;
+
+        /// <summary> Default flush size for write-behind cache store. </summary>
+        public const int DefaultWriteBehindFlushSize = 10240; // 10K
+
+        /// <summary> Default flush frequency for write-behind cache store. </summary>
+        public static readonly TimeSpan DefaultWriteBehindFlushFrequency = TimeSpan.FromMilliseconds(5000);
+
+        /// <summary> Default count of flush threads for write-behind cache store. </summary>
+        public const int DefaultWriteBehindFlushThreadCount = 1;
+
+        /// <summary> Default batch size for write-behind cache store. </summary>
+        public const int DefaultWriteBehindBatchSize = 512;
+
+        /// <summary> Default value for load previous value flag. </summary>
+        public const bool DefaultLoadPreviousValue = false;
+
+        /// <summary> Default memory mode. </summary>
+        public const CacheMemoryMode DefaultMemoryMode = CacheMemoryMode.OnheapTiered;
+
+        /// <summary> Default value for 'readFromBackup' flag. </summary>
+        public const bool DefaultReadFromBackup = true;
+
+        /// <summary> Default timeout after which long query warning will be printed. </summary>
+        public static readonly TimeSpan DefaultLongQueryWarningTimeout = TimeSpan.FromMilliseconds(3000);
+
+        /// <summary> Default size for onheap SQL row cache size. </summary>
+        public const int DefaultSqlOnheapRowCacheSize = 10*1024;
+
+        /// <summary> Default value for keep portable in store behavior .</summary>
+        public const bool DefaultKeepVinaryInStore = true;
+
+        /// <summary> Default value for 'copyOnRead' flag. </summary>
+        public const bool DefaultCopyOnRead = true;
+
+        /// <summary>
+        /// Gets or sets the cache name.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+        /// </summary>
+        public CacheConfiguration() : this((string) null)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+        /// </summary>
+        /// <param name="name">Cache name.</param>
+        public CacheConfiguration(string name)
+        {
+            Name = name;
+
+            Backups = DefaultBackups;
+            AtomicityMode = DefaultAtomicityMode;
+            CacheMode = DefaultCacheMode;
+            CopyOnRead = DefaultCopyOnRead;
+            EagerTtl = DefaultEagerTtl;
+            EvictSynchronizedKeyBufferSize = DefaultEvictSynchronizedKeyBufferSize;
+            EvictSynchronized = DefaultEvictSynchronized;
+            EvictSynchronizedConcurrencyLevel = DefaultEvictSynchronizedConcurrencyLevel;
+            EvictSynchronizedTimeout = DefaultEvictSynchronizedTimeout;
+            Invalidate = DefaultInvalidate;
+            KeepBinaryInStore = DefaultKeepVinaryInStore;
+            LoadPreviousValue = DefaultLoadPreviousValue;
+            LockTimeout = DefaultLockTimeout;
+            LongQueryWarningTimeout = DefaultLongQueryWarningTimeout;
+            MaxConcurrentAsyncOperations = DefaultMaxConcurrentAsyncOperations;
+            MaxEvictionOverflowRatio = DefaultMaxEvictionOverflowRatio;
+            MemoryMode = DefaultMemoryMode;
+            OffHeapMaxMemory = DefaultOffHeapMaxMemory;
+            ReadFromBackup = DefaultReadFromBackup;
+            RebalanceBatchSize = DefaultRebalanceBatchSize;
+            RebalanceMode = DefaultRebalanceMode;
+            RebalanceThrottle = DefaultRebalanceThrottle;
+            RebalanceTimeout = DefaultRebalanceTimeout;
+            SqlOnheapRowCacheSize = DefaultSqlOnheapRowCacheSize;
+            StartSize = DefaultStartSize;
+            EnableSwap = DefaultEnableSwap;
+            WriteBehindBatchSize = DefaultWriteBehindBatchSize;
+            WriteBehindEnabled = DefaultWriteBehindEnabled;
+            WriteBehindFlushFrequency = DefaultWriteBehindFlushFrequency;
+            WriteBehindFlushSize = DefaultWriteBehindFlushSize;
+            WriteBehindFlushThreadCount= DefaultWriteBehindFlushThreadCount;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheConfiguration"/> class 
+        /// and populates <see cref="QueryEntities"/> according to provided query types.
+        /// </summary>
+        /// <param name="name">Cache name.</param>
+        /// <param name="queryTypes">
+        /// Collection of types to be registered as query entities. These types should use 
+        /// <see cref="QuerySqlFieldAttribute"/> to configure query fields and properties.
+        /// </param>
+        public CacheConfiguration(string name, params Type[] queryTypes) : this(name)
+        {
+            QueryEntities = queryTypes.Select(type => new QueryEntity {ValueType = type}).ToArray();
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+        /// </summary>
+        /// <param name="name">Cache name.</param>
+        /// <param name="queryEntities">Query entities.</param>
+        public CacheConfiguration(string name, params QueryEntity[] queryEntities) : this(name)
+        {
+            QueryEntities = queryEntities;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        internal CacheConfiguration(IBinaryRawReader reader)
+        {
+            AtomicityMode = (CacheAtomicityMode) reader.ReadInt();
+            AtomicWriteOrderMode = (CacheAtomicWriteOrderMode) reader.ReadInt();
+            Backups = reader.ReadInt();
+            CacheMode = (CacheMode) reader.ReadInt();
+            CopyOnRead = reader.ReadBoolean();
+            EagerTtl = reader.ReadBoolean();
+            EnableSwap = reader.ReadBoolean();
+            EvictSynchronized = reader.ReadBoolean();
+            EvictSynchronizedConcurrencyLevel = reader.ReadInt();
+            EvictSynchronizedKeyBufferSize = reader.ReadInt();
+            EvictSynchronizedTimeout = reader.ReadLongAsTimespan();
+            Invalidate = reader.ReadBoolean();
+            KeepBinaryInStore = reader.ReadBoolean();
+            LoadPreviousValue = reader.ReadBoolean();
+            LockTimeout = reader.ReadLongAsTimespan();
+            LongQueryWarningTimeout = reader.ReadLongAsTimespan();
+            MaxConcurrentAsyncOperations = reader.ReadInt();
+            MaxEvictionOverflowRatio = reader.ReadFloat();
+            MemoryMode = (CacheMemoryMode) reader.ReadInt();
+            Name = reader.ReadString();
+            OffHeapMaxMemory = reader.ReadLong();
+            ReadFromBackup = reader.ReadBoolean();
+            RebalanceBatchSize = reader.ReadInt();
+            RebalanceDelay = reader.ReadLongAsTimespan();
+            RebalanceMode = (CacheRebalanceMode) reader.ReadInt();
+            RebalanceThrottle = reader.ReadLongAsTimespan();
+            RebalanceTimeout = reader.ReadLongAsTimespan();
+            SqlEscapeAll = reader.ReadBoolean();
+            SqlOnheapRowCacheSize = reader.ReadInt();
+            StartSize = reader.ReadInt();
+            WriteBehindBatchSize = reader.ReadInt();
+            WriteBehindEnabled = reader.ReadBoolean();
+            WriteBehindFlushFrequency = reader.ReadLongAsTimespan();
+            WriteBehindFlushSize = reader.ReadInt();
+            WriteBehindFlushThreadCount = reader.ReadInt();
+            WriteSynchronizationMode = (CacheWriteSynchronizationMode) reader.ReadInt();
+            CacheStoreFactory = reader.ReadObject<IFactory<ICacheStore>>();
+
+            var count = reader.ReadInt();
+            QueryEntities = count == 0 ? null : Enumerable.Range(0, count).Select(x => new QueryEntity(reader)).ToList();
+        }
+
+        /// <summary>
+        /// Writes this instane to the specified writer.
+        /// </summary>
+        /// <param name="writer">The writer.</param>
+        internal void Write(IBinaryRawWriter writer)
+        {
+            writer.WriteInt((int) AtomicityMode);
+            writer.WriteInt((int) AtomicWriteOrderMode);
+            writer.WriteInt(Backups);
+            writer.WriteInt((int) CacheMode);
+            writer.WriteBoolean(CopyOnRead);
+            writer.WriteBoolean(EagerTtl);
+            writer.WriteBoolean(EnableSwap);
+            writer.WriteBoolean(EvictSynchronized);
+            writer.WriteInt(EvictSynchronizedConcurrencyLevel);
+            writer.WriteInt(EvictSynchronizedKeyBufferSize);
+            writer.WriteLong((long) EvictSynchronizedTimeout.TotalMilliseconds);
+            writer.WriteBoolean(Invalidate);
+            writer.WriteBoolean(KeepBinaryInStore);
+            writer.WriteBoolean(LoadPreviousValue);
+            writer.WriteLong((long) LockTimeout.TotalMilliseconds);
+            writer.WriteLong((long) LongQueryWarningTimeout.TotalMilliseconds);
+            writer.WriteInt(MaxConcurrentAsyncOperations);
+            writer.WriteFloat(MaxEvictionOverflowRatio);
+            writer.WriteInt((int) MemoryMode);
+            writer.WriteString(Name);
+            writer.WriteLong(OffHeapMaxMemory);
+            writer.WriteBoolean(ReadFromBackup);
+            writer.WriteInt(RebalanceBatchSize);
+            writer.WriteLong((long) RebalanceDelay.TotalMilliseconds);
+            writer.WriteInt((int) RebalanceMode);
+            writer.WriteLong((long) RebalanceThrottle.TotalMilliseconds);
+            writer.WriteLong((long) RebalanceTimeout.TotalMilliseconds);
+            writer.WriteBoolean(SqlEscapeAll);
+            writer.WriteInt(SqlOnheapRowCacheSize);
+            writer.WriteInt(StartSize);
+            writer.WriteInt(WriteBehindBatchSize);
+            writer.WriteBoolean(WriteBehindEnabled);
+            writer.WriteLong((long) WriteBehindFlushFrequency.TotalMilliseconds);
+            writer.WriteInt(WriteBehindFlushSize);
+            writer.WriteInt(WriteBehindFlushThreadCount);
+            writer.WriteInt((int) WriteSynchronizationMode);
+            writer.WriteObject(CacheStoreFactory);
+
+            if (QueryEntities != null)
+            {
+                writer.WriteInt(QueryEntities.Count);
+
+                foreach (var entity in QueryEntities)
+                {
+                    if (entity == null)
+                        throw new InvalidOperationException("Invalid cache configuration: QueryEntity can't be null.");
+
+                    entity.Write(writer);
+                }
+            }
+            else
+                writer.WriteInt(0);
+        }
+
+        /// <summary>
+        /// Gets or sets write synchronization mode. This mode controls whether the main        
+        /// caller should wait for update on other nodes to complete or not.
+        /// </summary>
+        public CacheWriteSynchronizationMode WriteSynchronizationMode { get; set; }
+
+        /// <summary>
+        /// Gets or sets flag indicating whether eviction is synchronized between primary, backup and near nodes.        
+        /// If this parameter is true and swap is disabled then <see cref="ICache{TK,TV}.LocalEvict"/>
+        /// will involve all nodes where an entry is kept.  
+        /// If this property is set to false then eviction is done independently on different cache nodes.        
+        /// Note that it's not recommended to set this value to true if cache store is configured since it will allow 
+        /// to significantly improve cache performance.
+        /// </summary>
+        [DefaultValue(DefaultEvictSynchronized)]
+        public bool EvictSynchronized { get; set; }
+
+        /// <summary>
+        /// Gets or sets size of the key buffer for synchronized evictions.
+        /// </summary>
+        [DefaultValue(DefaultEvictSynchronizedKeyBufferSize)]
+        public int EvictSynchronizedKeyBufferSize { get; set; }
+
+        /// <summary>
+        /// Gets or sets concurrency level for synchronized evictions. 
+        /// This flag only makes sense with <see cref="EvictSynchronized"/> set to true. 
+        /// When synchronized evictions are enabled, it is possible that local eviction policy will try 
+        /// to evict entries faster than evictions can be synchronized with backup or near nodes. 
+        /// This value specifies how many concurrent synchronous eviction sessions should be allowed 
+        /// before the system is forced to wait and let synchronous evictions catch up with the eviction policy.       
+        /// </summary>
+        [DefaultValue(DefaultEvictSynchronizedConcurrencyLevel)]
+        public int EvictSynchronizedConcurrencyLevel { get; set; }
+
+        /// <summary>
+        /// Gets or sets timeout for synchronized evictions
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:10")]
+        public TimeSpan EvictSynchronizedTimeout { get; set; }
+
+        /// <summary>
+        /// This value denotes the maximum size of eviction queue in percents of cache size 
+        /// in case of distributed cache (replicated and partitioned) and using synchronized eviction
+        /// <para/>        
+        /// That queue is used internally as a buffer to decrease network costs for synchronized eviction. 
+        /// Once queue size reaches specified value all required requests for all entries in the queue 
+        /// are sent to remote nodes and the queue is cleared.
+        /// </summary>
+        [DefaultValue(DefaultMaxEvictionOverflowRatio)]
+        public float MaxEvictionOverflowRatio { get; set; }
+
+        /// <summary>
+        /// Gets or sets flag indicating whether expired cache entries will be eagerly removed from cache. 
+        /// When set to false, expired entries will be removed on next entry access.        
+        /// </summary>
+        [DefaultValue(DefaultEagerTtl)]
+        public bool EagerTtl { get; set; }
+
+        /// <summary>
+        /// Gets or sets initial cache size which will be used to pre-create internal hash table after start.
+        /// </summary>
+        [DefaultValue(DefaultStartSize)]
+        public int StartSize { get; set; }
+
+        /// <summary>
+        /// Gets or sets flag indicating whether value should be loaded from store if it is not in the cache 
+        /// for the following cache operations:   
+        /// <list type="bullet">
+        /// <item><term><see cref="ICache{TK,TV}.PutIfAbsent"/></term></item>
+        /// <item><term><see cref="ICache{TK,TV}.Replace(TK,TV)"/></term></item>
+        /// <item><term><see cref="ICache{TK,TV}.Remove(TK)"/></term></item>
+        /// <item><term><see cref="ICache{TK,TV}.GetAndPut"/></term></item>
+        /// <item><term><see cref="ICache{TK,TV}.GetAndRemove"/></term></item>
+        /// <item><term><see cref="ICache{TK,TV}.GetAndReplace"/></term></item>
+        /// <item><term><see cref="ICache{TK,TV}.GetAndPutIfAbsent"/></term></item>
+        /// </list>     
+        /// </summary>
+        [DefaultValue(DefaultLoadPreviousValue)]
+        public bool LoadPreviousValue { get; set; }
+
+        /// <summary>
+        /// Gets or sets the flag indicating whether <see cref="ICacheStore"/> is working with binary objects 
+        /// instead of deserialized objects.
+        /// </summary>
+        [DefaultValue(DefaultKeepVinaryInStore)]
+        public bool KeepBinaryInStore { get; set; }
+
+        /// <summary>
+        /// Gets or sets caching mode to use.
+        /// </summary>
+        [DefaultValue(DefaultCacheMode)]
+        public CacheMode CacheMode { get; set; }
+
+        /// <summary>
+        /// Gets or sets cache atomicity mode.
+        /// </summary>
+        [DefaultValue(DefaultAtomicityMode)]
+        public CacheAtomicityMode AtomicityMode { get; set; }
+
+        /// <summary>
+        /// Gets or sets cache write ordering mode.
+        /// </summary>
+        public CacheAtomicWriteOrderMode AtomicWriteOrderMode { get; set; }
+
+        /// <summary>
+        /// Gets or sets number of nodes used to back up single partition for 
+        /// <see cref="Configuration.CacheMode.Partitioned"/> cache.
+        /// </summary>
+        [DefaultValue(DefaultBackups)]
+        public int Backups { get; set; }
+
+        /// <summary>
+        /// Gets or sets default lock acquisition timeout.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:00")]
+        public TimeSpan LockTimeout { get; set; }
+
+        /// <summary>
+        /// Invalidation flag. If true, values will be invalidated (nullified) upon commit in near cache.
+        /// </summary>
+        [DefaultValue(DefaultInvalidate)]
+        public bool Invalidate { get; set; }
+
+        /// <summary>
+        /// Gets or sets cache rebalance mode.
+        /// </summary>
+        [DefaultValue(DefaultRebalanceMode)]
+        public CacheRebalanceMode RebalanceMode { get; set; }
+
+        /// <summary>
+        /// Gets or sets size (in number bytes) to be loaded within a single rebalance message.
+        /// Rebalancing algorithm will split total data set on every node into multiple batches prior to sending data.
+        /// </summary>
+        [DefaultValue(DefaultRebalanceBatchSize)]
+        public int RebalanceBatchSize { get; set; }
+
+        /// <summary>
+        /// Flag indicating whether Ignite should use swap storage by default.
+        /// </summary>
+        [DefaultValue(DefaultEnableSwap)]
+        public bool EnableSwap { get; set; }
+
+        /// <summary>
+        /// Gets or sets maximum number of allowed concurrent asynchronous operations, 0 for unlimited.
+        /// </summary>
+        [DefaultValue(DefaultMaxConcurrentAsyncOperations)]
+        public int MaxConcurrentAsyncOperations { get; set; }
+
+        /// <summary>
+        /// Flag indicating whether Ignite should use write-behind behaviour for the cache store.
+        /// </summary>
+        [DefaultValue(DefaultWriteBehindEnabled)]
+        public bool WriteBehindEnabled { get; set; }
+
+        /// <summary>
+        /// Maximum size of the write-behind cache. If cache size exceeds this value, all cached items are flushed 
+        /// to the cache store and write cache is cleared.
+        /// </summary>
+        [DefaultValue(DefaultWriteBehindFlushSize)]
+        public int WriteBehindFlushSize { get; set; }
+
+        /// <summary>
+        /// Frequency with which write-behind cache is flushed to the cache store.
+        /// This value defines the maximum time interval between object insertion/deletion from the cache
+        /// at the moment when corresponding operation is applied to the cache store.
+        /// <para/> 
+        /// If this value is 0, then flush is performed according to the flush size.
+        /// <para/>
+        /// Note that you cannot set both
+        /// <see cref="WriteBehindFlushSize"/> and <see cref="WriteBehindFlushFrequency"/> to 0.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:05")]
+        public TimeSpan WriteBehindFlushFrequency { get; set; }
+
+        /// <summary>
+        /// Number of threads that will perform cache flushing. Cache flushing is performed when cache size exceeds 
+        /// value defined by <see cref="WriteBehindFlushSize"/>, or flush interval defined by 
+        /// <see cref="WriteBehindFlushFrequency"/> is elapsed.
+        /// </summary>
+        [DefaultValue(DefaultWriteBehindFlushThreadCount)]
+        public int WriteBehindFlushThreadCount { get; set; }
+
+        /// <summary>
+        /// Maximum batch size for write-behind cache store operations. 
+        /// Store operations (get or remove) are combined in a batch of this size to be passed to 
+        /// <see cref="ICacheStore.WriteAll"/> or <see cref="ICacheStore.DeleteAll"/> methods. 
+        /// </summary>
+        [DefaultValue(DefaultWriteBehindBatchSize)]
+        public int WriteBehindBatchSize { get; set; }
+
+        /// <summary>
+        /// Gets or sets rebalance timeout.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:10")]
+        public TimeSpan RebalanceTimeout { get; set; }
+
+        /// <summary>
+        /// Gets or sets delay upon a node joining or leaving topology (or crash) 
+        /// after which rebalancing should be started automatically. 
+        /// Rebalancing should be delayed if you plan to restart nodes
+        /// after they leave topology, or if you plan to start multiple nodes at once or one after another
+        /// and don't want to repartition and rebalance until all nodes are started.
+        /// </summary>
+        public TimeSpan RebalanceDelay { get; set; }
+
+        /// <summary>
+        /// Time to wait between rebalance messages to avoid overloading of CPU or network.
+        /// When rebalancing large data sets, the CPU or network can get over-consumed with rebalancing messages,
+        /// which consecutively may slow down the application performance. This parameter helps tune 
+        /// the amount of time to wait between rebalance messages to make sure that rebalancing process
+        /// does not have any negative performance impact. Note that application will continue to work
+        /// properly while rebalancing is still in progress.
+        /// <para/>
+        /// Value of 0 means that throttling is disabled.
+        /// </summary>
+        public TimeSpan RebalanceThrottle { get; set; }
+
+        /// <summary>
+        /// Gets or sets maximum amount of memory available to off-heap storage. Possible values are
+        /// -1 means that off-heap storage is disabled. 0 means that Ignite will not limit off-heap storage 
+        /// (it's up to user to properly add and remove entries from cache to ensure that off-heap storage 
+        /// does not grow indefinitely.
+        /// Any positive value specifies the limit of off-heap storage in bytes.
+        /// </summary>
+        [DefaultValue(DefaultOffHeapMaxMemory)]
+        public long OffHeapMaxMemory { get; set; }
+
+        /// <summary>
+        /// Gets or sets memory mode for cache.
+        /// </summary>
+        [DefaultValue(DefaultMemoryMode)]
+        public CacheMemoryMode MemoryMode { get; set; }
+
+        /// <summary>
+        /// Gets or sets flag indicating whether data can be read from backup.
+        /// </summary>
+        [DefaultValue(DefaultReadFromBackup)]
+        public bool ReadFromBackup { get; set; }
+
+        /// <summary>
+        /// Gets or sets flag indicating whether copy of of the value stored in cache should be created
+        /// for cache operation implying return value. 
+        /// </summary>
+        [DefaultValue(DefaultCopyOnRead)]
+        public bool CopyOnRead { get; set; }
+
+        /// <summary>
+        /// Gets or sets the timeout after which long query warning will be printed.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "00:00:03")]
+        public TimeSpan LongQueryWarningTimeout { get; set; }
+
+        /// <summary>
+        /// If true all the SQL table and field names will be escaped with double quotes like 
+        /// ({ "tableName"."fieldsName"}). This enforces case sensitivity for field names and
+        /// also allows having special characters in table and field names.
+        /// </summary>
+        public bool SqlEscapeAll { get; set; }
+
+        /// <summary>
+        /// Number of SQL rows which will be cached onheap to avoid deserialization on each SQL index access.
+        /// This setting only makes sense when offheap is enabled for this cache.
+        /// </summary>
+        [DefaultValue(DefaultSqlOnheapRowCacheSize)]
+        public int SqlOnheapRowCacheSize { get; set; }
+
+        /// <summary>
+        /// Gets or sets the factory for underlying persistent storage for read-through and write-through operations.
+        /// </summary>
+        public IFactory<ICacheStore> CacheStoreFactory { get; set; }
+
+        /// <summary>
+        /// Gets or sets the query entity configuration.
+        /// </summary>
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public ICollection<QueryEntity> QueryEntities { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.cs
new file mode 100644
index 0000000..a072302
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.cs
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    /// <summary>
+    /// Memory modes define whether cache entries are stored on heap memory, offheap memory, or in swap space.
+    /// </summary>
+    public enum CacheMemoryMode
+    {
+        /// <summary>
+        /// Entries will be stored on-heap first. The onheap tiered storage works as follows:
+        /// <list type="bullet">
+        /// <item><description>
+        /// Entries are cached on heap memory first.
+        /// </description></item>
+        /// <item><description>
+        /// If offheap memory is enabled and eviction policy evicts an entry from heap memory, 
+        /// entry will be moved to offheap memory. If offheap memory is disabled, then entry is simply discarded.
+        /// </description></item>
+        /// <item><description>
+        /// If swap space is enabled and offheap memory fills up, then entry will be evicted into swap space. 
+        /// If swap space is disabled, then entry will be discarded. If swap is enabled and offheap memory is disabled, 
+        /// then entry will be evicted directly from heap memory into swap.
+        /// </description></item>
+        /// </list>
+        /// <para />
+        /// Note that heap memory evictions are handled by configured EvictionPolicy implementation. By default, 
+        /// no eviction policy is enabled, so entries never leave heap memory space unless explicitly removed.
+        /// </summary>
+        OnheapTiered,
+
+        /// <summary>
+        /// Works the same as <see cref="OnheapTiered"/>, except that entries never end up in heap memory and get 
+        /// stored in offheap memory right away. Entries get cached in offheap memory first and then 
+        /// get evicted to swap, if one is configured.
+        /// </summary>
+        OffheapTiered,
+
+        /// <summary>
+        /// Entry keys will be stored on heap memory, and values will be stored in offheap memory.
+        /// Note that in this mode entries can be evicted only to swap.
+        /// </summary>
+        OffheapValues
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs
new file mode 100644
index 0000000..6608354
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    /// <summary>
+    /// Caching modes.
+    /// </summary>
+    public enum CacheMode
+    {
+        /// <summary>
+        /// Specifies local-only cache behaviour. In this mode caches residing on
+        /// different grid nodes will not know about each other.
+        /// <para />
+        /// Other than distribution, <see cref="Local"/> caches still have all
+        /// the caching features, such as eviction, expiration, swapping,
+        /// querying, etc... This mode is very useful when caching read-only data
+        /// or data that automatically expires at a certain interval and
+        /// then automatically reloaded from persistence store.
+        /// </summary>
+        Local,
+
+        /// <summary>
+        /// Specifies fully replicated cache behavior. In this mode all the keys are distributed
+        /// to all participating nodes. 
+        /// </summary>
+        Replicated,
+
+        /// <summary>
+        /// Specifies partitioned cache behaviour. In this mode the overall
+        /// key set will be divided into partitions and all partitions will be split
+        /// equally between participating nodes. 
+        /// <para />
+        /// Note that partitioned cache is always fronted by local 'near' cache which stores most recent data. 
+        /// </summary>
+        Partitioned
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs
new file mode 100644
index 0000000..2ef2115
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    /// <summary>
+    /// Cache rebalance mode. When rebalancing is enabled (i.e. has value other than <see cref="None"/>), 
+    /// distributed caches will attempt to rebalance all necessary values from other grid nodes. 
+    /// <para />
+    /// Replicated caches will try to load the full set of cache entries from other nodes, 
+    /// while partitioned caches will only load the entries for which current node is primary or backup.
+    /// <para />
+    /// Note that rebalance mode only makes sense for <see cref="CacheMode.Replicated"/> 
+    /// and <see cref="CacheMode.Partitioned"/> caches. Caches with <see cref="CacheMode.Local"/> 
+    /// mode are local by definition and therefore cannot rebalance any values from neighboring nodes.
+    /// </summary>
+    public enum CacheRebalanceMode
+    {
+        /// <summary>
+        /// Synchronous rebalance mode. Distributed caches will not start until all necessary data
+        /// is loaded from other available grid nodes.
+        /// </summary>
+        Sync,
+
+        /// <summary>
+        /// Asynchronous rebalance mode. Distributed caches will start immediately and will load all necessary
+        /// data from other available grid nodes in the background.
+        /// </summary>
+        Async,
+
+        /// <summary>
+        /// In this mode no rebalancing will take place which means that caches will be either loaded on
+        /// demand from persistent store whenever data is accessed, or will be populated explicitly.
+        /// </summary>
+        None
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs
new file mode 100644
index 0000000..3257f15
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    /// <summary>
+    /// Mode indicating how Ignite should wait for write replies from other nodes.
+    /// </summary>
+    public enum CacheWriteSynchronizationMode
+    {
+        /// <summary>
+        /// Mode indicating that Ignite should wait for write or commit replies from all nodes.
+        /// This behavior guarantees that whenever any of the atomic or transactional writes
+        /// complete, all other participating nodes which cache the written data have been updated.
+        /// </summary>
+        FullSync,
+
+        /// <summary>
+        /// Flag indicating that Ignite will not wait for write or commit responses from participating nodes,
+        /// which means that remote nodes may get their state updated a bit after any of the cache write methods
+        /// complete, or after {@link Transaction#commit()} method completes.
+        /// </summary>
+        FullAsync,
+
+        /// <summary>
+        /// This flag only makes sense for {@link CacheMode#PARTITIONED} mode. When enabled, Ignite will wait 
+        /// for write or commit to complete on primary node, but will not wait for backups to be updated.
+        /// </summary>
+        PrimarySync
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs
new file mode 100644
index 0000000..33849c7
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Represents cache query configuration alias.
+    /// </summary>
+    public class QueryAlias
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryAlias"/> class.
+        /// </summary>
+        public QueryAlias()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryAlias"/> class.
+        /// </summary>
+        /// <param name="fullName">The full name.</param>
+        /// <param name="alias">The alias.</param>
+        public QueryAlias(string fullName, string alias)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(fullName, "fullName");
+            IgniteArgumentCheck.NotNullOrEmpty(alias, "alias");
+
+            FullName = fullName;
+            Alias = alias;
+        }
+
+        /// <summary>
+        /// Gets or sets the full name of the query field.
+        /// </summary>
+        public string FullName { get; set; }
+        
+        /// <summary>
+        /// Gets or sets the alias for the full name.
+        /// </summary>
+        public string Alias { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
new file mode 100644
index 0000000..4151540
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
@@ -0,0 +1,401 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable MemberCanBePrivate.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
+    using System.Reflection;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
+
+    /// <summary>
+    /// Query entity is a description of cache entry (composed of key and value) 
+    /// in a way of how it must be indexed and can be queried.
+    /// </summary>
+    public class QueryEntity
+    {
+        /** */
+        private Type _keyType;
+
+        /** */
+        private Type _valueType;
+
+        /** */
+        private string _valueTypeName;
+
+        /** */
+        private string _keyTypeName;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+        /// </summary>
+        public QueryEntity()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+        /// </summary>
+        /// <param name="valueType">Type of the cache entry value.</param>
+        public QueryEntity(Type valueType)
+        {
+            ValueType = valueType;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+        /// </summary>
+        /// <param name="keyType">Type of the key.</param>
+        /// <param name="valueType">Type of the value.</param>
+        public QueryEntity(Type keyType, Type valueType)
+        {
+            KeyType = keyType;
+            ValueType = valueType;
+        }
+
+        /// <summary>
+        /// Gets or sets key Java type name.
+        /// </summary>
+        public string KeyTypeName
+        {
+            get { return _keyTypeName; }
+            set
+            {
+                _keyTypeName = value;
+                _keyType = null;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the type of the key.
+        /// <para />
+        /// This is a shortcut for <see cref="KeyTypeName"/>. Getter will return null for non-primitive types.
+        /// <para />
+        /// Setting this property will overwrite <see cref="Fields"/> and <see cref="Indexes"/> according to
+        /// <see cref="QuerySqlFieldAttribute"/>, if any.
+        /// </summary>
+        public Type KeyType
+        {
+            get { return _keyType ?? JavaTypes.GetDotNetType(KeyTypeName); }
+            set
+            {
+                RescanAttributes(value, _valueType);  // Do this first because it can throw
+
+                KeyTypeName = value == null
+                    ? null
+                    : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value));
+
+                _keyType = value;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets value Java type name.
+        /// </summary>
+        public string ValueTypeName
+        {
+            get { return _valueTypeName; }
+            set
+            {
+                _valueTypeName = value;
+                _valueType = null;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the type of the value.
+        /// <para />
+        /// This is a shortcut for <see cref="ValueTypeName"/>. Getter will return null for non-primitive types.
+        /// <para />
+        /// Setting this property will overwrite <see cref="Fields"/> and <see cref="Indexes"/> according to
+        /// <see cref="QuerySqlFieldAttribute"/>, if any.
+        /// </summary>
+        public Type ValueType
+        {
+            get { return _valueType ?? JavaTypes.GetDotNetType(ValueTypeName); }
+            set
+            {
+                RescanAttributes(_keyType, value);  // Do this first because it can throw
+
+                ValueTypeName = value == null
+                    ? null
+                    : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value));
+
+                _valueType = value;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets query fields, a map from field name to Java type name. 
+        /// The order of fields defines the order of columns returned by the 'select *' queries.
+        /// </summary>
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public ICollection<QueryField> Fields { get; set; }
+
+        /// <summary>
+        /// Gets or sets field name aliases: mapping from full name in dot notation to an alias 
+        /// that will be used as SQL column name.
+        /// Example: {"parent.name" -> "parentName"}.
+        /// </summary>
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public ICollection<QueryAlias> Aliases { get; set; }
+
+        /// <summary>
+        /// Gets or sets the query indexes.
+        /// </summary>
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public ICollection<QueryIndex> Indexes { get; set; }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        internal QueryEntity(IBinaryRawReader reader)
+        {
+            KeyTypeName = reader.ReadString();
+            ValueTypeName = reader.ReadString();
+
+            var count = reader.ReadInt();
+            Fields = count == 0 ? null : Enumerable.Range(0, count).Select(x =>
+                    new QueryField(reader.ReadString(), reader.ReadString())).ToList();
+
+            count = reader.ReadInt();
+            Aliases = count == 0 ? null : Enumerable.Range(0, count)
+                .Select(x=> new QueryAlias(reader.ReadString(), reader.ReadString())).ToList();
+
+            count = reader.ReadInt();
+            Indexes = count == 0 ? null : Enumerable.Range(0, count).Select(x => new QueryIndex(reader)).ToList();
+        }
+
+        /// <summary>
+        /// Writes this instance.
+        /// </summary>
+        internal void Write(IBinaryRawWriter writer)
+        {
+            writer.WriteString(KeyTypeName);
+            writer.WriteString(ValueTypeName);
+
+            if (Fields != null)
+            {
+                writer.WriteInt(Fields.Count);
+
+                foreach (var field in Fields)
+                {
+                    writer.WriteString(field.Name);
+                    writer.WriteString(field.FieldTypeName);
+                }
+            }
+            else
+                writer.WriteInt(0);
+
+
+            if (Aliases != null)
+            {
+                writer.WriteInt(Aliases.Count);
+
+                foreach (var queryAlias in Aliases)
+                {
+                    writer.WriteString(queryAlias.FullName);
+                    writer.WriteString(queryAlias.Alias);
+                }
+            }
+            else
+                writer.WriteInt(0);
+
+            if (Indexes != null)
+            {
+                writer.WriteInt(Indexes.Count);
+
+                foreach (var index in Indexes)
+                {
+                    if (index == null)
+                        throw new InvalidOperationException("Invalid cache configuration: QueryIndex can't be null.");
+
+                    index.Write(writer);
+                }
+            }
+            else
+                writer.WriteInt(0);
+        }
+
+
+        /// <summary>
+        /// Rescans the attributes in <see cref="KeyType"/> and <see cref="ValueType"/>.
+        /// </summary>
+        private void RescanAttributes(params Type[] types)
+        {
+            if (types.Length == 0 || types.All(t => t == null))
+                return;
+
+            var fields = new List<QueryField>();
+            var indexes = new List<QueryIndexEx>();
+
+            foreach (var type in types.Where(t => t != null))
+                ScanAttributes(type, fields, indexes, null, new HashSet<Type>());
+
+            if (fields.Any())
+                Fields = fields;
+
+            if (indexes.Any())
+                Indexes = GetGroupIndexes(indexes).ToArray();
+        }
+
+        /// <summary>
+        /// Gets the group indexes.
+        /// </summary>
+        /// <param name="indexes">Ungrouped indexes with their group names.</param>
+        /// <returns></returns>
+        private static IEnumerable<QueryIndex> GetGroupIndexes(List<QueryIndexEx> indexes)
+        {
+            return indexes.Where(idx => idx.IndexGroups != null)
+                .SelectMany(idx => idx.IndexGroups.Select(g => new {Index = idx, GroupName = g}))
+                .GroupBy(x => x.GroupName)
+                .Select(g =>
+                {
+                    var idxs = g.Select(pair => pair.Index).ToArray();
+
+                    var first = idxs.First();
+
+                    return new QueryIndex(idxs.SelectMany(i => i.Fields).ToArray())
+                    {
+                        IndexType = first.IndexType,
+                        Name = first.Name
+                    };
+                })
+                .Concat(indexes.Where(idx => idx.IndexGroups == null));
+        }
+
+        /// <summary>
+        /// Scans specified type for occurences of <see cref="QuerySqlFieldAttribute"/>.
+        /// </summary>
+        /// <param name="type">The type.</param>
+        /// <param name="fields">The fields.</param>
+        /// <param name="indexes">The indexes.</param>
+        /// <param name="parentPropName">Name of the parent property.</param>
+        /// <param name="visitedTypes">The visited types.</param>
+        private static void ScanAttributes(Type type, List<QueryField> fields, List<QueryIndexEx> indexes, 
+            string parentPropName, ISet<Type> visitedTypes)
+        {
+            Debug.Assert(type != null);
+            Debug.Assert(fields != null);
+            Debug.Assert(indexes != null);
+
+            if (visitedTypes.Contains(type))
+                throw new InvalidOperationException("Recursive Query Field definition detected: " + type);
+
+            visitedTypes.Add(type);
+
+            foreach (var memberInfo in GetFieldsAndProperties(type))
+            {
+                var customAttributes = memberInfo.Key.GetCustomAttributes(true);
+
+                foreach (var attr in customAttributes.OfType<QuerySqlFieldAttribute>())
+                {
+                    var columnName = attr.Name ?? memberInfo.Key.Name;
+
+                    // Dot notation is required for nested SQL fields
+                    if (parentPropName != null)
+                        columnName = parentPropName + "." + columnName;
+
+                    fields.Add(new QueryField(columnName, memberInfo.Value));
+
+                    if (attr.IsIndexed)
+                        indexes.Add(new QueryIndexEx(columnName, attr.IsDescending, QueryIndexType.Sorted,
+                            attr.IndexGroups));
+
+                    ScanAttributes(memberInfo.Value, fields, indexes, columnName, visitedTypes);
+                }
+
+                foreach (var attr in customAttributes.OfType<QueryTextFieldAttribute>())
+                {
+                    var columnName = attr.Name ?? memberInfo.Key.Name;
+
+                    // No dot notation for FullText index names
+                    indexes.Add(new QueryIndexEx(columnName, false, QueryIndexType.FullText, null));
+
+                    if (parentPropName != null)
+                        columnName = parentPropName + "." + columnName;
+
+                    fields.Add(new QueryField(columnName, memberInfo.Value));
+
+                    ScanAttributes(memberInfo.Value, fields, indexes, columnName, visitedTypes);
+                }
+            }
+
+            visitedTypes.Remove(type);
+        }
+
+        /// <summary>
+        /// Gets the fields and properties.
+        /// </summary>
+        /// <param name="type">The type.</param>
+        /// <returns></returns>
+        private static IEnumerable<KeyValuePair<MemberInfo, Type>> GetFieldsAndProperties(Type type)
+        {
+            Debug.Assert(type != null);
+
+            if (type.IsPrimitive)
+                yield break;
+
+            var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
+                               BindingFlags.DeclaredOnly;
+
+            while (type != typeof (object) && type != null)
+            {
+                foreach (var fieldInfo in type.GetFields(bindingFlags))
+                    yield return new KeyValuePair<MemberInfo, Type>(fieldInfo, fieldInfo.FieldType);
+
+                foreach (var propertyInfo in type.GetProperties(bindingFlags))
+                    yield return new KeyValuePair<MemberInfo, Type>(propertyInfo, propertyInfo.PropertyType);
+
+                type = type.BaseType;
+            }
+        }
+
+        /// <summary>
+        /// Extended index with group names.
+        /// </summary>
+        private class QueryIndexEx : QueryIndex
+        {
+            /// <summary>
+            /// Initializes a new instance of the <see cref="QueryIndexEx"/> class.
+            /// </summary>
+            /// <param name="fieldName">Name of the field.</param>
+            /// <param name="isDescending">if set to <c>true</c> [is descending].</param>
+            /// <param name="indexType">Type of the index.</param>
+            /// <param name="groups">The groups.</param>
+            public QueryIndexEx(string fieldName, bool isDescending, QueryIndexType indexType, 
+                ICollection<string> groups) 
+                : base(isDescending, indexType, fieldName)
+            {
+                IndexGroups = groups;
+            }
+
+            /// <summary>
+            /// Gets or sets the index groups.
+            /// </summary>
+            public ICollection<string> IndexGroups { get; set; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
new file mode 100644
index 0000000..8c70a29
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable MemberCanBePrivate.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using System;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Represents a queryable field.
+    /// </summary>
+    public class QueryField
+    {
+        /** */
+        private Type _type;
+
+        /** */
+        private string _fieldTypeName;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryField"/> class.
+        /// </summary>
+        public QueryField()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryField"/> class.
+        /// </summary>
+        /// <param name="name">Name.</param>
+        /// <param name="javaFieldTypeName">Java type name.</param>
+        public QueryField(string name, string javaFieldTypeName)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+            IgniteArgumentCheck.NotNullOrEmpty(javaFieldTypeName, "typeName");
+
+            Name = name;
+            FieldTypeName = javaFieldTypeName;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryField" /> class.
+        /// </summary>
+        /// <param name="name">Name.</param>
+        /// <param name="fieldType">Type.</param>
+        public QueryField(string name, Type fieldType)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+            IgniteArgumentCheck.NotNull(fieldType, "type");
+
+            Name = name;
+            FieldType = fieldType;
+        }
+
+        /// <summary>
+        /// Gets the field name.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Gets or sets the type of the value.
+        /// <para />
+        /// This is a shortcut for <see cref="FieldTypeName"/>. Getter will return null for non-primitive types.
+        /// </summary>
+        public Type FieldType
+        {
+            get { return _type ?? JavaTypes.GetDotNetType(FieldTypeName); }
+            set
+            {
+                FieldTypeName = value == null
+                    ? null
+                    : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value));
+
+                _type = value;
+            }
+        }
+
+        /// <summary>
+        /// Gets the Java type name.
+        /// </summary>
+        public string FieldTypeName
+        {
+            get { return _fieldTypeName; }
+            set
+            {
+                _fieldTypeName = value;
+                _type = null;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs
new file mode 100644
index 0000000..7079606
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs
@@ -0,0 +1,137 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable UnusedMember.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Represents cache query index configuration.
+    /// </summary>
+    public class QueryIndex
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryIndex"/> class.
+        /// </summary>
+        public QueryIndex()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryIndex" /> class.
+        /// </summary>
+        /// <param name="fieldNames">Names of the fields to index.</param>
+        public QueryIndex(params string[] fieldNames) : this(false, fieldNames)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryIndex" /> class.
+        /// </summary>
+        /// <param name="isDescending">Sort direction.</param>
+        /// <param name="fieldNames">Names of the fields to index.</param>
+        public QueryIndex(bool isDescending, params string[] fieldNames)
+        {
+            Fields = fieldNames.Select(f => new QueryIndexField(f, isDescending)).ToArray();
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryIndex" /> class.
+        /// </summary>
+        /// <param name="isDescending">Sort direction.</param>
+        /// <param name="indexType">Type of the index.</param>
+        /// <param name="fieldNames">Names of the fields to index.</param>
+        public QueryIndex(bool isDescending, QueryIndexType indexType, params string[] fieldNames) 
+            : this(isDescending, fieldNames)
+        {
+            IndexType = indexType;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryIndex"/> class.
+        /// </summary>
+        /// <param name="fields">The fields.</param>
+        public QueryIndex(params QueryIndexField[] fields)
+        {
+            if (fields == null || fields.Length == 0)
+                throw new ArgumentException("Query index must have at least one field");
+
+            if (fields.Any(f => f == null))
+                throw new ArgumentException("IndexField cannot be null.");
+
+            Fields = fields;
+        }
+
+        /// <summary>
+        /// Gets or sets the index name.
+        /// Will be set automatically if not specified.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Gets or sets the type of the index.
+        /// </summary>
+        public QueryIndexType IndexType { get; set; }
+
+        /// <summary>
+        /// Gets or sets a collection of fields to be indexed.
+        /// </summary>
+        public ICollection<QueryIndexField> Fields { get; private set; }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryIndex"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        internal QueryIndex(IBinaryRawReader reader)
+        {
+            Name = reader.ReadString();
+            IndexType = (QueryIndexType) reader.ReadByte();
+
+            var count = reader.ReadInt();
+            Fields = count == 0 ? null : Enumerable.Range(0, count).Select(x =>
+                new QueryIndexField(reader.ReadString(), reader.ReadBoolean())).ToList();
+        }
+
+        /// <summary>
+        /// Writes this instance.
+        /// </summary>
+        internal void Write(IBinaryRawWriter writer)
+        {
+            writer.WriteString(Name);
+            writer.WriteByte((byte) IndexType);
+
+            if (Fields != null)
+            {
+                writer.WriteInt(Fields.Count);
+
+                foreach (var field in Fields)
+                {
+                    writer.WriteString(field.Name);
+                    writer.WriteBoolean(field.IsDescending);
+                }
+            }
+            else
+                writer.WriteInt(0);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs
new file mode 100644
index 0000000..0b11e9c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Represents an indexed field.
+    /// </summary>
+    public class QueryIndexField
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryIndexField"/> class.
+        /// </summary>
+        public QueryIndexField()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryIndexField"/> class.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        public QueryIndexField(string name)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+
+            Name = name;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryIndexField"/> class.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <param name="isDescending">Sort direction.</param>
+        public QueryIndexField(string name, bool isDescending) : this (name)
+        {
+            IsDescending = isDescending;
+        }
+
+        /// <summary>
+        /// Gets the name.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Gets a value indicating whether this index is descending. Default is false.
+        /// </summary>
+        public bool IsDescending { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs
new file mode 100644
index 0000000..25fed62
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    /// <summary>
+    /// Query index type.
+    /// </summary>
+    public enum QueryIndexType
+    {
+        /// <summary>
+        /// Sorted index.
+        /// </summary>
+        Sorted,
+
+        /// <summary>
+        /// Fulltext index.
+        /// </summary>
+        FullText,
+
+        /// <summary>
+        /// Geo-spatial index.
+        /// </summary>
+        Geospatial
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
new file mode 100644
index 0000000..a522115
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+
+    /// <summary>
+    /// Marks field or property for SQL queries.
+    /// <para />
+    /// Using this attribute is an alternative to <see cref="QueryEntity.Fields"/> in <see cref="CacheConfiguration"/>.
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
+    public sealed class QuerySqlFieldAttribute : Attribute
+    {
+        /// <summary>
+        /// Gets or sets the sql field name.
+        /// If not provided, property or field name will be used.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether corresponding field should be indexed.
+        /// Just like with databases, field indexing may require additional overhead during updates, 
+        /// but makes select operations faster.
+        /// </summary>
+        public bool IsIndexed { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether index for this field should be descending.
+        /// Ignored when <see cref="IsIndexed"/> is <c>false</c>.
+        /// </summary>
+        public bool IsDescending { get; set; }
+
+        /// <summary>
+        /// Gets or sets the collection of index groups this field belongs to. 
+        /// Groups are used for compound indexes, 
+        /// whenever index should be created on more than one field.
+        /// All fields within the same group will belong to the same index.
+        /// </summary>
+        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", 
+            Justification = "Attribute initializers do not allow collections")]
+        public string[] IndexGroups { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs
new file mode 100644
index 0000000..6386496
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using System;
+
+    /// <summary>
+    /// Marks field or property for Text queries.
+    /// <para />
+    /// Using this attribute is an alternative to <see cref="QueryEntity.Fields"/> in <see cref="CacheConfiguration"/>.
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
+    public sealed class QueryTextFieldAttribute : Attribute
+    {
+        /// <summary>
+        /// Gets or sets the text field name.
+        /// If not provided, property or field name will be used.
+        /// </summary>
+        public string Name { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
index 192dabf..f5e7cd2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Cache
     using System.Collections.Generic;
     using System.Diagnostics.CodeAnalysis;
     using System.Threading.Tasks;
+    using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Cache.Expiry;
     using Apache.Ignite.Core.Cache.Query;
     using Apache.Ignite.Core.Cache.Query.Continuous;
@@ -66,6 +67,11 @@ namespace Apache.Ignite.Core.Cache
         IIgnite Ignite { get; }
 
         /// <summary>
+        /// Gets the cache configuration.
+        /// </summary>
+        CacheConfiguration GetConfiguration();
+
+        /// <summary>
         /// Checks whether this cache contains no key-value mappings.
         /// <para />
         /// Semantically equals to <c>ICache.Size(CachePeekMode.PRIMARY) == 0</c>.

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs
new file mode 100644
index 0000000..67c2683
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Common
+{
+    using System;
+
+    /// <summary>
+    /// Factory that produces instances of a specific type.
+    /// Implementation can be passed over the wire and thus should be marked with <see cref="SerializableAttribute"/>.
+    /// </summary>
+    public interface IFactory<out T>
+    {
+        /// <summary>
+        /// Creates an instance of the cache store.
+        /// </summary>
+        /// <returns>New instance of the cache store.</returns>
+        T CreateInstance();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs
new file mode 100644
index 0000000..2fcafbf
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Discovery
+{
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Discovery.Tcp;
+
+    /// <summary>
+    /// Represents a discovery service provider interface.
+    /// Only predefined implementation is supported now: <see cref="TcpDiscoverySpi"/>.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
+    public interface IDiscoverySpi
+    {
+        // No-op.
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs
new file mode 100644
index 0000000..c2f4329
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Discovery.Tcp
+{
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+    using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+    /// <summary>
+    /// Represents an IP finder for <see cref="TcpDiscoverySpi"/>.
+    /// Only predefined implementations are supported now: 
+    /// <see cref="TcpDiscoveryStaticIpFinder"/>, <see cref="TcpDiscoveryMulticastIpFinder"/>.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
+    public interface ITcpDiscoveryIpFinder
+    {
+        // No-op.
+    }
+}
\ No newline at end of file


[16/28] ignite git commit: ignite-2080 Data alignment issues with Unsafe

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java
new file mode 100644
index 0000000..f3ff781
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java
@@ -0,0 +1,249 @@
+/*
+ * 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.util.io;
+
+import java.io.ByteArrayInputStream;
+import java.util.Random;
+import junit.framework.TestCase;
+
+import static org.apache.ignite.GridTestIoUtils.getCharByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getDoubleByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getFloatByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getIntByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getLongByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getShortByByteLE;
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Grid unsafe data input/output byte order sanity tests.
+ */
+public class GridUnsafeDataInputOutputByteOrderSelfTest extends TestCase {
+    /** Array length. */
+    private static final int ARR_LEN = 16;
+
+    /** Length bytes. */
+    private static final int LEN_BYTES = 4;
+
+    /** Rnd. */
+    private static Random RND = new Random();
+
+    /** Out. */
+    private GridUnsafeDataOutput out;
+
+    /** In. */
+    private GridUnsafeDataInput in;
+
+    /** {@inheritDoc} */
+    @Override protected void setUp() throws Exception {
+        out = new GridUnsafeDataOutput(16 * 8+ LEN_BYTES);
+        in = new GridUnsafeDataInput();
+        in.inputStream(new ByteArrayInputStream(out.internalArray()));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void tearDown() throws Exception {
+        in.close();
+        out.close();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testShort() throws Exception {
+        short val = (short)RND.nextLong();
+
+        out.writeShort(val);
+
+        assertEquals(val, getShortByByteLE(out.internalArray()));
+        assertEquals(val, in.readShort());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testShortArray() throws Exception {
+        short[] arr = new short[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = (short)RND.nextLong();
+
+        out.writeShortArray(arr);
+
+        byte[] outArr = out.internalArray();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getShortByByteLE(outArr, i * 2+ LEN_BYTES));
+
+        assertArrayEquals(arr, in.readShortArray());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testChar() throws Exception {
+        char val = (char)RND.nextLong();
+
+        out.writeChar(val);
+
+        assertEquals(val, getCharByByteLE(out.internalArray()));
+        assertEquals(val, in.readChar());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCharArray() throws Exception {
+        char[] arr = new char[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = (char)RND.nextLong();
+
+        out.writeCharArray(arr);
+
+        byte[] outArr = out.internalArray();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getCharByByteLE(outArr, i * 2+ LEN_BYTES));
+
+        assertArrayEquals(arr, in.readCharArray());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testInt() throws Exception {
+        int val = RND.nextInt();
+
+        out.writeInt(val);
+
+        assertEquals(val, getIntByByteLE(out.internalArray()));
+        assertEquals(val, in.readInt());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testIntArray() throws Exception {
+        int[] arr = new int[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextInt();
+
+        out.writeIntArray(arr);
+
+        byte[] outArr = out.internalArray();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getIntByByteLE(outArr, i * 4+ LEN_BYTES));
+
+        assertArrayEquals(arr, in.readIntArray());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLong() throws Exception {
+        long val = RND.nextLong();
+
+        out.writeLong(val);
+
+        assertEquals(val, getLongByByteLE(out.internalArray()));
+        assertEquals(val, in.readLong());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLongArray() throws Exception {
+        long[] arr = new long[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextLong();
+
+        out.writeLongArray(arr);
+
+        byte[] outArr = out.internalArray();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getLongByByteLE(outArr, i * 8+ LEN_BYTES));
+
+        assertArrayEquals(arr, in.readLongArray());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFloat() throws Exception {
+        float val = RND.nextFloat();
+
+        out.writeFloat(val);
+
+        assertEquals(val, getFloatByByteLE(out.internalArray()), 0);
+        assertEquals(val, in.readFloat(), 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFloatArray() throws Exception {
+        float[] arr = new float[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextFloat();
+
+        out.writeFloatArray(arr);
+
+        byte[] outArr = out.internalArray();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getFloatByByteLE(outArr, i * 4+ LEN_BYTES), 0);
+
+        assertArrayEquals(arr, in.readFloatArray(), 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDouble() throws Exception {
+        double val = RND.nextDouble();
+
+        out.writeDouble(val);
+
+        assertEquals(val, getDoubleByByteLE(out.internalArray()), 0);
+        assertEquals(val, in.readDouble(), 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDoubleArray() throws Exception {
+        double[] arr = new double[ARR_LEN];
+
+        for (int i = 0; i < ARR_LEN; i++)
+            arr[i] = RND.nextDouble();
+
+        out.writeDoubleArray(arr);
+
+        byte[] outArr = out.internalArray();
+
+        for (int i = 0; i < ARR_LEN; i++)
+            assertEquals(arr[i], getDoubleByByteLE(outArr, i * 8+ LEN_BYTES), 0);
+
+        assertArrayEquals(arr, in.readDoubleArray(), 0);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
index 37e7afe..1bbae51 100644
--- a/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
@@ -50,7 +50,6 @@ import org.apache.ignite.testframework.GridTestUtils;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentLinkedDeque8;
 import org.jsr166.ThreadLocalRandom8;
-import sun.misc.Unsafe;
 
 /**
  * Tests synchronization performance vs. lock.
@@ -948,16 +947,14 @@ public class GridBasicPerformanceTest {
 
         GridTimer t = new GridTimer("unsafe");
 
-        Unsafe unsafe = GridUnsafe.unsafe();
-
         int mem = 1024;
 
         for (int i = 0; i < MAX; i++) {
-            addrs[i] = unsafe.allocateMemory(mem);
+            addrs[i] = GridUnsafe.allocateMemory(mem);
 
-            unsafe.putByte(addrs[i] + RAND.nextInt(mem), (byte)RAND.nextInt(mem));
+            GridUnsafe.putByte(addrs[i] + RAND.nextInt(mem), (byte)RAND.nextInt(mem));
 
-            v = unsafe.getByte(addrs[i] + RAND.nextInt(mem));
+            v = GridUnsafe.getByte(addrs[i] + RAND.nextInt(mem));
         }
 
         X.println("Unsafe [time=" + t.stop() + "ms, v=" + v + ']');
@@ -965,7 +962,7 @@ public class GridBasicPerformanceTest {
         Thread.sleep(5000L);
 
         for (long l : addrs)
-            unsafe.freeMemory(l);
+            GridUnsafe.freeMemory(l);
     }
 
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
index 2d5b2c5..7bb2cf3 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
@@ -1101,7 +1101,7 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
         // On Windows and Mac machines two nodes can reside on the same port
         // (if one node has localHost="127.0.0.1" and another has localHost="0.0.0.0").
         // So two nodes do not even discover each other.
-        if (U.isWindows() || U.isMacOs())
+        if (U.isWindows() || U.isMacOs() || U.isSolaris())
             return;
 
         try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 27511ff..3c83d86 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -206,7 +206,7 @@ public abstract class GridAbstractTest extends TestCase {
      * @throws Exception If failed.
      */
     protected <T> T allocateInstance(Class<T> cls) throws Exception {
-        return (T)GridUnsafe.unsafe().allocateInstance(cls);
+        return (T)GridUnsafe.allocateInstance(cls);
     }
 
     /**
@@ -215,7 +215,7 @@ public abstract class GridAbstractTest extends TestCase {
      */
     @Nullable protected <T> T allocateInstance0(Class<T> cls) {
         try {
-            return (T)GridUnsafe.unsafe().allocateInstance(cls);
+            return (T)GridUnsafe.allocateInstance(cls);
         }
         catch (InstantiationException e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index 5eb7b66..3ec55d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -46,6 +46,8 @@ import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompac
 import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesDefaultMappersSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest;
+import org.apache.ignite.internal.binary.streams.BinaryHeapStreamByteOrderSelfTest;
+import org.apache.ignite.internal.binary.streams.BinaryOffheapStreamByteOrderSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataMultinodeTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataTest;
@@ -132,6 +134,10 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
         suite.addTestSuite(BinaryTxCacheLocalEntriesSelfTest.class);
         suite.addTestSuite(BinaryAtomicCacheLocalEntriesSelfTest.class);
 
+        // Byte order
+        suite.addTestSuite(BinaryHeapStreamByteOrderSelfTest.class);
+        suite.addTestSuite(BinaryOffheapStreamByteOrderSelfTest.class);
+
         return suite;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
index 1065fbd..e4a2bee 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
@@ -19,6 +19,8 @@ package org.apache.ignite.testsuites;
 
 import java.util.Set;
 import junit.framework.TestSuite;
+import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2ByteOrderSelfTest;
+import org.apache.ignite.internal.util.io.GridUnsafeDataInputOutputByteOrderSelfTest;
 import org.apache.ignite.internal.util.io.GridUnsafeDataOutputArraySizingSelfTest;
 import org.apache.ignite.marshaller.jdk.GridJdkMarshallerSelfTest;
 import org.apache.ignite.marshaller.optimized.OptimizedMarshallerEnumSelfTest;
@@ -55,8 +57,10 @@ public class IgniteMarshallerSelfTestSuite extends TestSuite {
         GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, OptimizedObjectStreamSelfTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, GridUnsafeDataOutputArraySizingSelfTest.class, ignoredTests);
+        GridTestUtils.addTestIfNeeded(suite, GridUnsafeDataInputOutputByteOrderSelfTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerNodeFailoverTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerSerialPersistentFieldsSelfTest.class, ignoredTests);
+        GridTestUtils.addTestIfNeeded(suite, DirectByteBufferStreamImplV2ByteOrderSelfTest.class, ignoredTests);
 
         return suite;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
index 0efdf2b..b940c72 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
@@ -39,6 +39,7 @@ import org.apache.ignite.internal.processors.hadoop.counter.HadoopPerformanceCou
 import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopConcurrentHashMultimap;
 import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopMultimap;
 import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopSkipList;
+import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -56,8 +57,6 @@ import org.apache.ignite.thread.IgniteThread;
 import static org.apache.ignite.internal.processors.hadoop.HadoopJobProperty.PARTITION_HASHMAP_SIZE;
 import static org.apache.ignite.internal.processors.hadoop.HadoopJobProperty.SHUFFLE_REDUCER_NO_SORTING;
 import static org.apache.ignite.internal.processors.hadoop.HadoopJobProperty.get;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.UNSAFE;
 
 /**
  * Shuffle job.
@@ -299,7 +298,7 @@ public class HadoopShuffleJob<T> implements AutoCloseable {
 
         /** */
         @Override public void copyTo(long ptr) {
-            UNSAFE.copyMemory(buf, BYTE_ARR_OFF + off, null, ptr, size);
+            GridUnsafe.copyMemory(buf, GridUnsafe.BYTE_ARR_OFF + off, null, ptr, size);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java
index 87a0ee0..69dfe64 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java
@@ -24,13 +24,11 @@ import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.processors.hadoop.HadoopJobId;
 import org.apache.ignite.internal.processors.hadoop.message.HadoopMessage;
+import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.UNSAFE;
-
 /**
  * Shuffle message.
  */
@@ -167,11 +165,11 @@ public class HadoopShuffleMessage implements HadoopMessage {
     private void add(byte marker, long ptr, int size) {
         buf[off++] = marker;
 
-        UNSAFE.putInt(buf, BYTE_ARR_OFF + off, size);
+        GridUnsafe.putInt(buf, GridUnsafe.BYTE_ARR_OFF + off, size);
 
         off += 4;
 
-        UNSAFE.copyMemory(null, ptr, buf, BYTE_ARR_OFF + off, size);
+        GridUnsafe.copyMemory(null, ptr, buf, GridUnsafe.BYTE_ARR_OFF + off, size);
 
         off += size;
     }
@@ -183,7 +181,7 @@ public class HadoopShuffleMessage implements HadoopMessage {
         for (int i = 0; i < off;) {
             byte marker = buf[i++];
 
-            int size = UNSAFE.getInt(buf, BYTE_ARR_OFF + i);
+            int size = GridUnsafe.getInt(buf, GridUnsafe.BYTE_ARR_OFF + i);
 
             i += 4;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/streams/HadoopDataOutStream.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/streams/HadoopDataOutStream.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/streams/HadoopDataOutStream.java
index 99d8963..f7b1a73 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/streams/HadoopDataOutStream.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/streams/HadoopDataOutStream.java
@@ -20,11 +20,9 @@ package org.apache.ignite.internal.processors.hadoop.shuffle.streams;
 import java.io.DataOutput;
 import java.io.OutputStream;
 import java.nio.charset.StandardCharsets;
+import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
 
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.UNSAFE;
-
 /**
  * Data output stream.
  */
@@ -69,7 +67,7 @@ public class HadoopDataOutStream extends OutputStream implements DataOutput {
 
     /** {@inheritDoc} */
     @Override public void write(byte[] b, int off, int len) {
-        UNSAFE.copyMemory(b, BYTE_ARR_OFF + off, null, move(len), len);
+        GridUnsafe.copyMemory(b, GridUnsafe.BYTE_ARR_OFF + off, null, move(len), len);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java
index d5deaac..a37d74b 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java
@@ -36,14 +36,12 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobInfo;
 import org.apache.ignite.internal.processors.hadoop.HadoopTaskContext;
 import org.apache.ignite.internal.processors.hadoop.HadoopTaskInput;
 import org.apache.ignite.internal.util.GridRandom;
+import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.io.GridDataInput;
 import org.apache.ignite.internal.util.io.GridUnsafeDataInput;
 import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
 import org.apache.ignite.internal.util.typedef.X;
 
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.UNSAFE;
-
 /**
  *
  */
@@ -162,7 +160,7 @@ public class HadoopConcurrentHashMultimapSelftest extends HadoopAbstractMapTest
             private void read(long ptr, int size, Writable w) {
                 assert size == 4 : size;
 
-                UNSAFE.copyMemory(null, ptr, buf, BYTE_ARR_OFF, size);
+                GridUnsafe.copyMemory(null, ptr, buf, GridUnsafe.BYTE_ARR_OFF, size);
 
                 dataInput.bytes(buf, size);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopSkipListSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopSkipListSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopSkipListSelfTest.java
index 969eeab..f70ef2f 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopSkipListSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopSkipListSelfTest.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobInfo;
 import org.apache.ignite.internal.processors.hadoop.HadoopTaskContext;
 import org.apache.ignite.internal.processors.hadoop.HadoopTaskInput;
 import org.apache.ignite.internal.util.GridRandom;
+import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.io.GridDataInput;
 import org.apache.ignite.internal.util.io.GridUnsafeDataInput;
 import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
@@ -45,8 +46,6 @@ import org.apache.ignite.internal.util.typedef.X;
 import static java.lang.Math.abs;
 import static java.lang.Math.ceil;
 import static java.lang.Math.max;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.UNSAFE;
 
 /**
  * Skip list tests.
@@ -201,7 +200,7 @@ public class HadoopSkipListSelfTest extends HadoopAbstractMapTest {
             private void read(long ptr, int size, Writable w) {
                 assert size == 4 : size;
 
-                UNSAFE.copyMemory(null, ptr, buf, BYTE_ARR_OFF, size);
+                GridUnsafe.copyMemory(null, ptr, buf, GridUnsafe.BYTE_ARR_OFF, size);
 
                 dataInput.bytes(buf, size);
 


[09/28] ignite git commit: 2224

Posted by vo...@apache.org.
2224


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

Branch: refs/heads/ignite-2508
Commit: 01135066d54df254a0b23afbbffca2ed103e3a8c
Parents: 62502b2
Author: Anton Vinogradov <av...@apache.org>
Authored: Tue Feb 2 15:25:05 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Feb 2 15:25:05 2016 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteCache.java     |  45 +-
 .../processors/cache/CacheEntryImplEx.java      |  14 +-
 .../processors/cache/GridCacheAdapter.java      | 297 +++++--
 .../processors/cache/GridCacheContext.java      |  33 +-
 .../processors/cache/GridCacheMapEntry.java     |   2 +-
 .../processors/cache/GridCacheProxyImpl.java    |  51 ++
 .../processors/cache/IgniteCacheProxy.java      |  51 ++
 .../processors/cache/IgniteInternalCache.java   |  85 ++
 .../dht/CacheDistributedGetFutureAdapter.java   |  15 -
 .../distributed/dht/GridDhtCacheAdapter.java    |   7 +-
 .../cache/distributed/dht/GridDhtGetFuture.java |   6 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |   4 +-
 .../dht/GridPartitionedGetFuture.java           |  38 +-
 .../dht/GridPartitionedSingleGetFuture.java     |  17 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  82 +-
 .../dht/colocated/GridDhtColocatedCache.java    |  42 +-
 .../distributed/near/GridNearAtomicCache.java   |   6 +-
 .../distributed/near/GridNearCacheAdapter.java  |   6 +-
 .../distributed/near/GridNearCacheEntry.java    |   3 +-
 .../distributed/near/GridNearGetFuture.java     |  45 +-
 ...arOptimisticSerializableTxPrepareFuture.java |   2 +-
 .../near/GridNearOptimisticTxPrepareFuture.java |   4 +
 .../GridNearPessimisticTxPrepareFuture.java     |   2 +
 .../near/GridNearTransactionalCache.java        |   9 +-
 .../local/atomic/GridLocalAtomicCache.java      |  97 ++-
 .../cache/transactions/IgniteTxEntry.java       |  32 +-
 .../transactions/IgniteTxLocalAdapter.java      | 196 +++--
 .../cache/transactions/IgniteTxLocalEx.java     |   3 +-
 .../cache/transactions/IgniteTxManager.java     |   2 +-
 .../cache/CacheGetEntryAbstractTest.java        | 803 +++++++++++++++++++
 ...GetEntryOptimisticReadCommittedSeltTest.java |  36 +
 ...etEntryOptimisticRepeatableReadSeltTest.java |  36 +
 ...eGetEntryOptimisticSerializableSeltTest.java |  36 +
 ...etEntryPessimisticReadCommittedSeltTest.java |  36 +
 ...tEntryPessimisticRepeatableReadSeltTest.java |  36 +
 ...GetEntryPessimisticSerializableSeltTest.java |  36 +
 .../cache/CacheReadThroughRestartSelfTest.java  |  43 +-
 .../CacheSerializableTransactionsTest.java      | 142 +++-
 .../cache/GridCacheAbstractFullApiSelfTest.java | 141 ++++
 .../GridCacheInterceptorAbstractSelfTest.java   | 172 +++-
 ...GridCacheDhtEvictionNearReadersSelfTest.java |   2 +-
 .../multijvm/IgniteCacheProcessProxy.java       |  59 +-
 .../testsuites/IgniteCacheTestSuite4.java       |  12 +
 .../config/benchmark-multicast.properties       |   7 +
 .../IgniteGetEntriesPutAllTxBenchmark.java      |  73 ++
 .../cache/IgnitePutGetEntryBenchmark.java       |  47 ++
 .../cache/IgnitePutGetEntryTxBenchmark.java     |  73 ++
 47 files changed, 2644 insertions(+), 342 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 886dca6..a791e38 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -31,10 +31,12 @@ import javax.cache.CacheException;
 import javax.cache.configuration.Configuration;
 import javax.cache.event.CacheEntryRemovedListener;
 import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.integration.CacheLoader;
 import javax.cache.integration.CacheWriter;
 import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.EntryProcessorResult;
+import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.cache.CacheMetrics;
 import org.apache.ignite.cache.CacheMode;
@@ -390,18 +392,59 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
      * <code>null</code> value for a key.
      */
     @IgniteAsyncSupported
-    <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
+    public <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
         Object... args);
 
     /** {@inheritDoc} */
     @IgniteAsyncSupported
     @Override public V get(K key);
 
+    /**
+     * Gets an entry from the cache.
+     * <p>
+     * If the cache is configured to use read-through, and get would return null
+     * because the entry is missing from the cache, the Cache's {@link CacheLoader}
+     * is called in an attempt to load the entry.
+     *
+     * @param key the key whose associated value is to be returned
+     * @return the element, or null, if it does not exist.
+     * @throws IllegalStateException if the cache is {@link #isClosed()}
+     * @throws NullPointerException  if the key is null
+     * @throws CacheException        if there is a problem fetching the value
+     * @throws ClassCastException    if the implementation is configured to perform
+     * runtime-type-checking, and the key or value types are incompatible with those that have been
+     * configured for the {@link Cache}
+     */
+    @IgniteAsyncSupported
+    public CacheEntry<K, V> getEntry(K key);
+
     /** {@inheritDoc} */
     @IgniteAsyncSupported
     @Override public Map<K, V> getAll(Set<? extends K> keys);
 
     /**
+     * Gets a collection of entries from the {@link Cache}.
+     * <p>
+     * If the cache is configured read-through, and a get for a key would
+     * return null because an entry is missing from the cache, the Cache's
+     * {@link CacheLoader} is called in an attempt to load the entry. If an
+     * entry cannot be loaded for a given key, the key will not be present in
+     * the returned Collection.
+     *
+     * @param keys The keys whose associated values are to be returned.
+     * @return A collection of entries that were found for the given keys. Entries not found
+     *         in the cache are not in the returned collection.
+     * @throws NullPointerException  if keys is null or if keys contains a null
+     * @throws IllegalStateException if the cache is {@link #isClosed()}
+     * @throws CacheException        if there is a problem fetching the values
+     * @throws ClassCastException    if the implementation is configured to perform
+     * runtime-type-checking, and the key or value types are incompatible with those that have been
+     * configured for the {@link Cache}
+     */
+    @IgniteAsyncSupported
+    public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys);
+
+    /**
      * Gets values from cache. Will bypass started transaction, if any, i.e. will not enlist entries
      * and will not lock any keys if pessimistic transaction is started by thread.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImplEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImplEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImplEx.java
index 1c7111a..af926c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImplEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImplEx.java
@@ -21,9 +21,13 @@ import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 
+import static org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry.GET_ENTRY_INVALID_VER_AFTER_GET;
+import static org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry.GET_ENTRY_INVALID_VER_UPDATED;
+
 /**
  *
  */
@@ -54,6 +58,14 @@ public class CacheEntryImplEx<K, V> extends CacheEntryImpl<K, V> implements Cach
 
     /** {@inheritDoc} */
     public GridCacheVersion version() {
+        if (ver == GET_ENTRY_INVALID_VER_AFTER_GET) {
+            throw new IgniteException("Impossible to get entry version after " +
+                "get() inside OPTIMISTIC REPEATABLE_READ transaction. Use only getEntry() or getEntries() inside " +
+                "OPTIMISTIC REPEATABLE_READ transaction to solve this problem.");
+        }
+        else if (ver == GET_ENTRY_INVALID_VER_UPDATED)
+            throw new IgniteException("Impossible to get version for entry updated in transaction.");
+
         return ver;
     }
 
@@ -81,7 +93,7 @@ public class CacheEntryImplEx<K, V> extends CacheEntryImpl<K, V> implements Cach
         String res = "CacheEntry [key=" + getKey() +
             ", val=" + getValue();
 
-        if (ver != null) {
+        if (ver != null && ver != GET_ENTRY_INVALID_VER_AFTER_GET && ver != GET_ENTRY_INVALID_VER_UPDATED) {
             res += ", topVer=" + ver.topologyVersion() +
                 ", nodeOrder=" + ver.nodeOrder() +
                 ", order=" + ver.order() +

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 9fd65e5..69abc54 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -52,6 +52,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.cache.CacheInterceptor;
 import org.apache.ignite.cache.CacheMetrics;
 import org.apache.ignite.cache.CachePeekMode;
@@ -607,7 +608,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             /*task name*/null,
             /*deserialize binary*/false,
             /*skip values*/true,
-            /*can remap*/true
+            /*can remap*/true,
+            false
         );
     }
 
@@ -633,7 +635,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             /*task name*/null,
             /*deserialize binary*/false,
             /*skip values*/true,
-            /*can remap*/true
+            /*can remap*/true,
+            false
         ).chain(new CX1<IgniteInternalFuture<Map<K, V>>, Boolean>() {
             @Override public Boolean applyx(IgniteInternalFuture<Map<K, V>> fut) throws IgniteCheckedException {
                 Map<K, V> kvMap = fut.get();
@@ -1296,7 +1299,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             taskName,
             /*deserialize cache objects*/true,
             /*skip values*/false,
-            /*can remap*/true
+            /*can remap*/true,
+            false
         ).get().get(key);
     }
 
@@ -1312,7 +1316,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             taskName,
             true,
             false,
-            /*can remap*/true
+            /*can remap*/true,
+            false
         ).chain(new CX1<IgniteInternalFuture<Map<K, V>>, V>() {
             @Override public V applyx(IgniteInternalFuture<Map<K, V>> e) throws IgniteCheckedException {
                 return e.get().get(key);
@@ -1332,7 +1337,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             taskName,
             /*deserialize cache objects*/true,
             /*skip values*/false,
-            /*can remap*/false
+            /*can remap*/false,
+            false
         ).get().get(key);
     }
 
@@ -1352,7 +1358,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             taskName,
             !ctx.keepBinary(),
             /*skip values*/false,
-            /*can remap*/true);
+            /*can remap*/true,
+            false);
     }
 
     /**
@@ -1372,7 +1379,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
         long start = statsEnabled ? System.nanoTime() : 0L;
 
-        V val = get(key, !ctx.keepBinary());
+        V val = get(key, !ctx.keepBinary(), false);
 
         if (ctx.config().getInterceptor() != null)
             val = (V)ctx.config().getInterceptor().onGet(key, val);
@@ -1384,6 +1391,30 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     }
 
     /** {@inheritDoc} */
+    @Nullable @Override public CacheEntry<K, V> getEntry(K key) throws IgniteCheckedException {
+        A.notNull(key, "key");
+
+        boolean statsEnabled = ctx.config().isStatisticsEnabled();
+
+        long start = statsEnabled ? System.nanoTime() : 0L;
+
+        T2<V, GridCacheVersion> t = (T2<V, GridCacheVersion>)get(key, !ctx.keepBinary(), true);
+
+        CacheEntry<K, V> val = t != null ? new CacheEntryImplEx<>(key, t.get1(), t.get2()): null;
+
+        if (ctx.config().getInterceptor() != null) {
+            V val0 = (V)ctx.config().getInterceptor().onGet(key, t != null ? val.getValue() : null);
+
+            val = (val0 != null) ? new CacheEntryImplEx<>(key, val0, t != null ? t.get2() : null) : null;
+        }
+
+        if (statsEnabled)
+            metrics0().addGetTimeNanos(System.nanoTime() - start);
+
+        return val;
+    }
+
+    /** {@inheritDoc} */
     @Override public IgniteInternalFuture<V> getAsync(final K key) {
         A.notNull(key, "key");
 
@@ -1391,7 +1422,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
         final long start = statsEnabled ? System.nanoTime() : 0L;
 
-        IgniteInternalFuture<V> fut = getAsync(key, !ctx.keepBinary());
+        IgniteInternalFuture<V> fut = getAsync(key, !ctx.keepBinary(), false);
 
         if (ctx.config().getInterceptor() != null)
             fut =  fut.chain(new CX1<IgniteInternalFuture<V>, V>() {
@@ -1407,6 +1438,42 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     }
 
     /** {@inheritDoc} */
+    @Override public IgniteInternalFuture<CacheEntry<K, V>> getEntryAsync(final K key) {
+        A.notNull(key, "key");
+
+        final boolean statsEnabled = ctx.config().isStatisticsEnabled();
+
+        final long start = statsEnabled ? System.nanoTime() : 0L;
+
+        IgniteInternalFuture<T2<V, GridCacheVersion>> fut =
+            (IgniteInternalFuture<T2<V, GridCacheVersion>>)getAsync(key, !ctx.keepBinary(), true);
+
+        final boolean intercept = ctx.config().getInterceptor() != null;
+
+        IgniteInternalFuture<CacheEntry<K, V>> fr = fut.chain(
+            new CX1<IgniteInternalFuture<T2<V, GridCacheVersion>>, CacheEntry<K, V>>() {
+            @Override public CacheEntry<K, V> applyx(IgniteInternalFuture<T2<V, GridCacheVersion>> f)
+                throws IgniteCheckedException {
+                T2<V, GridCacheVersion> t = f.get();
+
+                CacheEntry<K, V> val = t != null ? new CacheEntryImplEx<>(key, t.get1(), t.get2()) : null;
+                if (intercept) {
+                    V val0 = (V)ctx.config().getInterceptor().onGet(key, t != null ? val.getValue() : null);
+
+                    return new CacheEntryImplEx<>(key, val0, t != null ? t.get2() : null);
+                }
+                else
+                    return val;
+            }
+        });
+
+        if (statsEnabled)
+            fut.listen(new UpdateGetTimeStatClosure<T2<V, GridCacheVersion>>(metrics0(), start));
+
+        return fr;
+    }
+
+    /** {@inheritDoc} */
     @Override public Map<K, V> getAll(@Nullable Collection<? extends K> keys) throws IgniteCheckedException {
         A.notNull(keys, "keys");
 
@@ -1414,7 +1481,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
         long start = statsEnabled ? System.nanoTime() : 0L;
 
-        Map<K, V> map = getAll(keys, !ctx.keepBinary());
+        Map<K, V> map = getAll(keys, !ctx.keepBinary(), false);
 
         if (ctx.config().getInterceptor() != null)
             map = interceptGet(keys, map);
@@ -1426,6 +1493,32 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     }
 
     /** {@inheritDoc} */
+    @Override public Collection<CacheEntry<K, V>> getEntries(@Nullable Collection<? extends K> keys)
+        throws IgniteCheckedException {
+        A.notNull(keys, "keys");
+
+        boolean statsEnabled = ctx.config().isStatisticsEnabled();
+
+        long start = statsEnabled ? System.nanoTime() : 0L;
+
+        Map<K, T2<V, GridCacheVersion>> map = (Map<K, T2<V, GridCacheVersion>>)getAll(keys, !ctx.keepBinary(), true);
+
+        Collection<CacheEntry<K, V>> res = new HashSet<>();
+
+        if (ctx.config().getInterceptor() != null)
+            res = interceptGetEntries(keys, map);
+        else
+            for (Map.Entry<K, T2<V, GridCacheVersion>> e : map.entrySet())
+                res.add(new CacheEntryImplEx<>(e.getKey(), e.getValue().get1(), e.getValue().get2()));
+
+        if (statsEnabled)
+            metrics0().addGetTimeNanos(System.nanoTime() - start);
+
+        return res;
+    }
+
+
+    /** {@inheritDoc} */
     @Override public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable final Collection<? extends K> keys) {
         A.notNull(keys, "keys");
 
@@ -1433,7 +1526,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
         final long start = statsEnabled ? System.nanoTime() : 0L;
 
-        IgniteInternalFuture<Map<K, V>> fut = getAllAsync(keys, !ctx.keepBinary());
+        IgniteInternalFuture<Map<K, V>> fut = getAllAsync(keys, !ctx.keepBinary(), false);
 
         if (ctx.config().getInterceptor() != null)
             return fut.chain(new CX1<IgniteInternalFuture<Map<K, V>>, Map<K, V>>() {
@@ -1448,6 +1541,45 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         return fut;
     }
 
+    /** {@inheritDoc} */
+    @Override  public IgniteInternalFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(
+        @Nullable final Collection<? extends K> keys) {
+        A.notNull(keys, "keys");
+
+        final boolean statsEnabled = ctx.config().isStatisticsEnabled();
+
+        final long start = statsEnabled ? System.nanoTime() : 0L;
+
+        IgniteInternalFuture<Map<K, T2<V, GridCacheVersion>>> fut =
+            (IgniteInternalFuture<Map<K, T2<V, GridCacheVersion>>>)
+                ((IgniteInternalFuture)getAllAsync(keys, !ctx.keepBinary(), true));
+
+        final boolean intercept = ctx.config().getInterceptor() != null;
+
+        IgniteInternalFuture<Collection<CacheEntry<K, V>>> rf =
+            fut.chain(new CX1<IgniteInternalFuture<Map<K, T2<V, GridCacheVersion>>>, Collection<CacheEntry<K, V>>>() {
+                @Override public Collection<CacheEntry<K, V>> applyx(
+                    IgniteInternalFuture<Map<K, T2<V, GridCacheVersion>>> f) throws IgniteCheckedException {
+                    if (intercept)
+                        return interceptGetEntries(keys, f.get());
+                    else {
+                        Map<K, CacheEntry<K, V>> res = U.newHashMap(f.get().size());
+
+                        for (Map.Entry<K, T2<V, GridCacheVersion>> e : f.get().entrySet())
+                            res.put(e.getKey(),
+                                new CacheEntryImplEx<>(e.getKey(), e.getValue().get1(), e.getValue().get2()));
+
+                        return res.values();
+                    }
+                }
+            });
+
+        if (statsEnabled)
+            fut.listen(new UpdateGetTimeStatClosure<Map<K, T2<V, GridCacheVersion>>>(metrics0(), start));
+
+        return rf;
+    }
+
     /**
      * Applies cache interceptor on result of 'get' operation.
      *
@@ -1490,6 +1622,53 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     }
 
     /**
+     * Applies cache interceptor on result of 'getEntries' operation.
+     *
+     * @param keys All requested keys.
+     * @param map Result map.
+     * @return Map with values returned by cache interceptor..
+     */
+    @SuppressWarnings("IfMayBeConditional")
+    private Collection<CacheEntry<K, V>> interceptGetEntries(
+        @Nullable Collection<? extends K> keys, Map<K, T2<V, GridCacheVersion>> map) {
+        Map<K, CacheEntry<K, V>> res;
+
+        if (F.isEmpty(keys)) {
+            assert map.isEmpty();
+
+            return Collections.emptySet();
+        }
+
+        res = U.newHashMap(keys.size());
+
+        CacheInterceptor<K, V> interceptor = cacheCfg.getInterceptor();
+
+        assert interceptor != null;
+
+        for (Map.Entry<K, T2<V, GridCacheVersion>> e : map.entrySet()) {
+            V val = interceptor.onGet(e.getKey(), e.getValue().get1());
+
+            if (val != null)
+                res.put(e.getKey(), new CacheEntryImplEx<>(e.getKey(), val, e.getValue().get2()));
+        }
+
+        if (map.size() != keys.size()) { // Not all requested keys were in cache.
+            for (K key : keys) {
+                if (key != null) {
+                    if (!map.containsKey(key)) {
+                        V val = interceptor.onGet(key, null);
+
+                        if (val != null)
+                            res.put(key, new CacheEntryImplEx<>(key, val, null));
+                    }
+                }
+            }
+        }
+
+        return res.values();
+    }
+
+    /**
      * @param key Key.
      * @param forcePrimary Force primary.
      * @param skipTx Skip tx.
@@ -1498,6 +1677,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
      * @param deserializeBinary Deserialize binary.
      * @param skipVals Skip values.
      * @param canRemap Can remap flag.
+     * @param needVer Need version.
      * @return Future for the get operation.
      */
     protected IgniteInternalFuture<V> getAsync(
@@ -1508,7 +1688,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         String taskName,
         boolean deserializeBinary,
         final boolean skipVals,
-        boolean canRemap
+        boolean canRemap,
+        final boolean needVer
     ) {
         return getAllAsync(Collections.singletonList(key),
             forcePrimary,
@@ -1517,7 +1698,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             taskName,
             deserializeBinary,
             skipVals,
-            canRemap).chain(
+            canRemap,
+            needVer).chain(
             new CX1<IgniteInternalFuture<Map<K, V>>, V>() {
                 @Override public V applyx(IgniteInternalFuture<Map<K, V>> e) throws IgniteCheckedException {
                     Map<K, V> map = e.get();
@@ -1544,6 +1726,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
      * @param deserializeBinary Deserialize binary.
      * @param skipVals Skip values.
      * @param canRemap Can remap flag.
+     * @param needVer Need version.
      * @return Future for the get operation.
      * @see GridCacheAdapter#getAllAsync(Collection)
      */
@@ -1555,7 +1738,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         String taskName,
         boolean deserializeBinary,
         boolean skipVals,
-        boolean canRemap
+        boolean canRemap,
+        final boolean needVer
     ) {
         CacheOperationContext opCtx = ctx.operationContextPerCall();
 
@@ -1570,7 +1754,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             forcePrimary,
             skipVals ? null : expiryPolicy(opCtx != null ? opCtx.expiry() : null),
             skipVals,
-            canRemap);
+            canRemap,
+            needVer);
     }
 
     /**
@@ -1584,6 +1769,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
      * @param expiry Expiry policy.
      * @param skipVals Skip values.
      * @param canRemap Can remap flag.
+     * @param needVer Need version.
      * @return Future for the get operation.
      * @see GridCacheAdapter#getAllAsync(Collection)
      */
@@ -1596,7 +1782,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         final boolean forcePrimary,
         @Nullable IgniteCacheExpiryPolicy expiry,
         final boolean skipVals,
-        boolean canRemap
+        boolean canRemap,
+        final boolean needVer
     ) {
         ctx.checkSecurity(SecurityPermission.CACHE_READ);
 
@@ -1613,7 +1800,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             skipVals,
             false,
             canRemap,
-            false);
+            needVer);
     }
 
     /**
@@ -1708,20 +1895,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
                                     ctx.evicts().touch(entry, topVer);
                             }
                             else {
-                                if (needVer) {
-                                    assert keepCacheObjects;
-
-                                    map.put((K1)key, (V1)new T2<>(res.get1(), res.get2()));
-                                }
-                                else {
-                                    ctx.addResult(map,
-                                        key,
-                                        res.get1(),
-                                        skipVals,
-                                        keepCacheObjects,
-                                        deserializeBinary,
-                                        true);
-                                }
+                                ctx.addResult(map,
+                                    key,
+                                    res.get1(),
+                                    skipVals,
+                                    keepCacheObjects,
+                                    deserializeBinary,
+                                    true,
+                                    needVer ? res.get2() : null);
 
                                 if (tx == null || (!tx.implicit() && tx.isolation() == READ_COMMITTED))
                                     ctx.evicts().touch(entry, topVer);
@@ -1783,20 +1964,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
                                                 // Don't put key-value pair into result map if value is null.
                                                 if (val != null) {
-                                                    if (needVer) {
-                                                        assert keepCacheObjects;
-
-                                                        map.put((K1)key, (V1)new T2<>(cacheVal, set ? verSet : ver));
-                                                    }
-                                                    else {
-                                                        ctx.addResult(map,
-                                                            key,
-                                                            cacheVal,
-                                                            skipVals,
-                                                            keepCacheObjects,
-                                                            deserializeBinary,
-                                                            false);
-                                                    }
+                                                    ctx.addResult(map,
+                                                        key,
+                                                        cacheVal,
+                                                        skipVals,
+                                                        keepCacheObjects,
+                                                        deserializeBinary,
+                                                        false,
+                                                        needVer ? set ? verSet : ver : null);
                                                 }
 
                                                 if (tx0 == null || (!tx0.implicit() &&
@@ -1889,11 +2064,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             }
         }
         else {
-            assert !needVer;
-
             return asyncOp(tx, new AsyncOp<Map<K1, V1>>(keys) {
                 @Override public IgniteInternalFuture<Map<K1, V1>> op(IgniteTxLocalAdapter tx) {
-                    return tx.getAllAsync(ctx, keys, deserializeBinary, skipVals, false, !readThrough);
+                    return tx.getAllAsync(ctx, keys, deserializeBinary, skipVals, false, !readThrough, needVer);
                 }
             }, ctx.operationContextPerCall());
         }
@@ -4494,28 +4667,31 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     /**
      * @param key Key.
      * @param deserializeBinary Deserialize binary flag.
+     * @param needVer Need version.
      * @return Cached value.
      * @throws IgniteCheckedException If failed.
      */
-    @Nullable public V get(K key, boolean deserializeBinary) throws IgniteCheckedException {
+    @Nullable public V get(K key, boolean deserializeBinary, final boolean needVer) throws IgniteCheckedException {
         checkJta();
 
         String taskName = ctx.kernalContext().job().currentTaskName();
 
-        return get(key, taskName, deserializeBinary);
+        return get(key, taskName, deserializeBinary, needVer);
     }
 
     /**
      * @param key Key.
      * @param taskName Task name.
      * @param deserializeBinary Deserialize binary flag.
+     * @param needVer Need version.
      * @return Cached value.
      * @throws IgniteCheckedException If failed.
      */
     protected V get(
         final K key,
         String taskName,
-        boolean deserializeBinary) throws IgniteCheckedException {
+        boolean deserializeBinary,
+        boolean needVer) throws IgniteCheckedException {
         return getAsync(key,
             !ctx.config().isReadFromBackup(),
             /*skip tx*/false,
@@ -4523,15 +4699,17 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             taskName,
             deserializeBinary,
             false,
-            /*can remap*/true).get();
+            /*can remap*/true,
+            needVer).get();
     }
 
     /**
      * @param key Key.
      * @param deserializeBinary Deserialize binary flag.
+     * @param needVer Need version.
      * @return Read operation future.
      */
-    public final IgniteInternalFuture<V> getAsync(final K key, boolean deserializeBinary) {
+    public final IgniteInternalFuture<V> getAsync(final K key, boolean deserializeBinary, final boolean needVer) {
         try {
             checkJta();
         }
@@ -4548,28 +4726,32 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             taskName,
             deserializeBinary,
             false,
-            /*can remap*/true);
+            /*can remap*/true,
+            needVer);
     }
 
     /**
      * @param keys Keys.
      * @param deserializeBinary Deserialize binary flag.
+     * @param needVer Need version.
      * @return Map of cached values.
      * @throws IgniteCheckedException If read failed.
      */
-    public Map<K, V> getAll(Collection<? extends K> keys, boolean deserializeBinary) throws IgniteCheckedException {
+    public Map<K, V> getAll(Collection<? extends K> keys, boolean deserializeBinary,
+        boolean needVer) throws IgniteCheckedException {
         checkJta();
 
-        return getAllAsync(keys, deserializeBinary).get();
+        return getAllAsync(keys, deserializeBinary, needVer).get();
     }
 
     /**
      * @param keys Keys.
      * @param deserializeBinary Deserialize binary flag.
+     * @param needVer Need version.
      * @return Read future.
      */
     public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable Collection<? extends K> keys,
-        boolean deserializeBinary) {
+        boolean deserializeBinary, boolean needVer) {
         String taskName = ctx.kernalContext().job().currentTaskName();
 
         return getAllAsync(keys,
@@ -4579,7 +4761,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             taskName,
             deserializeBinary,
             /*skip vals*/false,
-            /*can remap*/true);
+            /*can remap*/true,
+            needVer);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index fc48b9d..e875df0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -49,12 +49,12 @@ import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.managers.communication.GridIoManager;
 import org.apache.ignite.internal.managers.deployment.GridDeploymentManager;
 import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
 import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
 import org.apache.ignite.internal.managers.swapspace.GridSwapSpaceManager;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
@@ -91,6 +91,7 @@ import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.C1;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.GPC;
@@ -1882,6 +1883,7 @@ public class GridCacheContext<K, V> implements Externalizable {
      * @param keepCacheObjects Keep cache objects flag.
      * @param deserializeBinary Deserialize binary flag.
      * @param cpy Copy flag.
+     * @param ver GridCacheVersion.
      */
     @SuppressWarnings("unchecked")
     public <K1, V1> void addResult(Map<K1, V1> map,
@@ -1890,7 +1892,8 @@ public class GridCacheContext<K, V> implements Externalizable {
         boolean skipVals,
         boolean keepCacheObjects,
         boolean deserializeBinary,
-        boolean cpy) {
+        boolean cpy,
+        final GridCacheVersion ver) {
         assert key != null;
         assert val != null || skipVals;
 
@@ -1902,10 +1905,32 @@ public class GridCacheContext<K, V> implements Externalizable {
             assert key0 != null : key;
             assert val0 != null : val;
 
-            map.put((K1)key0, (V1)val0);
+            map.put((K1)key0, ver != null ? (V1)new T2<>(val0, ver) : (V1)val0);
         }
         else
-            map.put((K1)key, (V1)(skipVals ? true : val));
+            map.put((K1)key,
+                (V1)(ver != null ?
+                    (V1)new T2<>(skipVals ? true : val, ver) :
+                    skipVals ? true : val));
+    }
+
+    /**
+     * @param map Map.
+     * @param key Key.
+     * @param val Value.
+     * @param skipVals Skip values flag.
+     * @param keepCacheObjects Keep cache objects flag.
+     * @param deserializeBinary Deserialize binary flag.
+     * @param cpy Copy flag.
+     */
+    public <K1, V1> void addResult(Map<K1, V1> map,
+        KeyCacheObject key,
+        CacheObject val,
+        boolean skipVals,
+        boolean keepCacheObjects,
+        boolean deserializeBinary,
+        boolean cpy) {
+        addResult(map, key, val, skipVals, keepCacheObjects, deserializeBinary, cpy, null);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 2d25d16..64cfd01 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -882,7 +882,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
                 updateTtl(expiryPlc);
 
             if (retVer) {
-                resVer = isNear() ? ((GridNearCacheEntry)this).dhtVersion() : this.ver;
+                resVer = (isNear() && cctx.transactional()) ? ((GridNearCacheEntry)this).dhtVersion() : this.ver;
 
                 if (resVer == null)
                     ret = null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 3a53942..9b4aff3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -31,6 +31,7 @@ import javax.cache.expiry.ExpiryPolicy;
 import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.EntryProcessorResult;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.cache.CacheMetrics;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.affinity.Affinity;
@@ -307,6 +308,18 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     }
 
     /** {@inheritDoc} */
+    @Nullable @Override public CacheEntry<K, V> getEntry(K key) throws IgniteCheckedException {
+        CacheOperationContext prev = gate.enter(opCtx);
+
+        try {
+            return delegate.getEntry(key);
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public V getTopologySafe(K key) throws IgniteCheckedException {
         CacheOperationContext prev = gate.enter(opCtx);
 
@@ -331,6 +344,18 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     }
 
     /** {@inheritDoc} */
+    @Override public IgniteInternalFuture<CacheEntry<K, V>> getEntryAsync(K key) {
+        CacheOperationContext prev = gate.enter(opCtx);
+
+        try {
+            return delegate.getEntryAsync(key);
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public V getForcePrimary(K key) throws IgniteCheckedException {
         CacheOperationContext prev = gate.enter(opCtx);
 
@@ -451,6 +476,19 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     }
 
     /** {@inheritDoc} */
+    @Override public Collection<CacheEntry<K, V>> getEntries(
+        @Nullable Collection<? extends K> keys) throws IgniteCheckedException {
+        CacheOperationContext prev = gate.enter(opCtx);
+
+        try {
+            return delegate.getEntries(keys);
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable Collection<? extends K> keys) {
         CacheOperationContext prev = gate.enter(opCtx);
 
@@ -463,6 +501,19 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     }
 
     /** {@inheritDoc} */
+    @Override public IgniteInternalFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(
+        @Nullable Collection<? extends K> keys) {
+        CacheOperationContext prev = gate.enter(opCtx);
+
+        try {
+            return delegate.getEntriesAsync(keys);
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
     @Nullable @Override public V getAndPut(K key, V val)
         throws IgniteCheckedException {
         CacheOperationContext prev = gate.enter(opCtx);

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 9e66d4d..5ed8753 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -44,6 +44,7 @@ import javax.cache.processor.EntryProcessorResult;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.cache.CacheManager;
 import org.apache.ignite.cache.CacheMetrics;
@@ -873,6 +874,31 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
     }
 
     /** {@inheritDoc} */
+    @Override public CacheEntry<K, V> getEntry(K key) {
+        try {
+            GridCacheGateway<K, V> gate = this.gate;
+
+            CacheOperationContext prev = onEnter(gate, opCtx);
+
+            try {
+                if (isAsync()) {
+                    setFuture(delegate.getEntryAsync(key));
+
+                    return null;
+                }
+                else
+                    return delegate.getEntry(key);
+            }
+            finally {
+                onLeave(gate, prev);
+            }
+        }
+        catch (IgniteCheckedException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public Map<K, V> getAll(Set<? extends K> keys) {
         try {
             GridCacheGateway<K, V> gate = this.gate;
@@ -898,6 +924,31 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
     }
 
     /** {@inheritDoc} */
+    @Override public Collection<CacheEntry<K, V>>  getEntries(Set<? extends K> keys) {
+        try {
+            GridCacheGateway<K, V> gate = this.gate;
+
+            CacheOperationContext prev = onEnter(gate, opCtx);
+
+            try {
+                if (isAsync()) {
+                    setFuture(delegate.getEntriesAsync(keys));
+
+                    return null;
+                }
+                else
+                    return delegate.getEntries(keys);
+            }
+            finally {
+                onLeave(gate, prev);
+            }
+        }
+        catch (IgniteCheckedException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
         try {
             GridCacheGateway<K, V> gate = this.gate;

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
index 433290c..68d0f06 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
@@ -31,6 +31,7 @@ import javax.cache.processor.EntryProcessorResult;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.cache.CacheMetrics;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CachePeekMode;
@@ -335,6 +336,28 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
     @Nullable public V get(K key) throws IgniteCheckedException;
 
     /**
+     * Retrieves value mapped to the specified key from cache. Value will only be returned if
+     * its entry passed the optional filter provided. Filter check is atomic, and therefore the
+     * returned value is guaranteed to be consistent with the filter. The return value of {@code null}
+     * means entry did not pass the provided filter or cache has no mapping for the
+     * key.
+     * <p>
+     * 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 disable, and if read-through is allowed, value
+     * will be loaded from {@link CacheStore} persistent storage via
+     * <code>CacheStore#load(Transaction, Object)</code> method.
+     * <h2 class="header">Transactions</h2>
+     * This method is transactional and will enlist the entry into ongoing transaction
+     * if there is one.
+     *
+     * @param key Key to retrieve the value for.
+     * @return Value for the given key.
+     * @throws IgniteCheckedException If get operation failed.
+     * @throws NullPointerException if the key is {@code null}.
+     */
+    @Nullable public CacheEntry<K, V> getEntry(K key) throws IgniteCheckedException;
+
+    /**
      * Asynchronously retrieves value mapped to the specified key from cache. Value will only be returned if
      * its entry passed the optional filter provided. Filter check is atomic, and therefore the
      * returned value is guaranteed to be consistent with the filter. The return value of {@code null}
@@ -356,6 +379,27 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
     public IgniteInternalFuture<V> getAsync(K key);
 
     /**
+     * Asynchronously retrieves value mapped to the specified key from cache. Value will only be returned if
+     * its entry passed the optional filter provided. Filter check is atomic, and therefore the
+     * returned value is guaranteed to be consistent with the filter. The return value of {@code null}
+     * means entry did not pass the provided filter or cache has no mapping for the
+     * key.
+     * <p>
+     * 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 {@link CacheStore} persistent storage via
+     * <code>CacheStore#load(Transaction, Object)</code> method.
+     * <h2 class="header">Transactions</h2>
+     * This method is transactional and will enlist the entry into ongoing transaction
+     * if there is one.
+     *
+     * @param key Key for the value to get.
+     * @return Future for the get operation.
+     * @throws NullPointerException if the key is {@code null}.
+     */
+    public IgniteInternalFuture<CacheEntry<K, V>> getEntryAsync(K key);
+
+    /**
      * Retrieves values mapped to the specified keys from cache. Value will only be returned if
      * its entry passed the optional filter provided. Filter check is atomic, and therefore the
      * returned value is guaranteed to be consistent with the filter. If requested key-value pair
@@ -377,6 +421,27 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
     public Map<K, V> getAll(@Nullable Collection<? extends K> keys) throws IgniteCheckedException;
 
     /**
+     * Retrieves values mapped to the specified keys from cache. Value will only be returned if
+     * its entry passed the optional filter provided. Filter check is atomic, and therefore the
+     * returned value is guaranteed to be consistent with the filter. If requested key-value pair
+     * is not present in the returned map, then it means that its entry did not pass the provided
+     * filter or cache has no mapping for the key.
+     * <p>
+     * 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 {@link CacheStore} persistent storage via
+     * <code>CacheStore#loadAll(Transaction, Collection, org.apache.ignite.lang.IgniteBiInClosure)</code> method.
+     * <h2 class="header">Transactions</h2>
+     * This method is transactional and will enlist the entry into ongoing transaction
+     * if there is one.
+     *
+     * @param keys Keys to get.
+     * @return Map of key-value pairs.
+     * @throws IgniteCheckedException If get operation failed.
+     */
+    public Collection<CacheEntry<K, V>> getEntries(@Nullable Collection<? extends K> keys) throws IgniteCheckedException;
+
+    /**
      * Asynchronously retrieves values mapped to the specified keys from cache. Value will only be returned if
      * its entry passed the optional filter provided. Filter check is atomic, and therefore the
      * returned value is guaranteed to be consistent with the filter. If requested key-value pair
@@ -397,6 +462,26 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
     public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable Collection<? extends K> keys);
 
     /**
+     * Asynchronously retrieves values mapped to the specified keys from cache. Value will only be returned if
+     * its entry passed the optional filter provided. Filter check is atomic, and therefore the
+     * returned value is guaranteed to be consistent with the filter. If requested key-value pair
+     * is not present in the returned map, then it means that its entry did not pass the provided
+     * filter or cache has no mapping for the key.
+     * <p>
+     * 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 {@link CacheStore} persistent storage via
+     * <code>CacheStore#loadAll(Transaction, Collection, org.apache.ignite.lang.IgniteBiInClosure)</code> method.
+     * <h2 class="header">Transactions</h2>
+     * This method is transactional and will enlist the entry into ongoing transaction
+     * if there is one.
+     *
+     * @param keys Key for the value to get.
+     * @return Future for the get operation.
+     */
+    public IgniteInternalFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(@Nullable Collection<? extends K> keys);
+
+    /**
      * Stores given key-value pair in cache. If filters are provided, then entries will
      * be stored in cache only if they pass the filter. Note that filter check is atomic,
      * so value stored in cache is guaranteed to be consistent with the filters. If cache

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java
index 7efaf49..28c94dd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java
@@ -153,21 +153,6 @@ public abstract class CacheDistributedGetFutureAdapter<K, V> extends GridCompoun
     }
 
     /**
-     * @param map Result map.
-     * @param key Key.
-     * @param val Value.
-     * @param ver Version.
-     */
-    @SuppressWarnings("unchecked")
-    protected final void versionedResult(Map map, KeyCacheObject key, Object val, GridCacheVersion ver) {
-        assert needVer;
-        assert skipVals || val != null;
-        assert ver != null;
-
-        map.put(key, new T2<>(skipVals ? true : val, ver));
-    }
-
-    /**
      * Affinity node to send get request to.
      *
      * @param affNodes All affinity nodes.

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 9cf8084..5be4e72 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -617,6 +617,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
      * @param keys {@inheritDoc}
      * @param forcePrimary {@inheritDoc}
      * @param skipTx {@inheritDoc}
+     * @param needVer Need version.
      * @return {@inheritDoc}
      */
     @Override public IgniteInternalFuture<Map<K, V>> getAllAsync(
@@ -627,7 +628,8 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
         String taskName,
         boolean deserializeBinary,
         boolean skipVals,
-        boolean canRemap
+        boolean canRemap,
+        boolean needVer
     ) {
         CacheOperationContext opCtx = ctx.operationContextPerCall();
 
@@ -640,7 +642,8 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
             forcePrimary,
             null,
             skipVals,
-            canRemap);
+            canRemap,
+            needVer);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
index cb8c842..c926c13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
@@ -383,7 +383,8 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
                     /*deserialize binary*/false,
                     skipVals,
                     /*keep cache objects*/true,
-                    /*skip store*/!readThrough);
+                    /*skip store*/!readThrough,
+                    false);
             }
         }
         else {
@@ -413,7 +414,8 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
                                 /*deserialize binary*/false,
                                 skipVals,
                                 /*keep cache objects*/true,
-                                /*skip store*/!readThrough);
+                                /*skip store*/!readThrough,
+                                false);
                         }
                     }
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index d8b2f37..41b28d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -946,7 +946,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
         if (retVal ||
             !F.isEmpty(e.entryProcessors()) ||
             !F.isEmpty(e.filters()) ||
-            e.serializableReadVersion() != null) {
+            e.entryReadVersion() != null) {
             if (map == null)
                 map = new HashMap<>();
 
@@ -1013,7 +1013,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
         throws IgniteCheckedException {
         try {
             for (IgniteTxEntry entry : entries) {
-                GridCacheVersion serReadVer = entry.serializableReadVersion();
+                GridCacheVersion serReadVer = entry.entryReadVersion();
 
                 if (serReadVer != null) {
                     entry.cached().unswap();

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/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 1f2d7c5..2c9a760 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
@@ -490,17 +490,14 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
                             cache.removeIfObsolete(key);
                     }
                     else {
-                        if (needVer)
-                            versionedResult(locVals, key, v, ver);
-                        else {
-                            cctx.addResult(locVals,
-                                key,
-                                v,
-                                skipVals,
-                                keepCacheObjects,
-                                deserializeBinary,
-                                true);
-                        }
+                        cctx.addResult(locVals,
+                            key,
+                            v,
+                            skipVals,
+                            keepCacheObjects,
+                            deserializeBinary,
+                            true,
+                            ver);
 
                         return true;
                     }
@@ -552,17 +549,14 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
             for (GridCacheEntryInfo info : infos) {
                 assert skipVals == (info.value() == null);
 
-                if (needVer)
-                    versionedResult(map, info.key(), info.value(), info.version());
-                else {
-                    cctx.addResult(map,
-                        info.key(),
-                        info.value(),
-                        skipVals,
-                        keepCacheObjects,
-                        deserializeBinary,
-                        false);
-                }
+                cctx.addResult(map,
+                    info.key(),
+                    info.value(),
+                    skipVals,
+                    keepCacheObjects,
+                    deserializeBinary,
+                    false,
+                    needVer ? info.version() : null);
             }
 
             return map;

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index 0c811ae..01e61bf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -625,20 +625,13 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
             assert !skipVals;
 
             if (val != null) {
-                if (needVer) {
-                    assert ver != null;
+                if (!keepCacheObjects) {
+                    Object res = cctx.unwrapBinaryIfNeeded(val, !deserializeBinary);
 
-                    onDone(new T2<>(val, ver));
-                }
-                else {
-                    if (!keepCacheObjects) {
-                        Object res = cctx.unwrapBinaryIfNeeded(val, !deserializeBinary);
-
-                        onDone(res);
-                    }
-                    else
-                        onDone(val);
+                    onDone(needVer ? new T2<>(res, ver) : res);
                 }
+                else
+                    onDone(needVer ? new T2<>(val, ver) : val);
             }
             else
                 onDone(null);

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index cba4e61..b806906 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -93,6 +93,7 @@ import org.apache.ignite.internal.util.typedef.CO;
 import org.apache.ignite.internal.util.typedef.CX1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P1;
+import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -317,7 +318,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override protected V get(K key, String taskName, boolean deserializeBinary) throws IgniteCheckedException {
+    @Override protected V get(K key, String taskName, boolean deserializeBinary, boolean needVer)
+        throws IgniteCheckedException {
         ctx.checkSecurity(SecurityPermission.CACHE_READ);
 
         if (keyCheck)
@@ -339,7 +341,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             expiryPlc,
             false,
             skipStore,
-            true).get();
+            true,
+            needVer).get();
     }
 
     /** {@inheritDoc} */
@@ -350,7 +353,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         final String taskName,
         final boolean deserializeBinary,
         final boolean skipVals,
-        final boolean canRemap) {
+        final boolean canRemap,
+        final boolean needVer) {
         ctx.checkSecurity(SecurityPermission.CACHE_READ);
 
         if (keyCheck)
@@ -376,7 +380,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                     expiryPlc,
                     skipVals,
                     skipStore,
-                    canRemap);
+                    canRemap,
+                    needVer);
             }
         });
     }
@@ -390,7 +395,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         final String taskName,
         final boolean deserializeBinary,
         final boolean skipVals,
-        final boolean canRemap
+        final boolean canRemap,
+        final boolean needVer
     ) {
         ctx.checkSecurity(SecurityPermission.CACHE_READ);
 
@@ -420,7 +426,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                     expiryPlc,
                     skipVals,
                     skipStore,
-                    canRemap);
+                    canRemap,
+                    needVer);
             }
         });
     }
@@ -1098,6 +1105,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
      * @param skipVals Skip values flag.
      * @param skipStore Skip store flag.
      * @param canRemap Can remap flag.
+     * @param needVer Need version.
      * @return Get future.
      */
     private IgniteInternalFuture<V> getAsync0(KeyCacheObject key,
@@ -1108,7 +1116,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         @Nullable ExpiryPolicy expiryPlc,
         boolean skipVals,
         boolean skipStore,
-        boolean canRemap
+        boolean canRemap,
+        boolean needVer
     ) {
         AffinityTopologyVersion topVer = canRemap ? ctx.affinity().affinityTopologyVersion() :
             ctx.shared().exchange().readyAffinityVersion();
@@ -1126,7 +1135,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             expiry,
             skipVals,
             canRemap,
-            false,
+            needVer,
             false);
 
         fut.init();
@@ -1145,6 +1154,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
      * @param expiryPlc Expiry policy.
      * @param skipVals Skip values flag.
      * @param skipStore Skip store flag.
+     * @param needVer Need version.
      * @return Get future.
      */
     private IgniteInternalFuture<Map<K, V>> getAllAsync0(@Nullable Collection<KeyCacheObject> keys,
@@ -1155,7 +1165,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         @Nullable ExpiryPolicy expiryPlc,
         boolean skipVals,
         boolean skipStore,
-        boolean canRemap
+        boolean canRemap,
+        boolean needVer
     ) {
         AffinityTopologyVersion topVer = canRemap ? ctx.affinity().affinityTopologyVersion() :
             ctx.shared().exchange().readyAffinityVersion();
@@ -1180,19 +1191,42 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                         if (entry != null) {
                             boolean isNew = entry.isNewLocked();
 
-                            CacheObject v = entry.innerGet(null,
-                                /*swap*/true,
-                                /*read-through*/false,
-                                /*fail-fast*/true,
-                                /*unmarshal*/true,
-                                /**update-metrics*/false,
-                                /*event*/!skipVals,
-                                /*temporary*/false,
-                                subjId,
-                                null,
-                                taskName,
-                                expiry,
-                                !deserializeBinary);
+                            CacheObject v = null;
+                            GridCacheVersion ver = null;
+
+                            if (needVer) {
+                                T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+                                    null,
+                                    /*swap*/true,
+                                    /*unmarshal*/true,
+                                    /**update-metrics*/false,
+                                    /*event*/!skipVals,
+                                    subjId,
+                                    null,
+                                    taskName,
+                                    expiry,
+                                    true);
+
+                                if (res != null) {
+                                    v = res.get1();
+                                    ver = res.get2();
+                                }
+                            }
+                            else {
+                                v = entry.innerGet(null,
+                                    /*swap*/true,
+                                    /*read-through*/false,
+                                    /*fail-fast*/true,
+                                    /*unmarshal*/true,
+                                    /**update-metrics*/false,
+                                    /*event*/!skipVals,
+                                    /*temporary*/false,
+                                    subjId,
+                                    null,
+                                    taskName,
+                                    expiry,
+                                    !deserializeBinary);
+                            }
 
                             // Entry was not in memory or in swap, so we remove it from cache.
                             if (v == null) {
@@ -1204,7 +1238,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                                 success = false;
                             }
                             else
-                                ctx.addResult(locVals, key, v, skipVals, false, deserializeBinary, true);
+                                ctx.addResult(locVals, key, v, skipVals, false, deserializeBinary, true, ver);
                         }
                         else
                             success = false;
@@ -1256,7 +1290,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             expiry,
             skipVals,
             canRemap,
-            false,
+            needVer,
             false);
 
         fut.init();

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 073043d..dc4b6bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -200,7 +200,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
         String taskName,
         final boolean deserializeBinary,
         final boolean skipVals,
-        boolean canRemap) {
+        boolean canRemap,
+        final boolean needVer) {
         ctx.checkSecurity(SecurityPermission.CACHE_READ);
 
         if (keyCheck)
@@ -218,7 +219,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
                         deserializeBinary,
                         skipVals,
                         false,
-                        opCtx != null && opCtx.skipStore());
+                        opCtx != null && opCtx.skipStore(),
+                        needVer);
 
                     return fut.chain(new CX1<IgniteInternalFuture<Map<Object, Object>>, V>() {
                         @SuppressWarnings("unchecked")
@@ -258,7 +260,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
             skipVals ? null : expiryPolicy(opCtx != null ? opCtx.expiry() : null),
             skipVals,
             canRemap,
-            /*needVer*/false,
+            needVer,
             /*keepCacheObjects*/false);
 
         fut.init();
@@ -275,7 +277,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
         String taskName,
         final boolean deserializeBinary,
         final boolean skipVals,
-        boolean canRemap
+        boolean canRemap,
+        final boolean needVer
     ) {
         ctx.checkSecurity(SecurityPermission.CACHE_READ);
 
@@ -297,7 +300,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
                         deserializeBinary,
                         skipVals,
                         false,
-                        opCtx != null && opCtx.skipStore());
+                        opCtx != null && opCtx.skipStore(),
+                        needVer);
                 }
             }, opCtx);
         }
@@ -318,7 +322,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
             deserializeBinary,
             skipVals ? null : expiryPolicy(opCtx != null ? opCtx.expiry() : null),
             skipVals,
-            canRemap);
+            canRemap,
+            needVer);
     }
 
     /** {@inheritDoc} */
@@ -345,6 +350,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
      * @param expiryPlc Expiry policy.
      * @param skipVals Skip values flag.
      * @param canRemap Can remap flag.
+     * @param needVer Need version.
      * @return Loaded values.
      */
     public IgniteInternalFuture<Map<K, V>> loadAsync(
@@ -357,7 +363,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
         boolean deserializeBinary,
         @Nullable IgniteCacheExpiryPolicy expiryPlc,
         boolean skipVals,
-        boolean canRemap) {
+        boolean canRemap,
+        boolean needVer) {
         return loadAsync(keys,
             readThrough,
             forcePrimary,
@@ -367,7 +374,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
             expiryPlc,
             skipVals,
             canRemap,
-            false,
+            needVer,
             false);
     }
 
@@ -522,17 +529,14 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
                                 if (locVals == null)
                                     locVals = U.newHashMap(keys.size());
 
-                                if (needVer)
-                                    locVals.put((K)key, (V)new T2<>((Object)(skipVals ? true : v), ver));
-                                else {
-                                    ctx.addResult(locVals,
-                                        key,
-                                        v,
-                                        skipVals,
-                                        keepCacheObj,
-                                        deserializeBinary,
-                                        true);
-                                }
+                                ctx.addResult(locVals,
+                                    key,
+                                    v,
+                                    skipVals,
+                                    keepCacheObj,
+                                    deserializeBinary,
+                                    true,
+                                    ver);
                             }
                         }
                         else

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
index a2d5adb..63c073d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
@@ -400,7 +400,8 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
         String taskName,
         boolean deserializeBinary,
         boolean skipVals,
-        boolean canRemap
+        boolean canRemap,
+        boolean needVer
     ) {
         ctx.checkSecurity(SecurityPermission.CACHE_READ);
 
@@ -423,7 +424,8 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
             skipVals ? null : opCtx != null ? opCtx.expiry() : null,
             skipVals,
             opCtx != null && opCtx.skipStore(),
-            canRemap);
+            canRemap,
+            needVer);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index 5bf18d9..c750be6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -230,6 +230,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
      * @param skipVal Skip value flag.
      * @param skipStore Skip store flag.
      * @param canRemap Can remap flag.
+     * @param needVer Need version.
      * @return Loaded values.
      */
     public IgniteInternalFuture<Map<K, V>> loadAsync(@Nullable IgniteInternalTx tx,
@@ -241,7 +242,8 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
         @Nullable ExpiryPolicy expiryPlc,
         boolean skipVal,
         boolean skipStore,
-        boolean canRemap
+        boolean canRemap,
+        boolean needVer
     ) {
         if (F.isEmpty(keys))
             return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
@@ -261,7 +263,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
             expiry,
             skipVal,
             canRemap,
-            false,
+            needVer,
             false);
 
         // init() will register future for responses if future has remote mappings.

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
index c0a1617..026fb4d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
@@ -350,7 +350,8 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
             null,
             false,
             /*skip store*/false,
-            /*can remap*/true
+            /*can remap*/true,
+            false
         ).get().get(keyValue(false));
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/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 9291001..06fc0a5 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
@@ -650,26 +650,25 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
      */
     @SuppressWarnings("unchecked")
     private void addResult(KeyCacheObject key, CacheObject v, GridCacheVersion ver) {
-        if (needVer) {
-            V val0 = (V)new T2<>(skipVals ? true : v, ver);
+        if (keepCacheObjects) {
+            K key0 = (K)key;
+            V val0 = needVer ?
+                (V)new T2<>(skipVals ? true : v, ver) :
+                (V)(skipVals ? true : v);
 
-            add(new GridFinishedFuture<>(Collections.singletonMap((K)key, val0)));
+            add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
         }
         else {
-            if (keepCacheObjects) {
-                K key0 = (K)key;
-                V val0 = (V)(skipVals ? true : v);
-
-                add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
-            }
-            else {
-                K key0 = (K)cctx.unwrapBinaryIfNeeded(key, !deserializeBinary, false);
-                V val0 = !skipVals ?
+            K key0 = (K)cctx.unwrapBinaryIfNeeded(key, !deserializeBinary, false);
+            V val0 = needVer ?
+                (V)new T2<>(!skipVals ?
+                    (V)cctx.unwrapBinaryIfNeeded(v, !deserializeBinary, false) :
+                    (V)Boolean.TRUE, ver) :
+                !skipVals ?
                     (V)cctx.unwrapBinaryIfNeeded(v, !deserializeBinary, false) :
                     (V)Boolean.TRUE;
 
-                add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
-            }
+            add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
         }
     }
 
@@ -741,16 +740,14 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
 
                     assert skipVals == (info.value() == null);
 
-                    if (needVer)
-                        versionedResult(map, key, val, info.version());
-                    else
-                        cctx.addResult(map,
-                            key,
-                            val,
-                            skipVals,
-                            keepCacheObjects,
-                            deserializeBinary,
-                            false);
+                    cctx.addResult(map,
+                        key,
+                        val,
+                        skipVals,
+                        keepCacheObjects,
+                        deserializeBinary,
+                        false,
+                        needVer ? info.version() : null);
                 }
                 catch (GridCacheEntryRemovedException ignore) {
                     if (log.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
index 4f9f227..52ebfc8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
@@ -107,7 +107,7 @@ public class GridNearOptimisticSerializableTxPrepareFuture extends GridNearOptim
 
             if (txEntry != null) {
                 if (entry.context().isLocal()) {
-                    GridCacheVersion serReadVer = txEntry.serializableReadVersion();
+                    GridCacheVersion serReadVer = txEntry.entryReadVersion();
 
                     if (serReadVer != null) {
                         GridCacheContext ctx = entry.context();

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
index bae0327..b968e57 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
@@ -279,6 +279,8 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
      * @param topLocked {@code True} if thread already acquired lock preventing topology change.
      */
     private void prepareSingle(IgniteTxEntry write, boolean topLocked) {
+        write.clearEntryReadVersion();
+
         AffinityTopologyVersion topVer = tx.topologyVersion();
 
         assert topVer.topologyVersion() > 0;
@@ -339,6 +341,8 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
         Queue<GridDistributedTxMapping> mappings = new ArrayDeque<>();
 
         for (IgniteTxEntry write : writes) {
+            write.clearEntryReadVersion();
+
             GridDistributedTxMapping updated = map(write, topVer, cur, topLocked);
 
             if (cur != updated) {


[10/28] ignite git commit: 1523

Posted by vo...@apache.org.
1523


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

Branch: refs/heads/ignite-2508
Commit: 28a5247d37ba65bdcb6119f97023f32d511b5f1e
Parents: 0113506
Author: Anton Vinogradov <av...@apache.org>
Authored: Tue Feb 2 15:37:12 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Feb 2 15:37:12 2016 +0300

----------------------------------------------------------------------
 .../internal/binary/BinaryEnumObjectImpl.java   |   2 +-
 .../processors/cache/GridCacheProcessor.java    |   2 +-
 .../ignite/internal/util/IgniteUtils.java       |   7 ++
 .../ignite/spi/discovery/tcp/ClientImpl.java    |   6 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  11 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   1 -
 .../TcpDiscoveryCustomEventMessage.java         |  10 +-
 .../GridCacheReplicatedPreloadSelfTest.java     | 108 ++++++++++++++++++
 .../tests/p2p/CacheDeploymentTestEnumValue.java |  47 ++++++++
 .../p2p/CacheDeploymentTestStoreFactory.java    | 113 +++++++++++++++++++
 10 files changed, 297 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index fd4a4d8..ab76b6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -110,7 +110,7 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <T> T deserialize() throws BinaryObjectException {
-        Class cls = BinaryUtils.resolveClass(ctx, typeId, clsName, null, true);
+        Class cls = BinaryUtils.resolveClass(ctx, typeId, clsName, ctx.configuration().getClassLoader(), true);
 
         return BinaryEnumCache.get(cls, ord);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/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 13048ec..26d3d4f 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
@@ -3421,7 +3421,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         }
 
         try {
-            return marshaller.unmarshal(marshaller.marshal(val), val.getClass().getClassLoader());
+            return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config().getClassLoader()));
         }
         catch (IgniteCheckedException e) {
             throw new IgniteCheckedException("Failed to validate cache configuration " +

http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 0bf937d..6c0b8e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -2193,6 +2193,13 @@ public abstract class IgniteUtils {
     }
 
     /**
+     * @return Class loader passed as an argument or classloader used to load Ignite itself in case argument is null.
+     */
+    public static ClassLoader resolveClassLoader(ClassLoader ldr) {
+        return ldr != null ? ldr : gridClassLoader;
+    }
+
+    /**
      * @param parent Parent to find.
      * @param ldr Loader to check.
      * @return {@code True} if parent found.

http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 850cc24..b12f7a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -1665,7 +1665,8 @@ class ClientImpl extends TcpDiscoveryImpl {
 
                     if (dataMap != null) {
                         for (Map.Entry<UUID, Map<Integer, byte[]>> entry : dataMap.entrySet())
-                            spi.onExchange(getLocalNodeId(), entry.getKey(), entry.getValue(), null);
+                            spi.onExchange(getLocalNodeId(), entry.getKey(), entry.getValue(),
+                                U.resolveClassLoader(spi.ignite().configuration().getClassLoader()));
                     }
 
                     locNode.setAttributes(msg.clientNodeAttributes());
@@ -1961,7 +1962,8 @@ class ClientImpl extends TcpDiscoveryImpl {
 
                     if (node != null && node.visible()) {
                         try {
-                            DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh);
+                            DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh,
+                                spi.ignite().configuration().getClassLoader());
 
                             notifyDiscovery(EVT_DISCOVERY_CUSTOM_EVT, topVer, node, allVisibleNodes(), msgObj);
                         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index c69a611..0106b0a 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -3600,7 +3600,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                     Map<Integer, byte[]> data = msg.newNodeDiscoveryData();
 
                     if (data != null)
-                        spi.onExchange(node.id(), node.id(), data, U.gridClassLoader());
+                        spi.onExchange(node.id(), node.id(), data,
+                            U.resolveClassLoader(spi.ignite().configuration().getClassLoader()));
 
                     msg.addDiscoveryData(locNodeId, spi.collectExchangeData(node.id()));
 
@@ -3679,7 +3680,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                 // Notify outside of synchronized block.
                 if (dataMap != null) {
                     for (Map.Entry<UUID, Map<Integer, byte[]>> entry : dataMap.entrySet())
-                        spi.onExchange(node.id(), entry.getKey(), entry.getValue(), U.gridClassLoader());
+                        spi.onExchange(node.id(), entry.getKey(), entry.getValue(),
+                            U.resolveClassLoader(spi.ignite().configuration().getClassLoader()));
                 }
 
                 processMessageFailedNodes(msg);
@@ -4604,7 +4606,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                     DiscoverySpiCustomMessage msgObj = null;
 
                     try {
-                        msgObj = msg.message(spi.marsh);
+                        msgObj = msg.message(spi.marsh, spi.ignite().configuration().getClassLoader());
                     }
                     catch (Throwable e) {
                         U.error(log, "Failed to unmarshal discovery custom message.", e);
@@ -4727,7 +4729,8 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                 if (node != null) {
                     try {
-                        DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh);
+                        DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh,
+                            spi.ignite().configuration().getClassLoader());
 
                         lsnr.onDiscovery(DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT,
                             msg.topologyVersion(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index f9273c3..0d41cd2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1700,7 +1700,6 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
      * @param joiningNodeID Joining node ID.
      * @param nodeId Remote node ID for which data is provided.
      * @param data Collection of marshalled discovery data objects from different components.
-     * @param clsLdr Class loader for discovery data unmarshalling.
      */
     protected void onExchange(UUID joiningNodeID,
         UUID nodeId,

http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
index 8f14459..e10de46 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
@@ -74,8 +74,16 @@ public class TcpDiscoveryCustomEventMessage extends TcpDiscoveryAbstractMessage
      * @throws java.lang.Throwable if unmarshal failed.
      */
     @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh) throws Throwable {
+        return message(marsh, null);
+    }
+
+    /**
+     * @return Deserialized message,
+     * @throws java.lang.Throwable if unmarshal failed.
+     */
+    @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh, ClassLoader ldr) throws Throwable {
         if (msg == null) {
-            msg = marsh.unmarshal(msgBytes, U.gridClassLoader());
+            msg = marsh.unmarshal(msgBytes, U.resolveClassLoader(ldr));
 
             assert msg != null;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
index 5649b34..523f641 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 import java.util.UUID;
+import javax.cache.configuration.Factory;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CachePeekMode;
@@ -70,6 +71,12 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
     private int poolSize = 2;
 
     /** */
+    private volatile boolean needStore = false;
+
+    /** */
+    private volatile boolean isClient = false;
+
+    /** */
     private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
 
     /** {@inheritDoc} */
@@ -104,6 +111,9 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
         if (getTestGridName(1).equals(gridName) || cfg.getMarshaller() instanceof BinaryMarshaller)
             cfg.setClassLoader(getExternalClassLoader());
 
+        if (isClient)
+            cfg.setClientMode(true);
+
         return cfg;
     }
 
@@ -122,6 +132,20 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
         cacheCfg.setRebalanceBatchSize(batchSize);
         cacheCfg.setRebalanceThreadPoolSize(poolSize);
 
+        if (needStore) {
+            Object sf = null;
+
+            try {
+                sf = getExternalClassLoader().
+                    loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
+            }
+            catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+
+            cacheCfg.setCacheStoreFactory((Factory)sf);
+        }
+
         return cacheCfg;
     }
 
@@ -233,6 +257,18 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
             assert v2.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader") ||
                 grid(2).configuration().getMarshaller() instanceof BinaryMarshaller;
 
+            Object e1 = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestEnumValue").getEnumConstants()[0];
+
+            cache1.put(2, e1);
+
+            Object e2 = cache2.get(2);
+
+            assert e2 != null;
+            assert e2.toString().equals(e1.toString());
+            assert !e2.getClass().getClassLoader().equals(getClass().getClassLoader());
+            assert e2.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader") ||
+                grid(2).configuration().getMarshaller() instanceof BinaryMarshaller;
+
             stopGrid(1);
 
             Ignite g3 = startGrid(3);
@@ -259,6 +295,78 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If test failed.
      */
+    public void testStore() throws Exception {
+        try {
+            Ignite g1 = startGrid(1);
+
+            if (g1.configuration().getMarshaller() instanceof BinaryMarshaller) {
+                stopAllGrids();
+
+                needStore = true;
+
+                g1 = startGrid(1);
+
+                ClassLoader ldr = grid(1).configuration().getClassLoader();
+
+                CacheConfiguration cfg = defaultCacheConfiguration();
+
+                Ignite g2 = startGrid(2);  // Checks deserialization at node join.
+
+                isClient = true;
+
+                Ignite g3 = startGrid(3);
+
+                isClient = false;
+
+                IgniteCache<Integer, Object> cache1 = g1.cache(null);
+                IgniteCache<Integer, Object> cache2 = g2.cache(null);
+                IgniteCache<Integer, Object> cache3 = g3.cache(null);
+
+                cache1.put(1, 1);
+
+                assertEquals(1, cache2.get(1));
+                assertEquals(1, cache3.get(1));
+
+                needStore = false;
+
+                stopAllGrids();
+
+                g1 = startGrid(1);
+                g2 = startGrid(2);
+
+                isClient = true;
+
+                g3 = startGrid(3);
+
+                isClient = false;
+
+                Object sf = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
+
+                cfg.setCacheStoreFactory((Factory)sf);
+                cfg.setName("customStore");
+
+                cache1 = g1.createCache(cfg);
+
+                cache2 = g2.getOrCreateCache(cfg); // Checks deserialization at cache creation.
+                cache3 = g3.getOrCreateCache(cfg); // Checks deserialization at cache creation.
+
+                cache1.put(1, 1);
+
+                assertEquals(1, cache2.get(1));
+                assertEquals(1, cache3.get(1));
+            }
+        }
+        finally {
+            needStore = false;
+            isClient = false;
+
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception If test failed.
+     */
     public void testSync() throws Exception {
         preloadMode = SYNC;
         batchSize = 512;

http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestEnumValue.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestEnumValue.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestEnumValue.java
new file mode 100644
index 0000000..cc70e2d
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestEnumValue.java
@@ -0,0 +1,47 @@
+/*
+ * 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.tests.p2p;
+
+/**
+ * Test enum for cache deployment tests.
+ */
+public enum CacheDeploymentTestEnumValue {
+    ONE("one"),
+    TWO("two"),
+    THREE("three");
+
+    /** */
+    private String value;
+
+    /** */
+    CacheDeploymentTestEnumValue(String value) {
+        this.value = value;
+    }
+
+    /** */
+    public String getValue() {
+        return value;
+    }
+
+    /** */
+    @Override public String toString() {
+        return "CacheDeploymentTestEnumValue{" +
+            "value='" + value + '\'' +
+            '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestStoreFactory.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestStoreFactory.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestStoreFactory.java
new file mode 100644
index 0000000..1a0fc17
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestStoreFactory.java
@@ -0,0 +1,113 @@
+/*
+ * 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.tests.p2p;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.internal.processors.cache.store.CacheLocalStore;
+import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Test store factory for cache deployment tests.
+ */
+public class CacheDeploymentTestStoreFactory implements Factory<CacheStore<Integer, String>>, Serializable {
+    /** {@inheritDoc} */
+    @Override public CacheStore<Integer, String> create() {
+        return new TestLocalStore();
+    }
+
+    /**
+     *
+     */
+    @CacheLocalStore
+    public static class TestLocalStore<K, V> implements CacheStore<K, IgniteBiTuple<V, ?>>, Serializable {
+        /** */
+        private Map<K, IgniteBiTuple<V, ?>> map = new ConcurrentHashMap<>();
+
+        /** {@inheritDoc} */
+        @Override public void loadCache(IgniteBiInClosure<K, IgniteBiTuple<V, ?>> clo, @Nullable Object... args)
+            throws CacheLoaderException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void sessionEnd(boolean commit) throws CacheWriterException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public IgniteBiTuple<V, ?> load(K key) throws CacheLoaderException {
+            return map.get(key);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<K, IgniteBiTuple<V, ?>> loadAll(Iterable<? extends K> keys) throws CacheLoaderException {
+            Map<K, IgniteBiTuple<V, ?>> res = new HashMap<>();
+
+            for (K key : keys) {
+                IgniteBiTuple<V, ?> val = map.get(key);
+
+                if (val != null)
+                    res.put(key, val);
+            }
+
+            return res;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void write(Cache.Entry<? extends K, ? extends IgniteBiTuple<V, ?>> entry)
+            throws CacheWriterException {
+            map.put(entry.getKey(), entry.getValue());
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeAll(Collection<Cache.Entry<? extends K, ? extends IgniteBiTuple<V, ?>>> entries)
+            throws CacheWriterException {
+            for (Cache.Entry<? extends K, ? extends IgniteBiTuple<V, ?>> e : entries)
+                map.put(e.getKey(), e.getValue());
+        }
+
+        /** {@inheritDoc} */
+        @Override public void delete(Object key) throws CacheWriterException {
+            map.remove(key);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void deleteAll(Collection<?> keys) throws CacheWriterException {
+            for (Object key : keys)
+                map.remove(key);
+        }
+
+        /**
+         * Clear store.
+         */
+        public void clear() {
+            map.clear();
+        }
+    }
+}
\ No newline at end of file


[20/28] ignite git commit: ignite-2080 Data alignment issues with Unsafe

Posted by vo...@apache.org.
ignite-2080 Data alignment issues with Unsafe


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

Branch: refs/heads/ignite-2508
Commit: a87decdca4009a2af857d8ca6a46e5a719786a6d
Parents: 4035d40
Author: agura <ag...@gridgain.com>
Authored: Mon Jan 11 14:53:02 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Tue Feb 2 20:26:24 2016 +0300

----------------------------------------------------------------------
 .../internal/binary/BinaryClassDescriptor.java  |    6 +-
 .../internal/binary/BinaryFieldAccessor.java    |   45 +-
 .../internal/binary/BinaryMarshaller.java       |    5 +-
 .../binary/BinaryObjectOffheapImpl.java         |   34 +-
 .../internal/binary/BinaryPrimitives.java       |  117 +-
 .../streams/BinaryAbstractInputStream.java      |   53 +-
 .../streams/BinaryAbstractOutputStream.java     |   90 +-
 .../binary/streams/BinaryAbstractStream.java    |   34 -
 .../binary/streams/BinaryHeapInputStream.java   |   43 +-
 .../binary/streams/BinaryHeapOutputStream.java  |   86 +-
 .../streams/BinaryMemoryAllocatorChunk.java     |    9 +-
 .../streams/BinaryOffheapInputStream.java       |   42 +-
 .../streams/BinaryOffheapOutputStream.java      |   94 +-
 .../internal/direct/DirectMessageReader.java    |    2 +-
 .../internal/direct/DirectMessageWriter.java    |    2 +-
 .../stream/v1/DirectByteBufferStreamImplV1.java |  106 +-
 .../stream/v2/DirectByteBufferStreamImplV2.java |  351 ++++-
 .../cache/GridCacheEvictionManager.java         |    7 +-
 .../cache/GridCacheOffheapSwapEntry.java        |   24 +-
 .../cache/GridCacheSwapEntryImpl.java           |   61 +-
 .../binary/CacheObjectBinaryProcessorImpl.java  |    8 +-
 .../dht/atomic/GridDhtAtomicCache.java          |   13 +-
 .../local/atomic/GridLocalAtomicCache.java      |    9 +-
 .../IgniteCacheObjectProcessorImpl.java         |    7 +-
 .../platform/memory/PlatformAbstractMemory.java |    6 +-
 .../PlatformBigEndianOutputStreamImpl.java      |   14 +-
 .../memory/PlatformInputStreamImpl.java         |   53 +-
 .../platform/memory/PlatformMemoryUtils.java    |  108 +-
 .../memory/PlatformOutputStreamImpl.java        |   58 +-
 .../ignite/internal/util/GridHandleTable.java   |   17 +-
 .../ignite/internal/util/GridJavaProcess.java   |    3 -
 .../internal/util/GridSpinReadWriteLock.java    |   10 +-
 .../apache/ignite/internal/util/GridUnsafe.java | 1483 +++++++++++++++++-
 .../ignite/internal/util/IgniteUtils.java       |   99 +-
 .../internal/util/io/GridUnsafeDataInput.java   |  145 +-
 .../internal/util/io/GridUnsafeDataOutput.java  |  165 +-
 .../util/offheap/unsafe/GridUnsafeMap.java      |   75 +-
 .../util/offheap/unsafe/GridUnsafeMemory.java   |  106 +-
 .../optimized/OptimizedClassDescriptor.java     |   22 +-
 .../optimized/OptimizedMarshaller.java          |    5 +-
 .../optimized/OptimizedMarshallerUtils.java     |   44 +-
 .../optimized/OptimizedObjectInputStream.java   |   10 +-
 .../java/org/apache/ignite/GridTestIoUtils.java |  117 +-
 .../ignite/internal/GridAffinitySelfTest.java   |    2 +-
 .../binary/BinaryFieldsOffheapSelfTest.java     |   13 +-
 .../BinaryFooterOffsetsOffheapSelfTest.java     |   13 +-
 .../binary/BinaryMarshallerSelfTest.java        |   17 +-
 ...naryObjectBuilderDefaultMappersSelfTest.java |   24 +-
 .../mutabletest/GridBinaryTestClasses.java      |    3 +-
 .../AbstractBinaryStreamByteOrderSelfTest.java  |  464 ++++++
 .../BinaryHeapStreamByteOrderSelfTest.java      |   29 +
 .../BinaryOffheapStreamByteOrderSelfTest.java   |   31 +
 ...ByteBufferStreamImplV2ByteOrderSelfTest.java |  244 +++
 .../cache/GridCacheConcurrentMapSelfTest.java   |   13 +-
 ...ContinuousQueryFailoverAbstractSelfTest.java |    6 +
 ...dUnsafeDataInputOutputByteOrderSelfTest.java |  249 +++
 .../ignite/lang/GridBasicPerformanceTest.java   |   11 +-
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java |    2 +-
 .../testframework/junits/GridAbstractTest.java  |    4 +-
 .../IgniteBinaryObjectsTestSuite.java           |    6 +
 .../IgniteMarshallerSelfTestSuite.java          |    4 +
 .../hadoop/shuffle/HadoopShuffleJob.java        |    5 +-
 .../hadoop/shuffle/HadoopShuffleMessage.java    |   10 +-
 .../shuffle/streams/HadoopDataOutStream.java    |    6 +-
 .../HadoopConcurrentHashMultimapSelftest.java   |    6 +-
 .../collections/HadoopSkipListSelfTest.java     |    5 +-
 66 files changed, 3851 insertions(+), 1104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
index 233e74b..5cb8a86 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
@@ -46,16 +46,12 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.MarshallerExclusions;
 import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
 import org.jetbrains.annotations.Nullable;
-import sun.misc.Unsafe;
 
 /**
  * Binary class descriptor.
  */
 public class BinaryClassDescriptor {
     /** */
-    public static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
     @GridToStringExclude
     private final BinaryContext ctx;
 
@@ -776,7 +772,7 @@ public class BinaryClassDescriptor {
      */
     private Object newInstance() throws BinaryObjectException {
         try {
-            return ctor != null ? ctor.newInstance() : UNSAFE.allocateInstance(cls);
+            return ctor != null ? ctor.newInstance() : GridUnsafe.allocateInstance(cls);
         }
         catch (InstantiationException | InvocationTargetException | IllegalAccessException e) {
             throw new BinaryObjectException("Failed to instantiate instance: " + cls, e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
index 2d69cbd..8c8bf27 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
@@ -17,11 +17,6 @@
 
 package org.apache.ignite.internal.binary;
 
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
-
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
@@ -29,6 +24,9 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.util.UUID;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.typedef.internal.U;
 
 /**
  * Field accessor to speedup access.
@@ -157,9 +155,6 @@ public abstract class BinaryFieldAccessor {
      * Base primitive field accessor.
      */
     private static abstract class AbstractPrimitiveAccessor extends BinaryFieldAccessor {
-        /** Unsafe instance. */
-        protected static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
         /** Offset. */
         protected final long offset;
 
@@ -175,7 +170,7 @@ public abstract class BinaryFieldAccessor {
 
             assert field != null;
 
-            offset = UNSAFE.objectFieldOffset(field);
+            offset = GridUnsafe.objectFieldOffset(field);
         }
     }
 
@@ -196,7 +191,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
             writer.writeFieldIdNoSchemaUpdate(id);
 
-            byte val = UNSAFE.getByte(obj, offset);
+            byte val = GridUnsafe.getByteField(obj, offset);
 
             writer.writeByteFieldPrimitive(val);
         }
@@ -205,7 +200,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
             byte val = reader.readByte(id);
 
-            UNSAFE.putByte(obj, offset, val);
+            GridUnsafe.putByteField(obj, offset, val);
         }
     }
 
@@ -226,7 +221,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
             writer.writeFieldIdNoSchemaUpdate(id);
 
-            boolean val = UNSAFE.getBoolean(obj, offset);
+            boolean val = GridUnsafe.getBooleanField(obj, offset);
 
             writer.writeBooleanFieldPrimitive(val);
         }
@@ -235,7 +230,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
             boolean val = reader.readBoolean(id);
 
-            UNSAFE.putBoolean(obj, offset, val);
+            GridUnsafe.putBooleanField(obj, offset, val);
         }
     }
 
@@ -256,7 +251,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
             writer.writeFieldIdNoSchemaUpdate(id);
 
-            short val = UNSAFE.getShort(obj, offset);
+            short val = GridUnsafe.getShortField(obj, offset);
 
             writer.writeShortFieldPrimitive(val);
         }
@@ -265,7 +260,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
             short val = reader.readShort(id);
 
-            UNSAFE.putShort(obj, offset, val);
+            GridUnsafe.putShortField(obj, offset, val);
         }
     }
 
@@ -286,7 +281,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
             writer.writeFieldIdNoSchemaUpdate(id);
 
-            char val = UNSAFE.getChar(obj, offset);
+            char val = GridUnsafe.getCharField(obj, offset);
 
             writer.writeCharFieldPrimitive(val);
         }
@@ -295,7 +290,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
             char val = reader.readChar(id);
 
-            UNSAFE.putChar(obj, offset, val);
+            GridUnsafe.putCharField(obj, offset, val);
         }
     }
 
@@ -316,7 +311,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
             writer.writeFieldIdNoSchemaUpdate(id);
 
-            int val = UNSAFE.getInt(obj, offset);
+            int val = GridUnsafe.getIntField(obj, offset);
 
             writer.writeIntFieldPrimitive(val);
         }
@@ -325,7 +320,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
             int val = reader.readInt(id);
 
-            UNSAFE.putInt(obj, offset, val);
+            GridUnsafe.putIntField(obj, offset, val);
         }
     }
 
@@ -346,7 +341,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
             writer.writeFieldIdNoSchemaUpdate(id);
 
-            long val = UNSAFE.getLong(obj, offset);
+            long val = GridUnsafe.getLongField(obj, offset);
 
             writer.writeLongFieldPrimitive(val);
         }
@@ -355,7 +350,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
             long val = reader.readLong(id);
 
-            UNSAFE.putLong(obj, offset, val);
+            GridUnsafe.putLongField(obj, offset, val);
         }
     }
 
@@ -376,7 +371,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
             writer.writeFieldIdNoSchemaUpdate(id);
 
-            float val = UNSAFE.getFloat(obj, offset);
+            float val = GridUnsafe.getFloatField(obj, offset);
 
             writer.writeFloatFieldPrimitive(val);
         }
@@ -385,7 +380,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
             float val = reader.readFloat(id);
 
-            UNSAFE.putFloat(obj, offset, val);
+            GridUnsafe.putFloatField(obj, offset, val);
         }
     }
 
@@ -406,7 +401,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
             writer.writeFieldIdNoSchemaUpdate(id);
 
-            double val = UNSAFE.getDouble(obj, offset);
+            double val = GridUnsafe.getDoubleField(obj, offset);
 
             writer.writeDoubleFieldPrimitive(val);
         }
@@ -415,7 +410,7 @@ public abstract class BinaryFieldAccessor {
         @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
             double val = reader.readDouble(id);
 
-            UNSAFE.putDouble(obj, offset, val);
+            GridUnsafe.putDoubleField(obj, offset, val);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
index 5480967..29a1fca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
@@ -24,7 +24,6 @@ import java.io.OutputStream;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.marshaller.AbstractMarshaller;
 import org.apache.ignite.marshaller.MarshallerContext;
 import org.jetbrains.annotations.Nullable;
@@ -52,9 +51,7 @@ public class BinaryMarshaller extends AbstractMarshaller {
     @SuppressWarnings({"TypeParameterExtendsFinalClass", "ErrorNotRethrown"})
     public static boolean available() {
         try {
-            Unsafe unsafe = GridUnsafe.unsafe();
-
-            Class<? extends Unsafe> unsafeCls = unsafe.getClass();
+            Class<? extends Unsafe> unsafeCls = Unsafe.class;
 
             unsafeCls.getMethod("allocateInstance", Class.class);
             unsafeCls.getMethod("copyMemory", Object.class, long.class, Object.class, long.class, long.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
index 696a34b..07ab4d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
@@ -17,6 +17,16 @@
 
 package org.apache.ignite.internal.binary;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
@@ -26,23 +36,10 @@ import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
 import org.apache.ignite.internal.binary.streams.BinaryOffheapInputStream;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
-import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
 import org.jetbrains.annotations.Nullable;
-import sun.misc.Unsafe;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.UUID;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 
@@ -54,9 +51,6 @@ public class BinaryObjectOffheapImpl extends BinaryObjectExImpl implements Exter
     private static final long serialVersionUID = 0L;
 
     /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
     private final BinaryContext ctx;
 
     /** */
@@ -97,22 +91,22 @@ public class BinaryObjectOffheapImpl extends BinaryObjectExImpl implements Exter
 
     /** {@inheritDoc} */
     @Override public int typeId() {
-        return UNSAFE.getInt(ptr + start + GridBinaryMarshaller.TYPE_ID_POS);
+        return BinaryPrimitives.readInt(ptr, start + GridBinaryMarshaller.TYPE_ID_POS);
     }
 
     /** {@inheritDoc} */
     @Override public int length() {
-        return UNSAFE.getInt(ptr + start + GridBinaryMarshaller.TOTAL_LEN_POS);
+        return BinaryPrimitives.readInt(ptr, start + GridBinaryMarshaller.TOTAL_LEN_POS);
     }
 
     /** {@inheritDoc} */
     @Override public int hashCode() {
-        return UNSAFE.getInt(ptr + start + GridBinaryMarshaller.HASH_CODE_POS);
+        return BinaryPrimitives.readInt(ptr, start + GridBinaryMarshaller.HASH_CODE_POS);
     }
 
     /** {@inheritDoc} */
     @Override protected int schemaId() {
-        return UNSAFE.getInt(ptr + start + GridBinaryMarshaller.SCHEMA_ID_POS);
+        return BinaryPrimitives.readInt(ptr, start + GridBinaryMarshaller.SCHEMA_ID_POS);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryPrimitives.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryPrimitives.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryPrimitives.java
index a6a867c..8b82fad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryPrimitives.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryPrimitives.java
@@ -18,33 +18,20 @@
 package org.apache.ignite.internal.binary;
 
 import org.apache.ignite.internal.util.GridUnsafe;
-import sun.misc.Unsafe;
 
-import java.nio.ByteOrder;
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
 
 /**
  * Primitives writer.
  */
 public abstract class BinaryPrimitives {
-    /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
-    private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** */
-    private static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
-    /** Whether little endian is set. */
-    private static final boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
-
     /**
      * @param arr Array.
      * @param off Offset.
      * @param val Value.
      */
     public static void writeByte(byte[] arr, int off, byte val) {
-        UNSAFE.putByte(arr, BYTE_ARR_OFF + off, val);
+        GridUnsafe.putByte(arr, GridUnsafe.BYTE_ARR_OFF + off, val);
     }
 
     /**
@@ -53,7 +40,7 @@ public abstract class BinaryPrimitives {
      * @return Value.
      */
     public static byte readByte(byte[] arr, int off) {
-        return UNSAFE.getByte(arr, BYTE_ARR_OFF + off);
+        return GridUnsafe.getByte(arr, GridUnsafe.BYTE_ARR_OFF + off);
     }
 
     /**
@@ -62,7 +49,7 @@ public abstract class BinaryPrimitives {
      * @return Value.
      */
     public static byte readByte(long ptr, int off) {
-        return UNSAFE.getByte(ptr + off);
+        return GridUnsafe.getByte(ptr + off);
     }
 
     /**
@@ -73,7 +60,7 @@ public abstract class BinaryPrimitives {
     public static byte[] readByteArray(byte[] arr, int off, int len) {
         byte[] arr0 = new byte[len];
 
-        UNSAFE.copyMemory(arr, BYTE_ARR_OFF + off, arr0, BYTE_ARR_OFF, len);
+        GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF + off, arr0, GridUnsafe.BYTE_ARR_OFF, len);
 
         return arr0;
     }
@@ -86,7 +73,7 @@ public abstract class BinaryPrimitives {
     public static byte[] readByteArray(long ptr, int off, int len) {
         byte[] arr0 = new byte[len];
 
-        UNSAFE.copyMemory(null, ptr + off, arr0, BYTE_ARR_OFF, len);
+        GridUnsafe.copyMemory(null, ptr + off, arr0, GridUnsafe.BYTE_ARR_OFF, len);
 
         return arr0;
     }
@@ -124,10 +111,12 @@ public abstract class BinaryPrimitives {
      * @param val Value.
      */
     public static void writeShort(byte[] arr, int off, short val) {
-        if (BIG_ENDIAN)
-            val = Short.reverseBytes(val);
+        long pos = GridUnsafe.BYTE_ARR_OFF + off;
 
-        UNSAFE.putShort(arr, BYTE_ARR_OFF + off, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putShortLE(arr, pos, val);
+        else
+            GridUnsafe.putShort(arr, pos, val);
     }
 
     /**
@@ -136,12 +125,9 @@ public abstract class BinaryPrimitives {
      * @return Value.
      */
     public static short readShort(byte[] arr, int off) {
-        short val = UNSAFE.getShort(arr, BYTE_ARR_OFF + off);
-
-        if (BIG_ENDIAN)
-            val = Short.reverseBytes(val);
+        long pos = GridUnsafe.BYTE_ARR_OFF + off;
 
-        return val;
+        return BIG_ENDIAN ? GridUnsafe.getShortLE(arr, pos) : GridUnsafe.getShort(arr, pos);
     }
 
     /**
@@ -150,12 +136,9 @@ public abstract class BinaryPrimitives {
      * @return Value.
      */
     public static short readShort(long ptr, int off) {
-        short val = UNSAFE.getShort(ptr + off);
-
-        if (BIG_ENDIAN)
-            val = Short.reverseBytes(val);
+        long addr = ptr + off;
 
-        return val;
+        return BIG_ENDIAN ? GridUnsafe.getShortLE(addr) : GridUnsafe.getShort(addr);
     }
 
     /**
@@ -164,10 +147,12 @@ public abstract class BinaryPrimitives {
      * @param val Value.
      */
     public static void writeChar(byte[] arr, int off, char val) {
-        if (BIG_ENDIAN)
-            val = Character.reverseBytes(val);
+        long pos = GridUnsafe.BYTE_ARR_OFF + off;
 
-        UNSAFE.putChar(arr, BYTE_ARR_OFF + off, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putCharLE(arr, pos, val);
+        else
+            GridUnsafe.putChar(arr, pos, val);
     }
 
     /**
@@ -176,12 +161,9 @@ public abstract class BinaryPrimitives {
      * @return Value.
      */
     public static char readChar(byte[] arr, int off) {
-        char val = UNSAFE.getChar(arr, BYTE_ARR_OFF + off);
-
-        if (BIG_ENDIAN)
-            val = Character.reverseBytes(val);
+        long pos = GridUnsafe.BYTE_ARR_OFF + off;
 
-        return val;
+        return BIG_ENDIAN ? GridUnsafe.getCharLE(arr, pos): GridUnsafe.getChar(arr, pos);
     }
 
     /**
@@ -190,12 +172,9 @@ public abstract class BinaryPrimitives {
      * @return Value.
      */
     public static char readChar(long ptr, int off) {
-        char val = UNSAFE.getChar(ptr + off);
+        long addr = ptr + off;
 
-        if (BIG_ENDIAN)
-            val = Character.reverseBytes(val);
-
-        return val;
+        return BIG_ENDIAN ? GridUnsafe.getCharLE(addr) : GridUnsafe.getChar(addr);
     }
 
     /**
@@ -206,7 +185,7 @@ public abstract class BinaryPrimitives {
     public static char[] readCharArray(byte[] arr, int off, int len) {
         char[] arr0 = new char[len];
 
-        UNSAFE.copyMemory(arr, BYTE_ARR_OFF + off, arr0, CHAR_ARR_OFF, len << 1);
+        GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF + off, arr0, GridUnsafe.CHAR_ARR_OFF, len << 1);
 
         if (BIG_ENDIAN) {
             for (int i = 0; i < len; i++)
@@ -224,7 +203,7 @@ public abstract class BinaryPrimitives {
     public static char[] readCharArray(long ptr, int off, int len) {
         char[] arr0 = new char[len];
 
-        UNSAFE.copyMemory(null, ptr + off, arr0, CHAR_ARR_OFF, len << 1);
+        GridUnsafe.copyMemory(null, ptr + off, arr0, GridUnsafe.CHAR_ARR_OFF, len << 1);
 
         if (BIG_ENDIAN) {
             for (int i = 0; i < len; i++)
@@ -240,10 +219,12 @@ public abstract class BinaryPrimitives {
      * @param val Value.
      */
     public static void writeInt(byte[] arr, int off, int val) {
-        if (BIG_ENDIAN)
-            val = Integer.reverseBytes(val);
+        long pos = GridUnsafe.BYTE_ARR_OFF + off;
 
-        UNSAFE.putInt(arr, BYTE_ARR_OFF + off, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putIntLE(arr, pos, val);
+        else
+            GridUnsafe.putInt(arr, pos, val);
     }
 
     /**
@@ -252,12 +233,9 @@ public abstract class BinaryPrimitives {
      * @return Value.
      */
     public static int readInt(byte[] arr, int off) {
-        int val = UNSAFE.getInt(arr, BYTE_ARR_OFF + off);
+        long pos = GridUnsafe.BYTE_ARR_OFF + off;
 
-        if (BIG_ENDIAN)
-            val = Integer.reverseBytes(val);
-
-        return val;
+        return BIG_ENDIAN ? GridUnsafe.getIntLE(arr, pos) : GridUnsafe.getInt(arr, pos);
     }
 
     /**
@@ -266,12 +244,9 @@ public abstract class BinaryPrimitives {
      * @return Value.
      */
     public static int readInt(long ptr, int off) {
-        int val = UNSAFE.getInt(ptr + off);
-
-        if (BIG_ENDIAN)
-            val = Integer.reverseBytes(val);
+        long addr = ptr + off;
 
-        return val;
+        return BIG_ENDIAN ? GridUnsafe.getIntLE(addr) : GridUnsafe.getInt(addr);
     }
 
     /**
@@ -280,10 +255,12 @@ public abstract class BinaryPrimitives {
      * @param val Value.
      */
     public static void writeLong(byte[] arr, int off, long val) {
-        if (BIG_ENDIAN)
-            val = Long.reverseBytes(val);
+        long pos = GridUnsafe.BYTE_ARR_OFF + off;
 
-        UNSAFE.putLong(arr, BYTE_ARR_OFF + off, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putLongLE(arr, pos, val);
+        else
+            GridUnsafe.putLong(arr, pos, val);
     }
 
     /**
@@ -292,12 +269,9 @@ public abstract class BinaryPrimitives {
      * @return Value.
      */
     public static long readLong(byte[] arr, int off) {
-        long val = UNSAFE.getLong(arr, BYTE_ARR_OFF + off);
+        long pos = GridUnsafe.BYTE_ARR_OFF + off;
 
-        if (BIG_ENDIAN)
-            val = Long.reverseBytes(val);
-
-        return val;
+        return BIG_ENDIAN ? GridUnsafe.getLongLE(arr, pos) : GridUnsafe.getLong(arr, pos);
     }
 
     /**
@@ -306,12 +280,9 @@ public abstract class BinaryPrimitives {
      * @return Value.
      */
     public static long readLong(long ptr, int off) {
-        long val = UNSAFE.getLong(ptr + off);
-
-        if (BIG_ENDIAN)
-            val = Long.reverseBytes(val);
+        long addr = ptr + off;
 
-        return val;
+        return BIG_ENDIAN ? GridUnsafe.getLongLE(addr) : GridUnsafe.getLong(addr);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractInputStream.java
index 334f455..b6c30bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractInputStream.java
@@ -18,6 +18,9 @@
 package org.apache.ignite.internal.binary.streams;
 
 import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
 
 /**
  * Binary abstract input stream.
@@ -40,7 +43,7 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         byte[] res = new byte[cnt];
 
-        copyAndShift(res, BYTE_ARR_OFF, cnt);
+        copyAndShift(res, GridUnsafe.BYTE_ARR_OFF, cnt);
 
         return res;
     }
@@ -56,7 +59,7 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         boolean[] res = new boolean[cnt];
 
-        copyAndShift(res, BOOLEAN_ARR_OFF, cnt);
+        copyAndShift(res, GridUnsafe.BOOLEAN_ARR_OFF, cnt);
 
         return res;
     }
@@ -69,9 +72,6 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         shift(2);
 
-        if (!LITTLE_ENDIAN)
-            res = Short.reverseBytes(res);
-
         return res;
     }
 
@@ -83,9 +83,9 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         short[] res = new short[cnt];
 
-        copyAndShift(res, SHORT_ARR_OFF, len);
+        copyAndShift(res, GridUnsafe.SHORT_ARR_OFF, len);
 
-        if (!LITTLE_ENDIAN) {
+        if (BIG_ENDIAN) {
             for (int i = 0; i < res.length; i++)
                 res[i] = Short.reverseBytes(res[i]);
         }
@@ -101,9 +101,6 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         shift(2);
 
-        if (!LITTLE_ENDIAN)
-            res = Character.reverseBytes(res);
-
         return res;
     }
 
@@ -115,9 +112,9 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         char[] res = new char[cnt];
 
-        copyAndShift(res, CHAR_ARR_OFF, len);
+        copyAndShift(res, GridUnsafe.CHAR_ARR_OFF, len);
 
-        if (!LITTLE_ENDIAN) {
+        if (BIG_ENDIAN) {
             for (int i = 0; i < res.length; i++)
                 res[i] = Character.reverseBytes(res[i]);
         }
@@ -133,9 +130,6 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         shift(4);
 
-        if (!LITTLE_ENDIAN)
-            res = Integer.reverseBytes(res);
-
         return res;
     }
 
@@ -147,9 +141,9 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         int[] res = new int[cnt];
 
-        copyAndShift(res, INT_ARR_OFF, len);
+        copyAndShift(res, GridUnsafe.INT_ARR_OFF, len);
 
-        if (!LITTLE_ENDIAN) {
+        if (BIG_ENDIAN) {
             for (int i = 0; i < res.length; i++)
                 res[i] = Integer.reverseBytes(res[i]);
         }
@@ -200,17 +194,17 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         float[] res = new float[cnt];
 
-        if (LITTLE_ENDIAN)
-            copyAndShift(res, FLOAT_ARR_OFF, len);
-        else {
+        if (BIG_ENDIAN) {
             for (int i = 0; i < res.length; i++) {
                 int x = readIntFast();
 
                 shift(4);
 
-                res[i] = Float.intBitsToFloat(Integer.reverseBytes(x));
+                res[i] = Float.intBitsToFloat(x);
             }
         }
+        else
+            copyAndShift(res, GridUnsafe.FLOAT_ARR_OFF, len);
 
         return res;
     }
@@ -223,9 +217,6 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         shift(8);
 
-        if (!LITTLE_ENDIAN)
-            res = Long.reverseBytes(res);
-
         return res;
     }
 
@@ -237,9 +228,9 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         long[] res = new long[cnt];
 
-        copyAndShift(res, LONG_ARR_OFF, len);
+        copyAndShift(res, GridUnsafe.LONG_ARR_OFF, len);
 
-        if (!LITTLE_ENDIAN) {
+        if (BIG_ENDIAN) {
             for (int i = 0; i < res.length; i++)
                 res[i] = Long.reverseBytes(res[i]);
         }
@@ -260,17 +251,17 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
 
         double[] res = new double[cnt];
 
-        if (LITTLE_ENDIAN)
-            copyAndShift(res, DOUBLE_ARR_OFF, len);
-        else {
+        if (BIG_ENDIAN) {
             for (int i = 0; i < res.length; i++) {
                 long x = readLongFast();
 
                 shift(8);
 
-                res[i] = Double.longBitsToDouble(Long.reverseBytes(x));
+                res[i] = Double.longBitsToDouble(x);
             }
         }
+        else
+            copyAndShift(res, GridUnsafe.DOUBLE_ARR_OFF, len);
 
         return res;
     }
@@ -280,7 +271,7 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
         if (len > remaining())
             len = remaining();
 
-        copyAndShift(arr, BYTE_ARR_OFF + off, len);
+        copyAndShift(arr, GridUnsafe.BYTE_ARR_OFF + off, len);
 
         return len;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStream.java
index 4221cbe..b9df68e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStream.java
@@ -17,6 +17,10 @@
 
 package org.apache.ignite.internal.binary.streams;
 
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+
 /**
  * Base binary output stream.
  */
@@ -36,7 +40,7 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
     @Override public void writeByteArray(byte[] val) {
         ensureCapacity(pos + val.length);
 
-        copyAndShift(val, BYTE_ARR_OFF, val.length);
+        copyAndShift(val, GridUnsafe.BYTE_ARR_OFF, val.length);
     }
 
     /** {@inheritDoc} */
@@ -48,16 +52,13 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
     @Override public void writeBooleanArray(boolean[] val) {
         ensureCapacity(pos + val.length);
 
-        copyAndShift(val, BOOLEAN_ARR_OFF, val.length);
+        copyAndShift(val, GridUnsafe.BOOLEAN_ARR_OFF, val.length);
     }
 
     /** {@inheritDoc} */
     @Override public void writeShort(short val) {
         ensureCapacity(pos + 2);
 
-        if (!LITTLE_ENDIAN)
-            val = Short.reverseBytes(val);
-
         writeShortFast(val);
 
         shift(2);
@@ -69,23 +70,21 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
 
         ensureCapacity(pos + cnt);
 
-        if (LITTLE_ENDIAN)
-            copyAndShift(val, SHORT_ARR_OFF, cnt);
-        else {
-            for (short item : val)
-                writeShortFast(Short.reverseBytes(item));
+        if (BIG_ENDIAN) {
+            for (short item : val) {
+                writeShortFast(item);
 
-            shift(cnt);
+                shift(2);
+            }
         }
+        else
+            copyAndShift(val, GridUnsafe.SHORT_ARR_OFF, cnt);
     }
 
     /** {@inheritDoc} */
     @Override public void writeChar(char val) {
         ensureCapacity(pos + 2);
 
-        if (!LITTLE_ENDIAN)
-            val = Character.reverseBytes(val);
-
         writeCharFast(val);
 
         shift(2);
@@ -97,23 +96,21 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
 
         ensureCapacity(pos + cnt);
 
-        if (LITTLE_ENDIAN)
-            copyAndShift(val, CHAR_ARR_OFF, cnt);
-        else {
-            for (char item : val)
-                writeCharFast(Character.reverseBytes(item));
+        if (BIG_ENDIAN) {
+            for (char item : val) {
+                writeCharFast(item);
 
-            shift(cnt);
+                shift(2);
+            }
         }
+        else
+            copyAndShift(val, GridUnsafe.CHAR_ARR_OFF, cnt);
     }
 
     /** {@inheritDoc} */
     @Override public void writeInt(int val) {
         ensureCapacity(pos + 4);
 
-        if (!LITTLE_ENDIAN)
-            val = Integer.reverseBytes(val);
-
         writeIntFast(val);
 
         shift(4);
@@ -139,14 +136,15 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
 
         ensureCapacity(pos + cnt);
 
-        if (LITTLE_ENDIAN)
-            copyAndShift(val, INT_ARR_OFF, cnt);
-        else {
-            for (int item : val)
-                writeIntFast(Integer.reverseBytes(item));
+        if (BIG_ENDIAN) {
+            for (int item : val) {
+                writeIntFast(item);
 
-            shift(cnt);
+                shift(4);
+            }
         }
+        else
+            copyAndShift(val, GridUnsafe.INT_ARR_OFF, cnt);
     }
 
     /** {@inheritDoc} */
@@ -160,24 +158,21 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
 
         ensureCapacity(pos + cnt);
 
-        if (LITTLE_ENDIAN)
-            copyAndShift(val, FLOAT_ARR_OFF, cnt);
-        else {
+        if (BIG_ENDIAN) {
             for (float item : val) {
-                writeIntFast(Integer.reverseBytes(Float.floatToIntBits(item)));
+                writeIntFast(Float.floatToIntBits(item));
 
                 shift(4);
             }
         }
+        else
+            copyAndShift(val, GridUnsafe.FLOAT_ARR_OFF, cnt);
     }
 
     /** {@inheritDoc} */
     @Override public void writeLong(long val) {
         ensureCapacity(pos + 8);
 
-        if (!LITTLE_ENDIAN)
-            val = Long.reverseBytes(val);
-
         writeLongFast(val);
 
         shift(8);
@@ -189,14 +184,15 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
 
         ensureCapacity(pos + cnt);
 
-        if (LITTLE_ENDIAN)
-            copyAndShift(val, LONG_ARR_OFF, cnt);
-        else {
-            for (long item : val)
-                writeLongFast(Long.reverseBytes(item));
+        if (BIG_ENDIAN) {
+            for (long item : val) {
+                writeLongFast(item);
 
-            shift(cnt);
+                shift(8);
+            }
         }
+        else
+            copyAndShift(val, GridUnsafe.LONG_ARR_OFF, cnt);
     }
 
     /** {@inheritDoc} */
@@ -210,22 +206,22 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
 
         ensureCapacity(pos + cnt);
 
-        if (LITTLE_ENDIAN)
-            copyAndShift(val, DOUBLE_ARR_OFF, cnt);
-        else {
+        if (BIG_ENDIAN) {
             for (double item : val) {
-                writeLongFast(Long.reverseBytes(Double.doubleToLongBits(item)));
+                writeLongFast(Double.doubleToLongBits(item));
 
                 shift(8);
             }
         }
+        else
+            copyAndShift(val, GridUnsafe.DOUBLE_ARR_OFF, cnt);
     }
 
     /** {@inheritDoc} */
     @Override public void write(byte[] arr, int off, int len) {
         ensureCapacity(pos + len);
 
-        copyAndShift(arr, BYTE_ARR_OFF + off, len);
+        copyAndShift(arr, GridUnsafe.BYTE_ARR_OFF + off, len);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractStream.java
index 1e8ce09..2983cbc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractStream.java
@@ -17,10 +17,6 @@
 
 package org.apache.ignite.internal.binary.streams;
 
-import java.nio.ByteOrder;
-import org.apache.ignite.internal.util.GridUnsafe;
-import sun.misc.Unsafe;
-
 /**
  * Binary abstract stream.
  */
@@ -31,36 +27,6 @@ public abstract class BinaryAbstractStream implements BinaryStream {
     /** Byte: one. */
     protected static final byte BYTE_ONE = 1;
 
-    /** Whether little endian is used on the platform. */
-    protected static final boolean LITTLE_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN;
-
-    /** Unsafe instance. */
-    protected static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** Array offset: boolean. */
-    protected static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
-
-    /** Array offset: byte. */
-    protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** Array offset: short. */
-    protected static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
-
-    /** Array offset: char. */
-    protected static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
-    /** Array offset: int. */
-    protected static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
-
-    /** Array offset: float. */
-    protected static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
-
-    /** Array offset: long. */
-    protected static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
-
-    /** Array offset: double. */
-    protected static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
-
     /** Position. */
     protected int pos;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapInputStream.java
index 732b8c7..b584373 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapInputStream.java
@@ -18,9 +18,12 @@
 package org.apache.ignite.internal.binary.streams;
 
 import java.util.Arrays;
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
 
 /**
- * Binary off-heap input stream.
+ * Binary heap input stream.
  */
 public final class BinaryHeapInputStream extends BinaryAbstractInputStream {
     /**
@@ -75,7 +78,7 @@ public final class BinaryHeapInputStream extends BinaryAbstractInputStream {
         if (data.length < len) {
             byte[] data0 = new byte[len];
 
-            UNSAFE.copyMemory(data, BYTE_ARR_OFF, data0, BYTE_ARR_OFF, data.length);
+            GridUnsafe.copyMemory(data, GridUnsafe.BYTE_ARR_OFF, data0, GridUnsafe.BYTE_ARR_OFF, data.length);
 
             data = data0;
         }
@@ -97,7 +100,7 @@ public final class BinaryHeapInputStream extends BinaryAbstractInputStream {
     @Override public byte[] arrayCopy() {
         byte[] res = new byte[len];
 
-        UNSAFE.copyMemory(data, BYTE_ARR_OFF, res, BYTE_ARR_OFF, res.length);
+        GridUnsafe.copyMemory(data, GridUnsafe.BYTE_ARR_OFF, res, GridUnsafe.BYTE_ARR_OFF, res.length);
 
         return res;
     }
@@ -114,53 +117,57 @@ public final class BinaryHeapInputStream extends BinaryAbstractInputStream {
 
     /** {@inheritDoc} */
     @Override protected void copyAndShift(Object target, long off, int len) {
-        UNSAFE.copyMemory(data, BYTE_ARR_OFF + pos, target, off, len);
+        GridUnsafe.copyMemory(data, GridUnsafe.BYTE_ARR_OFF + pos, target, off, len);
 
         shift(len);
     }
 
     /** {@inheritDoc} */
     @Override protected short readShortFast() {
-        return UNSAFE.getShort(data, BYTE_ARR_OFF + pos);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+        return BIG_ENDIAN ? GridUnsafe.getShortLE(data, off) : GridUnsafe.getShort(data, off);
+
     }
 
     /** {@inheritDoc} */
     @Override protected char readCharFast() {
-        return UNSAFE.getChar(data, BYTE_ARR_OFF + pos);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+        return BIG_ENDIAN ? GridUnsafe.getCharLE(data, off) : GridUnsafe.getChar(data, off);
     }
 
     /** {@inheritDoc} */
     @Override protected int readIntFast() {
-        return UNSAFE.getInt(data, BYTE_ARR_OFF + pos);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+        return BIG_ENDIAN ? GridUnsafe.getIntLE(data, off) : GridUnsafe.getInt(data, off);
     }
 
     /** {@inheritDoc} */
     @Override protected long readLongFast() {
-        return UNSAFE.getLong(data, BYTE_ARR_OFF + pos);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+        return BIG_ENDIAN ? GridUnsafe.getLongLE(data, off) : GridUnsafe.getLong(data, off);
     }
 
     /** {@inheritDoc} */
     @Override protected byte readBytePositioned0(int pos) {
-        return UNSAFE.getByte(data, BYTE_ARR_OFF + pos);
+        return GridUnsafe.getByte(data, GridUnsafe.BYTE_ARR_OFF + pos);
     }
 
     /** {@inheritDoc} */
     @Override protected short readShortPositioned0(int pos) {
-        short res = UNSAFE.getShort(data, BYTE_ARR_OFF + pos);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
 
-        if (!LITTLE_ENDIAN)
-            res = Short.reverseBytes(res);
+        return BIG_ENDIAN ? GridUnsafe.getShortLE(data, off) : GridUnsafe.getShort(data, off);
 
-        return res;
     }
 
     /** {@inheritDoc} */
     @Override protected int readIntPositioned0(int pos) {
-        int res = UNSAFE.getInt(data, BYTE_ARR_OFF + pos);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
 
-        if (!LITTLE_ENDIAN)
-            res = Integer.reverseBytes(res);
-
-        return res;
+        return BIG_ENDIAN ? GridUnsafe.getIntLE(data, off) : GridUnsafe.getInt(data, off);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapOutputStream.java
index 7553f3b..2c31641 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapOutputStream.java
@@ -17,6 +17,10 @@
 
 package org.apache.ignite.internal.binary.streams;
 
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+
 /**
  * Binary heap output stream.
  */
@@ -71,7 +75,7 @@ public final class BinaryHeapOutputStream extends BinaryAbstractOutputStream {
     @Override public byte[] arrayCopy() {
         byte[] res = new byte[pos];
 
-        UNSAFE.copyMemory(data, BYTE_ARR_OFF, res, BYTE_ARR_OFF, pos);
+        GridUnsafe.copyMemory(data, GridUnsafe.BYTE_ARR_OFF, res, GridUnsafe.BYTE_ARR_OFF, pos);
 
         return res;
     }
@@ -88,88 +92,120 @@ public final class BinaryHeapOutputStream extends BinaryAbstractOutputStream {
 
     /** {@inheritDoc} */
     @Override protected void copyAndShift(Object src, long off, int len) {
-        UNSAFE.copyMemory(src, off, data, BYTE_ARR_OFF + pos, len);
+        GridUnsafe.copyMemory(src, off, data, GridUnsafe.BYTE_ARR_OFF + pos, len);
 
         shift(len);
     }
 
     /** {@inheritDoc} */
     @Override protected void writeShortFast(short val) {
-        UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putShortLE(data, off, val);
+        else
+            GridUnsafe.putShort(data, off, val);
     }
 
     /** {@inheritDoc} */
     @Override protected void writeCharFast(char val) {
-        UNSAFE.putChar(data, BYTE_ARR_OFF + pos, val);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putCharLE(data, off, val);
+        else
+            GridUnsafe.putChar(data, off, val);
     }
 
     /** {@inheritDoc} */
     @Override protected void writeIntFast(int val) {
-        UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putIntLE(data, off, val);
+        else
+            GridUnsafe.putInt(data, off, val);
     }
 
     /** {@inheritDoc} */
     @Override protected void writeLongFast(long val) {
-        UNSAFE.putLong(data, BYTE_ARR_OFF + pos, val);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putLongLE(data, off, val);
+        else
+            GridUnsafe.putLong(data, off, val);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteByte(byte val) {
-        UNSAFE.putByte(data, BYTE_ARR_OFF + pos++, val);
+        GridUnsafe.putByte(data, GridUnsafe.BYTE_ARR_OFF + pos++, val);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteShort(short val) {
-        if (!LITTLE_ENDIAN)
-            val = Short.reverseBytes(val);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
 
-        UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putShortLE(data, off, val);
+        else
+            GridUnsafe.putShort(data, off, val);
 
         shift(2);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteShort(int pos, short val) {
-        if (!LITTLE_ENDIAN)
-            val = Short.reverseBytes(val);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
 
-        UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putShortLE(data, off, val);
+        else
+            GridUnsafe.putShort(data, off, val);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteChar(char val) {
-        if (!LITTLE_ENDIAN)
-            val = Character.reverseBytes(val);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
 
-        UNSAFE.putChar(data, BYTE_ARR_OFF + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putCharLE(data, off, val);
+        else
+            GridUnsafe.putChar(data, off, val);
 
         shift(2);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteInt(int val) {
-        if (!LITTLE_ENDIAN)
-            val = Integer.reverseBytes(val);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
 
-        UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putIntLE(data, off, val);
+        else
+            GridUnsafe.putInt(data, off, val);
 
         shift(4);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteInt(int pos, int val) {
-        if (!LITTLE_ENDIAN)
-            val = Integer.reverseBytes(val);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
 
-        UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putIntLE(data, off, val);
+        else
+            GridUnsafe.putInt(data, off, val);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteLong(long val) {
-        if (!LITTLE_ENDIAN)
-            val = Long.reverseBytes(val);
+        long off = GridUnsafe.BYTE_ARR_OFF + pos;
 
-        UNSAFE.putLong(data, BYTE_ARR_OFF + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putLongLE(data, off, val);
+        else
+            GridUnsafe.putLong(data, off, val);
 
         shift(8);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryMemoryAllocatorChunk.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryMemoryAllocatorChunk.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryMemoryAllocatorChunk.java
index 7c73742..f9db7da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryMemoryAllocatorChunk.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryMemoryAllocatorChunk.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.binary.streams;
 
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RECHECK;
 
@@ -27,12 +26,6 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RE
  * Memory allocator chunk.
  */
 public class BinaryMemoryAllocatorChunk {
-    /** Unsafe instance. */
-    protected static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** Array offset: byte. */
-    protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
     /** Buffer size re-check frequency. */
     private static final Long CHECK_FREQ = Long.getLong(IGNITE_MARSHAL_BUFFERS_RECHECK, 10000);
 
@@ -79,7 +72,7 @@ public class BinaryMemoryAllocatorChunk {
         if (this.data == data)
             this.data = newData;
 
-        UNSAFE.copyMemory(data, BYTE_ARR_OFF, newData, BYTE_ARR_OFF, data.length);
+        GridUnsafe.copyMemory(data, GridUnsafe.BYTE_ARR_OFF, newData, GridUnsafe.BYTE_ARR_OFF, data.length);
 
         return newData;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapInputStream.java
index cff002f..9230846 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapInputStream.java
@@ -17,6 +17,10 @@
 
 package org.apache.ignite.internal.binary.streams;
 
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+
 /**
  * Binary off-heap input stream.
  */
@@ -70,7 +74,7 @@ public class BinaryOffheapInputStream extends BinaryAbstractInputStream {
     @Override public byte[] arrayCopy() {
         byte[] res = new byte[len];
 
-        UNSAFE.copyMemory(null, ptr, res, BYTE_ARR_OFF, res.length);
+        GridUnsafe.copyMemory(null, ptr, res, GridUnsafe.BYTE_ARR_OFF, res.length);
 
         return res;
     }
@@ -82,59 +86,61 @@ public class BinaryOffheapInputStream extends BinaryAbstractInputStream {
 
     /** {@inheritDoc} */
     @Override protected byte readByteAndShift() {
-        return UNSAFE.getByte(ptr + pos++);
+        return GridUnsafe.getByte(ptr + pos++);
     }
 
     /** {@inheritDoc} */
     @Override protected void copyAndShift(Object target, long off, int len) {
-        UNSAFE.copyMemory(null, ptr + pos, target, off, len);
+        GridUnsafe.copyMemory(null, ptr + pos, target, off, len);
 
         shift(len);
     }
 
     /** {@inheritDoc} */
     @Override protected short readShortFast() {
-        return UNSAFE.getShort(ptr + pos);
+        long addr = ptr + pos;
+
+        return BIG_ENDIAN ? GridUnsafe.getShortLE(addr) : GridUnsafe.getShort(addr);
     }
 
     /** {@inheritDoc} */
     @Override protected char readCharFast() {
-        return UNSAFE.getChar(ptr + pos);
+        long addr = ptr + pos;
+
+        return BIG_ENDIAN ? GridUnsafe.getCharLE(addr) : GridUnsafe.getChar(addr);
     }
 
     /** {@inheritDoc} */
     @Override protected int readIntFast() {
-        return UNSAFE.getInt(ptr + pos);
+        long addr = ptr + pos;
+
+        return BIG_ENDIAN ? GridUnsafe.getIntLE(addr) : GridUnsafe.getInt(addr);
     }
 
     /** {@inheritDoc} */
     @Override protected long readLongFast() {
-        return UNSAFE.getLong(ptr + pos);
+        long addr = ptr + pos;
+
+        return BIG_ENDIAN ? GridUnsafe.getLongLE(addr) : GridUnsafe.getLong(addr);
     }
 
     /** {@inheritDoc} */
     @Override protected byte readBytePositioned0(int pos) {
-        return UNSAFE.getByte(ptr + pos);
+        return GridUnsafe.getByte(ptr + pos);
     }
 
     /** {@inheritDoc} */
     @Override protected short readShortPositioned0(int pos) {
-        short res = UNSAFE.getShort(ptr + pos);
-
-        if (!LITTLE_ENDIAN)
-            res = Short.reverseBytes(res);
+        long addr = ptr + pos;
 
-        return res;
+        return BIG_ENDIAN ? GridUnsafe.getShortLE(addr) : GridUnsafe.getShort(addr);
     }
 
     /** {@inheritDoc} */
     @Override protected int readIntPositioned0(int pos) {
-        int res = UNSAFE.getInt(ptr + pos);
+        long addr = ptr + pos;
 
-        if (!LITTLE_ENDIAN)
-            res = Integer.reverseBytes(res);
-
-        return res;
+        return BIG_ENDIAN ? GridUnsafe.getIntLE(addr) : GridUnsafe.getInt(addr);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapOutputStream.java
index 080a357..1cb9f4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapOutputStream.java
@@ -17,6 +17,10 @@
 
 package org.apache.ignite.internal.binary.streams;
 
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+
 /**
  * Binary offheap output stream.
  */
@@ -73,7 +77,7 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
     @Override public byte[] arrayCopy() {
         byte[] res = new byte[pos];
 
-        UNSAFE.copyMemory(null, ptr, res, BYTE_ARR_OFF, pos);
+        GridUnsafe.copyMemory(null, ptr, res, GridUnsafe.BYTE_ARR_OFF, pos);
 
         return res;
     }
@@ -94,34 +98,54 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
 
     /** {@inheritDoc} */
     @Override protected void writeByteAndShift(byte val) {
-        UNSAFE.putByte(ptr + pos++, val);
+        GridUnsafe.putByte(ptr + pos++, val);
     }
 
     /** {@inheritDoc} */
     @Override protected void copyAndShift(Object src, long offset, int len) {
-        UNSAFE.copyMemory(src, offset, null, ptr + pos, len);
+        GridUnsafe.copyMemory(src, offset, null, ptr + pos, len);
 
         shift(len);
     }
 
     /** {@inheritDoc} */
     @Override protected void writeShortFast(short val) {
-        UNSAFE.putShort(ptr + pos, val);
+        long addr = ptr + pos;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putShortLE(addr, val);
+        else
+            GridUnsafe.putShort(addr, val);
     }
 
     /** {@inheritDoc} */
     @Override protected void writeCharFast(char val) {
-        UNSAFE.putChar(ptr + pos, val);
+        long addr = ptr + pos;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putCharLE(addr, val);
+        else
+            GridUnsafe.putChar(addr, val);
     }
 
     /** {@inheritDoc} */
     @Override protected void writeIntFast(int val) {
-        UNSAFE.putInt(ptr + pos, val);
+        long addr = ptr + pos;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putIntLE(addr, val);
+        else
+            GridUnsafe.putInt(addr, val);
     }
 
     /** {@inheritDoc} */
     @Override protected void writeLongFast(long val) {
-        UNSAFE.putLong(ptr + pos, val);
+        long addr = ptr + pos;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putLongLE(addr, val);
+        else
+            GridUnsafe.putLong(addr, val);
     }
 
     /** {@inheritDoc} */
@@ -131,61 +155,73 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteByte(byte val) {
-        UNSAFE.putByte(ptr + pos++, val);
+        GridUnsafe.putByte(ptr + pos++, val);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteShort(short val) {
-        if (!LITTLE_ENDIAN)
-            val = Short.reverseBytes(val);
+        long addr = ptr + pos;
 
-        UNSAFE.putShort(ptr + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putShortLE(addr, val);
+        else
+            GridUnsafe.putShort(addr, val);
 
         shift(2);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteShort(int pos, short val) {
-        if (!LITTLE_ENDIAN)
-            val = Short.reverseBytes(val);
+        long addr = ptr + pos;
 
-        UNSAFE.putShort(ptr + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putShortLE(addr, val);
+        else
+            GridUnsafe.putShort(addr, val);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteChar(char val) {
-        if (!LITTLE_ENDIAN)
-            val = Character.reverseBytes(val);
+        long addr = ptr + pos;
 
-        UNSAFE.putChar(ptr + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putCharLE(addr, val);
+        else
+            GridUnsafe.putChar(addr, val);
 
         shift(2);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteInt(int val) {
-        if (!LITTLE_ENDIAN)
-            val = Integer.reverseBytes(val);
+        long addr = ptr + pos;
 
-        UNSAFE.putInt(ptr + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putIntLE(addr, val);
+        else
+            GridUnsafe.putInt(addr, val);
 
         shift(4);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteInt(int pos, int val) {
-        if (!LITTLE_ENDIAN)
-            val = Integer.reverseBytes(val);
+        long addr = ptr + pos;
 
-        UNSAFE.putInt(ptr + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putIntLE(addr, val);
+        else
+            GridUnsafe.putInt(addr, val);
     }
 
     /** {@inheritDoc} */
     @Override public void unsafeWriteLong(long val) {
-        if (!LITTLE_ENDIAN)
-            val = Long.reverseBytes(val);
+        long addr = ptr + pos;
 
-        UNSAFE.putLong(ptr + pos, val);
+        if (BIG_ENDIAN)
+            GridUnsafe.putLongLE(addr, val);
+        else
+            GridUnsafe.putLong(addr, val);
 
         shift(8);
     }
@@ -197,7 +233,7 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
      * @return Pointer.
      */
     protected long allocate(int cap) {
-        return UNSAFE.allocateMemory(cap);
+        return GridUnsafe.allocateMemory(cap);
     }
 
     /**
@@ -208,7 +244,7 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
      * @return New pointer.
      */
     protected long reallocate(long ptr, int cap) {
-        return UNSAFE.reallocateMemory(ptr, cap);
+        return GridUnsafe.reallocateMemory(ptr, cap);
     }
 
     /**
@@ -217,6 +253,6 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
      * @param ptr Pointer.
      */
     protected void release(long ptr) {
-        UNSAFE.freeMemory(ptr);
+        GridUnsafe.freeMemory(ptr);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
index 10bc7e2..b567a03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
@@ -26,8 +26,8 @@ import org.apache.ignite.internal.direct.state.DirectMessageState;
 import org.apache.ignite.internal.direct.state.DirectMessageStateItem;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.direct.stream.v1.DirectByteBufferStreamImplV1;
-import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
 import org.apache.ignite.lang.IgniteOutClosure;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
index b265c6c..be17113 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
@@ -26,9 +26,9 @@ import org.apache.ignite.internal.direct.state.DirectMessageState;
 import org.apache.ignite.internal.direct.state.DirectMessageStateItem;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.direct.stream.v1.DirectByteBufferStreamImplV1;
-import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
 import org.apache.ignite.lang.IgniteOutClosure;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
index 67fa9e7..2187945 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
@@ -37,7 +37,6 @@ import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemTy
 import org.apache.ignite.plugin.extensions.communication.MessageFactory;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
-import sun.misc.Unsafe;
 import sun.nio.ch.DirectBuffer;
 
 /**
@@ -45,33 +44,6 @@ import sun.nio.ch.DirectBuffer;
  */
 public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
-    private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** */
-    private static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
-
-    /** */
-    private static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
-
-    /** */
-    private static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
-
-    /** */
-    private static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
-
-    /** */
-    private static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
-
-    /** */
-    private static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
-    /** */
-    private static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
-
-    /** */
     private static final byte[] BYTE_ARR_EMPTY = new byte[0];
 
     /** */
@@ -303,7 +275,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
             this.buf = buf;
 
             heapArr = buf.isDirect() ? null : buf.array();
-            baseOff = buf.isDirect() ? ((DirectBuffer)buf).address() : BYTE_ARR_OFF;
+            baseOff = buf.isDirect() ? ((DirectBuffer)buf).address() : GridUnsafe.BYTE_ARR_OFF;
         }
     }
 
@@ -324,7 +296,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putByte(heapArr, baseOff + pos, val);
+            GridUnsafe.putByte(heapArr, baseOff + pos, val);
 
             buf.position(pos + 1);
         }
@@ -337,7 +309,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putShort(heapArr, baseOff + pos, val);
+            GridUnsafe.putShort(heapArr, baseOff + pos, val);
 
             buf.position(pos + 2);
         }
@@ -350,7 +322,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putInt(heapArr, baseOff + pos, val);
+            GridUnsafe.putInt(heapArr, baseOff + pos, val);
 
             buf.position(pos + 4);
         }
@@ -363,7 +335,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putLong(heapArr, baseOff + pos, val);
+            GridUnsafe.putLong(heapArr, baseOff + pos, val);
 
             buf.position(pos + 8);
         }
@@ -378,7 +350,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putFloat(heapArr, baseOff + pos, val);
+            GridUnsafe.putFloat(heapArr, baseOff + pos, val);
 
             buf.position(pos + 4);
         }
@@ -391,7 +363,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putDouble(heapArr, baseOff + pos, val);
+            GridUnsafe.putDouble(heapArr, baseOff + pos, val);
 
             buf.position(pos + 8);
         }
@@ -404,7 +376,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putChar(heapArr, baseOff + pos, val);
+            GridUnsafe.putChar(heapArr, baseOff + pos, val);
 
             buf.position(pos + 2);
         }
@@ -417,7 +389,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         if (lastFinished) {
             int pos = buf.position();
 
-            UNSAFE.putBoolean(heapArr, baseOff + pos, val);
+            GridUnsafe.putBoolean(heapArr, baseOff + pos, val);
 
             buf.position(pos + 1);
         }
@@ -426,7 +398,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeByteArray(byte[] val) {
         if (val != null)
-            lastFinished = writeArray(val, BYTE_ARR_OFF, val.length, val.length);
+            lastFinished = writeArray(val, GridUnsafe.BYTE_ARR_OFF, val.length, val.length);
         else
             writeInt(-1);
     }
@@ -434,7 +406,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeByteArray(byte[] val, long off, int len) {
         if (val != null)
-            lastFinished = writeArray(val, BYTE_ARR_OFF + off, len, len);
+            lastFinished = writeArray(val, GridUnsafe.BYTE_ARR_OFF + off, len, len);
         else
             writeInt(-1);
     }
@@ -442,7 +414,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeShortArray(short[] val) {
         if (val != null)
-            lastFinished = writeArray(val, SHORT_ARR_OFF, val.length, val.length << 1);
+            lastFinished = writeArray(val, GridUnsafe.SHORT_ARR_OFF, val.length, val.length << 1);
         else
             writeInt(-1);
     }
@@ -450,7 +422,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeIntArray(int[] val) {
         if (val != null)
-            lastFinished = writeArray(val, INT_ARR_OFF, val.length, val.length << 2);
+            lastFinished = writeArray(val, GridUnsafe.INT_ARR_OFF, val.length, val.length << 2);
         else
             writeInt(-1);
     }
@@ -458,7 +430,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeLongArray(long[] val) {
         if (val != null)
-            lastFinished = writeArray(val, LONG_ARR_OFF, val.length, val.length << 3);
+            lastFinished = writeArray(val, GridUnsafe.LONG_ARR_OFF, val.length, val.length << 3);
         else
             writeInt(-1);
     }
@@ -466,7 +438,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeFloatArray(float[] val) {
         if (val != null)
-            lastFinished = writeArray(val, FLOAT_ARR_OFF, val.length, val.length << 2);
+            lastFinished = writeArray(val, GridUnsafe.FLOAT_ARR_OFF, val.length, val.length << 2);
         else
             writeInt(-1);
     }
@@ -474,7 +446,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeDoubleArray(double[] val) {
         if (val != null)
-            lastFinished = writeArray(val, DOUBLE_ARR_OFF, val.length, val.length << 3);
+            lastFinished = writeArray(val, GridUnsafe.DOUBLE_ARR_OFF, val.length, val.length << 3);
         else
             writeInt(-1);
     }
@@ -482,7 +454,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeCharArray(char[] val) {
         if (val != null)
-            lastFinished = writeArray(val, CHAR_ARR_OFF, val.length, val.length << 1);
+            lastFinished = writeArray(val, GridUnsafe.CHAR_ARR_OFF, val.length, val.length << 1);
         else
             writeInt(-1);
     }
@@ -490,7 +462,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /** {@inheritDoc} */
     @Override public void writeBooleanArray(boolean[] val) {
         if (val != null)
-            lastFinished = writeArray(val, BOOLEAN_ARR_OFF, val.length, val.length);
+            lastFinished = writeArray(val, GridUnsafe.BOOLEAN_ARR_OFF, val.length, val.length);
         else
             writeInt(-1);
     }
@@ -653,7 +625,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
 
             buf.position(pos + 1);
 
-            return UNSAFE.getByte(heapArr, baseOff + pos);
+            return GridUnsafe.getByte(heapArr, baseOff + pos);
         }
         else
             return 0;
@@ -668,7 +640,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
 
             buf.position(pos + 2);
 
-            return UNSAFE.getShort(heapArr, baseOff + pos);
+            return GridUnsafe.getShort(heapArr, baseOff + pos);
         }
         else
             return 0;
@@ -683,7 +655,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
 
             buf.position(pos + 4);
 
-            return UNSAFE.getInt(heapArr, baseOff + pos);
+            return GridUnsafe.getInt(heapArr, baseOff + pos);
         }
         else
             return 0;
@@ -698,7 +670,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
 
             buf.position(pos + 8);
 
-            return UNSAFE.getLong(heapArr, baseOff + pos);
+            return GridUnsafe.getLong(heapArr, baseOff + pos);
         }
         else
             return 0;
@@ -713,7 +685,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
 
             buf.position(pos + 4);
 
-            return UNSAFE.getFloat(heapArr, baseOff + pos);
+            return GridUnsafe.getFloat(heapArr, baseOff + pos);
         }
         else
             return 0;
@@ -728,7 +700,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
 
             buf.position(pos + 8);
 
-            return UNSAFE.getDouble(heapArr, baseOff + pos);
+            return GridUnsafe.getDouble(heapArr, baseOff + pos);
         }
         else
             return 0;
@@ -743,7 +715,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
 
             buf.position(pos + 2);
 
-            return UNSAFE.getChar(heapArr, baseOff + pos);
+            return GridUnsafe.getChar(heapArr, baseOff + pos);
         }
         else
             return 0;
@@ -758,7 +730,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
 
             buf.position(pos + 1);
 
-            return UNSAFE.getBoolean(heapArr, baseOff + pos);
+            return GridUnsafe.getBoolean(heapArr, baseOff + pos);
         }
         else
             return false;
@@ -766,42 +738,42 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
 
     /** {@inheritDoc} */
     @Override public byte[] readByteArray() {
-        return readArray(BYTE_ARR_CREATOR, 0, BYTE_ARR_OFF);
+        return readArray(BYTE_ARR_CREATOR, 0, GridUnsafe.BYTE_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public short[] readShortArray() {
-        return readArray(SHORT_ARR_CREATOR, 1, SHORT_ARR_OFF);
+        return readArray(SHORT_ARR_CREATOR, 1, GridUnsafe.SHORT_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public int[] readIntArray() {
-        return readArray(INT_ARR_CREATOR, 2, INT_ARR_OFF);
+        return readArray(INT_ARR_CREATOR, 2, GridUnsafe.INT_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public long[] readLongArray() {
-        return readArray(LONG_ARR_CREATOR, 3, LONG_ARR_OFF);
+        return readArray(LONG_ARR_CREATOR, 3, GridUnsafe.LONG_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public float[] readFloatArray() {
-        return readArray(FLOAT_ARR_CREATOR, 2, FLOAT_ARR_OFF);
+        return readArray(FLOAT_ARR_CREATOR, 2, GridUnsafe.FLOAT_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public double[] readDoubleArray() {
-        return readArray(DOUBLE_ARR_CREATOR, 3, DOUBLE_ARR_OFF);
+        return readArray(DOUBLE_ARR_CREATOR, 3, GridUnsafe.DOUBLE_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public char[] readCharArray() {
-        return readArray(CHAR_ARR_CREATOR, 1, CHAR_ARR_OFF);
+        return readArray(CHAR_ARR_CREATOR, 1, GridUnsafe.CHAR_ARR_OFF);
     }
 
     /** {@inheritDoc} */
     @Override public boolean[] readBooleanArray() {
-        return readArray(BOOLEAN_ARR_CREATOR, 0, BOOLEAN_ARR_OFF);
+        return readArray(BOOLEAN_ARR_CREATOR, 0, GridUnsafe.BOOLEAN_ARR_OFF);
     }
 
     /** {@inheritDoc} */
@@ -1037,7 +1009,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         int remaining = buf.remaining();
 
         if (toWrite <= remaining) {
-            UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, toWrite);
+            GridUnsafe.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, toWrite);
 
             pos += toWrite;
 
@@ -1048,7 +1020,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
             return true;
         }
         else {
-            UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining);
+            GridUnsafe.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining);
 
             pos += remaining;
 
@@ -1103,7 +1075,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
         lastFinished = toRead <= remaining;
 
         if (lastFinished) {
-            UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead);
+            GridUnsafe.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead);
 
             buf.position(pos + toRead);
 
@@ -1116,7 +1088,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
             return arr;
         }
         else {
-            UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining);
+            GridUnsafe.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining);
 
             buf.position(pos + remaining);
 
@@ -1360,7 +1332,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
     /**
      * Array creator.
      */
-    private static interface ArrayCreator<T> {
+    private interface ArrayCreator<T> {
         /**
          * @param len Array length or {@code -1} if array was not fully read.
          * @return New array.


[05/28] ignite git commit: IGNITE-2191 - Support classes with the same simple name for Binary marshaller - Fixes #398.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
index 3cfbcaa..2e60025 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
@@ -19,6 +19,10 @@ package org.apache.ignite.internal.processors.platform.cpp;
 
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.PlatformConfiguration;
@@ -87,8 +91,36 @@ public class PlatformCppConfigurationClosure extends PlatformAbstractConfigurati
             bCfg = new BinaryConfiguration();
 
             bCfg.setCompactFooter(false);
+            bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+            bCfg.setIdMapper(new BinaryBasicIdMapper(true));
 
             igniteCfg.setBinaryConfiguration(bCfg);
+
+            cppCfg0.warnings(Collections.singleton("Binary configuration is automatically initiated, " +
+                "note that binary name mapper is set to " + bCfg.getNameMapper()
+                + " and binary ID mapper is set to " + bCfg.getIdMapper()
+                + " (other nodes must have the same binary name and ID mapper types)."));
+        }
+        else {
+            BinaryNameMapper nameMapper = bCfg.getNameMapper();
+
+            if (nameMapper == null) {
+                bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+
+                cppCfg0.warnings(Collections.singleton("Binary name mapper is automatically set to " +
+                    bCfg.getNameMapper()
+                    + " (other nodes must have the same binary name mapper type)."));
+            }
+
+            BinaryIdMapper idMapper = bCfg.getIdMapper();
+
+            if (idMapper == null) {
+                bCfg.setIdMapper(new BinaryBasicIdMapper(true));
+
+                cppCfg0.warnings(Collections.singleton("Binary ID mapper is automatically set to " +
+                    bCfg.getIdMapper()
+                    + " (other nodes must have the same binary ID mapper type)."));
+            }
         }
 
         if (bCfg.isCompactFooter())

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index c068d59..6b9b441 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -19,6 +19,10 @@ package org.apache.ignite.internal.processors.platform.dotnet;
 
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.PlatformConfiguration;
@@ -90,7 +94,7 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
 
         igniteCfg.setPlatformConfiguration(dotNetCfg0);
 
-        // Check marshaller
+        // Check marshaller.
         Marshaller marsh = igniteCfg.getMarshaller();
 
         if (marsh == null) {
@@ -109,8 +113,36 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
             bCfg = new BinaryConfiguration();
 
             bCfg.setCompactFooter(false);
+            bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+            bCfg.setIdMapper(new BinaryBasicIdMapper(true));
 
             igniteCfg.setBinaryConfiguration(bCfg);
+
+            dotNetCfg0.warnings(Collections.singleton("Binary configuration is automatically initiated, " +
+                "note that binary name mapper is set to " + bCfg.getNameMapper()
+                + " and binary ID mapper is set to " + bCfg.getIdMapper()
+                + " (other nodes must have the same binary name and ID mapper types)."));
+        }
+        else {
+            BinaryNameMapper nameMapper = bCfg.getNameMapper();
+
+            if (nameMapper == null) {
+                bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+
+                dotNetCfg0.warnings(Collections.singleton("Binary name mapper is automatically set to " +
+                    bCfg.getNameMapper()
+                    + " (other nodes must have the same binary name mapper type)."));
+            }
+
+            BinaryIdMapper idMapper = bCfg.getIdMapper();
+
+            if (idMapper == null) {
+                bCfg.setIdMapper(new BinaryBasicIdMapper(true));
+
+                dotNetCfg0.warnings(Collections.singleton("Binary ID mapper is automatically set to " +
+                    bCfg.getIdMapper()
+                    + " (other nodes must have the same binary ID mapper type)."));
+            }
         }
 
         if (bCfg.isCompactFooter())

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java
new file mode 100644
index 0000000..1d6da2c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.binary;
+
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.internal.binary.test.GridBinaryTestClass1;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class BinaryBasicIdMapperSelfTest extends GridCommonAbstractTest {
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLowerCase() throws Exception {
+        BinaryBasicIdMapper mapper = new BinaryBasicIdMapper(true);
+
+        assertEquals(GridBinaryTestClass1.class.getName().toLowerCase().hashCode(),
+            mapper.typeId(GridBinaryTestClass1.class.getName()));
+        assertEquals((GridBinaryTestClass1.class.getName() + "$InnerClass").toLowerCase().hashCode(),
+            mapper.typeId(GridBinaryTestClass1.class.getName() + "$InnerClass"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDefaultCase() throws Exception {
+        BinaryBasicIdMapper mapper = new BinaryBasicIdMapper(false);
+
+        assertEquals(GridBinaryTestClass1.class.getName().hashCode(),
+            mapper.typeId(GridBinaryTestClass1.class.getName()));
+        assertEquals((GridBinaryTestClass1.class.getName() + "$InnerClass").hashCode(),
+            mapper.typeId(GridBinaryTestClass1.class.getName() + "$InnerClass"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java
new file mode 100644
index 0000000..70fb8e7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.internal.binary.test.GridBinaryTestClass1;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class BinaryBasicNameMapperSelfTest extends GridCommonAbstractTest {
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSimpleName() throws Exception {
+        BinaryBasicNameMapper mapper = new BinaryBasicNameMapper(true);
+
+        assertEquals("GridBinaryTestClass1", mapper.typeName(GridBinaryTestClass1.class.getName()));
+
+        assertEquals("InnerClass", mapper.typeName(GridBinaryTestClass1.class.getName() + "$InnerClass"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFullName() throws Exception {
+        BinaryBasicNameMapper mapper = new BinaryBasicNameMapper(false);
+
+        assertEquals(GridBinaryTestClass1.class.getName(), mapper.typeName(GridBinaryTestClass1.class.getName()));
+
+        assertEquals(GridBinaryTestClass1.class.getName() + "$InnerClass",
+            mapper.typeName(GridBinaryTestClass1.class.getName() + "$InnerClass"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java
new file mode 100644
index 0000000..7a56d9c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java
@@ -0,0 +1,231 @@
+/*
+ * 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.binary;
+
+import java.util.Arrays;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
+
+/**
+ * Tests a check of binary configuration consistency.
+ */
+public class BinaryConfigurationConsistencySelfTest extends GridCommonAbstractTest {
+    /** */
+    private BinaryConfiguration binaryCfg;
+
+    /** */
+    private boolean isClient;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setClientMode(isClient);
+
+        cfg.setMarshaller(new BinaryMarshaller());
+
+        cfg.setBinaryConfiguration(binaryCfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        isClient = false;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSkipCheckConsistencyFlagEnabled() throws Exception {
+        String backup = System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, "true");
+
+        try {
+            // Wrong usage of Ignite (done only in test purposes).
+            binaryCfg = null;
+
+            startGrid(0);
+
+            binaryCfg = new BinaryConfiguration();
+
+            startGrid(1);
+
+            isClient = true;
+            binaryCfg = customConfig(true);
+
+            startGrid(2);
+        }
+        finally {
+            if (backup != null)
+                System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, backup);
+            else
+                System.clearProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPositiveNullConfig() throws Exception {
+        binaryCfg = null;
+
+        startGrids(2);
+
+        isClient = true;
+
+        startGrid(2);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPositiveEmptyConfig() throws Exception {
+        binaryCfg = new BinaryConfiguration();
+
+        startGrids(2);
+
+        isClient = true;
+
+        startGrid(2);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPositiveCustomConfig() throws Exception {
+        binaryCfg = customConfig(false);
+
+        startGrids(2);
+
+        isClient = true;
+
+        startGrid(2);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNegativeNullEmptyConfigs() throws Exception {
+        checkNegative(null, new BinaryConfiguration());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNegativeEmptyNullConfigs() throws Exception {
+        checkNegative(new BinaryConfiguration(), null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNegativeEmptyCustomConfigs() throws Exception {
+        checkNegative(new BinaryConfiguration(), customConfig(false));
+    }
+
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNegativeCustomNullConfigs() throws Exception {
+        checkNegative(customConfig(false), null);
+    }
+
+    /**
+     * @param bCfg1 BinaryConfiguration 1.
+     * @param bCfg2 BinaryConfiguration 2.
+     * @throws Exception If failed.
+     */
+    private void checkNegative(final BinaryConfiguration bCfg1, BinaryConfiguration bCfg2) throws Exception {
+        binaryCfg = bCfg1;
+
+        startGrid(0);
+
+        binaryCfg = bCfg2;
+
+        GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                startGrid(1);
+
+                return null;
+            }
+        }, IgniteCheckedException.class, "");
+
+        isClient = true;
+
+        GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                startGrid(2);
+
+                return null;
+            }
+        }, IgniteCheckedException.class, "");
+    }
+
+    /**
+     * @return Custom BinaryConfiguration.
+     * @param compactFooter Compact footer.
+     */
+    private BinaryConfiguration customConfig(boolean compactFooter) {
+        BinaryConfiguration c = new BinaryConfiguration();
+
+        c.setIdMapper(new BinaryBasicIdMapper(true));
+        c.setSerializer(new BinarySerializer() {
+            @Override public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
+                // No-op.
+            }
+
+            @Override public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
+                // No-op.
+            }
+        });
+        c.setCompactFooter(compactFooter);
+
+        BinaryTypeConfiguration btc = new BinaryTypeConfiguration("org.MyClass");
+
+        btc.setIdMapper(BinaryContext.defaultIdMapper());
+        btc.setEnum(false);
+        btc.setSerializer(new BinarySerializer() {
+            @Override public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
+                // No-op.
+            }
+
+            @Override public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
+                // No-op.
+            }
+        });
+
+        c.setTypeConfigurations(Arrays.asList(btc));
+
+        return c;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
index e503e07..6bd9b65 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
@@ -221,10 +221,10 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
     private void checkNestedBuilder(boolean registered) throws Exception {
         startUp(registered);
 
-        BinaryObject obj = node1.binary().builder("EnumHolder").setField("val", EnumType.ONE).build();
+        BinaryObject obj = node1.binary().builder(EnumHolder.class.getName()).setField("val", EnumType.ONE).build();
 
-        assert node1.binary().type("EnumHolder") != null;
-        assert node1.binary().type("EnumType") != null;
+        assert node1.binary().type(EnumHolder.class.getName()) != null;
+        assert node1.binary().type(EnumType.class.getName()) != null;
 
         cacheBinary1.put(1, obj);
 
@@ -271,7 +271,7 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
     public void checkSimpleBuilder(boolean registered) throws Exception {
         startUp(registered);
 
-        BinaryObject binary = node1.binary().buildEnum(EnumType.class.getSimpleName(), EnumType.ONE.ordinal());
+        BinaryObject binary = node1.binary().buildEnum(EnumType.class.getName(), EnumType.ONE.ordinal());
 
         cacheBinary1.put(1, binary);
 
@@ -337,8 +337,8 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
     public void checkSimpleBuilderArray(boolean registered) throws Exception {
         startUp(registered);
 
-        BinaryObject binaryOne = node1.binary().buildEnum(EnumType.class.getSimpleName(), EnumType.ONE.ordinal());
-        BinaryObject binaryTwo = node1.binary().buildEnum(EnumType.class.getSimpleName(), EnumType.TWO.ordinal());
+        BinaryObject binaryOne = node1.binary().buildEnum(EnumType.class.getName(), EnumType.ONE.ordinal());
+        BinaryObject binaryTwo = node1.binary().buildEnum(EnumType.class.getName(), EnumType.TWO.ordinal());
 
         cacheBinary1.put(1, new BinaryObject[] { binaryOne, binaryTwo });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
index c347b9f..fa0f9a7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
@@ -17,12 +17,49 @@
 
 package org.apache.ignite.internal.binary;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.InetSocketAddress;
+import java.sql.Timestamp;
+import java.util.AbstractQueue;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Queue;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListSet;
 import junit.framework.Assert;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
 import org.apache.ignite.binary.BinaryCollectionFactory;
 import org.apache.ignite.binary.BinaryField;
 import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryMapFactory;
+import org.apache.ignite.binary.BinaryNameMapper;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
 import org.apache.ignite.binary.BinaryObjectException;
@@ -53,43 +90,9 @@ import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 import sun.misc.Unsafe;
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.InetSocketAddress;
-import java.sql.Timestamp;
-import java.util.AbstractQueue;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Queue;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentSkipListSet;
-
-import static org.apache.ignite.internal.binary.streams.BinaryMemoryAllocator.*;
-import static org.junit.Assert.*;
+import static org.apache.ignite.internal.binary.streams.BinaryMemoryAllocator.INSTANCE;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertNotEquals;
 
 /**
  * Binary marshaller tests.
@@ -1047,7 +1050,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
             }
         });
 
-        BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+        BinaryMarshaller marsh = binaryMarshaller(null, new BinaryIdMapper() {
             @Override public int typeId(String clsName) {
                 return 11111;
             }
@@ -1092,6 +1095,63 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testSimpleNameLowerCaseMappers() throws Exception {
+        BinaryTypeConfiguration innerClassType = new BinaryTypeConfiguration(InnerMappedObject.class.getName());
+        BinaryTypeConfiguration publicClassType = new BinaryTypeConfiguration(TestMappedObject.class.getName());
+        BinaryTypeConfiguration typeWithCustomMapper = new BinaryTypeConfiguration(CustomMappedObject2.class.getName());
+
+        typeWithCustomMapper.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 44444;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                assert typeId == 44444;
+
+                if ("val1".equals(fieldName))
+                    return 55555;
+                else if ("val2".equals(fieldName))
+                    return 66666;
+
+                assert false : "Unknown field: " + fieldName;
+
+                return 0;
+            }
+        });
+
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true),
+            Arrays.asList(innerClassType, publicClassType, typeWithCustomMapper));
+
+        InnerMappedObject innerObj = new InnerMappedObject(10, "str1");
+
+        BinaryObjectExImpl innerBo = marshal(innerObj, marsh);
+
+        assertEquals("InnerMappedObject".toLowerCase().hashCode(), innerBo.type().typeId());
+
+        assertEquals(10, innerBo.<CustomMappedObject1>deserialize().val1);
+        assertEquals("str1", innerBo.<CustomMappedObject1>deserialize().val2);
+
+        TestMappedObject publicObj = new TestMappedObject();
+
+        BinaryObjectExImpl publicBo = marshal(publicObj, marsh);
+
+        assertEquals("TestMappedObject".toLowerCase().hashCode(), publicBo.type().typeId());
+
+        CustomMappedObject2 obj2 = new CustomMappedObject2(20, "str2");
+
+        BinaryObjectExImpl po2 = marshal(obj2, marsh);
+
+        assertEquals(44444, po2.type().typeId());
+        assertEquals((Integer)20, po2.field(55555));
+        assertEquals("str2", po2.field(66666));
+
+        assertEquals(20, po2.<CustomMappedObject2>deserialize().val1);
+        assertEquals("str2", po2.<CustomMappedObject2>deserialize().val2);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testDynamicObject() throws Exception {
         BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
             new BinaryTypeConfiguration(DynamicObject.class.getName())
@@ -1299,7 +1359,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
-    public void testTypeNames() throws Exception {
+    public void testTypeNamesSimpleNameMapper() throws Exception {
         BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
 
         customType1.setIdMapper(new BinaryIdMapper() {
@@ -1336,7 +1396,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
             }
         });
 
-        BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass5");
+        BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass0");
 
         customType4.setIdMapper(new BinaryIdMapper() {
             @Override public int typeId(String clsName) {
@@ -1348,7 +1408,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
             }
         });
 
-        BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true),
+            Arrays.asList(
             new BinaryTypeConfiguration(Key.class.getName()),
             new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
             new BinaryTypeConfiguration("NonExistentClass4"),
@@ -1360,14 +1421,296 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryContext ctx = binaryContext(marsh);
 
+        // Full name hashCode.
         assertEquals("notconfiguredclass".hashCode(), ctx.typeId("NotConfiguredClass"));
-        assertEquals("key".hashCode(), ctx.typeId("Key"));
-        assertEquals("nonexistentclass3".hashCode(), ctx.typeId("NonExistentClass3"));
+        assertEquals("key".hashCode(), ctx.typeId(Key.class.getName()));
+        assertEquals("nonexistentclass3".hashCode(), ctx.typeId("org.gridgain.NonExistentClass3"));
         assertEquals("nonexistentclass4".hashCode(), ctx.typeId("NonExistentClass4"));
-        assertEquals(300, ctx.typeId(getClass().getSimpleName() + "$Value"));
-        assertEquals(400, ctx.typeId("NonExistentClass1"));
+        assertEquals(300, ctx.typeId(Value.class.getName()));
+        assertEquals(400, ctx.typeId("org.gridgain.NonExistentClass1"));
         assertEquals(500, ctx.typeId("NonExistentClass2"));
-        assertEquals("nonexistentclass5".hashCode(), ctx.typeId("NonExistentClass5"));
+
+        // BinaryIdMapper.typeId() contract.
+        assertEquals("nonexistentclass0".hashCode(), ctx.typeId("NonExistentClass0"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTypeNamesFullNameMappers() throws Exception {
+        BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
+
+        customType1.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 300;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("org.gridgain.NonExistentClass1");
+
+        customType2.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 400;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType3 = new BinaryTypeConfiguration("NonExistentClass2");
+
+        customType3.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 500;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass0");
+
+        customType4.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 0;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false),
+            Arrays.asList(
+                new BinaryTypeConfiguration(Key.class.getName()),
+                new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
+                new BinaryTypeConfiguration("NonExistentClass4"),
+                customType1,
+                customType2,
+                customType3,
+                customType4
+            ));
+
+        BinaryContext ctx = binaryContext(marsh);
+
+        // Full name hashCode.
+        assertEquals("NotConfiguredClass".hashCode(), ctx.typeId("NotConfiguredClass"));
+        assertEquals(Key.class.getName().hashCode(), ctx.typeId(Key.class.getName()));
+        assertEquals("org.gridgain.NonExistentClass3".hashCode(), ctx.typeId("org.gridgain.NonExistentClass3"));
+        assertEquals("NonExistentClass4".hashCode(), ctx.typeId("NonExistentClass4"));
+        assertEquals(300, ctx.typeId(Value.class.getName()));
+        assertEquals(400, ctx.typeId("org.gridgain.NonExistentClass1"));
+        assertEquals(500, ctx.typeId("NonExistentClass2"));
+
+        // BinaryIdMapper.typeId() contract.
+        assertEquals("nonexistentclass0".hashCode(), ctx.typeId("NonExistentClass0"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTypeNamesSimpleNameMappers() throws Exception {
+        BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
+
+        customType1.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 300;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("org.gridgain.NonExistentClass1");
+
+        customType2.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 400;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType3 = new BinaryTypeConfiguration("NonExistentClass2");
+
+        customType3.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 500;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass0");
+
+        customType4.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 0;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType5 = new BinaryTypeConfiguration(DateClass1.class.getName());
+
+        customType5.setNameMapper(new BinaryBasicNameMapper(false));
+        customType5.setIdMapper(new BinaryBasicIdMapper(false));
+
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true),
+            Arrays.asList(
+                new BinaryTypeConfiguration(Key.class.getName()),
+                new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
+                new BinaryTypeConfiguration("NonExistentClass4"),
+                customType1,
+                customType2,
+                customType3,
+                customType4,
+                customType5
+            ));
+
+        BinaryContext ctx = binaryContext(marsh);
+
+        assertEquals("notconfiguredclass".hashCode(), ctx.typeId("NotConfiguredClass"));
+        assertEquals("notconfiguredclass".hashCode(), ctx.typeId("org.blabla.NotConfiguredClass"));
+        assertEquals("key".hashCode(), ctx.typeId(Key.class.getName()));
+        assertEquals("nonexistentclass3".hashCode(), ctx.typeId("org.gridgain.NonExistentClass3"));
+        assertEquals("nonexistentclass4".hashCode(), ctx.typeId("NonExistentClass4"));
+
+        assertEquals(300, ctx.typeId(Value.class.getName()));
+        assertEquals(400, ctx.typeId("org.gridgain.NonExistentClass1"));
+        assertEquals(500, ctx.typeId("NonExistentClass2"));
+
+        assertEquals(DateClass1.class.getName().hashCode(), ctx.typeId(DateClass1.class.getName()));
+
+        // BinaryIdMapper.typeId() contract.
+        assertEquals("nonexistentclass0".hashCode(), ctx.typeId("NonExistentClass0"));
+    }
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTypeNamesCustomIdMapper() throws Exception {
+        BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
+
+        customType1.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 300;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("org.gridgain.NonExistentClass1");
+
+        customType2.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 400;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType3 = new BinaryTypeConfiguration("NonExistentClass2");
+
+        customType3.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 500;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass0");
+
+        customType4.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return 0;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        });
+
+        BinaryTypeConfiguration customType5 = new BinaryTypeConfiguration(DateClass1.class.getName());
+
+        customType5.setIdMapper(new BinaryBasicIdMapper(false));
+
+        BinaryTypeConfiguration customType6 = new BinaryTypeConfiguration(MyTestClass.class.getName());
+
+        customType6.setIdMapper(new BinaryBasicIdMapper(true));
+        customType6.setNameMapper(new BinaryBasicNameMapper(true));
+
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                if ("org.blabla.NotConfiguredSpecialClass".equals(clsName))
+                    return 0;
+                else if (Key.class.getName().equals(clsName))
+                    return 991;
+                else if ("org.gridgain.NonExistentClass3".equals(clsName))
+                    return 992;
+                else if ("NonExistentClass4".equals(clsName))
+                    return 993;
+
+                return 999;
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return 0;
+            }
+        }, Arrays.asList(
+            new BinaryTypeConfiguration(Key.class.getName()),
+            new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
+            new BinaryTypeConfiguration("NonExistentClass4"),
+            customType1,
+            customType2,
+            customType3,
+            customType4,
+            customType5,
+            customType6
+        ));
+
+        BinaryContext ctx = binaryContext(marsh);
+
+        assertEquals(999, ctx.typeId("NotConfiguredClass"));
+        assertEquals(999, ctx.typeId("org.blabla.NotConfiguredClass"));
+
+        // BinaryIdMapper.typeId() contract.
+        assertEquals("notconfiguredspecialclass".hashCode(), ctx.typeId("org.blabla.NotConfiguredSpecialClass"));
+
+        assertEquals(991, ctx.typeId(Key.class.getName()));
+        assertEquals(992, ctx.typeId("org.gridgain.NonExistentClass3"));
+        assertEquals(993, ctx.typeId("NonExistentClass4"));
+
+
+        // Custom types.
+        assertEquals(300, ctx.typeId(Value.class.getName()));
+        assertEquals(400, ctx.typeId("org.gridgain.NonExistentClass1"));
+        assertEquals(500, ctx.typeId("NonExistentClass2"));
+
+        // BinaryIdMapper.typeId() contract.
+        assertEquals("nonexistentclass0".hashCode(), ctx.typeId("NonExistentClass0"));
+
+        assertEquals(DateClass1.class.getName().hashCode(), ctx.typeId(DateClass1.class.getName()));
+        assertEquals("mytestclass".hashCode(), ctx.typeId(MyTestClass.class.getName()));
     }
 
     /**
@@ -1656,11 +1999,11 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject 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);
     }
 
     /**
@@ -1819,11 +2162,11 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject copy = copy(po, F.<String, Object>asMap("strArr", new String[]{"str1", "str2"}));
 
-        assertArrayEquals(new String[]{"str1", "str2"}, copy.<String[]>field("strArr"));
+        assertArrayEquals(new String[] {"str1", "str2"}, copy.<String[]>field("strArr"));
 
         SimpleObject obj0 = copy.deserialize();
 
-        assertArrayEquals(new String[]{"str1", "str2"}, obj0.strArr);
+        assertArrayEquals(new String[] {"str1", "str2"}, obj0.strArr);
     }
 
     /**
@@ -1887,7 +2230,7 @@ public class BinaryMarshallerSelfTest 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);
     }
 
     /**
@@ -1912,8 +2255,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         map.put("str", "str555");
         map.put("inner", newObj);
         map.put("s", (short)2323);
-        map.put("bArr", new byte[]{6, 7, 9});
-        map.put("b", (byte) 111);
+        map.put("bArr", new byte[] {6, 7, 9});
+        map.put("b", (byte)111);
 
         BinaryObject copy = copy(po, map);
 
@@ -1930,8 +2273,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         assertEquals("str555", obj0.str);
         assertEquals(newObj, obj0.inner);
         assertEquals((short)2323, obj0.s);
-        assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
-        assertEquals((byte) 111, obj0.b);
+        assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
+        assertEquals((byte)111, obj0.b);
     }
 
     /**
@@ -2190,8 +2533,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
-    public void testDuplicateName() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller();
+    public void testDuplicateNameSimpleNameMapper() throws Exception {
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true),
+            new BinaryBasicIdMapper(true), null, null);
 
         Test1.Job job1 = new Test1().new Job();
         Test2.Job job2 = new Test2().new Job();
@@ -2213,6 +2557,21 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testDuplicateNameFullNameMapper() throws Exception {
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false),
+            new BinaryBasicIdMapper(false), null, null);
+
+        Test1.Job job1 = new Test1().new Job();
+        Test2.Job job2 = new Test2().new Job();
+
+        marsh.marshal(job1);
+
+        marsh.marshal(job2);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testClass() throws Exception {
         BinaryMarshaller marsh = binaryMarshaller();
 
@@ -2288,13 +2647,13 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     public void testPredefinedTypeIds() throws Exception {
         BinaryMarshaller marsh = binaryMarshaller();
 
-        BinaryContext pCtx = binaryContext(marsh);
+        BinaryContext bCtx = binaryContext(marsh);
 
-        Field field = pCtx.getClass().getDeclaredField("predefinedTypeNames");
+        Field field = bCtx.getClass().getDeclaredField("predefinedTypeNames");
 
         field.setAccessible(true);
 
-        Map<String, Integer> map = (Map<String, Integer>)field.get(pCtx);
+        Map<String, Integer> map = (Map<String, Integer>)field.get(bCtx);
 
         assertTrue(map.size() > 0);
 
@@ -2304,10 +2663,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
             if (id == GridBinaryMarshaller.UNREGISTERED_TYPE_ID)
                 continue;
 
-            BinaryClassDescriptor desc = pCtx.descriptorForTypeId(false, entry.getValue(), null, false);
+            BinaryClassDescriptor desc = bCtx.descriptorForTypeId(false, entry.getValue(), null, false);
 
-            assertEquals(desc.typeId(), pCtx.typeId(desc.describedClass().getName()));
-            assertEquals(desc.typeId(), pCtx.typeId(pCtx.typeName(desc.describedClass().getName())));
+            assertEquals(desc.typeId(), bCtx.typeId(desc.describedClass().getName()));
         }
     }
 
@@ -2714,7 +3072,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
      */
     protected BinaryMarshaller binaryMarshaller()
         throws IgniteCheckedException {
-        return binaryMarshaller(null, null, null);
+        return binaryMarshaller(null, null, null, null);
     }
 
     /**
@@ -2722,15 +3080,15 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
      */
     protected BinaryMarshaller binaryMarshaller(Collection<BinaryTypeConfiguration> cfgs)
         throws IgniteCheckedException {
-        return binaryMarshaller(null, null, cfgs);
+        return binaryMarshaller(null, null, null, cfgs);
     }
 
     /**
      *
      */
-    protected BinaryMarshaller binaryMarshaller(BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
+    protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
         throws IgniteCheckedException {
-        return binaryMarshaller(mapper, null, cfgs);
+        return binaryMarshaller(nameMapper, mapper, null, cfgs);
     }
 
     /**
@@ -2738,13 +3096,14 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
      */
     protected BinaryMarshaller binaryMarshaller(BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs)
         throws IgniteCheckedException {
-        return binaryMarshaller(null, serializer, cfgs);
+        return binaryMarshaller(null, null, serializer, cfgs);
     }
 
     /**
      * @return Binary marshaller.
      */
     protected BinaryMarshaller binaryMarshaller(
+        BinaryNameMapper nameMapper,
         BinaryIdMapper mapper,
         BinarySerializer serializer,
         Collection<BinaryTypeConfiguration> cfgs
@@ -2753,6 +3112,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryConfiguration bCfg = new BinaryConfiguration();
 
+        bCfg.setNameMapper(nameMapper);
         bCfg.setIdMapper(mapper);
         bCfg.setSerializer(serializer);
         bCfg.setCompactFooter(compactFooter());
@@ -3657,6 +4017,18 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
     /**
      */
+    private static class InnerMappedObject extends CustomMappedObject1 {
+        /**
+         * @param val1 Val1
+         * @param val2 Val2
+         */
+        InnerMappedObject(int val1, String val2) {
+            super(val1, val2);
+        }
+    }
+
+    /**
+     */
     private static class CustomMappedObject2 {
         /** */
         private int val1;

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
index 572df88..06e1e93 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
@@ -1258,7 +1258,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
         CacheObjectBinaryProcessorImpl processor = (CacheObjectBinaryProcessorImpl)(
             (IgniteBinaryImpl)binaries()).processor();
 
-        return new BinaryObjectBuilderImpl(processor.binaryContext(), processor.typeId(aCls.getName()),
-            aCls.getSimpleName());
+        return new BinaryObjectBuilderImpl(processor.binaryContext(), processor.typeId(aCls.getName()), 
+            processor.binaryContext().userTypeName(aCls.getName()));
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
new file mode 100644
index 0000000..059703e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
@@ -0,0 +1,1149 @@
+/*
+ * 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.binary;
+
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import junit.framework.TestCase;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
+import org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses;
+import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import sun.misc.Unsafe;
+
+/**
+ * Binary builder test.
+ */
+@SuppressWarnings("ResultOfMethodCallIgnored")
+public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
+
+    /** */
+    protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
+
+    /** */
+    private static IgniteConfiguration cfg;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        BinaryTypeConfiguration customTypeCfg = new BinaryTypeConfiguration();
+
+        customTypeCfg.setTypeName(CustomIdMapper.class.getName());
+        customTypeCfg.setIdMapper(new BinaryIdMapper() {
+            @Override public int typeId(String clsName) {
+                return ~BinaryContext.defaultIdMapper().typeId(clsName);
+            }
+
+            @Override public int fieldId(int typeId, String fieldName) {
+                return typeId + ~BinaryContext.defaultIdMapper().fieldId(typeId, fieldName);
+            }
+        });
+
+        BinaryConfiguration bCfg = new BinaryConfiguration();
+
+        bCfg.setCompactFooter(compactFooter());
+
+        bCfg.setTypeConfigurations(Arrays.asList(
+            new BinaryTypeConfiguration(Key.class.getName()),
+            new BinaryTypeConfiguration(Value.class.getName()),
+            new BinaryTypeConfiguration("org.gridgain.grid.internal.util.binary.mutabletest.*"),
+            customTypeCfg));
+
+        bCfg.setIdMapper(new BinaryBasicIdMapper(false));
+        bCfg.setNameMapper(new BinaryBasicNameMapper(false));
+
+        cfg.setBinaryConfiguration(bCfg);
+
+        cfg.setMarshaller(new BinaryMarshaller());
+
+        this.cfg = cfg;
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrids(1);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @return Whether to use compact footer.
+     */
+    protected boolean compactFooter() {
+        return true;
+    }
+
+    /**
+     *
+     */
+    public void testAllFieldsSerialization() {
+        GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
+        obj.setDefaultData();
+        obj.enumArr = null;
+
+        GridBinaryTestClasses.TestObjectAllTypes deserialized = builder(toBinary(obj)).build().deserialize();
+
+        GridTestUtils.deepEquals(obj, deserialized);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNullField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(42);
+
+        builder.setField("objField", (Object)null);
+
+        builder.setField("otherField", "value");
+
+        BinaryObject obj = builder.build();
+
+        assertNull(obj.field("objField"));
+        assertEquals("value", obj.field("otherField"));
+        assertEquals(42, obj.hashCode());
+
+        builder = builder(obj);
+
+        builder.setField("objField", "value");
+        builder.setField("otherField", (Object)null);
+
+        obj = builder.build();
+
+        assertNull(obj.field("otherField"));
+        assertEquals("value", obj.field("objField"));
+        assertEquals(42, obj.hashCode());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testByteField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("byteField", (byte)1);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals((byte) 1, po.<Byte>field("byteField").byteValue());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testShortField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("shortField", (short)1);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals((short)1, po.<Short>field("shortField").shortValue());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testIntField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("intField", 1);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals(1, po.<Integer>field("intField").intValue());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLongField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("longField", 1L);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals(1L, po.<Long>field("longField").longValue());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFloatField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("floatField", 1.0f);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals(1.0f, po.<Float>field("floatField").floatValue(), 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDoubleField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("doubleField", 1.0d);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals(1.0d, po.<Double>field("doubleField").doubleValue(), 0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCharField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("charField", (char)1);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals((char)1, po.<Character>field("charField").charValue());
+    }
+
+    /**
+     * @return Expected hash code.
+     * @param fullName Full name of type.
+     */
+    private int expectedHashCode(String fullName) {
+        BinaryIdMapper idMapper = cfg.getBinaryConfiguration().getIdMapper();
+        BinaryNameMapper nameMapper = cfg.getBinaryConfiguration().getNameMapper();
+
+        if (idMapper == null)
+            idMapper = BinaryContext.defaultIdMapper();
+
+        if (nameMapper == null)
+            nameMapper = BinaryContext.defaultNameMapper();
+
+        return idMapper.typeId(nameMapper.typeName(fullName));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBooleanField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("booleanField", true);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(po.<Boolean>field("booleanField"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDecimalField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("decimalField", BigDecimal.TEN);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals(BigDecimal.TEN, po.<BigDecimal>field("decimalField"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testStringField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("stringField", "str");
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals("str", po.<String>field("stringField"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDateField() throws Exception {
+        Date date = new Date();
+
+        assertEquals(date, builder("C").setField("d", date).build().<Date>field("d"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTimestampField() throws Exception {
+        Timestamp ts = new Timestamp(new Date().getTime());
+        ts.setNanos(1000);
+
+        assertEquals(ts, builder("C").setField("t", ts).build().<Timestamp>field("t"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testUuidField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        UUID uuid = UUID.randomUUID();
+
+        builder.setField("uuidField", uuid);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals(uuid, po.<UUID>field("uuidField"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testByteArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("byteArrayField", new byte[] {1, 2, 3});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(Arrays.equals(new byte[] {1, 2, 3}, po.<byte[]>field("byteArrayField")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testShortArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("shortArrayField", new short[] {1, 2, 3});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(Arrays.equals(new short[] {1, 2, 3}, po.<short[]>field("shortArrayField")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testIntArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("intArrayField", new int[] {1, 2, 3});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("intArrayField")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLongArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("longArrayField", new long[] {1, 2, 3});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(Arrays.equals(new long[] {1, 2, 3}, po.<long[]>field("longArrayField")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFloatArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("floatArrayField", new float[] {1, 2, 3});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(Arrays.equals(new float[] {1, 2, 3}, po.<float[]>field("floatArrayField")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDoubleArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("doubleArrayField", new double[] {1, 2, 3});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(Arrays.equals(new double[] {1, 2, 3}, po.<double[]>field("doubleArrayField")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCharArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("charArrayField", new char[] {1, 2, 3});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(Arrays.equals(new char[] {1, 2, 3}, po.<char[]>field("charArrayField")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBooleanArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("booleanArrayField", new boolean[] {true, false});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        boolean[] arr = po.field("booleanArrayField");
+
+        assertEquals(2, arr.length);
+
+        assertTrue(arr[0]);
+        assertFalse(arr[1]);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDecimalArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("decimalArrayField", new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(Arrays.equals(new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN}, po.<String[]>field("decimalArrayField")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testStringArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("stringArrayField", new String[] {"str1", "str2", "str3"});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(Arrays.equals(new String[] {"str1", "str2", "str3"}, po.<String[]>field("stringArrayField")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDateArrayField() throws Exception {
+        Date date1 = new Date();
+        Date date2 = new Date(date1.getTime() + 1000);
+
+        Date[] dateArr = new Date[] { date1, date2 };
+
+        assertTrue(Arrays.equals(dateArr, builder("C").setField("da", dateArr).build().<Date[]>field("da")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTimestampArrayField() throws Exception {
+        Timestamp ts1 = new Timestamp(new Date().getTime());
+        Timestamp ts2 = new Timestamp(new Date().getTime() + 1000);
+
+        ts1.setNanos(1000);
+        ts2.setNanos(2000);
+
+        Timestamp[] tsArr = new Timestamp[] { ts1, ts2 };
+
+        assertTrue(Arrays.equals(tsArr, builder("C").setField("ta", tsArr).build().<Timestamp[]>field("ta")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testUuidArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID()};
+
+        builder.setField("uuidArrayField", arr);
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertTrue(Arrays.equals(arr, po.<UUID[]>field("uuidArrayField")));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testObjectField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("objectField", new Value(1));
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals(1, po.<BinaryObject>field("objectField").<Value>deserialize().i);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testObjectArrayField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("objectArrayField", new Value[] {new Value(1), new Value(2)});
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        Object[] arr = po.field("objectArrayField");
+
+        assertEquals(2, arr.length);
+
+        assertEquals(1, ((BinaryObject)arr[0]).<Value>deserialize().i);
+        assertEquals(2, ((BinaryObject)arr[1]).<Value>deserialize().i);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCollectionField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("collectionField", Arrays.asList(new Value(1), new Value(2)));
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        List<BinaryObject> list = po.field("collectionField");
+
+        assertEquals(2, list.size());
+
+        assertEquals(1, list.get(0).<Value>deserialize().i);
+        assertEquals(2, list.get(1).<Value>deserialize().i);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMapField() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("mapField", F.asMap(new Key(1), new Value(1), new Key(2), new Value(2)));
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        Map<BinaryObject, BinaryObject> map = po.field("mapField");
+
+        assertEquals(2, map.size());
+
+        for (Map.Entry<BinaryObject, BinaryObject> e : map.entrySet())
+            assertEquals(e.getKey().<Key>deserialize().i, e.getValue().<Value>deserialize().i);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSeveralFields() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("i", 111);
+        builder.setField("f", 111.111f);
+        builder.setField("iArr", new int[] {1, 2, 3});
+        builder.setField("obj", new Key(1));
+        builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
+
+        BinaryObject po = builder.build();
+
+        assertEquals(expectedHashCode("Class"), po.type().typeId());
+        assertEquals(100, po.hashCode());
+
+        assertEquals(111, po.<Integer>field("i").intValue());
+        assertEquals(111.111f, po.<Float>field("f").floatValue(), 0);
+        assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("iArr")));
+        assertEquals(1, po.<BinaryObject>field("obj").<Key>deserialize().i);
+
+        List<BinaryObject> list = po.field("col");
+
+        assertEquals(2, list.size());
+
+        assertEquals(1, list.get(0).<Value>deserialize().i);
+        assertEquals(2, list.get(1).<Value>deserialize().i);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOffheapBinary() throws Exception {
+        BinaryObjectBuilder builder = builder("Class");
+
+        builder.hashCode(100);
+
+        builder.setField("i", 111);
+        builder.setField("f", 111.111f);
+        builder.setField("iArr", new int[] {1, 2, 3});
+        builder.setField("obj", new Key(1));
+        builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
+
+        BinaryObject po = builder.build();
+
+        byte[] arr = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).marshal(po);
+
+        long ptr = UNSAFE.allocateMemory(arr.length + 5);
+
+        try {
+            long ptr0 = ptr;
+
+            UNSAFE.putBoolean(null, ptr0++, false);
+
+            UNSAFE.putInt(ptr0, arr.length);
+
+            UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr0 + 4, arr.length);
+
+            BinaryObject offheapObj = (BinaryObject)
+                ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).unmarshal(ptr, false);
+
+            assertEquals(BinaryObjectOffheapImpl.class, offheapObj.getClass());
+
+            assertEquals(expectedHashCode("Class"), offheapObj.type().typeId());
+            assertEquals(100, offheapObj.hashCode());
+
+            assertEquals(111, offheapObj.<Integer>field("i").intValue());
+            assertEquals(111.111f, offheapObj.<Float>field("f").floatValue(), 0);
+            assertTrue(Arrays.equals(new int[] {1, 2, 3}, offheapObj.<int[]>field("iArr")));
+            assertEquals(1, offheapObj.<BinaryObject>field("obj").<Key>deserialize().i);
+
+            List<BinaryObject> list = offheapObj.field("col");
+
+            assertEquals(2, list.size());
+
+            assertEquals(1, list.get(0).<Value>deserialize().i);
+            assertEquals(2, list.get(1).<Value>deserialize().i);
+
+            assertEquals(po, offheapObj);
+            assertEquals(offheapObj, po);
+        }
+        finally {
+            UNSAFE.freeMemory(ptr);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBuildAndDeserialize() throws Exception {
+        BinaryObjectBuilder builder = builder(Value.class.getName());
+
+        builder.hashCode(100);
+
+        builder.setField("i", 1);
+
+        BinaryObject bo = builder.build();
+
+        assertEquals(expectedHashCode(Value.class.getName()), bo.type().typeId());
+        assertEquals(100, bo.hashCode());
+
+        assertEquals(1, bo.<Value>deserialize().i);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMetaData2() throws Exception {
+        BinaryObjectBuilder builder = builder("org.test.MetaTest2");
+
+        builder.setField("objectField", "a", Object.class);
+
+        BinaryObject bo = builder.build();
+
+        BinaryType meta = bo.type();
+
+        assertEquals(expectedTypeName("org.test.MetaTest2"), meta.typeName());
+        assertEquals("Object", meta.fieldTypeName("objectField"));
+    }
+
+    /**
+     * @param fullClsName Class name.
+     * @return Expected type name according to configuration.
+     */
+    private String expectedTypeName(String fullClsName) {
+        BinaryNameMapper mapper = cfg.getBinaryConfiguration().getNameMapper();
+
+        if (mapper == null)
+            mapper = BinaryContext.defaultNameMapper();
+
+        return mapper.typeName(fullClsName);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMetaData() throws Exception {
+        BinaryObjectBuilder builder = builder("org.test.MetaTest");
+
+        builder.hashCode(100);
+
+        builder.setField("intField", 1);
+        builder.setField("byteArrayField", new byte[] {1, 2, 3});
+
+        BinaryObject po = builder.build();
+
+        BinaryType meta = po.type();
+
+        assertEquals(expectedTypeName("org.test.MetaTest"), meta.typeName());
+
+        Collection<String> fields = meta.fieldNames();
+
+        assertEquals(2, fields.size());
+
+        assertTrue(fields.contains("intField"));
+        assertTrue(fields.contains("byteArrayField"));
+
+        assertEquals("int", meta.fieldTypeName("intField"));
+        assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
+
+        builder = builder("org.test.MetaTest");
+
+        builder.hashCode(100);
+
+        builder.setField("intField", 2);
+        builder.setField("uuidField", UUID.randomUUID());
+
+        po = builder.build();
+
+        meta = po.type();
+
+        assertEquals(expectedTypeName("org.test.MetaTest"), meta.typeName());
+
+        fields = meta.fieldNames();
+
+        assertEquals(3, fields.size());
+
+        assertTrue(fields.contains("intField"));
+        assertTrue(fields.contains("byteArrayField"));
+        assertTrue(fields.contains("uuidField"));
+
+        assertEquals("int", meta.fieldTypeName("intField"));
+        assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
+        assertEquals("UUID", meta.fieldTypeName("uuidField"));
+    }
+
+    /**
+     *
+     */
+    public void testGetFromCopiedObj() {
+        BinaryObject objStr = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName()).setField("str", "aaa").build();
+
+        BinaryObjectBuilderImpl builder = builder(objStr);
+        assertEquals("aaa", builder.getField("str"));
+
+        builder.setField("str", "bbb");
+        assertEquals("bbb", builder.getField("str"));
+
+        assertNull(builder.getField("i_"));
+        TestCase.assertEquals("bbb", builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
+    }
+
+    /**
+     *
+     */
+    @SuppressWarnings("unchecked")
+    public void testCopyFromInnerObjects() {
+        ArrayList<Object> list = new ArrayList<>();
+        list.add(new GridBinaryTestClasses.TestObjectAllTypes());
+        list.add(list.get(0));
+
+        GridBinaryTestClasses.TestObjectContainer c = new GridBinaryTestClasses.TestObjectContainer(list);
+
+        BinaryObjectBuilderImpl builder = builder(toBinary(c));
+        builder.<List>getField("foo").add("!!!");
+
+        BinaryObject res = builder.build();
+
+        GridBinaryTestClasses.TestObjectContainer deserialized = res.deserialize();
+
+        List deserializedList = (List)deserialized.foo;
+
+        assertSame(deserializedList.get(0), deserializedList.get(1));
+        assertEquals("!!!", deserializedList.get(2));
+        assertTrue(deserializedList.get(0) instanceof GridBinaryTestClasses.TestObjectAllTypes);
+    }
+
+    /**
+     *
+     */
+    public void testSetBinaryObject() {
+        // Prepare marshaller context.
+        CacheObjectBinaryProcessorImpl proc = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects());
+
+        proc.marshal(new GridBinaryTestClasses.TestObjectContainer());
+        proc.marshal(new GridBinaryTestClasses.TestObjectAllTypes());
+
+        // Actual test.
+        BinaryObject binaryObj = builder(GridBinaryTestClasses.TestObjectContainer.class.getName())
+            .setField("foo", toBinary(new GridBinaryTestClasses.TestObjectAllTypes()))
+            .build();
+
+        assertTrue(binaryObj.<GridBinaryTestClasses.TestObjectContainer>deserialize().foo instanceof
+            GridBinaryTestClasses.TestObjectAllTypes);
+    }
+
+    /**
+     *
+     */
+    public void testPlainBinaryObjectCopyFrom() {
+        GridBinaryTestClasses.TestObjectPlainBinary obj = new GridBinaryTestClasses.TestObjectPlainBinary(toBinary(new GridBinaryTestClasses.TestObjectAllTypes()));
+
+        BinaryObjectBuilderImpl builder = builder(toBinary(obj));
+        assertTrue(builder.getField("plainBinary") instanceof BinaryObject);
+
+        GridBinaryTestClasses.TestObjectPlainBinary deserialized = builder.build().deserialize();
+        assertTrue(deserialized.plainBinary != null);
+    }
+
+    /**
+     *
+     */
+    public void testRemoveFromNewObject() {
+        BinaryObjectBuilder builder = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName());
+
+        builder.setField("str", "a");
+
+        builder.removeField("str");
+
+        TestCase.assertNull(builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
+    }
+
+    /**
+     *
+     */
+    public void testRemoveFromExistingObject() {
+        GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
+        obj.setDefaultData();
+        obj.enumArr = null;
+
+        BinaryObjectBuilder builder = builder(toBinary(obj));
+
+        builder.removeField("str");
+
+        BinaryObject binary = builder.build();
+
+        GridBinaryTestClasses.TestObjectAllTypes deserialzied = binary.deserialize();
+
+        assertNull(deserialzied.str);
+    }
+
+    /**
+     *
+     */
+    public void testRemoveFromExistingObjectAfterGet() {
+        GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
+        obj.setDefaultData();
+        obj.enumArr = null;
+
+        BinaryObjectBuilderImpl builder = builder(toBinary(obj));
+
+        builder.getField("i_");
+
+        builder.removeField("str");
+
+        TestCase.assertNull(builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
+    }
+
+    /**
+     * @throws IgniteCheckedException If any error occurs.
+     */
+    public void testDontBrokeCyclicDependency() throws IgniteCheckedException {
+        GridBinaryTestClasses.TestObjectOuter outer = new GridBinaryTestClasses.TestObjectOuter();
+        outer.inner = new GridBinaryTestClasses.TestObjectInner();
+        outer.inner.outer = outer;
+        outer.foo = "a";
+
+        BinaryObjectBuilder builder = builder(toBinary(outer));
+
+        builder.setField("foo", "b");
+
+        GridBinaryTestClasses.TestObjectOuter res = builder.build().deserialize();
+
+        assertEquals("b", res.foo);
+        assertSame(res, res.inner.outer);
+    }
+
+    /**
+     * @return Binaries.
+     */
+    private IgniteBinary binaries() {
+        return grid(0).binary();
+    }
+
+    /**
+     * @param obj Object.
+     * @return Binary object.
+     */
+    private BinaryObject toBinary(Object obj) {
+        return binaries().toBinary(obj);
+    }
+
+    /**
+     * @return Builder.
+     */
+    private BinaryObjectBuilder builder(String clsName) {
+        return binaries().builder(clsName);
+    }
+
+    /**
+     * @return Builder.
+     */
+    private BinaryObjectBuilderImpl builder(BinaryObject obj) {
+        return (BinaryObjectBuilderImpl)binaries().builder(obj);
+    }
+
+    /**
+     *
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class CustomIdMapper {
+        /** */
+        private String str = "a";
+
+        /** */
+        private int i = 10;
+    }
+
+    /**
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class Key {
+        /** */
+        private int i;
+
+        /**
+         */
+        private Key() {
+            // No-op.
+        }
+
+        /**
+         * @param i Index.
+         */
+        private Key(int i) {
+            this.i = i;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            Key key = (Key)o;
+
+            return i == key.i;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return i;
+        }
+    }
+
+    /**
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class Value {
+        /** */
+        private int i;
+
+        /**
+         */
+        private Value() {
+            // No-op.
+        }
+
+        /**
+         * @param i Index.
+         */
+        private Value(int i) {
+            this.i = i;
+        }
+    }
+}


[03/28] ignite git commit: IGNITE-2191 - Support classes with the same simple name for Binary marshaller - Fixes #398.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java
new file mode 100644
index 0000000..041238f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java
@@ -0,0 +1,389 @@
+/*
+ * 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.binary;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Binary meta data test.
+ */
+public class GridDefaultBinaryMappersBinaryMetaDataSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static IgniteConfiguration cfg;
+
+    /** */
+    private static int idx;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        BinaryConfiguration bCfg = new BinaryConfiguration();
+
+        bCfg.setNameMapper(new BinaryBasicNameMapper(false));
+        bCfg.setIdMapper(new BinaryBasicIdMapper(false));
+
+        bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
+
+        cfg.setBinaryConfiguration(bCfg);
+
+        cfg.setMarshaller(new BinaryMarshaller());
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        cfg.setCacheConfiguration(ccfg);
+
+        GridDefaultBinaryMappersBinaryMetaDataSelfTest.cfg = cfg;
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        idx = 0;
+
+        startGrid();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopGrid();
+    }
+
+    /**
+     * @return Binaries API.
+     */
+    protected IgniteBinary binaries() {
+        return grid().binary();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testGetAll() throws Exception {
+        binaries().toBinary(new TestObject2());
+
+        Collection<BinaryType> metas = binaries().types();
+
+        assertEquals(2, metas.size());
+
+        for (BinaryType meta : metas) {
+            Collection<String> fields;
+
+            if (expectedTypeName(TestObject1.class.getName()).equals(meta.typeName())) {
+                fields = meta.fieldNames();
+
+                assertEquals(7, fields.size());
+
+                assertTrue(fields.contains("intVal"));
+                assertTrue(fields.contains("strVal"));
+                assertTrue(fields.contains("arrVal"));
+                assertTrue(fields.contains("obj1Val"));
+                assertTrue(fields.contains("obj2Val"));
+                assertTrue(fields.contains("decVal"));
+                assertTrue(fields.contains("decArrVal"));
+
+                assertEquals("int", meta.fieldTypeName("intVal"));
+                assertEquals("String", meta.fieldTypeName("strVal"));
+                assertEquals("byte[]", meta.fieldTypeName("arrVal"));
+                assertEquals("Object", meta.fieldTypeName("obj1Val"));
+                assertEquals("Object", meta.fieldTypeName("obj2Val"));
+                assertEquals("decimal", meta.fieldTypeName("decVal"));
+                assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+            }
+            else if (expectedTypeName(TestObject2.class.getName()).equals(meta.typeName())) {
+                fields = meta.fieldNames();
+
+                assertEquals(7, fields.size());
+
+                assertTrue(fields.contains("boolVal"));
+                assertTrue(fields.contains("dateVal"));
+                assertTrue(fields.contains("uuidArrVal"));
+                assertTrue(fields.contains("objVal"));
+                assertTrue(fields.contains("mapVal"));
+                assertTrue(fields.contains("decVal"));
+                assertTrue(fields.contains("decArrVal"));
+
+                assertEquals("boolean", meta.fieldTypeName("boolVal"));
+                assertEquals("Date", meta.fieldTypeName("dateVal"));
+                assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
+                assertEquals("Object", meta.fieldTypeName("objVal"));
+                assertEquals("Map", meta.fieldTypeName("mapVal"));
+                assertEquals("decimal", meta.fieldTypeName("decVal"));
+                assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+            }
+            else
+                assert false : meta.typeName();
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNoConfiguration() throws Exception {
+        binaries().toBinary(new TestObject3());
+
+        assertNotNull(binaries().type(TestObject3.class));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testReflection() throws Exception {
+        BinaryType meta = binaries().type(TestObject1.class);
+
+        assertNotNull(meta);
+
+        assertEquals(expectedTypeName(TestObject1.class.getName()), meta.typeName());
+
+        Collection<String> fields = meta.fieldNames();
+
+        assertEquals(7, fields.size());
+
+        assertTrue(fields.contains("intVal"));
+        assertTrue(fields.contains("strVal"));
+        assertTrue(fields.contains("arrVal"));
+        assertTrue(fields.contains("obj1Val"));
+        assertTrue(fields.contains("obj2Val"));
+        assertTrue(fields.contains("decVal"));
+        assertTrue(fields.contains("decArrVal"));
+
+        assertEquals("int", meta.fieldTypeName("intVal"));
+        assertEquals("String", meta.fieldTypeName("strVal"));
+        assertEquals("byte[]", meta.fieldTypeName("arrVal"));
+        assertEquals("Object", meta.fieldTypeName("obj1Val"));
+        assertEquals("Object", meta.fieldTypeName("obj2Val"));
+        assertEquals("decimal", meta.fieldTypeName("decVal"));
+        assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+    }
+
+    /**
+     * @param clsName Class name.
+     * @return Type name.
+     */
+    private String expectedTypeName(String clsName) {
+        BinaryNameMapper mapper = cfg.getBinaryConfiguration().getNameMapper();
+
+        if (mapper == null)
+            mapper = BinaryContext.defaultNameMapper();
+
+        return mapper.typeName(clsName);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBinaryMarshalAware() throws Exception {
+        binaries().toBinary(new TestObject2());
+
+        BinaryType meta = binaries().type(TestObject2.class);
+
+        assertNotNull(meta);
+
+        assertEquals(expectedTypeName(TestObject2.class.getName()), meta.typeName());
+
+        Collection<String> fields = meta.fieldNames();
+
+        assertEquals(7, fields.size());
+
+        assertTrue(fields.contains("boolVal"));
+        assertTrue(fields.contains("dateVal"));
+        assertTrue(fields.contains("uuidArrVal"));
+        assertTrue(fields.contains("objVal"));
+        assertTrue(fields.contains("mapVal"));
+        assertTrue(fields.contains("decVal"));
+        assertTrue(fields.contains("decArrVal"));
+
+        assertEquals("boolean", meta.fieldTypeName("boolVal"));
+        assertEquals("Date", meta.fieldTypeName("dateVal"));
+        assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
+        assertEquals("Object", meta.fieldTypeName("objVal"));
+        assertEquals("Map", meta.fieldTypeName("mapVal"));
+        assertEquals("decimal", meta.fieldTypeName("decVal"));
+        assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMerge() throws Exception {
+        binaries().toBinary(new TestObject2());
+
+        idx = 1;
+
+        binaries().toBinary(new TestObject2());
+
+        BinaryType meta = binaries().type(TestObject2.class);
+
+        assertNotNull(meta);
+
+        assertEquals(expectedTypeName(TestObject2.class.getName()), meta.typeName());
+
+        Collection<String> fields = meta.fieldNames();
+
+        assertEquals(9, fields.size());
+
+        assertTrue(fields.contains("boolVal"));
+        assertTrue(fields.contains("dateVal"));
+        assertTrue(fields.contains("uuidArrVal"));
+        assertTrue(fields.contains("objVal"));
+        assertTrue(fields.contains("mapVal"));
+        assertTrue(fields.contains("charVal"));
+        assertTrue(fields.contains("colVal"));
+        assertTrue(fields.contains("decVal"));
+        assertTrue(fields.contains("decArrVal"));
+
+        assertEquals("boolean", meta.fieldTypeName("boolVal"));
+        assertEquals("Date", meta.fieldTypeName("dateVal"));
+        assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
+        assertEquals("Object", meta.fieldTypeName("objVal"));
+        assertEquals("Map", meta.fieldTypeName("mapVal"));
+        assertEquals("char", meta.fieldTypeName("charVal"));
+        assertEquals("Collection", meta.fieldTypeName("colVal"));
+        assertEquals("decimal", meta.fieldTypeName("decVal"));
+        assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSerializedObject() throws Exception {
+        TestObject1 obj = new TestObject1();
+
+        obj.intVal = 10;
+        obj.strVal = "str";
+        obj.arrVal = new byte[] {2, 4, 6};
+        obj.obj1Val = null;
+        obj.obj2Val = new TestObject2();
+        obj.decVal = BigDecimal.ZERO;
+        obj.decArrVal = new BigDecimal[] { BigDecimal.ONE };
+
+        BinaryObject po = binaries().toBinary(obj);
+
+        info(po.toString());
+
+        BinaryType meta = po.type();
+
+        assertNotNull(meta);
+
+        assertEquals(expectedTypeName(TestObject1.class.getName()), meta.typeName());
+
+        Collection<String> fields = meta.fieldNames();
+
+        assertEquals(7, fields.size());
+
+        assertTrue(fields.contains("intVal"));
+        assertTrue(fields.contains("strVal"));
+        assertTrue(fields.contains("arrVal"));
+        assertTrue(fields.contains("obj1Val"));
+        assertTrue(fields.contains("obj2Val"));
+        assertTrue(fields.contains("decVal"));
+        assertTrue(fields.contains("decArrVal"));
+
+        assertEquals("int", meta.fieldTypeName("intVal"));
+        assertEquals("String", meta.fieldTypeName("strVal"));
+        assertEquals("byte[]", meta.fieldTypeName("arrVal"));
+        assertEquals("Object", meta.fieldTypeName("obj1Val"));
+        assertEquals("Object", meta.fieldTypeName("obj2Val"));
+        assertEquals("decimal", meta.fieldTypeName("decVal"));
+        assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+    }
+
+    /**
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class TestObject1 {
+        /** */
+        private int intVal;
+
+        /** */
+        private String strVal;
+
+        /** */
+        private byte[] arrVal;
+
+        /** */
+        private TestObject1 obj1Val;
+
+        /** */
+        private TestObject2 obj2Val;
+
+        /** */
+        private BigDecimal decVal;
+
+        /** */
+        private BigDecimal[] decArrVal;
+    }
+
+    /**
+     */
+    private static class TestObject2 implements Binarylizable {
+        /** {@inheritDoc} */
+        @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+            writer.writeBoolean("boolVal", false);
+            writer.writeDate("dateVal", new Date());
+            writer.writeUuidArray("uuidArrVal", null);
+            writer.writeObject("objVal", null);
+            writer.writeMap("mapVal", new HashMap<>());
+            writer.writeDecimal("decVal", BigDecimal.ZERO);
+            writer.writeDecimalArray("decArrVal", new BigDecimal[] { BigDecimal.ONE });
+
+            if (idx == 1) {
+                writer.writeChar("charVal", (char)0);
+                writer.writeCollection("colVal", null);
+            }
+
+            BinaryRawWriter raw = writer.rawWriter();
+
+            raw.writeChar((char)0);
+            raw.writeCollection(null);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+            // No-op.
+        }
+    }
+
+    /**
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class TestObject3 {
+        /** */
+        private int intVal;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.java
new file mode 100644
index 0000000..74c13ce
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+/**
+ * Binary meta data test.
+ */
+public class GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest
+    extends GridDefaultBinaryMappersBinaryMetaDataSelfTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
+
+        bCfg.setNameMapper(new BinaryBasicNameMapper());
+        bCfg.setIdMapper(new BinaryBasicIdMapper(true));
+
+        return cfg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/TestMappedObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/TestMappedObject.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/TestMappedObject.java
new file mode 100644
index 0000000..8705f6a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/TestMappedObject.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.binary;
+
+/**
+ *
+ */
+public class TestMappedObject {
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactDefaultMappersSelfTest.java
new file mode 100644
index 0000000..88a1296
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactDefaultMappersSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.binary.noncompact;
+
+import org.apache.ignite.internal.binary.BinaryObjectBuilderDefaultMappersSelfTest;
+
+/**
+ * Binary builder test for objects with non-compact footer.
+ */
+public class BinaryObjectBuilderNonCompactDefaultMappersSelfTest extends BinaryObjectBuilderDefaultMappersSelfTest {
+    /** {@inheritDoc} */
+    @Override protected boolean compactFooter() {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSelfTest.java
deleted file mode 100644
index c698783..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSelfTest.java
+++ /dev/null
@@ -1,30 +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.binary.noncompact;
-
-import org.apache.ignite.internal.binary.BinaryObjectBuilderSelfTest;
-
-/**
- * Binary builder test for objects with non-compact footer.
- */
-public class BinaryObjectBuilderNonCompactSelfTest extends BinaryObjectBuilderSelfTest {
-    /** {@inheritDoc} */
-    @Override protected boolean compactFooter() {
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.java
new file mode 100644
index 0000000..821c41b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.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.binary.noncompact;
+
+import org.apache.ignite.internal.binary.BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest;
+
+/**
+ * Binary builder test for objects with non-compact footer.
+ */
+public class BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest
+    extends BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest {
+    /** {@inheritDoc} */
+    @Override protected boolean compactFooter() {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java
index ea16c1f..3e96cf7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java
@@ -21,8 +21,8 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.managers.communication.GridIoMessageFactory;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.managers.communication.GridIoMessageFactory;
 import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.typedef.CO;
 import org.apache.ignite.plugin.extensions.communication.Message;
@@ -91,6 +91,8 @@ public class GridCacheConditionalDeploymentSelfTest extends GridCommonAbstractTe
 
         startGrid(1);
 
+        awaitPartitionMapExchange();
+
         ignite0.cache(null).put(1, new TestValue());
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
index 2da781b..271e3b5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
@@ -30,6 +30,7 @@ import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.binary.BinaryNameMapper;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CachePeekMode;
@@ -38,6 +39,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.BinaryObjectImpl;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -77,6 +79,9 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
     /** */
     private static final int ENTRY_CNT = 100;
 
+    /** */
+    private static IgniteConfiguration cfg;
+
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
@@ -109,6 +114,8 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
 
         cfg.setMarshaller(new BinaryMarshaller());
 
+        this.cfg = cfg;
+
         return cfg;
     }
 
@@ -200,8 +207,14 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
 
         assertNotNull(str);
 
-        assertTrue("Unexpected toString: " + str,
-            str.startsWith("TestReferenceObject") && str.contains("obj=TestReferenceObject ["));
+        BinaryNameMapper nameMapper = BinaryContext.defaultNameMapper();
+
+        if (cfg.getBinaryConfiguration() != null && cfg.getBinaryConfiguration().getNameMapper() != null)
+            nameMapper = cfg.getBinaryConfiguration().getNameMapper();
+
+        String typeName = nameMapper.typeName(TestReferenceObject.class.getName());
+
+        assertTrue("Unexpected toString: " + str, str.startsWith(typeName) && str.contains("obj=" + typeName + " ["));
 
         TestReferenceObject obj1_r = po.deserialize();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
index 0cfa88b..63ed30e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
@@ -24,6 +24,8 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import javax.cache.Cache;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
 import org.apache.ignite.cache.store.CacheStoreAdapter;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -46,6 +48,9 @@ public abstract class GridCacheBinaryStoreAbstractSelfTest extends GridCommonAbs
     /** */
     private static final TestStore STORE = new TestStore();
 
+    /** */
+    protected static IgniteConfiguration cfg;
+
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
@@ -53,6 +58,9 @@ public abstract class GridCacheBinaryStoreAbstractSelfTest extends GridCommonAbs
 
         BinaryConfiguration bCfg = new BinaryConfiguration();
 
+        bCfg.setNameMapper(new BinaryBasicNameMapper(false));
+        bCfg.setIdMapper(new BinaryBasicIdMapper(false));
+
         bCfg.setClassNames(Arrays.asList(Key.class.getName(), Value.class.getName()));
 
         cfg.setBinaryConfiguration(bCfg);
@@ -75,6 +83,8 @@ public abstract class GridCacheBinaryStoreAbstractSelfTest extends GridCommonAbs
 
         cfg.setDiscoverySpi(disco);
 
+        GridCacheBinaryStoreAbstractSelfTest.cfg = cfg;
+
         return cfg;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesDefaultMappersSelfTest.java
new file mode 100644
index 0000000..47fc53b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesDefaultMappersSelfTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.cache.binary;
+
+import java.util.Map;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.internal.binary.BinaryContext;
+
+/**
+ * Tests for cache store with binary.
+ */
+public class GridCacheBinaryStoreBinariesDefaultMappersSelfTest extends GridCacheBinaryStoreAbstractSelfTest {
+    /** {@inheritDoc} */
+    @Override protected boolean keepBinaryInStore() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void populateMap(Map<Object, Object> map, int... idxs) {
+        assert map != null;
+        assert idxs != null;
+
+        for (int idx : idxs)
+            map.put(binary(new Key(idx)), binary(new Value(idx)));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void checkMap(Map<Object, Object> map, int... idxs) {
+        assert map != null;
+        assert idxs != null;
+
+        assertEquals(idxs.length, map.size());
+
+        for (int idx : idxs) {
+            Object val = map.get(binary(new Key(idx)));
+
+            assertTrue(String.valueOf(val), val instanceof BinaryObject);
+
+            BinaryObject po = (BinaryObject)val;
+
+            assertEquals(expectedTypeName(Value.class.getName()), po.type().typeName());
+            assertEquals(new Integer(idx), po.field("idx"));
+        }
+    }
+
+    /**
+     * @param clsName Class name.
+     * @return Type name.
+     */
+    private String expectedTypeName(String clsName) {
+        BinaryNameMapper nameMapper = cfg.getBinaryConfiguration().getNameMapper();
+
+        if (nameMapper == null)
+            nameMapper = BinaryContext.defaultNameMapper();
+
+        return nameMapper.typeName(clsName);
+    }
+
+    /**
+     * @param obj Object.
+     * @return Binary object.
+     */
+    private Object binary(Object obj) {
+        return grid().binary().toBinary(obj);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSelfTest.java
deleted file mode 100644
index 4d163b3..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSelfTest.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.processors.cache.binary;
-
-import java.util.Map;
-import org.apache.ignite.binary.BinaryObject;
-
-/**
- * Tests for cache store with binary.
- */
-public class GridCacheBinaryStoreBinariesSelfTest extends GridCacheBinaryStoreAbstractSelfTest {
-    /** {@inheritDoc} */
-    @Override protected boolean keepBinaryInStore() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void populateMap(Map<Object, Object> map, int... idxs) {
-        assert map != null;
-        assert idxs != null;
-
-        for (int idx : idxs)
-            map.put(binary(new Key(idx)), binary(new Value(idx)));
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void checkMap(Map<Object, Object> map, int... idxs) {
-        assert map != null;
-        assert idxs != null;
-
-        assertEquals(idxs.length, map.size());
-
-        for (int idx : idxs) {
-            Object val = map.get(binary(new Key(idx)));
-
-            assertTrue(String.valueOf(val), val instanceof BinaryObject);
-
-            BinaryObject po = (BinaryObject)val;
-
-            assertEquals("Value", po.type().typeName());
-            assertEquals(new Integer(idx), po.field("idx"));
-        }
-    }
-
-    /**
-     * @param obj Object.
-     * @return Binary object.
-     */
-    private Object binary(Object obj) {
-        return grid().binary().toBinary(obj);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.java
new file mode 100644
index 0000000..0aee2f2
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.cache.binary;
+
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+/**
+ * Tests for cache store with binary.
+ */
+public class GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest
+    extends GridCacheBinaryStoreBinariesDefaultMappersSelfTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
+
+        bCfg.setNameMapper(new BinaryBasicNameMapper());
+        bCfg.setIdMapper(new BinaryBasicIdMapper(true));
+
+        return cfg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testframework/config/GridTestProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/config/GridTestProperties.java b/modules/core/src/test/java/org/apache/ignite/testframework/config/GridTestProperties.java
index 491f38f..d13f117 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/config/GridTestProperties.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/config/GridTestProperties.java
@@ -79,6 +79,9 @@ public final class GridTestProperties {
     public static final String BINARY_COMPACT_FOOTERS = "binary.marshaller.compact.footers";
 
     /** */
+    public static final String BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER = "binary.marshaller.use.simple.name.mapper";
+
+    /** */
     static {
         // Initialize IGNITE_HOME system property.
         String igniteHome = System.getProperty("IGNITE_HOME");
@@ -321,4 +324,4 @@ public final class GridTestProperties {
 
         return props;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 8bf877a..27511ff 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -50,6 +50,7 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -104,6 +105,7 @@ import org.springframework.context.support.FileSystemXmlApplicationContext;
 import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.testframework.config.GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER;
 
 /**
  * Common abstract test for Ignite tests.
@@ -732,7 +734,14 @@ public abstract class GridAbstractTest extends TestCase {
             startingGrid.set(gridName);
 
             try {
-                return IgnitionEx.start(optimize(getConfiguration(gridName)), ctx);
+                Ignite node = IgnitionEx.start(optimize(getConfiguration(gridName)), ctx);
+
+                IgniteConfiguration cfg = node.configuration();
+
+                log.info("Node started with the following configuration [id=" + node.cluster().localNode().id()
+                    + ", marshaller=" + cfg.getMarshaller() + ", binaryCfg=" + cfg.getBinaryConfiguration() + "]");
+
+                return node;
             }
             finally {
                 startingGrid.set(null);
@@ -1143,6 +1152,18 @@ public abstract class GridAbstractTest extends TestCase {
             }
         }
 
+        if (Boolean.valueOf(GridTestProperties.getProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER))) {
+            BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
+
+            if (bCfg == null) {
+                bCfg = new BinaryConfiguration();
+
+                cfg.setBinaryConfiguration(bCfg);
+            }
+
+            bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+        }
+
         if (gridName != null && gridName.matches(".*\\d")) {
             String idStr = UUID.randomUUID().toString();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index bcd1ede..dece258 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -111,7 +111,7 @@ public class IgniteBasicTestSuite extends TestSuite {
         suite.addTestSuite(GridFailFastNodeFailureDetectionSelfTest.class);
         suite.addTestSuite(OffHeapTieredTransactionSelfTest.class);
         suite.addTestSuite(IgniteSlowClientDetectionSelfTest.class);
-        suite.addTestSuite(IgniteDaemonNodeMarshallerCacheTest.class);
+        GridTestUtils.addTestIfNeeded(suite, IgniteDaemonNodeMarshallerCacheTest.class, ignoredTests);
         suite.addTestSuite(IgniteMarshallerCacheConcurrentReadWriteTest.class);
 
         suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
new file mode 100644
index 0000000..cbb87fa
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
@@ -0,0 +1,95 @@
+/*
+ * 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.testsuites;
+
+import java.util.HashSet;
+import java.util.Set;
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.ClusterGroupSelfTest;
+import org.apache.ignite.internal.GridReleaseTypeSelfTest;
+import org.apache.ignite.internal.GridVersionSelfTest;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.managers.deployment.GridDeploymentMessageCountSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingErrorTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingNearErrorTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingRebalanceErrorTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingTxErrorTest;
+import org.apache.ignite.internal.processors.cache.IgniteDaemonNodeMarshallerCacheTest;
+import org.apache.ignite.internal.util.GridStartupWithSpecifiedWorkDirectorySelfTest;
+import org.apache.ignite.internal.util.IgniteUtilsSelfTest;
+import org.apache.ignite.internal.util.io.GridUnsafeDataOutputArraySizingSelfTest;
+import org.apache.ignite.internal.util.nio.GridNioSelfTest;
+import org.apache.ignite.internal.util.nio.GridNioSslSelfTest;
+import org.apache.ignite.marshaller.jdk.GridJdkMarshallerSelfTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerEnumSelfTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerNodeFailoverTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerSelfTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerSerialPersistentFieldsSelfTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerTest;
+import org.apache.ignite.marshaller.optimized.OptimizedObjectStreamSelfTest;
+import org.apache.ignite.messaging.GridMessagingNoPeerClassLoadingSelfTest;
+import org.apache.ignite.messaging.GridMessagingSelfTest;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ * Basic test suite.
+ */
+public class IgniteBinaryBasicTestSuite extends TestSuite {
+    /**
+     * @return Test suite.
+     * @throws Exception Thrown in case of the failure.
+     */
+    public static TestSuite suite() throws Exception {
+        GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+
+        TestSuite suite = new TestSuite("GridGain Binary Basic Test Suite");
+
+        Set<Class> ignoredTests = new HashSet<>();
+
+        // Tests that are not ready to be used with PortableMarshaller
+        ignoredTests.add(GridJdkMarshallerSelfTest.class);
+        ignoredTests.add(OptimizedMarshallerEnumSelfTest.class);
+        ignoredTests.add(OptimizedMarshallerSelfTest.class);
+        ignoredTests.add(OptimizedMarshallerTest.class);
+        ignoredTests.add(OptimizedObjectStreamSelfTest.class);
+        ignoredTests.add(GridUnsafeDataOutputArraySizingSelfTest.class);
+        ignoredTests.add(OptimizedMarshallerNodeFailoverTest.class);
+        ignoredTests.add(OptimizedMarshallerSerialPersistentFieldsSelfTest.class);
+        ignoredTests.add(GridNioSslSelfTest.class);
+        ignoredTests.add(GridNioSelfTest.class);
+        ignoredTests.add(IgniteCacheP2pUnmarshallingErrorTest.class);
+        ignoredTests.add(IgniteCacheP2pUnmarshallingTxErrorTest.class);
+        ignoredTests.add(IgniteCacheP2pUnmarshallingNearErrorTest.class);
+        ignoredTests.add(IgniteCacheP2pUnmarshallingRebalanceErrorTest.class);
+        ignoredTests.add(GridReleaseTypeSelfTest.class);
+        ignoredTests.add(GridStartupWithSpecifiedWorkDirectorySelfTest.class);
+        ignoredTests.add(IgniteUtilsSelfTest.class);
+        ignoredTests.add(ClusterGroupSelfTest.class);
+        ignoredTests.add(GridMessagingNoPeerClassLoadingSelfTest.class);
+        ignoredTests.add(GridMessagingSelfTest.class);
+        ignoredTests.add(GridVersionSelfTest.class);
+        ignoredTests.add(GridDeploymentMessageCountSelfTest.class);
+
+        // TODO: check and delete if pass.
+        ignoredTests.add(IgniteDaemonNodeMarshallerCacheTest.class);
+
+        suite.addTest(IgniteBasicTestSuite.suite(ignoredTests));
+
+        return suite;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsSimpleNameMapperComputeGridTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsSimpleNameMapperComputeGridTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsSimpleNameMapperComputeGridTestSuite.java
new file mode 100644
index 0000000..d3ea755
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsSimpleNameMapperComputeGridTestSuite.java
@@ -0,0 +1,38 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ *
+ */
+public class IgniteBinaryObjectsSimpleNameMapperComputeGridTestSuite {
+    /**
+     * @return Test suite.
+     * @throws Exception If failed.
+     */
+    public static TestSuite suite() throws Exception {
+        GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+        GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+
+        return IgniteComputeGridTestSuite.suite();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index 9651f6d..5eb7b66 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -18,6 +18,9 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryBasicIdMapperSelfTest;
+import org.apache.ignite.internal.binary.BinaryBasicNameMapperSelfTest;
+import org.apache.ignite.internal.binary.BinaryConfigurationConsistencySelfTest;
 import org.apache.ignite.internal.binary.BinaryEnumsSelfTest;
 import org.apache.ignite.internal.binary.BinaryFieldsHeapSelfTest;
 import org.apache.ignite.internal.binary.BinaryFieldsOffheapSelfTest;
@@ -25,19 +28,24 @@ import org.apache.ignite.internal.binary.BinaryFooterOffsetsHeapSelfTest;
 import org.apache.ignite.internal.binary.BinaryFooterOffsetsOffheapSelfTest;
 import org.apache.ignite.internal.binary.BinaryMarshallerSelfTest;
 import org.apache.ignite.internal.binary.BinaryObjectBuilderAdditionalSelfTest;
-import org.apache.ignite.internal.binary.BinaryObjectBuilderSelfTest;
+import org.apache.ignite.internal.binary.BinaryObjectBuilderDefaultMappersSelfTest;
+import org.apache.ignite.internal.binary.BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest;
+import org.apache.ignite.internal.binary.BinarySimpleNameTestPropertySelfTest;
 import org.apache.ignite.internal.binary.GridBinaryAffinityKeySelfTest;
 import org.apache.ignite.internal.binary.GridBinaryMarshallerCtxDisabledSelfTest;
-import org.apache.ignite.internal.binary.GridBinaryMetaDataSelfTest;
 import org.apache.ignite.internal.binary.GridBinaryWildcardsSelfTest;
+import org.apache.ignite.internal.binary.GridDefaultBinaryMappersBinaryMetaDataSelfTest;
+import org.apache.ignite.internal.binary.GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest;
 import org.apache.ignite.internal.binary.noncompact.BinaryFieldsHeapNonCompactSelfTest;
 import org.apache.ignite.internal.binary.noncompact.BinaryFieldsOffheapNonCompactSelfTest;
 import org.apache.ignite.internal.binary.noncompact.BinaryFooterOffsetsHeapNonCompactSelfTest;
 import org.apache.ignite.internal.binary.noncompact.BinaryFooterOffsetsOffheapNonCompactSelfTest;
 import org.apache.ignite.internal.binary.noncompact.BinaryMarshallerNonCompactSelfTest;
 import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderAdditionalNonCompactSelfTest;
-import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactSelfTest;
-import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSelfTest;
+import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactDefaultMappersSelfTest;
+import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest;
+import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesDefaultMappersSelfTest;
+import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataMultinodeTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataTest;
@@ -68,22 +76,31 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
     public static TestSuite suite() throws Exception {
         TestSuite suite = new TestSuite("Ignite Binary Objects Test Suite");
 
+        suite.addTestSuite(BinarySimpleNameTestPropertySelfTest.class);
+        
+        suite.addTestSuite(BinaryBasicIdMapperSelfTest.class);
+        suite.addTestSuite(BinaryBasicNameMapperSelfTest.class);
+
         suite.addTestSuite(BinaryMarshallerSelfTest.class);
+        suite.addTestSuite(BinaryConfigurationConsistencySelfTest.class);
         suite.addTestSuite(GridBinaryMarshallerCtxDisabledSelfTest.class);
-        suite.addTestSuite(BinaryObjectBuilderSelfTest.class);
+        suite.addTestSuite(BinaryObjectBuilderDefaultMappersSelfTest.class);
+        suite.addTestSuite(BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.class);
         suite.addTestSuite(BinaryObjectBuilderAdditionalSelfTest.class);
         suite.addTestSuite(BinaryFieldsHeapSelfTest.class);
         suite.addTestSuite(BinaryFieldsOffheapSelfTest.class);
         suite.addTestSuite(BinaryFooterOffsetsHeapSelfTest.class);
         suite.addTestSuite(BinaryFooterOffsetsOffheapSelfTest.class);
         suite.addTestSuite(BinaryEnumsSelfTest.class);
-        suite.addTestSuite(GridBinaryMetaDataSelfTest.class);
+        suite.addTestSuite(GridDefaultBinaryMappersBinaryMetaDataSelfTest.class);
+        suite.addTestSuite(GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.class);
         suite.addTestSuite(GridBinaryAffinityKeySelfTest.class);
         suite.addTestSuite(GridBinaryWildcardsSelfTest.class);
 
         // Tests for objects with non-compact footers.
         suite.addTestSuite(BinaryMarshallerNonCompactSelfTest.class);
-        suite.addTestSuite(BinaryObjectBuilderNonCompactSelfTest.class);
+        suite.addTestSuite(BinaryObjectBuilderNonCompactDefaultMappersSelfTest.class);
+        suite.addTestSuite(BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.class);
         suite.addTestSuite(BinaryObjectBuilderAdditionalNonCompactSelfTest.class);
         suite.addTestSuite(BinaryFieldsHeapNonCompactSelfTest.class);
         suite.addTestSuite(BinaryFieldsOffheapNonCompactSelfTest.class);
@@ -105,7 +122,8 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheBinaryObjectsPartitionedNearDisabledOffheapTieredSelfTest.class);
 
         suite.addTestSuite(GridCacheBinaryStoreObjectsSelfTest.class);
-        suite.addTestSuite(GridCacheBinaryStoreBinariesSelfTest.class);
+        suite.addTestSuite(GridCacheBinaryStoreBinariesDefaultMappersSelfTest.class);
+        suite.addTestSuite(GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.class);
 
         suite.addTestSuite(GridCacheClientNodeBinaryObjectMetadataTest.class);
         suite.addTestSuite(GridCacheClientNodeBinaryObjectMetadataMultinodeTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java
new file mode 100644
index 0000000..77020bd
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java
@@ -0,0 +1,38 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ * Basic test suite.
+ */
+public class IgniteBinarySimpleNameMapperBasicTestSuite extends TestSuite {
+    /**
+     * @return Test suite.
+     * @throws Exception Thrown in case of the failure.
+     */
+    public static TestSuite suite() throws Exception {
+        GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+        GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+
+        return IgniteBinaryBasicTestSuite.suite();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java
new file mode 100644
index 0000000..bbf4297
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java
@@ -0,0 +1,39 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ * Cache full API suite with binary marshaller and simple name mapper.
+ */
+public class IgniteBinarySimpleNameMapperCacheFullApiTestSuite extends TestSuite {
+    /**
+     * @return Suite.
+     * @throws Exception In case of error.
+     */
+    public static TestSuite suite() throws Exception {
+        GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+        GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+
+        return IgniteCacheFullApiSelfTestSuite.suite();
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
index 3bab1f9..89ead35 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
@@ -21,90 +21,10 @@ import junit.framework.TestSuite;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.processors.cache.BinarySerializationQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.BinarySerializationQueryWithReflectiveSerializerSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheLocalQueryMetricsSelfTest;
-import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsDistributedSelfTest;
-import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsLocalSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsDistributedSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsLocalSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheScanPartitionQueryFallbackSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheCrossCacheQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexingDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheQueryInternalKeysSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheQuerySerializationSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheReduceQueryMultithreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteBinaryWrappedObjectFieldsQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryObjectsScanSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheCollocatedQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheDuplicateEntityConfigurationSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheFieldsQueryNoDataSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheLargeResultSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheNoClassQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapEvictQueryTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapTieredMultithreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingQueryErrorTest;
-import org.apache.ignite.internal.processors.cache.IgniteCachePartitionedQueryMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryEvictsMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryIndexSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryLoadSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreadedOffHeapTieredSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapEvictsMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheSqlQueryMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.SqlFieldsQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheClientQueryReplicatedNodeRestartSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQueryP2PDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedSnapshotEnabledQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartSelfTest2;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQueryP2PDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalAtomicQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryLostPartitionTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicPrimaryWriteOrderSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicReplicatedSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxReplicatedSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicNearEnabledSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicP2PDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedOnlySelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedP2PDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedOneNodeSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedP2PDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryTxSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientReconnectTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTxReconnectTest;
-import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryLocalSelfTest;
-import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryPartitionedSelfTest;
-import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryReplicatedSelfTest;
-import org.apache.ignite.internal.processors.query.IgniteSqlSplitterSelfTest;
-import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest;
-import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest;
-import org.apache.ignite.internal.processors.query.h2.sql.H2CompareBigQueryTest;
-import org.apache.ignite.spi.communication.tcp.GridOrderedMessageCancelSelfTest;
 import org.apache.ignite.testframework.config.GridTestProperties;
 
 /**
@@ -118,122 +38,24 @@ public class IgniteBinaryCacheQueryTestSuite extends TestSuite {
     public static TestSuite suite() throws Exception {
         GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
 
-        TestSuite suite = new TestSuite("Grid Cache Query Test Suite using BinaryMarshaller");
+        TestSuite suite = IgniteCacheQuerySelfTestSuite.suite();
 
         // Serialization.
         suite.addTestSuite(BinarySerializationQuerySelfTest.class);
         suite.addTestSuite(BinarySerializationQueryWithReflectiveSerializerSelfTest.class);
 
-        // Parsing.
-        suite.addTestSuite(GridQueryParsingTest.class);
-
-        // Config.
-        suite.addTestSuite(IgniteCacheDuplicateEntityConfigurationSelfTest.class);
-
-        // Queries tests.
-        suite.addTestSuite(IgniteSqlSplitterSelfTest.class);
-        suite.addTestSuite(GridCacheQueryIndexDisabledSelfTest.class);
-        suite.addTestSuite(IgniteCacheQueryLoadSelfTest.class);
-        suite.addTestSuite(IgniteCacheLocalQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheLocalAtomicQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheReplicatedQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheReplicatedQueryP2PDisabledSelfTest.class);
-        suite.addTestSuite(IgniteCachePartitionedQuerySelfTest.class);
-        suite.addTestSuite(IgniteCachePartitionedSnapshotEnabledQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheAtomicQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheAtomicNearEnabledQuerySelfTest.class);
-        suite.addTestSuite(IgniteCachePartitionedQueryP2PDisabledSelfTest.class);
-        suite.addTestSuite(IgniteCachePartitionedQueryMultiThreadedSelfTest.class);
-        suite.addTestSuite(IgniteCacheQueryIndexSelfTest.class);
-        suite.addTestSuite(IgniteCacheCollocatedQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheLargeResultSelfTest.class);
-        suite.addTestSuite(GridCacheQueryInternalKeysSelfTest.class);
-        suite.addTestSuite(IgniteCacheQueryMultiThreadedSelfTest.class);
-        suite.addTestSuite(IgniteCacheQueryMultiThreadedOffHeapTieredSelfTest.class);
-        suite.addTestSuite(IgniteCacheQueryEvictsMultiThreadedSelfTest.class);
-        suite.addTestSuite(IgniteCacheQueryOffheapMultiThreadedSelfTest.class);
-        suite.addTestSuite(IgniteCacheQueryOffheapEvictsMultiThreadedSelfTest.class);
-        suite.addTestSuite(IgniteCacheOffheapEvictQueryTest.class);
-        suite.addTestSuite(IgniteCacheSqlQueryMultiThreadedSelfTest.class);
-        suite.addTestSuite(IgniteCacheOffheapTieredMultithreadedSelfTest.class);
-        suite.addTestSuite(IgniteCacheQueryNodeRestartSelfTest.class);
-        suite.addTestSuite(IgniteCacheQueryNodeRestartSelfTest2.class);
-        suite.addTestSuite(IgniteCacheClientQueryReplicatedNodeRestartSelfTest.class);
-        suite.addTestSuite(GridCacheReduceQueryMultithreadedSelfTest.class);
-        suite.addTestSuite(GridCacheCrossCacheQuerySelfTest.class);
-        suite.addTestSuite(GridCacheQuerySerializationSelfTest.class);
         suite.addTestSuite(IgniteCacheBinaryObjectsScanSelfTest.class);
-        suite.addTestSuite(IgniteBinaryObjectFieldsQuerySelfTest.class);
-        suite.addTestSuite(IgniteBinaryWrappedObjectFieldsQuerySelfTest.class);
-
-        // Scan queries.
-        suite.addTestSuite(CacheScanPartitionQueryFallbackSelfTest.class);
-
-        // Fields queries.
-        suite.addTestSuite(SqlFieldsQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheLocalFieldsQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheReplicatedFieldsQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest.class);
-        suite.addTestSuite(IgniteCachePartitionedFieldsQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheAtomicFieldsQuerySelfTest.class);
-        suite.addTestSuite(IgniteCacheAtomicNearEnabledFieldsQuerySelfTest.class);
-        suite.addTestSuite(IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest.class);
-        suite.addTestSuite(IgniteCacheFieldsQueryNoDataSelfTest.class);
-
-        // Continuous queries.
-        suite.addTestSuite(GridCacheContinuousQueryLocalSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryLocalAtomicSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryReplicatedSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryReplicatedAtomicSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryReplicatedP2PDisabledSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryPartitionedSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryPartitionedOnlySelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryPartitionedP2PDisabledSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryTxSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryAtomicSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryAtomicNearEnabledSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryAtomicP2PDisabledSelfTest.class);
-        suite.addTestSuite(GridCacheContinuousQueryReplicatedOneNodeSelfTest.class);
-        suite.addTestSuite(IgniteCacheContinuousQueryClientTest.class);
-        suite.addTestSuite(IgniteCacheContinuousQueryClientReconnectTest.class);
-        suite.addTestSuite(IgniteCacheContinuousQueryClientTxReconnectTest.class);
-        suite.addTestSuite(CacheContinuousQueryFailoverAtomicPrimaryWriteOrderSelfTest.class);
-        suite.addTestSuite(CacheContinuousQueryFailoverAtomicReplicatedSelfTest.class);
-        suite.addTestSuite(CacheContinuousQueryFailoverTxSelfTest.class);
-        suite.addTestSuite(CacheContinuousQueryFailoverTxReplicatedSelfTest.class);
         suite.addTestSuite(CacheContinuousQueryLostPartitionTest.class);
 
-        // Reduce fields queries.
-        suite.addTestSuite(GridCacheReduceFieldsQueryLocalSelfTest.class);
-        suite.addTestSuite(GridCacheReduceFieldsQueryPartitionedSelfTest.class);
-        suite.addTestSuite(GridCacheReduceFieldsQueryAtomicSelfTest.class);
-        suite.addTestSuite(GridCacheReduceFieldsQueryReplicatedSelfTest.class);
-
-        suite.addTestSuite(GridCacheQueryIndexingDisabledSelfTest.class);
-
         //Should be adjusted. Not ready to be used with BinaryMarshaller.
         //suite.addTestSuite(GridCacheBinarySwapScanQuerySelfTest.class);
 
-        suite.addTestSuite(GridOrderedMessageCancelSelfTest.class);
-
-        // Ignite cache and H2 comparison.
-        suite.addTestSuite(BaseH2CompareQueryTest.class);
-        suite.addTestSuite(H2CompareBigQueryTest.class);
-
-        // Metrics tests
-        suite.addTestSuite(CacheLocalQueryMetricsSelfTest.class);
-        suite.addTestSuite(CachePartitionedQueryMetricsDistributedSelfTest.class);
-        suite.addTestSuite(CachePartitionedQueryMetricsLocalSelfTest.class);
-        suite.addTestSuite(CacheReplicatedQueryMetricsDistributedSelfTest.class);
-        suite.addTestSuite(CacheReplicatedQueryMetricsLocalSelfTest.class);
-
-        //Unmarshallig query test.
-        suite.addTestSuite(IgniteCacheP2pUnmarshallingQueryErrorTest.class);
-        suite.addTestSuite(IgniteCacheNoClassQuerySelfTest.class);
-
         suite.addTestSuite(GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.class);
         suite.addTestSuite(GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.class);
 
+        //TODO: the following tests= was never tested with binary. Exclude or pass?
+//        suite.addTestSuite(IgniteSqlSchemaIndexingTest.class);
+
         return suite;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java
new file mode 100644
index 0000000..3eed980
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java
@@ -0,0 +1,38 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ * Cache query suite with binary marshaller.
+ */
+public class IgniteBinarySimpleNameMapperCacheQueryTestSuite extends TestSuite {
+    /**
+     * @return Suite.
+     * @throws Exception In case of error.
+     */
+    public static TestSuite suite() throws Exception {
+        GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+        GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+
+        return IgniteBinaryCacheQueryTestSuite.suite();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
index 434f468..ef29a89 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
@@ -45,6 +45,27 @@
             </list>
         </property>
 
+        <property name="binaryConfiguration">
+            <bean class="org.apache.ignite.configuration.BinaryConfiguration">
+                <property name="compactFooter" value="false"/>
+                <property name="typeConfigurations">
+                    <list>
+                        <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+                            <property name="typeName" value="org.apache.ignite.platform.PlatformComputeBinarizable"/>
+                        </bean>
+                        <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+                            <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaBinarizable"/>
+                        </bean>
+                        <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+                            <property name="typeName" value="org.apache.ignite.platform.PlatformComputeEnum" />
+                            <property name="enum" value="true" />
+                        </bean>
+                    </list>
+                </property>
+
+            </bean>
+        </property>
+
         <property name="discoverySpi">
             <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                 <property name="ipFinder">

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
index 31ccdf0..d1c96b6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
@@ -25,14 +25,35 @@
       <property name="localHost" value="127.0.0.1"/>
         <property name="connectorConfiguration"><null/></property>
 
-      <property name="clientMode" value="true"/>
+        <property name="clientMode" value="true"/>
 
-      <property name="gridName" value="grid3"/>
+        <property name="gridName" value="grid3"/>
 
-      <property name="metricsUpdateFrequency" value="1000"/>
-      <property name="metricsLogFrequency" value="0"/>
+        <property name="metricsUpdateFrequency" value="1000"/>
+        <property name="metricsLogFrequency" value="0"/>
 
-      <property name="discoverySpi">
+        <property name="binaryConfiguration">
+            <bean class="org.apache.ignite.configuration.BinaryConfiguration">
+                <property name="compactFooter" value="false"/>
+                <property name="typeConfigurations">
+                    <list>
+                        <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+                            <property name="typeName" value="org.apache.ignite.platform.PlatformComputeBinarizable"/>
+                        </bean>
+                        <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+                            <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaBinarizable"/>
+                        </bean>
+                        <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+                            <property name="typeName" value="org.apache.ignite.platform.PlatformComputeEnum" />
+                            <property name="enum" value="true" />
+                        </bean>
+                    </list>
+                </property>
+
+            </bean>
+        </property>
+
+        <property name="discoverySpi">
             <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                 <property name="forceServerMode" value="true"/>
 


[06/28] ignite git commit: IGNITE-2191 - Support classes with the same simple name for Binary marshaller - Fixes #398.

Posted by vo...@apache.org.
IGNITE-2191 - Support classes with the same simple name for Binary marshaller - Fixes #398.

Signed-off-by: Alexey Goncharuk <al...@gmail.com>


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

Branch: refs/heads/ignite-2508
Commit: 62502b2c44d7d35584b31c8f1284b810840f9a8d
Parents: 58dce88
Author: ashutak <as...@gridgain.com>
Authored: Mon Feb 1 18:12:03 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Feb 1 18:12:03 2016 +0300

----------------------------------------------------------------------
 .../ignite/binary/BinaryBasicIdMapper.java      |  167 +++
 .../ignite/binary/BinaryBasicNameMapper.java    |  141 +++
 .../apache/ignite/binary/BinaryIdMapper.java    |   19 +-
 .../apache/ignite/binary/BinaryNameMapper.java  |   47 +
 .../ignite/binary/BinaryTypeConfiguration.java  |   23 +-
 .../configuration/BinaryConfiguration.java      |   28 +
 .../configuration/IgniteConfiguration.java      |    8 +-
 .../ignite/internal/IgniteNodeAttributes.java   |    3 +
 .../internal/binary/BinaryClassDescriptor.java  |   23 +-
 .../ignite/internal/binary/BinaryContext.java   |  347 ++++--
 .../internal/binary/BinaryEnumObjectImpl.java   |   11 +-
 .../internal/binary/BinaryInternalIdMapper.java |  161 ---
 .../internal/binary/BinaryInternalMapper.java   |  131 ++
 .../binary/BinaryMetadataCollector.java         |   22 +-
 .../internal/binary/BinaryReaderExImpl.java     |   14 +-
 .../internal/binary/BinaryWriterExImpl.java     |   30 +-
 .../binary/builder/BinaryBuilderSerializer.java |   16 +-
 .../binary/builder/BinaryObjectBuilderImpl.java |    2 +-
 .../binary/CacheObjectBinaryProcessorImpl.java  |  123 +-
 .../cpp/PlatformCppConfigurationClosure.java    |   32 +
 .../PlatformDotNetConfigurationClosure.java     |   34 +-
 .../binary/BinaryBasicIdMapperSelfTest.java     |   51 +
 .../binary/BinaryBasicNameMapperSelfTest.java   |   50 +
 .../BinaryConfigurationConsistencySelfTest.java |  231 ++++
 .../internal/binary/BinaryEnumsSelfTest.java    |   12 +-
 .../binary/BinaryMarshallerSelfTest.java        |  508 ++++++--
 .../BinaryObjectBuilderAdditionalSelfTest.java  |    4 +-
 ...naryObjectBuilderDefaultMappersSelfTest.java | 1149 ++++++++++++++++++
 .../binary/BinaryObjectBuilderSelfTest.java     | 1108 -----------------
 ...ilderSimpleNameLowerCaseMappersSelfTest.java |   41 +
 .../BinarySimpleNameTestPropertySelfTest.java   |   94 ++
 .../binary/GridBinaryMetaDataSelfTest.java      |  371 ------
 .../binary/GridBinaryWildcardsSelfTest.java     |  338 +++++-
 ...aultBinaryMappersBinaryMetaDataSelfTest.java |  389 ++++++
 ...CaseBinaryMappersBinaryMetaDataSelfTest.java |   41 +
 .../internal/binary/TestMappedObject.java       |   25 +
 ...BuilderNonCompactDefaultMappersSelfTest.java |   30 +
 .../BinaryObjectBuilderNonCompactSelfTest.java  |   30 -
 ...mpactSimpleNameLowerCaseMappersSelfTest.java |   31 +
 .../GridCacheConditionalDeploymentSelfTest.java |    4 +-
 .../GridCacheBinaryObjectsAbstractSelfTest.java |   17 +-
 .../GridCacheBinaryStoreAbstractSelfTest.java   |   10 +
 ...naryStoreBinariesDefaultMappersSelfTest.java |   81 ++
 .../GridCacheBinaryStoreBinariesSelfTest.java   |   66 -
 ...yStoreBinariesSimpleNameMappersSelfTest.java |   40 +
 .../config/GridTestProperties.java              |    5 +-
 .../testframework/junits/GridAbstractTest.java  |   23 +-
 .../ignite/testsuites/IgniteBasicTestSuite.java |    2 +-
 .../testsuites/IgniteBinaryBasicTestSuite.java  |   95 ++
 ...ctsSimpleNameMapperComputeGridTestSuite.java |   38 +
 .../IgniteBinaryObjectsTestSuite.java           |   34 +-
 ...iteBinarySimpleNameMapperBasicTestSuite.java |   38 +
 ...rySimpleNameMapperCacheFullApiTestSuite.java |   39 +
 .../IgniteBinaryCacheQueryTestSuite.java        |  186 +--
 ...narySimpleNameMapperCacheQueryTestSuite.java |   38 +
 .../Config/Compute/compute-grid2.xml            |   21 +
 .../Config/Compute/compute-grid3.xml            |   31 +-
 .../org/apache/ignite/yardstick/IgniteNode.java |    3 +
 58 files changed, 4381 insertions(+), 2275 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicIdMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicIdMapper.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicIdMapper.java
new file mode 100644
index 0000000..da31751
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicIdMapper.java
@@ -0,0 +1,167 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.internal.util.typedef.internal.A;
+
+/**
+ * Base binary ID mapper implementation.
+ */
+public class BinaryBasicIdMapper implements BinaryIdMapper {
+    /** Default lower case flag setting. */
+    public static final boolean DFLT_LOWER_CASE = true;
+
+    /** Maximum lower-case character. */
+    private static final char MAX_LOWER_CASE_CHAR = 0x7e;
+
+    /** Cached lower-case characters. */
+    private static final char[] LOWER_CASE_CHARS;
+
+    /** */
+    private boolean isLowerCase = DFLT_LOWER_CASE;
+
+    /**
+     * Static initializer.
+     */
+    static {
+        LOWER_CASE_CHARS = new char[MAX_LOWER_CASE_CHAR + 1];
+
+        for (char c = 0; c <= MAX_LOWER_CASE_CHAR; c++)
+            LOWER_CASE_CHARS[c] = Character.toLowerCase(c);
+    }
+
+    /**
+     * Default constructor.
+     */
+    public BinaryBasicIdMapper() {
+    }
+
+    /**
+     * @param isLowerCase Whether to use strings in lower case or not.
+     * <p>
+     * Defaults to {@link #DFLT_LOWER_CASE}.
+     */
+    public BinaryBasicIdMapper(boolean isLowerCase) {
+        this.isLowerCase = isLowerCase;
+    }
+
+    /**
+     * Get type ID.
+     *
+     * @param typeName Type name.
+     * @return Type ID.
+     */
+    public int typeId(String typeName) {
+        A.notNull(typeName, "typeName");
+
+        int id = isLowerCase ? lowerCaseHashCode(typeName) : typeName.hashCode();
+
+        if (id != 0)
+            return id;
+        else {
+            throw new BinaryObjectException("Binary ID mapper resolved type ID to zero " +
+                "(either change type's name or use custom ID mapper) " +
+                "[name=" + typeName + ", isLowerCase=" + isLowerCase + "]");
+        }
+    }
+
+    /**
+     * Get field ID.
+     *
+     * @param typeId Type ID.
+     * @param fieldName Field name.
+     * @return Field ID.
+     */
+    public int fieldId(int typeId, String fieldName) {
+        A.notNull(fieldName, "fieldName");
+
+        int id = isLowerCase ? lowerCaseHashCode(fieldName) : fieldName.hashCode();
+
+        if (id != 0)
+            return id;
+        else {
+            throw new BinaryObjectException("Binary ID mapper resolved field ID to zero " +
+                "(either change filed's name or use custom ID mapper) " +
+                "[name=" + fieldName + ", isLowerCase=" + isLowerCase + "]");
+        }
+    }
+
+    /**
+     * Gets whether to use strings in lower case or not.
+     *
+     * @return Whether to use strings in lower case or not.
+     */
+    public boolean isLowerCase() {
+        return isLowerCase;
+    }
+
+    /**
+     * Sets whether to use strings in lower case or not.
+     *
+     * @param isLowerCase Whether to use strings in lower case or not.
+     */
+    public void setLowerCase(boolean isLowerCase) {
+        this.isLowerCase = isLowerCase;
+    }
+
+    /**
+     * Routine to calculate string hash code an
+     *
+     * @param str String.
+     * @return Hash code for given string converted to lower case.
+     */
+    private static int lowerCaseHashCode(String str) {
+        int len = str.length();
+
+        int h = 0;
+
+        for (int i = 0; i < len; i++) {
+            int c = str.charAt(i);
+
+            c = c <= MAX_LOWER_CASE_CHAR ? LOWER_CASE_CHARS[c] : Character.toLowerCase(c);
+
+            h = 31 * h + c;
+        }
+
+        return h;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (!(o instanceof BinaryBasicIdMapper))
+            return false;
+
+        BinaryBasicIdMapper mapper = (BinaryBasicIdMapper)o;
+
+        return isLowerCase == mapper.isLowerCase;
+
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return (isLowerCase ? 1 : 0);
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "BinaryBaseIdMapper [isLowerCase=" + isLowerCase + ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java
new file mode 100644
index 0000000..62420f7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java
@@ -0,0 +1,141 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.internal.util.typedef.internal.A;
+
+/**
+ * Base binary name mapper implementation.
+ */
+public class BinaryBasicNameMapper implements BinaryNameMapper {
+    /** Default use simple name flag setting. */
+    public static final boolean DFLT_SIMPLE_NAME = false;
+
+    /** */
+    private boolean isSimpleName = DFLT_SIMPLE_NAME;
+
+    /**
+     * Default constructor.
+     */
+    public BinaryBasicNameMapper() {
+        // No-op.
+    }
+
+    /**
+     * @param isSimpleName Whether to use simple name of class or not.
+     * <p>
+     * Defaults to {@link #DFLT_SIMPLE_NAME}.
+     */
+    public BinaryBasicNameMapper(boolean isSimpleName) {
+        this.isSimpleName = isSimpleName;
+    }
+
+    /**
+     * Gets whether to use simple name of class or not.
+     *
+     * @return Whether to use simple name of class or not.
+     */
+    public boolean isSimpleName() {
+        return isSimpleName;
+    }
+
+    /**
+     * Sets whether to use simple name of class or not.
+     *
+     * @param isSimpleName Whether to use simple name of class or not.
+     */
+    public void setLowerCase(boolean isSimpleName) {
+        this.isSimpleName = isSimpleName;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String typeName(String clsName) {
+        A.notNull(clsName, "clsName");
+
+        return isSimpleName ? simpleName(clsName) : clsName;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String fieldName(String fieldName) {
+        A.notNull(fieldName, "fieldName");
+
+        return fieldName;
+    }
+
+    /**
+     * @param clsName Class name.
+     * @return Type name.
+     */
+    private static String simpleName(String clsName) {
+        assert clsName != null;
+
+        int idx = clsName.lastIndexOf('$');
+
+        if (idx == clsName.length() - 1)
+            // This is a regular (not inner) class name that ends with '$'. Common use case for Scala classes.
+            idx = -1;
+        else if (idx >= 0) {
+            String typeName = clsName.substring(idx + 1);
+
+            try {
+                Integer.parseInt(typeName);
+
+                // This is an anonymous class. Don't cut off enclosing class name for it.
+                idx = -1;
+            }
+            catch (NumberFormatException ignore) {
+                // This is a lambda class.
+                if (clsName.indexOf("$$Lambda$") > 0)
+                    idx = -1;
+                else
+                    return typeName;
+            }
+        }
+
+        if (idx < 0)
+            idx = clsName.lastIndexOf('.');
+
+        return idx >= 0 ? clsName.substring(idx + 1) : clsName;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (!(o instanceof BinaryBasicNameMapper))
+            return false;
+
+        BinaryBasicNameMapper mapper = (BinaryBasicNameMapper)o;
+
+        if (isSimpleName != mapper.isSimpleName)
+            return false;
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return (isSimpleName ? 1 : 0);
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "BinaryBaseNameMapper [isSimpleName=" + isSimpleName + ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
index 4c31140..dac5c44 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
@@ -30,26 +30,29 @@ package org.apache.ignite.binary;
  * Binary ID mapper can be configured for all binary objects via
  * {@link org.apache.ignite.configuration.BinaryConfiguration#getIdMapper()} method,
  * or for a specific binary type via {@link BinaryTypeConfiguration#getIdMapper()} method.
+ * @see BinaryNameMapper
  */
 public interface BinaryIdMapper {
     /**
-     * Gets type ID for provided class name.
+     * Gets type ID for provided type name.
      * <p>
      * If {@code 0} is returned, hash code of class simple name will be used.
      *
-     * @param clsName Class name.
+     * @param typeName Type name. Type name is a result of {@link BinaryNameMapper#typeName(String)} call for an
+     *        initial class or type name.
      * @return Type ID.
+     * @see BinaryNameMapper#typeName(String)
      */
-    public int typeId(String clsName);
+    public int typeId(String typeName);
 
     /**
-     * Gets ID for provided field.
-     * <p>
-     * If {@code 0} is returned, hash code of field name will be used.
+     * Gets ID for provided field name. <p> If {@code 0} is returned, hash code of field name will be used.
      *
      * @param typeId Type ID.
-     * @param fieldName Field name.
+     * @param fieldName Field name. Filed anme is a result of {@link BinaryNameMapper#fieldName(String)} call for an
+     *        initial filed name.
      * @return Field ID.
+     * @see BinaryNameMapper#fieldName(String)
      */
     public int fieldId(int typeId, String fieldName);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/binary/BinaryNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryNameMapper.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryNameMapper.java
new file mode 100644
index 0000000..2db0aeb
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryNameMapper.java
@@ -0,0 +1,47 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.configuration.BinaryConfiguration;
+
+/**
+ * Maps type and field names to different names. Prepares class/type names
+ * and field names before pass them to {@link BinaryIdMapper}.
+ * <p>
+ * Binary name mapper can be configured for all binary objects via
+ * {@link BinaryConfiguration#getNameMapper()} method,
+ * or for a specific binary type via {@link BinaryTypeConfiguration#getNameMapper()} method.
+ * @see BinaryIdMapper
+ */
+public interface BinaryNameMapper {
+    /**
+     * Gets type clsName.
+     *
+     * @param clsName Class came
+     * @return Type name.
+     */
+    String typeName(String clsName);
+
+    /**
+     * Gets field name.
+     *
+     * @param fieldName Field name.
+     * @return Field name.
+     */
+    String fieldName(String fieldName);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
index a00c061..fea0af7 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
@@ -36,6 +36,9 @@ public class BinaryTypeConfiguration {
     /** ID mapper. */
     private BinaryIdMapper idMapper;
 
+    /** Name mapper. */
+    private BinaryNameMapper nameMapper;
+
     /** Serializer. */
     private BinarySerializer serializer;
 
@@ -107,6 +110,24 @@ public class BinaryTypeConfiguration {
     }
 
     /**
+     * Gets name mapper.
+     *
+     * @return Name mapper.
+     */
+    public BinaryNameMapper getNameMapper() {
+        return nameMapper;
+    }
+
+    /**
+     * Sets name mapper.
+     *
+     * @param nameMapper Name mapper.
+     */
+    public void setNameMapper(BinaryNameMapper nameMapper) {
+        this.nameMapper = nameMapper;
+    }
+
+    /**
      * Gets serializer.
      *
      * @return Serializer.
@@ -146,4 +167,4 @@ public class BinaryTypeConfiguration {
     @Override public String toString() {
         return S.toString(BinaryTypeConfiguration.class, this, super.toString());
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
index 1151245..30d77de 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
@@ -20,8 +20,10 @@ package org.apache.ignite.configuration;
 import java.util.ArrayList;
 import java.util.Collection;
 import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
 import org.apache.ignite.binary.BinarySerializer;
 import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
  * Configuration object for Ignite Binary Objects.
@@ -34,6 +36,9 @@ public class BinaryConfiguration {
     /** ID mapper. */
     private BinaryIdMapper idMapper;
 
+    /** Name mapper. */
+    private BinaryNameMapper nameMapper;
+
     /** Serializer. */
     private BinarySerializer serializer;
 
@@ -75,6 +80,24 @@ public class BinaryConfiguration {
     }
 
     /**
+     * Gets name mapper.
+     *
+     * @return Name mapper.
+     */
+    public BinaryNameMapper getNameMapper() {
+        return nameMapper;
+    }
+
+    /**
+     * Sets name mapper.
+     *
+     * @param nameMapper Name mapper.
+     */
+    public void setNameMapper(BinaryNameMapper nameMapper) {
+        this.nameMapper = nameMapper;
+    }
+
+    /**
      * Gets serializer.
      *
      * @return Serializer.
@@ -136,4 +159,9 @@ public class BinaryConfiguration {
     public void setCompactFooter(boolean compactFooter) {
         this.compactFooter = compactFooter;
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(BinaryConfiguration.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 6598dc0..f705638 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -2002,8 +2002,10 @@ public class IgniteConfiguration {
      *
      * @param cacheKeyCfg Cache key configuration.
      */
-    public void setCacheKeyConfiguration(CacheKeyConfiguration... cacheKeyCfg) {
+    public IgniteConfiguration setCacheKeyConfiguration(CacheKeyConfiguration... cacheKeyCfg) {
         this.cacheKeyCfg = cacheKeyCfg;
+
+        return this;
     }
 
     /**
@@ -2020,8 +2022,10 @@ public class IgniteConfiguration {
      *
      * @param binaryCfg Binary configuration object.
      */
-    public void setBinaryConfiguration(BinaryConfiguration binaryCfg) {
+    public IgniteConfiguration setBinaryConfiguration(BinaryConfiguration binaryCfg) {
         this.binaryCfg = binaryCfg;
+
+        return this;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
index 3c5f960..da6f40d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
@@ -147,6 +147,9 @@ public final class IgniteNodeAttributes {
     /** Update notifier enabled. */
     public static final String ATTR_UPDATE_NOTIFIER_ENABLED = ATTR_PREFIX + ".update.notifier.enabled";
 
+    /** Binary configuration. */
+    public static final String ATTR_BINARY_CONFIGURATION = ATTR_PREFIX + ".binary.config";
+
     /**
      * Enforces singleton.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
index eb45ac6..233e74b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
@@ -34,13 +34,14 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.binary.BinaryReflectiveSerializer;
 import org.apache.ignite.binary.BinarySerializer;
 import org.apache.ignite.binary.Binarylizable;
 import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
 import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.MarshallerExclusions;
 import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
@@ -55,6 +56,7 @@ public class BinaryClassDescriptor {
     public static final Unsafe UNSAFE = GridUnsafe.unsafe();
 
     /** */
+    @GridToStringExclude
     private final BinaryContext ctx;
 
     /** */
@@ -64,7 +66,7 @@ public class BinaryClassDescriptor {
     private final BinarySerializer serializer;
 
     /** ID mapper. */
-    private final BinaryIdMapper idMapper;
+    private final BinaryInternalMapper mapper;
 
     /** */
     private final BinaryWriteMode mode;
@@ -118,7 +120,7 @@ public class BinaryClassDescriptor {
      * @param typeId Type ID.
      * @param typeName Type name.
      * @param affKeyFieldName Affinity key field name.
-     * @param idMapper ID mapper.
+     * @param mapper Mapper.
      * @param serializer Serializer.
      * @param metaDataEnabled Metadata enabled flag.
      * @param registered Whether typeId has been successfully registered by MarshallerContext or not.
@@ -131,14 +133,14 @@ public class BinaryClassDescriptor {
         int typeId,
         String typeName,
         @Nullable String affKeyFieldName,
-        @Nullable BinaryIdMapper idMapper,
+        @Nullable BinaryInternalMapper mapper,
         @Nullable BinarySerializer serializer,
         boolean metaDataEnabled,
         boolean registered
     ) throws BinaryObjectException {
         assert ctx != null;
         assert cls != null;
-        assert idMapper != null;
+        assert mapper != null;
 
         // If serializer is not defined at this point, then we have to user OptimizedMarshaller.
         useOptMarshaller = serializer == null;
@@ -154,7 +156,7 @@ public class BinaryClassDescriptor {
         this.typeName = typeName;
         this.affKeyFieldName = affKeyFieldName;
         this.serializer = serializer;
-        this.idMapper = idMapper;
+        this.mapper = mapper;
         this.registered = registered;
 
         schemaReg = ctx.schemaRegistry(typeId);
@@ -269,7 +271,7 @@ public class BinaryClassDescriptor {
 
                             assert added : name;
 
-                            int fieldId = idMapper.fieldId(typeId, name);
+                            int fieldId = this.mapper.fieldId(typeId, name);
 
                             if (!ids.add(fieldId))
                                 throw new BinaryObjectException("Duplicate field ID: " + name);
@@ -635,7 +637,7 @@ public class BinaryClassDescriptor {
                             if (schemaReg.schema(schemaId) == null) {
                                 // This is new schema, let's update metadata.
                                 BinaryMetadataCollector collector =
-                                    new BinaryMetadataCollector(typeId, typeName, idMapper);
+                                    new BinaryMetadataCollector(typeId, typeName, mapper);
 
                                 if (serializer != null)
                                     serializer.writeBinary(obj, collector);
@@ -804,4 +806,9 @@ public class BinaryClassDescriptor {
             throw new BinaryObjectException("Failed to get constructor for class: " + cls.getName(), e);
         }
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(BinaryClassDescriptor.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 163532d..cf19bdf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -17,10 +17,39 @@
 
 package org.apache.ignite.internal.binary;
 
+import java.io.Externalizable;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentMap;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
 import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryInvalidTypeException;
+import org.apache.ignite.binary.BinaryNameMapper;
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.binary.BinaryReflectiveSerializer;
 import org.apache.ignite.binary.BinarySerializer;
@@ -31,7 +60,6 @@ import org.apache.ignite.cache.affinity.AffinityKey;
 import org.apache.ignite.cache.affinity.AffinityKeyMapped;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgnitionEx;
 import org.apache.ignite.internal.processors.cache.binary.BinaryMetadataKey;
 import org.apache.ignite.internal.processors.datastructures.CollocatedQueueItemKey;
 import org.apache.ignite.internal.processors.datastructures.CollocatedSetItemKey;
@@ -46,32 +74,6 @@ import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
-import java.io.Externalizable;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentMap;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
 /**
  * Binary context.
  */
@@ -80,6 +82,14 @@ public class BinaryContext {
     private static final ClassLoader dfltLdr = U.gridClassLoader();
 
     /** */
+    private static final BinaryInternalMapper DFLT_MAPPER =
+        new BinaryInternalMapper(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(true), false);
+
+    /** */
+    static final BinaryInternalMapper SIMPLE_NAME_LOWER_CASE_MAPPER =
+        new BinaryInternalMapper(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true), false);
+
+    /** */
     private final ConcurrentMap<Class<?>, BinaryClassDescriptor> descByCls = new ConcurrentHashMap8<>();
 
     /** Holds classes loaded by default class loader only. */
@@ -97,14 +107,14 @@ public class BinaryContext {
     /** */
     private final Map<Class<? extends Map>, Byte> mapTypes = new HashMap<>();
 
-    /** */
-    private final ConcurrentMap<Integer, BinaryIdMapper> mappers = new ConcurrentHashMap8<>(0);
+    /** Maps typeId to mappers. */
+    private final ConcurrentMap<Integer, BinaryInternalMapper> typeId2Mapper = new ConcurrentHashMap8<>(0);
 
     /** Affinity key field names. */
     private final ConcurrentMap<Integer, String> affKeyFieldNames = new ConcurrentHashMap8<>(0);
 
-    /** */
-    private final Map<String, BinaryIdMapper> typeMappers = new ConcurrentHashMap8<>(0);
+    /** Maps className to mapper */
+    private final ConcurrentMap<String, BinaryInternalMapper> cls2Mappers = new ConcurrentHashMap8<>(0);
 
     /** */
     private BinaryMetadataHandler metaHnd;
@@ -271,6 +281,7 @@ public class BinaryContext {
         optmMarsh.setContext(marshCtx);
 
         configure(
+            binaryCfg.getNameMapper(),
             binaryCfg.getIdMapper(),
             binaryCfg.getSerializer(),
             binaryCfg.getTypeConfigurations()
@@ -286,6 +297,7 @@ public class BinaryContext {
      * @throws BinaryObjectException In case of error.
      */
     private void configure(
+        BinaryNameMapper globalNameMapper,
         BinaryIdMapper globalIdMapper,
         BinarySerializer globalSerializer,
         Collection<BinaryTypeConfiguration> typeCfgs
@@ -306,13 +318,20 @@ public class BinaryContext {
                 if (clsName == null)
                     throw new BinaryObjectException("Class name is required for binary type configuration.");
 
+                // Resolve mapper.
                 BinaryIdMapper idMapper = globalIdMapper;
 
                 if (typeCfg.getIdMapper() != null)
                     idMapper = typeCfg.getIdMapper();
 
-                idMapper = BinaryInternalIdMapper.create(idMapper);
+                BinaryNameMapper nameMapper = globalNameMapper;
+
+                if (typeCfg.getNameMapper() != null)
+                    nameMapper = typeCfg.getNameMapper();
+
+                BinaryInternalMapper mapper = resolveMapper(nameMapper, idMapper);
 
+                // Resolve serializer.
                 BinarySerializer serializer = globalSerializer;
 
                 if (typeCfg.getSerializer() != null)
@@ -322,25 +341,25 @@ public class BinaryContext {
                     String pkgName = clsName.substring(0, clsName.length() - 2);
 
                     for (String clsName0 : classesInPackage(pkgName))
-                        descs.add(clsName0, idMapper, serializer, affFields.get(clsName0),
+                        descs.add(clsName0, mapper, serializer, affFields.get(clsName0),
                             typeCfg.isEnum(), true);
                 }
                 else
-                    descs.add(clsName, idMapper, serializer, affFields.get(clsName),
+                    descs.add(clsName, mapper, serializer, affFields.get(clsName),
                         typeCfg.isEnum(), false);
             }
         }
 
         for (TypeDescriptor desc : descs.descriptors())
-            registerUserType(desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName, desc.isEnum);
+            registerUserType(desc.clsName, desc.mapper, desc.serializer, desc.affKeyFieldName, desc.isEnum);
 
-        BinaryInternalIdMapper dfltMapper = BinaryInternalIdMapper.create(globalIdMapper);
+        BinaryInternalMapper globalMapper = resolveMapper(globalNameMapper, globalIdMapper);
 
         // Put affinity field names for unconfigured types.
         for (Map.Entry<String, String> entry : affFields.entrySet()) {
             String typeName = entry.getKey();
 
-            int typeId = dfltMapper.typeId(typeName);
+            int typeId = globalMapper.typeId(typeName);
 
             affKeyFieldNames.putIfAbsent(typeId, entry.getValue());
         }
@@ -350,6 +369,52 @@ public class BinaryContext {
     }
 
     /**
+     * @param nameMapper Name mapper.
+     * @param idMapper ID mapper.
+     * @return Mapper.
+     */
+    private static BinaryInternalMapper resolveMapper(BinaryNameMapper nameMapper, BinaryIdMapper idMapper) {
+        if ((nameMapper == null || (DFLT_MAPPER.nameMapper().equals(nameMapper)))
+            && (idMapper == null || DFLT_MAPPER.idMapper().equals(idMapper)))
+            return DFLT_MAPPER;
+
+        if (nameMapper != null && nameMapper instanceof BinaryBasicNameMapper
+            && ((BinaryBasicNameMapper)nameMapper).isSimpleName()
+            && idMapper != null && idMapper instanceof BinaryBasicIdMapper
+            && ((BinaryBasicIdMapper)idMapper).isLowerCase())
+            return SIMPLE_NAME_LOWER_CASE_MAPPER;
+
+        if (nameMapper == null)
+            nameMapper = DFLT_MAPPER.nameMapper();
+
+        if (idMapper == null)
+            idMapper = DFLT_MAPPER.idMapper();
+
+        return new BinaryInternalMapper(nameMapper, idMapper, true);
+    }
+
+    /**
+     * @return Intenal mpper used as default.
+     */
+    public static BinaryInternalMapper defaultMapper() {
+        return DFLT_MAPPER;
+    }
+
+    /**
+     * @return ID mapper used as default.
+     */
+    public static BinaryIdMapper defaultIdMapper() {
+        return DFLT_MAPPER.idMapper();
+    }
+
+    /**
+     * @return Name mapper used as default.
+     */
+    public static BinaryNameMapper defaultNameMapper() {
+        return DFLT_MAPPER.nameMapper();
+    }
+
+    /**
      * @param cls Class.
      */
     private void addSystemClassAffinityKey(Class<?> cls) {
@@ -502,7 +567,8 @@ public class BinaryContext {
         if (desc == null) {
             desc = registerClassDescriptor(cls, deserialize);
 
-            assert desc.typeId() == typeId;
+            assert desc.typeId() == typeId : "Duplicate typeId [typeId=" + typeId + ", cls=" + cls
+                + ", desc=" + desc + "]";
         }
 
         return desc;
@@ -526,7 +592,7 @@ public class BinaryContext {
                 clsName.hashCode(),
                 clsName,
                 null,
-                BinaryInternalIdMapper.defaultInstance(),
+                SIMPLE_NAME_LOWER_CASE_MAPPER,
                 null,
                 false,
                 true /* registered */
@@ -552,11 +618,13 @@ public class BinaryContext {
     private BinaryClassDescriptor registerUserClassDescriptor(Class<?> cls, boolean deserialize) {
         boolean registered;
 
-        String typeName = typeName(cls.getName());
+        final String clsName = cls.getName();
+
+        BinaryInternalMapper mapper = userTypeMapper(clsName);
 
-        BinaryIdMapper idMapper = userTypeIdMapper(typeName);
+        final String typeName = mapper.typeName(clsName);
 
-        int typeId = idMapper.typeId(typeName);
+        final int typeId = mapper.typeId(clsName);
 
         try {
             registered = marshCtx.registerClass(typeId, cls);
@@ -575,7 +643,7 @@ public class BinaryContext {
             typeId,
             typeName,
             affFieldName,
-            idMapper,
+            mapper,
             serializer,
             true,
             registered
@@ -595,7 +663,7 @@ public class BinaryContext {
 
         descByCls.put(cls, desc);
 
-        mappers.putIfAbsent(typeId, idMapper);
+        typeId2Mapper.putIfAbsent(typeId, mapper);
 
         return desc;
     }
@@ -656,9 +724,7 @@ public class BinaryContext {
      * @return Type ID.
      */
     public int typeId(String typeName) {
-        String typeName0 = typeName(typeName);
-
-        Integer id = predefinedTypeNames.get(typeName0);
+        Integer id = predefinedTypeNames.get(SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(typeName));
 
         if (id != null)
             return id;
@@ -666,7 +732,9 @@ public class BinaryContext {
         if (marshCtx.isSystemType(typeName))
             return typeName.hashCode();
 
-        return userTypeIdMapper(typeName0).typeId(typeName0);
+        BinaryInternalMapper mapper = userTypeMapper(typeName);
+
+        return mapper.typeId(typeName);
     }
 
     /**
@@ -675,27 +743,107 @@ public class BinaryContext {
      * @return Field ID.
      */
     public int fieldId(int typeId, String fieldName) {
-        return userTypeIdMapper(typeId).fieldId(typeId, fieldName);
+        BinaryInternalMapper mapper = userTypeMapper(typeId);
+
+        return mapper.fieldId(typeId, fieldName);
     }
 
     /**
      * @param typeId Type ID.
      * @return Instance of ID mapper.
      */
-    public BinaryIdMapper userTypeIdMapper(int typeId) {
-        BinaryIdMapper idMapper = mappers.get(typeId);
+    public BinaryInternalMapper userTypeMapper(int typeId) {
+        BinaryInternalMapper mapper = typeId2Mapper.get(typeId);
 
-        return idMapper != null ? idMapper : BinaryInternalIdMapper.defaultInstance();
+        return mapper != null ? mapper : SIMPLE_NAME_LOWER_CASE_MAPPER;
     }
 
     /**
-     * @param typeName Type name.
+     * @param clsName Type name.
      * @return Instance of ID mapper.
      */
-    private BinaryIdMapper userTypeIdMapper(String typeName) {
-        BinaryIdMapper idMapper = typeMappers.get(typeName);
+    private BinaryInternalMapper userTypeMapper(String clsName) {
+        BinaryInternalMapper mapper = cls2Mappers.get(clsName);
+
+        if (mapper != null)
+            return mapper;
+
+        mapper = resolveMapper(clsName, igniteCfg.getBinaryConfiguration());
+
+        BinaryInternalMapper prevMap = cls2Mappers.putIfAbsent(clsName, mapper);
+
+        if (prevMap != null && !mapper.equals(prevMap))
+            throw new IgniteException("Different mappers [clsName=" + clsName + ", newMapper=" + mapper
+            + ", prevMap=" + prevMap + "]");
+
+        prevMap = typeId2Mapper.putIfAbsent(mapper.typeId(clsName), mapper);
 
-        return idMapper != null ? idMapper : BinaryInternalIdMapper.defaultInstance();
+        if (prevMap != null && !mapper.equals(prevMap))
+            throw new IgniteException("Different mappers [clsName=" + clsName + ", newMapper=" + mapper
+                + ", prevMap=" + prevMap + "]");
+
+        return mapper;
+    }
+
+    /**
+     * @param clsName Type name.
+     * @param cfg Binary configuration.
+     * @return Mapper according to configuration.
+     */
+    private static BinaryInternalMapper resolveMapper(String clsName, BinaryConfiguration cfg) {
+        assert clsName != null;
+
+        if (cfg == null)
+            return DFLT_MAPPER;
+
+        BinaryIdMapper globalIdMapper = cfg.getIdMapper();
+        BinaryNameMapper globalNameMapper = cfg.getNameMapper();
+
+        Collection<BinaryTypeConfiguration> typeCfgs = cfg.getTypeConfigurations();
+
+        if (typeCfgs != null) {
+            for (BinaryTypeConfiguration typeCfg : typeCfgs) {
+                String typeCfgName = typeCfg.getTypeName();
+
+                // Pattern.
+                if (typeCfgName != null && typeCfgName.endsWith(".*")) {
+                    String pkgName = typeCfgName.substring(0, typeCfgName.length() - 2);
+
+                    int dotIndex = clsName.lastIndexOf('.');
+
+                    if (dotIndex > 0) {
+                        String typePkgName = clsName.substring(0, dotIndex);
+
+                        if (pkgName.equals(typePkgName)) {
+                            // Resolve mapper.
+                            BinaryIdMapper idMapper = globalIdMapper;
+
+                            if (typeCfg.getIdMapper() != null)
+                                idMapper = typeCfg.getIdMapper();
+
+                            BinaryNameMapper nameMapper = globalNameMapper;
+
+                            if (typeCfg.getNameMapper() != null)
+                                nameMapper = typeCfg.getNameMapper();
+
+                            return resolveMapper(nameMapper, idMapper);
+                        }
+                    }
+                }
+            }
+        }
+
+        return resolveMapper(globalNameMapper, globalIdMapper);
+    }
+
+    /**
+     * @param clsName Class name.
+     * @return Type name.
+     */
+    public String userTypeName(String clsName) {
+        BinaryInternalMapper mapper = userTypeMapper(clsName);
+
+        return mapper.typeName(clsName);
     }
 
     /**
@@ -728,25 +876,25 @@ public class BinaryContext {
      * @return GridBinaryClassDescriptor.
      */
     public BinaryClassDescriptor registerPredefinedType(Class<?> cls, int id, String affFieldName) {
-        String typeName = typeName(cls.getName());
+        String simpleClsName = SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(cls.getName());
 
         if (id == 0)
-            id = BinaryInternalIdMapper.defaultInstance().typeId(typeName);
+            id = SIMPLE_NAME_LOWER_CASE_MAPPER.typeId(simpleClsName);
 
         BinaryClassDescriptor desc = new BinaryClassDescriptor(
             this,
             cls,
             false,
             id,
-            typeName,
+            simpleClsName,
             affFieldName,
-            BinaryInternalIdMapper.defaultInstance(),
+            SIMPLE_NAME_LOWER_CASE_MAPPER,
             new BinaryReflectiveSerializer(),
             false,
             true /* registered */
         );
 
-        predefinedTypeNames.put(typeName, id);
+        predefinedTypeNames.put(simpleClsName, id);
         predefinedTypes.put(id, desc);
 
         descByCls.put(cls, desc);
@@ -759,7 +907,7 @@ public class BinaryContext {
 
     /**
      * @param clsName Class name.
-     * @param idMapper ID mapper.
+     * @param mapper ID mapper.
      * @param serializer Serializer.
      * @param affKeyFieldName Affinity key field name.
      * @param isEnum If enum.
@@ -767,12 +915,12 @@ public class BinaryContext {
      */
     @SuppressWarnings("ErrorNotRethrown")
     public void registerUserType(String clsName,
-        BinaryIdMapper idMapper,
+        BinaryInternalMapper mapper,
         @Nullable BinarySerializer serializer,
         @Nullable String affKeyFieldName,
         boolean isEnum)
         throws BinaryObjectException {
-        assert idMapper != null;
+        assert mapper != null;
 
         Class<?> cls = null;
 
@@ -783,15 +931,15 @@ public class BinaryContext {
             // No-op.
         }
 
-        String typeName = typeName(clsName);
+        String typeName = mapper.typeName(clsName);
 
-        int id = idMapper.typeId(typeName);
+        int id = mapper.typeId(clsName);
 
         //Workaround for IGNITE-1358
         if (predefinedTypes.get(id) != null)
             throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
 
-        if (mappers.put(id, idMapper) != null)
+        if (typeId2Mapper.put(id, mapper) != null)
             throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
 
         if (affKeyFieldName != null) {
@@ -799,7 +947,7 @@ public class BinaryContext {
                 throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
         }
 
-        typeMappers.put(typeName, idMapper);
+        cls2Mappers.put(clsName, mapper);
 
         Map<String, Integer> fieldsMeta = null;
         Collection<BinarySchema> schemas = null;
@@ -820,7 +968,7 @@ public class BinaryContext {
                 id,
                 typeName,
                 affKeyFieldName,
-                idMapper,
+                mapper,
                 serializer,
                 true,
                 true /* registered */
@@ -858,7 +1006,9 @@ public class BinaryContext {
     public BinaryFieldImpl createField(int typeId, String fieldName) {
         BinarySchemaRegistry schemaReg = schemaRegistry(typeId);
 
-        int fieldId = userTypeIdMapper(typeId).fieldId(typeId, fieldName);
+        BinaryInternalMapper mapper = userTypeMapper(typeId);
+
+        int fieldId = mapper.fieldId(typeId, fieldName);
 
         return new BinaryFieldImpl(typeId, schemaReg, fieldName, fieldId);
     }
@@ -954,43 +1104,6 @@ public class BinaryContext {
     }
 
     /**
-     * @param clsName Class name.
-     * @return Type name.
-     */
-    @SuppressWarnings("ResultOfMethodCallIgnored")
-    public static String typeName(String clsName) {
-        assert clsName != null;
-
-        int idx = clsName.lastIndexOf('$');
-
-        if (idx == clsName.length() - 1)
-            // This is a regular (not inner) class name that ends with '$'. Common use case for Scala classes.
-            idx = -1;
-        else if (idx >= 0) {
-            String typeName = clsName.substring(idx + 1);
-
-            try {
-                Integer.parseInt(typeName);
-
-                // This is an anonymous class. Don't cut off enclosing class name for it.
-                idx = -1;
-            }
-            catch (NumberFormatException ignore) {
-                // This is a lambda class.
-                if (clsName.indexOf("$$Lambda$") > 0)
-                    idx = -1;
-                else
-                    return typeName;
-            }
-        }
-
-        if (idx < 0)
-            idx = clsName.lastIndexOf('.');
-
-        return idx >= 0 ? clsName.substring(idx + 1) : clsName;
-    }
-
-    /**
      * Undeployment callback invoked when class loader is being undeployed.
      *
      * Some marshallers may want to clean their internal state that uses the undeployed class loader somehow.
@@ -1017,7 +1130,7 @@ public class BinaryContext {
          * Add type descriptor.
          *
          * @param clsName Class name.
-         * @param idMapper ID mapper.
+         * @param mapper Mapper.
          * @param serializer Serializer.
          * @param affKeyFieldName Affinity key field name.
          * @param isEnum Enum flag.
@@ -1025,14 +1138,14 @@ public class BinaryContext {
          * @throws BinaryObjectException If failed.
          */
         private void add(String clsName,
-            BinaryIdMapper idMapper,
+            BinaryInternalMapper mapper,
             BinarySerializer serializer,
             String affKeyFieldName,
             boolean isEnum,
             boolean canOverride)
             throws BinaryObjectException {
             TypeDescriptor desc = new TypeDescriptor(clsName,
-                idMapper,
+                mapper,
                 serializer,
                 affKeyFieldName,
                 isEnum,
@@ -1063,8 +1176,8 @@ public class BinaryContext {
         /** Class name. */
         private final String clsName;
 
-        /** ID mapper. */
-        private BinaryIdMapper idMapper;
+        /** Mapper. */
+        private BinaryInternalMapper mapper;
 
         /** Serializer. */
         private BinarySerializer serializer;
@@ -1082,16 +1195,16 @@ public class BinaryContext {
          * Constructor.
          *
          * @param clsName Class name.
-         * @param idMapper ID mapper.
+         * @param mapper ID mapper.
          * @param serializer Serializer.
          * @param affKeyFieldName Affinity key field name.
          * @param isEnum Enum type.
          * @param canOverride Whether this descriptor can be override.
          */
-        private TypeDescriptor(String clsName, BinaryIdMapper idMapper, BinarySerializer serializer,
-            String affKeyFieldName, boolean isEnum, boolean canOverride) {
+        private TypeDescriptor(String clsName, BinaryInternalMapper mapper,
+            BinarySerializer serializer, String affKeyFieldName, boolean isEnum, boolean canOverride) {
             this.clsName = clsName;
-            this.idMapper = idMapper;
+            this.mapper = mapper;
             this.serializer = serializer;
             this.affKeyFieldName = affKeyFieldName;
             this.isEnum = isEnum;
@@ -1108,7 +1221,7 @@ public class BinaryContext {
             assert clsName.equals(other.clsName);
 
             if (canOverride) {
-                idMapper = other.idMapper;
+                mapper = other.mapper;
                 serializer = other.serializer;
                 affKeyFieldName = other.affKeyFieldName;
                 isEnum = other.isEnum;

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index 180e20a..fd4a4d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -17,6 +17,11 @@
 
 package org.apache.ignite.internal.binary;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
@@ -31,12 +36,6 @@ import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
 import org.jetbrains.annotations.Nullable;
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.nio.ByteBuffer;
-
 /**
  * Binary enum object.
  */

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalIdMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalIdMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalIdMapper.java
deleted file mode 100644
index 14d7d6f..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalIdMapper.java
+++ /dev/null
@@ -1,161 +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.binary;
-
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Internal ID mapper. Mimics ID mapper interface, but provides default implementation and offers slightly better
- * performance on micro-level in default case because it doesn't need virtual calls.
- */
-public class BinaryInternalIdMapper implements BinaryIdMapper {
-    /** Maximum lower-case character. */
-    private static final char MAX_LOWER_CASE_CHAR = 0x7e;
-
-    /** Cached lower-case characters. */
-    private static final char[] LOWER_CASE_CHARS;
-
-    /** Default implementation. */
-    private static final BinaryInternalIdMapper DFLT = new BinaryInternalIdMapper();
-
-    /**
-     * Static initializer.
-     */
-    static {
-        LOWER_CASE_CHARS = new char[MAX_LOWER_CASE_CHAR + 1];
-
-        for (char c = 0; c <= MAX_LOWER_CASE_CHAR; c++)
-            LOWER_CASE_CHARS[c] = Character.toLowerCase(c);
-    }
-
-    /**
-     * Get default instance.
-     *
-     * @return Default instance.
-     */
-    public static BinaryInternalIdMapper defaultInstance() {
-        return DFLT;
-    }
-
-    /**
-     * Create internal mapper.
-     *
-     * @param mapper Public mapper.
-     * @return Internal mapper.
-     */
-    public static BinaryInternalIdMapper create(@Nullable BinaryIdMapper mapper) {
-        return mapper == null ? DFLT : new Wrapper(mapper);
-    }
-
-    /**
-     * Private constructor.
-     */
-    protected BinaryInternalIdMapper() {
-        // No-op.
-    }
-
-    /**
-     * Get type ID.
-     *
-     * @param typeName Type name.
-     * @return Type ID.
-     */
-    public int typeId(String typeName) {
-        assert typeName != null;
-
-        return lowerCaseHashCode(typeName, true);
-    }
-
-    /**
-     * Get field ID.
-     *
-     * @param typeId Type ID.
-     * @param fieldName Field name.
-     * @return Field ID.
-     */
-    public int fieldId(int typeId, String fieldName) {
-        assert fieldName != null;
-
-        return lowerCaseHashCode(fieldName, false);
-    }
-
-    /**
-     * Routine to calculate string hash code an
-     *
-     * @param str String.
-     * @param type {@code True} if this is type name, false otherwise.
-     * @return Hash code for given string converted to lower case.
-     */
-    private static int lowerCaseHashCode(String str, boolean type) {
-        int len = str.length();
-
-        int h = 0;
-
-        for (int i = 0; i < len; i++) {
-            int c = str.charAt(i);
-
-            c = c <= MAX_LOWER_CASE_CHAR ? LOWER_CASE_CHARS[c] : Character.toLowerCase(c);
-
-            h = 31 * h + c;
-        }
-
-        if (h != 0)
-            return h;
-        else {
-            String what = type ? "type" : "field";
-
-            throw new BinaryObjectException("Default binary ID mapper resolved " + what + " ID to zero " +
-                "(either change " + what + "'s name or use custom ID mapper) [name=" + str + ']');
-        }
-    }
-
-    /**
-     * Wrapping ID mapper.
-     */
-    private static class Wrapper extends BinaryInternalIdMapper {
-        /** Delegate. */
-        private final BinaryIdMapper mapper;
-
-        /**
-         * Constructor.
-         *
-         * @param mapper Delegate.
-         */
-        private Wrapper(BinaryIdMapper mapper) {
-            assert mapper != null;
-
-            this.mapper = mapper;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int typeId(String typeName) {
-            int id = mapper.typeId(typeName);
-
-            return id != 0 ? id : super.typeId(typeName);
-        }
-
-        /** {@inheritDoc} */
-        @Override public int fieldId(int typeId, String fieldName) {
-            int id = mapper.fieldId(typeId, fieldName);
-
-            return id != 0 ? id : super.fieldId(typeId, fieldName);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalMapper.java
new file mode 100644
index 0000000..1adc8c7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalMapper.java
@@ -0,0 +1,131 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Internal binary mapper.
+ */
+public class BinaryInternalMapper {
+    /** */
+    private final BinaryNameMapper nameMapper;
+
+    /** */
+    private final BinaryIdMapper idMapper;
+
+    /** */
+    private boolean checkOnZeroId;
+
+    /**
+     * @param nameMapper Name mapper.
+     * @param idMapper Id mapper.
+     * @param checkOnZeroId Whether checks on zero id or not.
+     */
+    public BinaryInternalMapper(BinaryNameMapper nameMapper, BinaryIdMapper idMapper, boolean checkOnZeroId) {
+        assert nameMapper != null;
+        assert idMapper != null;
+
+        this.nameMapper = nameMapper;
+        this.idMapper = idMapper;
+        this.checkOnZeroId = checkOnZeroId;
+    }
+
+    /**
+     * @return Name mapper.
+     */
+    public BinaryNameMapper nameMapper() {
+        return nameMapper;
+    }
+
+    /**
+     * @return ID mapper.
+     */
+    public BinaryIdMapper idMapper() {
+        return idMapper;
+    }
+
+    /**
+     * @param clsName Class name.
+     * @return Type ID.
+     */
+    public int typeId(String clsName) {
+        int id = idMapper.typeId(nameMapper.typeName(clsName));
+
+        if (!checkOnZeroId)
+            return id;
+
+        return id != 0 ? id : BinaryContext.SIMPLE_NAME_LOWER_CASE_MAPPER.typeId(clsName);
+    }
+
+    /**
+     * @param typeId Type ID.
+     * @param fieldName Field name.
+     * @return Field ID.
+     */
+    public int fieldId(int typeId, String fieldName) {
+        int id = idMapper.fieldId(typeId, nameMapper.fieldName(fieldName));
+
+        if (!checkOnZeroId)
+            return id;
+
+        return id != 0 ? id : BinaryContext.SIMPLE_NAME_LOWER_CASE_MAPPER.fieldId(typeId, fieldName);
+    }
+
+    /**
+     * @param clsName Class name.
+     * @return Type name.
+     */
+    public String typeName(String clsName) {
+        return nameMapper.typeName(clsName);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (!(o instanceof BinaryInternalMapper))
+            return false;
+
+        BinaryInternalMapper mapper = (BinaryInternalMapper)o;
+
+        return checkOnZeroId == mapper.checkOnZeroId 
+            && idMapper.equals(mapper.idMapper) 
+            && nameMapper.equals(mapper.nameMapper);
+
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = nameMapper.hashCode();
+        
+        res = 31 * res + idMapper.hashCode();
+        
+        res = 31 * res + (checkOnZeroId ? 1 : 0);
+        
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(BinaryInternalMapper.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
index 54f2b13..e8574ef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
@@ -17,12 +17,6 @@
 
 package org.apache.ignite.internal.binary;
 
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryWriter;
-import org.jetbrains.annotations.Nullable;
-
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
@@ -33,6 +27,10 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryWriter;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Writer for meta data collection.
@@ -44,8 +42,8 @@ class BinaryMetadataCollector implements BinaryWriter {
     /** Type name. */
     private final String typeName;
 
-    /** ID mapper. */
-    private final BinaryIdMapper idMapper;
+    /** Name mapper. */
+    private final BinaryInternalMapper mapper;
 
     /** Collected metadata. */
     private final Map<String, Integer> meta = new HashMap<>();
@@ -58,12 +56,12 @@ class BinaryMetadataCollector implements BinaryWriter {
      *
      * @param typeId Type ID.
      * @param typeName Type name.
-     * @param idMapper ID mapper.
+     * @param mapper Name mapper.
      */
-    BinaryMetadataCollector(int typeId, String typeName, BinaryIdMapper idMapper) {
+    BinaryMetadataCollector(int typeId, String typeName, BinaryInternalMapper mapper) {
         this.typeId = typeId;
         this.typeName = typeName;
-        this.idMapper = idMapper;
+        this.mapper = mapper;
     }
 
     /**
@@ -272,6 +270,6 @@ class BinaryMetadataCollector implements BinaryWriter {
             );
         }
 
-        schemaBuilder.addField(idMapper.fieldId(typeId, name));
+        schemaBuilder.addField(mapper.fieldId(typeId, name));
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
index 8f9cc92..607dabc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
@@ -26,9 +26,7 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.util.UUID;
-
 import org.apache.ignite.binary.BinaryCollectionFactory;
-import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryInvalidTypeException;
 import org.apache.ignite.binary.BinaryMapFactory;
 import org.apache.ignite.binary.BinaryObject;
@@ -40,6 +38,7 @@ import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import static org.apache.ignite.internal.binary.GridBinaryMarshaller.BINARY_OBJ;
 import static org.apache.ignite.internal.binary.GridBinaryMarshaller.BOOLEAN;
 import static org.apache.ignite.internal.binary.GridBinaryMarshaller.BOOLEAN_ARR;
 import static org.apache.ignite.internal.binary.GridBinaryMarshaller.BYTE;
@@ -69,7 +68,6 @@ import static org.apache.ignite.internal.binary.GridBinaryMarshaller.NULL;
 import static org.apache.ignite.internal.binary.GridBinaryMarshaller.OBJ;
 import static org.apache.ignite.internal.binary.GridBinaryMarshaller.OBJ_ARR;
 import static org.apache.ignite.internal.binary.GridBinaryMarshaller.OPTM_MARSH;
-import static org.apache.ignite.internal.binary.GridBinaryMarshaller.BINARY_OBJ;
 import static org.apache.ignite.internal.binary.GridBinaryMarshaller.SHORT;
 import static org.apache.ignite.internal.binary.GridBinaryMarshaller.SHORT_ARR;
 import static org.apache.ignite.internal.binary.GridBinaryMarshaller.STRING;
@@ -115,8 +113,8 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
     /** Footer end. */
     private final int footerLen;
 
-    /** ID mapper. */
-    private final BinaryIdMapper idMapper;
+    /** Mapper. */
+    private final BinaryInternalMapper mapper;
 
     /** Schema Id. */
     private final int schemaId;
@@ -247,7 +245,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
                 dataStart = start + DFLT_HDR_LEN;
             }
 
-            idMapper = userType ? ctx.userTypeIdMapper(typeId) : BinaryInternalIdMapper.defaultInstance();
+            mapper = userType ? ctx.userTypeMapper(typeId) : BinaryContext.defaultMapper();
             schema = BinaryUtils.hasSchema(flags) ? getOrCreateSchema() : null;
         }
         else {
@@ -256,7 +254,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
             rawOff = 0;
             footerStart = 0;
             footerLen = 0;
-            idMapper = null;
+            mapper = null;
             schemaId = 0;
             userType = false;
             fieldIdLen = 0;
@@ -1653,7 +1651,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
     private int fieldId(String name) {
         assert name != null;
 
-        return idMapper.fieldId(typeId, name);
+        return mapper.fieldId(typeId, name);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index 6e05b40..877a2db 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -17,16 +17,6 @@
 
 package org.apache.ignite.internal.binary;
 
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
-import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
-import org.apache.ignite.internal.util.typedef.internal.A;
-import org.jetbrains.annotations.Nullable;
-
 import java.io.IOException;
 import java.io.ObjectOutput;
 import java.lang.reflect.InvocationTargetException;
@@ -37,6 +27,14 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
+import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.jetbrains.annotations.Nullable;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 
@@ -77,8 +75,8 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
     /** Amount of written fields. */
     private int fieldCnt;
 
-    /** ID mapper. */
-    private BinaryIdMapper idMapper;
+    /** */
+    private BinaryInternalMapper mapper;
 
     /**
      * @param ctx Context.
@@ -1642,10 +1640,12 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
         if (rawOffPos != 0)
             throw new BinaryObjectException("Individual field can't be written after raw writer is acquired.");
 
-        if (idMapper == null)
-            idMapper = ctx.userTypeIdMapper(typeId);
+        if (mapper == null)
+            mapper = ctx.userTypeMapper(typeId);
+
+        assert mapper != null;
 
-        int id = idMapper.fieldId(typeId, fieldName);
+        int id = mapper.fieldId(typeId, fieldName);
 
         writeFieldId(id);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
index a095242..6e5a621 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
@@ -17,17 +17,15 @@
 
 package org.apache.ignite.internal.binary.builder;
 
+import java.util.Collection;
+import java.util.IdentityHashMap;
+import java.util.Map;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.internal.binary.BinaryMetadata;
 import org.apache.ignite.internal.binary.BinaryObjectExImpl;
+import org.apache.ignite.internal.binary.BinaryUtils;
 import org.apache.ignite.internal.binary.BinaryWriterExImpl;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryContext;
-import org.apache.ignite.internal.binary.BinaryUtils;
-
-import java.util.Collection;
-import java.util.IdentityHashMap;
-import java.util.Map;
 
 /**
  *
@@ -100,8 +98,10 @@ class BinaryBuilderSerializer {
         }
 
         if (val.getClass().isEnum()) {
-            String typeName = BinaryContext.typeName(val.getClass().getName());
-            int typeId = writer.context().typeId(typeName);
+            String clsName = val.getClass().getName();
+
+            int typeId = writer.context().typeId(clsName);
+            String typeName = writer.context().userTypeName(clsName);
 
             BinaryMetadata meta = new BinaryMetadata(typeId, typeName, null, null, null, true);
             writer.context().updateMetadata(typeId, meta);

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
index 8353cdb..e2290d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
@@ -90,7 +90,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
      * @param ctx Binary context.
      */
     public BinaryObjectBuilderImpl(BinaryContext ctx, String clsName) {
-        this(ctx, ctx.typeId(clsName), BinaryContext.typeName(clsName));
+        this(ctx, ctx.typeId(clsName), ctx.userTypeName(clsName));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index c9d6dad..a21331e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -22,9 +22,10 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CountDownLatch;
@@ -39,16 +40,20 @@ import javax.cache.processor.MutableEntry;
 import org.apache.ignite.IgniteBinary;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
 import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.IgniteNodeAttributes;
+import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.BinaryEnumObjectImpl;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.binary.BinaryMetadata;
@@ -57,12 +62,12 @@ import org.apache.ignite.internal.binary.BinaryObjectEx;
 import org.apache.ignite.internal.binary.BinaryObjectImpl;
 import org.apache.ignite.internal.binary.BinaryObjectOffheapImpl;
 import org.apache.ignite.internal.binary.BinaryTypeImpl;
-import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
 import org.apache.ignite.internal.binary.streams.BinaryInputStream;
 import org.apache.ignite.internal.binary.streams.BinaryOffheapInputStream;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
 import org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter;
@@ -92,11 +97,16 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.spi.IgniteNodeValidationResult;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 import sun.misc.Unsafe;
 
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
+import static org.apache.ignite.IgniteSystemProperties.getBoolean;
+
 /**
  * Binary processor implementation.
  */
@@ -106,6 +116,9 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     private static final Unsafe UNSAFE = GridUnsafe.unsafe();
 
     /** */
+    public static final IgniteProductVersion BINARY_CFG_CHECK_SINCE = IgniteProductVersion.fromString("1.5.6");
+
+    /** */
     private final CountDownLatch startLatch = new CountDownLatch(1);
 
     /** */
@@ -204,16 +217,46 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
                 }
             };
 
-            BinaryMarshaller pMarh0 = (BinaryMarshaller)marsh;
+            BinaryMarshaller bMarsh0 = (BinaryMarshaller)marsh;
 
             binaryCtx = new BinaryContext(metaHnd, ctx.config(), ctx.log(BinaryContext.class));
 
-            IgniteUtils.invoke(BinaryMarshaller.class, pMarh0, "setBinaryContext", binaryCtx,
-                ctx.config());
+            IgniteUtils.invoke(BinaryMarshaller.class, bMarsh0, "setBinaryContext", binaryCtx, ctx.config());
 
             binaryMarsh = new GridBinaryMarshaller(binaryCtx);
 
             binaries = new IgniteBinaryImpl(ctx, this);
+
+            if (!getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK)) {
+                BinaryConfiguration bCfg = ctx.config().getBinaryConfiguration();
+
+                if (bCfg != null) {
+                    Map<String, Object> map = new HashMap<>();
+
+                    map.put("globIdMapper", bCfg.getIdMapper() != null ? bCfg.getIdMapper().getClass().getName() : null);
+                    map.put("globSerializer", bCfg.getSerializer() != null ? bCfg.getSerializer().getClass() : null);
+                    map.put("compactFooter", bCfg.isCompactFooter());
+
+                    if (bCfg.getTypeConfigurations() != null) {
+                        Map<Object, Object> typeCfgsMap = new HashMap<>();
+
+                        for (BinaryTypeConfiguration c : bCfg.getTypeConfigurations()) {
+                            typeCfgsMap.put(
+                                c.getTypeName() != null,
+                                Arrays.asList(
+                                    c.getIdMapper() != null ? c.getIdMapper().getClass() : null,
+                                    c.getSerializer() != null ? c.getSerializer().getClass() : null,
+                                    c.isEnum()
+                                )
+                            );
+                        }
+
+                        map.put("typeCfgs", typeCfgsMap);
+                    }
+
+                    ctx.addNodeAttribute(IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION, map);
+                }
+            }
         }
     }
 
@@ -294,6 +337,37 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     }
 
     /** {@inheritDoc} */
+    @Override public void onKernalStart() throws IgniteCheckedException {
+        super.onKernalStart();
+
+        if (!getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK) && marsh instanceof BinaryMarshaller) {
+            BinaryConfiguration bcfg = ctx.config().getBinaryConfiguration();
+
+            for (ClusterNode rmtNode : ctx.discovery().remoteNodes()) {
+                if (rmtNode.version().compareTo(BINARY_CFG_CHECK_SINCE) < 0) {
+                    if (bcfg == null || bcfg.getNameMapper() == null) {
+                        throw new IgniteCheckedException("When BinaryMarshaller is used and topology contains old " +
+                            "nodes, then " + BinaryBasicNameMapper.class.getName() + " mapper have to be set " +
+                            "explicitely into binary configuration and 'simpleName' property of the mapper " +
+                            "have to be set to 'true'.");
+                    }
+
+                    if (!(bcfg.getNameMapper() instanceof BinaryBasicNameMapper)
+                        || !((BinaryBasicNameMapper)bcfg.getNameMapper()).isSimpleName()) {
+                        U.quietAndWarn(log, "When BinaryMarshaller is used and topology contains old" +
+                            " nodes, it's strongly recommended, to set " + BinaryBasicNameMapper.class.getName() +
+                            " mapper into binary configuration explicitely " +
+                            " and 'simpleName' property of the mapper set to 'true' (fix configuration or set " +
+                            "-D" + IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK + "=true system property).");
+                    }
+
+                    break;
+                }
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public void onKernalStop(boolean cancel) {
         super.onKernalStop(cancel);
 
@@ -578,10 +652,10 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
 
     /** {@inheritDoc} */
     @Override public BinaryObject buildEnum(String typeName, int ord) throws IgniteException {
-        typeName = BinaryContext.typeName(typeName);
-
         int typeId = binaryCtx.typeId(typeName);
 
+        typeName = binaryCtx.userTypeName(typeName);
+
         updateMetadata(typeId, typeName, null, null, true);
 
         return new BinaryEnumObjectImpl(binaryCtx, typeId, null, ord);
@@ -784,6 +858,37 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
         return marshalToBinary(obj);
     }
 
+    /** {@inheritDoc} */
+    @Nullable @Override public IgniteNodeValidationResult validateNode(ClusterNode rmtNode) {
+        IgniteNodeValidationResult res = super.validateNode(rmtNode);
+
+        if (res != null)
+            return res;
+
+        if (getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK) || !(marsh instanceof BinaryMarshaller))
+            return null;
+
+        Object rmtBinaryCfg = rmtNode.attribute(IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION);
+
+        if (rmtNode.version().compareTo(BINARY_CFG_CHECK_SINCE) < 0)
+            return null;
+
+        ClusterNode locNode = ctx.discovery().localNode();
+
+        Object locBinaryCfg = locNode.attribute(IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION);
+
+        if (!F.eq(locBinaryCfg, rmtBinaryCfg)) {
+            String msg = "Local node's binary configuration is not equal to remote node's binary configuration " +
+                "[locNodeId=%s, rmtNodeId=%s, locBinaryCfg=%s, rmtBinaryCfg=%s]";
+
+            return new IgniteNodeValidationResult(rmtNode.id(),
+                String.format(msg, locNode.id(), rmtNode.id(), locBinaryCfg, rmtBinaryCfg),
+                String.format(msg, rmtNode.id(), locNode.id(), rmtBinaryCfg, locBinaryCfg));
+        }
+
+        return null;
+    }
+
     /**
      * Processor responsible for metadata update.
      */


[02/28] ignite git commit: IGNITE-2191 - Support classes with the same simple name for Binary marshaller - Fixes #398.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
index 93c80d3..33656fb 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
@@ -43,6 +43,7 @@ import org.yardstickframework.BenchmarkServer;
 import org.yardstickframework.BenchmarkUtils;
 
 import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER;
 
 /**
  * Standalone Ignite node.
@@ -150,6 +151,8 @@ public class IgniteNode implements BenchmarkServer {
         c.setCommunicationSpi(commSpi);
 
         ignite = IgniteSpring.start(c, appCtx);
+
+        BenchmarkUtils.println("Configured marshaller: " + ignite.cluster().localNode().attribute(ATTR_MARSHALLER));
     }
 
     /**


[22/28] ignite git commit: Updated CacheInterceptor JavaDoc

Posted by vo...@apache.org.
Updated CacheInterceptor JavaDoc


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

Branch: refs/heads/ignite-2508
Commit: e6acce66d84b0148aa6c4a49541ce9907d064d47
Parents: 57194e2
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Tue Feb 2 16:40:44 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Tue Feb 2 16:40:44 2016 -0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/ignite/cache/CacheInterceptor.java | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e6acce66/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
index 103fe57..ffb3c2b 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
@@ -63,6 +63,11 @@ public interface CacheInterceptor<K, V> extends Serializable {
      * from sensitive synchronization blocks.
      * <p>
      * This method should not throw any exception.
+     * <p>
+     * <b>IMPORTANT:</b> for this method to take affect, {@code newVal} and
+     * the returned value have to be different instances. I.e., you should
+     * not mutate {@code newVal} directly, but instead create a copy, update
+     * it and then return from the interceptor.
      *
      * @param entry Old entry. If {@link CacheConfiguration#isCopyOnRead()} is {@code true}, then is copy.
      * @param newVal New value.


[18/28] ignite git commit: ignite-2080 Data alignment issues with Unsafe

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
index 2867b0a..1f7a53c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
@@ -18,15 +18,67 @@
 package org.apache.ignite.internal.util;
 
 import java.lang.reflect.Field;
+import java.nio.ByteOrder;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import sun.misc.Unsafe;
 
 /**
- * Provides handle on Unsafe class from SUN which cannot be instantiated directly.
+ * <p>Wrapper for {@link sun.misc.Unsafe} class.</p>
+ *
+ * <p>
+ * The following statements for memory access operations  are true:
+ * <ul>
+ * <li>All {@code putXxx(long addr, xxx val)}, {@code getXxx(long addr)}, {@code putXxx(byte[] arr, long off, xxx val)},
+ * {@code getXxx(byte[] arr, long off)} and corresponding methods with {@code LE} suffix are alignment aware
+ * and can be safely used with unaligned pointers.</li>
+ * <li>All {@code putXxxField(Object obj, long fieldOff, xxx val)} and {@code getXxxField(Object obj, long fieldOff)}
+ * methods are not alignment aware and can't be safely used with unaligned pointers. This methods can be safely used
+ * for object field values access because all object fields addresses are aligned.</li>
+ * <li>All {@code putXxxLE(...)} and {@code getXxxLE(...)} methods assumes that byte order is fixed as little-endian
+ * while native byte order is big-endian. So it is client code responsibility to check native byte order before
+ * invoking of this methods.</li>
+ * </ul>
+ * </p>
  */
-public class GridUnsafe {
+public abstract class GridUnsafe {
+    /** Unsafe. */
+    private static final Unsafe UNSAFE = unsafe();
+
+    /** Unaligned flag. */
+    private static final boolean UNALIGNED = unaligned();
+
+    /** Big endian. */
+    public static final boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
+
+    /** Address size. */
+    public static final int ADDR_SIZE = UNSAFE.addressSize();
+
+    /** */
+    public static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
+
+    /** */
+    public static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
+
+    /** */
+    public static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
+
+    /** */
+    public static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
+
+    /** */
+    public static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
+
+    /** */
+    public static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
+
+    /** */
+    public static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
+
+    /** */
+    public static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
+
     /**
      * Ensure singleton.
      */
@@ -35,9 +87,1130 @@ public class GridUnsafe {
     }
 
     /**
+     * Gets boolean value from object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @return Boolean value from object field.
+     */
+    public static boolean getBooleanField(Object obj, long fieldOff) {
+        return UNSAFE.getBoolean(obj, fieldOff);
+    }
+
+    /**
+     * Stores boolean value into object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @param val Value.
+     */
+    public static void putBooleanField(Object obj, long fieldOff, boolean val) {
+        UNSAFE.putBoolean(obj, fieldOff, val);
+    }
+
+    /**
+     * Gets byte value from object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @return Byte value from object field.
+     */
+    public static byte getByteField(Object obj, long fieldOff) {
+        return UNSAFE.getByte(obj, fieldOff);
+    }
+
+    /**
+     * Stores byte value into object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @param val Value.
+     */
+    public static void putByteField(Object obj, long fieldOff, byte val) {
+        UNSAFE.putByte(obj, fieldOff, val);
+    }
+
+    /**
+     * Gets short value from object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @return Short value from object field.
+     */
+    public static short getShortField(Object obj, long fieldOff) {
+        return UNSAFE.getShort(obj, fieldOff);
+    }
+
+    /**
+     * Stores short value into object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @param val Value.
+     */
+    public static void putShortField(Object obj, long fieldOff, short val) {
+        UNSAFE.putShort(obj, fieldOff, val);
+    }
+
+    /**
+     * Gets char value from object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @return Char value from object field.
+     */
+    public static char getCharField(Object obj, long fieldOff) {
+        return UNSAFE.getChar(obj, fieldOff);
+    }
+
+    /**
+     * Stores char value into object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @param val Value.
+     */
+    public static void putCharField(Object obj, long fieldOff, char val) {
+        UNSAFE.putChar(obj, fieldOff, val);
+    }
+
+    /**
+     * Gets integer value from object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @return Integer value from object field.
+     */
+    public static int getIntField(Object obj, long fieldOff) {
+        return UNSAFE.getInt(obj, fieldOff);
+    }
+
+    /**
+     * Stores integer value into object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @param val Value.
+     */
+    public static void putIntField(Object obj, long fieldOff, int val) {
+        UNSAFE.putInt(obj, fieldOff, val);
+    }
+
+    /**
+     * Gets long value from object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @return Long value from object field.
+     */
+    public static long getLongField(Object obj, long fieldOff) {
+        return UNSAFE.getLong(obj, fieldOff);
+    }
+
+    /**
+     * Stores long value into object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @param val Value.
+     */
+    public static void putLongField(Object obj, long fieldOff, long val) {
+        UNSAFE.putLong(obj, fieldOff, val);
+    }
+
+    /**
+     * Gets float value from object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @return Float value from object field.
+     */
+    public static float getFloatField(Object obj, long fieldOff) {
+        return UNSAFE.getFloat(obj, fieldOff);
+    }
+
+    /**
+     * Stores float value into object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @param val Value.
+     */
+    public static void putFloatField(Object obj, long fieldOff, float val) {
+        UNSAFE.putFloat(obj, fieldOff, val);
+    }
+
+    /**
+     * Gets double value from object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @return Double value from object field.
+     */
+    public static double getDoubleField(Object obj, long fieldOff) {
+        return UNSAFE.getDouble(obj, fieldOff);
+    }
+
+    /**
+     * Stores double value into object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @param val Value.
+     */
+    public static void putDoubleField(Object obj, long fieldOff, double val) {
+        UNSAFE.putDouble(obj, fieldOff, val);
+    }
+
+    /**
+     * Gets reference from object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @return Reference from object field.
+     */
+    public static Object getObjectField(Object obj, long fieldOff) {
+        return UNSAFE.getObject(obj, fieldOff);
+    }
+
+    /**
+     * Stores reference value into object field.
+     *
+     * @param obj Object.
+     * @param fieldOff Field offset.
+     * @param val Value.
+     */
+    public static void putObjectField(Object obj, long fieldOff, Object val) {
+        UNSAFE.putObject(obj, fieldOff, val);
+    }
+
+    /**
+     * Gets boolean value from byte array.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Boolean value from byte array.
+     */
+    public static boolean getBoolean(byte[] arr, long off) {
+        return UNSAFE.getBoolean(arr, off);
+    }
+
+    /**
+     * Stores boolean value into byte array.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putBoolean(byte[] arr, long off, boolean val) {
+        UNSAFE.putBoolean(arr, off, val);
+    }
+
+    /**
+     * Gets byte value from byte array.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Byte value from byte array.
+     */
+    public static byte getByte(byte[] arr, long off) {
+        return UNSAFE.getByte(arr, off);
+    }
+
+    /**
+     * Stores byte value into byte array.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putByte(byte[] arr, long off, byte val) {
+        UNSAFE.putByte(arr, off, val);
+    }
+
+    /**
+     * Gets short value from byte array. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Short value from byte array.
+     */
+    public static short getShort(byte[] arr, long off) {
+        return UNALIGNED ? UNSAFE.getShort(arr, off) : getShortByByte(arr, off, BIG_ENDIAN);
+    }
+
+    /**
+     * Stores short value into byte array. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putShort(byte[] arr, long off, short val) {
+        if (UNALIGNED)
+            UNSAFE.putShort(arr, off, val);
+        else
+            putShortByByte(arr, off, val, BIG_ENDIAN);
+    }
+
+    /**
+     * Gets char value from byte array. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Char value from byte array.
+     */
+    public static char getChar(byte[] arr, long off) {
+        return UNALIGNED ? UNSAFE.getChar(arr, off) : getCharByByte(arr, off, BIG_ENDIAN);
+    }
+
+    /**
+     * Stores char value into byte array. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putChar(byte[] arr, long off, char val) {
+        if (UNALIGNED)
+            UNSAFE.putChar(arr, off, val);
+        else
+            putCharByByte(arr, off, val, BIG_ENDIAN);
+    }
+
+    /**
+     * Gets integer value from byte array. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Integer value from byte array.
+     */
+    public static int getInt(byte[] arr, long off) {
+        return UNALIGNED ? UNSAFE.getInt(arr, off) : getIntByByte(arr, off, BIG_ENDIAN);
+    }
+
+    /**
+     * Stores integer value into byte array. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putInt(byte[] arr, long off, int val) {
+        if (UNALIGNED)
+            UNSAFE.putInt(arr, off, val);
+        else
+            putIntByByte(arr, off, val, BIG_ENDIAN);
+    }
+
+    /**
+     * Gets long value from byte array. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Long value from byte array.
+     */
+    public static long getLong(byte[] arr, long off) {
+        return UNALIGNED ? UNSAFE.getLong(arr, off) : getLongByByte(arr, off, BIG_ENDIAN);
+    }
+
+    /**
+     * Stores long value into byte array. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putLong(byte[] arr, long off, long val) {
+        if (UNALIGNED)
+            UNSAFE.putLong(arr, off, val);
+        else
+            putLongByByte(arr, off, val, BIG_ENDIAN);
+    }
+
+    /**
+     * Gets float value from byte array. Alignment aware.
+     *
+     * @param arr Object.
+     * @param off Offset.
+     * @return Float value from byte array.
+     */
+    public static float getFloat(byte[] arr, long off) {
+        return UNALIGNED ? UNSAFE.getFloat(arr, off) : Float.intBitsToFloat(getIntByByte(arr, off, BIG_ENDIAN));
+    }
+
+    /**
+     * Stores float value into byte array. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putFloat(byte[] arr, long off, float val) {
+        if (UNALIGNED)
+            UNSAFE.putFloat(arr, off, val);
+        else
+            putIntByByte(arr, off, Float.floatToIntBits(val), BIG_ENDIAN);
+    }
+
+    /**
+     * Gets double value from byte array. Alignment aware.
+     *
+     * @param arr byte array.
+     * @param off Offset.
+     * @return Double value from byte array. Alignment aware.
+     */
+    public static double getDouble(byte[] arr, long off) {
+        return UNALIGNED ? UNSAFE.getDouble(arr, off) : Double.longBitsToDouble(getLongByByte(arr, off, BIG_ENDIAN));
+    }
+
+    /**
+     * Stores double value into byte array. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putDouble(byte[] arr, long off, double val) {
+        if (UNALIGNED)
+            UNSAFE.putDouble(arr, off, val);
+        else
+            putLongByByte(arr, off, Double.doubleToLongBits(val), BIG_ENDIAN);
+    }
+
+    /**
+     * Gets short value from byte array assuming that value stored in little-endian byte order and native byte order
+     * is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Short value from byte array.
+     */
+    public static short getShortLE(byte[] arr, long off) {
+        return UNALIGNED ? Short.reverseBytes(UNSAFE.getShort(arr, off)) : getShortByByte(arr, off, false);
+    }
+
+    /**
+     * Stores short value into byte array assuming that value should be stored in little-endian byte order and native
+     * byte order is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putShortLE(byte[] arr, long off, short val) {
+        if (UNALIGNED)
+            UNSAFE.putShort(arr, off, Short.reverseBytes(val));
+        else
+            putShortByByte(arr, off, val, false);
+    }
+
+    /**
+     * Gets char value from byte array assuming that value stored in little-endian byte order and native byte order
+     * is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Char value from byte array.
+     */
+    public static char getCharLE(byte[] arr, long off) {
+        return UNALIGNED ? Character.reverseBytes(UNSAFE.getChar(arr, off)) : getCharByByte(arr, off, false);
+    }
+
+    /**
+     * Stores char value into byte array assuming that value should be stored in little-endian byte order and native
+     * byte order is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putCharLE(byte[] arr, long off, char val) {
+        if (UNALIGNED)
+            UNSAFE.putChar(arr, off, Character.reverseBytes(val));
+        else
+            putCharByByte(arr, off, val, false);
+    }
+
+    /**
+     * Gets integer value from byte array assuming that value stored in little-endian byte order and native byte order
+     * is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Integer value from byte array.
+     */
+    public static int getIntLE(byte[] arr, long off) {
+        return UNALIGNED ? Integer.reverseBytes(UNSAFE.getInt(arr, off)) : getIntByByte(arr, off, false);
+    }
+
+    /**
+     * Stores integer value into byte array assuming that value should be stored in little-endian byte order and
+     * native byte order is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putIntLE(byte[] arr, long off, int val) {
+        if (UNALIGNED)
+            UNSAFE.putInt(arr, off, Integer.reverseBytes(val));
+        else
+            putIntByByte(arr, off, val, false);
+    }
+
+    /**
+     * Gets long value from byte array assuming that value stored in little-endian byte order and native byte order
+     * is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Long value from byte array.
+     */
+    public static long getLongLE(byte[] arr, long off) {
+        return UNALIGNED ? Long.reverseBytes(UNSAFE.getLong(arr, off)) : getLongByByte(arr, off, false);
+    }
+
+    /**
+     * Stores long value into byte array assuming that value should be stored in little-endian byte order and native
+     * byte order is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putLongLE(byte[] arr, long off, long val) {
+        if (UNALIGNED)
+            UNSAFE.putLong(arr, off, Long.reverseBytes(val));
+        else
+            putLongByByte(arr, off, val, false);
+    }
+
+    /**
+     * Gets float value from byte array assuming that value stored in little-endian byte order and native byte order
+     * is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Float value from byte array.
+     */
+    public static float getFloatLE(byte[] arr, long off) {
+        return Float.intBitsToFloat(
+            UNALIGNED ? Integer.reverseBytes(UNSAFE.getInt(arr, off)) : getIntByByte(arr, off, false)
+        );
+    }
+
+    /**
+     * Stores float value into byte array assuming that value should be stored in little-endian byte order and native
+     * byte order is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putFloatLE(byte[] arr, long off, float val) {
+        int intVal = Float.floatToIntBits(val);
+
+        if (UNALIGNED)
+            UNSAFE.putInt(arr, off, Integer.reverseBytes(intVal));
+        else
+            putIntByByte(arr, off, intVal, false);
+    }
+
+    /**
+     * Gets double value from byte array assuming that value stored in little-endian byte order and native byte order
+     * is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @return Double value from byte array.
+     */
+    public static double getDoubleLE(byte[] arr, long off) {
+        return Double.longBitsToDouble(
+            UNALIGNED ? Long.reverseBytes(UNSAFE.getLong(arr, off)) : getLongByByte(arr, off, false)
+        );
+    }
+
+    /**
+     * Stores double value into byte array assuming that value should be stored in little-endian byte order and
+     * native byte order is big-endian. Alignment aware.
+     *
+     * @param arr Byte array.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putDoubleLE(byte[] arr, long off, double val) {
+        long longVal = Double.doubleToLongBits(val);
+
+        if (UNALIGNED)
+            UNSAFE.putLong(arr, off, Long.reverseBytes(longVal));
+        else
+            putLongByByte(arr, off, longVal, false);
+    }
+
+    /**
+     * Gets byte value from given address.
+     *
+     * @param addr Address.
+     * @return Byte value from given address.
+     */
+    public static byte getByte(long addr) {
+        return UNSAFE.getByte(addr);
+    }
+
+    /**
+     * Stores given byte value.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putByte(long addr, byte val) {
+        UNSAFE.putByte(addr, val);
+    }
+
+    /**
+     * Gets short value from given address. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Short value from given address.
+     */
+    public static short getShort(long addr) {
+        return UNALIGNED ? UNSAFE.getShort(addr) : getShortByByte(addr, BIG_ENDIAN);
+    }
+
+    /**
+     * Stores given short value. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putShort(long addr, short val) {
+        if (UNALIGNED)
+            UNSAFE.putShort(addr, val);
+        else
+            putShortByByte(addr, val, BIG_ENDIAN);
+    }
+
+    /**
+     * Gets char value from given address. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Char value from given address.
+     */
+    public static char getChar(long addr) {
+        return UNALIGNED ? UNSAFE.getChar(addr) : getCharByByte(addr, BIG_ENDIAN);
+    }
+
+    /**
+     * Stores given char value. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putChar(long addr, char val) {
+        if (UNALIGNED)
+            UNSAFE.putChar(addr, val);
+        else
+            putCharByByte(addr, val, BIG_ENDIAN);
+    }
+
+    /**
+     * Gets integer value from given address. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Integer value from given address.
+     */
+    public static int getInt(long addr) {
+        return UNALIGNED ? UNSAFE.getInt(addr) : getIntByByte(addr, BIG_ENDIAN);
+    }
+
+    /**
+     * Stores given integer value. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putInt(long addr, int val) {
+        if (UNALIGNED)
+            UNSAFE.putInt(addr, val);
+        else
+            putIntByByte(addr, val, BIG_ENDIAN);
+    }
+
+    /**
+     * Gets long value from given address. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Long value from given address.
+     */
+    public static long getLong(long addr) {
+        return UNALIGNED ? UNSAFE.getLong(addr) : getLongByByte(addr, BIG_ENDIAN);
+    }
+
+    /**
+     * Stores given integer value. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putLong(long addr, long val) {
+        if (UNALIGNED)
+            UNSAFE.putLong(addr, val);
+        else
+            putLongByByte(addr, val, BIG_ENDIAN);
+    }
+
+    /**
+     * Gets float value from given address. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Float value from given address.
+     */
+    public static float getFloat(long addr) {
+        return UNALIGNED ? UNSAFE.getFloat(addr) : Float.intBitsToFloat(getIntByByte(addr, BIG_ENDIAN));
+    }
+
+    /**
+     * Stores given float value. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putFloat(long addr, float val) {
+        if (UNALIGNED)
+            UNSAFE.putFloat(addr, val);
+        else
+            putIntByByte(addr, Float.floatToIntBits(val), BIG_ENDIAN);
+    }
+
+    /**
+     * Gets double value from given address. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Double value from given address.
+     */
+    public static double getDouble(long addr) {
+        return UNALIGNED ? UNSAFE.getDouble(addr) : Double.longBitsToDouble(getLongByByte(addr, BIG_ENDIAN));
+    }
+
+    /**
+     * Stores given double value. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putDouble(long addr, double val) {
+        if (UNALIGNED)
+            UNSAFE.putDouble(addr, val);
+        else
+            putLongByByte(addr, Double.doubleToLongBits(val), BIG_ENDIAN);
+    }
+
+    /**
+     * Gets short value from given address assuming that value stored in little-endian byte order and native byte order
+     * is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Short value from given address.
+     */
+    public static short getShortLE(long addr) {
+        return UNALIGNED ? Short.reverseBytes(UNSAFE.getShort(addr)) : getShortByByte(addr, false);
+    }
+
+    /**
+     * Stores given short value assuming that value should be stored in little-endian byte order and native byte
+     * order is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putShortLE(long addr, short val) {
+        if (UNALIGNED)
+            UNSAFE.putShort(addr, Short.reverseBytes(val));
+        else
+            putShortByByte(addr, val, false);
+    }
+
+    /**
+     * Gets char value from given address assuming that value stored in little-endian byte order and native byte order
+     * is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Char value from given address.
+     */
+    public static char getCharLE(long addr) {
+        return UNALIGNED ? Character.reverseBytes(UNSAFE.getChar(addr)) : getCharByByte(addr, false);
+    }
+
+    /**
+     * Stores given char value assuming that value should be stored in little-endian byte order and native byte order
+     * is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putCharLE(long addr, char val) {
+        if (UNALIGNED)
+            UNSAFE.putChar(addr, Character.reverseBytes(val));
+        else
+            putCharByByte(addr, val, false);
+    }
+
+    /**
+     * Gets integer value from given address assuming that value stored in little-endian byte order
+     * and native byte order is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Integer value from given address.
+     */
+    public static int getIntLE(long addr) {
+        return UNALIGNED ? Integer.reverseBytes(UNSAFE.getInt(addr)) : getIntByByte(addr, false);
+    }
+
+    /**
+     * Stores given integer value assuming that value should be stored in little-endian byte order
+     * and native byte order is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putIntLE(long addr, int val) {
+        if (UNALIGNED)
+            UNSAFE.putInt(addr, Integer.reverseBytes(val));
+        else
+            putIntByByte(addr, val, false);
+    }
+
+    /**
+     * Gets long value from given address assuming that value stored in little-endian byte order
+     * and native byte order is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Long value from given address.
+     */
+    public static long getLongLE(long addr) {
+        return UNALIGNED ? Long.reverseBytes(UNSAFE.getLong(addr)) : getLongByByte(addr, false);
+    }
+
+    /**
+     * Stores given integer value assuming that value should be stored in little-endian byte order
+     * and native byte order is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putLongLE(long addr, long val) {
+        if (UNALIGNED)
+            UNSAFE.putLong(addr, Long.reverseBytes(val));
+        else
+            putLongByByte(addr, val, false);
+    }
+
+    /**
+     * Gets float value from given address assuming that value stored in little-endian byte order
+     * and native byte order is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Float value from given address.
+     */
+    public static float getFloatLE(long addr) {
+        return Float.intBitsToFloat(UNALIGNED ? Integer.reverseBytes(UNSAFE.getInt(addr)) : getIntByByte(addr, false));
+    }
+
+    /**
+     * Stores given float value assuming that value should be stored in little-endian byte order
+     * and native byte order is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putFloatLE(long addr, float val) {
+        int intVal = Float.floatToIntBits(val);
+
+        if (UNALIGNED)
+            UNSAFE.putInt(addr, Integer.reverseBytes(intVal));
+        else
+            putIntByByte(addr, intVal, false);
+    }
+
+    /**
+     * Gets double value from given address assuming that value stored in little-endian byte order
+     * and native byte order is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @return Double value from given address.
+     */
+    public static double getDoubleLE(long addr) {
+        return Double.longBitsToDouble(
+            UNALIGNED ? Long.reverseBytes(UNSAFE.getLong(addr)) : getLongByByte(addr, false)
+        );
+    }
+
+    /**
+     * Stores given double value assuming that value should be stored in little-endian byte order
+     * and native byte order is big-endian. Alignment aware.
+     *
+     * @param addr Address.
+     * @param val Value.
+     */
+    public static void putDoubleLE(long addr, double val) {
+        long longVal = Double.doubleToLongBits(val);
+
+        if (UNALIGNED)
+            UNSAFE.putLong(addr, Long.reverseBytes(longVal));
+        else
+            putLongByByte(addr, longVal, false);
+    }
+
+    /**
+     * Returns static field offset.
+     *
+     * @param field Field.
+     * @return Static field offset.
+     */
+    public static long staticFieldOffset(Field field) {
+        return UNSAFE.staticFieldOffset(field);
+    }
+
+    /**
+     * Returns object field offset.
+     *
+     * @param field Field.
+     * @return Object field offset.
+     */
+    public static long objectFieldOffset(Field field) {
+        return UNSAFE.objectFieldOffset(field);
+    }
+
+    /**
+     * Returns static field base.
+     *
+     * @param field Field.
+     * @return Static field base.
+     */
+    public static Object staticFieldBase(Field field) {
+        return UNSAFE.staticFieldBase(field);
+    }
+
+    /**
+     * Allocates memory.
+     *
+     * @param size Size.
+     * @return address.
+     */
+    public static long allocateMemory(long size) {
+        return UNSAFE.allocateMemory(size);
+    }
+
+    /**
+     * Reallocates memory.
+     *
+     * @param addr Address.
+     * @param len Length.
+     * @return address.
+     */
+    public static long reallocateMemory(long addr, long len) {
+        return UNSAFE.reallocateMemory(addr, len);
+    }
+
+    /**
+     * Fills memory with given value.
+     *
+     * @param addr Address.
+     * @param len Length.
+     * @param val Value.
+     */
+    public static void setMemory(long addr, long len, byte val) {
+        UNSAFE.setMemory(addr, len, val);
+    }
+
+    /**
+     * Copies memory.
+     *
+     * @param src Source.
+     * @param dst Dst.
+     * @param len Length.
+     */
+    public static void copyMemory(long src, long dst, long len) {
+        UNSAFE.copyMemory(src, dst, len);
+    }
+
+    /**
+     * Sets all bytes in a given block of memory to a copy of another block.
+     *
+     * @param srcBase Source base.
+     * @param srcOff Source offset.
+     * @param dstBase Dst base.
+     * @param dstOff Dst offset.
+     * @param len Length.
+     */
+    public static void copyMemory(Object srcBase, long srcOff, Object dstBase, long dstOff, long len) {
+        UNSAFE.copyMemory(srcBase, srcOff, dstBase, dstOff, len);
+    }
+
+    /**
+     * Frees memory.
+     *
+     * @param addr Address.
+     */
+    public static void freeMemory(long addr) {
+        UNSAFE.freeMemory(addr);
+    }
+
+    /**
+     * Returns the offset of the first element in the storage allocation of a given array class.
+     *
+     * @param cls Class.
+     * @return the offset of the first element in the storage allocation of a given array class.
+     */
+    public static int arrayBaseOffset(Class cls) {
+        return UNSAFE.arrayBaseOffset(cls);
+    }
+
+    /**
+     * Allocates instance of given class.
+     *
+     * @param cls Class.
+     * @return Allocated instance.
+     */
+    public static Object allocateInstance(Class cls) throws InstantiationException {
+        return UNSAFE.allocateInstance(cls);
+    }
+
+    /**
+     * Acquires monitor lock.
+     *
+     * @param obj Object.
+     */
+    public static void monitorEnter(Object obj) {
+        UNSAFE.monitorEnter(obj);
+    }
+
+    /**
+     * Releases monitor lock.
+     *
+     * @param obj Object.
+     */
+    public static void monitorExit(Object obj) {
+        UNSAFE.monitorExit(obj);
+    }
+
+    /**
+     * Integer CAS.
+     *
+     * @param obj Object.
+     * @param off Offset.
+     * @param exp Expected.
+     * @param upd Upd.
+     * @return {@code True} if operation completed successfully, {@code false} - otherwise.
+     */
+    public static boolean compareAndSwapInt(Object obj, long off, int exp, int upd) {
+        return UNSAFE.compareAndSwapInt(obj, off, exp, upd);
+    }
+
+    /**
+     * Long CAS.
+     *
+     * @param obj Object.
+     * @param off Offset.
+     * @param exp Expected.
+     * @param upd Upd.
+     * @return {@code True} if operation completed successfully, {@code false} - otherwise.
+     */
+    public static boolean compareAndSwapLong(Object obj, long off, long exp, long upd) {
+        return UNSAFE.compareAndSwapLong(obj, off, exp, upd);
+    }
+
+    /**
+     * Gets byte value with volatile semantic.
+     *
+     * @param obj Object.
+     * @param off Offset.
+     * @return Byte value.
+     */
+    public static byte getByteVolatile(Object obj, long off) {
+        return UNSAFE.getByteVolatile(obj, off);
+    }
+
+    /**
+     * Stores byte value with volatile semantic.
+     *
+     * @param obj Object.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putByteVolatile(Object obj, long off, byte val) {
+        UNSAFE.putByteVolatile(obj, off, val);
+    }
+
+    /**
+     * Gets integer value with volatile semantic.
+     *
+     * @param obj Object.
+     * @param off Offset.
+     * @return Integer value.
+     */
+    public static int getIntVolatile(Object obj, long off) {
+        return UNSAFE.getIntVolatile(obj, off);
+    }
+
+    /**
+     * Stores integer value with volatile semantic.
+     *
+     * @param obj Object.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putIntVolatile(Object obj, long off, int val) {
+        UNSAFE.putIntVolatile(obj, off, val);
+    }
+
+    /**
+     * Gets long value with volatile semantic.
+     *
+     * @param obj Object.
+     * @param off Offset.
+     * @return Long value.
+     */
+    public static long getLongVolatile(Object obj, long off) {
+        return UNSAFE.getLongVolatile(obj, off);
+    }
+
+    /**
+     * Stores long value with volatile semantic.
+     *
+     * @param obj Object.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putLongVolatile(Object obj, long off, long val) {
+        UNSAFE.putLongVolatile(obj, off, val);
+    }
+
+    /**
+     * Stores reference value with volatile semantic.
+     *
+     * @param obj Object.
+     * @param off Offset.
+     * @param val Value.
+     */
+    public static void putObjectVolatile(Object obj, long off, Object val) {
+        UNSAFE.putObjectVolatile(obj, off, val);
+    }
+
+    /**
+     * Returns unaligned flag.
+     */
+    private static boolean unaligned() {
+        String arch = System.getProperty("os.arch");
+
+        return arch.equals("i386") || arch.equals("x86") || arch.equals("amd64") || arch.equals("x86_64");
+    }
+
+    /**
      * @return Instance of Unsafe class.
      */
-    public static Unsafe unsafe() {
+    private static Unsafe unsafe() {
         try {
             return Unsafe.getUnsafe();
         }
@@ -59,4 +1232,308 @@ public class GridUnsafe {
             }
         }
     }
+
+    /**
+     * @param obj Object.
+     * @param off Offset.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static short getShortByByte(Object obj, long off, boolean bigEndian) {
+        if (bigEndian)
+            return (short)(UNSAFE.getByte(obj, off) << 8 | (UNSAFE.getByte(obj, off + 1) & 0xff));
+        else
+            return (short)(UNSAFE.getByte(obj, off + 1) << 8 | (UNSAFE.getByte(obj, off) & 0xff));
+    }
+
+    /**
+     * @param obj Object.
+     * @param off Offset.
+     * @param val Value.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static void putShortByByte(Object obj, long off, short val, boolean bigEndian) {
+        if (bigEndian) {
+            UNSAFE.putByte(obj, off, (byte)(val >> 8));
+            UNSAFE.putByte(obj, off + 1, (byte)val);
+        }
+        else {
+            UNSAFE.putByte(obj, off + 1, (byte)(val >> 8));
+            UNSAFE.putByte(obj, off, (byte)val);
+        }
+    }
+
+    /**
+     * @param obj Object.
+     * @param off Offset.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static char getCharByByte(Object obj, long off, boolean bigEndian) {
+        if (bigEndian)
+            return (char)(UNSAFE.getByte(obj, off) << 8 | (UNSAFE.getByte(obj, off + 1) & 0xff));
+        else
+            return (char)(UNSAFE.getByte(obj, off + 1) << 8 | (UNSAFE.getByte(obj, off) & 0xff));
+    }
+
+    /**
+     * @param obj Object.
+     * @param addr Address.
+     * @param val Value.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static void putCharByByte(Object obj, long addr, char val, boolean bigEndian) {
+        if (bigEndian) {
+            UNSAFE.putByte(obj, addr, (byte)(val >> 8));
+            UNSAFE.putByte(obj, addr + 1, (byte)val);
+        }
+        else {
+            UNSAFE.putByte(obj, addr + 1, (byte)(val >> 8));
+            UNSAFE.putByte(obj, addr, (byte)val);
+        }
+    }
+
+    /**
+     * @param obj Object.
+     * @param addr Address.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static int getIntByByte(Object obj, long addr, boolean bigEndian) {
+        if (bigEndian) {
+            return (((int)UNSAFE.getByte(obj, addr)) << 24) |
+                (((int)UNSAFE.getByte(obj, addr + 1) & 0xff) << 16) |
+                (((int)UNSAFE.getByte(obj, addr + 2) & 0xff) << 8) |
+                (((int)UNSAFE.getByte(obj, addr + 3) & 0xff));
+        }
+        else {
+            return (((int)UNSAFE.getByte(obj, addr + 3)) << 24) |
+                (((int)UNSAFE.getByte(obj, addr + 2) & 0xff) << 16) |
+                (((int)UNSAFE.getByte(obj, addr + 1) & 0xff) << 8) |
+                (((int)UNSAFE.getByte(obj, addr) & 0xff));
+        }
+    }
+
+    /**
+     * @param obj Object.
+     * @param addr Address.
+     * @param val Value.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static void putIntByByte(Object obj, long addr, int val, boolean bigEndian) {
+        if (bigEndian) {
+            UNSAFE.putByte(obj, addr, (byte)(val >> 24));
+            UNSAFE.putByte(obj, addr + 1, (byte)(val >> 16));
+            UNSAFE.putByte(obj, addr + 2, (byte)(val >> 8));
+            UNSAFE.putByte(obj, addr + 3, (byte)(val));
+        }
+        else {
+            UNSAFE.putByte(obj, addr + 3, (byte)(val >> 24));
+            UNSAFE.putByte(obj, addr + 2, (byte)(val >> 16));
+            UNSAFE.putByte(obj, addr + 1, (byte)(val >> 8));
+            UNSAFE.putByte(obj, addr, (byte)(val));
+        }
+    }
+
+    /**
+     * @param obj Object.
+     * @param addr Address.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static long getLongByByte(Object obj, long addr, boolean bigEndian) {
+        if (bigEndian) {
+            return (((long)UNSAFE.getByte(obj, addr)) << 56) |
+                (((long)UNSAFE.getByte(obj, addr + 1) & 0xff) << 48) |
+                (((long)UNSAFE.getByte(obj, addr + 2) & 0xff) << 40) |
+                (((long)UNSAFE.getByte(obj, addr + 3) & 0xff) << 32) |
+                (((long)UNSAFE.getByte(obj, addr + 4) & 0xff) << 24) |
+                (((long)UNSAFE.getByte(obj, addr + 5) & 0xff) << 16) |
+                (((long)UNSAFE.getByte(obj, addr + 6) & 0xff) << 8) |
+                (((long)UNSAFE.getByte(obj, addr + 7) & 0xff));
+        }
+        else {
+            return (((long)UNSAFE.getByte(obj, addr + 7)) << 56) |
+                (((long)UNSAFE.getByte(obj, addr + 6) & 0xff) << 48) |
+                (((long)UNSAFE.getByte(obj, addr + 5) & 0xff) << 40) |
+                (((long)UNSAFE.getByte(obj, addr + 4) & 0xff) << 32) |
+                (((long)UNSAFE.getByte(obj, addr + 3) & 0xff) << 24) |
+                (((long)UNSAFE.getByte(obj, addr + 2) & 0xff) << 16) |
+                (((long)UNSAFE.getByte(obj, addr + 1) & 0xff) << 8) |
+                (((long)UNSAFE.getByte(obj, addr) & 0xff));
+        }
+    }
+
+    /**
+     * @param obj Object.
+     * @param addr Address.
+     * @param val Value.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static void putLongByByte(Object obj, long addr, long val, boolean bigEndian) {
+        if (bigEndian) {
+            UNSAFE.putByte(obj, addr, (byte)(val >> 56));
+            UNSAFE.putByte(obj, addr + 1, (byte)(val >> 48));
+            UNSAFE.putByte(obj, addr + 2, (byte)(val >> 40));
+            UNSAFE.putByte(obj, addr + 3, (byte)(val >> 32));
+            UNSAFE.putByte(obj, addr + 4, (byte)(val >> 24));
+            UNSAFE.putByte(obj, addr + 5, (byte)(val >> 16));
+            UNSAFE.putByte(obj, addr + 6, (byte)(val >> 8));
+            UNSAFE.putByte(obj, addr + 7, (byte)(val));
+        }
+        else {
+            UNSAFE.putByte(obj, addr + 7, (byte)(val >> 56));
+            UNSAFE.putByte(obj, addr + 6, (byte)(val >> 48));
+            UNSAFE.putByte(obj, addr + 5, (byte)(val >> 40));
+            UNSAFE.putByte(obj, addr + 4, (byte)(val >> 32));
+            UNSAFE.putByte(obj, addr + 3, (byte)(val >> 24));
+            UNSAFE.putByte(obj, addr + 2, (byte)(val >> 16));
+            UNSAFE.putByte(obj, addr + 1, (byte)(val >> 8));
+            UNSAFE.putByte(obj, addr, (byte)(val));
+        }
+    }
+
+    /**
+     * @param addr Address.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static short getShortByByte(long addr, boolean bigEndian) {
+        if (bigEndian)
+            return (short)(UNSAFE.getByte(addr) << 8 | (UNSAFE.getByte(addr + 1) & 0xff));
+        else
+            return (short)(UNSAFE.getByte(addr + 1) << 8 | (UNSAFE.getByte(addr) & 0xff));
+    }
+
+    /**
+     * @param addr Address.
+     * @param val Value.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static void putShortByByte(long addr, short val, boolean bigEndian) {
+        if (bigEndian) {
+            UNSAFE.putByte(addr, (byte)(val >> 8));
+            UNSAFE.putByte(addr + 1, (byte)val);
+        }
+        else {
+            UNSAFE.putByte(addr + 1, (byte)(val >> 8));
+            UNSAFE.putByte(addr, (byte)val);
+        }
+    }
+
+    /**
+     * @param addr Address.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static char getCharByByte(long addr, boolean bigEndian) {
+        if (bigEndian)
+            return (char)(UNSAFE.getByte(addr) << 8 | (UNSAFE.getByte(addr + 1) & 0xff));
+        else
+            return (char)(UNSAFE.getByte(addr + 1) << 8 | (UNSAFE.getByte(addr) & 0xff));
+    }
+
+    /**
+     * @param addr Address.
+     * @param val Value.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static void putCharByByte(long addr, char val, boolean bigEndian) {
+        if (bigEndian) {
+            UNSAFE.putByte(addr, (byte)(val >> 8));
+            UNSAFE.putByte(addr + 1, (byte)val);
+        }
+        else {
+            UNSAFE.putByte(addr + 1, (byte)(val >> 8));
+            UNSAFE.putByte(addr, (byte)val);
+        }
+    }
+
+    /**
+     * @param addr Address.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static int getIntByByte(long addr, boolean bigEndian) {
+        if (bigEndian) {
+            return (((int)UNSAFE.getByte(addr)) << 24) |
+                (((int)UNSAFE.getByte(addr + 1) & 0xff) << 16) |
+                (((int)UNSAFE.getByte(addr + 2) & 0xff) << 8) |
+                (((int)UNSAFE.getByte(addr + 3) & 0xff));
+        }
+        else {
+            return (((int)UNSAFE.getByte(addr + 3)) << 24) |
+                (((int)UNSAFE.getByte(addr + 2) & 0xff) << 16) |
+                (((int)UNSAFE.getByte(addr + 1) & 0xff) << 8) |
+                (((int)UNSAFE.getByte(addr) & 0xff));
+        }
+    }
+
+    /**
+     * @param addr Address.
+     * @param val Value.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static void putIntByByte(long addr, int val, boolean bigEndian) {
+        if (bigEndian) {
+            UNSAFE.putByte(addr, (byte)(val >> 24));
+            UNSAFE.putByte(addr + 1, (byte)(val >> 16));
+            UNSAFE.putByte(addr + 2, (byte)(val >> 8));
+            UNSAFE.putByte(addr + 3, (byte)(val));
+        }
+        else {
+            UNSAFE.putByte(addr + 3, (byte)(val >> 24));
+            UNSAFE.putByte(addr + 2, (byte)(val >> 16));
+            UNSAFE.putByte(addr + 1, (byte)(val >> 8));
+            UNSAFE.putByte(addr, (byte)(val));
+        }
+    }
+
+    /**
+     * @param addr Address.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static long getLongByByte(long addr, boolean bigEndian) {
+        if (bigEndian) {
+            return (((long)UNSAFE.getByte(addr)) << 56) |
+                (((long)UNSAFE.getByte(addr + 1) & 0xff) << 48) |
+                (((long)UNSAFE.getByte(addr + 2) & 0xff) << 40) |
+                (((long)UNSAFE.getByte(addr + 3) & 0xff) << 32) |
+                (((long)UNSAFE.getByte(addr + 4) & 0xff) << 24) |
+                (((long)UNSAFE.getByte(addr + 5) & 0xff) << 16) |
+                (((long)UNSAFE.getByte(addr + 6) & 0xff) << 8) |
+                (((long)UNSAFE.getByte(addr + 7) & 0xff));
+        }
+        else {
+            return (((long)UNSAFE.getByte(addr + 7)) << 56) |
+                (((long)UNSAFE.getByte(addr + 6) & 0xff) << 48) |
+                (((long)UNSAFE.getByte(addr + 5) & 0xff) << 40) |
+                (((long)UNSAFE.getByte(addr + 4) & 0xff) << 32) |
+                (((long)UNSAFE.getByte(addr + 3) & 0xff) << 24) |
+                (((long)UNSAFE.getByte(addr + 2) & 0xff) << 16) |
+                (((long)UNSAFE.getByte(addr + 1) & 0xff) << 8) |
+                (((long)UNSAFE.getByte(addr) & 0xff));
+        }
+    }
+
+    /**
+     * @param addr Address.
+     * @param val Value.
+     * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+     */
+    private static void putLongByByte(long addr, long val, boolean bigEndian) {
+        if (bigEndian) {
+            UNSAFE.putByte(addr, (byte)(val >> 56));
+            UNSAFE.putByte(addr + 1, (byte)(val >> 48));
+            UNSAFE.putByte(addr + 2, (byte)(val >> 40));
+            UNSAFE.putByte(addr + 3, (byte)(val >> 32));
+            UNSAFE.putByte(addr + 4, (byte)(val >> 24));
+            UNSAFE.putByte(addr + 5, (byte)(val >> 16));
+            UNSAFE.putByte(addr + 6, (byte)(val >> 8));
+            UNSAFE.putByte(addr + 7, (byte)(val));
+        }
+        else {
+            UNSAFE.putByte(addr + 7, (byte)(val >> 56));
+            UNSAFE.putByte(addr + 6, (byte)(val >> 48));
+            UNSAFE.putByte(addr + 5, (byte)(val >> 40));
+            UNSAFE.putByte(addr + 4, (byte)(val >> 32));
+            UNSAFE.putByte(addr + 3, (byte)(val >> 24));
+            UNSAFE.putByte(addr + 2, (byte)(val >> 16));
+            UNSAFE.putByte(addr + 1, (byte)(val >> 8));
+            UNSAFE.putByte(addr, (byte)(val));
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 6c0b8e6..a6b28fd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -243,21 +243,19 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_BUILD_VER;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_CACHE;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_JVM_PID;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
+import static org.apache.ignite.internal.util.GridUnsafe.objectFieldOffset;
+import static org.apache.ignite.internal.util.GridUnsafe.putObjectVolatile;
+import static org.apache.ignite.internal.util.GridUnsafe.staticFieldBase;
+import static org.apache.ignite.internal.util.GridUnsafe.staticFieldOffset;
 
 /**
  * Collection of utility methods used throughout the system.
  */
 @SuppressWarnings({"UnusedReturnValue", "UnnecessaryFullyQualifiedName"})
 public abstract class IgniteUtils {
-    /** Unsafe. */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
     /** {@code True} if {@code unsafe} should be used for array copy. */
     private static final boolean UNSAFE_BYTE_ARR_CP = unsafeByteArrayCopyAvailable();
 
-    /** Offset. */
-    private static final int BYTE_ARRAY_DATA_OFFSET = UNSAFE.arrayBaseOffset(byte[].class);
-
     /** Sun-specific JDK constructor factory for objects that don't have empty constructor. */
     private static final Method CTOR_FACTORY;
 
@@ -526,7 +524,7 @@ public abstract class IgniteUtils {
                 }
 
             // UNIX name detection.
-            if (osLow.contains("olaris"))
+            if (osLow.contains("olaris") || osLow.contains("sunos"))
                 solaris = true;
             else if (osLow.contains("inux"))
                 linux = true;
@@ -669,9 +667,8 @@ public abstract class IgniteUtils {
 
                 // We use unsafe operations to update static fields on interface because
                 // they are treated as static final and cannot be updated via standard reflection.
-                UNSAFE.putObjectVolatile(UNSAFE.staticFieldBase(f1), UNSAFE.staticFieldOffset(f1), gridEvents());
-                UNSAFE.putObjectVolatile(UNSAFE.staticFieldBase(f2), UNSAFE.staticFieldOffset(f2),
-                    gridEvents(EVT_NODE_METRICS_UPDATED));
+                putObjectVolatile(staticFieldBase(f1), staticFieldOffset(f1), gridEvents());
+                putObjectVolatile(staticFieldBase(f2), staticFieldOffset(f2), gridEvents(EVT_NODE_METRICS_UPDATED));
 
                 assert EVTS_ALL != null;
                 assert EVTS_ALL.length == GRID_EVTS.length;
@@ -7692,7 +7689,7 @@ public abstract class IgniteUtils {
      */
     public static long fieldOffset(Class<?> cls, String fieldName) {
         try {
-            return UNSAFE.objectFieldOffset(cls.getDeclaredField(fieldName));
+            return objectFieldOffset(cls.getDeclaredField(fieldName));
         }
         catch (NoSuchFieldException e) {
             throw new IllegalStateException(e);
@@ -8304,7 +8301,7 @@ public abstract class IgniteUtils {
     @SuppressWarnings("TypeParameterExtendsFinalClass")
     private static boolean unsafeByteArrayCopyAvailable() {
         try {
-            Class<? extends Unsafe> unsafeCls = UNSAFE.getClass();
+            Class<? extends Unsafe> unsafeCls = Unsafe.class;
 
             unsafeCls.getMethod("copyMemory", Object.class, long.class, Object.class, long.class, long.class);
 
@@ -8327,7 +8324,7 @@ public abstract class IgniteUtils {
         assert resBuf.length >= resOff + len;
 
         if (UNSAFE_BYTE_ARR_CP)
-            UNSAFE.copyMemory(src, BYTE_ARRAY_DATA_OFFSET + off, resBuf, BYTE_ARRAY_DATA_OFFSET + resOff, len);
+            GridUnsafe.copyMemory(src, GridUnsafe.BYTE_ARR_OFF + off, resBuf, GridUnsafe.BYTE_ARR_OFF + resOff, len);
         else
             System.arraycopy(src, off, resBuf, resOff, len);
 
@@ -8860,18 +8857,18 @@ public abstract class IgniteUtils {
      * @return Offset.
      */
     public static long writeGridUuid(byte[] arr, long off, @Nullable IgniteUuid uid) {
-        UNSAFE.putBoolean(arr, off++, uid != null);
+        GridUnsafe.putBoolean(arr, off++, uid != null);
 
         if (uid != null) {
-            UNSAFE.putLong(arr, off, uid.globalId().getMostSignificantBits());
+            GridUnsafe.putLong(arr, off, uid.globalId().getMostSignificantBits());
 
             off += 8;
 
-            UNSAFE.putLong(arr, off, uid.globalId().getLeastSignificantBits());
+            GridUnsafe.putLong(arr, off, uid.globalId().getLeastSignificantBits());
 
             off += 8;
 
-            UNSAFE.putLong(arr, off, uid.localId());
+            GridUnsafe.putLong(arr, off, uid.localId());
 
             off += 8;
         }
@@ -8885,18 +8882,18 @@ public abstract class IgniteUtils {
      * @return UUID.
      */
     @Nullable public static IgniteUuid readGridUuid(byte[] arr, long off) {
-        if (UNSAFE.getBoolean(arr, off++)) {
-            long most = UNSAFE.getLong(arr, off);
+        if (GridUnsafe.getBoolean(arr, off++)) {
+            long most = GridUnsafe.getLong(arr, off);
 
             off += 8;
 
-            long least = UNSAFE.getLong(arr, off);
+            long least = GridUnsafe.getLong(arr, off);
 
             off += 8;
 
             UUID globalId = new UUID(most, least);
 
-            long locId = UNSAFE.getLong(arr, off);
+            long locId = GridUnsafe.getLong(arr, off);
 
             return new IgniteUuid(globalId, locId);
         }
@@ -8909,18 +8906,18 @@ public abstract class IgniteUtils {
      * @return UUID.
      */
     @Nullable public static IgniteUuid readGridUuid(long ptr) {
-        if (UNSAFE.getBoolean(null, ptr++)) {
-            long most = UNSAFE.getLong(ptr);
+        if (GridUnsafe.getBoolean(null, ptr++)) {
+            long most = GridUnsafe.getLong(ptr);
 
             ptr += 8;
 
-            long least = UNSAFE.getLong(ptr);
+            long least = GridUnsafe.getLong(ptr);
 
             ptr += 8;
 
             UUID globalId = new UUID(most, least);
 
-            long locId = UNSAFE.getLong(ptr);
+            long locId = GridUnsafe.getLong(ptr);
 
             return new IgniteUuid(globalId, locId);
         }
@@ -8937,43 +8934,43 @@ public abstract class IgniteUtils {
     public static long writeVersion(byte[] arr, long off, GridCacheVersion ver) {
         boolean verEx = ver instanceof GridCacheVersionEx;
 
-        UNSAFE.putBoolean(arr, off++, verEx);
+        GridUnsafe.putBoolean(arr, off++, verEx);
 
         if (verEx) {
             GridCacheVersion drVer = ver.conflictVersion();
 
             assert drVer != null;
 
-            UNSAFE.putInt(arr, off, drVer.topologyVersion());
+            GridUnsafe.putInt(arr, off, drVer.topologyVersion());
 
             off += 4;
 
-            UNSAFE.putInt(arr, off, drVer.nodeOrderAndDrIdRaw());
+            GridUnsafe.putInt(arr, off, drVer.nodeOrderAndDrIdRaw());
 
             off += 4;
 
-            UNSAFE.putLong(arr, off, drVer.globalTime());
+            GridUnsafe.putLong(arr, off, drVer.globalTime());
 
             off += 8;
 
-            UNSAFE.putLong(arr, off, drVer.order());
+            GridUnsafe.putLong(arr, off, drVer.order());
 
             off += 8;
         }
 
-        UNSAFE.putInt(arr, off, ver.topologyVersion());
+        GridUnsafe.putInt(arr, off, ver.topologyVersion());
 
         off += 4;
 
-        UNSAFE.putInt(arr, off, ver.nodeOrderAndDrIdRaw());
+        GridUnsafe.putInt(arr, off, ver.nodeOrderAndDrIdRaw());
 
         off += 4;
 
-        UNSAFE.putLong(arr, off, ver.globalTime());
+        GridUnsafe.putLong(arr, off, ver.globalTime());
 
         off += 8;
 
-        UNSAFE.putLong(arr, off, ver.order());
+        GridUnsafe.putLong(arr, off, ver.order());
 
         off += 8;
 
@@ -8986,18 +8983,18 @@ public abstract class IgniteUtils {
      * @return Version.
      */
     public static GridCacheVersion readVersion(long ptr, boolean verEx) {
-        GridCacheVersion ver = new GridCacheVersion(UNSAFE.getInt(ptr),
-            UNSAFE.getInt(ptr + 4),
-            UNSAFE.getLong(ptr + 8),
-            UNSAFE.getLong(ptr + 16));
+        GridCacheVersion ver = new GridCacheVersion(GridUnsafe.getInt(ptr),
+            GridUnsafe.getInt(ptr + 4),
+            GridUnsafe.getLong(ptr + 8),
+            GridUnsafe.getLong(ptr + 16));
 
         if (verEx) {
             ptr += 24;
 
-            ver = new GridCacheVersionEx(UNSAFE.getInt(ptr),
-                UNSAFE.getInt(ptr + 4),
-                UNSAFE.getLong(ptr + 8),
-                UNSAFE.getLong(ptr + 16),
+            ver = new GridCacheVersionEx(GridUnsafe.getInt(ptr),
+                GridUnsafe.getInt(ptr + 4),
+                GridUnsafe.getLong(ptr + 8),
+                GridUnsafe.getLong(ptr + 16),
                 ver);
         }
 
@@ -9011,38 +9008,38 @@ public abstract class IgniteUtils {
      * @return Version.
      */
     public static GridCacheVersion readVersion(byte[] arr, long off, boolean verEx) {
-        int topVer = UNSAFE.getInt(arr, off);
+        int topVer = GridUnsafe.getInt(arr, off);
 
         off += 4;
 
-        int nodeOrderDrId = UNSAFE.getInt(arr, off);
+        int nodeOrderDrId = GridUnsafe.getInt(arr, off);
 
         off += 4;
 
-        long globalTime = UNSAFE.getLong(arr, off);
+        long globalTime = GridUnsafe.getLong(arr, off);
 
         off += 8;
 
-        long order = UNSAFE.getLong(arr, off);
+        long order = GridUnsafe.getLong(arr, off);
 
         off += 8;
 
         GridCacheVersion ver = new GridCacheVersion(topVer, nodeOrderDrId, globalTime, order);
 
         if (verEx) {
-            topVer = UNSAFE.getInt(arr, off);
+            topVer = GridUnsafe.getInt(arr, off);
 
             off += 4;
 
-            nodeOrderDrId = UNSAFE.getInt(arr, off);
+            nodeOrderDrId = GridUnsafe.getInt(arr, off);
 
             off += 4;
 
-            globalTime = UNSAFE.getLong(arr, off);
+            globalTime = GridUnsafe.getLong(arr, off);
 
             off += 8;
 
-            order = UNSAFE.getLong(arr, off);
+            order = GridUnsafe.getLong(arr, off);
 
             ver = new GridCacheVersionEx(topVer, nodeOrderDrId, globalTime, order, ver);
         }
@@ -9058,7 +9055,7 @@ public abstract class IgniteUtils {
     public static byte[] copyMemory(long ptr, int size) {
         byte[] res = new byte[size];
 
-        UNSAFE.copyMemory(null, ptr, res, BYTE_ARRAY_DATA_OFFSET, size);
+        GridUnsafe.copyMemory(null, ptr, res, GridUnsafe.BYTE_ARR_OFF, size);
 
         return res;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
index 00fa2c3..2f57e59 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
@@ -26,41 +26,24 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RECHECK;
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+import static org.apache.ignite.internal.util.GridUnsafe.BYTE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.CHAR_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.DOUBLE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.FLOAT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.INT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.LONG_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.SHORT_ARR_OFF;
 
 /**
  * Data input based on {@code Unsafe} operations.
  */
 public class GridUnsafeDataInput extends InputStream implements GridDataInput {
-    /** Unsafe. */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
     /** */
     private static final Long CHECK_FREQ = Long.getLong(IGNITE_MARSHAL_BUFFERS_RECHECK, 10000);
 
-    /** */
-    private static final long byteArrOff = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** */
-    private static final long shortArrOff = UNSAFE.arrayBaseOffset(short[].class);
-
-    /** */
-    private static final long intArrOff = UNSAFE.arrayBaseOffset(int[].class);
-
-    /** */
-    private static final long longArrOff = UNSAFE.arrayBaseOffset(long[].class);
-
-    /** */
-    private static final long floatArrOff = UNSAFE.arrayBaseOffset(float[].class);
-
-    /** */
-    private static final long doubleArrOff = UNSAFE.arrayBaseOffset(double[].class);
-
-    /** */
-    private static final long charArrOff = UNSAFE.arrayBaseOffset(char[].class);
-
     /** Maximum data block length. */
     private static final int MAX_BLOCK_SIZE = 1024;
 
@@ -152,7 +135,7 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
             if (maxOff < halfSize) {
                 byte[] newInBuf = new byte[halfSize]; // Shrink.
 
-                UNSAFE.copyMemory(inBuf, byteArrOff, newInBuf, byteArrOff, off);
+                GridUnsafe.copyMemory(inBuf, BYTE_ARR_OFF, newInBuf, BYTE_ARR_OFF, off);
 
                 buf = inBuf = newInBuf;
             }
@@ -208,7 +191,7 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
 
         byte[] arr = new byte[arrSize];
 
-        UNSAFE.copyMemory(buf, byteArrOff + offset(arrSize), arr, byteArrOff, arrSize);
+        GridUnsafe.copyMemory(buf, BYTE_ARR_OFF + offset(arrSize), arr, BYTE_ARR_OFF, arrSize);
 
         return arr;
     }
@@ -223,7 +206,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
 
         short[] arr = new short[arrSize];
 
-        UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, shortArrOff, bytesToCp);
+        long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+        if (BIG_ENDIAN) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = GridUnsafe.getShortLE(buf, off);
+
+                off += 2;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(buf, off, arr, SHORT_ARR_OFF, bytesToCp);
 
         return arr;
     }
@@ -238,7 +231,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
 
         int[] arr = new int[arrSize];
 
-        UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, intArrOff, bytesToCp);
+        long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+        if (BIG_ENDIAN) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = GridUnsafe.getIntLE(buf, off);
+
+                off += 4;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(buf, off, arr, INT_ARR_OFF, bytesToCp);
 
         return arr;
     }
@@ -253,7 +256,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
 
         double[] arr = new double[arrSize];
 
-        UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, doubleArrOff, bytesToCp);
+        long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+        if (BIG_ENDIAN) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = GridUnsafe.getDoubleLE(buf, off);
+
+                off += 8;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(buf, off, arr, DOUBLE_ARR_OFF, bytesToCp);
 
         return arr;
     }
@@ -280,7 +293,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
 
         char[] arr = new char[arrSize];
 
-        UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, charArrOff, bytesToCp);
+        long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+        if (BIG_ENDIAN) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = GridUnsafe.getCharLE(buf, off);
+
+                off += 2;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(buf, off, arr, CHAR_ARR_OFF, bytesToCp);
 
         return arr;
     }
@@ -295,7 +318,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
 
         long[] arr = new long[arrSize];
 
-        UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, longArrOff, bytesToCp);
+        long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+        if (BIG_ENDIAN) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = GridUnsafe.getLongLE(buf, off);
+
+                off += 8;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(buf, off, arr, LONG_ARR_OFF, bytesToCp);
 
         return arr;
     }
@@ -310,7 +343,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
 
         float[] arr = new float[arrSize];
 
-        UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, floatArrOff, bytesToCp);
+        long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+        if (BIG_ENDIAN) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = GridUnsafe.getFloatLE(buf, off);
+
+                off += 4;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(buf, off, arr, FLOAT_ARR_OFF, bytesToCp);
 
         return arr;
     }
@@ -321,14 +364,14 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
 
         fromStream(len);
 
-        UNSAFE.copyMemory(buf, byteArrOff + offset(len), b, byteArrOff, len);
+        GridUnsafe.copyMemory(buf, BYTE_ARR_OFF + offset(len), b, BYTE_ARR_OFF, len);
     }
 
     /** {@inheritDoc} */
     @Override public void readFully(byte[] b, int off, int len) throws IOException {
         fromStream(len);
 
-        UNSAFE.copyMemory(buf, byteArrOff + offset(len), b, byteArrOff + off, len);
+        GridUnsafe.copyMemory(buf, BYTE_ARR_OFF + offset(len), b, BYTE_ARR_OFF + off, len);
     }
 
     /** {@inheritDoc} */
@@ -345,14 +388,14 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
     @Override public boolean readBoolean() throws IOException {
         fromStream(1);
 
-        return UNSAFE.getBoolean(buf, byteArrOff + offset(1));
+        return GridUnsafe.getBoolean(buf, BYTE_ARR_OFF + offset(1));
     }
 
     /** {@inheritDoc} */
     @Override public byte readByte() throws IOException {
         fromStream(1);
 
-        return UNSAFE.getByte(buf, byteArrOff + offset(1));
+        return GridUnsafe.getByte(buf, BYTE_ARR_OFF + offset(1));
     }
 
     /** {@inheritDoc} */
@@ -364,7 +407,9 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
     @Override public short readShort() throws IOException {
         fromStream(2);
 
-        return UNSAFE.getShort(buf, byteArrOff + offset(2));
+        long off = BYTE_ARR_OFF + offset(2);
+
+        return BIG_ENDIAN ? GridUnsafe.getShortLE(buf, off) : GridUnsafe.getShort(buf, off);
     }
 
     /** {@inheritDoc} */
@@ -376,7 +421,9 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
     @Override public char readChar() throws IOException {
         fromStream(2);
 
-        char v = UNSAFE.getChar(buf, byteArrOff + off);
+        long off = BYTE_ARR_OFF + this.off;
+
+        char v = BIG_ENDIAN ? GridUnsafe.getCharLE(buf, off) : GridUnsafe.getChar(buf, off);
 
         offset(2);
 
@@ -387,28 +434,32 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
     @Override public int readInt() throws IOException {
         fromStream(4);
 
-        return UNSAFE.getInt(buf, byteArrOff + offset(4));
+        long off = BYTE_ARR_OFF + offset(4);
+
+        return BIG_ENDIAN ? GridUnsafe.getIntLE(buf, off) : GridUnsafe.getInt(buf, off);
     }
 
     /** {@inheritDoc} */
     @Override public long readLong() throws IOException {
         fromStream(8);
 
-        return UNSAFE.getLong(buf, byteArrOff + offset(8));
+        long off = BYTE_ARR_OFF + offset(8);
+
+        return BIG_ENDIAN ? GridUnsafe.getLongLE(buf, off) : GridUnsafe.getLong(buf, off);
     }
 
     /** {@inheritDoc} */
     @Override public float readFloat() throws IOException {
-        fromStream(4);
+        int v = readInt();
 
-        return UNSAFE.getFloat(buf, byteArrOff + offset(4));
+        return Float.intBitsToFloat(v);
     }
 
     /** {@inheritDoc} */
     @Override public double readDouble() throws IOException {
-        fromStream(8);
+        long v = readLong();
 
-        return UNSAFE.getDouble(buf, byteArrOff + offset(8));
+        return Double.longBitsToDouble(v);
     }
 
     /** {@inheritDoc} */
@@ -437,7 +488,7 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
         else {
             int toRead = Math.min(len, max - this.off);
 
-            UNSAFE.copyMemory(buf, byteArrOff + offset(toRead), b, byteArrOff + off, toRead);
+            GridUnsafe.copyMemory(buf, BYTE_ARR_OFF + offset(toRead), b, BYTE_ARR_OFF + off, toRead);
 
             return toRead;
         }
@@ -501,7 +552,7 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
             else {
                 // shift and refill buffer manually
                 if (avail > 0)
-                    UNSAFE.copyMemory(utfBuf, byteArrOff + pos, utfBuf, byteArrOff, avail);
+                    GridUnsafe.copyMemory(utfBuf, BYTE_ARR_OFF + pos, utfBuf, BYTE_ARR_OFF, avail);
 
                 pos = 0;
                 end = (int)Math.min(MAX_BLOCK_SIZE, utfLen);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutput.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutput.java b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutput.java
index b7c82a6..c0fe0d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutput.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutput.java
@@ -22,41 +22,24 @@ import java.io.OutputStream;
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RECHECK;
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+import static org.apache.ignite.internal.util.GridUnsafe.BYTE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.CHAR_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.DOUBLE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.FLOAT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.INT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.LONG_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.SHORT_ARR_OFF;
 
 /**
  * Data output based on {@code Unsafe} operations.
  */
 public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput {
-    /** Unsafe. */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
     /** */
     private static final Long CHECK_FREQ = Long.getLong(IGNITE_MARSHAL_BUFFERS_RECHECK, 10000);
 
-    /** */
-    private static final long byteArrOff = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** */
-    private static final long shortArrOff = UNSAFE.arrayBaseOffset(short[].class);
-
-    /** */
-    private static final long intArrOff = UNSAFE.arrayBaseOffset(int[].class);
-
-    /** */
-    private static final long longArrOff = UNSAFE.arrayBaseOffset(long[].class);
-
-    /** */
-    private static final long floatArrOff = UNSAFE.arrayBaseOffset(float[].class);
-
-    /** */
-    private static final long doubleArrOff = UNSAFE.arrayBaseOffset(double[].class);
-
-    /** */
-    private static final long charArrOff = UNSAFE.arrayBaseOffset(char[].class);
-
     /** Length of char buffer (for writing strings). */
     private static final int CHAR_BUF_SIZE = 256;
 
@@ -114,7 +97,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
     @Override public byte[] array() {
         byte[] bytes0 = new byte[off];
 
-        UNSAFE.copyMemory(bytes, byteArrOff, bytes0, byteArrOff, off);
+        GridUnsafe.copyMemory(bytes, BYTE_ARR_OFF, bytes0, BYTE_ARR_OFF, off);
 
         return bytes0;
     }
@@ -147,7 +130,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
         if (size > bytes.length) {
             byte[] newBytes = new byte[size << 1]; // Grow.
 
-            UNSAFE.copyMemory(bytes, byteArrOff, newBytes, byteArrOff, off);
+            GridUnsafe.copyMemory(bytes, BYTE_ARR_OFF, newBytes, BYTE_ARR_OFF, off);
 
             bytes = newBytes;
         }
@@ -157,7 +140,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
             if (maxOff < halfSize) {
                 byte[] newBytes = new byte[halfSize]; // Shrink.
 
-                UNSAFE.copyMemory(bytes, byteArrOff, newBytes, byteArrOff, off);
+                GridUnsafe.copyMemory(bytes, BYTE_ARR_OFF, newBytes, BYTE_ARR_OFF, off);
 
                 bytes = newBytes;
             }
@@ -182,7 +165,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
     @Override public void write(byte[] b) throws IOException {
         requestFreeSize(b.length);
 
-        UNSAFE.copyMemory(b, byteArrOff, bytes, byteArrOff + off, b.length);
+        GridUnsafe.copyMemory(b, BYTE_ARR_OFF, bytes, BYTE_ARR_OFF + off, b.length);
 
         onWrite(b.length);
     }
@@ -191,7 +174,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
     @Override public void write(byte[] b, int off, int len) throws IOException {
         requestFreeSize(len);
 
-        UNSAFE.copyMemory(b, byteArrOff + off, bytes, byteArrOff + this.off, len);
+        GridUnsafe.copyMemory(b, BYTE_ARR_OFF + off, bytes, BYTE_ARR_OFF + this.off, len);
 
         onWrite(len);
     }
@@ -204,7 +187,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
 
         requestFreeSize(bytesToCp);
 
-        UNSAFE.copyMemory(arr, doubleArrOff, bytes, byteArrOff + off, bytesToCp);
+        if (BIG_ENDIAN) {
+            long off = BYTE_ARR_OFF + this.off;
+
+            for (double val : arr) {
+                GridUnsafe.putDoubleLE(bytes, off, val);
+
+                off += 8;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(arr, DOUBLE_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
 
         onWrite(bytesToCp);
     }
@@ -226,7 +219,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
 
         requestFreeSize(bytesToCp);
 
-        UNSAFE.copyMemory(arr, charArrOff, bytes, byteArrOff + off, bytesToCp);
+        if (BIG_ENDIAN) {
+            long off = BYTE_ARR_OFF + this.off;
+
+            for (char val : arr) {
+                GridUnsafe.putCharLE(bytes, off, val);
+
+                off += 2;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(arr, CHAR_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
 
         onWrite(bytesToCp);
     }
@@ -239,7 +242,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
 
         requestFreeSize(bytesToCp);
 
-        UNSAFE.copyMemory(arr, longArrOff, bytes, byteArrOff + off, bytesToCp);
+        if (BIG_ENDIAN) {
+            long off = BYTE_ARR_OFF + this.off;
+
+            for (long val : arr) {
+                GridUnsafe.putLongLE(bytes, off, val);
+
+                off += 8;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(arr, LONG_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
 
         onWrite(bytesToCp);
     }
@@ -252,7 +265,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
 
         requestFreeSize(bytesToCp);
 
-        UNSAFE.copyMemory(arr, floatArrOff, bytes, byteArrOff + off, bytesToCp);
+        if (BIG_ENDIAN) {
+            long off = BYTE_ARR_OFF + this.off;
+
+            for (float val : arr) {
+                GridUnsafe.putFloatLE(bytes, off, val);
+
+                off += 4;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(arr, FLOAT_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
 
         onWrite(bytesToCp);
     }
@@ -270,7 +293,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
 
         requestFreeSize(arr.length);
 
-        UNSAFE.copyMemory(arr, byteArrOff, bytes, byteArrOff + off, arr.length);
+        GridUnsafe.copyMemory(arr, BYTE_ARR_OFF, bytes, BYTE_ARR_OFF + off, arr.length);
 
         onWrite(arr.length);
     }
@@ -283,7 +306,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
 
         requestFreeSize(bytesToCp);
 
-        UNSAFE.copyMemory(arr, shortArrOff, bytes, byteArrOff + off, bytesToCp);
+        if (BIG_ENDIAN) {
+            long off = BYTE_ARR_OFF + this.off;
+
+            for (short val : arr) {
+                GridUnsafe.putShortLE(bytes, off, val);
+
+                off += 2;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(arr, SHORT_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
 
         onWrite(bytesToCp);
     }
@@ -296,7 +329,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
 
         requestFreeSize(bytesToCp);
 
-        UNSAFE.copyMemory(arr, intArrOff, bytes, byteArrOff + off, bytesToCp);
+        if (BIG_ENDIAN) {
+            long off = BYTE_ARR_OFF + this.off;
+
+            for (int val : arr) {
+                GridUnsafe.putIntLE(bytes, off, val);
+
+                off += 4;
+            }
+        }
+        else
+            GridUnsafe.copyMemory(arr, INT_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
 
         onWrite(bytesToCp);
     }
@@ -310,7 +353,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
     @Override public void writeBoolean(boolean v) throws IOException {
         requestFreeSize(1);
 
-        UNSAFE.putBoolean(bytes, byteArrOff + off, v);
+        GridUnsafe.putBoolean(bytes, BYTE_ARR_OFF + off, v);
 
         onWrite(1);
     }
@@ -319,7 +362,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
     @Override public void writeByte(int v) throws IOException {
         requestFreeSize(1);
 
-        UNSAFE.putByte(bytes, byteArrOff + off, (byte)v);
+        GridUnsafe.putByte(bytes, BYTE_ARR_OFF + off, (byte)v);
 
         onWrite(1);
     }
@@ -328,7 +371,14 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
     @Override public void writeShort(int v) throws IOException {
         requestFreeSize(2);
 
-        UNSAFE.putShort(bytes, byteArrOff + off, (short)v);
+        short val = (short)v;
+
+        long off = BYTE_ARR_OFF + this.off;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putShortLE(bytes, off, val);
+        else
+            GridUnsafe.putShort(bytes, off, val);
 
         onWrite(2);
     }
@@ -337,7 +387,14 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
     @Override public void writeChar(int v) throws IOException {
         requestFreeSize(2);
 
-        UNSAFE.putChar(bytes, byteArrOff + off, (char)v);
+        char val = (char)v;
+
+        long off = BYTE_ARR_OFF + this.off;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putCharLE(bytes, off, val);
+        else
+            GridUnsafe.putChar(bytes, off, val);
 
         onWrite(2);
     }
@@ -346,7 +403,12 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
     @Override public void writeInt(int v) throws IOException {
         requestFreeSize(4);
 
-        UNSAFE.putInt(bytes, byteArrOff + off, v);
+        long off = BYTE_ARR_OFF + this.off;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putIntLE(bytes, off, v);
+        else
+            GridUnsafe.putInt(bytes, off, v);
 
         onWrite(4);
     }
@@ -355,27 +417,28 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
     @Override public void writeLong(long v) throws IOException {
         requestFreeSize(8);
 
-        UNSAFE.putLong(bytes, byteArrOff + off, v);
+        long off = BYTE_ARR_OFF + this.off;
+
+        if (BIG_ENDIAN)
+            GridUnsafe.putLongLE(bytes, off, v);
+        else
+            GridUnsafe.putLong(bytes, off, v);
 
         onWrite(8);
     }
 
     /** {@inheritDoc} */
     @Override public void writeFloat(float v) throws IOException {
-        requestFreeSize(4);
+        int val = Float.floatToIntBits(v);
 
-        UNSAFE.putFloat(bytes, byteArrOff + off, v);
-
-        onWrite(4);
+        writeInt(val);
     }
 
     /** {@inheritDoc} */
     @Override public void writeDouble(double v) throws IOException {
-        requestFreeSize(8);
-
-        UNSAFE.putDouble(bytes, byteArrOff + off, v);
+        long val = Double.doubleToLongBits(v);
 
-        onWrite(8);
+        writeLong(val);
     }
 
     /** {@inheritDoc} */


[04/28] ignite git commit: IGNITE-2191 - Support classes with the same simple name for Binary marshaller - Fixes #398.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSelfTest.java
deleted file mode 100644
index 3b6d0b0..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSelfTest.java
+++ /dev/null
@@ -1,1108 +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.binary;
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import junit.framework.TestCase;
-import org.apache.ignite.IgniteBinary;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses;
-import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
-import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import sun.misc.Unsafe;
-
-/**
- * Binary builder test.
- */
-@SuppressWarnings("ResultOfMethodCallIgnored")
-public class BinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
-    /** */
-    private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
-    /** */
-    protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        BinaryTypeConfiguration customTypeCfg = new BinaryTypeConfiguration();
-
-        customTypeCfg.setTypeName(CustomIdMapper.class.getName());
-        customTypeCfg.setIdMapper(new BinaryIdMapper() {
-            @Override public int typeId(String clsName) {
-                return ~BinaryInternalIdMapper.defaultInstance().typeId(clsName);
-            }
-
-            @Override public int fieldId(int typeId, String fieldName) {
-                return typeId + ~BinaryInternalIdMapper.defaultInstance().fieldId(typeId, fieldName);
-            }
-        });
-
-        BinaryConfiguration bCfg = new BinaryConfiguration();
-
-        bCfg.setCompactFooter(compactFooter());
-
-        bCfg.setTypeConfigurations(Arrays.asList(
-            new BinaryTypeConfiguration(Key.class.getName()),
-            new BinaryTypeConfiguration(Value.class.getName()),
-            new BinaryTypeConfiguration("org.gridgain.grid.internal.util.binary.mutabletest.*"),
-            customTypeCfg));
-
-        cfg.setBinaryConfiguration(bCfg);
-
-        cfg.setMarshaller(new BinaryMarshaller());
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        startGrids(1);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
-    }
-
-    /**
-     * @return Whether to use compact footer.
-     */
-    protected boolean compactFooter() {
-        return true;
-    }
-
-    /**
-     *
-     */
-    public void testAllFieldsSerialization() {
-        GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
-        obj.setDefaultData();
-        obj.enumArr = null;
-
-        GridBinaryTestClasses.TestObjectAllTypes deserialized = builder(toBinary(obj)).build().deserialize();
-
-        GridTestUtils.deepEquals(obj, deserialized);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNullField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(42);
-
-        builder.setField("objField", (Object)null);
-
-        builder.setField("otherField", "value");
-
-        BinaryObject obj = builder.build();
-
-        assertNull(obj.field("objField"));
-        assertEquals("value", obj.field("otherField"));
-        assertEquals(42, obj.hashCode());
-
-        builder = builder(obj);
-
-        builder.setField("objField", "value");
-        builder.setField("otherField", (Object)null);
-
-        obj = builder.build();
-
-        assertNull(obj.field("otherField"));
-        assertEquals("value", obj.field("objField"));
-        assertEquals(42, obj.hashCode());
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testByteField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("byteField", (byte)1);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals((byte) 1, po.<Byte>field("byteField").byteValue());
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testShortField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("shortField", (short)1);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals((short)1, po.<Short>field("shortField").shortValue());
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testIntField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("intField", 1);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals(1, po.<Integer>field("intField").intValue());
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testLongField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("longField", 1L);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals(1L, po.<Long>field("longField").longValue());
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testFloatField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("floatField", 1.0f);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals(1.0f, po.<Float>field("floatField").floatValue(), 0);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testDoubleField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("doubleField", 1.0d);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals(1.0d, po.<Double>field("doubleField").doubleValue(), 0);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testCharField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("charField", (char)1);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals((char)1, po.<Character>field("charField").charValue());
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBooleanField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("booleanField", true);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(po.<Boolean>field("booleanField"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testDecimalField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("decimalField", BigDecimal.TEN);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals(BigDecimal.TEN, po.<BigDecimal>field("decimalField"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testStringField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("stringField", "str");
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals("str", po.<String>field("stringField"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testDateField() throws Exception {
-        Date date = new Date();
-
-        assertEquals(date, builder("C").setField("d", date).build().<Date>field("d"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testTimestampField() throws Exception {
-        Timestamp ts = new Timestamp(new Date().getTime());
-        ts.setNanos(1000);
-
-        assertEquals(ts, builder("C").setField("t", ts).build().<Timestamp>field("t"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testUuidField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        UUID uuid = UUID.randomUUID();
-
-        builder.setField("uuidField", uuid);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals(uuid, po.<UUID>field("uuidField"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testByteArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("byteArrayField", new byte[] {1, 2, 3});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(Arrays.equals(new byte[] {1, 2, 3}, po.<byte[]>field("byteArrayField")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testShortArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("shortArrayField", new short[] {1, 2, 3});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(Arrays.equals(new short[] {1, 2, 3}, po.<short[]>field("shortArrayField")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testIntArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("intArrayField", new int[] {1, 2, 3});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("intArrayField")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testLongArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("longArrayField", new long[] {1, 2, 3});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(Arrays.equals(new long[] {1, 2, 3}, po.<long[]>field("longArrayField")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testFloatArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("floatArrayField", new float[] {1, 2, 3});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(Arrays.equals(new float[] {1, 2, 3}, po.<float[]>field("floatArrayField")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testDoubleArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("doubleArrayField", new double[] {1, 2, 3});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(Arrays.equals(new double[] {1, 2, 3}, po.<double[]>field("doubleArrayField")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testCharArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("charArrayField", new char[] {1, 2, 3});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(Arrays.equals(new char[] {1, 2, 3}, po.<char[]>field("charArrayField")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBooleanArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("booleanArrayField", new boolean[] {true, false});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        boolean[] arr = po.field("booleanArrayField");
-
-        assertEquals(2, arr.length);
-
-        assertTrue(arr[0]);
-        assertFalse(arr[1]);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testDecimalArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("decimalArrayField", new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(Arrays.equals(new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN}, po.<String[]>field("decimalArrayField")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testStringArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("stringArrayField", new String[] {"str1", "str2", "str3"});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(Arrays.equals(new String[] {"str1", "str2", "str3"}, po.<String[]>field("stringArrayField")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testDateArrayField() throws Exception {
-        Date date1 = new Date();
-        Date date2 = new Date(date1.getTime() + 1000);
-
-        Date[] dateArr = new Date[] { date1, date2 };
-
-        assertTrue(Arrays.equals(dateArr, builder("C").setField("da", dateArr).build().<Date[]>field("da")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testTimestampArrayField() throws Exception {
-        Timestamp ts1 = new Timestamp(new Date().getTime());
-        Timestamp ts2 = new Timestamp(new Date().getTime() + 1000);
-
-        ts1.setNanos(1000);
-        ts2.setNanos(2000);
-
-        Timestamp[] tsArr = new Timestamp[] { ts1, ts2 };
-
-        assertTrue(Arrays.equals(tsArr, builder("C").setField("ta", tsArr).build().<Timestamp[]>field("ta")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testUuidArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID()};
-
-        builder.setField("uuidArrayField", arr);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertTrue(Arrays.equals(arr, po.<UUID[]>field("uuidArrayField")));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testObjectField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("objectField", new Value(1));
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals(1, po.<BinaryObject>field("objectField").<Value>deserialize().i);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testObjectArrayField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("objectArrayField", new Value[] {new Value(1), new Value(2)});
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        Object[] arr = po.field("objectArrayField");
-
-        assertEquals(2, arr.length);
-
-        assertEquals(1, ((BinaryObject)arr[0]).<Value>deserialize().i);
-        assertEquals(2, ((BinaryObject)arr[1]).<Value>deserialize().i);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testCollectionField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("collectionField", Arrays.asList(new Value(1), new Value(2)));
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        List<BinaryObject> list = po.field("collectionField");
-
-        assertEquals(2, list.size());
-
-        assertEquals(1, list.get(0).<Value>deserialize().i);
-        assertEquals(2, list.get(1).<Value>deserialize().i);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testMapField() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("mapField", F.asMap(new Key(1), new Value(1), new Key(2), new Value(2)));
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        Map<BinaryObject, BinaryObject> map = po.field("mapField");
-
-        assertEquals(2, map.size());
-
-        for (Map.Entry<BinaryObject, BinaryObject> e : map.entrySet())
-            assertEquals(e.getKey().<Key>deserialize().i, e.getValue().<Value>deserialize().i);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testSeveralFields() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("i", 111);
-        builder.setField("f", 111.111f);
-        builder.setField("iArr", new int[] {1, 2, 3});
-        builder.setField("obj", new Key(1));
-        builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
-
-        BinaryObject po = builder.build();
-
-        assertEquals("class".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals(111, po.<Integer>field("i").intValue());
-        assertEquals(111.111f, po.<Float>field("f").floatValue(), 0);
-        assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("iArr")));
-        assertEquals(1, po.<BinaryObject>field("obj").<Key>deserialize().i);
-
-        List<BinaryObject> list = po.field("col");
-
-        assertEquals(2, list.size());
-
-        assertEquals(1, list.get(0).<Value>deserialize().i);
-        assertEquals(2, list.get(1).<Value>deserialize().i);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testOffheapBinary() throws Exception {
-        BinaryObjectBuilder builder = builder("Class");
-
-        builder.hashCode(100);
-
-        builder.setField("i", 111);
-        builder.setField("f", 111.111f);
-        builder.setField("iArr", new int[] {1, 2, 3});
-        builder.setField("obj", new Key(1));
-        builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
-
-        BinaryObject po = builder.build();
-
-        byte[] arr = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).marshal(po);
-
-        long ptr = UNSAFE.allocateMemory(arr.length + 5);
-
-        try {
-            long ptr0 = ptr;
-
-            UNSAFE.putBoolean(null, ptr0++, false);
-
-            UNSAFE.putInt(ptr0, arr.length);
-
-            UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr0 + 4, arr.length);
-
-            BinaryObject offheapObj = (BinaryObject)
-                ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).unmarshal(ptr, false);
-
-            assertEquals(BinaryObjectOffheapImpl.class, offheapObj.getClass());
-
-            assertEquals("class".hashCode(), offheapObj.type().typeId());
-            assertEquals(100, offheapObj.hashCode());
-
-            assertEquals(111, offheapObj.<Integer>field("i").intValue());
-            assertEquals(111.111f, offheapObj.<Float>field("f").floatValue(), 0);
-            assertTrue(Arrays.equals(new int[] {1, 2, 3}, offheapObj.<int[]>field("iArr")));
-            assertEquals(1, offheapObj.<BinaryObject>field("obj").<Key>deserialize().i);
-
-            List<BinaryObject> list = offheapObj.field("col");
-
-            assertEquals(2, list.size());
-
-            assertEquals(1, list.get(0).<Value>deserialize().i);
-            assertEquals(2, list.get(1).<Value>deserialize().i);
-
-            assertEquals(po, offheapObj);
-            assertEquals(offheapObj, po);
-        }
-        finally {
-            UNSAFE.freeMemory(ptr);
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBuildAndDeserialize() throws Exception {
-        BinaryObjectBuilder builder = builder(Value.class.getName());
-
-        builder.hashCode(100);
-
-        builder.setField("i", 1);
-
-        BinaryObject po = builder.build();
-
-        assertEquals("value".hashCode(), po.type().typeId());
-        assertEquals(100, po.hashCode());
-
-        assertEquals(1, po.<Value>deserialize().i);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testMetaData2() throws Exception {
-        BinaryObjectBuilder builder = builder("org.test.MetaTest2");
-
-        builder.setField("objectField", "a", Object.class);
-
-        BinaryObject po = builder.build();
-
-        BinaryType meta = po.type();
-
-        assertEquals("MetaTest2", meta.typeName());
-        assertEquals("Object", meta.fieldTypeName("objectField"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testMetaData() throws Exception {
-        BinaryObjectBuilder builder = builder("org.test.MetaTest");
-
-        builder.hashCode(100);
-
-        builder.setField("intField", 1);
-        builder.setField("byteArrayField", new byte[] {1, 2, 3});
-
-        BinaryObject po = builder.build();
-
-        BinaryType meta = po.type();
-
-        assertEquals("MetaTest", meta.typeName());
-
-        Collection<String> fields = meta.fieldNames();
-
-        assertEquals(2, fields.size());
-
-        assertTrue(fields.contains("intField"));
-        assertTrue(fields.contains("byteArrayField"));
-
-        assertEquals("int", meta.fieldTypeName("intField"));
-        assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
-
-        builder = builder("org.test.MetaTest");
-
-        builder.hashCode(100);
-
-        builder.setField("intField", 2);
-        builder.setField("uuidField", UUID.randomUUID());
-
-        po = builder.build();
-
-        meta = po.type();
-
-        assertEquals("MetaTest", meta.typeName());
-
-        fields = meta.fieldNames();
-
-        assertEquals(3, fields.size());
-
-        assertTrue(fields.contains("intField"));
-        assertTrue(fields.contains("byteArrayField"));
-        assertTrue(fields.contains("uuidField"));
-
-        assertEquals("int", meta.fieldTypeName("intField"));
-        assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
-        assertEquals("UUID", meta.fieldTypeName("uuidField"));
-    }
-
-    /**
-     *
-     */
-    public void testGetFromCopiedObj() {
-        BinaryObject objStr = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName()).setField("str", "aaa").build();
-
-        BinaryObjectBuilderImpl builder = builder(objStr);
-        assertEquals("aaa", builder.getField("str"));
-
-        builder.setField("str", "bbb");
-        assertEquals("bbb", builder.getField("str"));
-
-        assertNull(builder.getField("i_"));
-        TestCase.assertEquals("bbb", builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
-    }
-
-    /**
-     *
-     */
-    @SuppressWarnings("unchecked")
-    public void testCopyFromInnerObjects() {
-        ArrayList<Object> list = new ArrayList<>();
-        list.add(new GridBinaryTestClasses.TestObjectAllTypes());
-        list.add(list.get(0));
-
-        GridBinaryTestClasses.TestObjectContainer c = new GridBinaryTestClasses.TestObjectContainer(list);
-
-        BinaryObjectBuilderImpl builder = builder(toBinary(c));
-        builder.<List>getField("foo").add("!!!");
-
-        BinaryObject res = builder.build();
-
-        GridBinaryTestClasses.TestObjectContainer deserialized = res.deserialize();
-
-        List deserializedList = (List)deserialized.foo;
-
-        assertSame(deserializedList.get(0), deserializedList.get(1));
-        assertEquals("!!!", deserializedList.get(2));
-        assertTrue(deserializedList.get(0) instanceof GridBinaryTestClasses.TestObjectAllTypes);
-    }
-
-    /**
-     *
-     */
-    public void testSetBinaryObject() {
-        // Prepare marshaller context.
-        CacheObjectBinaryProcessorImpl proc = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects());
-
-        proc.marshal(new GridBinaryTestClasses.TestObjectContainer());
-        proc.marshal(new GridBinaryTestClasses.TestObjectAllTypes());
-
-        // Actual test.
-        BinaryObject binaryObj = builder(GridBinaryTestClasses.TestObjectContainer.class.getName())
-            .setField("foo", toBinary(new GridBinaryTestClasses.TestObjectAllTypes()))
-            .build();
-
-        assertTrue(binaryObj.<GridBinaryTestClasses.TestObjectContainer>deserialize().foo instanceof
-            GridBinaryTestClasses.TestObjectAllTypes);
-    }
-
-    /**
-     *
-     */
-    public void testPlainBinaryObjectCopyFrom() {
-        GridBinaryTestClasses.TestObjectPlainBinary obj = new GridBinaryTestClasses.TestObjectPlainBinary(toBinary(new GridBinaryTestClasses.TestObjectAllTypes()));
-
-        BinaryObjectBuilderImpl builder = builder(toBinary(obj));
-        assertTrue(builder.getField("plainBinary") instanceof BinaryObject);
-
-        GridBinaryTestClasses.TestObjectPlainBinary deserialized = builder.build().deserialize();
-        assertTrue(deserialized.plainBinary != null);
-    }
-
-    /**
-     *
-     */
-    public void testRemoveFromNewObject() {
-        BinaryObjectBuilder builder = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName());
-
-        builder.setField("str", "a");
-
-        builder.removeField("str");
-
-        TestCase.assertNull(builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
-    }
-
-    /**
-     *
-     */
-    public void testRemoveFromExistingObject() {
-        GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
-        obj.setDefaultData();
-        obj.enumArr = null;
-
-        BinaryObjectBuilder builder = builder(toBinary(obj));
-
-        builder.removeField("str");
-
-        BinaryObject binary = builder.build();
-
-        GridBinaryTestClasses.TestObjectAllTypes deserialzied = binary.deserialize();
-
-        assertNull(deserialzied.str);
-    }
-
-    /**
-     *
-     */
-    public void testRemoveFromExistingObjectAfterGet() {
-        GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
-        obj.setDefaultData();
-        obj.enumArr = null;
-
-        BinaryObjectBuilderImpl builder = builder(toBinary(obj));
-
-        builder.getField("i_");
-
-        builder.removeField("str");
-
-        TestCase.assertNull(builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
-    }
-
-    /**
-     * @throws IgniteCheckedException If any error occurs.
-     */
-    public void testDontBrokeCyclicDependency() throws IgniteCheckedException {
-        GridBinaryTestClasses.TestObjectOuter outer = new GridBinaryTestClasses.TestObjectOuter();
-        outer.inner = new GridBinaryTestClasses.TestObjectInner();
-        outer.inner.outer = outer;
-        outer.foo = "a";
-
-        BinaryObjectBuilder builder = builder(toBinary(outer));
-
-        builder.setField("foo", "b");
-
-        GridBinaryTestClasses.TestObjectOuter res = builder.build().deserialize();
-
-        assertEquals("b", res.foo);
-        assertSame(res, res.inner.outer);
-    }
-
-    /**
-     * @return Binaries.
-     */
-    private IgniteBinary binaries() {
-        return grid(0).binary();
-    }
-
-    /**
-     * @param obj Object.
-     * @return Binary object.
-     */
-    private BinaryObject toBinary(Object obj) {
-        return binaries().toBinary(obj);
-    }
-
-    /**
-     * @return Builder.
-     */
-    private BinaryObjectBuilder builder(String clsName) {
-        return binaries().builder(clsName);
-    }
-
-    /**
-     * @return Builder.
-     */
-    private BinaryObjectBuilderImpl builder(BinaryObject obj) {
-        return (BinaryObjectBuilderImpl)binaries().builder(obj);
-    }
-
-    /**
-     *
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    private static class CustomIdMapper {
-        /** */
-        private String str = "a";
-
-        /** */
-        private int i = 10;
-    }
-
-    /**
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    private static class Key {
-        /** */
-        private int i;
-
-        /**
-         */
-        private Key() {
-            // No-op.
-        }
-
-        /**
-         * @param i Index.
-         */
-        private Key(int i) {
-            this.i = i;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            if (this == o)
-                return true;
-
-            if (o == null || getClass() != o.getClass())
-                return false;
-
-            Key key = (Key)o;
-
-            return i == key.i;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return i;
-        }
-    }
-
-    /**
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    private static class Value {
-        /** */
-        private int i;
-
-        /**
-         */
-        private Value() {
-            // No-op.
-        }
-
-        /**
-         * @param i Index.
-         */
-        private Value(int i) {
-            this.i = i;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.java
new file mode 100644
index 0000000..da87072
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.binary;
+
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+/**
+ * Binary builder test.
+ */
+@SuppressWarnings("ResultOfMethodCallIgnored")
+public class BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest extends BinaryObjectBuilderDefaultMappersSelfTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
+
+        bCfg.setIdMapper(new BinaryBasicIdMapper(true));
+        bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+
+        return cfg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java
new file mode 100644
index 0000000..8f2df9e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.binary;
+
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.testframework.config.GridTestProperties;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.testframework.config.GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER;
+import static org.apache.ignite.testframework.config.GridTestProperties.MARSH_CLASS_NAME;
+
+/**
+ * Tests testing framewrok, epecially BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER test property.
+ */
+public class BinarySimpleNameTestPropertySelfTest extends GridCommonAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPropertyEnabled() throws Exception {
+        String useSimpleNameBackup = GridTestProperties.getProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER);
+
+        try {
+            GridTestProperties.setProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+
+            checkProperty("TestClass");
+        }
+        finally {
+            if (useSimpleNameBackup != null)
+                GridTestProperties.setProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPropertyDisabled() throws Exception {
+        checkProperty("org.ignite.test.TestClass");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testBinaryDisabled() throws Exception {
+        assertNull(startGrid().binary());
+    }
+
+    /**
+     * @param expTypeName Type name.
+     * @throws Exception If failed.
+     */
+    private void checkProperty(String expTypeName) throws Exception {
+        String marshBackup = GridTestProperties.getProperty(MARSH_CLASS_NAME);
+
+        try {
+            GridTestProperties.setProperty(MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+
+            IgniteBinary binary = startGrid().binary();
+
+            BinaryObjectBuilder builder = binary.builder("org.ignite.test.TestClass");
+
+            BinaryObject bObj = builder.build();
+
+            assertEquals(expTypeName, bObj.type().typeName());
+        }
+        finally {
+            if (marshBackup != null)
+                GridTestProperties.setProperty(MARSH_CLASS_NAME, marshBackup);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMetaDataSelfTest.java
deleted file mode 100644
index 5c5d6c3..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMetaDataSelfTest.java
+++ /dev/null
@@ -1,371 +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.binary;
-
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import org.apache.ignite.IgniteBinary;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- * Binary meta data test.
- */
-public class GridBinaryMetaDataSelfTest extends GridCommonAbstractTest {
-    /** */
-    private static int idx;
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        BinaryConfiguration bCfg = new BinaryConfiguration();
-
-        bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
-
-        cfg.setBinaryConfiguration(bCfg);
-
-        cfg.setMarshaller(new BinaryMarshaller());
-
-        CacheConfiguration ccfg = new CacheConfiguration();
-
-        cfg.setCacheConfiguration(ccfg);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        idx = 0;
-
-        startGrid();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        stopGrid();
-    }
-
-    /**
-     * @return Binaries API.
-     */
-    protected IgniteBinary binaries() {
-        return grid().binary();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testGetAll() throws Exception {
-        binaries().toBinary(new TestObject2());
-
-        Collection<BinaryType> metas = binaries().types();
-
-        assertEquals(2, metas.size());
-
-        for (BinaryType meta : metas) {
-            Collection<String> fields;
-
-            switch (meta.typeName()) {
-                case "TestObject1":
-                    fields = meta.fieldNames();
-
-                    assertEquals(7, fields.size());
-
-                    assertTrue(fields.contains("intVal"));
-                    assertTrue(fields.contains("strVal"));
-                    assertTrue(fields.contains("arrVal"));
-                    assertTrue(fields.contains("obj1Val"));
-                    assertTrue(fields.contains("obj2Val"));
-                    assertTrue(fields.contains("decVal"));
-                    assertTrue(fields.contains("decArrVal"));
-
-                    assertEquals("int", meta.fieldTypeName("intVal"));
-                    assertEquals("String", meta.fieldTypeName("strVal"));
-                    assertEquals("byte[]", meta.fieldTypeName("arrVal"));
-                    assertEquals("Object", meta.fieldTypeName("obj1Val"));
-                    assertEquals("Object", meta.fieldTypeName("obj2Val"));
-                    assertEquals("decimal", meta.fieldTypeName("decVal"));
-                    assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
-
-                    break;
-
-                case "TestObject2":
-                    fields = meta.fieldNames();
-
-                    assertEquals(7, fields.size());
-
-                    assertTrue(fields.contains("boolVal"));
-                    assertTrue(fields.contains("dateVal"));
-                    assertTrue(fields.contains("uuidArrVal"));
-                    assertTrue(fields.contains("objVal"));
-                    assertTrue(fields.contains("mapVal"));
-                    assertTrue(fields.contains("decVal"));
-                    assertTrue(fields.contains("decArrVal"));
-
-                    assertEquals("boolean", meta.fieldTypeName("boolVal"));
-                    assertEquals("Date", meta.fieldTypeName("dateVal"));
-                    assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
-                    assertEquals("Object", meta.fieldTypeName("objVal"));
-                    assertEquals("Map", meta.fieldTypeName("mapVal"));
-                    assertEquals("decimal", meta.fieldTypeName("decVal"));
-                    assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
-
-                    break;
-
-                default:
-                    assert false : meta.typeName();
-            }
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNoConfiguration() throws Exception {
-        binaries().toBinary(new TestObject3());
-
-        assertNotNull(binaries().type(TestObject3.class));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testReflection() throws Exception {
-        BinaryType meta = binaries().type(TestObject1.class);
-
-        assertNotNull(meta);
-
-        assertEquals("TestObject1", meta.typeName());
-
-        Collection<String> fields = meta.fieldNames();
-
-        assertEquals(7, fields.size());
-
-        assertTrue(fields.contains("intVal"));
-        assertTrue(fields.contains("strVal"));
-        assertTrue(fields.contains("arrVal"));
-        assertTrue(fields.contains("obj1Val"));
-        assertTrue(fields.contains("obj2Val"));
-        assertTrue(fields.contains("decVal"));
-        assertTrue(fields.contains("decArrVal"));
-
-        assertEquals("int", meta.fieldTypeName("intVal"));
-        assertEquals("String", meta.fieldTypeName("strVal"));
-        assertEquals("byte[]", meta.fieldTypeName("arrVal"));
-        assertEquals("Object", meta.fieldTypeName("obj1Val"));
-        assertEquals("Object", meta.fieldTypeName("obj2Val"));
-        assertEquals("decimal", meta.fieldTypeName("decVal"));
-        assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBinaryMarshalAware() throws Exception {
-        binaries().toBinary(new TestObject2());
-
-        BinaryType meta = binaries().type(TestObject2.class);
-
-        assertNotNull(meta);
-
-        assertEquals("TestObject2", meta.typeName());
-
-        Collection<String> fields = meta.fieldNames();
-
-        assertEquals(7, fields.size());
-
-        assertTrue(fields.contains("boolVal"));
-        assertTrue(fields.contains("dateVal"));
-        assertTrue(fields.contains("uuidArrVal"));
-        assertTrue(fields.contains("objVal"));
-        assertTrue(fields.contains("mapVal"));
-        assertTrue(fields.contains("decVal"));
-        assertTrue(fields.contains("decArrVal"));
-
-        assertEquals("boolean", meta.fieldTypeName("boolVal"));
-        assertEquals("Date", meta.fieldTypeName("dateVal"));
-        assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
-        assertEquals("Object", meta.fieldTypeName("objVal"));
-        assertEquals("Map", meta.fieldTypeName("mapVal"));
-        assertEquals("decimal", meta.fieldTypeName("decVal"));
-        assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testMerge() throws Exception {
-        binaries().toBinary(new TestObject2());
-
-        idx = 1;
-
-        binaries().toBinary(new TestObject2());
-
-        BinaryType meta = binaries().type(TestObject2.class);
-
-        assertNotNull(meta);
-
-        assertEquals("TestObject2", meta.typeName());
-
-        Collection<String> fields = meta.fieldNames();
-
-        assertEquals(9, fields.size());
-
-        assertTrue(fields.contains("boolVal"));
-        assertTrue(fields.contains("dateVal"));
-        assertTrue(fields.contains("uuidArrVal"));
-        assertTrue(fields.contains("objVal"));
-        assertTrue(fields.contains("mapVal"));
-        assertTrue(fields.contains("charVal"));
-        assertTrue(fields.contains("colVal"));
-        assertTrue(fields.contains("decVal"));
-        assertTrue(fields.contains("decArrVal"));
-
-        assertEquals("boolean", meta.fieldTypeName("boolVal"));
-        assertEquals("Date", meta.fieldTypeName("dateVal"));
-        assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
-        assertEquals("Object", meta.fieldTypeName("objVal"));
-        assertEquals("Map", meta.fieldTypeName("mapVal"));
-        assertEquals("char", meta.fieldTypeName("charVal"));
-        assertEquals("Collection", meta.fieldTypeName("colVal"));
-        assertEquals("decimal", meta.fieldTypeName("decVal"));
-        assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testSerializedObject() throws Exception {
-        TestObject1 obj = new TestObject1();
-
-        obj.intVal = 10;
-        obj.strVal = "str";
-        obj.arrVal = new byte[] {2, 4, 6};
-        obj.obj1Val = null;
-        obj.obj2Val = new TestObject2();
-        obj.decVal = BigDecimal.ZERO;
-        obj.decArrVal = new BigDecimal[] { BigDecimal.ONE };
-
-        BinaryObject po = binaries().toBinary(obj);
-
-        info(po.toString());
-
-        BinaryType meta = po.type();
-
-        assertNotNull(meta);
-
-        assertEquals("TestObject1", meta.typeName());
-
-        Collection<String> fields = meta.fieldNames();
-
-        assertEquals(7, fields.size());
-
-        assertTrue(fields.contains("intVal"));
-        assertTrue(fields.contains("strVal"));
-        assertTrue(fields.contains("arrVal"));
-        assertTrue(fields.contains("obj1Val"));
-        assertTrue(fields.contains("obj2Val"));
-        assertTrue(fields.contains("decVal"));
-        assertTrue(fields.contains("decArrVal"));
-
-        assertEquals("int", meta.fieldTypeName("intVal"));
-        assertEquals("String", meta.fieldTypeName("strVal"));
-        assertEquals("byte[]", meta.fieldTypeName("arrVal"));
-        assertEquals("Object", meta.fieldTypeName("obj1Val"));
-        assertEquals("Object", meta.fieldTypeName("obj2Val"));
-        assertEquals("decimal", meta.fieldTypeName("decVal"));
-        assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
-    }
-
-    /**
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    private static class TestObject1 {
-        /** */
-        private int intVal;
-
-        /** */
-        private String strVal;
-
-        /** */
-        private byte[] arrVal;
-
-        /** */
-        private TestObject1 obj1Val;
-
-        /** */
-        private TestObject2 obj2Val;
-
-        /** */
-        private BigDecimal decVal;
-
-        /** */
-        private BigDecimal[] decArrVal;
-    }
-
-    /**
-     */
-    private static class TestObject2 implements Binarylizable {
-        /** {@inheritDoc} */
-        @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
-            writer.writeBoolean("boolVal", false);
-            writer.writeDate("dateVal", new Date());
-            writer.writeUuidArray("uuidArrVal", null);
-            writer.writeObject("objVal", null);
-            writer.writeMap("mapVal", new HashMap<>());
-            writer.writeDecimal("decVal", BigDecimal.ZERO);
-            writer.writeDecimalArray("decArrVal", new BigDecimal[] { BigDecimal.ONE });
-
-            if (idx == 1) {
-                writer.writeChar("charVal", (char)0);
-                writer.writeCollection("colVal", null);
-            }
-
-            BinaryRawWriter raw = writer.rawWriter();
-
-            raw.writeChar((char)0);
-            raw.writeCollection(null);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
-            // No-op.
-        }
-    }
-
-    /**
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    private static class TestObject3 {
-        /** */
-        private int intVal;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
index ae0cfa0..d0d63b3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
@@ -17,31 +17,67 @@
 
 package org.apache.ignite.internal.binary;
 
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.Map;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
 import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
 import org.apache.ignite.binary.BinarySerializer;
 import org.apache.ignite.binary.BinaryTypeConfiguration;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.test.GridBinaryTestClass1;
+import org.apache.ignite.internal.binary.test.GridBinaryTestClass2;
 import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.logger.NullLogger;
 import org.apache.ignite.marshaller.MarshallerContextTestImpl;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
-import java.util.Arrays;
-import java.util.Map;
-
 /**
  * Wildcards test.
  */
 public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
+    /** */
+    public static final String CLASS1_FULL_NAME = GridBinaryTestClass1.class.getName();
+
+    /** */
+    public static final String CLASS2_FULL_NAME = GridBinaryTestClass2.class.getName();
+
+    /** */
+    public static final String INNER_CLASS_FULL_NAME = GridBinaryTestClass1.class.getName() + "$InnerClass";
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClassNamesFullNameMapper() throws Exception {
+        checkClassNames(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClassNamesSimpleNameMapper() throws Exception {
+        checkClassNames(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClassNamesMixedMappers() throws Exception {
+        checkClassNames(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(true));
+    }
+
     /**
      * @throws Exception If failed.
+     * @param nameMapper Name mapper.
+     * @param mapper ID mapper.
      */
-    public void testClassNames() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+    private void checkClassNames(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws Exception {
+        BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList(
             new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
             new BinaryTypeConfiguration("unknown.*")
         ));
@@ -52,16 +88,16 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         assertEquals(3, typeIds.size());
 
-        assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
-        assertTrue(typeIds.containsKey("gridbinarytestclass2".hashCode()));
-        assertTrue(typeIds.containsKey("innerclass".hashCode()));
+        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
+        assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, mapper)));
+        assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testClassNamesWithMapper() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+    public void testClassNamesCustomMappers() throws Exception {
+        BinaryMarshaller marsh = binaryMarshaller(null, new BinaryIdMapper() {
             @SuppressWarnings("IfMayBeConditional")
             @Override public int typeId(String clsName) {
                 if (clsName.endsWith("1"))
@@ -84,20 +120,37 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+        Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
 
         assertEquals(3, typeMappers.size());
 
-        assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
-        assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
-        assertEquals(500, typeMappers.get("InnerClass").typeId("InnerClass"));
+        assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+        assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
+        assertEquals(500, typeMappers.get(INNER_CLASS_FULL_NAME).idMapper().typeId(INNER_CLASS_FULL_NAME));
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testTypeConfigurations() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+    public void testTypeConfigurationsSimpleNameIdMapper() throws Exception {
+        checkTypeConfigurations(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTypeConfigurationsFullNameIdMapper() throws Exception {
+        checkTypeConfigurations(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+    }
+
+    /**
+     *
+     * @param nameMapper Name mapper.
+     * @param idMapper ID mapper.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void checkTypeConfigurations(BinaryNameMapper nameMapper, BinaryIdMapper idMapper) throws IgniteCheckedException {
+        BinaryMarshaller marsh = binaryMarshaller(nameMapper, idMapper, Arrays.asList(
             new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
             new BinaryTypeConfiguration("unknown.*")
         ));
@@ -108,16 +161,31 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         assertEquals(3, typeIds.size());
 
-        assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
-        assertTrue(typeIds.containsKey("gridbinarytestclass2".hashCode()));
-        assertTrue(typeIds.containsKey("innerclass".hashCode()));
+        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, idMapper)));
+    }
+
+    /**
+     * @param typeName Type name.
+     * @param nameMapper Name mapper.
+     * @param mapper ID mapper.  @return Type ID.
+     */
+    private int typeId(String typeName, BinaryNameMapper nameMapper, BinaryIdMapper mapper) {
+        if (mapper == null)
+            mapper = BinaryContext.defaultIdMapper();
+
+        if (nameMapper == null)
+            nameMapper = BinaryContext.defaultNameMapper();
+
+        return mapper.typeId(nameMapper.typeName(typeName));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTypeConfigurationsWithGlobalMapper() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {
             @SuppressWarnings("IfMayBeConditional")
             @Override public int typeId(String clsName) {
                 if (clsName.endsWith("1"))
@@ -140,20 +208,20 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+        Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
 
         assertEquals(3, typeMappers.size());
 
-        assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
-        assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
-        assertEquals(500, typeMappers.get("InnerClass").typeId("InnerClass"));
+        assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+        assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
+        assertEquals(500, typeMappers.get(INNER_CLASS_FULL_NAME).idMapper().typeId(INNER_CLASS_FULL_NAME));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTypeConfigurationsWithNonGlobalMapper() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryIdMapper() {
             @SuppressWarnings("IfMayBeConditional")
             @Override public int typeId(String clsName) {
                 if (clsName.endsWith("1"))
@@ -176,22 +244,39 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+        Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
 
         assertEquals(3, typeMappers.size());
 
-        assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
-        assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
-        assertEquals(500, typeMappers.get("InnerClass").typeId("InnerClass"));
+        assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+        assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
+        assertEquals(500, typeMappers.get(INNER_CLASS_FULL_NAME).idMapper().typeId(INNER_CLASS_FULL_NAME));
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testOverride() throws Exception {
+    public void testOverrideIdMapperSimpleNameMapper() throws Exception {
+        checkOverrideNameMapper(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOverrideIdMapperFullNameMapper() throws Exception {
+        checkOverrideNameMapper(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+    }
+
+    /**
+     *
+     * @param nameMapper Name mapper.
+     * @param mapper Mapper.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void checkOverrideIdMapper(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws IgniteCheckedException {
         BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
 
-        typeCfg.setTypeName("GridBinaryTestClass2");
+        typeCfg.setTypeName(CLASS2_FULL_NAME);
         typeCfg.setIdMapper(new BinaryIdMapper() {
             @Override public int typeId(String clsName) {
                 return 100;
@@ -202,7 +287,7 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
             }
         });
 
-        BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+        BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList(
             new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
             typeCfg));
 
@@ -212,20 +297,90 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         assertEquals(3, typeIds.size());
 
-        assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
-        assertTrue(typeIds.containsKey("innerclass".hashCode()));
-        assertFalse(typeIds.containsKey(100));
+        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
+        assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
+        assertTrue(typeIds.containsKey(100));
 
-        Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+        Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
 
-        assertEquals(100, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
+        assertEquals(100, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testClassNamesJar() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+    public void testOverrideNameMapperSimpleNameMapper() throws Exception {
+        checkOverrideNameMapper(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOverrideNameMapperFullNameMapper() throws Exception {
+        checkOverrideNameMapper(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+    }
+
+    /**
+     *
+     * @param nameMapper Name mapper.
+     * @param mapper Mapper.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void checkOverrideNameMapper(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws IgniteCheckedException {
+        BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
+
+        typeCfg.setTypeName(CLASS2_FULL_NAME);
+        typeCfg.setNameMapper(new BinaryNameMapper() {
+            @Override public String typeName(String clsName) {
+                return "type2";
+            }
+
+            @Override public String fieldName(String fieldName) {
+                return "field2";
+            }
+        });
+
+        BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList(
+            new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
+            typeCfg));
+
+        BinaryContext ctx = binaryContext(marsh);
+
+        Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
+
+        assertEquals(3, typeIds.size());
+
+        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
+        assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
+        assertTrue(typeIds.containsKey("type2".hashCode()));
+
+        Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
+
+        assertEquals("type2", typeMappers.get(CLASS2_FULL_NAME).nameMapper().typeName(CLASS2_FULL_NAME));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClassNamesJarFullNameMapper() throws Exception {
+        checkClassNamesJar(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClassNamesJarSimpleNameMapper() throws Exception {
+        checkClassNamesJar(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+    }
+
+    /**
+     *
+     * @param nameMapper Name mapper.
+     * @param idMapper Mapper.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void checkClassNamesJar(BinaryNameMapper nameMapper, BinaryIdMapper idMapper) throws IgniteCheckedException {
+        BinaryMarshaller marsh = binaryMarshaller(nameMapper, idMapper, Arrays.asList(
             new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
             new BinaryTypeConfiguration("unknown.*")
         ));
@@ -236,15 +391,15 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         assertEquals(3, typeIds.size());
 
-        assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
-        assertTrue(typeIds.containsKey("gridbinarytestclass2".hashCode()));
+        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testClassNamesWithMapperJar() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+    public void testClassNamesWithCustomMapperJar() throws Exception {
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {
             @SuppressWarnings("IfMayBeConditional")
             @Override public int typeId(String clsName) {
                 if (clsName.endsWith("1"))
@@ -265,19 +420,40 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+        Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
 
         assertEquals(3, typeMappers.size());
 
-        assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
-        assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
+        assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS1_FULL_NAME).nameMapper()).isSimpleName());
+        assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+
+        assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS2_FULL_NAME).nameMapper()).isSimpleName());
+        assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTypeConfigurationsJarSimpleNameMapper() throws Exception {
+        checkTypeConfigurationJar(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testTypeConfigurationsJar() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+    public void testTypeConfigurationsJarFullNameMapper() throws Exception {
+        checkTypeConfigurationJar(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+    }
+
+    /**
+     *
+     * @param nameMapper
+     * @param idMapper Mapper.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void checkTypeConfigurationJar(BinaryNameMapper nameMapper, BinaryIdMapper idMapper)
+        throws IgniteCheckedException {
+        BinaryMarshaller marsh = binaryMarshaller(nameMapper, idMapper, Arrays.asList(
             new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
             new BinaryTypeConfiguration("unknown.*")
         ));
@@ -288,15 +464,15 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         assertEquals(3, typeIds.size());
 
-        assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
-        assertTrue(typeIds.containsKey("gridbinarytestclass2".hashCode()));
+        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTypeConfigurationsWithGlobalMapperJar() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {
             @SuppressWarnings("IfMayBeConditional")
             @Override public int typeId(String clsName) {
                 if (clsName.endsWith("1"))
@@ -317,19 +493,22 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+        Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
 
         assertEquals(3, typeMappers.size());
 
-        assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
-        assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
+        assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS1_FULL_NAME).nameMapper()).isSimpleName());
+        assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+
+        assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS2_FULL_NAME).nameMapper()).isSimpleName());
+        assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTypeConfigurationsWithNonGlobalMapperJar() throws Exception {
-        BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+        BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {
             @SuppressWarnings("IfMayBeConditional")
             @Override public int typeId(String clsName) {
                 if (clsName.endsWith("1"))
@@ -350,18 +529,38 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+        Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
 
         assertEquals(3, typeMappers.size());
 
-        assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
-        assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
+        assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS1_FULL_NAME).nameMapper()).isSimpleName());
+        assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+
+        assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS2_FULL_NAME).nameMapper()).isSimpleName());
+        assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testOverrideJar() throws Exception {
+    public void testOverrideJarSimpleNameMapper() throws Exception {
+        checkOverrideJar(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOverrideJarFullNameMapper() throws Exception {
+        checkOverrideJar(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+    }
+
+    /**
+     *
+     * @param nameMapper Name mapper.
+     * @param idMapper Mapper.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void checkOverrideJar(BinaryNameMapper nameMapper, BinaryIdMapper idMapper) throws IgniteCheckedException {
         BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(
             "org.apache.ignite.internal.binary.test.GridBinaryTestClass2");
 
@@ -375,7 +574,7 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
             }
         });
 
-        BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+        BinaryMarshaller marsh = binaryMarshaller(nameMapper, idMapper, Arrays.asList(
             new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
             typeCfg));
 
@@ -385,13 +584,14 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         assertEquals(3, typeIds.size());
 
-        assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
+        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
 
-        Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+        Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
 
         assertEquals(3, typeMappers.size());
 
-        assertEquals(100, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
+        assertEquals(nameMapper, typeMappers.get(CLASS2_FULL_NAME).nameMapper());
+        assertEquals(100, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
     }
 
     /**
@@ -423,9 +623,10 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
     /**
      *
      */
-    protected BinaryMarshaller binaryMarshaller(BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
+    protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper mapper,
+        Collection<BinaryTypeConfiguration> cfgs)
         throws IgniteCheckedException {
-        return binaryMarshaller(mapper, null, cfgs);
+        return binaryMarshaller(nameMapper, mapper, null, cfgs);
     }
 
     /**
@@ -433,10 +634,14 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
      */
     protected BinaryMarshaller binaryMarshaller(BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs)
         throws IgniteCheckedException {
-        return binaryMarshaller(null, serializer, cfgs);
+        return binaryMarshaller(null, null, serializer, cfgs);
     }
 
+    /**
+     *
+     */
     protected BinaryMarshaller binaryMarshaller(
+        BinaryNameMapper nameMapper,
         BinaryIdMapper mapper,
         BinarySerializer serializer,
         Collection<BinaryTypeConfiguration> cfgs
@@ -445,6 +650,7 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
 
         BinaryConfiguration bCfg = new BinaryConfiguration();
 
+        bCfg.setNameMapper(nameMapper);
         bCfg.setIdMapper(mapper);
         bCfg.setSerializer(serializer);
 


[08/28] ignite git commit: 2224

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
index 8170008..615a92b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
@@ -176,6 +176,8 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
         txMapping = new GridDhtTxMapping();
 
         for (IgniteTxEntry txEntry : tx.allEntries()) {
+            txEntry.clearEntryReadVersion();
+
             GridCacheContext cacheCtx = txEntry.context();
 
             List<ClusterNode> nodes = cacheCtx.affinity().nodes(txEntry.key(), topVer);

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index a09dec0..a3130cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -122,7 +122,8 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
         String taskName,
         final boolean deserializeBinary,
         final boolean skipVals,
-        boolean canRemap
+        boolean canRemap,
+        final boolean needVer
     ) {
         ctx.checkSecurity(SecurityPermission.CACHE_READ);
 
@@ -146,7 +147,8 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
                         deserializeBinary,
                         skipVals,
                         false,
-                        skipStore);
+                        skipStore,
+                        needVer);
                 }
             }, opCtx);
         }
@@ -162,7 +164,8 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
             skipVals ? null : opCtx != null ? opCtx.expiry() : null,
             skipVals,
             skipStore,
-            canRemap);
+            canRemap,
+            needVer);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index 6130ead..fed3e33 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -477,7 +477,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
     /** {@inheritDoc} */
 
     @SuppressWarnings("unchecked")
-    @Override @Nullable public V get(K key, boolean deserializeBinary) throws IgniteCheckedException {
+    @Override @Nullable public V get(K key, boolean deserializeBinary, boolean needVer) throws IgniteCheckedException {
         String taskName = ctx.kernalContext().job().currentTaskName();
 
         Map<K, V> m = getAllInternal(Collections.singleton(key),
@@ -485,7 +485,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             ctx.readThrough(),
             taskName,
             deserializeBinary,
-            false);
+            false,
+            needVer);
 
         assert m.isEmpty() || m.size() == 1 : m.size();
 
@@ -494,7 +495,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public final Map<K, V> getAll(Collection<? extends K> keys, boolean deserializeBinary)
+    @Override public final Map<K, V> getAll(Collection<? extends K> keys, boolean deserializeBinary, boolean needVer)
         throws IgniteCheckedException {
         A.notNull(keys, "keys");
 
@@ -505,7 +506,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             ctx.readThrough(),
             taskName,
             deserializeBinary,
-            false);
+            false,
+            needVer);
     }
 
 
@@ -519,7 +521,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         final String taskName,
         final boolean deserializeBinary,
         final boolean skipVals,
-        boolean canRemap
+        boolean canRemap,
+        final boolean needVer
     ) {
         A.notNull(keys, "keys");
 
@@ -528,7 +531,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
 
         return asyncOp(new Callable<Map<K, V>>() {
             @Override public Map<K, V> call() throws Exception {
-                return getAllInternal(keys, swapOrOffheap, storeEnabled, taskName, deserializeBinary, skipVals);
+                return getAllInternal(keys, swapOrOffheap, storeEnabled, taskName, deserializeBinary, skipVals, needVer);
             }
         });
     }
@@ -542,6 +545,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
      * @param taskName Task name.
      * @param deserializeBinary Deserialize binary .
      * @param skipVals Skip value flag.
+     * @param needVer Need version.
      * @return Key-value map.
      * @throws IgniteCheckedException If failed.
      */
@@ -551,7 +555,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         boolean storeEnabled,
         String taskName,
         boolean deserializeBinary,
-        boolean skipVals
+        boolean skipVals,
+        boolean needVer
     ) throws IgniteCheckedException {
         ctx.checkSecurity(SecurityPermission.CACHE_READ);
 
@@ -584,24 +589,65 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                     entry = swapOrOffheap ? entryEx(cacheKey) : peekEx(cacheKey);
 
                     if (entry != null) {
-                        CacheObject v = entry.innerGet(null,
-                            /*swap*/swapOrOffheap,
-                            /*read-through*/false,
-                            /*fail-fast*/false,
-                            /*unmarshal*/true,
-                            /**update-metrics*/true,
-                            /**event*/!skipVals,
-                            /**temporary*/false,
-                            subjId,
-                            null,
-                            taskName,
-                            expiry,
-                            !deserializeBinary);
+                        CacheObject v ;
+                        GridCacheVersion ver;
 
-                        if (v != null)
-                            ctx.addResult(vals, cacheKey, v, skipVals, false, deserializeBinary, true);
-                        else
-                            success = false;
+                        if (needVer) {
+                            T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+                                null,
+                                /*swap*/swapOrOffheap,
+                                /*unmarshal*/true,
+                                /**update-metrics*/false,
+                                /*event*/!skipVals,
+                                subjId,
+                                null,
+                                taskName,
+                                expiry,
+                                !deserializeBinary);
+
+                            if (res != null) {
+                                v = res.get1();
+                                ver = res.get2();
+
+                                ctx.addResult(
+                                    vals,
+                                    cacheKey,
+                                    v,
+                                    skipVals,
+                                    false,
+                                    deserializeBinary,
+                                    true,
+                                    ver);
+                            }else
+                                success = false;
+                        }
+                        else {
+                            v = entry.innerGet(null,
+                                /*swap*/swapOrOffheap,
+                                /*read-through*/false,
+                                /*fail-fast*/false,
+                                /*unmarshal*/true,
+                                /**update-metrics*/true,
+                                /**event*/!skipVals,
+                                /**temporary*/false,
+                                subjId,
+                                null,
+                                taskName,
+                                expiry,
+                                !deserializeBinary);
+
+                            if (v != null) {
+                                ctx.addResult(vals,
+                                    cacheKey,
+                                    v,
+                                    skipVals,
+                                    false,
+                                    deserializeBinary,
+                                    true);
+                            }
+                            else
+                                success = false;
+                        }
                     }
                     else {
                         if (!storeEnabled && configuration().isStatisticsEnabled() && !skipVals)
@@ -638,7 +684,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             /*force primary*/false,
             expiry,
             skipVals,
-            /*can remap*/true).get();
+            /*can remap*/true,
+            needVer).get();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index f731975..8b871a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -25,6 +25,7 @@ import java.util.UUID;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 import javax.cache.expiry.ExpiryPolicy;
 import javax.cache.processor.EntryProcessor;
+import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.GridDirectTransient;
 import org.apache.ignite.internal.IgniteCodeGeneratingFail;
@@ -73,6 +74,12 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
     /** Dummy version for any existing entry read in SERIALIZABLE transaction. */
     public static final GridCacheVersion SER_READ_NOT_EMPTY_VER = new GridCacheVersion(0, 0, 0, 1);
 
+    /** */
+    public static final GridCacheVersion GET_ENTRY_INVALID_VER_UPDATED = new GridCacheVersion(0, 0, 0, 2);
+
+    /** */
+    public static final GridCacheVersion GET_ENTRY_INVALID_VER_AFTER_GET = new GridCacheVersion(0, 0, 0, 3);
+
     /** Prepared flag updater. */
     private static final AtomicIntegerFieldUpdater<IgniteTxEntry> PREPARED_UPD =
         AtomicIntegerFieldUpdater.newUpdater(IgniteTxEntry.class, "prepared");
@@ -918,13 +925,30 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
     }
 
     /**
-     * @param serReadVer Read version for serializable transaction.
+     * Gets stored entry version. Version is stored for all entries in serializable transaction or
+     * when value is read using {@link IgniteCache#getEntry(Object)} method.
+     *
+     * @return Entry version.
+     */
+    @Nullable public GridCacheVersion entryReadVersion() {
+        return serReadVer;
+    }
+
+    /**
+     * @param ver Entry version.
      */
-    public void serializableReadVersion(GridCacheVersion serReadVer) {
+    public void entryReadVersion(GridCacheVersion  ver) {
         assert this.serReadVer == null;
-        assert serReadVer != null;
+        assert ver != null;
 
-        this.serReadVer = serReadVer;
+        this.serReadVer = ver;
+    }
+
+    /**
+     * Clears recorded read version, should be done before starting commit of not serializable/optimistic transaction.
+     */
+    public void clearEntryReadVersion() {
+        serReadVer = null;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index aad9841..a999358 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -58,6 +58,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheUpdateTxResult;
 import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtDetachedCacheEntry;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry;
 import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
 import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -1342,7 +1343,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
 
     /**
      * Checks if there is a cached or swapped value for
-     * {@link #getAllAsync(GridCacheContext, Collection, boolean, boolean, boolean, boolean)} method.
+     * {@link #getAllAsync(GridCacheContext, Collection, boolean, boolean, boolean, boolean, boolean)} method.
      *
      * @param cacheCtx Cache context.
      * @param keys Key to enlist.
@@ -1368,7 +1369,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
         boolean deserializeBinary,
         boolean skipVals,
         boolean keepCacheObjects,
-        boolean skipStore
+        boolean skipStore,
+        final boolean needVer
     ) throws IgniteCheckedException {
         assert !F.isEmpty(keys);
         assert keysCnt == keys.size();
@@ -1381,7 +1383,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
 
         AffinityTopologyVersion topVer = topologyVersion();
 
-        boolean needReadVer = serializable() && optimistic();
+        boolean needReadVer = (serializable() && optimistic()) || needVer;
 
         // In this loop we cover only read-committed or optimistic transactions.
         // Transactions that are pessimistic and not read-committed are covered
@@ -1403,31 +1405,89 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                     if (!F.isEmpty(txEntry.entryProcessors()))
                         val = txEntry.applyEntryProcessors(val);
 
-                    if (val != null)
-                        cacheCtx.addResult(map, key, val, skipVals, keepCacheObjects, deserializeBinary, false);
+                    if (val != null) {
+                        GridCacheVersion ver = null;
+
+                        if (needVer) {
+                            if (txEntry.op() != READ)
+                                ver = IgniteTxEntry.GET_ENTRY_INVALID_VER_UPDATED;
+                            else {
+                                ver = txEntry.entryReadVersion();
+
+                                if (ver == null && pessimistic()) {
+                                    while (true) {
+                                        try {
+                                            GridCacheEntryEx cached = txEntry.cached();
+
+                                            ver = cached.isNear() ?
+                                                ((GridNearCacheEntry)cached).dhtVersion() : cached.version();
+
+                                            break;
+                                        }
+                                        catch (GridCacheEntryRemovedException rmvdErr) {
+                                            txEntry.cached(entryEx(cacheCtx, txEntry.txKey(), topVer));
+                                        }
+                                    }
+                                }
+
+                                if (ver == null) {
+                                    assert optimistic() && repeatableRead() : this;
+
+                                    ver = IgniteTxEntry.GET_ENTRY_INVALID_VER_AFTER_GET;
+                                }
+                            }
+
+                            assert ver != null;
+                        }
+
+                        cacheCtx.addResult(map, key, val, skipVals, keepCacheObjects, deserializeBinary, false, ver);
+                    }
                 }
                 else {
                     assert txEntry.op() == TRANSFORM;
 
                     while (true) {
                         try {
+                            GridCacheVersion readVer = null;
+
                             Object transformClo =
-                                (txEntry.op() == TRANSFORM  && cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ)) ?
+                                (txEntry.op() == TRANSFORM &&
+                                    cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ)) ?
                                     F.first(txEntry.entryProcessors()) : null;
 
-                            val = txEntry.cached().innerGet(this,
-                                /*swap*/true,
-                                /*read-through*/false,
-                                /*fail fast*/true,
-                                /*unmarshal*/true,
-                                /*metrics*/true,
-                                /*event*/!skipVals,
-                                /*temporary*/false,
-                                CU.subjectId(this, cctx),
-                                transformClo,
-                                resolveTaskName(),
-                                null,
-                                txEntry.keepBinary());
+                            if (needVer) {
+                                T2<CacheObject, GridCacheVersion> res = txEntry.cached().innerGetVersioned(
+                                    this,
+                                    /*swap*/true,
+                                    /*unmarshal*/true,
+                                    /*update-metrics*/true,
+                                    /*event*/!skipVals,
+                                    CU.subjectId(this, cctx),
+                                    transformClo,
+                                    resolveTaskName(),
+                                    null,
+                                    txEntry.keepBinary());
+
+                                if (res != null) {
+                                    val = res.get1();
+                                    readVer = res.get2();
+                                }
+                            }
+                            else {
+                                val = txEntry.cached().innerGet(this,
+                                    /*swap*/true,
+                                    /*read-through*/false,
+                                    /*fail fast*/true,
+                                    /*unmarshal*/true,
+                                    /*metrics*/true,
+                                    /*event*/!skipVals,
+                                    /*temporary*/false,
+                                    CU.subjectId(this, cctx),
+                                    transformClo,
+                                    resolveTaskName(),
+                                    null,
+                                    txEntry.keepBinary());
+                            }
 
                             if (val != null) {
                                 if (!readCommitted() && !skipVals)
@@ -1442,7 +1502,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                                     skipVals,
                                     keepCacheObjects,
                                     deserializeBinary,
-                                    false);
+                                    false,
+                                    readVer);
                             }
                             else
                                 missed.put(key, txEntry.cached().version());
@@ -1517,7 +1578,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                                     skipVals,
                                     keepCacheObjects,
                                     deserializeBinary,
-                                    false);
+                                    false,
+                                    needVer ? readVer : null);
                             }
                             else
                                 missed.put(key, ver);
@@ -1549,7 +1611,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                                 if (needReadVer) {
                                     assert readVer != null;
 
-                                    txEntry.serializableReadVersion(readVer);
+                                    txEntry.entryReadVersion(readVer);
                                 }
                             }
                         }
@@ -1600,7 +1662,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
 
     /**
      * Loads all missed keys for
-     * {@link #getAllAsync(GridCacheContext, Collection, boolean, boolean, boolean, boolean)} method.
+     * {@link #getAllAsync(GridCacheContext, Collection, boolean, boolean, boolean, boolean, boolean)} method.
      *
      * @param cacheCtx Cache context.
      * @param map Return map.
@@ -1618,12 +1680,14 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
         final boolean deserializeBinary,
         final boolean skipVals,
         final boolean keepCacheObjects,
-        final boolean skipStore
+        final boolean skipStore,
+        final boolean needVer
+
     ) {
         if (log.isDebugEnabled())
             log.debug("Loading missed values for missed map: " + missedMap);
 
-        final boolean needReadVer = serializable() && optimistic();
+        final boolean needReadVer = (serializable() && optimistic()) || needVer;
 
         return new GridEmbeddedFuture<>(
             new C2<Void, Exception, Map<K, V>>() {
@@ -1685,7 +1749,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                                     skipVals,
                                     keepCacheObjects,
                                     deserializeBinary,
-                                    false);
+                                    false,
+                                    needVer ? loadVer : null);
                             }
                         }
                         else {
@@ -1696,7 +1761,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                             if (needReadVer) {
                                 assert loadVer != null;
 
-                                txEntry.serializableReadVersion(loadVer);
+                                txEntry.entryReadVersion(loadVer);
                             }
 
                             if (visibleVal != null) {
@@ -1706,7 +1771,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                                     skipVals,
                                     keepCacheObjects,
                                     deserializeBinary,
-                                    false);
+                                    false,
+                                    needVer ? loadVer : null);
                             }
                         }
                     }
@@ -1715,13 +1781,15 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override public <K, V> IgniteInternalFuture<Map<K, V>> getAllAsync(
         final GridCacheContext cacheCtx,
         Collection<KeyCacheObject> keys,
         final boolean deserializeBinary,
         final boolean skipVals,
         final boolean keepCacheObjects,
-        final boolean skipStore) {
+        final boolean skipStore,
+        final boolean needVer) {
         if (F.isEmpty(keys))
             return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
 
@@ -1751,7 +1819,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                 deserializeBinary,
                 skipVals,
                 keepCacheObjects,
-                skipStore);
+                skipStore,
+                needVer);
 
             if (single && missed.isEmpty())
                 return new GridFinishedFuture<>(retMap);
@@ -1797,25 +1866,48 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                             while (true) {
                                 GridCacheEntryEx cached = txEntry.cached();
 
+                                CacheObject val = null;
+                                GridCacheVersion readVer = null;
+
                                 try {
                                     Object transformClo =
                                         (!F.isEmpty(txEntry.entryProcessors()) &&
                                             cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ)) ?
                                             F.first(txEntry.entryProcessors()) : null;
 
-                                    CacheObject val = cached.innerGet(IgniteTxLocalAdapter.this,
-                                        cacheCtx.isSwapOrOffheapEnabled(),
-                                        /*read-through*/false,
-                                        /*fail-fast*/true,
-                                        /*unmarshal*/true,
-                                        /*metrics*/true,
-                                        /*events*/!skipVals,
-                                        /*temporary*/true,
-                                        CU.subjectId(IgniteTxLocalAdapter.this, cctx),
-                                        transformClo,
-                                        resolveTaskName(),
-                                        null,
-                                        txEntry.keepBinary());
+                                    if (needVer) {
+                                        T2<CacheObject, GridCacheVersion> res = cached.innerGetVersioned(
+                                            IgniteTxLocalAdapter.this,
+                                            /*swap*/cacheCtx.isSwapOrOffheapEnabled(),
+                                            /*unmarshal*/true,
+                                            /**update-metrics*/true,
+                                            /*event*/!skipVals,
+                                            CU.subjectId(IgniteTxLocalAdapter.this, cctx),
+                                            transformClo,
+                                            resolveTaskName(),
+                                            null,
+                                            txEntry.keepBinary());
+
+                                        if (res != null) {
+                                            val = res.get1();
+                                            readVer = res.get2();
+                                        }
+                                    }
+                                    else{
+                                        val = cached.innerGet(IgniteTxLocalAdapter.this,
+                                            cacheCtx.isSwapOrOffheapEnabled(),
+                                            /*read-through*/false,
+                                            /*fail-fast*/true,
+                                            /*unmarshal*/true,
+                                            /*metrics*/true,
+                                            /*events*/!skipVals,
+                                            /*temporary*/true,
+                                            CU.subjectId(IgniteTxLocalAdapter.this, cctx),
+                                            transformClo,
+                                            resolveTaskName(),
+                                            null,
+                                            txEntry.keepBinary());
+                                    }
 
                                     // If value is in cache and passed the filter.
                                     if (val != null) {
@@ -1832,7 +1924,11 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                                             skipVals,
                                             keepCacheObjects,
                                             deserializeBinary,
-                                            false);
+                                            false,
+                                            readVer);
+
+                                        if (readVer != null)
+                                            txEntry.entryReadVersion(readVer);
                                     }
 
                                     // Even though we bring the value back from lock acquisition,
@@ -1858,7 +1954,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                                 deserializeBinary,
                                 skipVals,
                                 keepCacheObjects,
-                                skipStore);
+                                skipStore,
+                                needVer);
                         }
 
                         return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
@@ -1924,7 +2021,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                         deserializeBinary,
                         skipVals,
                         keepCacheObjects,
-                        skipStore);
+                        skipStore,
+                        needVer);
                 }
 
                 return new GridFinishedFuture<>(retMap);
@@ -2315,7 +2413,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                     if (needReadVer) {
                         assert loadVer != null;
 
-                        e.serializableReadVersion(singleRmv && val != null ? SER_READ_NOT_EMPTY_VER : loadVer);
+                        e.entryReadVersion(singleRmv && val != null ? SER_READ_NOT_EMPTY_VER : loadVer);
                     }
 
                     if (singleRmv) {
@@ -2508,7 +2606,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                             if (needReadVer) {
                                 assert readVer != null;
 
-                                txEntry.serializableReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
+                                txEntry.entryReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
                             }
                         }
 
@@ -2561,7 +2659,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                             if (needReadVer) {
                                 assert readVer != null;
 
-                                txEntry.serializableReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
+                                txEntry.entryReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
                             }
 
                             if (retval && !transform)

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
index a5d3373..78f517c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
@@ -76,7 +76,8 @@ public interface IgniteTxLocalEx extends IgniteInternalTx {
         boolean deserializeBinary,
         boolean skipVals,
         boolean keepCacheObjects,
-        boolean skipStore);
+        boolean skipStore,
+        boolean needVer);
 
     /**
      * @param cacheCtx Cache context.

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 3e43726..28a7cc0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -1419,7 +1419,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
                     assert !entry1.detached() : "Expected non-detached entry for near transaction " +
                         "[locNodeId=" + cctx.localNodeId() + ", entry=" + entry1 + ']';
 
-                    GridCacheVersion serReadVer = txEntry1.serializableReadVersion();
+                    GridCacheVersion serReadVer = txEntry1.entryReadVersion();
 
                     assert serReadVer == null || (tx.optimistic() && tx.serializable()) : txEntry1;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
new file mode 100644
index 0000000..c0ba42c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
@@ -0,0 +1,803 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.LOCAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public abstract class CacheGetEntryAbstractTest extends GridCacheAbstractSelfTest {
+    /** */
+    private static final String UPDATED_ENTRY_ERR = "Impossible to get version for entry updated in transaction";
+
+    /** */
+    private static final String ENTRY_AFTER_GET_ERR = "Impossible to get entry version after get()";
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 3;
+    }
+
+    /**
+     * @return Transaction concurrency.
+     */
+    abstract protected TransactionConcurrency concurrency();
+
+    /**
+     *
+     * @return Transaction isolation.
+     */
+    abstract protected TransactionIsolation isolation();
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 60_000;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setMarshaller(null);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNear() throws Exception {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setWriteSynchronizationMode(FULL_SYNC);
+        cfg.setCacheMode(PARTITIONED);
+        cfg.setAtomicityMode(ATOMIC);
+        cfg.setName("near");
+        cfg.setNearConfiguration(new NearCacheConfiguration());
+
+        test(cfg);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNearTransactional() throws Exception {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setWriteSynchronizationMode(FULL_SYNC);
+        cfg.setCacheMode(PARTITIONED);
+        cfg.setAtomicityMode(TRANSACTIONAL);
+        cfg.setName("nearT");
+        cfg.setNearConfiguration(new NearCacheConfiguration());
+
+        test(cfg);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPartitioned() throws Exception {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setWriteSynchronizationMode(FULL_SYNC);
+        cfg.setCacheMode(PARTITIONED);
+        cfg.setAtomicityMode(ATOMIC);
+        cfg.setName("partitioned");
+
+        test(cfg);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPartitionedTransactional() throws Exception {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setWriteSynchronizationMode(FULL_SYNC);
+        cfg.setCacheMode(PARTITIONED);
+        cfg.setAtomicityMode(TRANSACTIONAL);
+        cfg.setName("partitionedT");
+
+        test(cfg);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLocal() throws Exception {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setWriteSynchronizationMode(FULL_SYNC);
+        cfg.setCacheMode(LOCAL);
+        cfg.setAtomicityMode(ATOMIC);
+        cfg.setName("local");
+
+        test(cfg);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLocalTransactional() throws Exception {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setWriteSynchronizationMode(FULL_SYNC);
+        cfg.setCacheMode(LOCAL);
+        cfg.setAtomicityMode(TRANSACTIONAL);
+        cfg.setName("localT");
+
+        test(cfg);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testReplicated() throws Exception {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setWriteSynchronizationMode(FULL_SYNC);
+        cfg.setCacheMode(REPLICATED);
+        cfg.setAtomicityMode(ATOMIC);
+        cfg.setName("replicated");
+
+        test(cfg);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testReplicatedTransactional() throws Exception {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setWriteSynchronizationMode(FULL_SYNC);
+        cfg.setCacheMode(REPLICATED);
+        cfg.setAtomicityMode(TRANSACTIONAL);
+        cfg.setName("replicatedT");
+
+        test(cfg);
+    }
+
+    /**
+     * @param cfg Cache configuration.
+     * @throws Exception If failed.
+     */
+    private void test(CacheConfiguration cfg) throws Exception {
+        test(cfg, true);
+
+        test(cfg, false);
+    }
+
+    /**
+     * @param cfg Cache configuration.
+     * @param oneEntry If {@code true} then single entry is tested.
+     * @throws Exception If failed.
+     */
+    private void test(CacheConfiguration cfg, final boolean oneEntry) throws Exception {
+        final IgniteCache<Integer, TestValue> cache = grid(0).createCache(cfg);
+
+        try {
+            init(cache);
+
+            test(cache, null, null, null, oneEntry);
+
+            if (cfg.getAtomicityMode() == TRANSACTIONAL) {
+                TransactionConcurrency txConcurrency = concurrency();
+                TransactionIsolation txIsolation = isolation();
+
+                try (Transaction tx = grid(0).transactions().txStart(txConcurrency, txIsolation)) {
+                    initTx(cache);
+
+                    test(cache, txConcurrency, txIsolation, tx, oneEntry);
+
+                    tx.commit();
+                }
+
+                testConcurrentTx(cache, OPTIMISTIC, REPEATABLE_READ, oneEntry);
+                testConcurrentTx(cache, OPTIMISTIC, READ_COMMITTED, oneEntry);
+
+                testConcurrentTx(cache, PESSIMISTIC, REPEATABLE_READ, oneEntry);
+                testConcurrentTx(cache, PESSIMISTIC, READ_COMMITTED, oneEntry);
+            }
+        }
+        finally {
+            cache.destroy();
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param txConcurrency Transaction concurrency.
+     * @param txIsolation Transaction isolation.
+     * @param oneEntry If {@code true} then single entry is tested.
+     * @throws Exception If failed.
+     */
+    private void testConcurrentTx(final IgniteCache<Integer, TestValue> cache,
+        final TransactionConcurrency txConcurrency,
+        final TransactionIsolation txIsolation,
+        final boolean oneEntry) throws Exception {
+        GridTestUtils.runMultiThreaded(new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                IgniteTransactions txs = grid(0).transactions();
+
+                long stopTime = System.currentTimeMillis() + 3000;
+
+                while (System.currentTimeMillis() < stopTime) {
+                    Set<Integer> keys = new LinkedHashSet<>();
+
+                    for (int i = 0; i < 100; i++)
+                        keys.add(i);
+
+                    try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
+                        if (oneEntry) {
+                            for (int i = 0; i < 100; i++)
+                                cache.getEntry(i);
+                        }
+                        else
+                            cache.getEntries(keys);
+
+                        for (int i = 0; i < 100; i++)
+                            cache.put(i, new TestValue(i));
+
+                        tx.commit();
+                    }
+                }
+
+                return null;
+            }
+        }, 10, "tx-thread");
+    }
+
+    /**
+     * @param base Start value.
+     * @return Keys.
+     */
+    private Set<Integer> getKeys(int base) {
+        int start = 0;
+        int finish = 100;
+
+        Set<Integer> keys = new HashSet<>(finish - start);
+
+        for (int i = base + start; i < base + finish; ++i)
+            keys.add(i);
+
+        return keys;
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> createdBeforeTxKeys() {
+        return getKeys(0);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> createdBeforeTxWithBinaryKeys() {
+        return getKeys(1_000);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> createdBeforeTxKeys2() {
+        return getKeys(2_000);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> createdBeforeTxWithBinaryKeys2() {
+        return getKeys(3_000);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> createdBeforeTxKeys3() {
+        return getKeys(4_000);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> createdBeforeTxWithBinaryKeys3() {
+        return getKeys(5_000);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> removedBeforeTxKeys() {
+        return getKeys(6_000);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> removedBeforeTxWithBinaryKeys() {
+        return getKeys(7_000);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> createdAtTxKeys() {
+        return getKeys(8_000);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> createdAtTxWithBinaryKeys() {
+        return getKeys(9_000);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> removedAtTxKeys() {
+        return getKeys(10_000);
+    }
+
+    /**
+     * @return Keys.
+     */
+    private Set<Integer> removedAtTxWithBinaryKeys() {
+        return getKeys(11_000);
+    }
+
+    /**
+     * @param cache Cacge.
+     */
+    private void init(IgniteCache<Integer, TestValue> cache) {
+        Set<Integer> keys = new HashSet<>();
+
+        keys.addAll(createdBeforeTxKeys());
+        keys.addAll(createdBeforeTxWithBinaryKeys());
+        keys.addAll(createdBeforeTxKeys2());
+        keys.addAll(createdBeforeTxWithBinaryKeys2());
+        keys.addAll(createdBeforeTxKeys3());
+        keys.addAll(createdBeforeTxWithBinaryKeys3());
+        keys.addAll(removedBeforeTxKeys());
+        keys.addAll(removedBeforeTxWithBinaryKeys());
+        keys.addAll(removedAtTxKeys());
+        keys.addAll(removedAtTxWithBinaryKeys());
+
+        for (int i : keys)
+            cache.put(i, new TestValue(i));
+
+        for (int i : removedBeforeTxKeys())
+            cache.remove(i);
+
+        for (int i : removedBeforeTxWithBinaryKeys())
+            cache.remove(i);
+    }
+
+    /**
+     * @param cache Cache.
+     */
+    private void initTx(IgniteCache<Integer, TestValue> cache) {
+        for (int i : createdAtTxKeys())
+            cache.put(i, new TestValue(i));
+
+        for (int i : createdAtTxWithBinaryKeys())
+            cache.put(i, new TestValue(i));
+
+        for (int i : removedAtTxKeys())
+            cache.remove(i);
+
+        for (int i : removedAtTxWithBinaryKeys())
+            cache.remove(i);
+    }
+
+    /**
+     * @param e Entry.
+     * @param cache Cache.
+     * @throws Exception If failed.
+     */
+    private void compareVersionWithPrimaryNode(CacheEntry<Integer, ?> e, IgniteCache<Integer, TestValue> cache)
+        throws Exception {
+        CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class);
+
+        if (cfg.getCacheMode() != LOCAL) {
+            Ignite prim = primaryNode(e.getKey(), cache.getName());
+
+            GridCacheAdapter<Object, Object> cacheAdapter = ((IgniteKernal)prim).internalCache(cache.getName());
+
+            if (cfg.getNearConfiguration() != null)
+                cacheAdapter = ((GridNearCacheAdapter)cacheAdapter).dht();
+
+            IgniteCacheObjectProcessor cacheObjects = cacheAdapter.context().cacheObjects();
+
+            CacheObjectContext cacheObjCtx = cacheAdapter.context().cacheObjectContext();
+
+            GridCacheMapEntry mapEntry = cacheAdapter.map().getEntry(cacheObjects.toCacheKeyObject(
+                cacheObjCtx, e.getKey(), true));
+
+            assertNotNull("No entry for key: " + e.getKey(), mapEntry);
+            assertEquals(mapEntry.version(), e.version());
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param i Key.
+     * @param oneEntry If {@code true} then single entry is tested.
+     * @param getVerErr Not null error if entry version access should fail.
+     * @param expKeys Expected keys with values.
+     * @throws Exception If failed.
+     */
+    private void checkData(IgniteCache<Integer, TestValue> cache,
+        int i,
+        boolean oneEntry,
+        @Nullable String getVerErr,
+        Set<Integer> expKeys) throws Exception {
+        if (oneEntry) {
+            final CacheEntry<Integer, TestValue> e = cache.getEntry(i);
+
+            if (getVerErr == null)
+                compareVersionWithPrimaryNode(e, cache);
+            else {
+                Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        e.version();
+
+                        return null;
+                    }
+                }, IgniteException.class, null);
+
+                assertTrue("Unexpected error message: " + err.getMessage(), err.getMessage().startsWith(getVerErr));
+            }
+
+            assertEquals(e.getValue().val, i);
+        }
+        else {
+            Set<Integer> set = new HashSet<>();
+
+            int expCnt = 0;
+
+            for (int j = 0; j < 10; j++) {
+                Integer key = i + j;
+
+                set.add(key);
+
+                if (expKeys.contains(key))
+                    expCnt++;
+            }
+
+            Collection<CacheEntry<Integer, TestValue>> entries = cache.getEntries(set);
+
+            assertEquals(expCnt, entries.size());
+
+            for (final CacheEntry<Integer, TestValue> e : entries) {
+                if (getVerErr == null)
+                    compareVersionWithPrimaryNode(e, cache);
+                else {
+                    Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
+                        @Override public Void call() throws Exception {
+                            e.version();
+
+                            return null;
+                        }
+                    }, IgniteException.class, null);
+
+                    assertTrue("Unexpected error message: " + err.getMessage(), err.getMessage().startsWith(getVerErr));
+                }
+
+                assertEquals((Integer)e.getValue().val, e.getKey());
+
+                assertTrue(set.contains(e.getValue().val));
+            }
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param i Key.
+     * @param oneEntry If {@code true} then single entry is tested.
+     * @param getVerErr Not null error if entry version access should fail.
+     * @param expKeys Expected keys with values.
+     * @throws Exception If failed.
+     */
+    private void checkBinaryData(IgniteCache<Integer, TestValue> cache,
+        int i,
+        boolean oneEntry,
+        @Nullable String getVerErr,
+        Set<Integer> expKeys) throws Exception {
+        IgniteCache<Integer, BinaryObject> cacheB = cache.withKeepBinary();
+
+        if (oneEntry) {
+            final CacheEntry<Integer, BinaryObject> e = cacheB.getEntry(i);
+
+            if (getVerErr == null)
+                compareVersionWithPrimaryNode(e, cache);
+            else {
+                Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        e.version();
+
+                        return null;
+                    }
+                }, IgniteException.class, null);
+
+                assertTrue("Unexpected error message: " + err.getMessage(), err.getMessage().startsWith(getVerErr));
+            }
+
+            assertEquals(((TestValue)e.getValue().deserialize()).val, i);
+        }
+        else {
+            Set<Integer> set = new HashSet<>();
+
+            int expCnt = 0;
+
+            for (int j = 0; j < 10; j++) {
+                Integer key = i + j;
+
+                set.add(key);
+
+                if (expKeys.contains(key))
+                    expCnt++;
+            }
+
+            Collection<CacheEntry<Integer, BinaryObject>> entries = cacheB.getEntries(set);
+
+            assertEquals(expCnt, entries.size());
+
+            for (final CacheEntry<Integer, BinaryObject> e : entries) {
+                if (getVerErr == null)
+                    compareVersionWithPrimaryNode(e, cache);
+                else {
+                    Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
+                        @Override public Void call() throws Exception {
+                            e.version();
+
+                            return null;
+                        }
+                    }, IgniteException.class, null);
+
+                    assertTrue("Unexpected error message: " + err.getMessage(), err.getMessage().startsWith(getVerErr));
+                }
+
+                TestValue tv = e.getValue().deserialize();
+
+                assertEquals((Integer)tv.val, e.getKey());
+
+                assertTrue(set.contains((tv).val));
+            }
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param i Key.
+     * @param oneEntry If {@code true} then single entry is tested.
+     */
+    private void checkRemoved(IgniteCache<Integer, TestValue> cache, int i, boolean oneEntry) {
+        if (oneEntry) {
+            CacheEntry<Integer, TestValue> e = cache.getEntry(i);
+
+            assertNull(e);
+        }
+        else {
+            Set<Integer> set = new HashSet<>();
+
+            for (int j = 0; j < 10; j++)
+                set.add(i + j);
+
+            Collection<CacheEntry<Integer, TestValue>> es = cache.getEntries(set);
+
+            assertTrue(es.isEmpty());
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param i Key.
+     * @param oneEntry If {@code true} then single entry is tested.
+     */
+    private void checkBinaryRemoved(IgniteCache<Integer, TestValue> cache, int i, boolean oneEntry) {
+        IgniteCache<Integer, BinaryObject> cacheB = cache.withKeepBinary();
+
+        if (oneEntry) {
+            CacheEntry<Integer, BinaryObject> e = cacheB.getEntry(i);
+
+            assertNull(e);
+        }
+        else {
+            Set<Integer> set = new HashSet<>();
+
+            for (int j = 0; j < 10; j++)
+                set.add(i + j);
+
+            Collection<CacheEntry<Integer, BinaryObject>> es = cacheB.getEntries(set);
+
+            assertTrue(es.isEmpty());
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param txConcurrency Transaction concurrency.
+     * @param txIsolation Transaction isolation.
+     * @param tx Transaction.
+     * @param oneEntry If {@code true} then single entry is tested.
+     * @throws Exception If failed.
+     */
+    private void test(IgniteCache<Integer, TestValue> cache,
+        TransactionConcurrency txConcurrency,
+        TransactionIsolation txIsolation,
+        Transaction tx,
+        boolean oneEntry) throws Exception {
+        if (tx == null) {
+            Set<Integer> keys = createdBeforeTxKeys();
+
+            for (int i : keys)
+                checkData(cache, i, oneEntry, null, keys);
+
+            keys = createdBeforeTxWithBinaryKeys();
+
+            for (int i : keys)
+                checkBinaryData(cache, i, oneEntry, null, keys);
+
+            for (int i : removedBeforeTxKeys())
+                checkRemoved(cache, i, oneEntry);
+
+            for (int i : removedBeforeTxWithBinaryKeys())
+                checkBinaryRemoved(cache, i, oneEntry);
+        }
+        else {
+            Set<Integer> keys = createdBeforeTxKeys2();
+
+            for (int i : keys) {
+                checkData(cache, i, oneEntry, null, keys);
+                checkData(cache, i, oneEntry, null, keys);
+            }
+
+            keys = createdBeforeTxWithBinaryKeys2();
+
+            for (int i : keys) {
+                checkBinaryData(cache, i, oneEntry, null, keys);
+                checkBinaryData(cache, i, oneEntry, null, keys);
+            }
+
+            String verGetErr = null;
+
+            if (txConcurrency == OPTIMISTIC && txIsolation == REPEATABLE_READ)
+                verGetErr = ENTRY_AFTER_GET_ERR;
+
+            keys = createdBeforeTxKeys3();
+
+            for (int i : keys) {
+                if (oneEntry)
+                    cache.get(i);
+                else {
+                    Set<Integer> set = new HashSet<>();
+
+                    for (int j = 0; j < 10; j++)
+                        set.add(i + j);
+
+                    cache.getAll(set);
+                }
+
+                checkData(cache, i, oneEntry, verGetErr, keys);
+            }
+
+            keys = createdBeforeTxWithBinaryKeys3();
+
+            for (int i : keys) {
+                if (oneEntry)
+                    cache.get(i);
+                else {
+                    Set<Integer> set = new HashSet<>();
+
+                    for (int j = 0; j < 10; j++)
+                        set.add(i + j);
+
+                    cache.getAll(set);
+                }
+
+                checkBinaryData(cache, i, oneEntry, verGetErr, keys);
+            }
+
+            keys = createdAtTxKeys();
+
+            for (int i : keys)
+                checkData(cache, i, oneEntry, UPDATED_ENTRY_ERR, keys);
+
+            keys = createdAtTxWithBinaryKeys();
+
+            for (int i : keys)
+                checkBinaryData(cache, i, oneEntry, UPDATED_ENTRY_ERR, keys);
+
+            for (int i : removedBeforeTxKeys())
+                checkRemoved(cache, i, oneEntry);
+
+            for (int i : removedBeforeTxWithBinaryKeys())
+                checkBinaryRemoved(cache, i, oneEntry);
+
+            for (int i : removedAtTxKeys())
+                checkRemoved(cache, i, oneEntry);
+
+            for (int i : removedAtTxWithBinaryKeys())
+                checkBinaryRemoved(cache, i, oneEntry);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class TestValue implements Serializable {
+        /** */
+        private int val;
+
+        /**
+         * @param val Value.
+         */
+        public TestValue(int val) {
+            this.val = val;
+        }
+
+        /**
+         * @return Value.
+         */
+        public int value() {
+            return val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(TestValue.class, this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java
new file mode 100644
index 0000000..acc21df
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.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.internal.processors.cache;
+
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryOptimisticReadCommittedSeltTest extends CacheGetEntryAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.OPTIMISTIC;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.READ_COMMITTED;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java
new file mode 100644
index 0000000..6153869
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.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.internal.processors.cache;
+
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryOptimisticRepeatableReadSeltTest extends CacheGetEntryAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.OPTIMISTIC;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.REPEATABLE_READ;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java
new file mode 100644
index 0000000..6ded4a9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.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.internal.processors.cache;
+
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryOptimisticSerializableSeltTest extends CacheGetEntryAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.OPTIMISTIC;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.SERIALIZABLE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java
new file mode 100644
index 0000000..975d271
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.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.internal.processors.cache;
+
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryPessimisticReadCommittedSeltTest extends CacheGetEntryAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.PESSIMISTIC;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.READ_COMMITTED;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java
new file mode 100644
index 0000000..dac64d9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.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.internal.processors.cache;
+
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryPessimisticRepeatableReadSeltTest extends CacheGetEntryAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.PESSIMISTIC;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.REPEATABLE_READ;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java
new file mode 100644
index 0000000..70f71ce
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.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.internal.processors.cache;
+
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryPessimisticSerializableSeltTest extends CacheGetEntryAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.PESSIMISTIC;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.SERIALIZABLE;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
index c606a2a..b60ada7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
@@ -85,6 +85,20 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
      * @throws Exception If failed.
      */
     public void testReadThroughInTx() throws Exception {
+        testReadThroughInTx(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testReadEntryThroughInTx() throws Exception {
+        testReadThroughInTx(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void testReadThroughInTx(boolean needVer) throws Exception {
         IgniteCache<String, Integer> cache = grid(1).cache(null);
 
         for (int k = 0; k < 1000; k++)
@@ -104,7 +118,14 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
                     for (int k = 0; k < 1000; k++) {
                         String key = "key" + k;
 
-                        assertNotNull("Null value for key: " + key, cache.get(key));
+                        if (needVer) {
+                            assertNotNull("Null value for key: " + key, cache.getEntry(key));
+                            assertNotNull("Null value for key: " + key, cache.getEntry(key));
+                        }
+                        else {
+                            assertNotNull("Null value for key: " + key, cache.get(key));
+                            assertNotNull("Null value for key: " + key, cache.get(key));
+                        }
                     }
 
                     tx.commit();
@@ -117,6 +138,20 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
      * @throws Exception If failed.
      */
     public void testReadThrough() throws Exception {
+        testReadThrough(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testReadEntryThrough() throws Exception {
+        testReadThrough(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void testReadThrough(boolean needVer) throws Exception {
         IgniteCache<String, Integer> cache = grid(1).cache(null);
 
         for (int k = 0; k < 1000; k++)
@@ -132,8 +167,10 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
 
         for (int k = 0; k < 1000; k++) {
             String key = "key" + k;
-
-            assertNotNull("Null value for key: " + key, cache.get(key));
+            if (needVer)
+                assertNotNull("Null value for key: " + key, cache.getEntry(key));
+            else
+                assertNotNull("Null value for key: " + key, cache.get(key));
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
index 9906ad3..4baef66 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -46,6 +47,7 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.store.CacheStore;
@@ -575,6 +577,20 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testTxCommitReadOnlyGetAll() throws Exception {
+        testTxCommitReadOnlyGetAll(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTxCommitReadOnlyGetEntries() throws Exception {
+        testTxCommitReadOnlyGetAll(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTxCommitReadOnlyGetAll(boolean needVer) throws Exception {
         Ignite ignite0 = ignite(0);
 
         final IgniteTransactions txs = ignite0.transactions();
@@ -591,9 +607,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
                     keys.add(i);
 
                 try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
-                    Map<Integer, Integer> map = cache.getAll(keys);
+                    if (needVer) {
+                        Collection<CacheEntry<Integer, Integer>> c = cache.getEntries(keys);
 
-                    assertTrue(map.isEmpty());
+                        assertTrue(c.isEmpty());
+                    }
+                    else {
+                        Map<Integer, Integer> map = cache.getAll(keys);
+
+                        assertTrue(map.isEmpty());
+                    }
 
                     tx.commit();
                 }
@@ -602,9 +625,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
                     checkValue(key, null, cache.getName());
 
                 try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
-                    Map<Integer, Integer> map = cache.getAll(keys);
+                    if (needVer) {
+                        Collection<CacheEntry<Integer, Integer>> c = cache.getEntries(keys);
 
-                    assertTrue(map.isEmpty());
+                        assertTrue(c.isEmpty());
+                    }
+                    else {
+                        Map<Integer, Integer> map = cache.getAll(keys);
+
+                        assertTrue(map.isEmpty());
+                    }
 
                     tx.rollback();
                 }
@@ -653,21 +683,35 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testTxConflictRead1() throws Exception {
-        txConflictRead(true);
+        txConflictRead(true, false);
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTxConflictRead2() throws Exception {
-        txConflictRead(false);
+        txConflictRead(false, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTxConflictReadEntry1() throws Exception {
+        txConflictRead(true, true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTxConflictReadEntry2() throws Exception {
+        txConflictRead(false, true);
     }
 
     /**
      * @param noVal If {@code true} there is no cache value when read in tx.
      * @throws Exception If failed.
      */
-    private void txConflictRead(boolean noVal) throws Exception {
+    private void txConflictRead(boolean noVal, boolean needVer) throws Exception {
         Ignite ignite0 = ignite(0);
 
         final IgniteTransactions txs = ignite0.transactions();
@@ -693,9 +737,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
 
                     try {
                         try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
-                            Integer val = cache.get(key);
+                            if (needVer) {
+                                CacheEntry<Integer, Integer> val = cache.getEntry(key);
 
-                            assertEquals(expVal, val);
+                                assertEquals(expVal, val == null ? null : val.getValue());
+                            }
+                            else {
+                                Integer val = cache.get(key);
+
+                                assertEquals(expVal, val);
+                            }
 
                             updateKey(cache, key, 1);
 
@@ -711,9 +762,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
                     checkValue(key, 1, cache.getName());
 
                     try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
-                        Object val = cache.get(key);
+                        if (needVer) {
+                            CacheEntry<Integer, Integer> val = cache.getEntry(key);
 
-                        assertEquals(1, val);
+                            assertEquals((Integer)1, val.getValue());
+                        }
+                        else {
+                            Object val = cache.get(key);
+
+                            assertEquals(1, val);
+                        }
 
                         tx.commit();
                     }
@@ -731,28 +789,56 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testTxConflictReadWrite1() throws Exception {
-        txConflictReadWrite(true, false);
+        txConflictReadWrite(true, false, false);
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTxConflictReadWrite2() throws Exception {
-        txConflictReadWrite(false, false);
+        txConflictReadWrite(false, false, false);
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTxConflictReadRemove1() throws Exception {
-        txConflictReadWrite(true, true);
+        txConflictReadWrite(true, true, false);
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testTxConflictReadRemove2() throws Exception {
-        txConflictReadWrite(false, true);
+        txConflictReadWrite(false, true, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTxConflictReadEntryWrite1() throws Exception {
+        txConflictReadWrite(true, false, true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTxConflictReadEntryWrite2() throws Exception {
+        txConflictReadWrite(false, false, true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTxConflictReadEntryRemove1() throws Exception {
+        txConflictReadWrite(true, true, true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTxConflictReadEntryRemove2() throws Exception {
+        txConflictReadWrite(false, true, true);
     }
 
     /**
@@ -760,7 +846,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
      * @param rmv If {@code true} tests remove, otherwise put.
      * @throws Exception If failed.
      */
-    private void txConflictReadWrite(boolean noVal, boolean rmv) throws Exception {
+    private void txConflictReadWrite(boolean noVal, boolean rmv, boolean needVer) throws Exception {
         Ignite ignite0 = ignite(0);
 
         final IgniteTransactions txs = ignite0.transactions();
@@ -786,9 +872,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
 
                     try {
                         try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
-                            Integer val = cache.get(key);
+                            if (needVer) {
+                                CacheEntry<Integer, Integer> val = cache.getEntry(key);
 
-                            assertEquals(expVal, val);
+                                assertEquals(expVal, val == null ? null : val.getValue());
+                            }
+                            else {
+                                Integer val = cache.get(key);
+
+                                assertEquals(expVal, val);
+                            }
 
                             updateKey(cache, key, 1);
 
@@ -809,9 +902,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
                     checkValue(key, 1, cache.getName());
 
                     try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
-                        Integer val = cache.get(key);
+                        if (needVer) {
+                            CacheEntry<Integer, Integer> val = cache.getEntry(key);
+
+                            assertEquals(1, (Object)val.getValue());
+                        }
+                        else {
+                            Integer val = cache.get(key);
 
-                        assertEquals(1, (Object) val);
+                            assertEquals(1, (Object)val);
+                        }
 
                         if (rmv)
                             cache.remove(key);
@@ -4239,7 +4339,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
                 ignite.destroyCache(cacheName);
             }
             catch (IgniteException ignore) {
-                // No-op.                
+                // No-op.
             }
 
             GridTestSwapSpaceSpi spi = (GridTestSwapSpaceSpi)ignite.configuration().getSwapSpaceSpi();


[25/28] ignite git commit: Merge branch 'master' into ignite-2508

Posted by vo...@apache.org.
Merge branch 'master' into ignite-2508


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

Branch: refs/heads/ignite-2508
Commit: 04e705ff81842f072f4e8b66490eb899db00dfe6
Parents: 14e837c e7de923
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Feb 3 15:11:11 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 3 15:11:11 2016 +0300

----------------------------------------------------------------------
 .gitignore                                      |    1 +
 .../java/org/apache/ignite/IgniteCache.java     |   45 +-
 .../ignite/binary/BinaryBasicIdMapper.java      |  167 ++
 .../ignite/binary/BinaryBasicNameMapper.java    |  141 ++
 .../apache/ignite/binary/BinaryIdMapper.java    |   19 +-
 .../apache/ignite/binary/BinaryNameMapper.java  |   47 +
 .../ignite/binary/BinaryTypeConfiguration.java  |   23 +-
 .../org/apache/ignite/cache/CacheEntry.java     |    9 +-
 .../apache/ignite/cache/CacheInterceptor.java   |    5 +
 .../configuration/BinaryConfiguration.java      |   28 +
 .../configuration/IgniteConfiguration.java      |    8 +-
 .../ignite/internal/IgniteNodeAttributes.java   |    3 +
 .../org/apache/ignite/internal/IgnitionEx.java  |    3 +-
 .../internal/binary/BinaryClassDescriptor.java  |   29 +-
 .../ignite/internal/binary/BinaryContext.java   |  347 ++--
 .../internal/binary/BinaryEnumObjectImpl.java   |   13 +-
 .../internal/binary/BinaryFieldAccessor.java    |   45 +-
 .../internal/binary/BinaryInternalIdMapper.java |  161 --
 .../internal/binary/BinaryInternalMapper.java   |  131 ++
 .../internal/binary/BinaryMarshaller.java       |    5 +-
 .../binary/BinaryMetadataCollector.java         |   22 +-
 .../binary/BinaryObjectOffheapImpl.java         |   34 +-
 .../internal/binary/BinaryPrimitives.java       |  117 +-
 .../internal/binary/BinaryReaderExImpl.java     |   14 +-
 .../internal/binary/BinaryWriterExImpl.java     |   30 +-
 .../internal/binary/GridBinaryMarshaller.java   |   23 +-
 .../binary/builder/BinaryBuilderSerializer.java |   16 +-
 .../binary/builder/BinaryObjectBuilderImpl.java |    2 +-
 .../streams/BinaryAbstractInputStream.java      |   53 +-
 .../streams/BinaryAbstractOutputStream.java     |   90 +-
 .../binary/streams/BinaryAbstractStream.java    |   34 -
 .../binary/streams/BinaryHeapInputStream.java   |   43 +-
 .../binary/streams/BinaryHeapOutputStream.java  |   86 +-
 .../streams/BinaryMemoryAllocatorChunk.java     |    9 +-
 .../streams/BinaryOffheapInputStream.java       |   42 +-
 .../streams/BinaryOffheapOutputStream.java      |   94 +-
 .../internal/direct/DirectMessageReader.java    |    2 +-
 .../internal/direct/DirectMessageWriter.java    |    2 +-
 .../stream/v1/DirectByteBufferStreamImplV1.java |  106 +-
 .../stream/v2/DirectByteBufferStreamImplV2.java |  351 ++++-
 .../processors/cache/CacheEntryImplEx.java      |   14 +-
 .../processors/cache/GridCacheAdapter.java      |  297 +++-
 .../processors/cache/GridCacheContext.java      |   33 +-
 .../cache/GridCacheEvictionManager.java         |    7 +-
 .../processors/cache/GridCacheMapEntry.java     |    2 +-
 .../cache/GridCacheOffheapSwapEntry.java        |   24 +-
 .../processors/cache/GridCacheProcessor.java    |   43 +-
 .../processors/cache/GridCacheProxyImpl.java    |   51 +
 .../cache/GridCacheSwapEntryImpl.java           |   61 +-
 .../processors/cache/IgniteCacheProxy.java      |   51 +
 .../processors/cache/IgniteInternalCache.java   |   85 +
 .../binary/CacheObjectBinaryProcessorImpl.java  |  127 +-
 .../dht/CacheDistributedGetFutureAdapter.java   |   15 -
 .../distributed/dht/GridDhtCacheAdapter.java    |    7 +-
 .../cache/distributed/dht/GridDhtGetFuture.java |    6 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |    4 +-
 .../dht/GridPartitionedGetFuture.java           |   38 +-
 .../dht/GridPartitionedSingleGetFuture.java     |   17 +-
 .../dht/atomic/GridDhtAtomicCache.java          |   95 +-
 .../dht/colocated/GridDhtColocatedCache.java    |   42 +-
 .../distributed/near/GridNearAtomicCache.java   |    6 +-
 .../distributed/near/GridNearCacheAdapter.java  |    6 +-
 .../distributed/near/GridNearCacheEntry.java    |    3 +-
 .../distributed/near/GridNearGetFuture.java     |   45 +-
 ...arOptimisticSerializableTxPrepareFuture.java |    2 +-
 .../near/GridNearOptimisticTxPrepareFuture.java |    4 +
 .../GridNearPessimisticTxPrepareFuture.java     |    2 +
 .../near/GridNearTransactionalCache.java        |    9 +-
 .../local/atomic/GridLocalAtomicCache.java      |  106 +-
 .../continuous/CacheContinuousQueryHandler.java |    9 +
 .../cache/transactions/IgniteTxEntry.java       |   32 +-
 .../transactions/IgniteTxLocalAdapter.java      |  196 ++-
 .../cache/transactions/IgniteTxLocalEx.java     |    3 +-
 .../cache/transactions/IgniteTxManager.java     |    2 +-
 .../IgniteCacheObjectProcessorImpl.java         |    7 +-
 .../processors/platform/PlatformIgnition.java   |    6 +-
 .../platform/PlatformNoopProcessor.java         |   15 +
 .../processors/platform/PlatformProcessor.java  |   25 +
 .../platform/PlatformProcessorImpl.java         |   34 +-
 .../platform/cache/PlatformCache.java           |   16 +-
 .../cpp/PlatformCppConfigurationClosure.java    |   32 +
 .../dotnet/PlatformDotNetCacheStore.java        |   39 +-
 .../PlatformDotNetConfigurationClosure.java     |   80 +-
 .../platform/memory/PlatformAbstractMemory.java |    6 +-
 .../PlatformBigEndianOutputStreamImpl.java      |   14 +-
 .../memory/PlatformInputStreamImpl.java         |   53 +-
 .../platform/memory/PlatformMemoryUtils.java    |  108 +-
 .../memory/PlatformOutputStreamImpl.java        |   58 +-
 .../utils/PlatformConfigurationUtils.java       |  621 ++++++++
 .../platform/utils/PlatformUtils.java           |   52 +-
 .../ignite/internal/util/GridHandleTable.java   |   17 +-
 .../ignite/internal/util/GridJavaProcess.java   |    3 -
 .../internal/util/GridSpinReadWriteLock.java    |   10 +-
 .../apache/ignite/internal/util/GridUnsafe.java | 1483 +++++++++++++++++-
 .../ignite/internal/util/IgniteUtils.java       |  106 +-
 .../internal/util/io/GridUnsafeDataInput.java   |  145 +-
 .../internal/util/io/GridUnsafeDataOutput.java  |  165 +-
 .../util/offheap/unsafe/GridUnsafeMap.java      |   75 +-
 .../util/offheap/unsafe/GridUnsafeMemory.java   |  106 +-
 .../optimized/OptimizedClassDescriptor.java     |   22 +-
 .../optimized/OptimizedMarshaller.java          |    5 +-
 .../optimized/OptimizedMarshallerUtils.java     |   44 +-
 .../optimized/OptimizedObjectInputStream.java   |   10 +-
 .../PlatformDotNetCacheStoreFactoryNative.java  |   58 +
 .../ignite/spi/discovery/tcp/ClientImpl.java    |    6 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |   11 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |    1 -
 .../TcpDiscoveryMulticastIpFinder.java          |   12 +-
 .../TcpDiscoveryCustomEventMessage.java         |   10 +-
 .../java/org/apache/ignite/GridTestIoUtils.java |  117 +-
 .../ignite/internal/GridAffinitySelfTest.java   |    2 +-
 .../binary/BinaryBasicIdMapperSelfTest.java     |   51 +
 .../binary/BinaryBasicNameMapperSelfTest.java   |   50 +
 .../BinaryConfigurationConsistencySelfTest.java |  231 +++
 .../internal/binary/BinaryEnumsSelfTest.java    |   12 +-
 .../binary/BinaryFieldsOffheapSelfTest.java     |   13 +-
 .../BinaryFooterOffsetsOffheapSelfTest.java     |   13 +-
 .../binary/BinaryMarshallerSelfTest.java        |  525 ++++++-
 .../BinaryObjectBuilderAdditionalSelfTest.java  |    4 +-
 ...naryObjectBuilderDefaultMappersSelfTest.java | 1149 ++++++++++++++
 .../binary/BinaryObjectBuilderSelfTest.java     | 1108 -------------
 ...ilderSimpleNameLowerCaseMappersSelfTest.java |   41 +
 .../BinarySimpleNameTestPropertySelfTest.java   |   94 ++
 .../binary/GridBinaryMetaDataSelfTest.java      |  371 -----
 .../binary/GridBinaryWildcardsSelfTest.java     |  338 +++-
 ...aultBinaryMappersBinaryMetaDataSelfTest.java |  389 +++++
 ...CaseBinaryMappersBinaryMetaDataSelfTest.java |   41 +
 .../internal/binary/TestMappedObject.java       |   25 +
 .../mutabletest/GridBinaryTestClasses.java      |    3 +-
 ...BuilderNonCompactDefaultMappersSelfTest.java |   30 +
 .../BinaryObjectBuilderNonCompactSelfTest.java  |   30 -
 ...mpactSimpleNameLowerCaseMappersSelfTest.java |   31 +
 .../AbstractBinaryStreamByteOrderSelfTest.java  |  464 ++++++
 .../BinaryHeapStreamByteOrderSelfTest.java      |   29 +
 .../BinaryOffheapStreamByteOrderSelfTest.java   |   31 +
 ...ByteBufferStreamImplV2ByteOrderSelfTest.java |  244 +++
 .../cache/CacheGetEntryAbstractTest.java        |  803 ++++++++++
 ...GetEntryOptimisticReadCommittedSeltTest.java |   36 +
 ...etEntryOptimisticRepeatableReadSeltTest.java |   36 +
 ...eGetEntryOptimisticSerializableSeltTest.java |   36 +
 ...etEntryPessimisticReadCommittedSeltTest.java |   36 +
 ...tEntryPessimisticRepeatableReadSeltTest.java |   36 +
 ...GetEntryPessimisticSerializableSeltTest.java |   36 +
 .../cache/CacheReadThroughRestartSelfTest.java  |   43 +-
 .../CacheSerializableTransactionsTest.java      |  142 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java |  141 ++
 .../cache/GridCacheConcurrentMapSelfTest.java   |   13 +-
 .../GridCacheConditionalDeploymentSelfTest.java |    4 +-
 .../GridCacheInterceptorAbstractSelfTest.java   |  172 +-
 .../GridCacheBinaryObjectsAbstractSelfTest.java |   17 +-
 .../GridCacheBinaryStoreAbstractSelfTest.java   |   10 +
 ...naryStoreBinariesDefaultMappersSelfTest.java |   81 +
 .../GridCacheBinaryStoreBinariesSelfTest.java   |   66 -
 ...yStoreBinariesSimpleNameMappersSelfTest.java |   40 +
 ...GridCacheDhtEvictionNearReadersSelfTest.java |    2 +-
 .../GridCacheReplicatedPreloadSelfTest.java     |  108 ++
 ...ContinuousQueryFailoverAbstractSelfTest.java |    6 +
 ...ntinuousQueryPartitionAtomicOneNodeTest.java |   37 +
 ...heContinuousQueryPartitionTxOneNodeTest.java |   37 +
 ...tinuousQueryReplicatedAtomicOneNodeTest.java |   31 +
 ...ontinuousQueryReplicatedOneNodeSelfTest.java |  120 --
 ...eContinuousQueryReplicatedTxOneNodeTest.java |  193 +++
 ...dUnsafeDataInputOutputByteOrderSelfTest.java |  249 +++
 .../ignite/lang/GridBasicPerformanceTest.java   |   11 +-
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java |    2 +-
 .../config/GridTestProperties.java              |    5 +-
 .../testframework/junits/GridAbstractTest.java  |   27 +-
 .../multijvm/IgniteCacheProcessProxy.java       |   59 +-
 .../ignite/testsuites/IgniteBasicTestSuite.java |    2 +-
 .../testsuites/IgniteBinaryBasicTestSuite.java  |   95 ++
 ...ctsSimpleNameMapperComputeGridTestSuite.java |   38 +
 .../IgniteBinaryObjectsTestSuite.java           |   40 +-
 ...iteBinarySimpleNameMapperBasicTestSuite.java |   38 +
 ...rySimpleNameMapperCacheFullApiTestSuite.java |   39 +
 .../testsuites/IgniteCacheTestSuite4.java       |   12 +
 .../IgniteMarshallerSelfTestSuite.java          |    4 +
 .../tests/p2p/CacheDeploymentTestEnumValue.java |   47 +
 .../p2p/CacheDeploymentTestStoreFactory.java    |  113 ++
 .../hadoop/shuffle/HadoopShuffleJob.java        |    5 +-
 .../hadoop/shuffle/HadoopShuffleMessage.java    |   10 +-
 .../shuffle/streams/HadoopDataOutStream.java    |    6 +-
 .../HadoopConcurrentHashMultimapSelftest.java   |    6 +-
 .../collections/HadoopSkipListSelfTest.java     |    5 +-
 .../IgniteBinaryCacheQueryTestSuite.java        |  186 +--
 ...narySimpleNameMapperCacheQueryTestSuite.java |   38 +
 .../IgniteCacheQuerySelfTestSuite.java          |   10 +-
 .../cpp/common/include/ignite/common/exports.h  |    3 +
 .../cpp/common/include/ignite/common/java.h     |    9 +
 .../platforms/cpp/common/project/vs/module.def  |    5 +-
 modules/platforms/cpp/common/src/exports.cpp    |   12 +
 modules/platforms/cpp/common/src/java.cpp       |   44 +
 .../Apache.Ignite.Core.Tests.csproj             |    3 +
 .../Binary/BinarySelfTest.cs                    |    9 +
 .../Cache/CacheAbstractTest.cs                  |    2 +-
 .../Cache/CacheAffinityTest.cs                  |    2 +-
 .../Cache/CacheConfigurationTest.cs             |  538 +++++++
 .../Cache/CacheDynamicStartTest.cs              |    4 +-
 .../Cache/CacheTestAsyncWrapper.cs              |    7 +
 .../Query/CacheQueriesCodeConfigurationTest.cs  |  295 ++++
 .../Cache/Query/CacheQueriesTest.cs             |    2 +-
 .../Continuous/ContinuousQueryAbstractTest.cs   |    2 +-
 .../Cache/Store/CacheStoreSessionTest.cs        |    2 +-
 .../Cache/Store/CacheStoreTest.cs               |   23 +-
 .../Config/Compute/compute-grid2.xml            |   21 +
 .../Config/Compute/compute-grid3.xml            |   31 +-
 .../Dataload/DataStreamerTest.cs                |    4 +-
 .../Apache.Ignite.Core.Tests/ExceptionsTest.cs  |    2 +-
 .../IgniteConfigurationTest.cs                  |  367 +++++
 .../Apache.Ignite.Core.Tests/MarshallerTest.cs  |    4 +-
 .../SerializationTest.cs                        |    2 +-
 .../Apache.Ignite.Core.Tests/TestRunner.cs      |    5 +-
 .../Apache.Ignite.Core.csproj                   |   29 +-
 .../Binary/BinaryConfiguration.cs               |   27 +-
 .../Configuration/CacheAtomicWriteOrderMode.cs  |   43 +
 .../Cache/Configuration/CacheAtomicityMode.cs   |   54 +
 .../Cache/Configuration/CacheConfiguration.cs   |  601 +++++++
 .../Cache/Configuration/CacheMemoryMode.cs      |   60 +
 .../Cache/Configuration/CacheMode.cs            |   52 +
 .../Cache/Configuration/CacheRebalanceMode.cs   |   51 +
 .../CacheWriteSynchronizationMode.cs            |   45 +
 .../Cache/Configuration/QueryAlias.cs           |   59 +
 .../Cache/Configuration/QueryEntity.cs          |  401 +++++
 .../Cache/Configuration/QueryField.cs           |  109 ++
 .../Cache/Configuration/QueryIndex.cs           |  137 ++
 .../Cache/Configuration/QueryIndexField.cs      |   66 +
 .../Cache/Configuration/QueryIndexType.cs       |   40 +
 .../Configuration/QuerySqlFieldAttribute.cs     |   60 +
 .../Configuration/QueryTextFieldAttribute.cs    |   36 +
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |    6 +
 .../Apache.Ignite.Core/Common/IFactory.cs       |   34 +
 .../Discovery/IDiscoverySpi.cs                  |   32 +
 .../Discovery/Tcp/ITcpDiscoveryIpFinder.cs      |   34 +
 .../Multicast/TcpDiscoveryMulticastIpFinder.cs  |  133 ++
 .../Tcp/Static/TcpDiscoveryStaticIpFinder.cs    |   84 +
 .../Discovery/Tcp/TcpDiscoveryIpFinderBase.cs   |   78 +
 .../Discovery/Tcp/TcpDiscoverySpi.cs            |  144 ++
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |   29 +-
 .../Apache.Ignite.Core/IgniteConfiguration.cs   |  347 +++-
 .../dotnet/Apache.Ignite.Core/Ignition.cs       |   29 +-
 .../Apache.Ignite.Core/Impl/Binary/Binary.cs    |    3 -
 .../Impl/Binary/BinaryReaderExtensions.cs       |   19 +
 .../Apache.Ignite.Core/Impl/Binary/JavaTypes.cs |   92 ++
 .../Impl/Binary/Marshaller.cs                   |    8 +-
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |    9 +-
 .../Apache.Ignite.Core/Impl/Cache/CacheOp.cs    |    3 +-
 .../Impl/Cache/Store/CacheStore.cs              |   20 +-
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |   48 +
 .../Impl/IgniteConfigurationEx.cs               |   57 -
 .../Apache.Ignite.Core/Impl/IgniteManager.cs    |    5 +-
 .../Apache.Ignite.Core/Impl/IgniteProxy.cs      |   18 +-
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |    2 +-
 .../Impl/Memory/PlatformRawMemory.cs            |    2 +-
 .../Impl/Transactions/TransactionsImpl.cs       |    2 +-
 .../Impl/Unmanaged/IgniteJniNativeMethods.cs    |   11 +-
 .../Impl/Unmanaged/UnmanagedUtils.cs            |   22 +-
 .../visor/commands/node/VisorNodeCommand.scala  |    1 +
 .../scala/org/apache/ignite/visor/visor.scala   |    3 +-
 .../config/benchmark-multicast.properties       |    7 +
 .../org/apache/ignite/yardstick/IgniteNode.java |    3 +
 .../IgniteGetEntriesPutAllTxBenchmark.java      |   73 +
 .../cache/IgnitePutGetEntryBenchmark.java       |   47 +
 .../cache/IgnitePutGetEntryTxBenchmark.java     |   73 +
 parent/pom.xml                                  |    1 +
 263 files changed, 16706 insertions(+), 4105 deletions(-)
----------------------------------------------------------------------



[24/28] ignite git commit: 2224 Added Javadoc about new methods to CacheEntry

Posted by vo...@apache.org.
2224 Added Javadoc about new methods to CacheEntry


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

Branch: refs/heads/ignite-2508
Commit: e7de923e6c34bdb4e276bd4314868541087d66f1
Parents: 60c8b07
Author: Anton Vinogradov <av...@apache.org>
Authored: Wed Feb 3 13:11:10 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Feb 3 13:11:10 2016 +0300

----------------------------------------------------------------------
 .../src/main/java/org/apache/ignite/cache/CacheEntry.java   | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e7de923e/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
index d92f9fb..19585a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
@@ -24,9 +24,9 @@ import org.apache.ignite.IgniteCache;
 
 /**
  * Cache entry that extends {@link javax.cache.Cache.Entry} by providing additional entry related information.
- *
- * To get an instance of {@code CacheEntry} use {@link javax.cache.Cache.Entry#unwrap(Class)} method by passing
- * {@code CacheEntry} class to it as the argument.
+ * <p>
+ * To get an instance of {@code CacheEntry} from {@link javax.cache.Cache.Entry} use
+ * {@link javax.cache.Cache.Entry#unwrap(Class)} method by passing {@code CacheEntry} class to it as the argument.
  * <p>
  * {@code CacheEntry} is supported only for {@link javax.cache.Cache.Entry} returned by one of the following methods:
  * <ul>
@@ -36,6 +36,9 @@ import org.apache.ignite.IgniteCache;
  * <li>{@link IgniteCache#randomEntry()}</li>
  * </ul>
  * <p>
+ * To get an instance of {@code CacheEntry} directly use {@link IgniteCache#getEntry(Object)} or
+ * {@link IgniteCache#getEntries(Set)} methods.
+ * <p>
  * {@code CacheEntry} is not supported for {@link javax.cache.Cache#iterator()} because of performance reasons.
  * {@link javax.cache.Cache#iterator()} loads entries from all the cluster nodes and to speed up the load additional
  * information, like entry's version, is ignored.