You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/05/29 09:30:27 UTC

[01/24] ignite git commit: .NET: Remove more dead code from old LINQ CompiledQuery

Repository: ignite
Updated Branches:
  refs/heads/ignite-5075-cc ed2f8b3b7 -> b6d938482


.NET: Remove more dead code from old LINQ CompiledQuery


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

Branch: refs/heads/ignite-5075-cc
Commit: cfc74364c27ad06d38fc2bb40fdc442327e95285
Parents: bdd43ff
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri May 26 11:38:06 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri May 26 11:38:06 2017 +0300

----------------------------------------------------------------------
 .../Impl/CacheQueryExpressionVisitor.cs             | 12 +-----------
 .../Impl/CacheQueryModelVisitor.cs                  | 13 +------------
 .../dotnet/Apache.Ignite.Linq/Impl/MethodVisitor.cs |  7 +++++--
 .../dotnet/Apache.Ignite.Linq/Impl/QueryData.cs     | 16 +---------------
 4 files changed, 8 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cfc74364/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs
index 2d14ec4..8fa0b5d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs
@@ -313,22 +313,12 @@ namespace Apache.Ignite.Linq.Impl
                 ResultBuilder.AppendFormat("{0}.{1}", Aliases.GetTableAlias(expression), fieldName);
             }
             else
-                AppendParameter(RegisterEvaluatedParameter(expression));
+                AppendParameter(ExpressionWalker.EvaluateExpression<object>(expression));
 
             return expression;
         }
 
         /// <summary>
-        /// Registers query parameter that is evaluated from a lambda expression argument.
-        /// </summary>
-        public object RegisterEvaluatedParameter(Expression expression)
-        {
-            _modelVisitor.ParameterExpressions.Add(expression);
-
-            return ExpressionWalker.EvaluateExpression<object>(expression);
-        }
-
-        /// <summary>
         /// Gets the name of the field from a member expression.
         /// </summary>
         private static string GetFieldName(MemberExpression expression, ICacheQueryableInternal queryable)

http://git-wip-us.apache.org/repos/asf/ignite/blob/cfc74364/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
index f74ccc7..f566caa 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
@@ -43,9 +43,6 @@ namespace Apache.Ignite.Linq.Impl
         private readonly List<object> _parameters = new List<object>();
 
         /** */
-        private readonly List<Expression> _parameterExpressions = new List<Expression>();
-
-        /** */
         private readonly AliasDictionary _aliases = new AliasDictionary();
 
         /// <summary>
@@ -63,7 +60,7 @@ namespace Apache.Ignite.Linq.Impl
 
             var qryText = _builder.ToString();
 
-            return new QueryData(qryText, _parameters, _parameterExpressions);
+            return new QueryData(qryText, _parameters);
         }
 
         /// <summary>
@@ -83,14 +80,6 @@ namespace Apache.Ignite.Linq.Impl
         }
 
         /// <summary>
-        /// Gets the parameters.
-        /// </summary>
-        public IList<Expression> ParameterExpressions
-        {
-            get { return _parameterExpressions; }
-        }
-
-        /// <summary>
         /// Gets the aliases.
         /// </summary>
         public AliasDictionary Aliases

http://git-wip-us.apache.org/repos/asf/ignite/blob/cfc74364/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/MethodVisitor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/MethodVisitor.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/MethodVisitor.cs
index 578c5da..9446af3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/MethodVisitor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/MethodVisitor.cs
@@ -250,7 +250,8 @@ namespace Apache.Ignite.Linq.Impl
         /// <summary>
         /// Visits the SQL like expression.
         /// </summary>
-        private static void VisitSqlLike(MethodCallExpression expression, CacheQueryExpressionVisitor visitor, string likeFormat)
+        private static void VisitSqlLike(MethodCallExpression expression, CacheQueryExpressionVisitor visitor,
+            string likeFormat)
         {
             visitor.ResultBuilder.Append("(");
 
@@ -260,7 +261,9 @@ namespace Apache.Ignite.Linq.Impl
 
             var arg = expression.Arguments[0] as ConstantExpression;
 
-            var paramValue = arg != null ? arg.Value : visitor.RegisterEvaluatedParameter(expression.Arguments[0]);
+            var paramValue = arg != null
+                ? arg.Value
+                : ExpressionWalker.EvaluateExpression<object>(expression.Arguments[0]);
 
             visitor.Parameters.Add(paramValue);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/cfc74364/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs
index 5424692..81b91d2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs
@@ -33,24 +33,18 @@ namespace Apache.Ignite.Linq.Impl
         /** */
         private readonly string _queryText;
 
-        /** */
-        private readonly ICollection<Expression> _parameterExpressions;
-
         /// <summary>
         /// Initializes a new instance of the <see cref="QueryData"/> class.
         /// </summary>
         /// <param name="queryText">The query text.</param>
         /// <param name="parameters">The parameters.</param>
-        /// <param name="parameterExpressions"></param>
-        public QueryData(string queryText, ICollection<object> parameters, ICollection<Expression> parameterExpressions)
+        public QueryData(string queryText, ICollection<object> parameters)
         {
             Debug.Assert(queryText != null);
             Debug.Assert(parameters != null);
-            Debug.Assert(parameterExpressions != null);
 
             _queryText = queryText;
             _parameters = parameters;
-            _parameterExpressions = parameterExpressions;
         }
 
         /// <summary>
@@ -70,14 +64,6 @@ namespace Apache.Ignite.Linq.Impl
         }
 
         /// <summary>
-        /// Gets the parameter expressions.
-        /// </summary>
-        public ICollection<Expression> ParameterExpressions
-        {
-            get { return _parameterExpressions; }
-        }
-
-        /// <summary>
         /// Returns a <see cref="string" /> that represents this instance.
         /// </summary>
         /// <returns>


[21/24] ignite git commit: master - tests for SQL schema

Posted by sb...@apache.org.
master - tests for SQL schema


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

Branch: refs/heads/ignite-5075-cc
Commit: c68c146d1671a26efd38335f7902965d0534c0b6
Parents: 52e14ac
Author: Sergi Vladykin <se...@gmail.com>
Authored: Mon May 29 09:41:56 2017 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Mon May 29 09:41:56 2017 +0300

----------------------------------------------------------------------
 .../query/IgniteSqlSplitterSelfTest.java        | 51 ++++++++++++++++++++
 1 file changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c68c146d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index 4bb6a3a..6b984bf 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -1123,6 +1123,57 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     */
+    public void testSchemaQuoted() {
+        assert false; // TODO test hangs
+        doTestSchemaName("\"ppAf\"");
+    }
+
+    /**
+     */
+    public void testSchemaQuotedUpper() {
+        assert false; // TODO test hangs
+        doTestSchemaName("\"PPAF\"");
+    }
+
+    /**
+     */
+    public void testSchemaUnquoted() {
+        doTestSchemaName("ppAf");
+    }
+
+    /**
+     */
+    public void testSchemaUnquotedUpper() {
+        doTestSchemaName("PPAF");
+    }
+
+    /**
+     * @param schema Schema name.
+     */
+    public void doTestSchemaName(String schema) {
+        CacheConfiguration ccfg = cacheConfig("persPartAff", true, Integer.class, Person2.class);
+
+        ccfg.setSqlSchema(schema);
+
+        IgniteCache<Integer, Person2> ppAf = ignite(0).createCache(ccfg);
+
+        try {
+            ppAf.put(1, new Person2(10, "Petya"));
+            ppAf.put(2, new Person2(10, "Kolya"));
+
+            List<List<?>> res = ppAf.query(new SqlFieldsQuery("select name from " +
+                schema + ".Person2 order by _key")).getAll();
+
+            assertEquals("Petya", res.get(0).get(0));
+            assertEquals("Kolya", res.get(1).get(0));
+        }
+        finally {
+            ppAf.destroy();
+        }
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testIndexSegmentation() throws Exception {


[11/24] ignite git commit: IGNITE-5287: Simplified CacheConfiguration.sqlEscapeAll handling. This closes #2004.

Posted by sb...@apache.org.
IGNITE-5287: Simplified CacheConfiguration.sqlEscapeAll handling. This closes #2004.


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

Branch: refs/heads/ignite-5075-cc
Commit: 427ca6900209421db7693df1dbf7e15fc872c0cd
Parents: e09b5a2
Author: devozerov <vo...@gridgain.com>
Authored: Sat May 27 12:48:08 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Sat May 27 12:48:08 2017 +0300

----------------------------------------------------------------------
 .../internal/jdbc2/JdbcNoDefaultCacheTest.java  |   2 -
 .../configuration/CacheConfiguration.java       |  11 +
 .../processors/cache/GridCacheProcessor.java    |  16 +-
 .../processors/query/GridQueryIndexing.java     |   9 +-
 .../processors/query/GridQueryProcessor.java    |  21 +-
 .../query/GridQueryTypeDescriptor.java          |  15 +
 .../internal/processors/query/QuerySchema.java  |   2 +-
 .../query/QueryTypeDescriptorImpl.java          |   9 +
 .../internal/processors/query/QueryUtils.java   | 272 ++++++++++++++-----
 .../query/property/QueryBinaryProperty.java     |   2 +-
 .../query/h2/H2IndexingAbstractGeoSelfTest.java |  26 +-
 .../query/h2/H2IndexingBinaryGeoSelfTest.java   |  30 --
 .../H2IndexingBinarySegmentedGeoSelfTest.java   |  30 --
 .../query/h2/H2IndexingGeoSelfTest.java         |   2 +-
 .../h2/H2IndexingSegmentedGeoSelfTest.java      |   2 +-
 .../testsuites/GeoSpatialIndexingTestSuite.java |   5 -
 .../processors/query/h2/H2RowDescriptor.java    |   8 +-
 .../internal/processors/query/h2/H2Schema.java  |  46 +++-
 .../processors/query/h2/H2TableDescriptor.java  |  30 +-
 .../internal/processors/query/h2/H2Utils.java   |  79 +-----
 .../processors/query/h2/IgniteH2Indexing.java   |  74 ++---
 .../processors/query/h2/opt/GridH2Table.java    |   6 +-
 .../IgniteCacheInsertSqlQuerySelfTest.java      |  27 +-
 .../cache/index/AbstractSchemaSelfTest.java     | 123 +++++++--
 .../DynamicIndexAbstractBasicSelfTest.java      |  77 ++----
 .../DynamicIndexAbstractConcurrentSelfTest.java |  28 +-
 .../index/DynamicIndexAbstractSelfTest.java     |  30 +-
 .../index/H2DynamicIndexAbstractSelfTest.java   |  48 ++--
 .../cache/index/SchemaExchangeSelfTest.java     |  13 +-
 .../query/IgniteSqlSchemaIndexingTest.java      |   4 +-
 .../query/IgniteSqlSplitterSelfTest.java        |  10 +-
 .../h2/GridIndexingSpiAbstractSelfTest.java     |  10 +
 .../query/h2/sql/BaseH2CompareQueryTest.java    |  12 +-
 .../query/h2/sql/H2CompareBigQueryTest.java     |   2 +-
 .../processors/query/h2/sql/bigQuery.sql        |   8 +-
 35 files changed, 602 insertions(+), 487 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java
index b28f9dd..545286c 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.jdbc2;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
-import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.concurrent.Callable;
@@ -33,7 +32,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 1136c71..7269086 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -1819,6 +1819,17 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     }
 
     /**
+     * Clear query entities.
+     *
+     * @return {@code this} for chaining.
+     */
+    public CacheConfiguration<K, V> clearQueryEntities() {
+        this.qryEntities = null;
+
+        return this;
+    }
+
+    /**
      * Defines a hint to query execution engine on desired degree of parallelism within a single node.
      * Query executor may or may not use this hint depending on estimated query costs. Query executor may define
      * certain restrictions on parallelism depending on query type and/or cache type.

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/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 d94c41f..9a25672 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
@@ -45,6 +45,7 @@ import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheExistsException;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.affinity.AffinityFunction;
 import org.apache.ignite.cache.affinity.AffinityFunctionContext;
 import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
@@ -297,6 +298,17 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 throw new IgniteCheckedException("Cannot set both cache writer factory and cache store factory " +
                     "for cache: " + U.maskName(cfg.getName()));
         }
+
+        Collection<QueryEntity> entities = cfg.getQueryEntities();
+
+        if (!F.isEmpty(entities)) {
+            Collection<QueryEntity> normalEntities = new ArrayList<>(entities.size());
+
+            for (QueryEntity entity : entities)
+                normalEntities.add(QueryUtils.normalizeQueryEntity(entity, cfg.isSqlEscapeAll()));
+
+            cfg.clearQueryEntities().setQueryEntities(normalEntities);
+        }
     }
 
     /**
@@ -503,8 +515,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (cc.getEvictionPolicy() != null && !cc.isOnheapCacheEnabled())
             throw new IgniteCheckedException("Onheap cache must be enabled if eviction policy is configured [cacheName="
                 + U.maskName(cc.getName()) + "]");
-
-        QueryUtils.validateCacheConfiguration(cc);
     }
 
     /**
@@ -1361,8 +1371,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         CacheStore cfgStore = cfg.getCacheStoreFactory() != null ? cfg.getCacheStoreFactory().create() : null;
 
-        QueryUtils.prepareCacheConfiguration(cfg);
-
         validate(ctx.config(), cfg, desc.cacheType(), cfgStore);
 
         if (pluginMgr == null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
index 4b9c0e2..77c581c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
@@ -168,12 +168,13 @@ public interface GridQueryIndexing {
      * Registers cache.
      *
      * @param cacheName Cache name.
+     * @param schemaName Schema name.
      * @param cctx Cache context.
      * @param ccfg Cache configuration.
      * @throws IgniteCheckedException If failed.
      */
-    public void registerCache(String cacheName, GridCacheContext<?,?> cctx, CacheConfiguration<?,?> ccfg)
-        throws IgniteCheckedException;
+    public void registerCache(String cacheName, String schemaName, GridCacheContext<?,?> cctx,
+        CacheConfiguration<?,?> ccfg) throws IgniteCheckedException;
 
     /**
      * Unregisters cache.
@@ -207,14 +208,14 @@ public interface GridQueryIndexing {
      * the key should be removed from indexes other than one being updated.
      *
      * @param cacheName Cache name.
-     * @param typeName Type name.
+     * @param type Type descriptor.
      * @param key Key.
      * @param val Value.
      * @param ver Version.
      * @param expirationTime Expiration time or 0 if never expires.
      * @throws IgniteCheckedException If failed.
      */
-    public void store(String cacheName, String typeName, KeyCacheObject key, int partId, CacheObject val,
+    public void store(String cacheName, GridQueryTypeDescriptor type, KeyCacheObject key, int partId, CacheObject val,
         GridCacheVersion ver, long expirationTime, long link) throws IgniteCheckedException;
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 09dbe42..3233fd2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -668,8 +668,12 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
         try {
             synchronized (stateMux) {
+                boolean escape = cctx.config().isSqlEscapeAll();
+
                 String cacheName = cctx.name();
 
+                String schemaName = QueryUtils.normalizeSchemaName(cacheName, cctx.config().getSqlSchema(), escape);
+
                 // Prepare candidates.
                 List<Class<?>> mustDeserializeClss = new ArrayList<>();
 
@@ -680,7 +684,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 if (!F.isEmpty(qryEntities)) {
                     for (QueryEntity qryEntity : qryEntities) {
                         QueryTypeCandidate cand = QueryUtils.typeForQueryEntity(cacheName, cctx, qryEntity,
-                            mustDeserializeClss);
+                            mustDeserializeClss, escape);
 
                         cands.add(cand);
                     }
@@ -755,7 +759,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 }
 
                 // Ready to register at this point.
-                registerCache0(cacheName, cctx, cands);
+                registerCache0(cacheName, schemaName, cctx, cands);
 
                 // Warn about possible implicit deserialization.
                 if (!mustDeserializeClss.isEmpty()) {
@@ -978,7 +982,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         Map<String, T2<QueryEntity, QueryIndex>> idxMap = new HashMap<>();
 
         for (QueryEntity entity : schema.entities()) {
-            String tblName = QueryUtils.tableName(entity);
+            String tblName = entity.getTableName();
 
             QueryEntity oldEntity = tblMap.put(tblName, entity);
 
@@ -989,7 +993,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             }
 
             for (QueryIndex entityIdx : entity.getIndexes()) {
-                String idxName = QueryUtils.indexName(entity, entityIdx);
+                String idxName = entityIdx.getName();
 
                 T2<QueryEntity, QueryIndex> oldIdxEntity = idxMap.put(idxName, new T2<>(entity, entityIdx));
 
@@ -1321,15 +1325,16 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * Register cache in indexing SPI.
      *
      * @param cacheName Cache name.
+     * @param schemaName Schema name.
      * @param cctx Cache context.
      * @param cands Candidates.
      * @throws IgniteCheckedException If failed.
      */
-    private void registerCache0(String cacheName, GridCacheContext<?, ?> cctx, Collection<QueryTypeCandidate> cands)
-        throws IgniteCheckedException {
+    private void registerCache0(String cacheName, String schemaName, GridCacheContext<?, ?> cctx,
+        Collection<QueryTypeCandidate> cands) throws IgniteCheckedException {
         synchronized (stateMux) {
             if (idx != null)
-                idx.registerCache(cacheName, cctx, cctx.config());
+                idx.registerCache(cacheName, schemaName, cctx, cctx.config());
 
             try {
                 for (QueryTypeCandidate cand : cands) {
@@ -1596,7 +1601,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             if (desc == null)
                 return;
 
-            idx.store(cacheName, desc.name(), key, partId, val, ver, expirationTime, link);
+            idx.store(cacheName, desc, key, partId, val, ver, expirationTime, link);
         }
         finally {
             busyLock.leaveBusy();

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
index 3c75ac4..c1a9e1e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.query;
 
 import java.util.Map;
 import org.apache.ignite.IgniteCheckedException;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Value descriptor which allows to extract fields from value object of given type.
@@ -145,4 +146,18 @@ public interface GridQueryTypeDescriptor {
      * @return value field name.
      */
     public String valueFieldName();
+
+    /**
+     * Gets key field alias.
+     *
+     * @return Key field alias.
+     */
+    @Nullable public String keyFieldAlias();
+
+    /**
+     * Gets value field alias.
+     *
+     * @return value field alias.
+     */
+    @Nullable public String valueFieldAlias();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
index b380131..34a4502 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
@@ -93,7 +93,7 @@ public class QuerySchema implements Serializable {
                 SchemaIndexCreateOperation op0 = (SchemaIndexCreateOperation)op;
 
                 for (QueryEntity entity : entities) {
-                    String tblName = QueryUtils.tableName(entity);
+                    String tblName = entity.getTableName();
 
                     if (F.eq(tblName, op0.tableName())) {
                         boolean exists = false;

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryTypeDescriptorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryTypeDescriptorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryTypeDescriptorImpl.java
index 4848b0a..c0da83f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryTypeDescriptorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryTypeDescriptorImpl.java
@@ -447,4 +447,13 @@ public class QueryTypeDescriptorImpl implements GridQueryTypeDescriptor {
     @Override public String valueFieldName() {
         return valFieldName;
     }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public String keyFieldAlias() {
+        return keyFieldName != null ? aliases.get(keyFieldName) : null;
+    }
+
+    @Nullable @Override public String valueFieldAlias() {
+        return valFieldName != null ? aliases.get(valFieldName) : null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
index 245965c..c327820 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.query;
 
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.QueryIndexType;
@@ -45,10 +46,10 @@ import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.sql.Time;
 import java.sql.Timestamp;
-import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -64,13 +65,13 @@ import static org.apache.ignite.IgniteSystemProperties.getInteger;
 public class QueryUtils {
 
     /** Field name for key. */
-    public static final String KEY_FIELD_NAME = "_key";
+    public static final String KEY_FIELD_NAME = "_KEY";
 
     /** Field name for value. */
-    public static final String VAL_FIELD_NAME = "_val";
+    public static final String VAL_FIELD_NAME = "_VAL";
 
     /** Version field name. */
-    public static final String VER_FIELD_NAME = "_ver";
+    public static final String VER_FIELD_NAME = "_VER";
 
     /** Discovery history size. */
     private static final int DISCO_HIST_SIZE = getInteger(IGNITE_INDEXING_DISCOVERY_HISTORY_SIZE, 1000);
@@ -106,8 +107,14 @@ public class QueryUtils {
     public static String tableName(QueryEntity entity) {
         String res = entity.getTableName();
 
-        if (res == null)
+        if (res == null) {
+            String valTyp = entity.findValueType();
+
+            if (valTyp == null)
+                throw new IgniteException("Value type cannot be null or empty [queryEntity=" + entity + ']');
+
             res = typeName(entity.findValueType());
+        }
 
         return res;
     }
@@ -161,17 +168,172 @@ public class QueryUtils {
     }
 
     /**
+     * Normalize query entity. If "escape" flag is set, nothing changes. Otherwise we convert all object names to
+     * upper case and replace inner class separator characters ('$' for Java and '.' for .NET) with underscore.
+     *
+     * @param entity Query entity.
+     * @param escape Escape flag taken form configuration.
+     * @return Normalized query entity.
+     */
+    public static QueryEntity normalizeQueryEntity(QueryEntity entity, boolean escape) {
+        if (escape) {
+            String tblName = tableName(entity);
+
+            entity.setTableName(tblName);
+
+            Map<String, String> aliases = new HashMap<>(entity.getAliases());
+
+            for (String fieldName : entity.getFields().keySet()) {
+                String fieldAlias = entity.getAliases().get(fieldName);
+
+                if (fieldAlias == null) {
+                    fieldAlias = aliasForFieldName(fieldName);
+
+                    aliases.put(fieldName, fieldAlias);
+                }
+            }
+
+            entity.setAliases(aliases);
+
+            for (QueryIndex idx : entity.getIndexes())
+                idx.setName(indexName(tblName, idx));
+
+            validateQueryEntity(entity);
+
+            return entity;
+        }
+
+        QueryEntity normalEntity = new QueryEntity();
+
+        // Propagate plain properties.
+        normalEntity.setKeyType(entity.getKeyType());
+        normalEntity.setValueType(entity.getValueType());
+        normalEntity.setFields(entity.getFields());
+        normalEntity.setKeyFields(entity.getKeyFields());
+        normalEntity.setKeyFieldName(entity.getKeyFieldName());
+        normalEntity.setValueFieldName(entity.getValueFieldName());
+
+        // Normalize table name.
+        String normalTblName = entity.getTableName();
+
+        if (normalTblName == null)
+            // Replace special characters for auto-generated table name.
+            normalTblName = normalizeObjectName(tableName(entity), true);
+        else
+            // No replaces for manually defined table.
+            normalTblName = normalizeObjectName(normalTblName, false);
+
+        normalEntity.setTableName(normalTblName);
+
+        // Normalize field names through aliases.
+        Map<String, String> normalAliases = new HashMap<>(normalEntity.getAliases());
+
+        for (String fieldName : normalEntity.getFields().keySet()) {
+            String fieldAlias = entity.getAliases().get(fieldName);
+
+            if (fieldAlias == null)
+                fieldAlias = aliasForFieldName(fieldName);
+
+            assert fieldAlias != null;
+
+            normalAliases.put(fieldName, normalizeObjectName(fieldAlias, false));
+        }
+
+        normalEntity.setAliases(normalAliases);
+
+        // Normalize indexes.
+        Collection<QueryIndex> normalIdxs = new LinkedList<>();
+
+        for (QueryIndex idx : entity.getIndexes()) {
+            QueryIndex normalIdx = new QueryIndex();
+
+            normalIdx.setFields(idx.getFields());
+            normalIdx.setIndexType(idx.getIndexType());
+            normalIdx.setInlineSize(idx.getInlineSize());
+
+            normalIdx.setName(normalizeObjectName(indexName(normalTblName, idx), false));
+
+            normalIdxs.add(normalIdx);
+        }
+
+        normalEntity.setIndexes(normalIdxs);
+
+        validateQueryEntity(normalEntity);
+
+        return normalEntity;
+    }
+
+    /**
+     * Stores rule for constructing schemaName according to cache configuration.
+     *
+     * @param cacheName Cache name.
+     * @param schemaName Schema name.
+     * @param escape Whether to perform escape.
+     * @return Proper schema name according to ANSI-99 standard.
+     */
+    public static String normalizeSchemaName(String cacheName, @Nullable String schemaName, boolean escape) {
+        String res = schemaName;
+
+        if (res == null) {
+            res = cacheName;
+
+            // If schema name is not set explicitly, we will use escaped cache name. The reason is that cache name
+            // could contain weird characters, such as underscores, dots or non-Latin stuff, which are invalid from
+            // SQL synthax perspective. We do not want node to fail on startup due to this.
+            escape = true;
+        }
+
+        if (!escape)
+            res = normalizeObjectName(res, false);
+
+        return res;
+    }
+
+    /**
+     * Get alias for the field name (i.e. last part of the property).
+     *
+     * @param fieldName Field name.
+     * @return Alias.
+     */
+    private static String aliasForFieldName(String fieldName) {
+        int idx = fieldName.lastIndexOf('.');
+
+        if (idx >= 0)
+            fieldName = fieldName.substring(idx + 1);
+
+        return fieldName;
+    }
+
+    /**
+     * Normalize object name.
+     *
+     * @param str String.
+     * @param replace Whether to perform replace.
+     * @return Escaped string.
+     */
+    public static @Nullable String normalizeObjectName(@Nullable String str, boolean replace) {
+        if (str == null)
+            return null;
+
+        if (replace)
+            str = str.replace('.', '_').replace('$', '_');
+
+        return str.toUpperCase();
+    }
+
+    /**
      * Create type candidate for query entity.
      *
      * @param cacheName Cache name.
      * @param cctx Cache context.
      * @param qryEntity Query entity.
      * @param mustDeserializeClss Classes which must be deserialized.
+     * @param escape Escape flag.
      * @return Type candidate.
      * @throws IgniteCheckedException If failed.
      */
     public static QueryTypeCandidate typeForQueryEntity(String cacheName, GridCacheContext cctx, QueryEntity qryEntity,
-        List<Class<?>> mustDeserializeClss) throws IgniteCheckedException {
+        List<Class<?>> mustDeserializeClss, boolean escape) throws IgniteCheckedException {
         GridKernalContext ctx = cctx.kernalContext();
         CacheConfiguration<?,?> ccfg = cctx.config();
 
@@ -253,8 +415,12 @@ public class QueryUtils {
                 // Need to setup affinity key for distributed joins.
                 String affField = ctx.cacheObjects().affinityField(qryEntity.findKeyType());
 
-                if (affField != null)
+                if (affField != null) {
+                    if (!escape)
+                        affField = normalizeObjectName(affField, false);
+
                     desc.affinityKey(affField);
+                }
             }
         }
         else {
@@ -266,8 +432,12 @@ public class QueryUtils {
                 String affField =
                     ((GridCacheDefaultAffinityKeyMapper)keyMapper).affinityKeyPropertyName(desc.keyClass());
 
-                if (affField != null)
+                if (affField != null) {
+                    if (!escape)
+                        affField = normalizeObjectName(affField, false);
+
                     desc.affinityKey(affField);
+                }
             }
 
             typeId = new QueryTypeIdKey(cacheName, valCls);
@@ -836,76 +1006,48 @@ public class QueryUtils {
     }
 
     /**
-     * Prepare cache configuration.
+     * Validate query entity.
      *
-     * @param ccfg Cache configuration.
+     * @param entity Entity.
      */
-    @SuppressWarnings("unchecked")
-    public static void prepareCacheConfiguration(CacheConfiguration ccfg) {
-        assert ccfg != null;
-
-        Collection<QueryEntity> entities = ccfg.getQueryEntities();
-
-        if (!F.isEmpty(entities)) {
-            for (QueryEntity entity : entities) {
-                if (F.isEmpty(entity.findValueType()))
-                    continue;
-
-                Collection<QueryIndex> idxs = entity.getIndexes();
+    private static void validateQueryEntity(QueryEntity entity) {
+        if (F.isEmpty(entity.findValueType()))
+            throw new IgniteException("Value type cannot be null or empty [queryEntity=" + entity + ']');
 
-                if (!F.isEmpty(idxs)) {
-                    for (QueryIndex idx : idxs) {
-                        if (idx.getName() == null) {
-                            String idxName = indexName(entity, idx);
+        String keyFieldName = entity.getKeyFieldName();
 
-                            idx.setName(idxName);
-                        }
-                    }
-                }
-            }
+        if (keyFieldName != null && !entity.getFields().containsKey(keyFieldName)) {
+            throw new IgniteException("Key field is not in the field list [queryEntity=" + entity +
+                ", keyFieldName=" + keyFieldName + "]");
         }
-    }
 
-    /**
-     * Prepare cache configuration.
-     *
-     * @param ccfg Cache configuration.
-     * @throws IgniteCheckedException If failed.
-     */
-    @SuppressWarnings("unchecked")
-    public static void validateCacheConfiguration(CacheConfiguration ccfg) throws IgniteCheckedException {
-        assert ccfg != null;
-
-        Collection<QueryEntity> entities = ccfg.getQueryEntities();
+        String valFieldName = entity.getValueFieldName();
 
-        if (!F.isEmpty(entities)) {
-            for (QueryEntity entity : entities) {
-                if (F.isEmpty(entity.findValueType()))
-                    throw new IgniteCheckedException("Value type cannot be null or empty [cacheName=" +
-                        ccfg.getName() + ", queryEntity=" + entity + ']');
+        if (valFieldName != null && !entity.getFields().containsKey(valFieldName)) {
+            throw new IgniteException("Value field is not in the field list [queryEntity=" + entity +
+                ", valFieldName=" + valFieldName + "]");
+        }
 
-                Collection<QueryIndex> idxs = entity.getIndexes();
+        Collection<QueryIndex> idxs = entity.getIndexes();
 
-                if (!F.isEmpty(idxs)) {
-                    Set<String> idxNames = new HashSet<>();
+        if (!F.isEmpty(idxs)) {
+            Set<String> idxNames = new HashSet<>();
 
-                    for (QueryIndex idx : idxs) {
-                        String idxName = idx.getName();
+            for (QueryIndex idx : idxs) {
+                String idxName = idx.getName();
 
-                        if (idxName == null)
-                            idxName = indexName(entity, idx);
+                if (idxName == null)
+                    idxName = indexName(entity, idx);
 
-                        assert !F.isEmpty(idxName);
+                assert !F.isEmpty(idxName);
 
-                        if (!idxNames.add(idxName))
-                            throw new IgniteCheckedException("Duplicate index name [cacheName=" + ccfg.getName() +
-                                ", queryEntity=" + entity + ", queryIdx=" + idx + ']');
+                if (!idxNames.add(idxName))
+                    throw new IgniteException("Duplicate index name [queryEntity=" + entity +
+                        ", queryIdx=" + idx + ']');
 
-                        if (idx.getIndexType() == null)
-                            throw new IgniteCheckedException("Index type is not set [cacheName=" + ccfg.getName() +
-                                ", queryEntity=" + entity + ", queryIdx=" + idx + ']');
-                    }
-                }
+                if (idx.getIndexType() == null)
+                    throw new IgniteException("Index type is not set [queryEntity=" + entity +
+                        ", queryIdx=" + idx + ']');
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/core/src/main/java/org/apache/ignite/internal/processors/query/property/QueryBinaryProperty.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/property/QueryBinaryProperty.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/property/QueryBinaryProperty.java
index 3b42a78..d8b907e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/property/QueryBinaryProperty.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/property/QueryBinaryProperty.java
@@ -137,7 +137,7 @@ public class QueryBinaryProperty implements GridQueryProperty {
         else if (obj instanceof BinaryObjectBuilder) {
             BinaryObjectBuilder obj0 = (BinaryObjectBuilder)obj;
 
-            return obj0.getField(name());
+            return obj0.getField(propName);
         }
         else
             throw new IgniteCheckedException("Unexpected binary object class [type=" + obj.getClass() + ']');

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
index ddba4cc..7f135fd 100644
--- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
+++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
@@ -30,9 +30,7 @@ import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
 import org.apache.ignite.internal.processors.query.QueryUtils;
 import org.apache.ignite.internal.util.GridStringBuilder;
@@ -74,20 +72,15 @@ public abstract class H2IndexingAbstractGeoSelfTest extends GridCacheAbstractSel
     /** */
     private static final int QRY_PARALLELISM_LVL = 7;
 
-    /** Binary marshaller flag. */
-    private final boolean binary;
-
     /** Segmented index flag. */
     private final boolean segmented;
 
     /**
      * Constructor.
      *
-     * @param binary Binary marshaller flag.
      * @param segmented Segmented index flag.
      */
-    protected H2IndexingAbstractGeoSelfTest(boolean binary, boolean segmented) {
-        this.binary = binary;
+    protected H2IndexingAbstractGeoSelfTest(boolean segmented) {
         this.segmented = segmented;
     }
 
@@ -101,16 +94,6 @@ public abstract class H2IndexingAbstractGeoSelfTest extends GridCacheAbstractSel
         return DUR * 3;
     }
 
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
-        if (binary)
-            cfg.setMarshaller(new BinaryMarshaller());
-
-        return cfg;
-    }
-
     /**
      * Create cache.
      *
@@ -157,8 +140,11 @@ public abstract class H2IndexingAbstractGeoSelfTest extends GridCacheAbstractSel
             IgniteCache<K, V> cache = grid(0).getOrCreateCache(ccfg);
 
             // Process indexes dynamically.
-            for (QueryIndex idx : idxs)
-                createDynamicIndex(cache, entity, idx);
+            for (QueryIndex idx : idxs) {
+                QueryEntity normalEntity = QueryUtils.normalizeQueryEntity(entity, ccfg.isSqlEscapeAll());
+
+                createDynamicIndex(cache, normalEntity, idx);
+            }
 
             return cache;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingBinaryGeoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingBinaryGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingBinaryGeoSelfTest.java
deleted file mode 100644
index eb3ec6e..0000000
--- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingBinaryGeoSelfTest.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.processors.query.h2;
-
-/**
- * Geo-indexing test for binary mode.
- */
-public class H2IndexingBinaryGeoSelfTest extends H2IndexingAbstractGeoSelfTest {
-    /**
-     * Constructor.
-     */
-    public H2IndexingBinaryGeoSelfTest() {
-        super(true, false);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingBinarySegmentedGeoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingBinarySegmentedGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingBinarySegmentedGeoSelfTest.java
deleted file mode 100644
index fe94a3d..0000000
--- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingBinarySegmentedGeoSelfTest.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.processors.query.h2;
-
-/**
- * Geo-indexing test for binary mode and segmented cache.
- */
-public class H2IndexingBinarySegmentedGeoSelfTest extends H2IndexingAbstractGeoSelfTest {
-    /**
-     * Constructor.
-     */
-    public H2IndexingBinarySegmentedGeoSelfTest() {
-        super(true, true);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingGeoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingGeoSelfTest.java
index 280c946..be3f5cd 100644
--- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingGeoSelfTest.java
+++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingGeoSelfTest.java
@@ -25,6 +25,6 @@ public class H2IndexingGeoSelfTest extends H2IndexingAbstractGeoSelfTest {
      * Constructor.
      */
     public H2IndexingGeoSelfTest() {
-        super(false, false);
+        super(false);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingSegmentedGeoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingSegmentedGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingSegmentedGeoSelfTest.java
index b2cf781..97bfb88 100644
--- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingSegmentedGeoSelfTest.java
+++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingSegmentedGeoSelfTest.java
@@ -25,6 +25,6 @@ public class H2IndexingSegmentedGeoSelfTest extends H2IndexingAbstractGeoSelfTes
      * Constructor.
      */
     public H2IndexingSegmentedGeoSelfTest() {
-        super(false, true);
+        super(true);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java b/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java
index 2395b93..22109de 100644
--- a/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java
+++ b/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java
@@ -18,8 +18,6 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
-import org.apache.ignite.internal.processors.query.h2.H2IndexingBinaryGeoSelfTest;
-import org.apache.ignite.internal.processors.query.h2.H2IndexingBinarySegmentedGeoSelfTest;
 import org.apache.ignite.internal.processors.query.h2.H2IndexingGeoSelfTest;
 import org.apache.ignite.internal.processors.query.h2.H2IndexingSegmentedGeoSelfTest;
 
@@ -37,9 +35,6 @@ public class GeoSpatialIndexingTestSuite extends TestSuite {
         suite.addTestSuite(H2IndexingGeoSelfTest.class);
         suite.addTestSuite(H2IndexingSegmentedGeoSelfTest.class);
 
-        suite.addTestSuite(H2IndexingBinaryGeoSelfTest.class);
-        suite.addTestSuite(H2IndexingBinarySegmentedGeoSelfTest.class);
-
         return suite;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
index 6f5ce3e..fbc9d6c 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
@@ -154,8 +154,12 @@ public class H2RowDescriptor implements GridH2RowDescriptor {
         }
 
         final List<String> fieldsList = Arrays.asList(fields);
-        keyAliasColumnId = (type.keyFieldName() != null) ? DEFAULT_COLUMNS_COUNT + fieldsList.indexOf(type.keyFieldName()) : -1;
-        valueAliasColumnId = (type.valueFieldName() != null) ? DEFAULT_COLUMNS_COUNT + fieldsList.indexOf(type.valueFieldName()) : -1;
+
+        keyAliasColumnId =
+            (type.keyFieldName() != null) ? DEFAULT_COLUMNS_COUNT + fieldsList.indexOf(type.keyFieldAlias()) : -1;
+
+        valueAliasColumnId =
+            (type.valueFieldName() != null) ? DEFAULT_COLUMNS_COUNT + fieldsList.indexOf(type.valueFieldAlias()) : -1;
 
         // Index is not snapshotable in db-x.
         snapshotableIdx = false;

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Schema.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Schema.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Schema.java
index 603a0c1..8dd87c0 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Schema.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Schema.java
@@ -17,14 +17,13 @@
 
 package org.apache.ignite.internal.processors.query.h2;
 
-import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row;
 import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
 import org.h2.mvstore.cache.CacheLongKeyLIRS;
 import org.jsr166.ConcurrentHashMap8;
 
-import java.util.Map;
+import java.util.Collection;
 import java.util.concurrent.ConcurrentMap;
 
 /**
@@ -43,27 +42,24 @@ public class H2Schema {
     /** */
     private final ConcurrentMap<String, H2TableDescriptor> tbls = new ConcurrentHashMap8<>();
 
+    /** */
+    private final ConcurrentMap<String, H2TableDescriptor> typeToTbl = new ConcurrentHashMap8<>();
+
     /** Cache for deserialized offheap rows. */
     private final CacheLongKeyLIRS<GridH2Row> rowCache;
 
     /** */
     private final GridCacheContext<?, ?> cctx;
 
-    /** */
-    private final CacheConfiguration<?, ?> ccfg;
-
     /**
      * @param cacheName Cache name.
      * @param schemaName Schema name.
      * @param cctx Cache context.
-     * @param ccfg Cache configuration.
      */
-    H2Schema(String cacheName, String schemaName, GridCacheContext<?, ?> cctx,
-        CacheConfiguration<?, ?> ccfg) {
+    public H2Schema(String cacheName, String schemaName, GridCacheContext<?, ?> cctx) {
         this.cacheName = cacheName;
         this.cctx = cctx;
         this.schemaName = schemaName;
-        this.ccfg = ccfg;
 
         rowCache = null;
     }
@@ -106,23 +102,43 @@ public class H2Schema {
     /**
      * @return Tables.
      */
-    public Map<String, H2TableDescriptor> tables() {
-        return tbls;
+    public Collection<H2TableDescriptor> tables() {
+        return tbls.values();
+    }
+
+    /**
+     * @param tblName Table name.
+     * @return Table.
+     */
+    public H2TableDescriptor tableByName(String tblName) {
+        return tbls.get(tblName);
+    }
+
+    /**
+     * @param typeName Type name.
+     * @return Table.
+     */
+    public H2TableDescriptor tableByTypeName(String typeName) {
+        return typeToTbl.get(typeName);
     }
 
     /**
      * @param tbl Table descriptor.
      */
     public void add(H2TableDescriptor tbl) {
-        if (tbls.putIfAbsent(tbl.typeName(), tbl) != null)
+        if (tbls.putIfAbsent(tbl.tableName(), tbl) != null)
+            throw new IllegalStateException("Table already registered: " + tbl.fullTableName());
+
+        if (typeToTbl.putIfAbsent(tbl.typeName(), tbl) != null)
             throw new IllegalStateException("Table already registered: " + tbl.fullTableName());
     }
 
     /**
-     * @return Escape all.
+     * @param tbl Table descriptor.
      */
-    public boolean escapeAll() {
-        return ccfg.isSqlEscapeAll();
+    public void remove(H2TableDescriptor tbl) {
+        tbls.remove(tbl.tableName());
+        typeToTbl.remove(tbl.typeName());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
index a9548aa..2440788 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
@@ -80,9 +80,7 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
         this.type = type;
         this.schema = schema;
 
-        String tblName = H2Utils.escapeName(type.tableName(), schema.escapeAll());
-
-        fullTblName = schema.schemaName() + "." + tblName;
+        fullTblName = H2Utils.withQuotes(schema.schemaName()) + "." + H2Utils.withQuotes(type.tableName());
     }
 
     /**
@@ -121,6 +119,13 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
     }
 
     /**
+     * @return Table name.
+     */
+    String tableName() {
+        return type.tableName();
+    }
+
+    /**
      * @return Database full table name.
      */
     String fullTableName() {
@@ -232,10 +237,7 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
 
                 String firstField = idxDesc.fields().iterator().next();
 
-                String firstFieldName =
-                    schema.escapeAll() ? firstField : H2Utils.escapeName(firstField, false).toUpperCase();
-
-                Column col = tbl.getColumn(firstFieldName);
+                Column col = tbl.getColumn(firstField);
 
                 IndexColumn idxCol = tbl.indexColumn(col.getColumnId(),
                     idxDesc.descending(firstField) ? SortOrder.DESCENDING : SortOrder.ASCENDING);
@@ -279,31 +281,27 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
      * @return Index.
      */
     public GridH2IndexBase createUserIndex(GridQueryIndexDescriptor idxDesc) {
-        String name = schema.escapeAll() ? idxDesc.name() : H2Utils.escapeName(idxDesc.name(), false).toUpperCase();
-
         IndexColumn keyCol = tbl.indexColumn(KEY_COL, SortOrder.ASCENDING);
         IndexColumn affCol = tbl.getAffinityKeyColumn();
 
         List<IndexColumn> cols = new ArrayList<>(idxDesc.fields().size() + 2);
 
-        boolean escapeAll = schema.escapeAll();
-
         for (String field : idxDesc.fields()) {
-            String fieldName = escapeAll ? field : H2Utils.escapeName(field, false).toUpperCase();
-
-            Column col = tbl.getColumn(fieldName);
+            Column col = tbl.getColumn(field);
 
             cols.add(tbl.indexColumn(col.getColumnId(),
                 idxDesc.descending(field) ? SortOrder.DESCENDING : SortOrder.ASCENDING));
         }
 
         GridH2RowDescriptor desc = tbl.rowDescriptor();
+
         if (idxDesc.type() == QueryIndexType.SORTED) {
             cols = H2Utils.treeIndexColumns(desc, cols, keyCol, affCol);
-            return idx.createSortedIndex(schema, name, tbl, false, cols, idxDesc.inlineSize());
+
+            return idx.createSortedIndex(schema, idxDesc.name(), tbl, false, cols, idxDesc.inlineSize());
         }
         else if (idxDesc.type() == QueryIndexType.GEOSPATIAL) {
-            return H2Utils.createSpatialIndex(tbl, name, cols.toArray(new IndexColumn[cols.size()]));
+            return H2Utils.createSpatialIndex(tbl, idxDesc.name(), cols.toArray(new IndexColumn[cols.size()]));
         }
 
         throw new IllegalStateException("Index type: " + idxDesc.type());

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Utils.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Utils.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Utils.java
index 75d739d..a4fdb53 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Utils.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2Utils.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.processors.query.h2;
 
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor;
@@ -46,11 +45,8 @@ public class H2Utils {
     private static final String SPATIAL_IDX_CLS =
         "org.apache.ignite.internal.processors.query.h2.opt.GridH2SpatialIndex";
 
-    /** */
-    public static final char ESC_CH = '\"';
-
-    /** */
-    private static final String ESC_STR = ESC_CH + "" + ESC_CH;
+    /** Quotation character. */
+    private static final char ESC_CH = '\"';
 
     /**
      * @param c1 First column.
@@ -98,15 +94,14 @@ public class H2Utils {
      * @param ifNotExists Quietly skip index creation if it exists.
      * @return Statement string.
      */
-    public static String indexCreateSql(String fullTblName, GridH2IndexBase h2Idx, boolean ifNotExists,
-        boolean escapeAll) {
+    public static String indexCreateSql(String fullTblName, GridH2IndexBase h2Idx, boolean ifNotExists) {
         boolean spatial = F.eq(SPATIAL_IDX_CLS, h2Idx.getClass().getName());
 
         GridStringBuilder sb = new SB("CREATE ")
             .a(spatial ? "SPATIAL " : "")
             .a("INDEX ")
             .a(ifNotExists ? "IF NOT EXISTS " : "")
-            .a(escapeName(h2Idx.getName(), escapeAll))
+            .a(withQuotes(h2Idx.getName()))
             .a(" ON ")
             .a(fullTblName)
             .a(" (");
@@ -119,7 +114,7 @@ public class H2Utils {
             else
                 sb.a(", ");
 
-            sb.a("\"" + col.columnName + "\"").a(" ").a(col.sortType == SortOrder.ASCENDING ? "ASC" : "DESC");
+            sb.a(withQuotes(col.columnName)).a(" ").a(col.sortType == SortOrder.ASCENDING ? "ASC" : "DESC");
         }
 
         sb.a(')');
@@ -132,53 +127,10 @@ public class H2Utils {
      * @param schemaName <b>Quoted</b> schema name.
      * @param idxName Index name.
      * @param ifExists Quietly skip index drop if it exists.
-     * @param escapeAll Escape flag.
      * @return Statement string.
      */
-    public static String indexDropSql(String schemaName, String idxName, boolean ifExists, boolean escapeAll) {
-        return "DROP INDEX " + (ifExists ? "IF EXISTS " : "") + schemaName + '.' + escapeName(idxName, escapeAll);
-    }
-
-    /**
-     * Escapes name to be valid SQL identifier. Currently just replaces '.' and '$' sign with '_'.
-     *
-     * @param name Name.
-     * @param escapeAll Escape flag.
-     * @return Escaped name.
-     */
-    public static String escapeName(String name, boolean escapeAll) {
-        if (name == null) // It is possible only for a cache name.
-            return ESC_STR;
-
-        if (escapeAll)
-            return ESC_CH + name + ESC_CH;
-
-        SB sb = null;
-
-        for (int i = 0; i < name.length(); i++) {
-            char ch = name.charAt(i);
-
-            if (!Character.isLetter(ch) && !Character.isDigit(ch) && ch != '_' &&
-                !(ch == '"' && (i == 0 || i == name.length() - 1)) && ch != '-') {
-                // Class name can also contain '$' or '.' - these should be escaped.
-                assert ch == '$' || ch == '.';
-
-                if (sb == null)
-                    sb = new SB();
-
-                sb.a(name.substring(sb.length(), i));
-
-                // Replace illegal chars with '_'.
-                sb.a('_');
-            }
-        }
-
-        if (sb == null)
-            return name;
-
-        sb.a(name.substring(sb.length(), name.length()));
-
-        return sb.toString();
+    public static String indexDropSql(String schemaName, String idxName, boolean ifExists) {
+        return "DROP INDEX " + (ifExists ? "IF EXISTS " : "") + withQuotes(schemaName) + '.' + withQuotes(idxName);
     }
 
     /**
@@ -231,20 +183,13 @@ public class H2Utils {
     }
 
     /**
-     * Stores rule for constructing schemaName according to cache configuration.
+     * Add quotes around the name.
      *
-     * @param ccfg Cache configuration.
-     * @return Proper schema name according to ANSI-99 standard.
+     * @param str String.
+     * @return String with quotes.
      */
-    public static String schemaNameFromCacheConfiguration(CacheConfiguration<?, ?> ccfg) {
-        if (ccfg.getSqlSchema() == null)
-            return escapeName(ccfg.getName(), true);
-
-        if (ccfg.getSqlSchema().charAt(0) == ESC_CH)
-            return ccfg.getSqlSchema();
-
-        return ccfg.isSqlEscapeAll() ?
-            escapeName(ccfg.getSqlSchema(), true) : ccfg.getSqlSchema().toUpperCase();
+    public static String withQuotes(String str) {
+        return ESC_CH + str + ESC_CH;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 8e6eeba..71d3ad5 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -450,7 +450,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             try {
                 stmt = c.connection().createStatement();
 
-                stmt.executeUpdate("SET SCHEMA " + schema);
+                stmt.executeUpdate("SET SCHEMA " + H2Utils.withQuotes(schema));
 
                 if (log.isDebugEnabled())
                     log.debug("Set schema: " + schema);
@@ -476,7 +476,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
      * @throws IgniteCheckedException If failed to create db schema.
      */
     private void createSchema(String schema) throws IgniteCheckedException {
-        executeStatement("INFORMATION_SCHEMA", "CREATE SCHEMA IF NOT EXISTS " + schema);
+        executeStatement("INFORMATION_SCHEMA", "CREATE SCHEMA IF NOT EXISTS " + H2Utils.withQuotes(schema));
 
         if (log.isDebugEnabled())
             log.debug("Created H2 schema for index database: " + schema);
@@ -489,7 +489,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
      * @throws IgniteCheckedException If failed to create db schema.
      */
     private void dropSchema(String schema) throws IgniteCheckedException {
-        executeStatement("INFORMATION_SCHEMA", "DROP SCHEMA IF EXISTS " + schema);
+        executeStatement("INFORMATION_SCHEMA", "DROP SCHEMA IF EXISTS " + H2Utils.withQuotes(schema));
 
         if (log.isDebugEnabled())
             log.debug("Dropped H2 schema for index database: " + schema);
@@ -559,14 +559,14 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
     /** {@inheritDoc} */
     @Override public void store(String cacheName,
-        String typeName,
+        GridQueryTypeDescriptor type,
         KeyCacheObject k,
         int partId,
         CacheObject v,
         GridCacheVersion ver,
         long expirationTime,
         long link) throws IgniteCheckedException {
-        H2TableDescriptor tbl = tableDescriptor(typeName, cacheName);
+        H2TableDescriptor tbl = tableDescriptor(type.name(), cacheName);
 
         if (tbl == null)
             return; // Type was rejected.
@@ -664,7 +664,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
         tbl.onDrop();
 
-        tbl.schema().tables().remove(tbl.typeName());
+        tbl.schema().remove(tbl);
     }
 
     /**
@@ -682,7 +682,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         h2Tbl.proposeUserIndex(h2Idx);
 
         try {
-            String sql = H2Utils.indexCreateSql(desc.fullTableName(), h2Idx, false, desc.schema().escapeAll());
+            String sql = H2Utils.indexCreateSql(desc.fullTableName(), h2Idx, false);
 
             executeSql(cacheName, sql);
         }
@@ -703,7 +703,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
         H2Schema schema = schemas.get(schemaName);
 
-        H2TableDescriptor desc = (schema != null ? schema.tables().get(tblName) : null);
+        H2TableDescriptor desc = (schema != null ? schema.tableByName(tblName) : null);
 
         if (desc == null)
             throw new IgniteCheckedException("Table not found in internal H2 database [schemaName=" + schemaName +
@@ -738,7 +738,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             // At this point index is in consistent state, promote it through H2 SQL statement, so that cached
             // prepared statements are re-built.
-            String sql = H2Utils.indexCreateSql(desc.fullTableName(), h2Idx, ifNotExists, schema.escapeAll());
+            String sql = H2Utils.indexCreateSql(desc.fullTableName(), h2Idx, ifNotExists);
 
             executeSql(cacheName, sql);
         }
@@ -756,9 +756,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         throws IgniteCheckedException{
         String schemaName = schema(cacheName);
 
-        H2Schema schema = schemas.get(schemaName);
-
-        String sql = H2Utils.indexDropSql(schemaName, idxName, ifExists, schema.escapeAll());
+        String sql = H2Utils.indexDropSql(schemaName, idxName, ifExists);
 
         executeSql(cacheName, sql);
     }
@@ -1450,7 +1448,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                     caches0.add(cctx.cacheId());
 
                     for (QueryTable table : twoStepQry.tables()) {
-                        String tblCacheName = cacheNameForSchemaAndTable(table.schema(), table.table());
+                        String tblCacheName = cacheName(table.schema());
 
                         int cacheId = CU.cacheId(tblCacheName);
 
@@ -1505,17 +1503,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /**
-     * Get cache for schema and table.
-     *
-     * @param schemaName Schema name.
-     * @param tblName Table name.
-     * @return Cache name.
-     */
-    private String cacheNameForSchemaAndTable(String schemaName, String tblName) {
-        return cacheName(schemaName);
-    }
-
-    /**
      * @throws IllegalStateException if segmented indices used with non-segmented indices.
      */
     private void checkCacheIndexSegmentation(List<Integer> cacheIds) {
@@ -1661,16 +1648,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                 name.equalsIgnoreCase(VER_FIELD_NAME))
                 throw new IgniteCheckedException(MessageFormat.format(ptrn, name));
         }
-
-        if (type.keyFieldName() != null && !type.fields().containsKey(type.keyFieldName())) {
-            throw new IgniteCheckedException(MessageFormat.format("Name ''{0}'' must be amongst fields since it " +
-                "is configured as ''keyFieldName'' [type=" + type.name() + "]", type.keyFieldName()));
-        }
-
-        if (type.valueFieldName() != null && !type.fields().containsKey(type.valueFieldName())) {
-            throw new IgniteCheckedException(MessageFormat.format("Name ''{0}'' must be amongst fields since it " +
-                "is configured as ''valueFieldName'' [type=" + type.name() + "]", type.valueFieldName()));
-        }
     }
 
     /**
@@ -1688,8 +1665,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         assert schema != null;
         assert tbl != null;
 
-        boolean escapeAll = schema.escapeAll();
-
         String keyType = dbTypeFromClass(tbl.type().keyClass());
         String valTypeStr = dbTypeFromClass(tbl.type().valueClass());
 
@@ -1704,7 +1679,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         sql.a(',').a(VER_FIELD_NAME).a(" OTHER INVISIBLE");
 
         for (Map.Entry<String, Class<?>> e : tbl.type().fields().entrySet())
-            sql.a(',').a(H2Utils.escapeName(e.getKey(), escapeAll)).a(' ').a(dbTypeFromClass(e.getValue()));
+            sql.a(',').a(H2Utils.withQuotes(e.getKey())).a(' ').a(dbTypeFromClass(e.getValue()));
 
         sql.a(')');
 
@@ -1797,7 +1772,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         if (schema == null)
             return null;
 
-        return schema.tables().get(type);
+        return schema.tableByTypeName(type);
     }
 
     /**
@@ -1838,12 +1813,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
         H2Schema schema = schemas.get(schemaName);
 
-        // For the compatibility with conversion from """" to "" inside h2 lib
-        if (schema == null) {
-            assert schemaName.isEmpty() || schemaName.charAt(0) != H2Utils.ESC_CH;
-
-            schema = schemas.get(H2Utils.escapeName(schemaName, true));
-        }
+        assert schema != null;
 
         return schema.cacheName();
     }
@@ -2248,18 +2218,16 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /** {@inheritDoc} */
-    @Override public void registerCache(String cacheName, GridCacheContext<?, ?> cctx, CacheConfiguration<?, ?> ccfg)
-        throws IgniteCheckedException {
-        String schema = H2Utils.schemaNameFromCacheConfiguration(ccfg);
-
-        if (schemas.putIfAbsent(schema, new H2Schema(cacheName, schema, cctx, ccfg)) != null)
+    @Override public void registerCache(String cacheName, String schemaName, GridCacheContext<?, ?> cctx,
+        CacheConfiguration<?, ?> ccfg) throws IgniteCheckedException {
+        if (schemas.putIfAbsent(schemaName, new H2Schema(cacheName, schemaName, cctx)) != null)
             throw new IgniteCheckedException("Cache already registered: " + U.maskName(cacheName));
 
-        cacheName2schema.put(cacheName, schema);
+        cacheName2schema.put(cacheName, schemaName);
 
-        createSchema(schema);
+        createSchema(schemaName);
 
-        createSqlFunctions(schema, ccfg.getSqlFunctionClasses());
+        createSqlFunctions(schemaName, ccfg.getSqlFunctionClasses());
     }
 
     /** {@inheritDoc} */
@@ -2281,7 +2249,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                 U.error(log, "Failed to drop schema on cache stop (will ignore): " + cacheName, e);
             }
 
-            for (H2TableDescriptor tblDesc : rmv.tables().values())
+            for (H2TableDescriptor tblDesc : rmv.tables())
                 for (Index idx : tblDesc.table().getIndexes())
                     idx.close(null);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
index cb9042e..a85cd93 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
@@ -138,10 +138,8 @@ public class GridH2Table extends TableBase {
             int affKeyColId = -1;
 
             if (affKey != null) {
-                String colName = desc.context().config().isSqlEscapeAll() ? affKey : affKey.toUpperCase();
-
-                if (doesColumnExist(colName))
-                    affKeyColId = getColumn(colName).getColumnId();
+                if (doesColumnExist(affKey))
+                    affKeyColId = getColumn(affKey).getColumnId();
                 else
                     affinityColExists = false;
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
index 6bbd7e1..579432f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
@@ -30,6 +30,8 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.GridTestUtils;
 
+import static org.apache.ignite.internal.processors.cache.IgniteCacheUpdateSqlQuerySelfTest.*;
+
 /**
  *
  */
@@ -187,15 +189,20 @@ public class IgniteCacheInsertSqlQuerySelfTest extends IgniteCacheAbstractInsert
      *
      */
     public void testNestedFieldsHandling() {
-        IgniteCache<Integer, IgniteCacheUpdateSqlQuerySelfTest.AllTypes> p = ignite(0).cache("I2AT");
+        IgniteCache<Integer, AllTypes> p = ignite(0).cache("I2AT");
 
-        p.query(new SqlFieldsQuery("insert into AllTypes(_key, innerTypeCol, arrListCol, _val, innerStrCol) " +
-            "values (1, ?, ?, ?, 'sss')") .setArgs(new IgniteCacheUpdateSqlQuerySelfTest.AllTypes.InnerType(50L),
-            new ArrayList<>(Arrays.asList(3L, 2L, 1L)), new IgniteCacheUpdateSqlQuerySelfTest.AllTypes(1L)));
+        p.query(new SqlFieldsQuery(
+            "insert into AllTypes(_key, innerTypeCol, arrListCol, _val, innerStrCol) values (1, ?, ?, ?, 'sss')").
+            setArgs(
+                new AllTypes.InnerType(50L),
+                new ArrayList<>(Arrays.asList(3L, 2L, 1L)),
+                new AllTypes(1L)
+            )
+        );
 
-        IgniteCacheUpdateSqlQuerySelfTest.AllTypes res = p.get(1);
+        AllTypes res = p.get(1);
 
-        IgniteCacheUpdateSqlQuerySelfTest.AllTypes.InnerType resInner = new IgniteCacheUpdateSqlQuerySelfTest.AllTypes.InnerType(50L);
+        AllTypes.InnerType resInner = new AllTypes.InnerType(50L);
 
         resInner.innerStrCol = "sss";
         resInner.arrListCol = new ArrayList<>(Arrays.asList(3L, 2L, 1L));
@@ -208,17 +215,17 @@ public class IgniteCacheInsertSqlQuerySelfTest extends IgniteCacheAbstractInsert
         IgniteCache<Integer, IgniteCacheUpdateSqlQuerySelfTest.AllTypes> p = ignite(0).cache("I2AT");
 
         p.query(new SqlFieldsQuery("insert into AllTypes(_key, _val) values (1, ?)")
-            .setArgs(new IgniteCacheUpdateSqlQuerySelfTest.AllTypes(1L)));
+            .setArgs(new AllTypes(1L)));
 
         p.destroy();
 
         p = ignite(0).getOrCreateCache(cacheConfig("I2AT", true, false, Integer.class,
-            IgniteCacheUpdateSqlQuerySelfTest.AllTypes.class));
+            AllTypes.class));
 
         p.query(new SqlFieldsQuery("insert into AllTypes(_key, _val, dateCol) values (1, ?, null)")
-            .setArgs(new IgniteCacheUpdateSqlQuerySelfTest.AllTypes(1L)));
+            .setArgs(new AllTypes(1L)));
 
-        IgniteCacheUpdateSqlQuerySelfTest.AllTypes exp = new IgniteCacheUpdateSqlQuerySelfTest.AllTypes(1L);
+        AllTypes exp = new AllTypes(1L);
 
         exp.dateCol = null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
index 1f50244..91ae2f7 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
@@ -22,6 +22,7 @@ import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.QueryIndexType;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteEx;
@@ -33,7 +34,9 @@ import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
 import org.apache.ignite.internal.processors.query.QueryIndexDescriptorImpl;
 import org.apache.ignite.internal.processors.query.QueryTypeDescriptorImpl;
 import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.internal.util.GridStringBuilder;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgnitePredicate;
@@ -58,32 +61,38 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
     /** Table name. */
     protected static final String TBL_NAME = tableName(ValueClass.class);
 
-    /** Table name 2. */
-    protected static final String TBL_NAME_2 = tableName(ValueClass2.class);
+    /** Escaped table name. */
+    protected static final String TBL_NAME_ESCAPED = typeName(ValueClass.class);
 
     /** Index name 1. */
-    protected static final String IDX_NAME_1 = "idx_1";
+    protected static final String IDX_NAME_1 = "IDX_1";
+
+    /** Index name 1 escaped. */
+    protected static final String IDX_NAME_1_ESCAPED = "idx_1";
 
     /** Index name 2. */
-    protected static final String IDX_NAME_2 = "idx_2";
+    protected static final String IDX_NAME_2 = "IDX_2";
 
-    /** Index name 3. */
-    protected static final String IDX_NAME_3 = "idx_3";
+    /** Index name 2 escaped. */
+    protected static final String IDX_NAME_2_ESCAPED = "idx_2";
 
     /** Key ID field. */
     protected static final String FIELD_KEY = "id";
 
-    /** Field 1. */
-    protected static final String FIELD_NAME_1 = "field1";
+    /** Key alias */
+    protected static final String FIELD_KEY_ALIAS = "key";
 
     /** Field 1. */
-    protected static final String FIELD_NAME_2 = "field2";
+    protected static final String FIELD_NAME_1 = "FIELD1";
 
-    /** Field 3. */
-    protected static final String FIELD_NAME_3 = "field3";
+    /** Field 1 escaped. */
+    protected static final String FIELD_NAME_1_ESCAPED = "field1";
 
-    /** Key alias */
-    protected static final String FIELD_KEY_ALIAS = "key";
+    /** Field 2. */
+    protected static final String FIELD_NAME_2 = "FIELD2";
+
+    /** Field 2 escaped. */
+    protected static final String FIELD_NAME_2_ESCAPED = "field2";
 
     /**
      * Get type on the given node for the given cache and table name. Type must exist.
@@ -205,7 +214,7 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
         assert desc != null;
 
         for (QueryEntity entity : desc.schema().entities()) {
-            if (F.eq(tblName, QueryUtils.tableName(entity))) {
+            if (F.eq(tblName, entity.getTableName())) {
                 for (QueryIndex idx : entity.getIndexes()) {
                     if (F.eq(QueryUtils.indexName(entity, idx), idxName)) {
                         LinkedHashMap<String, Boolean> idxFields = idx.getFields();
@@ -215,7 +224,7 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
                         int i = 0;
 
                         for (String idxField : idxFields.keySet()) {
-                            assertEquals(idxField, fields[i].get1());
+                            assertEquals(idxField.toLowerCase(), fields[i].get1().toLowerCase());
                             assertEquals(idxFields.get(idxField), fields[i].get2());
 
                             i++;
@@ -256,8 +265,8 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
             String expFieldName = fields[i].get1();
             boolean expFieldAsc = fields[i].get2();
 
-            assertEquals("Index field mismatch [pos=" + i + ", expField=" + expFieldName +
-                ", actualField=" + fieldNames.get(i) + ']', expFieldName, fieldNames.get(i));
+            assertEquals("Index field mismatch [pos=" + i + ", expField=" + expFieldName + ", actualField=" +
+                fieldNames.get(i) + ']', expFieldName.toLowerCase(), fieldNames.get(i).toLowerCase());
 
             boolean fieldAsc = !idxDesc.descending(expFieldName);
 
@@ -275,7 +284,7 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
      */
     protected static void assertNoIndex(String cacheName, String tblName, String idxName) {
         for (Ignite node : Ignition.allGrids())
-            assertNoIndex((IgniteEx)node, cacheName, tblName, idxName);
+            assertNoIndex(node, cacheName, tblName, idxName);
     }
 
     /**
@@ -367,11 +376,21 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
      * @param cls Class.
      * @return Table name.
      */
-    protected static String tableName(Class cls) {
+    protected static String typeName(Class cls) {
         return cls.getSimpleName();
     }
 
     /**
+     * Get table name for class.
+     *
+     * @param cls Class.
+     * @return Table name.
+     */
+    protected static String tableName(Class cls) {
+        return QueryUtils.normalizeObjectName(typeName(cls), true);
+    }
+
+    /**
      * Convenient method for index creation.
      *
      * @param name Name.
@@ -433,6 +452,72 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * Synchronously create index.
+     *
+     * @param node Ignite node.
+     * @param cacheName Cache name.
+     * @param tblName Table name.
+     * @param idx Index.
+     * @param ifNotExists When set to true operation will fail if index already exists.
+     * @throws Exception If failed.
+     */
+    protected void dynamicIndexCreate(Ignite node, String cacheName, String tblName, QueryIndex idx, boolean ifNotExists)
+        throws Exception {
+        GridStringBuilder sql = new SB("CREATE INDEX ")
+            .a(ifNotExists ? "IF NOT EXISTS " : "")
+            .a(idx.getName())
+            .a(" ON ")
+            .a(tblName)
+            .a(" (");
+
+        boolean first = true;
+
+        for (Map.Entry<String, Boolean> fieldEntry : idx.getFields().entrySet()) {
+            if (first)
+                first = false;
+            else
+                sql.a(", ");
+
+            String name = fieldEntry.getKey();
+            boolean asc = fieldEntry.getValue();
+
+            sql.a(name).a(" ").a(asc ? "ASC" : "DESC");
+        }
+
+        sql.a(')');
+
+        executeSql(node, cacheName, sql.toString());
+    }
+
+    /**
+     * Synchronously drop index.
+     *
+     * @param node Ignite node.
+     * @param cacheName Cache name.
+     * @param idxName Index name.
+     * @param ifExists When set to true operation fill fail if index doesn't exists.
+     * @throws Exception if failed.
+     */
+    protected void dynamicIndexDrop(Ignite node, String cacheName, String idxName, boolean ifExists) throws Exception {
+        String sql = "DROP INDEX " + (ifExists ? "IF EXISTS " : "") + idxName;
+
+        executeSql(node, cacheName, sql);
+    }
+
+    /**
+     * Execute SQL.
+     *
+     * @param node Ignite node.
+     * @param cacheName Cache name.
+     * @param sql SQL.
+     */
+    private void executeSql(Ignite node, String cacheName, String sql) {
+        log.info("Executing DDL: " + sql);
+
+        node.cache(cacheName).query(new SqlFieldsQuery(sql)).getAll();
+    }
+
+    /**
      * Key class.
      */
     public static class KeyClass {


[17/24] ignite git commit: IGNITE-5311: Added ability to get CacheObject value without CacheObjectContext. This closes #2019.

Posted by sb...@apache.org.
IGNITE-5311: Added ability to get CacheObject value without CacheObjectContext. This closes #2019.


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

Branch: refs/heads/ignite-5075-cc
Commit: aad3b0c536e3f7b0836d31daa63cd6d6137675d5
Parents: 858e5b7
Author: devozerov <vo...@gridgain.com>
Authored: Sat May 27 21:39:08 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Sat May 27 21:39:08 2017 +0300

----------------------------------------------------------------------
 .../internal/binary/BinaryEnumObjectImpl.java   |   5 +-
 .../internal/binary/BinaryObjectImpl.java       |  18 +-
 .../binary/BinaryObjectOffheapImpl.java         |   3 +-
 .../internal/processors/cache/CacheObject.java  |   2 +-
 .../processors/cache/CacheObjectAdapter.java    |   4 +-
 .../cache/CacheObjectByteArrayImpl.java         |   2 +-
 .../processors/cache/CacheObjectContext.java    | 197 ++-----------------
 .../processors/cache/CacheObjectImpl.java       |  25 ++-
 .../processors/cache/CacheObjectUtils.java      | 173 ++++++++++++++++
 .../cache/CacheObjectValueContext.java          |  50 +++++
 .../processors/cache/GridCacheContext.java      |   4 +-
 .../processors/cache/GridCacheEventManager.java |   2 +-
 .../processors/cache/GridCacheMapEntry.java     |   4 +-
 .../processors/cache/KeyCacheObjectImpl.java    |   4 +-
 .../cache/binary/CacheObjectBinaryContext.java  |   6 +-
 .../binary/CacheObjectBinaryProcessorImpl.java  |   5 +-
 .../cache/database/CacheDataRowAdapter.java     |   8 +-
 .../cache/distributed/near/GridNearTxLocal.java |   3 +-
 .../cache/transactions/TxDeadlock.java          |   7 +-
 .../cacheobject/IgniteCacheObjectProcessor.java |   6 +-
 .../IgniteCacheObjectProcessorImpl.java         |  39 ++--
 .../query/CacheQueryObjectValueContext.java     |  64 ++++++
 .../query/GridQueryCacheObjectsIterator.java    |  16 +-
 .../processors/query/GridQueryProcessor.java    |  14 +-
 .../processors/query/GridRunningQueryInfo.java  |  16 +-
 .../query/VisorRunningQueriesCollectorTask.java |   2 +-
 .../internal/GridAffinityNoCacheSelfTest.java   |   3 +-
 .../IgniteIncompleteCacheObjectSelfTest.java    |   2 +-
 .../database/FreeListImplSelfTest.java          |   3 +-
 .../query/h2/DmlStatementsProcessor.java        |   4 +-
 .../processors/query/h2/IgniteH2Indexing.java   |  44 +++--
 .../query/h2/opt/GridLuceneIndex.java           |   2 +-
 .../query/h2/twostep/GridMapQueryExecutor.java  |   4 +-
 .../h2/twostep/GridReduceQueryExecutor.java     | 159 ++++-----------
 .../query/h2/twostep/ReduceQueryRun.java        | 157 +++++++++++++++
 .../h2/GridIndexingSpiAbstractSelfTest.java     |   3 +-
 .../query/h2/sql/GridQueryParsingTest.java      |   4 +-
 37 files changed, 655 insertions(+), 409 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/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 f889e45..6a1ad6e 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
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.GridDirectTransient;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectAdapter;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.SB;
@@ -280,7 +281,7 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+    @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
         return deserialize();
     }
 
@@ -335,7 +336,7 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
 
     /** {@inheritDoc} */
     @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
-        this.ctx = ((CacheObjectBinaryProcessorImpl)ctx.processor()).binaryContext();
+        this.ctx = ((CacheObjectBinaryProcessorImpl)ctx.kernalContext().cacheObjects()).binaryContext();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
index 16e5ccd..d0d0699 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
@@ -38,6 +38,7 @@ import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectAdapter;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -135,7 +136,7 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+    @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
         Object obj0 = obj;
 
         if (obj0 == null || (cpy && needCopy(ctx)))
@@ -188,7 +189,7 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
 
     /** {@inheritDoc} */
     @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
-        this.ctx = ((CacheObjectBinaryProcessorImpl)ctx.processor()).binaryContext();
+        this.ctx = ((CacheObjectBinaryProcessorImpl)ctx.kernalContext().cacheObjects()).binaryContext();
     }
 
     /** {@inheritDoc} */
@@ -787,9 +788,9 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
      * @param coCtx CacheObjectContext.
      * @return Object.
      */
-    private Object deserializeValue(@Nullable CacheObjectContext coCtx) {
-        BinaryReaderExImpl reader = reader(null,
-            coCtx != null ? coCtx.kernalContext().config().getClassLoader() : ctx.configuration().getClassLoader(), true);
+    private Object deserializeValue(@Nullable CacheObjectValueContext coCtx) {
+        BinaryReaderExImpl reader = reader(null, coCtx != null ?
+            coCtx.kernalContext().config().getClassLoader() : ctx.configuration().getClassLoader(), true);
 
         Object obj0 = reader.deserialize();
 
@@ -807,8 +808,8 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
      * @param ctx Context.
      * @return {@code True} need to copy value returned to user.
      */
-    private boolean needCopy(CacheObjectContext ctx) {
-        return ctx.copyOnGet() && obj != null && !ctx.processor().immutable(obj);
+    private boolean needCopy(CacheObjectValueContext ctx) {
+        return ctx.copyOnGet() && obj != null && !ctx.kernalContext().cacheObjects().immutable(obj);
     }
 
     /**
@@ -819,7 +820,8 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
      * @param forUnmarshal {@code True} if reader is need to unmarshal object.
      * @return Reader.
      */
-    private BinaryReaderExImpl reader(@Nullable BinaryReaderHandles rCtx, @Nullable ClassLoader ldr, boolean forUnmarshal) {
+    private BinaryReaderExImpl reader(@Nullable BinaryReaderHandles rCtx, @Nullable ClassLoader ldr,
+        boolean forUnmarshal) {
         if (ldr == null)
             ldr = ctx.configuration().getClassLoader();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/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 bdf0ce1..0a0a7b1 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
@@ -37,6 +37,7 @@ 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.processors.cache.CacheObjectValueContext;
 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;
@@ -444,7 +445,7 @@ public class BinaryObjectOffheapImpl extends BinaryObjectExImpl implements Exter
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+    @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
         return (T)deserializeValue();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
index c226ba2..8faaa03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
@@ -43,7 +43,7 @@ public interface CacheObject extends Message {
      * @param cpy If {@code true} need to copy value.
      * @return Value.
      */
-    @Nullable public <T> T value(CacheObjectContext ctx, boolean cpy);
+    @Nullable public <T> T value(CacheObjectValueContext ctx, boolean cpy);
 
     /**
      * @param ctx Context.

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
index 6af38ac..e2a15ee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java
@@ -50,8 +50,8 @@ public abstract class CacheObjectAdapter implements CacheObject, Externalizable
      * @param ctx Context.
      * @return {@code True} need to copy value returned to user.
      */
-    protected boolean needCopy(CacheObjectContext ctx) {
-        return ctx.copyOnGet() && val != null && !ctx.processor().immutable(val);
+    protected boolean needCopy(CacheObjectValueContext ctx) {
+        return ctx.copyOnGet() && val != null && !ctx.kernalContext().cacheObjects().immutable(val);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
index fe284ae..6a13f8d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
@@ -62,7 +62,7 @@ public class CacheObjectByteArrayImpl implements CacheObject, Externalizable {
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+    @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
         if (cpy)
             return (T)Arrays.copyOf(val, val.length);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
index a777ab6..655a3e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
@@ -27,21 +27,17 @@ import java.util.Map;
 import org.apache.ignite.cache.affinity.AffinityKeyMapper;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.binary.BinaryUtils;
-import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
 import org.apache.ignite.internal.util.typedef.F;
 
 /**
  *
  */
 @SuppressWarnings("TypeMayBeWeakened")
-public class CacheObjectContext {
+public class CacheObjectContext implements CacheObjectValueContext {
     /** */
     private GridKernalContext kernalCtx;
 
     /** */
-    private IgniteCacheObjectProcessor proc;
-
-    /** */
     private String cacheName;
 
     /** */
@@ -54,9 +50,6 @@ public class CacheObjectContext {
     private boolean storeVal;
 
     /** */
-    private boolean p2pEnabled;
-
-    /** */
     private boolean addDepInfo;
 
     /**
@@ -78,9 +71,6 @@ public class CacheObjectContext {
         this.cpyOnGet = cpyOnGet;
         this.storeVal = storeVal;
         this.addDepInfo = addDepInfo;
-
-        p2pEnabled = kernalCtx.config().isPeerClassLoadingEnabled();
-        proc = kernalCtx.cacheObjects();
     }
 
     /**
@@ -90,31 +80,18 @@ public class CacheObjectContext {
         return cacheName;
     }
 
-    /**
-     * @return {@code True} if peer class loading is enabled.
-     */
-    public boolean p2pEnabled() {
-        return p2pEnabled;
-    }
-
-    /**
-     * @return {@code True} if deployment info should be associated with the objects of this cache.
-     */
-    public boolean addDeploymentInfo() {
+    /** {@inheritDoc} */
+    @Override public boolean addDeploymentInfo() {
         return addDepInfo;
     }
 
-    /**
-     * @return Copy on get flag.
-     */
-    public boolean copyOnGet() {
+    /** {@inheritDoc} */
+    @Override public boolean copyOnGet() {
         return cpyOnGet;
     }
 
-    /**
-     * @return {@code True} if should store unmarshalled value in cache.
-     */
-    public boolean storeValue() {
+    /** {@inheritDoc} */
+    @Override public boolean storeValue() {
         return storeVal;
     }
 
@@ -125,27 +102,14 @@ public class CacheObjectContext {
         return dfltAffMapper;
     }
 
-    /**
-     * @return Kernal context.
-     */
-    public GridKernalContext kernalContext() {
+    /** {@inheritDoc} */
+    @Override public GridKernalContext kernalContext() {
         return kernalCtx;
     }
 
-    /**
-     * @return Processor.
-     */
-    public IgniteCacheObjectProcessor processor() {
-        return proc;
-    }
-
-    /**
-     * @param o Object to unwrap.
-     * @param keepBinary Keep binary flag.
-     * @return Unwrapped object.
-     */
-    public Object unwrapBinaryIfNeeded(Object o, boolean keepBinary) {
-        return unwrapBinaryIfNeeded(o, keepBinary, true);
+    /** {@inheritDoc} */
+    @Override public boolean binaryEnabled() {
+        return false;
     }
 
     /**
@@ -158,141 +122,6 @@ public class CacheObjectContext {
         if (o == null)
             return null;
 
-        return unwrapBinary(o, keepBinary, cpy);
-    }
-
-    /**
-     * @param col Collection of objects to unwrap.
-     * @param keepBinary Keep binary flag.
-     * @return Unwrapped collection.
-     */
-    public Collection<Object> unwrapBinariesIfNeeded(Collection<Object> col, boolean keepBinary) {
-        return unwrapBinariesIfNeeded(col, keepBinary, true);
-    }
-
-    /**
-     * @param col Collection to unwrap.
-     * @param keepBinary Keep binary flag.
-     * @param cpy Copy value flag.
-     * @return Unwrapped collection.
-     */
-    public Collection<Object> unwrapBinariesIfNeeded(Collection<Object> col, boolean keepBinary, boolean cpy) {
-        Collection<Object> col0 = BinaryUtils.newKnownCollection(col);
-
-        if (col0 == null)
-            col0 = new ArrayList<>(col.size());
-
-        for (Object obj : col)
-            col0.add(unwrapBinary(obj, keepBinary, cpy));
-
-        return col0;
-    }
-
-    /**
-     * @param col Collection to unwrap.
-     * @param keepBinary Keep binary flag.
-     * @param cpy Copy flag.
-     * @return Unwrapped collection.
-     */
-    private Collection<Object> unwrapKnownCollection(Collection<Object> col, boolean keepBinary, boolean cpy) {
-        Collection<Object> col0 = BinaryUtils.newKnownCollection(col);
-
-        for (Object obj : col)
-            col0.add(unwrapBinary(obj, keepBinary, cpy));
-
-        return col0;
-    }
-
-    /**
-     * Unwrap array of binaries if needed.
-     *
-     * @param arr Array.
-     * @param keepBinary Keep binary flag.
-     * @param cpy Copy.
-     * @return Result.
-     */
-    public Object[] unwrapBinariesInArrayIfNeeded(Object[] arr, boolean keepBinary, boolean cpy) {
-        if (BinaryUtils.knownArray(arr))
-            return arr;
-
-        Object[] res = new Object[arr.length];
-
-        for (int i = 0; i < arr.length; i++)
-            res[i] = unwrapBinary(arr[i], keepBinary, cpy);
-
-        return res;
-    }
-
-    /**
-     * Unwraps map.
-     *
-     * @param map Map to unwrap.
-     * @param keepBinary Keep binary flag.
-     * @return Unwrapped collection.
-     */
-    private Map<Object, Object> unwrapBinariesIfNeeded(Map<Object, Object> map, boolean keepBinary, boolean cpy) {
-        if (keepBinary)
-            return map;
-
-        Map<Object, Object> map0 = BinaryUtils.newMap(map);
-
-        for (Map.Entry<Object, Object> e : map.entrySet())
-            map0.put(unwrapBinary(e.getKey(), keepBinary, cpy), unwrapBinary(e.getValue(), keepBinary, cpy));
-
-        return map0;
-    }
-
-    /**
-     * @param o Object to unwrap.
-     * @return Unwrapped object.
-     */
-    private Object unwrapBinary(Object o, boolean keepBinary, boolean cpy) {
-        if (o instanceof Map.Entry) {
-            Map.Entry entry = (Map.Entry)o;
-
-            Object key = entry.getKey();
-
-            Object uKey = unwrapBinary(key, keepBinary, cpy);
-
-            Object val = entry.getValue();
-
-            Object uVal = unwrapBinary(val, keepBinary, cpy);
-
-            return (key != uKey || val != uVal) ? F.t(uKey, uVal) : o;
-        }
-        else if (BinaryUtils.knownCollection(o))
-            return unwrapKnownCollection((Collection<Object>)o, keepBinary, cpy);
-        else if (BinaryUtils.knownMap(o))
-            return unwrapBinariesIfNeeded((Map<Object, Object>)o, keepBinary, cpy);
-        else if (o instanceof Object[])
-            return unwrapBinariesInArrayIfNeeded((Object[])o, keepBinary, cpy);
-        else if (o instanceof CacheObject) {
-            CacheObject co = (CacheObject)o;
-
-            if (!keepBinary || co.isPlatformType())
-                return unwrapBinary(co.value(this, cpy), keepBinary, cpy);
-        }
-
-        return o;
-    }
-
-    /**
-     * @param o Object to test.
-     * @return True if collection should be recursively unwrapped.
-     */
-    private boolean knownCollection(Object o) {
-        Class<?> cls = o == null ? null : o.getClass();
-
-        return cls == ArrayList.class || cls == LinkedList.class || cls == HashSet.class;
-    }
-
-    /**
-     * @param o Object to test.
-     * @return True if map should be recursively unwrapped.
-     */
-    private boolean knownMap(Object o) {
-        Class<?> cls = o == null ? null : o.getClass();
-
-        return cls == HashMap.class || cls == LinkedHashMap.class;
+        return CacheObjectUtils.unwrapBinaryIfNeeded(this, o, keepBinary, cpy);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
index 7fe4297..76f354a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
@@ -19,6 +19,8 @@ package org.apache.ignite.internal.processors.cache;
 
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -53,27 +55,31 @@ public class CacheObjectImpl extends CacheObjectAdapter {
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+    @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
         cpy = cpy && needCopy(ctx);
 
         try {
+            GridKernalContext kernalCtx = ctx.kernalContext();
+
+            IgniteCacheObjectProcessor proc = ctx.kernalContext().cacheObjects();
+
             if (cpy) {
                 if (valBytes == null) {
                     assert val != null;
 
-                    valBytes = ctx.processor().marshal(ctx, val);
+                    valBytes = proc.marshal(ctx, val);
                 }
 
                 ClassLoader clsLdr;
 
                 if (val != null)
                     clsLdr = val.getClass().getClassLoader();
-                else if (ctx.kernalContext().config().isPeerClassLoadingEnabled())
-                    clsLdr = ctx.kernalContext().cache().context().deploy().globalLoader();
+                else if (kernalCtx.config().isPeerClassLoadingEnabled())
+                    clsLdr = kernalCtx.cache().context().deploy().globalLoader();
                 else
                     clsLdr = null;
 
-                return (T)ctx.processor().unmarshal(ctx, valBytes, clsLdr);
+                return (T)proc.unmarshal(ctx, valBytes, clsLdr);
             }
 
             if (val != null)
@@ -81,9 +87,8 @@ public class CacheObjectImpl extends CacheObjectAdapter {
 
             assert valBytes != null;
 
-            Object val = ctx.processor().unmarshal(ctx, valBytes,
-                ctx.kernalContext().config().isPeerClassLoadingEnabled() ?
-                    ctx.kernalContext().cache().context().deploy().globalLoader() : null);
+            Object val = proc.unmarshal(ctx, valBytes, kernalCtx.config().isPeerClassLoadingEnabled() ?
+                kernalCtx.cache().context().deploy().globalLoader() : null);
 
             if (ctx.storeValue())
                 this.val = val;
@@ -98,7 +103,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
     /** {@inheritDoc} */
     @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
         if (valBytes == null)
-            valBytes = ctx.processor().marshal(ctx, val);
+            valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val);
 
         return valBytes;
     }
@@ -116,7 +121,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
         assert val != null || valBytes != null;
 
         if (val == null && ctx.storeValue())
-            val = ctx.processor().unmarshal(ctx, valBytes, ldr);
+            val = ctx.kernalContext().cacheObjects().unmarshal(ctx, valBytes, ldr);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectUtils.java
new file mode 100644
index 0000000..f9c76df
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectUtils.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.util.typedef.F;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Cache object utility methods.
+ */
+public class CacheObjectUtils {
+    /**
+     * @param o Object to unwrap.
+     * @param keepBinary Keep binary flag.
+     * @param cpy Copy value flag.
+     * @return Unwrapped object.
+     */
+    public static Object unwrapBinaryIfNeeded(CacheObjectValueContext ctx, Object o, boolean keepBinary, boolean cpy) {
+        if (o == null)
+            return null;
+
+        return unwrapBinary(ctx, o, keepBinary, cpy);
+    }
+
+    /**
+     * @param col Collection of objects to unwrap.
+     * @param keepBinary Keep binary flag.
+     * @return Unwrapped collection.
+     */
+    public static Collection<Object> unwrapBinariesIfNeeded(CacheObjectValueContext ctx, Collection<Object> col,
+        boolean keepBinary) {
+        return unwrapBinariesIfNeeded(ctx, col, keepBinary, true);
+    }
+
+    /**
+     * @param col Collection to unwrap.
+     * @param keepBinary Keep binary flag.
+     * @param cpy Copy flag.
+     * @return Unwrapped collection.
+     */
+    private static Collection<Object> unwrapKnownCollection(CacheObjectValueContext ctx, Collection<Object> col,
+        boolean keepBinary, boolean cpy) {
+        Collection<Object> col0 = BinaryUtils.newKnownCollection(col);
+
+        assert col0 != null;
+
+        for (Object obj : col)
+            col0.add(unwrapBinary(ctx, obj, keepBinary, cpy));
+
+        return col0;
+    }
+
+    /**
+     * Unwraps map.
+     *
+     * @param map Map to unwrap.
+     * @param keepBinary Keep binary flag.
+     * @return Unwrapped collection.
+     */
+    private static Map<Object, Object> unwrapBinariesIfNeeded(CacheObjectValueContext ctx, Map<Object, Object> map,
+        boolean keepBinary, boolean cpy) {
+        if (keepBinary)
+            return map;
+
+        Map<Object, Object> map0 = BinaryUtils.newMap(map);
+
+        for (Map.Entry<Object, Object> e : map.entrySet())
+            map0.put(unwrapBinary(ctx, e.getKey(), false, cpy), unwrapBinary(ctx, e.getValue(), false, cpy));
+
+        return map0;
+    }
+
+    /**
+     * @param col Collection to unwrap.
+     * @param keepBinary Keep binary flag.
+     * @param cpy Copy value flag.
+     * @return Unwrapped collection.
+     */
+    private static Collection<Object> unwrapBinariesIfNeeded(CacheObjectValueContext ctx, Collection<Object> col,
+        boolean keepBinary, boolean cpy) {
+        Collection<Object> col0 = BinaryUtils.newKnownCollection(col);
+
+        if (col0 == null)
+            col0 = new ArrayList<>(col.size());
+
+        for (Object obj : col)
+            col0.add(unwrapBinary(ctx, obj, keepBinary, cpy));
+
+        return col0;
+    }
+
+    /**
+     * Unwrap array of binaries if needed.
+     *
+     * @param arr Array.
+     * @param keepBinary Keep binary flag.
+     * @param cpy Copy.
+     * @return Result.
+     */
+    private static Object[] unwrapBinariesInArrayIfNeeded(CacheObjectValueContext ctx, Object[] arr, boolean keepBinary,
+        boolean cpy) {
+        if (BinaryUtils.knownArray(arr))
+            return arr;
+
+        Object[] res = new Object[arr.length];
+
+        for (int i = 0; i < arr.length; i++)
+            res[i] = unwrapBinary(ctx, arr[i], keepBinary, cpy);
+
+        return res;
+    }
+
+    /**
+     * @param o Object to unwrap.
+     * @return Unwrapped object.
+     */
+    @SuppressWarnings("unchecked")
+    private static Object unwrapBinary(CacheObjectValueContext ctx, Object o, boolean keepBinary, boolean cpy) {
+        if (o instanceof Map.Entry) {
+            Map.Entry entry = (Map.Entry)o;
+
+            Object key = entry.getKey();
+
+            Object uKey = unwrapBinary(ctx, key, keepBinary, cpy);
+
+            Object val = entry.getValue();
+
+            Object uVal = unwrapBinary(ctx, val, keepBinary, cpy);
+
+            return (key != uKey || val != uVal) ? F.t(uKey, uVal) : o;
+        }
+        else if (BinaryUtils.knownCollection(o))
+            return unwrapKnownCollection(ctx, (Collection<Object>)o, keepBinary, cpy);
+        else if (BinaryUtils.knownMap(o))
+            return unwrapBinariesIfNeeded(ctx, (Map<Object, Object>)o, keepBinary, cpy);
+        else if (o instanceof Object[])
+            return unwrapBinariesInArrayIfNeeded(ctx, (Object[])o, keepBinary, cpy);
+        else if (o instanceof CacheObject) {
+            CacheObject co = (CacheObject)o;
+
+            if (!keepBinary || co.isPlatformType())
+                return unwrapBinary(ctx, co.value(ctx, cpy), keepBinary, cpy);
+        }
+
+        return o;
+    }
+
+    /**
+     * Private constructor.
+     */
+    private CacheObjectUtils() {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectValueContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectValueContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectValueContext.java
new file mode 100644
index 0000000..49b2873
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectValueContext.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.processors.cache;
+
+import org.apache.ignite.internal.GridKernalContext;
+
+/**
+ * Context to get value of cache object.
+ */
+public interface CacheObjectValueContext {
+    /**
+     * @return Kernal context.
+     */
+    public GridKernalContext kernalContext();
+
+    /**
+     * @return Copy on get flag.
+     */
+    public boolean copyOnGet();
+
+    /**
+     * @return {@code True} if should store unmarshalled value in cache.
+     */
+    public boolean storeValue();
+
+    /**
+     * @return {@code True} if deployment info should be associated with the objects of this cache.
+     */
+    public boolean addDeploymentInfo();
+
+    /**
+     * @return Binary enabled flag.
+     */
+    public boolean binaryEnabled();
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/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 a3e70dd..e637122 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
@@ -1713,7 +1713,7 @@ public class GridCacheContext<K, V> implements Externalizable {
      * @return Unwrapped collection.
      */
     public Collection<Object> unwrapBinariesIfNeeded(Collection<Object> col, boolean keepBinary) {
-        return cacheObjCtx.unwrapBinariesIfNeeded(col, keepBinary);
+        return CacheObjectUtils.unwrapBinariesIfNeeded(cacheObjCtx, col, keepBinary);
     }
 
     /**
@@ -1724,7 +1724,7 @@ public class GridCacheContext<K, V> implements Externalizable {
      * @return Unwrapped object.
      */
     public Object unwrapBinaryIfNeeded(Object o, boolean keepBinary) {
-        return cacheObjCtx.unwrapBinaryIfNeeded(o, keepBinary);
+        return unwrapBinaryIfNeeded(o, keepBinary, true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
index 687b132..93c5950 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
@@ -309,7 +309,7 @@ public class GridCacheEventManager extends GridCacheManagerAdapter {
                 oldVal0 = cctx.cacheObjectContext().unwrapBinaryIfNeeded(oldVal, keepBinary, false);
             }
             catch (Exception e) {
-                if (!cctx.cacheObjectContext().processor().isBinaryEnabled(cctx.config()))
+                if (!cctx.cacheObjectContext().kernalContext().cacheObjects().isBinaryEnabled(cctx.config()))
                     throw e;
 
                 if (log.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/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 15e4469..4f87658 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
@@ -3840,13 +3840,13 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
         /** {@inheritDoc} */
         @Override public K getKey() {
-            return (K)cctx.cacheObjectContext().unwrapBinaryIfNeeded(key, keepBinary);
+            return (K)cctx.cacheObjectContext().unwrapBinaryIfNeeded(key, keepBinary, true);
         }
 
         /** {@inheritDoc} */
         @SuppressWarnings("unchecked")
         @Override public V getValue() {
-            return (V)cctx.cacheObjectContext().unwrapBinaryIfNeeded(peekVisibleValue(), keepBinary);
+            return (V)cctx.cacheObjectContext().unwrapBinaryIfNeeded(peekVisibleValue(), keepBinary, true);
         }
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
index b9efab1..c50672b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
@@ -75,7 +75,7 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb
     /** {@inheritDoc} */
     @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
         if (valBytes == null)
-            valBytes = ctx.processor().marshal(ctx, val);
+            valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val);
 
         return valBytes;
     }
@@ -94,7 +94,7 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+    @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
         assert val != null;
 
         return (T)val;

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryContext.java
index 26c713c..3b3cf67 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryContext.java
@@ -53,10 +53,8 @@ public class CacheObjectBinaryContext extends CacheObjectContext {
         this.binaryEnabled = binaryEnabled;
     }
 
-    /**
-     * @return Binary enabled flag.
-     */
-    public boolean binaryEnabled() {
+    /** {@inheritDoc} */
+    @Override public boolean binaryEnabled() {
         return binaryEnabled;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/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 14947e9..5567809 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
@@ -59,6 +59,7 @@ import org.apache.ignite.internal.binary.streams.BinaryOffheapInputStream;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheUtils;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
@@ -735,7 +736,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     }
 
     /** {@inheritDoc} */
-    @Override public byte[] marshal(CacheObjectContext ctx, Object val) throws IgniteCheckedException {
+    @Override public byte[] marshal(CacheObjectValueContext ctx, Object val) throws IgniteCheckedException {
         if (!((CacheObjectBinaryContext)ctx).binaryEnabled() || binaryMarsh == null)
             return super.marshal(ctx, val);
 
@@ -747,7 +748,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     }
 
     /** {@inheritDoc} */
-    @Override public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr)
+    @Override public Object unmarshal(CacheObjectValueContext ctx, byte[] bytes, ClassLoader clsLdr)
         throws IgniteCheckedException {
         if (!((CacheObjectBinaryContext)ctx).binaryEnabled() || binaryMarsh == null)
             return super.unmarshal(ctx, bytes, clsLdr);

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
index afeada5..955ca69 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
@@ -283,7 +283,7 @@ public class CacheDataRowAdapter implements CacheDataRow {
             byte[] bytes = PageUtils.getBytes(addr, off, len);
             off += len;
 
-            key = coctx.processor().toKeyCacheObject(coctx, type, bytes);
+            key = coctx.kernalContext().cacheObjects().toKeyCacheObject(coctx, type, bytes);
 
             if (rowData == RowData.KEY_ONLY)
                 return;
@@ -300,7 +300,7 @@ public class CacheDataRowAdapter implements CacheDataRow {
         byte[] bytes = PageUtils.getBytes(addr, off, len);
         off += len;
 
-        val = coctx.processor().toCacheObject(coctx, type, bytes);
+        val = coctx.kernalContext().cacheObjects().toCacheObject(coctx, type, bytes);
 
         ver = CacheVersionIO.read(addr + off, false);
 
@@ -359,7 +359,7 @@ public class CacheDataRowAdapter implements CacheDataRow {
         ByteBuffer buf,
         IncompleteCacheObject incomplete
     ) throws IgniteCheckedException {
-        incomplete = coctx.processor().toKeyCacheObject(coctx, buf, incomplete);
+        incomplete = coctx.kernalContext().cacheObjects().toKeyCacheObject(coctx, buf, incomplete);
 
         if (incomplete.isReady()) {
             key = (KeyCacheObject)incomplete.object();
@@ -384,7 +384,7 @@ public class CacheDataRowAdapter implements CacheDataRow {
         ByteBuffer buf,
         IncompleteCacheObject incomplete
     ) throws IgniteCheckedException {
-        incomplete = coctx.processor().toCacheObject(coctx, buf, incomplete);
+        incomplete = coctx.kernalContext().cacheObjects().toCacheObject(coctx, buf, incomplete);
 
         if (incomplete.isReady()) {
             val = incomplete.object();

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index 9ad084e..8c10e53 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -1728,7 +1728,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements AutoClosea
                         for (KeyCacheObject cacheKey : lockKeys) {
                             K keyVal = (K)
                                 (keepCacheObjects ? cacheKey :
-                                    cacheCtx.cacheObjectContext().unwrapBinaryIfNeeded(cacheKey, !deserializeBinary));
+                                    cacheCtx.cacheObjectContext().unwrapBinaryIfNeeded(cacheKey, !deserializeBinary,
+                                        true));
 
                             if (retMap.containsKey(keyVal))
                                 // We already have a return value.

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlock.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlock.java
index 97db698..a613184 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlock.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlock.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.typedef.T2;
@@ -133,15 +134,15 @@ public class TxDeadlock {
             IgniteTxKey txKey = e.getKey();
 
             try {
-                CacheObjectContext objCtx = ctx.cacheObjectContext(txKey.cacheId());
+                GridCacheContext cctx = ctx.cacheContext(txKey.cacheId());
 
-                Object val = txKey.key().value(objCtx, true);
+                Object val = txKey.key().value(cctx.cacheObjectContext(), true);
 
                 sb.append(e.getValue())
                     .append(" [key=")
                     .append(val)
                     .append(", cache=")
-                    .append(objCtx.cacheName())
+                    .append(cctx.name())
                     .append("]\n");
             }
             catch (Exception ex) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
index 9beb296..ee2d1f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.GridProcessor;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.IncompleteCacheObject;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
@@ -116,7 +117,7 @@ public interface IgniteCacheObjectProcessor extends GridProcessor {
      * @return Value bytes.
      * @throws IgniteCheckedException If failed.
      */
-    public byte[] marshal(CacheObjectContext ctx, Object val) throws IgniteCheckedException;
+    public byte[] marshal(CacheObjectValueContext ctx, Object val) throws IgniteCheckedException;
 
     /**
      * @param ctx Context.
@@ -125,7 +126,8 @@ public interface IgniteCacheObjectProcessor extends GridProcessor {
      * @return Unmarshalled object.
      * @throws IgniteCheckedException If failed.
      */
-    public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr) throws IgniteCheckedException;
+    public Object unmarshal(CacheObjectValueContext ctx, byte[] bytes, ClassLoader clsLdr)
+        throws IgniteCheckedException;
 
     /**
      * @param ccfg Cache configuration.

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/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 a8595fb..de9256c 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
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectByteArrayImpl;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
 import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper;
 import org.apache.ignite.internal.processors.cache.IncompleteCacheObject;
@@ -55,8 +56,8 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
     /** */
     private IgniteBinary noOpBinary = new NoOpBinary();
 
-    /**
-     *
+    /*
+     * Static initializer
      */
     static {
         IMMUTABLE_CLS.add(String.class);
@@ -99,12 +100,12 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
     }
 
     /** {@inheritDoc} */
-    @Override public byte[] marshal(CacheObjectContext ctx, Object val) throws IgniteCheckedException {
+    @Override public byte[] marshal(CacheObjectValueContext ctx, Object val) throws IgniteCheckedException {
         return CU.marshal(ctx.kernalContext().cache().context(), ctx.addDeploymentInfo(), val);
     }
 
     /** {@inheritDoc} */
-    @Override public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr)
+    @Override public Object unmarshal(CacheObjectValueContext ctx, byte[] bytes, ClassLoader clsLdr)
         throws IgniteCheckedException {
         return U.unmarshal(ctx.kernalContext(), bytes, U.resolveClassLoader(clsLdr, ctx.kernalContext().config()));
     }
@@ -166,7 +167,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
                 throw new IllegalArgumentException("Byte arrays cannot be used as cache keys.");
 
             case CacheObject.TYPE_REGULAR:
-                return new KeyCacheObjectImpl(ctx.processor().unmarshal(ctx, bytes, null), bytes, -1);
+                return new KeyCacheObjectImpl(ctx.kernalContext().cacheObjects().unmarshal(ctx, bytes, null), bytes, -1);
         }
 
         throw new IllegalArgumentException("Invalid object type: " + type);
@@ -392,14 +393,18 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
         /** {@inheritDoc} */
         @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
             try {
-                if (!ctx.processor().immutable(val)) {
+                IgniteCacheObjectProcessor proc = ctx.kernalContext().cacheObjects();
+
+                if (!proc.immutable(val)) {
                     if (valBytes == null)
-                        valBytes = ctx.processor().marshal(ctx, val);
+                        valBytes = proc.marshal(ctx, val);
+
+                    boolean p2pEnabled = ctx.kernalContext().config().isPeerClassLoadingEnabled();
 
-                    ClassLoader ldr = ctx.p2pEnabled() ?
+                    ClassLoader ldr = p2pEnabled ?
                         IgniteUtils.detectClassLoader(IgniteUtils.detectClass(this.val)) : U.gridClassLoader();
 
-                    Object val = ctx.processor().unmarshal(ctx, valBytes, ldr);
+                    Object val = proc.unmarshal(ctx, valBytes, ldr);
 
                     KeyCacheObject key = new KeyCacheObjectImpl(val, valBytes, partition());
 
@@ -443,22 +448,26 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
         }
 
         /** {@inheritDoc} */
-        @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+        @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
             return super.value(ctx, false); // Do not need copy since user value is not in cache.
         }
 
         /** {@inheritDoc} */
         @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
             try {
+                IgniteCacheObjectProcessor proc = ctx.kernalContext().cacheObjects();
+
                 if (valBytes == null)
-                    valBytes = ctx.processor().marshal(ctx, val);
+                    valBytes = proc.marshal(ctx, val);
 
                 if (ctx.storeValue()) {
-                    ClassLoader ldr = ctx.p2pEnabled() ?
+                    boolean p2pEnabled = ctx.kernalContext().config().isPeerClassLoadingEnabled();
+
+                    ClassLoader ldr = p2pEnabled ?
                         IgniteUtils.detectClass(this.val).getClassLoader() : val.getClass().getClassLoader();
 
-                    Object val = this.val != null && ctx.processor().immutable(this.val) ? this.val :
-                        ctx.processor().unmarshal(ctx, valBytes, ldr);
+                    Object val = this.val != null && proc.immutable(this.val) ? this.val :
+                        proc.unmarshal(ctx, valBytes, ldr);
 
                     return new CacheObjectImpl(val, valBytes);
                 }
@@ -493,7 +502,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
         }
 
         /** {@inheritDoc} */
-        @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+        @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
             return super.value(ctx, false); // Do not need copy since user value is not in cache.
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/CacheQueryObjectValueContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/CacheQueryObjectValueContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/CacheQueryObjectValueContext.java
new file mode 100644
index 0000000..08f71c8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/CacheQueryObjectValueContext.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.query;
+
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
+
+/**
+ * Cache object value context for queries.
+ */
+public class CacheQueryObjectValueContext implements CacheObjectValueContext {
+    /** Kernal context. */
+    private final GridKernalContext ctx;
+
+    /**
+     * Constructor.
+     *
+     * @param ctx Kernal context.
+     */
+    public CacheQueryObjectValueContext(GridKernalContext ctx) {
+        this.ctx = ctx;
+    }
+
+    /** {@inheritDoc} */
+    @Override public GridKernalContext kernalContext() {
+        return ctx;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean copyOnGet() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean storeValue() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean addDeploymentInfo() {
+        return ctx.config().isPeerClassLoadingEnabled() && !binaryEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean binaryEnabled() {
+        return ctx.config().getMarshaller() instanceof BinaryMarshaller;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryCacheObjectsIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryCacheObjectsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryCacheObjectsIterator.java
index b006c75..b0e1562 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryCacheObjectsIterator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryCacheObjectsIterator.java
@@ -20,7 +20,9 @@ package org.apache.ignite.internal.processors.query;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
+
+import org.apache.ignite.internal.processors.cache.CacheObjectUtils;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.util.typedef.internal.U;
 
 /**
@@ -31,19 +33,20 @@ public class GridQueryCacheObjectsIterator implements Iterator<List<?>>, AutoClo
     private final Iterator<List<?>> iter;
 
     /** */
-    private final GridCacheContext<?,?> cctx;
+    private final CacheObjectValueContext cacheObjValCtx;
 
     /** */
     private final boolean keepBinary;
 
     /**
      * @param iter Iterator.
-     * @param cctx Cache context.
+     * @param cacheObjValCtx Cache object context.
      * @param keepBinary Keep binary.
      */
-    public GridQueryCacheObjectsIterator(Iterator<List<?>> iter, GridCacheContext<?,?> cctx, boolean keepBinary) {
+    public GridQueryCacheObjectsIterator(Iterator<List<?>> iter, CacheObjectValueContext cacheObjValCtx,
+        boolean keepBinary) {
         this.iter = iter;
-        this.cctx = cctx;
+        this.cacheObjValCtx = cacheObjValCtx;
         this.keepBinary = keepBinary;
     }
 
@@ -61,7 +64,8 @@ public class GridQueryCacheObjectsIterator implements Iterator<List<?>>, AutoClo
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public List<?> next() {
-        return (List<?>)cctx.unwrapBinariesIfNeeded((Collection<Object>)iter.next(), keepBinary);
+        return ((List<?>)CacheObjectUtils.unwrapBinariesIfNeeded(
+            cacheObjValCtx, (Collection<Object>)iter.next(), keepBinary));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 76cde17..65151c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -1587,10 +1587,10 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         try {
             CacheObjectContext coctx = cacheObjectContext(cacheName);
 
-            QueryTypeDescriptorImpl desc = typeByValue(coctx, key, val, true);
+            QueryTypeDescriptorImpl desc = typeByValue(cacheName, coctx, key, val, true);
 
             if (prevVal != null) {
-                QueryTypeDescriptorImpl prevValDesc = typeByValue(coctx, key, prevVal, false);
+                QueryTypeDescriptorImpl prevValDesc = typeByValue(cacheName, coctx, key, prevVal, false);
 
                 if (prevValDesc != null && prevValDesc != desc)
                     idx.remove(cacheName, prevValDesc, key, partId, prevVal, prevVer);
@@ -1607,6 +1607,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * @param cacheName Cache name.
      * @param coctx Cache context.
      * @param key Key.
      * @param val Value.
@@ -1615,7 +1616,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @throws IgniteCheckedException If type check failed.
      */
     @SuppressWarnings("ConstantConditions")
-    @Nullable private QueryTypeDescriptorImpl typeByValue(CacheObjectContext coctx,
+    @Nullable private QueryTypeDescriptorImpl typeByValue(String cacheName,
+        CacheObjectContext coctx,
         KeyCacheObject key,
         CacheObject val,
         boolean checkType)
@@ -1629,12 +1631,12 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         if (binaryVal) {
             int typeId = ctx.cacheObjects().typeId(val);
 
-            id = new QueryTypeIdKey(coctx.cacheName(), typeId);
+            id = new QueryTypeIdKey(cacheName, typeId);
         }
         else {
             valCls = val.value(coctx, false).getClass();
 
-            id = new QueryTypeIdKey(coctx.cacheName(), valCls);
+            id = new QueryTypeIdKey(cacheName, valCls);
         }
 
         QueryTypeDescriptorImpl desc = types.get(id);
@@ -2078,7 +2080,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         try {
             CacheObjectContext coctx = cacheObjectContext(cacheName);
 
-            QueryTypeDescriptorImpl desc = typeByValue(coctx, key, val, false);
+            QueryTypeDescriptorImpl desc = typeByValue(cacheName, coctx, key, val, false);
 
             if (desc == null)
                 return;

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridRunningQueryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridRunningQueryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridRunningQueryInfo.java
index d77c8c0..9e11cdf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridRunningQueryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridRunningQueryInfo.java
@@ -32,8 +32,8 @@ public class GridRunningQueryInfo {
     /** Query type. */
     private final GridCacheQueryType qryType;
 
-    /** */
-    private final String cache;
+    /** Schema name. */
+    private final String schemaName;
 
     /** */
     private final long startTime;
@@ -48,17 +48,17 @@ public class GridRunningQueryInfo {
      * @param id Query ID.
      * @param qry Query text.
      * @param qryType Query type.
-     * @param cache Cache where query was executed.
+     * @param schemaName Schema name.
      * @param startTime Query start time.
      * @param cancel Query cancel.
      * @param loc Local query flag.
      */
-    public GridRunningQueryInfo(Long id, String qry, GridCacheQueryType qryType, String cache, long startTime,
+    public GridRunningQueryInfo(Long id, String qry, GridCacheQueryType qryType, String schemaName, long startTime,
         GridQueryCancel cancel, boolean loc) {
         this.id = id;
         this.qry = qry;
         this.qryType = qryType;
-        this.cache = cache;
+        this.schemaName = schemaName;
         this.startTime = startTime;
         this.cancel = cancel;
         this.loc = loc;
@@ -86,10 +86,10 @@ public class GridRunningQueryInfo {
     }
 
     /**
-     * @return Cache where query was executed.
+     * @return Schema name.
      */
-    public String cache() {
-        return cache;
+    public String schemaName() {
+        return schemaName;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTask.java
index 8d00dd6..9d1da00 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTask.java
@@ -90,7 +90,7 @@ public class VisorRunningQueriesCollectorTask extends VisorMultiNodeTask<VisorRu
             long curTime = U.currentTimeMillis();
 
             for (GridRunningQueryInfo qry : queries)
-                res.add(new VisorRunningQuery(qry.id(), qry.query(), qry.queryType(), qry.cache(),
+                res.add(new VisorRunningQuery(qry.id(), qry.query(), qry.queryType(), qry.schemaName(),
                     qry.startTime(), curTime - qry.startTime(),
                     qry.cancelable(), qry.local()));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
index a49e095..e144325 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
@@ -26,6 +26,7 @@ import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.affinity.GridCacheAffinityImpl;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -235,7 +236,7 @@ public class GridAffinityNoCacheSelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+        @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
             A.notNull(ctx, "ctx");
 
             return (T)val;

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
index 5be277a..77b6836 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
@@ -102,7 +102,7 @@ public class IgniteIncompleteCacheObjectSelfTest extends GridCommonAbstractTest
         }
 
         /** {@inheritDoc} */
-        @Nullable @Override public <T> T value(final CacheObjectContext ctx, final boolean cpy) {
+        @Nullable @Override public <T> T value(final CacheObjectValueContext ctx, final boolean cpy) {
             return null;
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
index 5f61bd6..a487218 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.pagemem.PageUtils;
 import org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.database.CacheDataRow;
 import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
@@ -463,7 +464,7 @@ public class FreeListImplSelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+        @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
             return (T)data;
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
index 0474aeb..352fe85 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
@@ -282,7 +282,7 @@ public class DmlStatementsProcessor {
             QueryCursorImpl<List<?>> stepCur = new QueryCursorImpl<>(new Iterable<List<?>>() {
                 @Override public Iterator<List<?>> iterator() {
                     try {
-                        return new GridQueryCacheObjectsIterator(res.iterator(), cctx, cctx.keepBinary());
+                        return new GridQueryCacheObjectsIterator(res.iterator(), idx.valueContext(), cctx.keepBinary());
                     }
                     catch (IgniteCheckedException e) {
                         throw new IgniteException(e);
@@ -372,7 +372,7 @@ public class DmlStatementsProcessor {
             cur = new QueryCursorImpl<>(new Iterable<List<?>>() {
                 @Override public Iterator<List<?>> iterator() {
                     try {
-                        return new GridQueryCacheObjectsIterator(res.iterator(), cctx, cctx.keepBinary());
+                        return new GridQueryCacheObjectsIterator(res.iterator(), idx.valueContext(), cctx.keepBinary());
                     }
                     catch (IgniteCheckedException e) {
                         throw new IgniteException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index c94c215..508c8be 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -63,6 +63,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheAffinityManager;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -78,6 +79,7 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery;
 import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
 import org.apache.ignite.internal.processors.cache.query.QueryTable;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.processors.query.CacheQueryObjectValueContext;
 import org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator;
 import org.apache.ignite.internal.processors.query.GridQueryCancel;
 import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
@@ -303,6 +305,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     /** */
     protected volatile GridKernalContext ctx;
 
+    /** Cache object value context. */
+    protected CacheQueryObjectValueContext valCtx;
+
     /** */
     private DmlStatementsProcessor dmlProc;
 
@@ -339,14 +344,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /**
-     * @param cacheName Cache name.
-     * @return Connection.
-     */
-    public Connection connectionForCache(String cacheName) {
-        return connectionForSchema(schema(cacheName));
-    }
-
-    /**
      * @param schema Schema.
      * @return Connection.
      */
@@ -403,7 +400,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
     /** {@inheritDoc} */
     @Override public PreparedStatement prepareNativeStatement(String cacheName, String sql) throws SQLException {
-        return prepareStatement(connectionForCache(cacheName), sql, true);
+        String schemaName = schema(cacheName);
+
+        return prepareStatement(connectionForSchema(schemaName), sql, true);
     }
 
     /** {@inheritDoc} */
@@ -918,7 +917,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     /** {@inheritDoc} */
     @Override public long streamUpdateQuery(String cacheName, String qry,
         @Nullable Object[] params, IgniteDataStreamer<?, ?> streamer) throws IgniteCheckedException {
-        final Connection conn = connectionForCache(cacheName);
+        String schemaName = schema(cacheName);
+
+        final Connection conn = connectionForSchema(schemaName);
 
         final PreparedStatement stmt;
 
@@ -1117,7 +1118,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             QueryCursorImpl<List<?>> cursor = new QueryCursorImpl<>(new Iterable<List<?>>() {
                 @Override public Iterator<List<?>> iterator() {
                     try {
-                        return new GridQueryCacheObjectsIterator(res.iterator(), cctx, keepBinary);
+                        return new GridQueryCacheObjectsIterator(res.iterator(), valueContext(), keepBinary);
                     }
                     catch (IgniteCheckedException e) {
                         throw new IgniteException(e);
@@ -1231,7 +1232,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /**
-     * @param cctx Cache context.
+     * @param schemaName Schema name.
      * @param qry Query.
      * @param keepCacheObj Flag to keep cache object.
      * @param enforceJoinOrder Enforce join order of tables.
@@ -1239,7 +1240,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
      * @return Iterable result.
      */
     private Iterable<List<?>> runQueryTwoStep(
-        final GridCacheContext<?,?> cctx,
+        final String schemaName,
         final GridCacheTwoStepQuery qry,
         final boolean keepCacheObj,
         final boolean enforceJoinOrder,
@@ -1250,7 +1251,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     ) {
         return new Iterable<List<?>>() {
             @Override public Iterator<List<?>> iterator() {
-                return rdcQryExec.query(cctx, qry, keepCacheObj, enforceJoinOrder, timeoutMillis, cancel, params,
+                return rdcQryExec.query(schemaName, qry, keepCacheObj, enforceJoinOrder, timeoutMillis, cancel, params,
                     parts);
             }
         };
@@ -1484,7 +1485,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             cancel = new GridQueryCancel();
 
         QueryCursorImpl<List<?>> cursor = new QueryCursorImpl<>(
-            runQueryTwoStep(cctx, twoStepQry, keepBinary, enforceJoinOrder, qry.getTimeout(), cancel,
+            runQueryTwoStep(schemaName, twoStepQry, keepBinary, enforceJoinOrder, qry.getTimeout(), cancel,
                 qry.getArgs(), qry.getPartitions()), cancel);
 
         cursor.fieldsMeta(meta);
@@ -1900,12 +1901,14 @@ public class IgniteH2Indexing implements GridQueryIndexing {
      * @throws IgniteCheckedException If failed or {@code -1} if the type is unknown.
      */
     long size(String cacheName, String typeName) throws IgniteCheckedException {
+        String schemaName = schema(cacheName);
+
         H2TableDescriptor tbl = tableDescriptor(typeName, cacheName);
 
         if (tbl == null)
             return -1;
 
-        Connection conn = connectionForCache(cacheName);
+        Connection conn = connectionForSchema(schemaName);
 
         H2Utils.setupConnection(conn, false, false);
 
@@ -1999,6 +2002,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         else {
             this.ctx = ctx;
 
+            valCtx = new CacheQueryObjectValueContext(ctx);
+
             nodeId = ctx.localNodeId();
             marshaller = ctx.config().getMarshaller();
 
@@ -2031,6 +2036,13 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /**
+     * @return Value context.
+     */
+    public CacheObjectValueContext valueContext() {
+        return valCtx;
+    }
+
+    /**
      * @param topic Topic.
      * @param topicOrd Topic ordinal for {@link GridTopic}.
      * @param nodes Nodes.

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
index 48c0cb9..93ebc71 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
@@ -356,7 +356,7 @@ public class GridLuceneIndex implements AutoCloseable {
             if (coctx == null) // For tests.
                 return (Z)JdbcUtils.deserialize(bytes, null);
 
-            return (Z)coctx.processor().unmarshal(coctx, bytes, ldr);
+            return (Z)coctx.kernalContext().cacheObjects().unmarshal(coctx, bytes, ldr);
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index 6fff8de..b7bdde5 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -579,7 +579,9 @@ public class GridMapQueryExecutor {
                 }
             }
 
-            Connection conn = h2.connectionForCache(mainCctx.name());
+            String schemaName = h2.schema(mainCctx.name());
+
+            Connection conn = h2.connectionForSchema(schemaName);
 
             H2Utils.setupConnection(conn, distributedJoinMode != OFF, enforceJoinOrder);
 


[09/24] ignite git commit: IGNITE-1925: Removed flaky test HadoopSkipListSelfTest.testLevel. Distribution itself looks fine. This closes #1678.

Posted by sb...@apache.org.
IGNITE-1925: Removed flaky test HadoopSkipListSelfTest.testLevel. Distribution itself looks fine. This closes #1678.


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

Branch: refs/heads/ignite-5075-cc
Commit: e09b5a2dfb317698ba20f337e920c5e2be38a32d
Parents: b5c7b6f
Author: devozerov <vo...@gridgain.com>
Authored: Fri May 26 15:27:56 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri May 26 15:27:56 2017 +0300

----------------------------------------------------------------------
 .../collections/HadoopSkipListSelfTest.java     | 37 --------------------
 1 file changed, 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e09b5a2d/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopSkipListSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopSkipListSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopSkipListSelfTest.java
index 1138803..21575c5 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopSkipListSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopSkipListSelfTest.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.hadoop.impl.shuffle.collections;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Multimap;
 import java.io.IOException;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Deque;
 import java.util.Iterator;
@@ -45,47 +44,11 @@ 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 java.lang.Math.abs;
-import static java.lang.Math.ceil;
-import static java.lang.Math.max;
-
 /**
  * Skip list tests.
  */
 public class HadoopSkipListSelfTest extends HadoopAbstractMapTest {
     /**
-     *
-     */
-    public void testLevel() {
-        Random rnd = new GridRandom();
-
-        int[] levelsCnts = new int[32];
-
-        int all = 10000;
-
-        for (int i = 0; i < all; i++) {
-            int level = HadoopSkipList.randomLevel(rnd);
-
-            levelsCnts[level]++;
-        }
-
-        X.println("Distribution: " + Arrays.toString(levelsCnts));
-
-        for (int level = 0; level < levelsCnts.length; level++) {
-            int exp = (level + 1) == levelsCnts.length ? 0 : all >>> (level + 1);
-
-            double precission = 0.72 / Math.max(32 >>> level, 1);
-
-            int sigma = max((int)ceil(precission * exp), 5);
-
-            X.println("Level: " + level + " exp: " + exp + " act: " + levelsCnts[level] + " precision: " + precission +
-                " sigma: " + sigma);
-
-            assertTrue(abs(exp - levelsCnts[level]) <= sigma); // Sometimes fails.
-        }
-    }
-
-    /**
      * @throws Exception On error.
      */
     public void testMapSimple() throws Exception {


[07/24] ignite git commit: IGNITE-4575: Improved binary enums support. This closes #1968.

Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs
index 841972d..7ab69e9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs
@@ -65,6 +65,14 @@ namespace Apache.Ignite.Core.Binary
         int EnumValue { get; }
 
         /// <summary>
+        /// Gets the name of the underlying enum value.
+        /// </summary>
+        /// <value>
+        /// The name of the enum value.
+        /// </value>
+        string EnumName { get; }
+
+        /// <summary>
         /// Creates a new <see cref="IBinaryObjectBuilder"/> based on this object.
         /// <para />
         /// This is equivalent to <see cref="IBinary.GetBuilder(IBinaryObject)"/>.

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryType.cs
index bec863f..df6693d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryType.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryType.cs
@@ -61,5 +61,11 @@ namespace Apache.Ignite.Core.Binary
         /// Gets the type identifier.
         /// </summary>
         int TypeId { get; }
+
+        /// <summary>
+        /// Gets the enum values.
+        /// Only valid when <see cref="IsEnum"/> is true.
+        /// </summary>
+        IEnumerable<IBinaryObject> GetEnumValues();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 4f3156c..bcf6c2d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Binary
 {
     using System;
     using System.Collections.Generic;
+    using System.Diagnostics;
     using System.IO;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Common;
@@ -165,7 +166,8 @@ namespace Apache.Ignite.Core.Impl.Binary
         public IBinaryObject BuildEnum(Type type, int value)
         {
             IgniteArgumentCheck.NotNull(type, "type");
-            IgniteArgumentCheck.Ensure(type.IsEnum, "type", "Type should be an Enum.");
+            IgniteArgumentCheck.Ensure(BinaryUtils.IsIgniteEnum(type), "type", 
+                "Type should be an Enum.");
             
             var desc = Marshaller.GetDescriptor(type);
 
@@ -176,15 +178,53 @@ namespace Apache.Ignite.Core.Impl.Binary
             return new BinaryEnum(desc.TypeId, value, Marshaller);
         }
 
+        /** <inheritDoc /> */
+        public IBinaryObject BuildEnum(string typeName, string valueName)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
+            IgniteArgumentCheck.NotNullOrEmpty(valueName, "valueName");
+
+            var desc = Marshaller.GetDescriptor(typeName);
+
+            IgniteArgumentCheck.Ensure(desc.IsEnum, "typeName", "Type should be an Enum.");
+
+            _marsh.PutBinaryType(desc);
+
+            var value = GetEnumValueAsInt(typeName, valueName, desc);
+
+            return new BinaryEnum(desc.TypeId, value, Marshaller);
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryObject BuildEnum(Type type, string valueName)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(valueName, "valueName");
+
+            var desc = Marshaller.GetDescriptor(type);
+
+            IgniteArgumentCheck.Ensure(desc.IsEnum, "typeName", "Type should be an Enum.");
+
+            _marsh.PutBinaryType(desc);
+
+            var value = GetEnumValueAsInt(type.ToString(), valueName, desc);
+
+            return new BinaryEnum(desc.TypeId, value, Marshaller);
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryType RegisterEnum(string typeName, IEnumerable<KeyValuePair<string, int>> values)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
+
+            return Marshaller.Ignite.BinaryProcessor.RegisterEnum(typeName, values);
+        }
+
         /// <summary>
         /// Marshaller.
         /// </summary>
         internal Marshaller Marshaller
         {
-            get
-            {
-                return _marsh;
-            }
+            get { return _marsh; }
         }
 
         /// <summary>
@@ -199,5 +239,22 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             return new BinaryObjectBuilder(this, parent, obj, desc);
         }
+
+        /// <summary>
+        /// Gets the enum value as int.
+        /// </summary>
+        private int GetEnumValueAsInt(string typeName, string valueName, IBinaryTypeDescriptor desc)
+        {
+            var type = Marshaller.GetBinaryType(desc.TypeId);
+
+            var value = type.GetEnumValue(valueName);
+
+            IgniteArgumentCheck.Ensure(value != null, "valueName",
+                string.Format("Enum '{0}' does not have a value {1}", typeName, valueName));
+
+            Debug.Assert(value.HasValue);
+
+            return value.Value;
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs
index 710cf17..2bc4bdf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs
@@ -88,6 +88,12 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /** <inheritdoc /> */
+        public string EnumName
+        {
+            get { return _marsh.GetBinaryType(_typeId).GetEnumName(_enumValue); }
+        }
+
+        /** <inheritdoc /> */
         public IBinaryObjectBuilder ToBuilder()
         {
             throw new NotSupportedException("Builder cannot be created for enum.");
@@ -136,11 +142,8 @@ namespace Apache.Ignite.Core.Impl.Binary
                 return string.Format("BinaryEnum [typeId={0}, enumValue={1}]", _typeId, _enumValue);
             }
 
-            var desc = _marsh.GetDescriptor(true, _typeId);
-            var enumValueName = desc != null && desc.Type != null ? Enum.GetName(desc.Type, _enumValue) : null;
-
             return string.Format("{0} [typeId={1}, enumValue={2}, enumValueName={3}]",
-                meta.TypeName, _typeId, _enumValue, enumValueName);
+                meta.TypeName, _typeId, _enumValue, EnumName);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
index 480e0e6..8c5cee6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
@@ -131,7 +131,18 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             get
             {
-                throw new NotSupportedException("IBinaryObject.Value is only supported for enums. " +
+                throw new NotSupportedException("IBinaryObject.EnumValue is only supported for enums. " +
+                    "Check IBinaryObject.GetBinaryType().IsEnum property before accessing Value.");
+            }
+        }
+
+        /** <inheritdoc /> */
+        [ExcludeFromCodeCoverage]
+        public string EnumName
+        {
+            get
+            {
+                throw new NotSupportedException("IBinaryObject.EnumName is only supported for enums. " +
                     "Check IBinaryObject.GetBinaryType().IsEnum property before accessing Value.");
             }
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
index 72a1d5b..f48bcc0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs
@@ -24,7 +24,7 @@ namespace Apache.Ignite.Core.Impl.Binary
     using Apache.Ignite.Core.Impl.Unmanaged;
 
     /// <summary>
-    /// Binary metadata processor.
+    /// Binary metadata processor, delegates to PlatformBinaryProcessor in Java.
     /// </summary>
     internal class BinaryProcessor : PlatformTarget
     {
@@ -38,7 +38,8 @@ namespace Apache.Ignite.Core.Impl.Binary
             PutMeta = 3,
             GetSchema = 4,
             RegisterType = 5,
-            GetType = 6
+            GetType = 6,
+            RegisterEnum = 7
         }
 
         /// <summary>
@@ -54,9 +55,9 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <summary>
         /// Gets metadata for specified type.
         /// </summary>
-        public IBinaryType GetBinaryType(int typeId)
+        public BinaryType GetBinaryType(int typeId)
         {
-            return DoOutInOp<IBinaryType>((int) Op.GetMeta,
+            return DoOutInOp((int) Op.GetMeta,
                 writer => writer.WriteInt(typeId),
                 stream =>
                 {
@@ -126,8 +127,27 @@ namespace Apache.Ignite.Core.Impl.Binary
                         w.WriteInt(field.Value.FieldId);
                     }
 
+                    // Enum data
                     w.WriteBoolean(meta.IsEnum);
 
+                    if (meta.IsEnum)
+                    {
+                        if (meta.EnumValuesMap != null)
+                        {
+                            w.WriteInt(meta.EnumValuesMap.Count);
+
+                            foreach (var pair in meta.EnumValuesMap)
+                            {
+                                w.WriteString(pair.Key);
+                                w.WriteInt(pair.Value);
+                            }
+                        }
+                        else
+                        {
+                            w.WriteInt(0);
+                        }
+                    }
+
                     // Send schemas
                     var desc = meta.Descriptor;
                     Debug.Assert(desc != null);
@@ -175,6 +195,43 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /// <summary>
+        /// Registers the enum.
+        /// </summary>
+        /// <param name="typeName">Name of the type.</param>
+        /// <param name="values">The values.</param>
+        /// <returns>Resulting binary type.</returns>
+        public BinaryType RegisterEnum(string typeName, IEnumerable<KeyValuePair<string, int>> values)
+        {
+            Debug.Assert(typeName != null);
+
+            return DoOutInOp((int) Op.RegisterEnum, w =>
+            {
+                w.WriteString(typeName);
+
+                if (values == null)
+                {
+                    w.WriteInt(0);
+                }
+                else
+                {
+                    var countPos = w.Stream.Position;
+                    w.WriteInt(0);
+                    var count = 0;
+
+                    foreach (var enumPair in values)
+                    {
+                        w.WriteString(enumPair.Key);
+                        w.WriteInt(enumPair.Value);
+
+                        count++;
+                    }
+
+                    w.Stream.WriteInt(countPos, count);
+                }
+            }, s => s.ReadBool() ? new BinaryType(Marshaller.StartUnmarshal(s)) : null);
+        }
+
+        /// <summary>
         /// Gets the type by id.
         /// </summary>
         /// <param name="id">The identifier.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
index a5c6814..73a0456 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
@@ -401,6 +401,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                     return default(T);
 
                 case BinaryUtils.TypeEnum:
+                case BinaryUtils.TypeBinaryEnum:
                     // Never read enums in binary mode when reading a field (we do not support half-binary objects)
                     return ReadEnum0<T>(this, false);  
 
@@ -411,9 +412,9 @@ namespace Apache.Ignite.Core.Impl.Binary
                     return ReadObject<T>(); 
 
                 default:
-                    throw new BinaryObjectException(
-                        string.Format("Invalid header on enum deserialization. Expected: {0} or {1} but was: {2}",
-                            BinaryUtils.TypeEnum, BinaryUtils.HdrFull, hdr));
+                    throw new BinaryObjectException(string.Format(
+                        "Invalid header on enum deserialization. Expected: {0} or {1} or {2} but was: {3}",
+                            BinaryUtils.TypeEnum, BinaryUtils.TypeBinaryEnum, BinaryUtils.HdrFull, hdr));
             }
         }
 
@@ -571,6 +572,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                     return true;
 
                 case BinaryUtils.TypeEnum:
+                case BinaryUtils.TypeBinaryEnum:
                     res = ReadEnum0<T>(this, _mode != BinaryMode.Deserialize);
 
                     return true;
@@ -994,7 +996,9 @@ namespace Apache.Ignite.Core.Impl.Binary
             var enumValue = reader.ReadInt();
 
             if (!keepBinary)
+            {
                 return BinaryUtils.GetEnumValue<T>(enumValue, enumType, reader.Marshaller);
+            }
 
             return TypeCaster<T>.Cast(new BinaryEnum(enumType, enumValue, reader.Marshaller));
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
index 1dfc3b6..95a0be3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
@@ -255,7 +255,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                 if (elemType == typeof(Guid?))
                     return new BinarySystemWriteHandler<Guid?[]>(WriteGuidArray, true);
                 // Enums.
-                if (IsIntEnum(elemType) || elemType == typeof(BinaryEnum))
+                if (BinaryUtils.IsIgniteEnum(elemType) || elemType == typeof(BinaryEnum))
                     return new BinarySystemWriteHandler<object>(WriteEnumArray, true);
 
                 // Object array.
@@ -266,23 +266,6 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /// <summary>
-        /// Determines whether specified type is an enum which fits into Int32.
-        /// </summary>
-        private static bool IsIntEnum(Type type)
-        {
-            if (!type.IsEnum)
-                return false;
-
-            var underlyingType = Enum.GetUnderlyingType(type);
-
-            return underlyingType == typeof(int) 
-                || underlyingType == typeof(short)
-                || underlyingType == typeof(ushort)
-                || underlyingType == typeof(byte)
-                || underlyingType == typeof(sbyte);
-        }
-
-        /// <summary>
         /// Find write handler for type.
         /// </summary>
         /// <param name="type">Type.</param>
@@ -294,10 +277,10 @@ namespace Apache.Ignite.Core.Impl.Binary
             if (TypeIds.TryGetValue(type, out res))
                 return res;
 
-            if (type.IsEnum)
+            if (BinaryUtils.IsIgniteEnum(type))
                 return BinaryUtils.TypeEnum;
 
-            if (type.IsArray && type.GetElementType().IsEnum)
+            if (type.IsArray && BinaryUtils.IsIgniteEnum(type.GetElementType()))
                 return BinaryUtils.TypeArrayEnum;
 
             return BinaryUtils.TypeObject;
@@ -545,7 +528,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             var binEnum = obj;
 
-            ctx.Stream.WriteByte(BinaryUtils.TypeEnum);
+            ctx.Stream.WriteByte(BinaryUtils.TypeBinaryEnum);
 
             ctx.WriteInt(binEnum.TypeId);
             ctx.WriteInt(binEnum.EnumValue);

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
index a2783ba..2ac617e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
@@ -143,6 +143,9 @@ namespace Apache.Ignite.Core.Impl.Binary
         /** Type: enum array. */
         public const byte TypeArrayEnum = 29;
 
+        /** Type: binary enum. */
+        public const byte TypeBinaryEnum = 38;
+
         /** Type: native job holder. */
         public const byte TypeNativeJobHolder = 77;
 
@@ -1778,6 +1781,22 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /// <summary>
+        /// Determines whether specified type is Ignite-compatible enum (value fits into 4 bytes).
+        /// </summary>
+        public static bool IsIgniteEnum(Type type)
+        {
+            Debug.Assert(type != null);
+
+            if (!type.IsEnum)
+                return false;
+
+            var enumType = Enum.GetUnderlyingType(type);
+
+            return enumType == typeof(int) || enumType == typeof(byte) || enumType == typeof(sbyte) 
+                || enumType == typeof(short) || enumType == typeof(ushort) || enumType == typeof(uint);
+        }
+
+        /// <summary>
         /// Creates and instance from the type name in reader.
         /// </summary>
         private static T CreateInstance<T>(BinaryReader reader)

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
index 56774d4..a5fed48 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
@@ -1468,7 +1468,7 @@ namespace Apache.Ignite.Core.Impl.Binary
             {
                 _metas = new Dictionary<int, BinaryType>(1)
                 {
-                    {desc.TypeId, new BinaryType(desc, fields)}
+                    {desc.TypeId, new BinaryType(desc, _marsh, fields)}
                 };
             }
             else
@@ -1478,7 +1478,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                 if (_metas.TryGetValue(desc.TypeId, out meta))
                     meta.UpdateFields(fields);
                 else
-                    _metas[desc.TypeId] = new BinaryType(desc, fields);
+                    _metas[desc.TypeId] = new BinaryType(desc, _marsh, fields);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 ea2964a..8f12acf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -97,13 +97,13 @@ namespace Apache.Ignite.Core.Impl.Binary
 
             if (typeCfgs != null)
                 foreach (BinaryTypeConfiguration typeCfg in typeCfgs)
-                    AddUserType(cfg, typeCfg, typeResolver);
+                    AddUserType(typeCfg, typeResolver);
 
             var typeNames = _cfg.Types;
 
             if (typeNames != null)
                 foreach (string typeName in typeNames)
-                    AddUserType(cfg, new BinaryTypeConfiguration(typeName), typeResolver);
+                    AddUserType(new BinaryTypeConfiguration(typeName), typeResolver);
         }
 
         /// <summary>
@@ -289,14 +289,16 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// </summary>
         /// <param name="typeId">Type ID.</param>
         /// <returns>Metadata or null.</returns>
-        public IBinaryType GetBinaryType(int typeId)
+        public BinaryType GetBinaryType(int typeId)
         {
             if (Ignite != null)
             {
-                IBinaryType meta = Ignite.BinaryProcessor.GetBinaryType(typeId);
+                var meta = Ignite.BinaryProcessor.GetBinaryType(typeId);
 
                 if (meta != null)
+                {
                     return meta;
+                }
             }
 
             return BinaryType.Empty;
@@ -314,7 +316,7 @@ namespace Apache.Ignite.Core.Impl.Binary
 
             if (Ignite != null)
             {
-                ICollection<BinaryType> metas = new[] {new BinaryType(desc)};
+                ICollection<BinaryType> metas = new[] {new BinaryType(desc, this)};
                 Ignite.BinaryProcessor.PutBinaryTypes(metas);
             }
         }
@@ -337,7 +339,8 @@ namespace Apache.Ignite.Core.Impl.Binary
                         IDictionary<int, BinaryTypeHolder> metas0 =
                             new Dictionary<int, BinaryTypeHolder>(_metas);
 
-                        holder = new BinaryTypeHolder(desc.TypeId, desc.TypeName, desc.AffinityKeyFieldName, desc.IsEnum);
+                        holder = new BinaryTypeHolder(desc.TypeId, desc.TypeName, desc.AffinityKeyFieldName, 
+                            desc.IsEnum, this);
 
                         metas0[desc.TypeId] = holder;
 
@@ -366,16 +369,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             foreach (var meta in newMetas)
             {
-                var mergeInfo = new Dictionary<int, Tuple<string, BinaryField>>(meta.GetFieldsMap().Count);
-
-                foreach (var fieldMeta in meta.GetFieldsMap())
-                {
-                    int fieldId = BinaryUtils.FieldId(meta.TypeId, fieldMeta.Key, null, null);
-
-                    mergeInfo[fieldId] = new Tuple<string, BinaryField>(fieldMeta.Key, fieldMeta.Value);
-                }
-
-                _metas[meta.TypeId].Merge(mergeInfo);
+                _metas[meta.TypeId].Merge(meta);
             }
         }
 
@@ -391,7 +385,9 @@ namespace Apache.Ignite.Core.Impl.Binary
             BinaryFullTypeDescriptor desc;
 
             if (!_typeToDesc.TryGetValue(type, out desc) || !desc.IsRegistered)
+            {
                 desc = RegisterType(type, desc);
+            }
 
             return desc;
         }
@@ -405,10 +401,14 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             BinaryFullTypeDescriptor desc;
 
-            return _typeNameToDesc.TryGetValue(typeName, out desc)
-                ? (IBinaryTypeDescriptor) desc
-                : new BinarySurrogateTypeDescriptor(_cfg,
-                    GetTypeId(typeName, _cfg.IdMapper), typeName);
+            if (_typeNameToDesc.TryGetValue(typeName, out desc))
+            {
+                return desc;
+            }
+
+            var typeId = GetTypeId(typeName, _cfg.IdMapper);
+
+            return GetDescriptor(true, typeId, typeName: typeName);
         }
 
         /// <summary>
@@ -416,18 +416,18 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// </summary>
         /// <param name="userType">User type flag.</param>
         /// <param name="typeId">Type id.</param>
-        /// <param name="requiresType">
-        /// If set to true, resulting descriptor must have Type property populated.
+        /// <param name="requiresType">If set to true, resulting descriptor must have Type property populated.
         /// <para />
         /// When working in binary mode, we don't need Type. And there is no Type at all in some cases.
         /// So we should not attempt to call BinaryProcessor right away.
         /// Only when we really deserialize the value, requiresType is set to true
-        /// and we attempt to resolve the type by all means.
-        /// </param>
+        /// and we attempt to resolve the type by all means.</param>
+        /// <param name="typeName">Known type name.</param>
         /// <returns>
         /// Descriptor.
         /// </returns>
-        public IBinaryTypeDescriptor GetDescriptor(bool userType, int typeId, bool requiresType = false)
+        public IBinaryTypeDescriptor GetDescriptor(bool userType, int typeId, bool requiresType = false, 
+            string typeName = null)
         {
             BinaryFullTypeDescriptor desc;
 
@@ -442,7 +442,7 @@ namespace Apache.Ignite.Core.Impl.Binary
             if (requiresType && _ignite != null)
             {
                 // Check marshaller context for dynamically registered type.
-                var typeName = _ignite.BinaryProcessor.GetTypeName(typeId);
+                typeName = typeName ?? _ignite.BinaryProcessor.GetTypeName(typeId);
 
                 if (typeName != null)
                 {
@@ -460,15 +460,16 @@ namespace Apache.Ignite.Core.Impl.Binary
 
             if (meta != BinaryType.Empty)
             {
-                desc = new BinaryFullTypeDescriptor(null, meta.TypeId, meta.TypeName, true, null, null, null, false,
-                    meta.AffinityKeyFieldName, meta.IsEnum);
-
-                _idToDesc.GetOrAdd(typeKey, _ => desc);
+                var typeCfg = new BinaryTypeConfiguration(meta.TypeName)
+                {
+                    IsEnum = meta.IsEnum,
+                    AffinityKeyFieldName = meta.AffinityKeyFieldName
+                };
 
-                return desc;
+                return AddUserType(typeCfg, new TypeResolver());
             }
 
-            return new BinarySurrogateTypeDescriptor(_cfg, typeId, null);
+            return new BinarySurrogateTypeDescriptor(_cfg, typeId, typeName);
         }
 
         /// <summary>
@@ -507,7 +508,7 @@ namespace Apache.Ignite.Core.Impl.Binary
 
             desc = desc == null
                 ? new BinaryFullTypeDescriptor(type, typeId, typeName, true, _cfg.NameMapper,
-                    _cfg.IdMapper, ser, false, null, type.IsEnum, registered)
+                    _cfg.IdMapper, ser, false, null, BinaryUtils.IsIgniteEnum(type), registered)
                 : new BinaryFullTypeDescriptor(desc, type, ser, registered);
 
             if (RegistrationDisabled)
@@ -540,11 +541,10 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <summary>
         /// Add user type.
         /// </summary>
-        /// <param name="cfg">The binary configuration.</param>
         /// <param name="typeCfg">Type configuration.</param>
         /// <param name="typeResolver">The type resolver.</param>
         /// <exception cref="BinaryObjectException"></exception>
-        private void AddUserType(BinaryConfiguration cfg, BinaryTypeConfiguration typeCfg, TypeResolver typeResolver)
+        private BinaryFullTypeDescriptor AddUserType(BinaryTypeConfiguration typeCfg, TypeResolver typeResolver)
         {
             // Get converter/mapper/serializer.
             IBinaryNameMapper nameMapper = typeCfg.NameMapper ?? _cfg.NameMapper ?? GetDefaultNameMapper();
@@ -560,23 +560,23 @@ namespace Apache.Ignite.Core.Impl.Binary
             {
                 ValidateUserType(type);
 
-                if (typeCfg.IsEnum != type.IsEnum)
+                if (typeCfg.IsEnum != BinaryUtils.IsIgniteEnum(type))
                 {
                     throw new BinaryObjectException(
                         string.Format(
                             "Invalid IsEnum flag in binary type configuration. " +
-                            "Configuration value: IsEnum={0}, actual type: IsEnum={1}",
-                            typeCfg.IsEnum, type.IsEnum));
+                            "Configuration value: IsEnum={0}, actual type: IsEnum={1}, type={2}",
+                            typeCfg.IsEnum, type.IsEnum, type));
                 }
 
                 // Type is found.
                 var typeName = GetTypeName(type, nameMapper);
                 int typeId = GetTypeId(typeName, idMapper);
                 var affKeyFld = typeCfg.AffinityKeyFieldName ?? GetAffinityKeyFieldNameFromAttribute(type);
-                var serializer = GetSerializer(cfg, typeCfg, type, typeId, nameMapper, idMapper, _log);
+                var serializer = GetSerializer(_cfg, typeCfg, type, typeId, nameMapper, idMapper, _log);
 
-                AddType(type, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, serializer,
-                    affKeyFld, type.IsEnum);
+                return AddType(type, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, serializer,
+                    affKeyFld, BinaryUtils.IsIgniteEnum(type));
             }
             else
             {
@@ -585,7 +585,7 @@ namespace Apache.Ignite.Core.Impl.Binary
 
                 int typeId = GetTypeId(typeName, idMapper);
 
-                AddType(null, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, null,
+                return AddType(null, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, null,
                     typeCfg.AffinityKeyFieldName, typeCfg.IsEnum);
             }
         }
@@ -653,7 +653,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <param name="serializer">Serializer.</param>
         /// <param name="affKeyFieldName">Affinity key field name.</param>
         /// <param name="isEnum">Enum flag.</param>
-        private void AddType(Type type, int typeId, string typeName, bool userType,
+        private BinaryFullTypeDescriptor AddType(Type type, int typeId, string typeName, bool userType,
             bool keepDeserialized, IBinaryNameMapper nameMapper, IBinaryIdMapper idMapper,
             IBinarySerializerInternal serializer, string affKeyFieldName, bool isEnum)
         {
@@ -685,6 +685,8 @@ namespace Apache.Ignite.Core.Impl.Binary
                 _typeNameToDesc.GetOrAdd(typeName, x => descriptor);
 
             _idToDesc.GetOrAdd(typeKey, _ => descriptor);
+
+            return descriptor;
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryType.cs
index 837c28a..db54ce7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryType.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryType.cs
@@ -17,9 +17,11 @@
 
 namespace Apache.Ignite.Core.Impl.Binary.Metadata
 {
+    using System;
     using System.Collections.Generic;
     using System.Diagnostics;
     using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Impl.Common;
 
@@ -30,7 +32,7 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
     {
         /** Empty metadata. */
         public static readonly BinaryType Empty =
-            new BinaryType(BinaryUtils.TypeObject, BinaryTypeNames.TypeNameObject, null, null, false);
+            new BinaryType(BinaryUtils.TypeObject, BinaryTypeNames.TypeNameObject, null, null, false, null, null);
 
         /** Empty dictionary. */
         private static readonly IDictionary<string, BinaryField> EmptyDict = new Dictionary<string, BinaryField>();
@@ -44,6 +46,12 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
         /** Fields. */
         private readonly IDictionary<string, BinaryField> _fields;
 
+        /** Enum values. */
+        private readonly IDictionary<string, int> _enumNameToValue;
+
+        /** Enum names. */
+        private readonly IDictionary<int, string> _enumValueToName;
+
         /** Enum flag. */
         private readonly bool _isEnum;
 
@@ -59,6 +67,9 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
         /** Type descriptor. */
         private readonly IBinaryTypeDescriptor _descriptor;
 
+        /** Marshaller. */
+        private readonly Marshaller _marshaller;
+
         /// <summary>
         /// Initializes the <see cref="BinaryType"/> class.
         /// </summary>
@@ -117,7 +128,7 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
         /// Initializes a new instance of the <see cref="BinaryType" /> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public BinaryType(IBinaryRawReader reader)
+        public BinaryType(BinaryReader reader)
         {
             _typeId = reader.ReadInt();
             _typeName = reader.ReadString();
@@ -136,15 +147,34 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
             }
             
             _isEnum = reader.ReadBoolean();
+
+            if (_isEnum)
+            {
+                var count = reader.ReadInt();
+
+                _enumNameToValue = new Dictionary<string, int>(count);
+
+                for (var i = 0; i < count; i++)
+                {
+                    _enumNameToValue[reader.ReadString()] = reader.ReadInt();
+                }
+
+                _enumValueToName = _enumNameToValue.ToDictionary(x => x.Value, x => x.Key);
+            }
+
+            _marshaller = reader.Marshaller;
         }
 
         /// <summary>
-        /// Initializes a new instance of the <see cref="BinaryType"/> class.
+        /// Initializes a new instance of the <see cref="BinaryType" /> class.
         /// </summary>
         /// <param name="desc">Descriptor.</param>
+        /// <param name="marshaller">Marshaller.</param>
         /// <param name="fields">Fields.</param>
-        public BinaryType(IBinaryTypeDescriptor desc, IDictionary<string, BinaryField> fields = null) 
-            : this (desc.TypeId, desc.TypeName, fields, desc.AffinityKeyFieldName, desc.IsEnum)
+        public BinaryType(IBinaryTypeDescriptor desc, Marshaller marshaller, 
+            IDictionary<string, BinaryField> fields = null) 
+            : this (desc.TypeId, desc.TypeName, fields, desc.AffinityKeyFieldName, desc.IsEnum, 
+                  GetEnumValues(desc), marshaller)
         {
             _descriptor = desc;
         }
@@ -157,14 +187,24 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
         /// <param name="fields">Fields.</param>
         /// <param name="affKeyFieldName">Affinity key field name.</param>
         /// <param name="isEnum">Enum flag.</param>
+        /// <param name="enumValues">Enum values.</param>
+        /// <param name="marshaller">Marshaller.</param>
         public BinaryType(int typeId, string typeName, IDictionary<string, BinaryField> fields,
-            string affKeyFieldName, bool isEnum)
+            string affKeyFieldName, bool isEnum, IDictionary<string, int> enumValues, Marshaller marshaller)
         {
             _typeId = typeId;
             _typeName = typeName;
             _affinityKeyFieldName = affKeyFieldName;
             _fields = fields;
             _isEnum = isEnum;
+            _enumNameToValue = enumValues;
+
+            if (_enumNameToValue != null)
+            {
+                _enumValueToName = _enumNameToValue.ToDictionary(x => x.Value, x => x.Key);
+            }
+
+            _marshaller = marshaller;
         }
 
         /// <summary>
@@ -232,6 +272,27 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
             get { return _isEnum; }
         }
 
+        /** <inheritdoc /> */
+        public IEnumerable<IBinaryObject> GetEnumValues()
+        {
+            if (!_isEnum)
+            {
+                throw new NotSupportedException(
+                    "IBinaryObject.Value is only supported for enums. " +
+                    "Check IBinaryObject.GetBinaryType().IsEnum property before accessing Value.");
+            }
+
+            if (_marshaller == null)
+            {
+                yield break;
+            }
+
+            foreach (var pair in _enumValueToName)
+            {
+                yield return new BinaryEnum(_typeId, pair.Key, _marshaller);
+            }
+        }
+
         /// <summary>
         /// Gets the descriptor.
         /// </summary>
@@ -250,6 +311,14 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
         }
 
         /// <summary>
+        /// Gets the enum values map.
+        /// </summary>
+        public IDictionary<string, int> EnumValuesMap
+        {
+            get { return _enumNameToValue; }
+        }
+
+        /// <summary>
         /// Updates the fields.
         /// </summary>
         public void UpdateFields(IDictionary<string, BinaryField> fields)
@@ -262,5 +331,103 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
             foreach (var field in fields)
                 _fields[field.Key] = field.Value;
         }
+
+        /// <summary>
+        /// Gets the enum value by name.
+        /// </summary>
+        public int? GetEnumValue(string valueName)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(valueName, "valueName");
+
+            if (!_isEnum)
+            {
+                throw new NotSupportedException("Can't get enum value for a non-enum type: " + _typeName);
+            }
+
+            int res;
+
+            return _enumNameToValue != null && _enumNameToValue.TryGetValue(valueName, out res) ? res : (int?) null;
+        }
+
+        /// <summary>
+        /// Gets the name of the enum value.
+        /// </summary>
+        public string GetEnumName(int value)
+        {
+            if (!_isEnum)
+            {
+                throw new NotSupportedException("Can't get enum value for a non-enum type: " + _typeName);
+            }
+
+            string res;
+
+            return _enumValueToName != null && _enumValueToName.TryGetValue(value, out res) ? res : null;
+        }
+
+        /// <summary>
+        /// Gets the enum values.
+        /// </summary>
+        private static IDictionary<string, int> GetEnumValues(IBinaryTypeDescriptor desc)
+        {
+            if (desc == null || desc.Type == null || !desc.IsEnum)
+            {
+                return null;
+            }
+
+            var enumType = desc.Type;
+
+            var values = Enum.GetValues(enumType);
+            var res = new Dictionary<string, int>(values.Length);
+
+            var underlyingType = Enum.GetUnderlyingType(enumType);
+
+            foreach (var value in values)
+            {
+                var name = Enum.GetName(enumType, value);
+                Debug.Assert(name != null);
+
+                res[name] = GetEnumValueAsInt(underlyingType, value);
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Gets the enum value as int.
+        /// </summary>
+        private static int GetEnumValueAsInt(Type underlyingType, object value)
+        {
+            if (underlyingType == typeof(int))
+            {
+                return (int) value;
+            }
+
+            if (underlyingType == typeof(byte))
+            {
+                return (byte) value;
+            }
+
+            if (underlyingType == typeof(sbyte))
+            {
+                return (sbyte) value;
+            }
+
+            if (underlyingType == typeof(short))
+            {
+                return (short) value;
+            }
+
+            if (underlyingType == typeof(ushort))
+            {
+                return (ushort) value;
+            }
+
+            if (underlyingType == typeof(uint))
+            {
+                return unchecked((int) (uint) value);
+            }
+
+            throw new BinaryObjectException("Unexpected enum underlying type: " + underlyingType);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHolder.cs
index cdbc687..7e1e970 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHolder.cs
@@ -17,8 +17,8 @@
 
 namespace Apache.Ignite.Core.Impl.Binary.Metadata
 {
-    using System;
     using System.Collections.Generic;
+    using System.Diagnostics;
 
     /// <summary>
     /// Metadata for particular type.
@@ -37,6 +37,9 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
         /** Enum flag. */
         private readonly bool _isEnum;
 
+        /** Marshaller. */
+        private readonly Marshaller _marshaller;
+
         /** Collection of know field IDs. */
         private volatile HashSet<int> _ids;
 
@@ -46,7 +49,6 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
         /** Saved flag (set if type metadata was saved at least once). */
         private volatile bool _saved;
 
-
         /// <summary>
         /// Constructor.
         /// </summary>
@@ -54,12 +56,15 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
         /// <param name="typeName">Type name.</param>
         /// <param name="affKeyFieldName">Affinity key field name.</param>
         /// <param name="isEnum">Enum flag.</param>
-        public BinaryTypeHolder(int typeId, string typeName, string affKeyFieldName, bool isEnum)
+        /// <param name="marshaller">The marshaller.</param>
+        public BinaryTypeHolder(int typeId, string typeName, string affKeyFieldName, bool isEnum,
+            Marshaller marshaller)
         {
             _typeId = typeId;
             _typeName = typeName;
             _affKeyFieldName = affKeyFieldName;
             _isEnum = isEnum;
+            _marshaller = marshaller;
         }
 
         /// <summary>
@@ -100,13 +105,19 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
         /// <summary>
         /// Merge newly sent field metadatas into existing ones.
         /// </summary>
-        /// <param name="newMap">New field metadatas map.</param>
-        public void Merge(IDictionary<int, Tuple<string, BinaryField>> newMap)
+        /// <param name="meta">Binary type to merge.</param>
+        public void Merge(BinaryType meta)
         {
+            Debug.Assert(meta != null);
+            
             _saved = true;
 
-            if (newMap == null || newMap.Count == 0)
+            var fieldsMap = meta.GetFieldsMap();
+
+            if (fieldsMap.Count == 0)
+            {
                 return;
+            }
 
             lock (this)
             {
@@ -118,20 +129,27 @@ namespace Apache.Ignite.Core.Impl.Binary.Metadata
 
                 IDictionary<string, BinaryField> newFields = meta0 != null 
                     ? new Dictionary<string, BinaryField>(meta0.GetFieldsMap()) 
-                    : new Dictionary<string, BinaryField>(newMap.Count);
+                    : new Dictionary<string, BinaryField>(fieldsMap.Count);
 
                 // 2. Add new fields.
-                foreach (var newEntry in newMap)
+                foreach (var fieldMeta in fieldsMap)
                 {
-                    if (!newIds.Contains(newEntry.Key))
-                        newIds.Add(newEntry.Key);
+                    int fieldId = BinaryUtils.FieldId(meta.TypeId, fieldMeta.Key, null, null);
 
-                    if (!newFields.ContainsKey(newEntry.Value.Item1))
-                        newFields[newEntry.Value.Item1] = newEntry.Value.Item2;
+                    if (!newIds.Contains(fieldId))
+                    {
+                        newIds.Add(fieldId);
+                    }
+
+                    if (!newFields.ContainsKey(fieldMeta.Key))
+                    {
+                        newFields[fieldMeta.Key] = fieldMeta.Value;
+                    }
                 }
 
                 // 3. Assign new meta. Order is important here: meta must be assigned before field IDs.
-                _meta = new BinaryType(_typeId, _typeName, newFields, _affKeyFieldName, _isEnum);
+                _meta = new BinaryType(_typeId, _typeName, newFields, _affKeyFieldName, _isEnum, 
+                    meta.EnumValuesMap, _marshaller);
                 _ids = newIds;
             }
         }


[16/24] ignite git commit: IGNITE-5311: Added ability to get CacheObject value without CacheObjectContext. This closes #2019.

Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index a31263f..8d9d953 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -37,7 +37,6 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import javax.cache.CacheException;
@@ -100,7 +99,6 @@ import org.jsr166.ConcurrentHashMap8;
 
 import static java.util.Collections.singletonList;
 import static org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE;
-import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SQL_FIELDS;
 import static org.apache.ignite.internal.processors.cache.query.GridCacheSqlQuery.EMPTY_PARAMS;
 import static org.apache.ignite.internal.processors.query.h2.opt.DistributedJoinMode.OFF;
 import static org.apache.ignite.internal.processors.query.h2.opt.GridH2QueryType.REDUCE;
@@ -132,7 +130,7 @@ public class GridReduceQueryExecutor {
     private final AtomicLong qryIdGen;
 
     /** */
-    private final ConcurrentMap<Long, QueryRun> runs = new ConcurrentHashMap8<>();
+    private final ConcurrentMap<Long, ReduceQueryRun> runs = new ConcurrentHashMap8<>();
 
     /** */
     private volatile List<GridThreadLocalTable> fakeTbls = Collections.emptyList();
@@ -191,8 +189,8 @@ public class GridReduceQueryExecutor {
             @Override public void onEvent(final Event evt) {
                 UUID nodeId = ((DiscoveryEvent)evt).eventNode().id();
 
-                for (QueryRun r : runs.values()) {
-                    for (GridMergeIndex idx : r.idxs) {
+                for (ReduceQueryRun r : runs.values()) {
+                    for (GridMergeIndex idx : r.indexes()) {
                         if (idx.hasSource(nodeId)) {
                             handleNodeLeft(r, nodeId);
 
@@ -208,7 +206,7 @@ public class GridReduceQueryExecutor {
      * @param r Query run.
      * @param nodeId Left node ID.
      */
-    private void handleNodeLeft(QueryRun r, UUID nodeId) {
+    private void handleNodeLeft(ReduceQueryRun r, UUID nodeId) {
         // Will attempt to retry. If reduce query was started it will fail on next page fetching.
         retry(r, h2.readyTopologyVersion(), nodeId);
     }
@@ -248,7 +246,7 @@ public class GridReduceQueryExecutor {
      * @param msg Message.
      */
     private void onFail(ClusterNode node, GridQueryFailResponse msg) {
-        QueryRun r = runs.get(msg.queryRequestId());
+        ReduceQueryRun r = runs.get(msg.queryRequestId());
 
         fail(r, node.id(), msg.error(), msg.failCode());
     }
@@ -258,7 +256,7 @@ public class GridReduceQueryExecutor {
      * @param nodeId Failed node ID.
      * @param msg Error message.
      */
-    private void fail(QueryRun r, UUID nodeId, String msg, byte failCode) {
+    private void fail(ReduceQueryRun r, UUID nodeId, String msg, byte failCode) {
         if (r != null) {
             CacheException e = new CacheException("Failed to execute map query on the node: " + nodeId + ", " + msg);
 
@@ -278,21 +276,21 @@ public class GridReduceQueryExecutor {
         final int qry = msg.query();
         final int seg = msg.segmentId();
 
-        final QueryRun r = runs.get(qryReqId);
+        final ReduceQueryRun r = runs.get(qryReqId);
 
         if (r == null) // Already finished with error or canceled.
             return;
 
-        final int pageSize = r.pageSize;
+        final int pageSize = r.pageSize();
 
-        GridMergeIndex idx = r.idxs.get(msg.query());
+        GridMergeIndex idx = r.indexes().get(msg.query());
 
         GridResultPage page;
 
         try {
             page = new GridResultPage(ctx, node.id(), msg) {
                 @Override public void fetchNextPage() {
-                    Object errState = r.state.get();
+                    Object errState = r.state();
 
                     if (errState != null) {
                         CacheException err0 = errState instanceof CacheException ? (CacheException)errState : null;
@@ -335,7 +333,7 @@ public class GridReduceQueryExecutor {
         if (msg.retry() != null)
             retry(r, msg.retry(), node.id());
         else if (msg.page() == 0) // Do count down on each first page received.
-            r.latch.countDown();
+            r.latch().countDown();
     }
 
     /**
@@ -343,7 +341,7 @@ public class GridReduceQueryExecutor {
      * @param retryVer Retry version.
      * @param nodeId Node ID.
      */
-    private void retry(QueryRun r, AffinityTopologyVersion retryVer, UUID nodeId) {
+    private void retry(ReduceQueryRun r, AffinityTopologyVersion retryVer, UUID nodeId) {
         r.state(retryVer, nodeId);
     }
 
@@ -501,7 +499,7 @@ public class GridReduceQueryExecutor {
     }
 
     /**
-     * @param cctx Cache context.
+     * @param schemaName Schema name.
      * @param qry Query.
      * @param keepPortable Keep portable.
      * @param enforceJoinOrder Enforce join order of tables.
@@ -512,7 +510,7 @@ public class GridReduceQueryExecutor {
      * @return Rows iterator.
      */
     public Iterator<List<?>> query(
-        GridCacheContext<?, ?> cctx,
+        String schemaName,
         GridCacheTwoStepQuery qry,
         boolean keepPortable,
         boolean enforceJoinOrder,
@@ -541,10 +539,8 @@ public class GridReduceQueryExecutor {
 
             final long qryReqId = qryIdGen.incrementAndGet();
 
-            final String cacheName = cctx.name();
-
-            final QueryRun r = new QueryRun(qryReqId, qry.originalSql(), cacheName,
-                h2.connectionForCache(cacheName), qry.mapQueries().size(), qry.pageSize(),
+            final ReduceQueryRun r = new ReduceQueryRun(qryReqId, qry.originalSql(), schemaName,
+                h2.connectionForSchema(schemaName), qry.mapQueries().size(), qry.pageSize(),
                 U.currentTimeMillis(), cancel);
 
             AffinityTopologyVersion topVer = h2.readyTopologyVersion();
@@ -633,7 +629,7 @@ public class GridReduceQueryExecutor {
                     GridMergeTable tbl;
 
                     try {
-                        tbl = createMergeTable(r.conn, mapQry, qry.explain());
+                        tbl = createMergeTable(r.connection(), mapQry, qry.explain());
                     }
                     catch (IgniteCheckedException e) {
                         throw new IgniteException(e);
@@ -641,7 +637,7 @@ public class GridReduceQueryExecutor {
 
                     idx = tbl.getMergeIndex();
 
-                    fakeTable(r.conn, tblIdx++).innerTable(tbl);
+                    fakeTable(r.connection(), tblIdx++).innerTable(tbl);
                 }
                 else
                     idx = GridMergeIndexUnsorted.createDummy(ctx);
@@ -659,13 +655,13 @@ public class GridReduceQueryExecutor {
                 else
                     idx.setSources(nodes, segmentsPerIndex);
 
-                idx.setPageSize(r.pageSize);
+                idx.setPageSize(r.pageSize());
 
-                r.idxs.add(idx);
+                r.indexes().add(idx);
             }
 
-            r.latch = new CountDownLatch(isReplicatedOnly ? 1 :
-                (r.idxs.size() - replicatedQrysCnt) * nodes.size() * segmentsPerIndex + replicatedQrysCnt);
+            r.latch(new CountDownLatch(isReplicatedOnly ? 1 :
+                (r.indexes().size() - replicatedQrysCnt) * nodes.size() * segmentsPerIndex + replicatedQrysCnt));
 
             runs.put(qryReqId, r);
 
@@ -719,7 +715,7 @@ public class GridReduceQueryExecutor {
                         new GridH2QueryRequest()
                                 .requestId(qryReqId)
                                 .topologyVersion(topVer)
-                                .pageSize(r.pageSize)
+                                .pageSize(r.pageSize())
                                 .caches(qry.cacheIds())
                                 .tables(distributedJoins ? qry.tables() : null)
                                 .partitions(convert(partsMap))
@@ -731,7 +727,7 @@ public class GridReduceQueryExecutor {
                         false)) {
                     awaitAllReplies(r, nodes, cancel);
 
-                    Object state = r.state.get();
+                    Object state = r.state();
 
                     if (state != null) {
                         if (state instanceof CacheException) {
@@ -764,7 +760,7 @@ public class GridReduceQueryExecutor {
                         List<List<?>> res = new ArrayList<>();
 
                         // Simple UNION ALL can have multiple indexes.
-                        for (GridMergeIndex idx : r.idxs) {
+                        for (GridMergeIndex idx : r.indexes()) {
                             Cursor cur = idx.findInStream(null, null);
 
                             while (cur.next()) {
@@ -788,21 +784,19 @@ public class GridReduceQueryExecutor {
 
                         UUID locNodeId = ctx.localNodeId();
 
-                        H2Utils.setupConnection(r.conn, false, enforceJoinOrder);
+                        H2Utils.setupConnection(r.connection(), false, enforceJoinOrder);
 
                         GridH2QueryContext.set(new GridH2QueryContext(locNodeId, locNodeId, qryReqId, REDUCE)
-                            .pageSize(r.pageSize).distributedJoinMode(OFF));
+                            .pageSize(r.pageSize()).distributedJoinMode(OFF));
 
                         try {
-                            String schema = h2.schema(cacheName);
-
                             if (qry.explain())
-                                return explainPlan(r.conn, schema, qry, params);
+                                return explainPlan(r.connection(), schemaName, qry, params);
 
                             GridCacheSqlQuery rdc = qry.reduceQuery();
 
-                            ResultSet res = h2.executeSqlQueryWithTimer(schema,
-                                r.conn,
+                            ResultSet res = h2.executeSqlQueryWithTimer(schemaName,
+                                r.connection(),
                                 rdc.query(),
                                 F.asList(rdc.parameters(params)),
                                 false, // The statement will cache some extra thread local objects.
@@ -824,10 +818,10 @@ public class GridReduceQueryExecutor {
                     continue;
                 }
 
-                return new GridQueryCacheObjectsIterator(resIter, cctx, keepPortable);
+                return new GridQueryCacheObjectsIterator(resIter, h2.valueContext(), keepPortable);
             }
             catch (IgniteCheckedException | RuntimeException e) {
-                U.closeQuiet(r.conn);
+                U.closeQuiet(r.connection());
 
                 if (e instanceof CacheException) {
                     if (wasCancelled((CacheException)e))
@@ -898,7 +892,7 @@ public class GridReduceQueryExecutor {
      * @param distributedJoins Distributed join flag.
      */
     private void cancelRemoteQueriesIfNeeded(Collection<ClusterNode> nodes,
-        QueryRun r,
+        ReduceQueryRun r,
         long qryReqId,
         boolean distributedJoins)
     {
@@ -906,7 +900,7 @@ public class GridReduceQueryExecutor {
         if (distributedJoins)
             send(nodes, new GridQueryCancelRequest(qryReqId), null, false);
         else {
-            for (GridMergeIndex idx : r.idxs) {
+            for (GridMergeIndex idx : r.indexes()) {
                 if (!idx.fetchedAll()) {
                     send(nodes, new GridQueryCancelRequest(qryReqId), null, false);
 
@@ -922,9 +916,9 @@ public class GridReduceQueryExecutor {
      * @param cancel Query cancel.
      * @throws IgniteInterruptedCheckedException If interrupted.
      */
-    private void awaitAllReplies(QueryRun r, Collection<ClusterNode> nodes, GridQueryCancel cancel)
+    private void awaitAllReplies(ReduceQueryRun r, Collection<ClusterNode> nodes, GridQueryCancel cancel)
         throws IgniteInterruptedCheckedException, QueryCancelledException {
-        while (!U.await(r.latch, 500, TimeUnit.MILLISECONDS)) {
+        while (!U.await(r.latch(), 500, TimeUnit.MILLISECONDS)) {
 
             cancel.checkCancelled();
 
@@ -932,7 +926,7 @@ public class GridReduceQueryExecutor {
                 if (!ctx.discovery().alive(node)) {
                     handleNodeLeft(r, node.id());
 
-                    assert r.latch.getCount() == 0;
+                    assert r.latch().getCount() == 0;
 
                     return;
                 }
@@ -1420,7 +1414,7 @@ public class GridReduceQueryExecutor {
         CacheException err = new CacheException("Query was cancelled, client node disconnected.",
             new IgniteClientDisconnectedException(reconnectFut, "Client node disconnected."));
 
-        for (Map.Entry<Long, QueryRun> e : runs.entrySet())
+        for (Map.Entry<Long, ReduceQueryRun> e : runs.entrySet())
             e.getValue().disconnected(err);
     }
 
@@ -1435,9 +1429,9 @@ public class GridReduceQueryExecutor {
 
         long curTime = U.currentTimeMillis();
 
-        for (QueryRun run : runs.values()) {
-            if (run.qry.longQuery(curTime, duration))
-                res.add(run.qry);
+        for (ReduceQueryRun run : runs.values()) {
+            if (run.queryInfo().longQuery(curTime, duration))
+                res.add(run.queryInfo());
         }
 
         return res;
@@ -1450,77 +1444,10 @@ public class GridReduceQueryExecutor {
      */
     public void cancelQueries(Collection<Long> queries) {
         for (Long qryId : queries) {
-            QueryRun run = runs.get(qryId);
+            ReduceQueryRun run = runs.get(qryId);
 
             if (run != null)
-                run.qry.cancel();
-        }
-    }
-
-    /**
-     * Query run.
-     */
-    private static class QueryRun {
-        /** */
-        private final GridRunningQueryInfo qry;
-
-        /** */
-        private final List<GridMergeIndex> idxs;
-
-        /** */
-        private CountDownLatch latch;
-
-        /** */
-        private final JdbcConnection conn;
-
-        /** */
-        private final int pageSize;
-
-        /** Can be either CacheException in case of error or AffinityTopologyVersion to retry if needed. */
-        private final AtomicReference<Object> state = new AtomicReference<>();
-
-        /**
-         * @param id Query ID.
-         * @param qry Query text.
-         * @param cache Cache where query was executed.
-         * @param conn Connection.
-         * @param idxsCnt Number of indexes.
-         * @param pageSize Page size.
-         * @param startTime Start time.
-         * @param cancel Query cancel handler.
-         */
-        private QueryRun(Long id, String qry, String cache, Connection conn, int idxsCnt, int pageSize, long startTime, GridQueryCancel cancel) {
-            this.qry = new GridRunningQueryInfo(id, qry, SQL_FIELDS, cache, startTime, cancel, false);
-            this.conn = (JdbcConnection)conn;
-            this.idxs = new ArrayList<>(idxsCnt);
-            this.pageSize = pageSize > 0 ? pageSize : GridCacheTwoStepQuery.DFLT_PAGE_SIZE;
-        }
-
-        /**
-         * @param o Fail state object.
-         * @param nodeId Node ID.
-         */
-        void state(Object o, @Nullable UUID nodeId) {
-            assert o != null;
-            assert o instanceof CacheException || o instanceof AffinityTopologyVersion : o.getClass();
-
-            if (!state.compareAndSet(null, o))
-                return;
-
-            while (latch.getCount() != 0) // We don't need to wait for all nodes to reply.
-                latch.countDown();
-
-            CacheException e = o instanceof CacheException ? (CacheException) o : null;
-
-            for (GridMergeIndex idx : idxs) // Fail all merge indexes.
-                idx.fail(nodeId, e);
-        }
-
-        /**
-         * @param e Error.
-         */
-        void disconnected(CacheException e) {
-            state(e, null);
+                run.queryInfo().cancel();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReduceQueryRun.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReduceQueryRun.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReduceQueryRun.java
new file mode 100644
index 0000000..73bb002
--- /dev/null
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/ReduceQueryRun.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.query.h2.twostep;
+
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery;
+import org.apache.ignite.internal.processors.query.GridQueryCancel;
+import org.apache.ignite.internal.processors.query.GridRunningQueryInfo;
+import org.h2.jdbc.JdbcConnection;
+import org.jetbrains.annotations.Nullable;
+
+import javax.cache.CacheException;
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SQL_FIELDS;
+
+/**
+ * Query run.
+ */
+class ReduceQueryRun {
+    /** */
+    private final GridRunningQueryInfo qry;
+
+    /** */
+    private final List<GridMergeIndex> idxs;
+
+    /** */
+    private CountDownLatch latch;
+
+    /** */
+    private final JdbcConnection conn;
+
+    /** */
+    private final int pageSize;
+
+    /** Can be either CacheException in case of error or AffinityTopologyVersion to retry if needed. */
+    private final AtomicReference<Object> state = new AtomicReference<>();
+
+    /**
+     * Constructor.
+     *
+     * @param id Query ID.
+     * @param qry Query text.
+     * @param schemaName Schema name.
+     * @param conn Connection.
+     * @param idxsCnt Number of indexes.
+     * @param pageSize Page size.
+     * @param startTime Start time.
+     * @param cancel Query cancel handler.
+     */
+    ReduceQueryRun(Long id, String qry, String schemaName, Connection conn, int idxsCnt, int pageSize, long startTime,
+        GridQueryCancel cancel) {
+        this.qry = new GridRunningQueryInfo(id, qry, SQL_FIELDS, schemaName, startTime, cancel, false);
+
+        this.conn = (JdbcConnection)conn;
+
+        this.idxs = new ArrayList<>(idxsCnt);
+
+        this.pageSize = pageSize > 0 ? pageSize : GridCacheTwoStepQuery.DFLT_PAGE_SIZE;
+    }
+
+    /**
+     * @param o Fail state object.
+     * @param nodeId Node ID.
+     */
+    void state(Object o, @Nullable UUID nodeId) {
+        assert o != null;
+        assert o instanceof CacheException || o instanceof AffinityTopologyVersion : o.getClass();
+
+        if (!state.compareAndSet(null, o))
+            return;
+
+        while (latch.getCount() != 0) // We don't need to wait for all nodes to reply.
+            latch.countDown();
+
+        CacheException e = o instanceof CacheException ? (CacheException) o : null;
+
+        for (GridMergeIndex idx : idxs) // Fail all merge indexes.
+            idx.fail(nodeId, e);
+    }
+
+    /**
+     * @param e Error.
+     */
+    void disconnected(CacheException e) {
+        state(e, null);
+    }
+
+    /**
+     * @return Query info.
+     */
+    GridRunningQueryInfo queryInfo() {
+        return qry;
+    }
+
+    /**
+     * @return Page size.
+     */
+    int pageSize() {
+        return pageSize;
+    }
+
+    /**
+     * @return Connection.
+     */
+    JdbcConnection connection() {
+        return conn;
+    }
+
+    /**
+     * @return State.
+     */
+    Object state() {
+        return state.get();
+    }
+
+    /**
+     * @return Indexes.
+     */
+    List<GridMergeIndex> indexes() {
+        return idxs;
+    }
+
+    /**
+     * @return Latch.
+     */
+    CountDownLatch latch() {
+        return latch;
+    }
+
+    /**
+     * @param latch Latch.
+     */
+    void latch(CountDownLatch latch) {
+        this.latch = latch;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index 5ac02a5..1f73dcb 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -41,6 +41,7 @@ import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.binary.BinaryObjectImpl;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.query.GridQueryFieldsResult;
 import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor;
@@ -726,7 +727,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         }
 
         /** {@inheritDoc} */
-        @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+        @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
             return (T)val;
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/aad3b0c5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
index 5939b59..b66a343 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
@@ -870,7 +870,9 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
 
         IgniteH2Indexing idx = U.field(qryProcessor, "idx");
 
-        return (JdbcConnection)idx.connectionForCache(DEFAULT_CACHE_NAME);
+        String schemaName = idx.schema(DEFAULT_CACHE_NAME);
+
+        return (JdbcConnection)idx.connectionForSchema(schemaName);
     }
 
     /**


[19/24] ignite git commit: master - AffinityKeyMapper is deprecated.

Posted by sb...@apache.org.
master - AffinityKeyMapper is deprecated.


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

Branch: refs/heads/ignite-5075-cc
Commit: 52e14ac079a27e42c4b356202148d0d5cddce52a
Parents: fb12f0f
Author: Sergi Vladykin <se...@gmail.com>
Authored: Sun May 28 22:40:20 2017 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Sun May 28 22:40:20 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/cache/affinity/AffinityKeyMapper.java  | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/52e14ac0/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityKeyMapper.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityKeyMapper.java
index 4e2c624..7fd5e08 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityKeyMapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityKeyMapper.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.cache.affinity;
 
 import java.io.Serializable;
+import org.apache.ignite.cache.CacheKeyConfiguration;
 
 /**
  * Affinity mapper which maps cache key to an affinity key. Affinity key is a key which will be
@@ -41,7 +42,9 @@ import java.io.Serializable;
  * {@link AffinityKeyMapped @AffinityKeyMapped} documentation.
  * @see AffinityFunction
  * @see AffinityKeyMapped
+ * @deprecated Use {@link AffinityKeyMapped} or {@link CacheKeyConfiguration#setAffinityKeyFieldName(String)} instead.
  */
+@Deprecated
 public interface AffinityKeyMapper extends Serializable {
     /**
      * Maps passed in key to an alternate key which will be used for node affinity.


[24/24] ignite git commit: cc

Posted by sb...@apache.org.
cc


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

Branch: refs/heads/ignite-5075-cc
Commit: b6d938482e6fb3f3ca1bcefd0f3508ebd4fd3a6c
Parents: edc8eb1
Author: sboikov <sb...@gridgain.com>
Authored: Mon May 29 12:30:05 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon May 29 12:30:05 2017 +0300

----------------------------------------------------------------------
 .../cache/query/continuous/CacheContinuousQueryEntry.java         | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b6d93848/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
index 3f463a1..d1af1b1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java
@@ -209,6 +209,9 @@ public class CacheContinuousQueryEntry implements GridCacheDeployable, Message {
      */
     void markFiltered() {
         flags |= FILTERED_ENTRY;
+        key = null;
+        newVal = null;
+        oldVal = null;
         depInfo = null;
     }
 


[20/24] ignite git commit: IGNITE-5200 Reworked webpack build.

Posted by sb...@apache.org.
IGNITE-5200 Reworked webpack build.


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

Branch: refs/heads/ignite-5075-cc
Commit: 88fd1a63f0fe8b856cbb42c750a9f3b4efced530
Parents: 52e14ac
Author: Andrey Novikov <an...@gridgain.com>
Authored: Mon May 29 10:11:24 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Mon May 29 10:11:24 2017 +0700

----------------------------------------------------------------------
 modules/web-console/frontend/.babelrc           |   9 +-
 modules/web-console/frontend/.gitignore         |   1 -
 modules/web-console/frontend/app/app.js         |  18 +-
 .../components/web-console-header/component.js  |   6 +-
 .../app/modules/agent/AgentManager.service.js   |   2 -
 .../frontend/gulpfile.babel.js/index.js         |  26 ---
 .../frontend/gulpfile.babel.js/paths.js         |  64 ------
 .../frontend/gulpfile.babel.js/tasks/build.js   |  21 --
 .../frontend/gulpfile.babel.js/tasks/bundle.js  |  36 ----
 .../frontend/gulpfile.babel.js/tasks/clean.js   |  32 ---
 .../frontend/gulpfile.babel.js/tasks/copy.js    |  33 ---
 .../gulpfile.babel.js/tasks/ignite-modules.js   |  55 -----
 .../frontend/gulpfile.babel.js/tasks/watch.js   |  30 ---
 .../gulpfile.babel.js/webpack/common.js         | 205 -------------------
 .../webpack/environments/development.js         |  60 ------
 .../webpack/environments/production.js          |  41 ----
 .../webpack/environments/test.js                |  44 ----
 .../frontend/gulpfile.babel.js/webpack/index.js |  36 ----
 .../frontend/ignite_modules/index.js            |   7 +-
 modules/web-console/frontend/package.json       | 104 ++++------
 .../frontend/test/karma.conf.babel.js           |  13 +-
 modules/web-console/frontend/test/karma.conf.js |   2 +-
 .../frontend/webpack/webpack.common.js          | 188 +++++++++++++++++
 .../frontend/webpack/webpack.dev.babel.js       | 100 +++++++++
 .../frontend/webpack/webpack.prod.babel.js      |  64 ++++++
 .../frontend/webpack/webpack.test.js            |  33 +++
 26 files changed, 449 insertions(+), 781 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/.babelrc
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/.babelrc b/modules/web-console/frontend/.babelrc
index a1d48c1..da16f08 100644
--- a/modules/web-console/frontend/.babelrc
+++ b/modules/web-console/frontend/.babelrc
@@ -1,9 +1,4 @@
 {
-  "presets": ["angular"],
-  "plugins": [[
-    "transform-builtin-extend", {
-      "globals": ["Error", "Array"],
-      "approximate": true
-    }
-  ]]
+  "presets": ["es2015", "stage-1"],
+  "plugins": ["add-module-exports"]
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/.gitignore
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/.gitignore b/modules/web-console/frontend/.gitignore
index 27138f6..296d61c 100644
--- a/modules/web-console/frontend/.gitignore
+++ b/modules/web-console/frontend/.gitignore
@@ -4,5 +4,4 @@
 .npmrc
 build/*
 node_modules
-ignite_modules_temp/*
 public/stylesheets/*.css

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/app/app.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js
index e32b1ad..df58f0e 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -103,11 +103,11 @@ import hasPojo from './filters/hasPojo.filter';
 import uiGridSubcategories from './filters/uiGridSubcategories.filter';
 
 // Controllers
-import caches from 'controllers/caches-controller';
-import clusters from 'controllers/clusters-controller';
-import domains from 'controllers/domains-controller';
-import igfs from 'controllers/igfs-controller';
-import profile from 'controllers/profile-controller';
+import caches from '../controllers/caches-controller';
+import clusters from '../controllers/clusters-controller';
+import domains from '../controllers/domains-controller';
+import igfs from '../controllers/igfs-controller';
+import profile from '../controllers/profile-controller';
 import auth from './controllers/auth.controller';
 import resetPassword from './controllers/reset-password.controller';
 
@@ -121,7 +121,7 @@ import webConsoleFooter from './components/web-console-footer';
 import igniteIcon from './components/ignite-icon';
 
 // Inject external modules.
-import 'ignite_modules_temp/index';
+import IgniteModules from 'IgniteModules/index';
 
 import baseTemplate from 'views/base.pug';
 
@@ -175,12 +175,12 @@ angular
     'ignite-console.loading',
     // Ignite configuration module.
     'ignite-console.config',
-    // Ignite modules.
-    'ignite-console.modules',
     // Components
     webConsoleHeader.name,
     webConsoleFooter.name,
-    igniteIcon.name
+    igniteIcon.name,
+    // Ignite modules.
+    IgniteModules.name
 ])
 // Directives.
 .directive(...igniteAutoFocus)

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/app/components/web-console-header/component.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/web-console-header/component.js b/modules/web-console/frontend/app/components/web-console-header/component.js
index 339ec46..364037f 100644
--- a/modules/web-console/frontend/app/components/web-console-header/component.js
+++ b/modules/web-console/frontend/app/components/web-console-header/component.js
@@ -21,7 +21,7 @@ import './style.scss';
 export default {
     template,
     controller: class {
-        static $inject = ['$scope', '$state', 'IgniteBranding'];
+        static $inject = ['$rootScope', '$scope', '$state', 'IgniteBranding'];
 
         static webAgentDownloadVisibleStates = [
             'base.configuration',
@@ -29,8 +29,8 @@ export default {
             'base.settings'
         ];
 
-        constructor($scope, $state, branding) {
-            Object.assign(this, {$scope, $state, branding});
+        constructor($rootScope, $scope, $state, branding) {
+            Object.assign(this, {$rootScope, $scope, $state, branding});
         }
 
         $onInit() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
index c511242..3344ef2 100644
--- a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
+++ b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-import io from 'socket.io-client'; // eslint-disable-line no-unused-vars
-
 import { BehaviorSubject } from 'rxjs/BehaviorSubject';
 
 const maskNull = (val) => _.isNil(val) ? 'null' : val;

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/index.js b/modules/web-console/frontend/gulpfile.babel.js/index.js
deleted file mode 100644
index 95602a1..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/index.js
+++ /dev/null
@@ -1,26 +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.
- */
-
-import gulp from 'gulp';
-import requireDir from 'require-dir';
-
-// Require all tasks in gulpfile.js/tasks, including subfolders.
-requireDir('./tasks', { recurse: true });
-
-// Default no-arg task.
-gulp.task('default', ['build']);
-

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/paths.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/paths.js b/modules/web-console/frontend/gulpfile.babel.js/paths.js
deleted file mode 100644
index 0007c18..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/paths.js
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import path from 'path';
-
-const rootDir = path.resolve('./');
-const srcDir = path.resolve('app');
-const destDir = path.resolve('build');
-
-const igniteModulesDir = process.env.IGNITE_MODULES ? path.join(path.normalize(process.env.IGNITE_MODULES), 'frontend') : './ignite_modules';
-const igniteModulesTemp = path.resolve('ignite_modules_temp');
-
-const appModulePaths = [
-    igniteModulesDir + '/index.js',
-    igniteModulesDir + '/**/main.js',
-    igniteModulesDir + '/**/module.js',
-    igniteModulesDir + '/**/app/modules/*.js',
-    igniteModulesDir + '/**/app/modules/**/*.js',
-    igniteModulesDir + '/**/app/modules/**/*.pug',
-    igniteModulesDir + '/**/*.pug',
-    igniteModulesDir + '/**/*.tpl.pug',
-    igniteModulesDir + '/**/app/**/*.js',
-    igniteModulesDir + '/**/app/**/*.css',
-    igniteModulesDir + '/**/app/**/*.scss',
-    igniteModulesDir + '/**/app/data/*.json'
-];
-
-const resourcePaths = [
-    './public/**/*.svg',
-    './public/**/*.png',
-    './public/*.ico'
-];
-
-const resourceModulePaths = [
-    igniteModulesDir + '/**/images/*.png',
-    igniteModulesDir + '/**/images/*.svg',
-    igniteModulesDir + '/*.ico'
-];
-
-export {
-    rootDir,
-    srcDir,
-    destDir,
-    igniteModulesDir,
-    igniteModulesTemp,
-
-    resourcePaths,
-    resourceModulePaths,
-    appModulePaths
-};

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/tasks/build.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/tasks/build.js b/modules/web-console/frontend/gulpfile.babel.js/tasks/build.js
deleted file mode 100644
index 149b076..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/tasks/build.js
+++ /dev/null
@@ -1,21 +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.
- */
-
-import gulp from 'gulp';
-import sequence from 'gulp-sequence';
-
-gulp.task('build', (cb) => sequence(['clean', 'clean:ignite-modules-temp'], 'ignite:modules', ['copy:resource'], 'bundle', cb));

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/tasks/bundle.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/tasks/bundle.js b/modules/web-console/frontend/gulpfile.babel.js/tasks/bundle.js
deleted file mode 100644
index d42a711..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/tasks/bundle.js
+++ /dev/null
@@ -1,36 +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.
- */
-
-import gulp from 'gulp';
-import webpack from 'webpack';
-import webpackConfig from '../webpack';
-import WebpackDevServer from 'webpack-dev-server';
-
-gulp.task('bundle', (cb) => {
-    const devServerConfig = webpackConfig.devServer;
-
-    delete webpackConfig.devServer;
-
-    if (process.env.NODE_ENV === 'development') {
-        // Important! Call webpack and WebpackDevServer must be inline.
-        new WebpackDevServer(webpack(webpackConfig), devServerConfig)
-            .listen(devServerConfig.port, devServerConfig.host, cb);
-    }
-    else
-        webpack(webpackConfig, cb);
-});
-

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/tasks/clean.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/tasks/clean.js b/modules/web-console/frontend/gulpfile.babel.js/tasks/clean.js
deleted file mode 100644
index c9104b2..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/tasks/clean.js
+++ /dev/null
@@ -1,32 +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.
- */
-
-import gulp from 'gulp';
-import clean from 'gulp-rimraf';
-
-import { destDir, igniteModulesTemp } from '../paths';
-
-// Clean build folder, remove files.
-gulp.task('clean', () =>
-    gulp.src(`${destDir}/*`, {read: false})
-        .pipe(clean({ force: true }))
-);
-
-gulp.task('clean:ignite-modules-temp', () =>
-    gulp.src(igniteModulesTemp, {read: false})
-        .pipe(clean({ force: true }))
-);

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/tasks/copy.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/tasks/copy.js b/modules/web-console/frontend/gulpfile.babel.js/tasks/copy.js
deleted file mode 100644
index 59373a8..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/tasks/copy.js
+++ /dev/null
@@ -1,33 +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.
- */
-
-import gulp from 'gulp';
-import sequence from 'gulp-sequence';
-
-import { destDir, resourcePaths, resourceModulePaths } from '../paths';
-
-gulp.task('copy:resource', (cb) => sequence('copy:resource:app', 'copy:resource:ignite_modules', cb));
-
-gulp.task('copy:resource:app', () =>
-    gulp.src(resourcePaths)
-        .pipe(gulp.dest(destDir))
-);
-
-gulp.task('copy:resource:ignite_modules', () =>
-    gulp.src(resourceModulePaths)
-        .pipe(gulp.dest(`${destDir}/ignite_modules`))
-);

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/tasks/ignite-modules.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/tasks/ignite-modules.js b/modules/web-console/frontend/gulpfile.babel.js/tasks/ignite-modules.js
deleted file mode 100644
index b97de7c..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/tasks/ignite-modules.js
+++ /dev/null
@@ -1,55 +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.
- */
-
-import gulp from 'gulp';
-import inject from 'gulp-inject';
-import clean from 'gulp-rimraf';
-import sequence from 'gulp-sequence';
-import {appModulePaths, igniteModulesTemp} from '../paths';
-
-gulp.task('ignite:modules', (cb) => sequence('ignite:modules:copy', 'ignite:modules:inject', cb));
-
-gulp.task('ignite:modules:copy', () =>
-    gulp.src(appModulePaths)
-        .pipe(gulp.dest(igniteModulesTemp))
-);
-
-gulp.task('ignite:modules:inject', () =>
-    gulp.src(`${igniteModulesTemp}/index.js`)
-        .pipe(inject(gulp.src([`${igniteModulesTemp}/**/main.js`]), {
-            starttag: '/* ignite:modules */',
-            endtag: '/* endignite */',
-            transform: (filePath) => {
-                const igniteModuleName = filePath.replace(/.*ignite_modules_temp\/([^\/]+).*/mgi, '$1');
-
-                // Return file contents as string.
-                return `import './${igniteModuleName}/main';`;
-            }
-        }))
-        .pipe(inject(gulp.src([`${igniteModulesTemp}/**/main.js`]), {
-            starttag: '/* ignite-console:modules */',
-            endtag: '/* endignite */',
-            transform: (filePath, file, i) => {
-                const igniteModuleName = filePath.replace(/.*ignite_modules_temp\/([^\/]+).*/mgi, '$1');
-
-                // Return file contents as string.
-                return (i ? ',' : '') + `'ignite-console.${igniteModuleName}'`;
-            }
-        }))
-        .pipe(clean({force: true}))
-        .pipe(gulp.dest(igniteModulesTemp))
-);

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/tasks/watch.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/tasks/watch.js b/modules/web-console/frontend/gulpfile.babel.js/tasks/watch.js
deleted file mode 100644
index 9a02b88..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/tasks/watch.js
+++ /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.
- */
-
-import gulp from 'gulp';
-import sequence from 'gulp-sequence';
-
-import { resourcePaths, resourceModulePaths, appModulePaths } from '../paths';
-
-gulp.task('watch:ignite-modules', (cb) => sequence('clean:ignite-modules-temp', 'ignite:modules', cb));
-
-// Build + watch task.
-gulp.task('watch', ['build'], () => {
-    gulp.watch(resourcePaths, ['copy:resource:app']);
-    gulp.watch(resourceModulePaths, ['copy:resource:ignite_modules']);
-    gulp.watch(appModulePaths, ['watch:ignite-modules']);
-});

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/webpack/common.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/webpack/common.js b/modules/web-console/frontend/gulpfile.babel.js/webpack/common.js
deleted file mode 100644
index 75b0ef4..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/webpack/common.js
+++ /dev/null
@@ -1,205 +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.
- */
-
-import path from 'path';
-import fs from 'fs';
-import webpack from 'webpack';
-
-import ProgressBarPlugin from 'progress-bar-webpack-plugin';
-import eslintFormatter from 'eslint-friendly-formatter';
-
-import HtmlWebpackPlugin from 'html-webpack-plugin';
-
-import ExtractTextPlugin from 'extract-text-webpack-plugin';
-
-import {srcDir, destDir, rootDir, igniteModulesDir} from '../paths';
-
-const viewsDir = path.resolve('views');
-const imagesDir = path.resolve('public/images');
-const iconsDir = path.resolve('public/images/icons');
-
-const NODE_ENV = process.env.NODE_ENV || 'production';
-const development = NODE_ENV === 'development';
-const node_modules_path = path.resolve('node_modules');
-
-let favicon = 'build/ignite_modules/favicon.ico';
-
-try {
-    fs.accessSync(path.join(igniteModulesDir, 'favicon.ico'), fs.F_OK);
-} catch (ignore) {
-    favicon = 'build/favicon.ico';
-}
-
-export default {
-    cache: true,
-    node: {
-        fs: 'empty'
-    },
-    // Entry points.
-    entry: {
-        polyfill: 'babel-polyfill',
-        vendor: path.join(srcDir, 'vendor.js'),
-        app: path.join(srcDir, 'app.js')
-    },
-
-    // Output system.
-    output: {
-        path: destDir,
-        filename: '[name].js'
-    },
-
-    // Resolves modules.
-    resolve: {
-        extensions: [
-            '.js'
-        ],
-        modules: [
-            srcDir,
-            rootDir,
-            node_modules_path
-        ],
-        // A list of module source folders.
-        alias: {
-            app: srcDir,
-            views: viewsDir,
-            images: imagesDir
-        }
-    },
-
-    // Resolve loader use postfix.
-    resolveLoader: {
-        moduleExtensions: ['-loader']
-    },
-
-    module: {
-        rules: [
-            {
-                test: /\.json$/,
-                loader: 'json'
-            },
-
-            // Exclude tpl.pug files to import in bundle.
-            {
-                test: /^(?:(?!tpl\.pug$).)*\.pug$/, // TODO: check this regexp for correct.
-                loader: `pug-html?basedir=${rootDir}`
-            },
-
-            // Render .tpl.pug files to assets folder.
-            {
-                test: /\.tpl\.pug$/,
-                use: [
-                    'file?exports=false&name=assets/templates/[name].[hash].html',
-                    `pug-html?exports=false&basedir=${rootDir}`
-                ]
-            },
-            {
-                test: /\.js$/,
-                enforce: 'pre',
-                exclude: [node_modules_path],
-                use: [{
-                    loader: 'eslint',
-                    options: {
-                        failOnWarning: false,
-                        failOnError: false,
-                        formatter: eslintFormatter
-                    }
-                }]
-            },
-            {
-                test: /\.js$/,
-                exclude: [node_modules_path],
-                use: [{
-                    loader: 'babel',
-                    options: {
-                        cacheDirectory: true,
-                        plugins: [
-                            'transform-runtime',
-                            'add-module-exports'
-                        ],
-                        presets: ['angular']
-                    }
-                }]
-            },
-            {
-                test: /\.css$/,
-                use: development ? ['style', 'css'] : ExtractTextPlugin.extract({
-                    fallback: 'style',
-                    use: ['css']
-                })
-            },
-            {
-                test: /\.scss$/,
-                use: development ? ['style', 'css', 'sass'] : ExtractTextPlugin.extract({
-                    fallback: 'style-loader',
-                    use: ['css', 'sass']
-                })
-            },
-            {
-                test: /\.(ttf|eot|svg|woff(2)?)(\?v=[\d.]+)?(\?[a-z0-9#-]+)?$/,
-                exclude: [iconsDir],
-                loader: 'file?name=assets/fonts/[name].[ext]'
-            },
-            {
-                test: /.*\.svg$/,
-                include: [iconsDir],
-                use: ['svg-sprite-loader']
-            },
-            {
-                test: /\.(jpe?g|png|gif)$/i,
-                loader: 'file?name=assets/images/[name]_[hash].[ext]'
-            },
-            {
-                test: require.resolve('jquery'),
-                use: [
-                    'expose-loader?$',
-                    'expose-loader?jQuery'
-                ]
-            },
-            {
-                test: require.resolve('nvd3'),
-                use: ['expose-loader?nv']
-            }
-        ]
-    },
-
-    // Load plugins.
-    plugins: [
-        new webpack.LoaderOptionsPlugin({
-            options: {
-                pug: {
-                    basedir: rootDir
-                },
-                target: 'web'
-            }
-        }),
-        new webpack.ProvidePlugin({
-            $: 'jquery',
-            jQuery: 'jquery',
-            _: 'lodash',
-            nv: 'nvd3'
-        }),
-        new webpack.DefinePlugin({NODE_ENV: JSON.stringify(NODE_ENV)}),
-        new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
-        new webpack.optimize.AggressiveMergingPlugin({moveToParents: true}),
-        new HtmlWebpackPlugin({
-            template: './views/index.pug',
-            favicon
-        }),
-        new ExtractTextPlugin({filename: 'assets/css/[name].css', allChunks: true}),
-        new ProgressBarPlugin()
-    ]
-};

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/development.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/development.js b/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/development.js
deleted file mode 100644
index 28ecc13..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/development.js
+++ /dev/null
@@ -1,60 +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.
- */
-
-import {destDir} from '../../paths';
-
-const backendPort = 3000;
-const devServerPort = process.env.PORT || 9000;
-const devServerHost = process.env.HOST || '0.0.0.0';
-
-export default {
-    devtool: 'source-map',
-    watch: true,
-    devServer: {
-        compress: true,
-        historyApiFallback: true,
-        contentBase: destDir,
-        // hot: true,
-        inline: true,
-        proxy: {
-            '/socket.io': {
-                target: `http://localhost:${backendPort}`,
-                ws: true
-            },
-            '/agents': {
-                target: `http://localhost:${backendPort}`,
-                ws: true
-            },
-            '/api/v1/*': {
-                target: `http://localhost:${backendPort}`,
-                pathRewrite: {
-                    '^/api/v1': ''
-                }
-            }
-        },
-        watchOptions: {
-            aggregateTimeout: 1000,
-            poll: 2000
-        },
-        stats: {
-            colors: true,
-            chunks: false
-        },
-        host: devServerHost,
-        port: devServerPort
-    }
-};

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/production.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/production.js b/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/production.js
deleted file mode 100644
index cbbe9ca..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/production.js
+++ /dev/null
@@ -1,41 +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.
- */
-
-
-import webpack from 'webpack';
-
-import {destDir} from '../../paths';
-
-const plugins = [
-    new webpack.optimize.UglifyJsPlugin({
-        path: destDir,
-        minimize: true,
-        warnings: false,
-        sourceMap: false,
-        mangle: true
-    })
-];
-
-export default {
-    bail: true, // Cancel build on error.
-    devtool: 'cheap-source-map',
-    output: {
-        publicPath: '/',
-        filename: '[name].[chunkhash].js'
-    },
-    plugins
-};

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/test.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/test.js b/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/test.js
deleted file mode 100644
index 0cb9b77..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/test.js
+++ /dev/null
@@ -1,44 +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.
- */
-
-import webpack from 'webpack';
-
-const NODE_ENV = process.env.NODE_ENV || 'production';
-
-export default {
-    cache: true,
-    node: {
-        fs: 'empty'
-    },
-
-    // Entry points.
-    entry: null,
-
-    // Output system.
-    output: null,
-
-    // Load plugins.
-    plugins: [
-        new webpack.ProvidePlugin({
-            $: 'jquery',
-            jQuery: 'jquery',
-            _: 'lodash',
-            nv: 'nvd3'
-        }),
-        new webpack.DefinePlugin({NODE_ENV: JSON.stringify(NODE_ENV)})
-    ]
-};

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/gulpfile.babel.js/webpack/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/webpack/index.js b/modules/web-console/frontend/gulpfile.babel.js/webpack/index.js
deleted file mode 100644
index 3caf06c..0000000
--- a/modules/web-console/frontend/gulpfile.babel.js/webpack/index.js
+++ /dev/null
@@ -1,36 +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.
- */
-
-import _ from 'lodash';
-import commonConfig from './common';
-import devConfig from './environments/development';
-import prodConfig from './environments/production';
-
-// TODO check test config
-import testConfig from './environments/test';
-
-const env = process.env.NODE_ENV || 'production';
-
-// Config by environments.
-const configs = {
-    production: prodConfig,
-    development: devConfig,
-    test: testConfig
-};
-
-// Load config file by environment
-export default _.merge(commonConfig, configs[env]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/ignite_modules/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/ignite_modules/index.js b/modules/web-console/frontend/ignite_modules/index.js
index c38d2d4..21ccf6a 100644
--- a/modules/web-console/frontend/ignite_modules/index.js
+++ b/modules/web-console/frontend/ignite_modules/index.js
@@ -17,11 +17,6 @@
 
 import angular from 'angular';
 
-/* ignite:modules */
-/* endignite */
-
-angular
+export default angular
 .module('ignite-console.modules', [
-    /* ignite-console:modules */
-    /* endignite */
 ]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/package.json
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/package.json b/modules/web-console/frontend/package.json
index 31a34f2..b20089a 100644
--- a/modules/web-console/frontend/package.json
+++ b/modules/web-console/frontend/package.json
@@ -4,10 +4,11 @@
   "description": "Interactive Web console for configuration, executing SQL queries and monitoring of Apache Ignite Cluster",
   "private": true,
   "scripts": {
-    "dev": "cross-env NODE_ENV=development gulp watch",
-    "build": "cross-env NODE_ENV=production gulp build",
-    "test": "cross-env NODE_ENV=test karma start ./test/karma.conf.js",
-    "eslint": "eslint --format node_modules/eslint-friendly-formatter gulpfile.babel.js/ app/ controllers/ ignite_modules/ ignite_modules_temp/ -- --eff-by-issue"
+    "start": "webpack-dev-server --config ./webpack/webpack.dev.babel.js",
+    "dev": "npm start",
+    "build": "webpack --config ./webpack/webpack.prod.babel.js",
+    "test": "karma start ./test/karma.conf.js",
+    "eslint": "eslint --format node_modules/eslint-friendly-formatter gulpfile.babel.js/ app/ controllers/ ignite_modules/ -- --eff-by-issue"
   },
   "author": "",
   "contributors": [
@@ -20,8 +21,8 @@
   "keywords": "grid",
   "homepage": "https://ignite.apache.org/",
   "engines": {
-    "npm": "^3.x.x",
-    "node": "^4.x.x"
+    "npm": "3.x.x",
+    "node": "4.x.x"
   },
   "os": [
     "darwin",
@@ -48,55 +49,57 @@
     "angular-tree-control": "0.2.28",
     "angular-ui-grid": "4.0.4",
     "angular-ui-router": "0.4.2",
+    "babel-core": "6.24.1",
+    "babel-eslint": "7.2.3",
+    "babel-loader": "7.0.0",
+    "babel-plugin-add-module-exports": "0.2.1",
+    "babel-plugin-transform-runtime": "6.23.0",
+    "babel-polyfill": "6.23.0",
+    "babel-preset-es2015": "6.24.1",
+    "babel-preset-stage-1": "6.24.1",
+    "babel-runtime": "6.23.0",
     "bootstrap-sass": "3.3.7",
     "brace": "0.10.0",
-    "es6-promise": "4.1.0",
+    "copy-webpack-plugin": "4.0.1",
+    "css-loader": "0.28.3",
+    "eslint": "3.19.0",
+    "eslint-friendly-formatter": "3.0.0",
+    "eslint-loader": "1.7.1",
+    "expose-loader": "0.7.3",
+    "extract-text-webpack-plugin": "2.1.0",
+    "file-loader": "0.11.1",
     "file-saver": "1.3.3",
     "font-awesome": "4.7.0",
-    "glob": "7.1.1",
+    "glob": "7.1.2",
+    "html-loader": "0.4.5",
+    "html-webpack-plugin": "2.28.0",
     "jquery": "3.2.1",
+    "json-loader": "0.5.4",
     "jszip": "3.1.3",
     "lodash": "4.17.4",
+    "node-sass": "4.5.3",
     "nvd3": "1.8.4",
+    "progress-bar-webpack-plugin": "1.9.3",
+    "pug-html-loader": "1.1.0",
+    "pug-loader": "2.3.0",
     "raleway-webfont": "3.0.1",
+    "resolve-url-loader": "2.0.2",
     "roboto-font": "0.1.0",
     "rxjs": "5.4.0",
+    "sass-loader": "6.0.5",
     "socket.io-client": "1.7.3",
-    "ui-router-metatags": "1.0.3"
+    "style-loader": "0.18.1",
+    "svg-sprite-loader": "^3.0.2",
+    "ui-router-metatags": "1.0.3",
+    "webpack": "2.6.1",
+    "webpack-dev-server": "2.4.5",
+    "webpack-merge": "4.1.0",
+    "worker-loader": "0.8.0"
   },
   "devDependencies": {
-    "assets-webpack-plugin": "3.5.1",
-    "autoprefixer": "6.7.7",
-    "babel-core": "6.24.1",
-    "babel-eslint": "7.2.1",
-    "babel-loader": "6.4.1",
-    "babel-plugin-add-module-exports": "0.2.1",
-    "babel-plugin-transform-builtin-extend": "1.1.2",
-    "babel-plugin-transform-runtime": "6.23.0",
-    "babel-polyfill": "6.23.0",
-    "babel-preset-angular": "6.0.15",
-    "babel-preset-es2015": "6.24.1",
-    "babel-runtime": "6.23.0",
     "chai": "3.5.0",
-    "cross-env": "4.0.0",
-    "css-loader": "0.28.0",
-    "eslint": "3.19.0",
-    "eslint-friendly-formatter": "2.0.7",
-    "eslint-loader": "1.7.1",
-    "expose-loader": "0.7.3",
-    "extract-text-webpack-plugin": "2.1.0",
-    "file-loader": "0.11.1",
-    "gulp": "3.9.1",
-    "gulp-eslint": "3.0.1",
-    "gulp-inject": "4.2.0",
-    "gulp-rimraf": "0.2.1",
-    "gulp-sequence": "0.4.6",
-    "gulp-util": "3.0.8",
-    "html-loader": "0.4.5",
-    "html-webpack-plugin": "2.28.0",
-    "jasmine-core": "2.5.2",
-    "json-loader": "0.5.4",
-    "karma": "1.6.0",
+    "jasmine-core": "2.6.2",
+    "karma": "1.7.0",
     "karma-babel-preprocessor": "6.0.1",
     "karma-jasmine": "1.1.0",
     "karma-mocha": "1.3.0",
@@ -104,25 +107,8 @@
     "karma-phantomjs-launcher": "1.0.4",
     "karma-teamcity-reporter": "1.0.0",
     "karma-webpack": "2.0.3",
-    "mocha": "3.2.0",
+    "mocha": "3.4.2",
     "mocha-teamcity-reporter": "1.1.1",
-    "ngtemplate-loader": "1.3.1",
-    "node-sass": "4.5.2",
-    "phantomjs-prebuilt": "2.1.14",
-    "postcss-loader": "1.3.3",
-    "progress-bar-webpack-plugin": "1.9.3",
-    "pug-html-loader": "1.1.0",
-    "pug-loader": "2.3.0",
-    "require-dir": "0.3.1",
-    "resolve-url-loader": "2.0.2",
-    "sass-loader": "6.0.3",
-    "style-loader": "0.16.1",
-    "svg-sprite-loader": "2.1.0",
-    "url": "0.11.0",
-    "url-loader": "0.5.8",
-    "webpack": "2.3.3",
-    "webpack-dev-server": "2.4.2",
-    "webpack-stream": "3.2.0",
-    "worker-loader": "0.8.0"
+    "phantomjs-prebuilt": "2.1.14"
   }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/test/karma.conf.babel.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/test/karma.conf.babel.js b/modules/web-console/frontend/test/karma.conf.babel.js
index aa6b11c..1651c30 100644
--- a/modules/web-console/frontend/test/karma.conf.babel.js
+++ b/modules/web-console/frontend/test/karma.conf.babel.js
@@ -15,21 +15,14 @@
  * limitations under the License.
  */
 
-import webpack from '../gulpfile.babel.js/webpack';
 import path from 'path';
 
-const basePath = path.resolve('./');
-
-// Webpack chunk plugin has to be removed during test runs due to incompatibility issues,
-// otherwise tests would not run at all.
-// https://github.com/webpack-contrib/karma-webpack/issues/24#issuecomment-257613167
-const chunkPluginIndex = webpack.plugins.findIndex((plugin) => plugin.chunkNames);
-webpack.plugins.splice(chunkPluginIndex, 1);
+import testCfg from '../webpack/webpack.test';
 
 export default (config) => {
     config.set({
         // Base path that will be used to resolve all patterns (eg. files, exclude).
-        basePath,
+        basePath: path.resolve('./'),
 
         // Frameworks to use available frameworks: https://npmjs.org/browse/keyword/karma-adapter
         frameworks: ['mocha'],
@@ -53,7 +46,7 @@ export default (config) => {
             'test/**/*.js': ['webpack']
         },
 
-        webpack,
+        webpack: testCfg,
 
         webpackMiddleware: {
             noInfo: true

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/test/karma.conf.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/test/karma.conf.js b/modules/web-console/frontend/test/karma.conf.js
index a8b1b11..e354482 100644
--- a/modules/web-console/frontend/test/karma.conf.js
+++ b/modules/web-console/frontend/test/karma.conf.js
@@ -16,4 +16,4 @@
  */
 
 require('babel-core/register');
-module.exports = require('./karma.conf.babel.js').default;
+module.exports = require('./karma.conf.babel.js');

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/webpack/webpack.common.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/webpack/webpack.common.js b/modules/web-console/frontend/webpack/webpack.common.js
new file mode 100644
index 0000000..ca7f672
--- /dev/null
+++ b/modules/web-console/frontend/webpack/webpack.common.js
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import path from 'path';
+import webpack from 'webpack';
+
+import transformRuntime from 'babel-plugin-transform-runtime';
+import presetEs2015 from 'babel-preset-es2015';
+import presetStage1 from 'babel-preset-stage-1';
+
+import CopyWebpackPlugin from 'copy-webpack-plugin';
+import ExtractTextPlugin from 'extract-text-webpack-plugin';
+import HtmlWebpackPlugin from 'html-webpack-plugin';
+import ProgressBarPlugin from 'progress-bar-webpack-plugin';
+
+const basedir = path.resolve('./');
+const contentBase = path.resolve('public');
+const node_modules = path.resolve('node_modules');
+
+const app = path.resolve('app');
+const IgniteModules = process.env.IGNITE_MODULES ? path.join(process.env.IGNITE_MODULES, 'frontend') : path.resolve('ignite_modules');
+
+export default {
+    cache: true,
+    node: {
+        fs: 'empty'
+    },
+    // Entry points.
+    entry: {
+        polyfill: 'babel-polyfill',
+        vendor: path.join(app, 'vendor.js'),
+        app: path.join(app, 'app.js')
+    },
+
+    // Output system.
+    output: {
+        path: path.resolve('build'),
+        filename: '[name].[chunkhash].js',
+        publicPath: '/',
+        sourceMapFilename: '[name].[chunkhash].map'
+    },
+
+    // Resolves modules.
+    resolve: {
+        modules: [node_modules],
+        // A list of module source folders.
+        alias: {
+            app,
+            images: path.resolve('public/images'),
+            views: path.resolve('views'),
+            IgniteModules
+        }
+    },
+
+    // Resolve loader use postfix.
+    resolveLoader: {
+        modules: [
+            node_modules
+        ],
+        moduleExtensions: ['-loader']
+    },
+
+    module: {
+        rules: [
+            {
+                test: /\.json$/,
+                loader: 'json'
+            },
+            // Exclude tpl.pug files to import in bundle.
+            {
+                test: /^(?:(?!tpl\.pug$).)*\.pug$/, // TODO: check this regexp for correct.
+                loader: `pug-html?basedir=${basedir}`
+            },
+
+            // Render .tpl.pug files to assets folder.
+            {
+                test: /\.tpl\.pug$/,
+                use: [
+                    'file?exports=false&name=assets/templates/[name].[hash].html',
+                    `pug-html?exports=false&basedir=${basedir}`
+                ]
+            },
+            {
+                test: /\.js$/,
+                enforce: 'pre',
+                exclude: [node_modules],
+                use: [{
+                    loader: 'eslint',
+                    options: {
+                        failOnWarning: false,
+                        failOnError: false,
+                        formatter: 'eslint-friendly-formatter'
+                    }
+                }]
+            },
+            {
+                test: /\.js$/,
+                exclude: [node_modules],
+                use: [{
+                    loader: 'babel-loader',
+                    options: {
+                        cacheDirectory: true,
+                        plugins: [
+                            transformRuntime
+                        ],
+                        presets: [
+                            presetEs2015,
+                            presetStage1
+                        ]
+                    }
+                }]
+            },
+            {
+                test: /\.(ttf|eot|svg|woff(2)?)(\?v=[\d.]+)?(\?[a-z0-9#-]+)?$/,
+                exclude: [contentBase],
+                loader: 'file?name=assets/fonts/[name].[ext]'
+            },
+            {
+                test: /.*\.svg$/,
+                include: [contentBase],
+                use: ['svg-sprite-loader']
+            },
+            {
+                test: /\.(jpe?g|png|gif)$/i,
+                loader: 'file?name=assets/images/[name]_[hash].[ext]'
+            },
+            {
+                test: require.resolve('jquery'),
+                use: [
+                    'expose-loader?$',
+                    'expose-loader?jQuery'
+                ]
+            },
+            {
+                test: require.resolve('nvd3'),
+                use: ['expose-loader?nv']
+            }
+        ]
+    },
+
+    // Load plugins.
+    plugins: [
+        new webpack.LoaderOptionsPlugin({
+            options: {
+                pug: {
+                    basedir
+                },
+                target: 'web'
+            }
+        }),
+        new webpack.ProvidePlugin({
+            $: 'jquery',
+            jQuery: 'jquery',
+            _: 'lodash',
+            nv: 'nvd3',
+            io: 'socket.io-client'
+        }),
+        new webpack.optimize.AggressiveMergingPlugin({moveToParents: true}),
+        new HtmlWebpackPlugin({
+            template: './views/index.pug'
+        }),
+        new ExtractTextPlugin({filename: 'assets/css/[name].css', allChunks: true}),
+        new CopyWebpackPlugin([
+            { context: 'public', from: '**/*.png' },
+            { context: 'public', from: '**/*.svg' },
+            { context: 'public', from: '**/*.ico' },
+            // Ignite modules.
+            { context: IgniteModules, from: '**/*.png', force: true },
+            { context: IgniteModules, from: '**/*.svg', force: true },
+            { context: IgniteModules, from: '**/*.ico', force: true }
+        ]),
+        new ProgressBarPlugin()
+    ]
+};

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/webpack/webpack.dev.babel.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/webpack/webpack.dev.babel.js b/modules/web-console/frontend/webpack/webpack.dev.babel.js
new file mode 100644
index 0000000..dc5cd41
--- /dev/null
+++ b/modules/web-console/frontend/webpack/webpack.dev.babel.js
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import webpack from 'webpack';
+import merge from 'webpack-merge';
+
+import path from 'path';
+
+import commonCfg from './webpack.common';
+
+import ExtractTextPlugin from 'extract-text-webpack-plugin';
+
+const backendPort = process.env.BACKEND_PORT || 3000;
+const devServerPort = process.env.PORT || 9000;
+const devServerHost = process.env.HOST || '0.0.0.0';
+
+export default merge(commonCfg, {
+    devtool: 'source-map',
+    watch: true,
+    module: {
+        rules: [
+            {
+                test: /\.css$/,
+                use: ['style', 'css']
+            },
+            {
+                test: /\.scss$/,
+                // Version without extract plugin fails on some machines. https://github.com/sass/node-sass/issues/1895
+                use: ExtractTextPlugin.extract({
+                    fallback: 'style-loader',
+                    use: [
+                        {
+                            loader: 'css',
+                            options: {
+                                sourceMap: true
+                            }
+                        },
+                        {
+                            loader: 'sass',
+                            options: {
+                                sourceMap: true
+                            }
+                        }
+                    ]
+                })
+            }
+        ]
+    },
+    devServer: {
+        compress: true,
+        historyApiFallback: true,
+        disableHostCheck: true,
+        contentBase: path.resolve('build'),
+        // hot: true,
+        inline: true,
+        proxy: {
+            '/socket.io': {
+                target: `http://localhost:${backendPort}`,
+                ws: true
+            },
+            '/agents': {
+                target: `http://localhost:${backendPort}`,
+                ws: true
+            },
+            '/api/v1/*': {
+                target: `http://localhost:${backendPort}`,
+                pathRewrite: {
+                    '^/api/v1': ''
+                }
+            }
+        },
+        watchOptions: {
+            aggregateTimeout: 1000,
+            poll: 2000
+        },
+        stats: {
+            colors: true,
+            chunks: false
+        },
+        host: devServerHost,
+        port: devServerPort
+    },
+    plugins: [
+        new webpack.optimize.CommonsChunkPlugin({name: 'vendor'})
+    ]
+});

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/webpack/webpack.prod.babel.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/webpack/webpack.prod.babel.js b/modules/web-console/frontend/webpack/webpack.prod.babel.js
new file mode 100644
index 0000000..f18a3ba
--- /dev/null
+++ b/modules/web-console/frontend/webpack/webpack.prod.babel.js
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import webpack from 'webpack';
+import merge from 'webpack-merge';
+
+import ExtractTextPlugin from 'extract-text-webpack-plugin';
+
+import commonCfg from './webpack.common';
+
+export default merge(commonCfg, {
+    bail: true, // Cancel build on error.
+    devtool: 'cheap-source-map',
+    module: {
+        rules: [
+            {
+                test: /\.css$/,
+                use: ExtractTextPlugin.extract({
+                    fallback: 'style',
+                    use: ['css']
+                })
+            },
+            {
+                test: /\.scss$/,
+                use: ExtractTextPlugin.extract({
+                    fallback: 'style-loader',
+                    use: ['css', 'sass']
+                })
+            }
+        ]
+    },
+    plugins: [
+        new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
+        new webpack.LoaderOptionsPlugin({
+            minimize: true,
+            debug: false
+        }),
+        new webpack.optimize.UglifyJsPlugin({
+            beautify: false,
+            mangle: {
+                screw_ie8: true,
+                keep_fnames: true
+            },
+            compress: {
+                screw_ie8: true
+            },
+            comments: false
+        })
+    ]
+});

http://git-wip-us.apache.org/repos/asf/ignite/blob/88fd1a63/modules/web-console/frontend/webpack/webpack.test.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/webpack/webpack.test.js b/modules/web-console/frontend/webpack/webpack.test.js
new file mode 100644
index 0000000..36d2650
--- /dev/null
+++ b/modules/web-console/frontend/webpack/webpack.test.js
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import merge from 'webpack-merge';
+
+import commonCfg from './webpack.common';
+
+export default merge(commonCfg, {
+    cache: true,
+    node: {
+        fs: 'empty'
+    },
+
+    // Entry points.
+    entry: null,
+
+    // Output system.
+    output: null
+});


[04/24] ignite git commit: .NET: Remove unused imports

Posted by sb...@apache.org.
.NET: Remove unused imports


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

Branch: refs/heads/ignite-5075-cc
Commit: 22d108c076988dc2291fc78776e0473e0c457d91
Parents: d911848
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri May 26 12:07:46 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri May 26 12:07:46 2017 +0300

----------------------------------------------------------------------
 modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/22d108c0/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs
index 81b91d2..ae04a0b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs
@@ -20,7 +20,6 @@ namespace Apache.Ignite.Linq.Impl
     using System.Collections.Generic;
     using System.Diagnostics;
     using System.Linq;
-    using System.Linq.Expressions;
 
     /// <summary>
     /// Query data holder.


[12/24] ignite git commit: IGNITE-5304: SQL: decoupled DDL from schema. This closes #2017.

Posted by sb...@apache.org.
IGNITE-5304: SQL: decoupled DDL from schema. This closes #2017.


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

Branch: refs/heads/ignite-5075-cc
Commit: 40851c7ff44c0ec97d9cca53923c8db0a38f78cd
Parents: 427ca69
Author: devozerov <vo...@gridgain.com>
Authored: Sat May 27 15:07:01 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Sat May 27 15:07:01 2017 +0300

----------------------------------------------------------------------
 .../processors/query/GridQueryIndexing.java     |  9 ++-
 .../processors/query/GridQueryProcessor.java    | 32 +++++-----
 .../processors/query/QueryIndexKey.java         | 28 +++------
 .../processors/query/h2/IgniteH2Indexing.java   | 32 +++++-----
 .../query/h2/ddl/DdlStatementsProcessor.java    | 66 ++++++++++++--------
 .../DynamicIndexAbstractConcurrentSelfTest.java |  8 +--
 6 files changed, 83 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/40851c7f/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
index 77c581c..9d66c0a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
@@ -142,27 +142,26 @@ public interface GridQueryIndexing {
     /**
      * Create new index locally.
      *
-     * @param cacheName Cache name.
+     * @param schemaName Schema name.
      * @param tblName Table name.
      * @param idxDesc Index descriptor.
      * @param ifNotExists Ignore operation if index exists (instead of throwing an error).
      * @param cacheVisitor Cache visitor
      * @throws IgniteCheckedException if failed.
      */
-    public void dynamicIndexCreate(String cacheName, String tblName, QueryIndexDescriptorImpl idxDesc,
+    public void dynamicIndexCreate(String schemaName, String tblName, QueryIndexDescriptorImpl idxDesc,
         boolean ifNotExists, SchemaIndexCacheVisitor cacheVisitor) throws IgniteCheckedException;
 
     /**
      * Remove index from the cache.
      *
-     * @param cacheName cache name.
+     * @param schemaName Schema name.
      * @param idxName Index name.
      * @param ifExists Ignore operation if index does not exist (instead of throwing an error).
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
-    public void dynamicIndexDrop(String cacheName, String idxName, boolean ifExists)
-        throws IgniteCheckedException;
+    public void dynamicIndexDrop(String schemaName, String idxName, boolean ifExists) throws IgniteCheckedException;
 
     /**
      * Registers cache.

http://git-wip-us.apache.org/repos/asf/ignite/blob/40851c7f/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 3233fd2..76cde17 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -933,7 +933,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             if (err == null) {
                 String idxName = op0.index().getName();
 
-                QueryIndexKey idxKey = new QueryIndexKey(cacheName, idxName);
+                QueryIndexKey idxKey = new QueryIndexKey(op.schemaName(), idxName);
 
                 if (idxs.get(idxKey) != null) {
                     if (op0.ifNotExists())
@@ -948,7 +948,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
             String idxName = op0.indexName();
 
-            QueryIndexDescriptorImpl oldIdx = idxs.get(new QueryIndexKey(cacheName, idxName));
+            QueryIndexDescriptorImpl oldIdx = idxs.get(new QueryIndexKey(op.schemaName(), idxName));
 
             if (oldIdx == null) {
                 if (op0.ifExists())
@@ -1159,7 +1159,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             if (log.isDebugEnabled())
                 log.debug("Local operation finished successfully [opId=" + op.id() + ']');
 
-            String cacheName = op.cacheName();
+            String schemaName = op.schemaName();
 
             try {
                 if (op instanceof SchemaIndexCreateOperation) {
@@ -1169,7 +1169,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
                     QueryIndexDescriptorImpl idxDesc = type.index(op0.indexName());
 
-                    QueryIndexKey idxKey = new QueryIndexKey(cacheName, op0.indexName());
+                    QueryIndexKey idxKey = new QueryIndexKey(schemaName, op0.indexName());
 
                     idxs.put(idxKey, idxDesc);
                 }
@@ -1180,7 +1180,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
 
                     QueryUtils.processDynamicIndexChange(op0.indexName(), null, type);
 
-                    QueryIndexKey idxKey = new QueryIndexKey(cacheName, op0.indexName());
+                    QueryIndexKey idxKey = new QueryIndexKey(schemaName, op0.indexName());
 
                     idxs.remove(idxKey);
                 }
@@ -1251,12 +1251,12 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 SchemaIndexCacheVisitor visitor =
                     new SchemaIndexCacheVisitorImpl(this, cache.context(), cacheName, op0.tableName(), cancelTok);
 
-                idx.dynamicIndexCreate(cacheName, op0.tableName(), idxDesc, op0.ifNotExists(), visitor);
+                idx.dynamicIndexCreate(op0.schemaName(), op0.tableName(), idxDesc, op0.ifNotExists(), visitor);
             }
             else if (op instanceof SchemaIndexDropOperation) {
                 SchemaIndexDropOperation op0 = (SchemaIndexDropOperation) op;
 
-                idx.dynamicIndexDrop(cacheName, op0.indexName(), op0.ifExists());
+                idx.dynamicIndexDrop(op0.schemaName(), op0.indexName(), op0.ifExists());
             }
             else
                 throw new SchemaOperationException("Unsupported operation: " + op);
@@ -1293,10 +1293,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         CacheConfiguration<?, ?> newCfg = new CacheConfiguration<>(templateCfg);
 
         newCfg.setName(entity.getTableName());
-
         newCfg.setQueryEntities(Collections.singleton(entity));
 
-        // We want to preserve user specified names as they are
+        // Preserve user specified names as they are.
         newCfg.setSqlEscapeAll(true);
 
         boolean res = ctx.grid().getOrCreateCache0(newCfg).get2();
@@ -1308,14 +1307,14 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     /**
      * Drop table by destroying its cache if it's an 1:1 per cache table.
      *
-     * @param schemaName Schema name.
+     * @param cacheName Cache name.
      * @param tblName Table name.
      * @param ifExists Quietly ignore this command if table does not exist.
      * @throws SchemaOperationException if {@code ifExists} is {@code false} and cache was not found.
      */
     @SuppressWarnings("unchecked")
-    public void dynamicTableDrop(String schemaName, String tblName, boolean ifExists) throws SchemaOperationException {
-        boolean res = ctx.grid().destroyCache0(tblName);
+    public void dynamicTableDrop(String cacheName, String tblName, boolean ifExists) throws SchemaOperationException {
+        boolean res = ctx.grid().destroyCache0(cacheName);
 
         if (!res && !ifExists)
             throw new SchemaOperationException(SchemaOperationException.CODE_TABLE_NOT_FOUND, tblName);
@@ -1352,13 +1351,14 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                         types.put(altTypeId, desc);
 
                     for (QueryIndexDescriptorImpl idx : desc.indexes0()) {
-                        QueryIndexKey idxKey = new QueryIndexKey(cacheName, idx.name());
+                        QueryIndexKey idxKey = new QueryIndexKey(schemaName, idx.name());
 
                         QueryIndexDescriptorImpl oldIdx = idxs.putIfAbsent(idxKey, idx);
 
                         if (oldIdx != null) {
                             throw new IgniteException("Duplicate index name [cache=" + cacheName +
-                                ", idxName=" + idx.name() + ", existingTable=" + oldIdx.typeDescriptor().tableName() +
+                                ", schemaName=" + schemaName + ", idxName=" + idx.name() +
+                                ", existingTable=" + oldIdx.typeDescriptor().tableName() +
                                 ", table=" + desc.tableName() + ']');
                         }
                     }
@@ -1409,9 +1409,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             while (idxIt.hasNext()) {
                 Map.Entry<QueryIndexKey, QueryIndexDescriptorImpl> idxEntry = idxIt.next();
 
-                QueryIndexKey idxKey = idxEntry.getKey();
-
-                if (F.eq(cacheName, idxKey.cacheName()))
+                if (F.eq(cacheName, idxEntry.getValue().typeDescriptor().cacheName()))
                     idxIt.remove();
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/40851c7f/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryIndexKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryIndexKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryIndexKey.java
index 7fdb805..fea6594 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryIndexKey.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryIndexKey.java
@@ -29,8 +29,8 @@ public class QueryIndexKey implements Serializable {
     /** */
     private static final long serialVersionUID = 0L;
 
-    /** Cache name. */
-    private final String cacheName;
+    /** Schema name. */
+    private final String schemaName;
 
     /** Name. */
     private final String name;
@@ -38,31 +38,17 @@ public class QueryIndexKey implements Serializable {
     /**
      * Constructor.
      *
-     * @param cacheName Cache name.
+     * @param schemaName Schema name.
      * @param name Name.
      */
-    public QueryIndexKey(String cacheName, String name) {
-        this.cacheName = cacheName;
+    public QueryIndexKey(String schemaName, String name) {
+        this.schemaName = schemaName;
         this.name = name;
     }
 
-    /**
-     * @return Cache name.
-     */
-    public String cacheName() {
-        return cacheName;
-    }
-
-    /**
-     * @return Name.
-     */
-    public String name() {
-        return name;
-    }
-
     /** {@inheritDoc} */
     @Override public int hashCode() {
-        return 31 * (cacheName != null ? cacheName.hashCode() : 0) + (name != null ? name.hashCode() : 0);
+        return 31 * (schemaName != null ? schemaName.hashCode() : 0) + (name != null ? name.hashCode() : 0);
     }
 
     /** {@inheritDoc} */
@@ -75,7 +61,7 @@ public class QueryIndexKey implements Serializable {
 
         QueryIndexKey other = (QueryIndexKey)o;
 
-        return F.eq(name, other.name) && F.eq(cacheName, other.cacheName);
+        return F.eq(name, other.name) && F.eq(schemaName, other.schemaName);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/40851c7f/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 71d3ad5..0291b0a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -670,12 +670,12 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     /**
      * Add initial user index.
      *
-     * @param cacheName Cache name.
+     * @param schemaName Schema name.
      * @param desc Table descriptor.
      * @param h2Idx User index.
      * @throws IgniteCheckedException If failed.
      */
-    private void addInitialUserIndex(String cacheName, H2TableDescriptor desc, GridH2IndexBase h2Idx)
+    private void addInitialUserIndex(String schemaName, H2TableDescriptor desc, GridH2IndexBase h2Idx)
         throws IgniteCheckedException {
         GridH2Table h2Tbl = desc.table();
 
@@ -684,7 +684,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         try {
             String sql = H2Utils.indexCreateSql(desc.fullTableName(), h2Idx, false);
 
-            executeSql(cacheName, sql);
+            executeSql(schemaName, sql);
         }
         catch (Exception e) {
             // Rollback and re-throw.
@@ -695,12 +695,10 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /** {@inheritDoc} */
-    @Override public void dynamicIndexCreate(final String cacheName, final String tblName,
+    @Override public void dynamicIndexCreate(final String schemaName, final String tblName,
         final QueryIndexDescriptorImpl idxDesc, boolean ifNotExists, SchemaIndexCacheVisitor cacheVisitor)
         throws IgniteCheckedException {
         // Locate table.
-        String schemaName = schema(cacheName);
-
         H2Schema schema = schemas.get(schemaName);
 
         H2TableDescriptor desc = (schema != null ? schema.tableByName(tblName) : null);
@@ -740,7 +738,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             // prepared statements are re-built.
             String sql = H2Utils.indexCreateSql(desc.fullTableName(), h2Idx, ifNotExists);
 
-            executeSql(cacheName, sql);
+            executeSql(schemaName, sql);
         }
         catch (Exception e) {
             // Rollback and re-throw.
@@ -752,25 +750,23 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
     /** {@inheritDoc} */
     @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
-    @Override public void dynamicIndexDrop(final String cacheName, String idxName, boolean ifExists)
+    @Override public void dynamicIndexDrop(final String schemaName, String idxName, boolean ifExists)
         throws IgniteCheckedException{
-        String schemaName = schema(cacheName);
-
         String sql = H2Utils.indexDropSql(schemaName, idxName, ifExists);
 
-        executeSql(cacheName, sql);
+        executeSql(schemaName, sql);
     }
 
     /**
      * Execute DDL command.
      *
-     * @param cacheName Cache name.
+     * @param schemaName Schema name.
      * @param sql SQL.
      * @throws IgniteCheckedException If failed.
      */
-    private void executeSql(String cacheName, String sql) throws IgniteCheckedException {
+    private void executeSql(String schemaName, String sql) throws IgniteCheckedException {
         try {
-            Connection conn = connectionForCache(cacheName);
+            Connection conn = connectionForSchema(schemaName);
 
             try (PreparedStatement stmt = prepareStatement(conn, sql, false)) {
                 stmt.execute();
@@ -1609,7 +1605,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         try {
             Connection conn = connectionForThread(schemaName);
 
-            createTable(cacheName, schema, tbl, conn);
+            createTable(schemaName, schema, tbl, conn);
 
             schema.add(tbl);
         }
@@ -1653,14 +1649,14 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     /**
      * Create db table by using given table descriptor.
      *
-     * @param cacheName Cache name.
+     * @param schemaName Schema name.
      * @param schema Schema.
      * @param tbl Table descriptor.
      * @param conn Connection.
      * @throws SQLException If failed to create db table.
      * @throws IgniteCheckedException If failed.
      */
-    private void createTable(String cacheName, H2Schema schema, H2TableDescriptor tbl, Connection conn)
+    private void createTable(String schemaName, H2Schema schema, H2TableDescriptor tbl, Connection conn)
         throws SQLException, IgniteCheckedException {
         assert schema != null;
         assert tbl != null;
@@ -1693,7 +1689,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         GridH2Table h2Tbl = H2TableEngine.createTable(conn, sql.toString(), rowDesc, rowFactory, tbl);
 
         for (GridH2IndexBase usrIdx : tbl.createUserIndexes())
-            addInitialUserIndex(cacheName, tbl, usrIdx);
+            addInitialUserIndex(schemaName, tbl, usrIdx);
 
         if (dataTables.putIfAbsent(h2Tbl.identifier(), h2Tbl) != null)
             throw new IllegalStateException("Table already exists: " + h2Tbl.identifierString());

http://git-wip-us.apache.org/repos/asf/ignite/blob/40851c7f/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
index 7157d1f..e324ed9 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
@@ -88,34 +88,34 @@ public class DdlStatementsProcessor {
         throws IgniteCheckedException {
         assert stmt instanceof JdbcPreparedStatement;
 
-        IgniteInternalFuture fut;
+        IgniteInternalFuture fut = null;
 
         try {
-            GridSqlStatement gridStmt = new GridSqlQueryParser(false).parse(GridSqlQueryParser.prepared(stmt));
+            GridSqlStatement stmt0 = new GridSqlQueryParser(false).parse(GridSqlQueryParser.prepared(stmt));
 
-            if (gridStmt instanceof GridSqlCreateIndex) {
-                GridSqlCreateIndex createIdx = (GridSqlCreateIndex)gridStmt;
+            if (stmt0 instanceof GridSqlCreateIndex) {
+                GridSqlCreateIndex cmd = (GridSqlCreateIndex)stmt0;
 
                 QueryIndex newIdx = new QueryIndex();
 
-                newIdx.setName(createIdx.index().getName());
+                newIdx.setName(cmd.index().getName());
 
-                newIdx.setIndexType(createIdx.index().getIndexType());
+                newIdx.setIndexType(cmd.index().getIndexType());
 
                 LinkedHashMap<String, Boolean> flds = new LinkedHashMap<>();
 
-                GridH2Table tbl = idx.dataTable(createIdx.schemaName(), createIdx.tableName());
+                GridH2Table tbl = idx.dataTable(cmd.schemaName(), cmd.tableName());
 
                 if (tbl == null)
                     throw new SchemaOperationException(SchemaOperationException.CODE_TABLE_NOT_FOUND,
-                        createIdx.tableName());
+                        cmd.tableName());
 
                 assert tbl.rowDescriptor() != null;
 
                 // Let's replace H2's table and property names by those operated by GridQueryProcessor.
                 GridQueryTypeDescriptor typeDesc = tbl.rowDescriptor().type();
 
-                for (Map.Entry<String, Boolean> e : createIdx.index().getFields().entrySet()) {
+                for (Map.Entry<String, Boolean> e : cmd.index().getFields().entrySet()) {
                     GridQueryProperty prop = typeDesc.property(e.getKey());
 
                     if (prop == null)
@@ -126,39 +126,51 @@ public class DdlStatementsProcessor {
 
                 newIdx.setFields(flds);
 
-                fut = ctx.query().dynamicIndexCreate(tbl.cacheName(), createIdx.schemaName(), typeDesc.tableName(),
-                    newIdx, createIdx.ifNotExists());
+                fut = ctx.query().dynamicIndexCreate(tbl.cacheName(), cmd.schemaName(), typeDesc.tableName(),
+                    newIdx, cmd.ifNotExists());
             }
-            else if (gridStmt instanceof GridSqlDropIndex) {
-                GridSqlDropIndex dropIdx = (GridSqlDropIndex)gridStmt;
+            else if (stmt0 instanceof GridSqlDropIndex) {
+                GridSqlDropIndex cmd = (GridSqlDropIndex)stmt0;
 
-                GridH2Table tbl = idx.dataTableForIndex(dropIdx.schemaName(), dropIdx.indexName());
+                GridH2Table tbl = idx.dataTableForIndex(cmd.schemaName(), cmd.indexName());
 
                 if (tbl != null)
-                    fut = ctx.query().dynamicIndexDrop(tbl.cacheName(), dropIdx.schemaName(), dropIdx.indexName(),
-                        dropIdx.ifExists());
+                    fut = ctx.query().dynamicIndexDrop(tbl.cacheName(), cmd.schemaName(), cmd.indexName(),
+                        cmd.ifExists());
                 else {
-                    if (dropIdx.ifExists())
+                    if (cmd.ifExists())
                         fut = new GridFinishedFuture();
                     else
                         throw new SchemaOperationException(SchemaOperationException.CODE_INDEX_NOT_FOUND,
-                            dropIdx.indexName());
+                            cmd.indexName());
                 }
             }
-            else if (gridStmt instanceof GridSqlCreateTable) {
-                GridSqlCreateTable createTbl = (GridSqlCreateTable)gridStmt;
+            else if (stmt0 instanceof GridSqlCreateTable) {
+                GridSqlCreateTable cmd = (GridSqlCreateTable)stmt0;
 
-                ctx.query().dynamicTableCreate(createTbl.schemaName(), toQueryEntity(createTbl),
-                    createTbl.templateCacheName(), createTbl.ifNotExists());
+                GridH2Table tbl = idx.dataTable(cmd.schemaName(), cmd.tableName());
 
-                fut = null;
+                if (tbl != null) {
+                    if (!cmd.ifNotExists())
+                        throw new SchemaOperationException(SchemaOperationException.CODE_TABLE_EXISTS,
+                            cmd.tableName());
+                }
+                else
+                    ctx.query().dynamicTableCreate(cmd.schemaName(), toQueryEntity(cmd), cmd.templateCacheName(),
+                        cmd.ifNotExists());
             }
-            else if (gridStmt instanceof GridSqlDropTable) {
-                GridSqlDropTable dropTbl = (GridSqlDropTable)gridStmt;
+            else if (stmt0 instanceof GridSqlDropTable) {
+                GridSqlDropTable cmd = (GridSqlDropTable)stmt0;
 
-                ctx.query().dynamicTableDrop(dropTbl.schemaName(), dropTbl.tableName(), dropTbl.ifExists());
+                GridH2Table tbl = idx.dataTable(cmd.schemaName(), cmd.tableName());
 
-                fut = null;
+                if (tbl == null) {
+                    if (!cmd.ifExists())
+                        throw new SchemaOperationException(SchemaOperationException.CODE_TABLE_NOT_FOUND,
+                            cmd.tableName());
+                }
+                else
+                    ctx.query().dynamicTableDrop(tbl.cacheName(), cmd.tableName(), cmd.ifExists());
             }
             else
                 throw new IgniteSQLException("Unsupported DDL operation: " + sql,

http://git-wip-us.apache.org/repos/asf/ignite/blob/40851c7f/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
index 5d93c12..9936a81 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
@@ -1043,20 +1043,20 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
      */
     private static class BlockingIndexing extends IgniteH2Indexing {
         /** {@inheritDoc} */
-        @Override public void dynamicIndexCreate(@NotNull String cacheName, String tblName,
+        @Override public void dynamicIndexCreate(@NotNull String schemaName, String tblName,
             QueryIndexDescriptorImpl idxDesc, boolean ifNotExists, SchemaIndexCacheVisitor cacheVisitor)
             throws IgniteCheckedException {
             awaitIndexing(ctx.localNodeId());
 
-            super.dynamicIndexCreate(cacheName, tblName, idxDesc, ifNotExists, cacheVisitor);
+            super.dynamicIndexCreate(schemaName, tblName, idxDesc, ifNotExists, cacheVisitor);
         }
 
         /** {@inheritDoc} */
-        @Override public void dynamicIndexDrop(@NotNull String cacheName, String idxName, boolean ifExists)
+        @Override public void dynamicIndexDrop(@NotNull String schemaName, String idxName, boolean ifExists)
             throws IgniteCheckedException{
             awaitIndexing(ctx.localNodeId());
 
-            super.dynamicIndexDrop(cacheName, idxName, ifExists);
+            super.dynamicIndexDrop(schemaName, idxName, ifExists);
         }
     }
 }


[15/24] ignite git commit: IGNITE-5312: Changed cache name to schema name in H2TwoStepCachedQueryKey. This closes #2020.

Posted by sb...@apache.org.
IGNITE-5312: Changed cache name to schema name in H2TwoStepCachedQueryKey. This closes #2020.


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

Branch: refs/heads/ignite-5075-cc
Commit: 858e5b729b621efef057c1919273463ebdcb133d
Parents: e59d389
Author: devozerov <vo...@gridgain.com>
Authored: Sat May 27 21:07:54 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Sat May 27 21:07:54 2017 +0300

----------------------------------------------------------------------
 .../query/h2/H2TwoStepCachedQuery.java           | 18 ++++++++++++++++--
 .../query/h2/H2TwoStepCachedQueryKey.java        | 19 ++++++-------------
 .../processors/query/h2/IgniteH2Indexing.java    | 19 +++++++++++--------
 3 files changed, 33 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/858e5b72/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQuery.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQuery.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQuery.java
index dd1b44c..6139869 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQuery.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQuery.java
@@ -28,10 +28,10 @@ import java.util.List;
  */
 public class H2TwoStepCachedQuery {
     /** */
-    final List<GridQueryFieldMetadata> meta;
+    private final List<GridQueryFieldMetadata> meta;
 
     /** */
-    final GridCacheTwoStepQuery twoStepQry;
+    private final GridCacheTwoStepQuery twoStepQry;
 
     /**
      * @param meta Fields metadata.
@@ -42,6 +42,20 @@ public class H2TwoStepCachedQuery {
         this.twoStepQry = twoStepQry;
     }
 
+    /**
+     * @return Fields metadata.
+     */
+    public List<GridQueryFieldMetadata> meta() {
+        return meta;
+    }
+
+    /**
+     * @return Query.
+     */
+    public GridCacheTwoStepQuery query() {
+        return twoStepQry;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(H2TwoStepCachedQuery.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/858e5b72/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQueryKey.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQueryKey.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQueryKey.java
index 1452a83..cc14abd 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQueryKey.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TwoStepCachedQueryKey.java
@@ -22,7 +22,7 @@ package org.apache.ignite.internal.processors.query.h2;
  */
 public class H2TwoStepCachedQueryKey {
     /** */
-    private final String cacheName;
+    private final String schemaName;
 
     /** */
     private final String sql;
@@ -40,20 +40,20 @@ public class H2TwoStepCachedQueryKey {
     private final boolean isLocal;
 
     /**
-     * @param cacheName Cache name.
+     * @param schemaName Schema name.
      * @param sql Sql.
      * @param grpByCollocated Collocated GROUP BY.
      * @param distributedJoins Distributed joins enabled.
      * @param enforceJoinOrder Enforce join order of tables.
      * @param isLocal Query is local flag.
      */
-    H2TwoStepCachedQueryKey(String cacheName,
+    H2TwoStepCachedQueryKey(String schemaName,
         String sql,
         boolean grpByCollocated,
         boolean distributedJoins,
         boolean enforceJoinOrder,
         boolean isLocal) {
-        this.cacheName = cacheName;
+        this.schemaName = schemaName;
         this.sql = sql;
         this.grpByCollocated = grpByCollocated;
         this.distributedJoins = distributedJoins;
@@ -61,13 +61,6 @@ public class H2TwoStepCachedQueryKey {
         this.isLocal = isLocal;
     }
 
-    /**
-     * @return Cache name.
-     */
-    public String cacheName() {
-        return cacheName;
-    }
-
     /** {@inheritDoc} */
     @Override public boolean equals(Object o) {
         if (this == o)
@@ -87,7 +80,7 @@ public class H2TwoStepCachedQueryKey {
         if (enforceJoinOrder != that.enforceJoinOrder)
             return false;
 
-        if (cacheName != null ? !cacheName.equals(that.cacheName) : that.cacheName != null)
+        if (schemaName != null ? !schemaName.equals(that.schemaName) : that.schemaName != null)
             return false;
 
         return isLocal == that.isLocal && sql.equals(that.sql);
@@ -95,7 +88,7 @@ public class H2TwoStepCachedQueryKey {
 
     /** {@inheritDoc} */
     @Override public int hashCode() {
-        int res = cacheName != null ? cacheName.hashCode() : 0;
+        int res = schemaName != null ? schemaName.hashCode() : 0;
         res = 31 * res + sql.hashCode();
         res = 31 * res + (grpByCollocated ? 1 : 0);
         res = res + (distributedJoins ? 2 : 0);

http://git-wip-us.apache.org/repos/asf/ignite/blob/858e5b72/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 0291b0a..c94c215 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1324,12 +1324,11 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     /** {@inheritDoc} */
     @Override public FieldsQueryCursor<List<?>> queryDistributedSqlFields(GridCacheContext<?, ?> cctx,
         SqlFieldsQuery qry, boolean keepBinary, GridQueryCancel cancel) {
-        final String cacheName = cctx.name();
         final String sqlQry = qry.getSql();
 
-        String schema = schema(cctx.name());
+        String schemaName = schema(cctx.name());
 
-        Connection c = connectionForSchema(schema);
+        Connection c = connectionForSchema(schemaName);
 
         final boolean enforceJoinOrder = qry.isEnforceJoinOrder();
         final boolean distributedJoins = qry.isDistributedJoins();
@@ -1340,13 +1339,13 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         GridCacheTwoStepQuery twoStepQry = null;
         List<GridQueryFieldMetadata> meta;
 
-        final H2TwoStepCachedQueryKey cachedQryKey = new H2TwoStepCachedQueryKey(cacheName, sqlQry, grpByCollocated,
+        final H2TwoStepCachedQueryKey cachedQryKey = new H2TwoStepCachedQueryKey(schemaName, sqlQry, grpByCollocated,
             distributedJoins, enforceJoinOrder, qry.isLocal());
         H2TwoStepCachedQuery cachedQry = twoStepCache.get(cachedQryKey);
 
         if (cachedQry != null) {
-            twoStepQry = cachedQry.twoStepQry.copy();
-            meta = cachedQry.meta;
+            twoStepQry = cachedQry.query().copy();
+            meta = cachedQry.meta();
         }
         else {
             final UUID locNodeId = ctx.localNodeId();
@@ -1415,7 +1414,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                 if (twoStepQry == null) {
                     if (DmlStatementsProcessor.isDmlStatement(prepared)) {
                         try {
-                            return dmlProc.updateSqlFieldsDistributed(schema, stmt, qry, cancel);
+                            return dmlProc.updateSqlFieldsDistributed(schemaName, stmt, qry, cancel);
                         }
                         catch (IgniteCheckedException e) {
                             throw new IgniteSQLException("Failed to execute DML statement [stmt=" + sqlQry +
@@ -2249,11 +2248,15 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                 for (Index idx : tblDesc.table().getIndexes())
                     idx.close(null);
 
+            int cacheId = CU.cacheId(cacheName);
+
             for (Iterator<Map.Entry<H2TwoStepCachedQueryKey, H2TwoStepCachedQuery>> it =
                 twoStepCache.entrySet().iterator(); it.hasNext();) {
                 Map.Entry<H2TwoStepCachedQueryKey, H2TwoStepCachedQuery> e = it.next();
 
-                if (F.eq(e.getKey().cacheName(), cacheName))
+                GridCacheTwoStepQuery qry = e.getValue().query();
+
+                if (!F.isEmpty(qry.cacheIds()) && qry.cacheIds().contains(cacheId))
                     it.remove();
             }
         }


[23/24] ignite git commit: Merge remote-tracking branch 'remotes/origin/master' into ignite-5075-cc

Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-5075-cc


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

Branch: refs/heads/ignite-5075-cc
Commit: edc8eb16722e44b203a3e9bf9f63e8da1f6a937b
Parents: ed2f8b3 172419b
Author: sboikov <sb...@gridgain.com>
Authored: Mon May 29 10:05:05 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon May 29 10:05:05 2017 +0300

----------------------------------------------------------------------
 .../datagrid/CacheClientBinaryQueryExample.java |   4 +-
 .../internal/jdbc2/JdbcNoDefaultCacheTest.java  |   2 -
 .../java/org/apache/ignite/IgniteBinary.java    |  23 +-
 .../org/apache/ignite/binary/BinaryObject.java  |   8 +
 .../org/apache/ignite/binary/BinaryType.java    |   5 +
 .../ignite/binary/BinaryTypeConfiguration.java  |  26 ++
 .../cache/affinity/AffinityKeyMapper.java       |   3 +
 .../configuration/CacheConfiguration.java       |  11 +
 .../ignite/internal/GridKernalContext.java      |   1 +
 .../ignite/internal/GridKernalContextImpl.java  |   1 +
 .../binary/BinaryCachingMetadataHandler.java    |   5 +
 .../internal/binary/BinaryClassDescriptor.java  |   4 +-
 .../ignite/internal/binary/BinaryContext.java   |  60 +++-
 .../internal/binary/BinaryEnumObjectImpl.java   |  41 ++-
 .../internal/binary/BinaryFieldAccessor.java    |  10 +
 .../ignite/internal/binary/BinaryMetadata.java  |  93 ++++++-
 .../internal/binary/BinaryMetadataHandler.java  |   9 +
 .../binary/BinaryNoopMetadataHandler.java       |   5 +
 .../internal/binary/BinaryObjectExImpl.java     |   5 +
 .../internal/binary/BinaryObjectImpl.java       |  24 +-
 .../binary/BinaryObjectOffheapImpl.java         |   9 +-
 .../internal/binary/BinaryReaderExImpl.java     |  18 ++
 .../ignite/internal/binary/BinaryTypeImpl.java  |  15 +
 .../ignite/internal/binary/BinaryTypeProxy.java |   6 +
 .../ignite/internal/binary/BinaryUtils.java     | 104 ++++++-
 .../internal/binary/BinaryWriterExImpl.java     |  18 +-
 .../internal/binary/GridBinaryMarshaller.java   |   3 +
 .../binary/builder/BinaryBuilderSerializer.java |  10 +-
 .../binary/builder/BinaryObjectBuilderImpl.java |   2 +-
 .../internal/processors/cache/CacheObject.java  |   8 +-
 .../processors/cache/CacheObjectAdapter.java    |   4 +-
 .../cache/CacheObjectByteArrayImpl.java         |   8 +-
 .../processors/cache/CacheObjectContext.java    | 197 +-------------
 .../processors/cache/CacheObjectImpl.java       |  31 ++-
 .../processors/cache/CacheObjectUtils.java      | 173 ++++++++++++
 .../cache/CacheObjectValueContext.java          |  50 ++++
 .../processors/cache/GridCacheContext.java      |  12 +-
 .../processors/cache/GridCacheEventManager.java |   2 +-
 .../processors/cache/GridCacheMapEntry.java     |   4 +-
 .../processors/cache/GridCacheProcessor.java    |  16 +-
 .../processors/cache/KeyCacheObjectImpl.java    |  10 +-
 .../cache/binary/CacheObjectBinaryContext.java  |   6 +-
 .../binary/CacheObjectBinaryProcessor.java      |  21 +-
 .../binary/CacheObjectBinaryProcessorImpl.java  | 100 +++++--
 .../cache/binary/IgniteBinaryImpl.java          |  26 ++
 .../cache/database/CacheDataRowAdapter.java     |   8 +-
 .../cache/distributed/near/GridNearTxLocal.java |   3 +-
 .../cache/transactions/TxDeadlock.java          |   7 +-
 .../cacheobject/IgniteCacheObjectProcessor.java |   6 +-
 .../IgniteCacheObjectProcessorImpl.java         |  39 ++-
 .../processors/cacheobject/NoOpBinary.java      |  12 +
 .../platform/PlatformContextImpl.java           |  29 +-
 .../binary/PlatformBinaryProcessor.java         |  25 ++
 .../query/CacheQueryObjectValueContext.java     |  64 +++++
 .../query/GridQueryCacheObjectsIterator.java    |  16 +-
 .../processors/query/GridQueryIndexing.java     |  18 +-
 .../processors/query/GridQueryProcessor.java    |  80 +++---
 .../query/GridQueryTypeDescriptor.java          |  15 +
 .../processors/query/GridRunningQueryInfo.java  |  16 +-
 .../processors/query/QueryIndexKey.java         |  28 +-
 .../internal/processors/query/QuerySchema.java  |   2 +-
 .../query/QueryTypeDescriptorImpl.java          |   9 +
 .../internal/processors/query/QueryUtils.java   | 272 ++++++++++++++-----
 .../query/property/QueryBinaryProperty.java     |   2 +-
 .../query/VisorRunningQueriesCollectorTask.java |   2 +-
 .../communication/tcp/TcpCommunicationSpi.java  |   4 +-
 .../internal/GridAffinityNoCacheSelfTest.java   |  10 +-
 .../internal/binary/BinaryEnumsSelfTest.java    | 146 +++++++++-
 .../binary/TestCachingMetadataHandler.java      |   5 +
 .../IgniteIncompleteCacheObjectSelfTest.java    |  10 +-
 .../database/FreeListImplSelfTest.java          |  10 +-
 .../platform/PlatformComputeEchoTask.java       |  13 +
 .../query/h2/H2IndexingAbstractGeoSelfTest.java |  26 +-
 .../query/h2/H2IndexingBinaryGeoSelfTest.java   |  30 --
 .../H2IndexingBinarySegmentedGeoSelfTest.java   |  30 --
 .../query/h2/H2IndexingGeoSelfTest.java         |   2 +-
 .../h2/H2IndexingSegmentedGeoSelfTest.java      |   2 +-
 .../testsuites/GeoSpatialIndexingTestSuite.java |   5 -
 .../collections/HadoopSkipListSelfTest.java     |  37 ---
 .../query/h2/DmlStatementsProcessor.java        |  32 +--
 .../processors/query/h2/H2DmlPlanKey.java       |  66 +++++
 .../query/h2/H2ResultSetIterator.java           |   4 +-
 .../processors/query/h2/H2RowDescriptor.java    |  27 +-
 .../internal/processors/query/h2/H2Schema.java  |  46 +++-
 .../processors/query/h2/H2TableDescriptor.java  |  52 ++--
 .../processors/query/h2/H2TableEngine.java      |   2 +-
 .../query/h2/H2TwoStepCachedQuery.java          |  18 +-
 .../query/h2/H2TwoStepCachedQueryKey.java       |  19 +-
 .../internal/processors/query/h2/H2Utils.java   |  79 +-----
 .../processors/query/h2/IgniteH2Indexing.java   | 201 ++++++--------
 .../query/h2/ddl/DdlStatementsProcessor.java    |  66 +++--
 .../processors/query/h2/opt/GridH2Table.java    |   6 +-
 .../query/h2/opt/GridH2ValueCacheObject.java    |  32 +--
 .../query/h2/opt/GridLuceneIndex.java           |   2 +-
 .../query/h2/twostep/GridMapQueryExecutor.java  |  20 +-
 .../h2/twostep/GridReduceQueryExecutor.java     | 159 +++--------
 .../query/h2/twostep/ReduceQueryRun.java        | 157 +++++++++++
 .../query/h2/twostep/msg/GridH2CacheObject.java |  39 +--
 .../IgniteCacheInsertSqlQuerySelfTest.java      |  27 +-
 .../cache/index/AbstractSchemaSelfTest.java     | 123 +++++++--
 .../DynamicIndexAbstractBasicSelfTest.java      |  77 ++----
 .../DynamicIndexAbstractConcurrentSelfTest.java |  36 ++-
 .../index/DynamicIndexAbstractSelfTest.java     |  30 +-
 .../index/H2DynamicIndexAbstractSelfTest.java   |  48 ++--
 .../cache/index/SchemaExchangeSelfTest.java     |  13 +-
 .../query/IgniteSqlSchemaIndexingTest.java      |   4 +-
 .../query/IgniteSqlSplitterSelfTest.java        |  61 ++++-
 .../h2/GridIndexingSpiAbstractSelfTest.java     |  19 +-
 .../query/h2/sql/BaseH2CompareQueryTest.java    |  12 +-
 .../query/h2/sql/GridQueryParsingTest.java      |   4 +-
 .../query/h2/sql/H2CompareBigQueryTest.java     |   2 +-
 .../processors/query/h2/sql/bigQuery.sql        |   8 +-
 .../Binary/BinaryBuilderSelfTest.cs             |  88 +++++-
 .../Cache/Query/CacheLinqTest.cs                |  70 ++++-
 .../Compute/ComputeApiTest.cs                   |  25 ++
 .../Binary/BinaryTypeConfiguration.cs           |   3 +-
 .../dotnet/Apache.Ignite.Core/Binary/IBinary.cs |  24 ++
 .../Apache.Ignite.Core/Binary/IBinaryObject.cs  |   8 +
 .../Apache.Ignite.Core/Binary/IBinaryType.cs    |   6 +
 .../Apache.Ignite.Core/Impl/Binary/Binary.cs    |  67 ++++-
 .../Impl/Binary/BinaryEnum.cs                   |  11 +-
 .../Impl/Binary/BinaryObject.cs                 |  13 +-
 .../Impl/Binary/BinaryProcessor.cs              |  65 ++++-
 .../Impl/Binary/BinaryReader.cs                 |  10 +-
 .../Impl/Binary/BinarySystemHandlers.cs         |  25 +-
 .../Impl/Binary/BinaryUtils.cs                  |  19 ++
 .../Impl/Binary/BinaryWriter.cs                 |   4 +-
 .../Impl/Binary/Marshaller.cs                   |  88 +++---
 .../Impl/Binary/Metadata/BinaryType.cs          | 179 +++++++++++-
 .../Impl/Binary/Metadata/BinaryTypeHolder.cs    |  44 ++-
 .../Apache.Ignite.Linq.csproj                   |   3 +
 .../Apache.Ignite.Linq/CacheExtensions.cs       |  65 +++++
 .../Impl/CacheQueryExpressionVisitor.cs         |  12 +-
 .../Impl/CacheQueryModelVisitor.cs              |  73 +++--
 .../Apache.Ignite.Linq/Impl/CacheQueryParser.cs |  21 +-
 .../Impl/Dml/RemoveAllExpressionNode.cs         |  88 ++++++
 .../Impl/Dml/RemoveAllResultOperator.cs         |  61 +++++
 .../Apache.Ignite.Linq/Impl/MethodVisitor.cs    |   7 +-
 .../dotnet/Apache.Ignite.Linq/Impl/QueryData.cs |  17 +-
 .../dotnet/Apache.Ignite.sln.DotSettings        |   1 +
 .../dotnet/Apache.Ignite/Apache.Ignite.csproj   |   1 -
 .../Apache.Ignite/Service/ServiceDescription.cs |  32 ---
 modules/web-console/frontend/.babelrc           |   9 +-
 modules/web-console/frontend/.gitignore         |   1 -
 modules/web-console/frontend/app/app.js         |  18 +-
 .../components/web-console-header/component.js  |   6 +-
 .../app/modules/agent/AgentManager.service.js   |   2 -
 .../frontend/gulpfile.babel.js/index.js         |  26 --
 .../frontend/gulpfile.babel.js/paths.js         |  64 -----
 .../frontend/gulpfile.babel.js/tasks/build.js   |  21 --
 .../frontend/gulpfile.babel.js/tasks/bundle.js  |  36 ---
 .../frontend/gulpfile.babel.js/tasks/clean.js   |  32 ---
 .../frontend/gulpfile.babel.js/tasks/copy.js    |  33 ---
 .../gulpfile.babel.js/tasks/ignite-modules.js   |  55 ----
 .../frontend/gulpfile.babel.js/tasks/watch.js   |  30 --
 .../gulpfile.babel.js/webpack/common.js         | 205 --------------
 .../webpack/environments/development.js         |  60 ----
 .../webpack/environments/production.js          |  41 ---
 .../webpack/environments/test.js                |  44 ---
 .../frontend/gulpfile.babel.js/webpack/index.js |  36 ---
 .../frontend/ignite_modules/index.js            |   7 +-
 modules/web-console/frontend/package.json       | 104 +++----
 .../frontend/test/karma.conf.babel.js           |  13 +-
 modules/web-console/frontend/test/karma.conf.js |   2 +-
 .../frontend/webpack/webpack.common.js          | 188 +++++++++++++
 .../frontend/webpack/webpack.dev.babel.js       | 100 +++++++
 .../frontend/webpack/webpack.prod.babel.js      |  64 +++++
 .../frontend/webpack/webpack.test.js            |  33 +++
 168 files changed, 3782 insertions(+), 2245 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/edc8eb16/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------


[14/24] ignite git commit: Fixed CacheClientBinaryQueryExample.

Posted by sb...@apache.org.
Fixed CacheClientBinaryQueryExample.


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

Branch: refs/heads/ignite-5075-cc
Commit: e59d3890ce4d50b6627e731c13dad36ae05959b4
Parents: b673bdb
Author: devozerov <vo...@gridgain.com>
Authored: Sat May 27 21:05:26 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Sat May 27 21:05:26 2017 +0300

----------------------------------------------------------------------
 .../examples/binary/datagrid/CacheClientBinaryQueryExample.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e59d3890/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java
index 11c00e9..c2d4964 100644
--- a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java
@@ -149,9 +149,9 @@ public class CacheClientBinaryQueryExample {
         employeeEntity.setIndexes(Arrays.asList(
             new QueryIndex("name"),
             new QueryIndex("salary"),
-            new QueryIndex("zip"),
+            new QueryIndex("addr.zip"),
             new QueryIndex("organizationId"),
-            new QueryIndex("street", QueryIndexType.FULLTEXT)
+            new QueryIndex("addr.street", QueryIndexType.FULLTEXT)
         ));
 
         return employeeEntity;


[02/24] ignite git commit: .NET: Remove dead code from exe project

Posted by sb...@apache.org.
.NET: Remove dead code from exe project


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

Branch: refs/heads/ignite-5075-cc
Commit: d911848d4240af5ea17e79b2312132c2047b3071
Parents: cfc7436
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri May 26 11:43:57 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri May 26 11:43:57 2017 +0300

----------------------------------------------------------------------
 .../dotnet/Apache.Ignite/Apache.Ignite.csproj   |  1 -
 .../Apache.Ignite/Service/ServiceDescription.cs | 32 --------------------
 2 files changed, 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d911848d/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
index 13379f5..3e8f83e 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
@@ -52,7 +52,6 @@
     <Compile Include="Service\IgniteService.cs">
       <SubType>Component</SubType>
     </Compile>
-    <Compile Include="Service\ServiceDescription.cs" />
     <Compile Include="Service\IgniteServiceInstaller.cs">
       <SubType>Component</SubType>
     </Compile>

http://git-wip-us.apache.org/repos/asf/ignite/blob/d911848d/modules/platforms/dotnet/Apache.Ignite/Service/ServiceDescription.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Service/ServiceDescription.cs b/modules/platforms/dotnet/Apache.Ignite/Service/ServiceDescription.cs
deleted file mode 100644
index a81a737..0000000
--- a/modules/platforms/dotnet/Apache.Ignite/Service/ServiceDescription.cs
+++ /dev/null
@@ -1,32 +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.Service
-{
-    using System;
-    using System.Runtime.InteropServices;
-
-    /// <summary>
-    /// Service description structure.
-    /// </summary>
-    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
-    public struct ServiceDescription
-    {
-        /** Pointer to description. */
-        public IntPtr desc;
-    }
-}
\ No newline at end of file


[05/24] ignite git commit: Merge remote-tracking branch 'origin/master'

Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/master'


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

Branch: refs/heads/ignite-5075-cc
Commit: 279f35b156a74faec271f23ee589e0a54f7ac53d
Parents: 8a6bc9e 22d108c
Author: sboikov <sb...@gridgain.com>
Authored: Fri May 26 12:11:49 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri May 26 12:11:49 2017 +0300

----------------------------------------------------------------------
 modules/platforms/dotnet/Apache.Ignite.Linq/Impl/QueryData.cs | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------



[10/24] ignite git commit: IGNITE-5287: Simplified CacheConfiguration.sqlEscapeAll handling. This closes #2004.

Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
index 7e3473f..cc6fb9a 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
@@ -22,7 +22,6 @@ import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.QueryIndex;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
@@ -30,13 +29,10 @@ import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
 import org.apache.ignite.internal.processors.query.IgniteSQLException;
 import org.apache.ignite.internal.processors.query.schema.SchemaOperationException;
-import org.apache.ignite.internal.util.GridStringBuilder;
-import org.apache.ignite.internal.util.typedef.internal.SB;
 
 import javax.cache.CacheException;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Map;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
@@ -189,10 +185,10 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
     private void checkCreate(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
         initialize(mode, atomicityMode, near);
 
-        final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
+        final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
 
         dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1));
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
 
         assertSchemaException(new RunnableX() {
             @Override public void run() throws Exception {
@@ -201,7 +197,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
         }, IgniteQueryErrorCode.INDEX_ALREADY_EXISTS);
 
         dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, true);
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1));
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
 
         assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
 
@@ -273,10 +269,10 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
     private void checkCreateComposite(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
         initialize(mode, atomicityMode, near);
 
-        final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1), field(alias(FIELD_NAME_2)));
+        final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED), field(alias(FIELD_NAME_2_ESCAPED)));
 
         dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1), field(alias(FIELD_NAME_2)));
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1_ESCAPED), field(alias(FIELD_NAME_2_ESCAPED)));
 
         assertCompositeIndexOperations(SQL_COMPOSITE);
 
@@ -348,7 +344,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
     private void checkCreateNotCache(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
         initialize(mode, atomicityMode, near);
 
-        final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
+        final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
 
         try {
             String cacheName = randomString();
@@ -434,7 +430,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
     private void checkCreateNoTable(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
         initialize(mode, atomicityMode, near);
 
-        final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
+        final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
 
         assertSchemaException(new RunnableX() {
             @Override public void run() throws Exception {
@@ -589,7 +585,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
 
         assertSchemaException(new RunnableX() {
             @Override public void run() throws Exception {
-                QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_2));
+                QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_2_ESCAPED));
 
                 dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
             }
@@ -597,10 +593,10 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
 
         assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
 
-        QueryIndex idx = index(IDX_NAME_1, field(alias(FIELD_NAME_2)));
+        QueryIndex idx = index(IDX_NAME_1, field(alias(FIELD_NAME_2_ESCAPED)));
 
         dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(alias(FIELD_NAME_2)));
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(alias(FIELD_NAME_2_ESCAPED)));
 
         assertSimpleIndexOperations(SQL_SIMPLE_FIELD_2);
 
@@ -673,20 +669,20 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
         initialize(mode, atomicityMode, near);
 
         // Create target index.
-        QueryIndex idx1 = index(IDX_NAME_1, field(FIELD_NAME_1));
+        QueryIndex idx1 = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
 
         dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx1, false);
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1));
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
 
         assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
 
         assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
 
         // Create another index which must stay intact afterwards.
-        QueryIndex idx2 = index(IDX_NAME_2, field(alias(FIELD_NAME_2)));
+        QueryIndex idx2 = index(IDX_NAME_2, field(alias(FIELD_NAME_2_ESCAPED)));
 
         dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx2, false);
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2)));
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2_ESCAPED)));
 
         // Load some data.
         loadInitialData();
@@ -700,7 +696,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
         assertIndexNotUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
 
         // Make sure the second index is still there.
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2)));
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2_ESCAPED)));
     }
 
     /**
@@ -875,7 +871,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
                 node.getOrCreateCache(cacheConfiguration().setCacheMode(LOCAL));
         }
 
-        final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
+        final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
 
         assertSchemaException(new RunnableX() {
             @Override public void run() throws Exception {
@@ -1028,30 +1024,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
      */
     private void dynamicIndexCreate(String cacheName, String tblName, QueryIndex idx, boolean ifNotExists)
         throws Exception {
-        GridStringBuilder sql = new SB("CREATE INDEX ")
-            .a(ifNotExists ? "IF NOT EXISTS " : "")
-            .a("\"" + idx.getName() + "\"")
-            .a(" ON ")
-            .a(tblName)
-            .a(" (");
-
-        boolean first = true;
-
-        for (Map.Entry<String, Boolean> fieldEntry : idx.getFields().entrySet()) {
-            if (first)
-                first = false;
-            else
-                sql.a(", ");
-
-            String name = fieldEntry.getKey();
-            boolean asc = fieldEntry.getValue();
-
-            sql.a("\"" + name + "\"").a(" ").a(asc ? "ASC" : "DESC");
-        }
-
-        sql.a(')');
-
-        executeSql(cacheName, sql.toString());
+        dynamicIndexCreate(node(), cacheName, tblName, idx, ifNotExists);
     }
 
     /**
@@ -1063,20 +1036,6 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
      * @throws Exception if failed.
      */
     private void dynamicIndexDrop(String cacheName, String idxName, boolean ifExists) throws Exception {
-        String sql = "DROP INDEX " + (ifExists ? "IF EXISTS " : "") + "\"" + idxName + "\"";
-
-        executeSql(cacheName, sql);
-    }
-
-    /**
-     * Execute SQL.
-     *
-     * @param cacheName Cache name.
-     * @param sql SQL.
-     */
-    private void executeSql(String cacheName, String sql) {
-        log.info("Executing DDL: " + sql);
-
-        node().cache(cacheName).query(new SqlFieldsQuery(sql)).getAll();
+        dynamicIndexDrop(node(), cacheName, idxName, ifExists);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
index 3600022..5d93c12 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
@@ -169,7 +169,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
         // Test migration from normal server to non-affinity server.
         blockIndexing(srv2Id);
 
-        QueryIndex idx2 = index(IDX_NAME_2, field(alias(FIELD_NAME_2)));
+        QueryIndex idx2 = index(IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
 
         IgniteInternalFuture<?> idxFut2 =
             queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx2, false);
@@ -183,7 +183,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
 
         idxFut2.get();
 
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2)));
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
         assertIndexUsed(IDX_NAME_2, SQL_SIMPLE_FIELD_2, SQL_ARG_1);
         assertSqlSimpleData(SQL_SIMPLE_FIELD_2, KEY_AFTER - SQL_ARG_1);
     }
@@ -205,7 +205,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
         blockIndexing(srv1);
 
         QueryIndex idx1 = index(IDX_NAME_1, field(FIELD_NAME_1));
-        QueryIndex idx2 = index(IDX_NAME_2, field(alias(FIELD_NAME_2)));
+        QueryIndex idx2 = index(IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
 
         IgniteInternalFuture<?> idxFut1 =
             queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx1, false);
@@ -227,7 +227,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
         idxFut2.get();
 
         assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1));
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2)));
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
 
         Thread.sleep(100);
 
@@ -354,7 +354,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
         for (Ignite node : Ignition.allGrids()) {
             IgniteCache<BinaryObject, BinaryObject> nodeCache = node.cache(CACHE_NAME).withKeepBinary();
 
-            SqlQuery qry = new SqlQuery(tableName(ValueClass.class), SQL_SIMPLE_FIELD_1).setArgs(SQL_ARG_1);
+            SqlQuery qry = new SqlQuery(typeName(ValueClass.class), SQL_SIMPLE_FIELD_1).setArgs(SQL_ARG_1);
 
             List<Cache.Entry<BinaryObject, BinaryObject>> res = nodeCache.query(qry).getAll();
 
@@ -676,11 +676,11 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
         assertIndexNotUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
 
         // Update existing index.
-        QueryIndex idx = index(IDX_NAME_2, field(alias(FIELD_NAME_2)));
+        QueryIndex idx = index(IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
 
         queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false).get();
 
-        assertIndex(cli, true, CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2)));
+        assertIndex(cli, true, CACHE_NAME, TBL_NAME, IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
         assertIndexUsed(IDX_NAME_2, SQL_SIMPLE_FIELD_2, SQL_ARG_2);
 
         reconnectClientNode(srv, cli, restartCache, new RunnableX() {
@@ -688,13 +688,13 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
                 if (!restartCache)
                     queryProcessor(srv).dynamicIndexDrop(CACHE_NAME, CACHE_NAME, IDX_NAME_2, false).get();
 
-                final QueryIndex idx = index(IDX_NAME_2, field(FIELD_NAME_1), field(alias(FIELD_NAME_2)));
+                final QueryIndex idx = index(IDX_NAME_2, field(FIELD_NAME_1), field(aliasUnescaped(FIELD_NAME_2)));
 
                 queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false);
             }
         });
 
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(FIELD_NAME_1), field(alias(FIELD_NAME_2)));
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(FIELD_NAME_1), field(aliasUnescaped(FIELD_NAME_2)));
         assertIndexUsed(IDX_NAME_2, SQL_COMPOSITE, SQL_ARG_1, SQL_ARG_2);
     }
 
@@ -1029,6 +1029,16 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
     }
 
     /**
+     * Get unescaped field alias.
+     *
+     * @param field Field.
+     * @return Alias.
+     */
+    private static String aliasUnescaped(String field) {
+        return alias(field).toUpperCase();
+    }
+
+    /**
      * Blocking indexing processor.
      */
     private static class BlockingIndexing extends IgniteH2Indexing {

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractSelfTest.java
index fc765a4..5a58965 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractSelfTest.java
@@ -60,15 +60,15 @@ public abstract class DynamicIndexAbstractSelfTest extends AbstractSchemaSelfTes
     protected static final int KEY_AFTER = 200;
 
     /** SQL to check index on the field 1. */
-    protected static final String SQL_SIMPLE_FIELD_1 = "SELECT * FROM " + TBL_NAME + " WHERE " + FIELD_NAME_1 + " >= ?";
+    protected static final String SQL_SIMPLE_FIELD_1 = "SELECT * FROM " + TBL_NAME + " WHERE " + FIELD_NAME_1_ESCAPED + " >= ?";
 
     /** SQL to check composite index */
-    protected static final String SQL_COMPOSITE = "SELECT * FROM " + TBL_NAME + " WHERE " + FIELD_NAME_1 +
-        " >= ? AND " + alias(FIELD_NAME_2) + " >= ?";
+    protected static final String SQL_COMPOSITE = "SELECT * FROM " + TBL_NAME + " WHERE " + FIELD_NAME_1_ESCAPED +
+        " >= ? AND " + alias(FIELD_NAME_2_ESCAPED) + " >= ?";
 
     /** SQL to check index on the field 2. */
     protected static final String SQL_SIMPLE_FIELD_2 =
-        "SELECT * FROM " + TBL_NAME + " WHERE " + alias(FIELD_NAME_2) + " >= ?";
+        "SELECT * FROM " + TBL_NAME + " WHERE " + alias(FIELD_NAME_2_ESCAPED) + " >= ?";
 
     /** Argument for simple SQL (1). */
     protected static final int SQL_ARG_1 = 40;
@@ -165,12 +165,12 @@ public abstract class DynamicIndexAbstractSelfTest extends AbstractSchemaSelfTes
         entity.addQueryField(FIELD_KEY_ALIAS, entity.getKeyType(), null);
 
         entity.addQueryField(FIELD_KEY, Long.class.getName(), null);
-        entity.addQueryField(FIELD_NAME_1, Long.class.getName(), null);
-        entity.addQueryField(FIELD_NAME_2, Long.class.getName(), null);
+        entity.addQueryField(FIELD_NAME_1_ESCAPED, Long.class.getName(), null);
+        entity.addQueryField(FIELD_NAME_2_ESCAPED, Long.class.getName(), null);
 
         entity.setKeyFields(Collections.singleton(FIELD_KEY));
 
-        entity.setAliases(Collections.singletonMap(FIELD_NAME_2, alias(FIELD_NAME_2)));
+        entity.setAliases(Collections.singletonMap(FIELD_NAME_2_ESCAPED, alias(FIELD_NAME_2_ESCAPED)));
 
         ccfg.setQueryEntities(Collections.singletonList(entity));
 
@@ -264,8 +264,8 @@ public abstract class DynamicIndexAbstractSelfTest extends AbstractSchemaSelfTes
      */
     protected static BinaryObject value(Ignite ignite, long id) {
         return ignite.binary().builder(ValueClass.class.getName())
-            .setField(FIELD_NAME_1, id)
-            .setField(FIELD_NAME_2, id)
+            .setField(FIELD_NAME_1_ESCAPED, id)
+            .setField(FIELD_NAME_2_ESCAPED, id)
             .build();
     }
 
@@ -388,7 +388,7 @@ public abstract class DynamicIndexAbstractSelfTest extends AbstractSchemaSelfTes
      * @param expSize Expected size.
      */
     protected static void assertSqlSimpleData(Ignite node, String sql, int expSize) {
-        SqlQuery qry = new SqlQuery(tableName(ValueClass.class), sql).setArgs(SQL_ARG_1);
+        SqlQuery qry = new SqlQuery(typeName(ValueClass.class), sql).setArgs(SQL_ARG_1);
 
         List<Cache.Entry<BinaryObject, BinaryObject>> res = node.cache(CACHE_NAME).withKeepBinary().query(qry).getAll();
 
@@ -397,8 +397,8 @@ public abstract class DynamicIndexAbstractSelfTest extends AbstractSchemaSelfTes
         for (Cache.Entry<BinaryObject, BinaryObject> entry : res) {
             long id = entry.getKey().field(FIELD_KEY);
 
-            long field1 = entry.getValue().field(FIELD_NAME_1);
-            long field2 = entry.getValue().field(FIELD_NAME_2);
+            long field1 = entry.getValue().field(FIELD_NAME_1_ESCAPED);
+            long field2 = entry.getValue().field(FIELD_NAME_2_ESCAPED);
 
             assertTrue(field1 >= SQL_ARG_1);
 
@@ -420,7 +420,7 @@ public abstract class DynamicIndexAbstractSelfTest extends AbstractSchemaSelfTes
      * @param expSize Expected size.
      */
     protected static void assertSqlCompositeData(Ignite node, String sql, int expSize) {
-        SqlQuery qry = new SqlQuery(tableName(ValueClass.class), sql).setArgs(SQL_ARG_1, SQL_ARG_2);
+        SqlQuery qry = new SqlQuery(typeName(ValueClass.class), sql).setArgs(SQL_ARG_1, SQL_ARG_2);
 
         List<Cache.Entry<BinaryObject, BinaryObject>> res = node.cache(CACHE_NAME).withKeepBinary().query(qry).getAll();
 
@@ -429,8 +429,8 @@ public abstract class DynamicIndexAbstractSelfTest extends AbstractSchemaSelfTes
         for (Cache.Entry<BinaryObject, BinaryObject> entry : res) {
             long id = entry.getKey().field(FIELD_KEY);
 
-            long field1 = entry.getValue().field(FIELD_NAME_1);
-            long field2 = entry.getValue().field(FIELD_NAME_2);
+            long field1 = entry.getValue().field(FIELD_NAME_1_ESCAPED);
+            long field2 = entry.getValue().field(FIELD_NAME_2_ESCAPED);
 
             assertTrue(field1 >= SQL_ARG_2);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexAbstractSelfTest.java
index cf563cc..85b4e8c 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexAbstractSelfTest.java
@@ -66,7 +66,7 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
 
         client().getOrCreateCache(cacheConfiguration());
 
-        assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
+        assertNoIndex(CACHE_NAME, TBL_NAME_ESCAPED, IDX_NAME_1_ESCAPED);
 
         IgniteCache<KeyClass, ValueClass> cache = client().cache(CACHE_NAME);
 
@@ -90,8 +90,8 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
 
         assertSize(3);
 
-        cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1 + "\" ON \"" + TBL_NAME + "\"(\""
-            + FIELD_NAME_1 + "\" ASC)")).getAll();
+        cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1_ESCAPED + "\" ON \"" + TBL_NAME_ESCAPED + "\"(\""
+            + FIELD_NAME_1_ESCAPED + "\" ASC)")).getAll();
 
         // Test that local queries on all nodes use new index.
         for (int i = 0 ; i < 4; i++) {
@@ -124,12 +124,13 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
     public void testCreateIndexWithDuplicateName() {
         final IgniteCache<KeyClass, ValueClass> cache = cache();
 
-        cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1 + "\" ON \"" + TBL_NAME + "\"(\""
-            + FIELD_NAME_1 + "\" ASC)"));
+        cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1_ESCAPED + "\" ON \"" + TBL_NAME_ESCAPED + "\"(\""
+            + FIELD_NAME_1_ESCAPED + "\" ASC)"));
 
         assertSqlException(new RunnableX() {
             @Override public void run() throws Exception {
-                cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1 + "\" ON \"" + TBL_NAME + "\"(\"id\" ASC)"));
+                cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1_ESCAPED + "\" ON \"" +
+                    TBL_NAME_ESCAPED + "\"(\"id\" ASC)"));
             }
         }, IgniteQueryErrorCode.INDEX_ALREADY_EXISTS);
     }
@@ -140,11 +141,11 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
     public void testCreateIndexIfNotExists() {
         final IgniteCache<KeyClass, ValueClass> cache = cache();
 
-        cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1 + "\" ON \"" + TBL_NAME + "\"(\""
-            + FIELD_NAME_1 + "\" ASC)"));
+        cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1_ESCAPED + "\" ON \"" + TBL_NAME_ESCAPED + "\"(\""
+            + FIELD_NAME_1_ESCAPED + "\" ASC)"));
 
-        cache.query(new SqlFieldsQuery("CREATE INDEX IF NOT EXISTS \"" + IDX_NAME_1 + "\" ON \"" + TBL_NAME +
-            "\"(\"id\" ASC)"));
+        cache.query(new SqlFieldsQuery("CREATE INDEX IF NOT EXISTS \"" + IDX_NAME_1_ESCAPED + "\" ON \"" +
+            TBL_NAME_ESCAPED + "\"(\"id\" ASC)"));
     }
 
     /**
@@ -155,12 +156,12 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
 
         assertSize(3);
 
-        cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1 + "\" ON \"" + TBL_NAME + "\"(\""
-            + FIELD_NAME_1 + "\" ASC)"));
+        cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1_ESCAPED + "\" ON \"" + TBL_NAME_ESCAPED + "\"(\""
+            + FIELD_NAME_1_ESCAPED + "\" ASC)"));
 
         assertSize(3);
 
-        cache.query(new SqlFieldsQuery("DROP INDEX \"" + IDX_NAME_1 + "\""));
+        cache.query(new SqlFieldsQuery("DROP INDEX \"" + IDX_NAME_1_ESCAPED + "\""));
 
         // Test that no local queries on all nodes use new index.
         for (int i = 0 ; i < 4; i++) {
@@ -187,7 +188,7 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
 
         assertSqlException(new RunnableX() {
             @Override public void run() throws Exception {
-                cache.query(new SqlFieldsQuery("DROP INDEX \"" + IDX_NAME_1 + "\""));
+                cache.query(new SqlFieldsQuery("DROP INDEX \"" + IDX_NAME_1_ESCAPED + "\""));
             }
         }, IgniteQueryErrorCode.INDEX_NOT_FOUND);
     }
@@ -198,7 +199,7 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
     public void testDropMissingIndexIfExists() {
         final IgniteCache<KeyClass, ValueClass> cache = cache();
 
-        cache.query(new SqlFieldsQuery("DROP INDEX IF EXISTS \"" + IDX_NAME_1 + "\""));
+        cache.query(new SqlFieldsQuery("DROP INDEX IF EXISTS \"" + IDX_NAME_1_ESCAPED + "\""));
     }
 
     /**
@@ -209,8 +210,8 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
 
         assertColumnValues("val1", "val2", "val3");
 
-        cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1 + "\" ON \"" + TBL_NAME + "\"(\""
-            + FIELD_NAME_1 + "\" ASC)"));
+        cache.query(new SqlFieldsQuery("CREATE INDEX \"" + IDX_NAME_1_ESCAPED + "\" ON \"" + TBL_NAME_ESCAPED + "\"(\""
+            + FIELD_NAME_1_ESCAPED + "\" ASC)"));
 
         assertColumnValues("val1", "val2", "val3");
 
@@ -222,7 +223,7 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
 
         assertColumnValues("someVal", "val1", "val3");
 
-        cache.query(new SqlFieldsQuery("DROP INDEX \"" + IDX_NAME_1 + "\""));
+        cache.query(new SqlFieldsQuery("DROP INDEX \"" + IDX_NAME_1_ESCAPED + "\""));
 
         assertColumnValues("someVal", "val1", "val3");
     }
@@ -237,9 +238,8 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
         for (String v : vals)
             expRes.add(Collections.singletonList(v));
 
-        assertEquals(expRes, cache().query(new SqlFieldsQuery("SELECT \"" + FIELD_NAME_1 + "\" FROM \"" + TBL_NAME +
-            "\" ORDER BY \"id\""))
-            .getAll());
+        assertEquals(expRes, cache().query(new SqlFieldsQuery("SELECT \"" + FIELD_NAME_1_ESCAPED + "\" FROM \"" +
+            TBL_NAME_ESCAPED + "\" ORDER BY \"id\"")).getAll());
     }
 
     /**
@@ -332,12 +332,12 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT
         entity.setValueType(ValueClass.class.getName());
 
         entity.addQueryField("id", Long.class.getName(), null);
-        entity.addQueryField(FIELD_NAME_1, String.class.getName(), null);
-        entity.addQueryField(FIELD_NAME_2, String.class.getName(), null);
+        entity.addQueryField(FIELD_NAME_1_ESCAPED, String.class.getName(), null);
+        entity.addQueryField(FIELD_NAME_2_ESCAPED, String.class.getName(), null);
 
         entity.setKeyFields(Collections.singleton("id"));
 
-        entity.setAliases(Collections.singletonMap(FIELD_NAME_2, alias(FIELD_NAME_2)));
+        entity.setAliases(Collections.singletonMap(FIELD_NAME_2_ESCAPED, alias(FIELD_NAME_2_ESCAPED)));
 
         ccfg.setQueryEntities(Collections.singletonList(entity));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
index 71244bb..33478a2 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.cache.index;
 
-import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteClientDisconnectedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.Ignition;
@@ -28,6 +27,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.processors.query.QueryTypeDescriptorImpl;
+import org.apache.ignite.internal.processors.query.QueryUtils;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.lang.IgniteFuture;
@@ -466,18 +466,21 @@ public class SchemaExchangeSelfTest extends AbstractSchemaSelfTest {
             @Override public void run() {
                 assertTrue(node2.context().clientDisconnected());
 
-                final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
+                final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
 
                 try {
-                    queryProcessor(node1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false).get();
+                    dynamicIndexCreate(node1, CACHE_NAME, TBL_NAME, idx, false);
                 }
-                catch (IgniteCheckedException e) {
+                catch (Exception e) {
                     throw new IgniteException(e);
                 }
             }
         });
 
-        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1));
+        assertIndex(CACHE_NAME,
+            QueryUtils.normalizeObjectName(TBL_NAME, true),
+            QueryUtils.normalizeObjectName(IDX_NAME_1, false),
+            field(QueryUtils.normalizeObjectName(FIELD_NAME_1_ESCAPED, false)));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSchemaIndexingTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSchemaIndexingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSchemaIndexingTest.java
index b79a064..4672290 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSchemaIndexingTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSchemaIndexingTest.java
@@ -93,8 +93,10 @@ public class IgniteSqlSchemaIndexingTest extends GridCommonAbstractTest {
             @Override public Object call() throws Exception {
                 final CacheConfiguration cfg = cacheConfig("InSensitiveCache", true, Integer.class, Integer.class)
                     .setSqlSchema("InsensitiveCache");
+
                 final CacheConfiguration collisionCfg = cacheConfig("InsensitiveCache", true, Integer.class, Integer.class)
                     .setSqlSchema("Insensitivecache");
+
                 IgniteConfiguration icfg = new IgniteConfiguration()
                     .setLocalHost("127.0.0.1")
                     .setCacheConfiguration(cfg, collisionCfg);
@@ -158,7 +160,7 @@ public class IgniteSqlSchemaIndexingTest extends GridCommonAbstractTest {
             .setSqlEscapeAll(true);
 
         final CacheConfiguration<Integer, Fact> cfgEsc = cacheConfig("escapedSchema", true, Integer.class, Fact.class)
-            .setSqlSchema("\"SchemaName2\"")
+            .setSqlSchema("SchemaName2")
             .setSqlEscapeAll(true);
 
         escapeCheckSchemaName(ignite(0).createCache(cfg), log, cfg.getSqlSchema());

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index f98f41b..4bb6a3a 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -615,9 +615,9 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
             c1.put(5, new Person2(3, "p3"));
 
             String select = "select o.name n1, p.name n2 from Person2 p, \"org\".Organization o" +
-                            " where p.orgId = o._key and o._key=1" +
-                            " union select o.name n1, p.name n2 from Person2 p, \"org\".Organization o" +
-                            " where p.orgId = o._key and o._key=2";
+                " where p.orgId = o._key and o._key=1" +
+                " union select o.name n1, p.name n2 from Person2 p, \"org\".Organization o" +
+                " where p.orgId = o._key and o._key=2";
 
             String plan = c1.query(new SqlFieldsQuery("explain " + select)
                 .setDistributedJoins(true).setEnforceJoinOrder(true))
@@ -1615,11 +1615,11 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
     public void testJoinWithSubquery() throws Exception {
         IgniteCache<Integer, Contract> c1 = ignite(0).createCache(
             cacheConfig("Contract", true,
-            Integer.class, Contract.class));
+                Integer.class, Contract.class));
 
         IgniteCache<Integer, PromoContract> c2 = ignite(0).createCache(
             cacheConfig("PromoContract", true,
-            Integer.class, PromoContract.class));
+                Integer.class, PromoContract.class));
 
         for (int i = 0; i < 100; i++) {
             int coId = i % 10;

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index 97db2c4..5ac02a5 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -692,6 +692,16 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         @Override public String valueFieldName() {
             return null;
         }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public String keyFieldAlias() {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public String valueFieldAlias() {
+            return null;
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
index 1324b72..9a3f64d 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
@@ -130,7 +130,7 @@ public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest {
             insertInDb(org);
         }
 
-       // Adresses.
+        // Adresses.
         List<Address> addreses = new ArrayList<>();
 
         for (int i = 0; i < ADDR_CNT; i++) {
@@ -259,13 +259,13 @@ public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest {
 
         List<List<?>> res = compareQueryRes0(cachePers,
             "select avg(old) from \"pers\".Person left join \"addr\".Address " +
-            " on Person.addrId = Address.id where lower(Address.street) = lower(?)", addStreet);
+                " on Person.addrId = Address.id where lower(Address.street) = lower(?)", addStreet);
 
         assertNotSame(0, res);
 
         compareQueryRes0(cachePers,
             "select avg(old) from \"pers\".Person join \"addr\".Address on Person.addrId = Address.id " +
-            "where lower(Address.street) = lower(?)", addStreet);
+                "where lower(Address.street) = lower(?)", addStreet);
 
         compareQueryRes0(cachePers,
             "select avg(old) from \"pers\".Person left join \"addr\".Address " +
@@ -274,7 +274,7 @@ public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest {
 
         compareQueryRes0(cachePers,
             "select avg(old) from \"pers\".Person, \"addr\".Address where Person.addrId = Address.id " +
-            "and lower(Address.street) = lower(?)", addStreet);
+                "and lower(Address.street) = lower(?)", addStreet);
 
         compareQueryRes0(cachePers, "select firstName, date from \"pers\".Person");
         compareQueryRes0(cachePers, "select distinct firstName, date from \"pers\".Person");
@@ -483,8 +483,8 @@ public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest {
      */
     public void testOrdered() throws Exception {
         compareOrderedQueryRes0(cachePers, "select firstName, lastName" +
-                " from \"pers\".Person" +
-                " order by lastName, firstName");
+            " from \"pers\".Person" +
+            " order by lastName, firstName");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java
index 26a0a68..50b71b5 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java
@@ -435,7 +435,7 @@ public class H2CompareBigQueryTest extends AbstractH2CompareQueryTest {
             st.setObject(++i, o.orderId);
             st.setObject(++i, o.parentAlgo);
 
-           st.executeUpdate();
+            st.executeUpdate();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/427ca690/modules/indexing/src/test/resources/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/resources/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql b/modules/indexing/src/test/resources/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
index d441e3f..ac70026 100644
--- a/modules/indexing/src/test/resources/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
+++ b/modules/indexing/src/test/resources/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
@@ -21,9 +21,9 @@ from (
   from (
 	select  date, orderId, rootOrderId, origOrderId, archSeq, alias 
 	from "custord".CustOrder where alias='CUSTOM'
-	
+
 	union all
-	
+
 	select  date, orderId, rootOrderId, refOrderId as origOrderId, archSeq, alias
 	from "replord".ReplaceOrder where alias='CUSTOM'
   ) co,
@@ -45,9 +45,9 @@ from (
     and h.origOrderId = co.origOrderId and h.date = co.date
     and co.archSeq = h.maxArchSeq
 	and co.alias='CUSTOM'
-) cop 
+) cop
 inner join (
-  select e.date, e.rootOrderId as eRootOrderId, e.rootOrderId, sum(e.execShares) as execShares, 
+  select e.date, e.rootOrderId as eRootOrderId, e.rootOrderId, sum(e.execShares) as execShares,
 	sum(e.execShares*e.price)/sum(e.execShares) as price,
 	case when min(e.lastMkt) = max(e.lastMkt) then min(e.lastMkt) else min('XOFF') end as execMeet
   from "exec".Exec e


[03/24] ignite git commit: TcpCommunicationSpi: increased default idle timeout.

Posted by sb...@apache.org.
TcpCommunicationSpi: increased default idle timeout.


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

Branch: refs/heads/ignite-5075-cc
Commit: 8a6bc9e61677e3b1b75684233a4693921e991db7
Parents: d911848
Author: sboikov <sb...@gridgain.com>
Authored: Fri May 26 12:07:40 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri May 26 12:07:40 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8a6bc9e6/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 5ec9a6e..2e35c6e 100755
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -267,8 +267,8 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
     /** Default port which node sets listener for shared memory connections (value is <tt>48100</tt>). */
     public static final int DFLT_SHMEM_PORT = -1;
 
-    /** Default idle connection timeout (value is <tt>30000</tt>ms). */
-    public static final long DFLT_IDLE_CONN_TIMEOUT = 30000;
+    /** Default idle connection timeout (value is <tt>10</tt>min). */
+    public static final long DFLT_IDLE_CONN_TIMEOUT = 10 * 60_000;
 
     /** Default socket send and receive buffer size. */
     public static final int DFLT_SOCK_BUF_SIZE = 32 * 1024;


[06/24] ignite git commit: IGNITE-4904 .NET: DML Delete via LINQ

Posted by sb...@apache.org.
IGNITE-4904 .NET: DML Delete via LINQ

This closes #2009


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

Branch: refs/heads/ignite-5075-cc
Commit: d38ca8b1004effefa5126981f434649d26db1e68
Parents: 279f35b
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri May 26 13:02:01 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri May 26 13:02:01 2017 +0300

----------------------------------------------------------------------
 .../Cache/Query/CacheLinqTest.cs                | 70 +++++++++++++++-
 .../Apache.Ignite.Linq.csproj                   |  3 +
 .../Apache.Ignite.Linq/CacheExtensions.cs       | 65 +++++++++++++++
 .../Impl/CacheQueryModelVisitor.cs              | 60 +++++++++++--
 .../Apache.Ignite.Linq/Impl/CacheQueryParser.cs | 21 ++++-
 .../Impl/Dml/RemoveAllExpressionNode.cs         | 88 ++++++++++++++++++++
 .../Impl/Dml/RemoveAllResultOperator.cs         | 61 ++++++++++++++
 .../dotnet/Apache.Ignite.sln.DotSettings        |  1 +
 8 files changed, 359 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d38ca8b1/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
index cb3fece..b603d75 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
@@ -37,6 +37,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Cache.Query;
+    using Apache.Ignite.Core.Common;
     using Apache.Ignite.Linq;
     using NUnit.Framework;
 
@@ -1269,7 +1270,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             var cache = GetPersonCache();
 
             // Check regular query
-            var query = (ICacheQueryable) cache.AsCacheQueryable(new QueryOptions
+            var query = cache.AsCacheQueryable(new QueryOptions
             {
                 Local = true,
                 PageSize = 999,
@@ -1277,7 +1278,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
                 Timeout = TimeSpan.FromSeconds(2.5),
                 ReplicatedOnly = true,
                 Colocated = true
-            }).Where(x => x.Key > 10);
+            }).Where(x => x.Key > 10).ToCacheQueryable();
 
             Assert.AreEqual(cache.Name, query.CacheName);
             Assert.AreEqual(cache.Ignite, query.Ignite);
@@ -1325,7 +1326,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             var distrQuery = cache.AsCacheQueryable(new QueryOptions {EnableDistributedJoins = true})
                 .Where(x => x.Key > 10 && x.Value.Age > 20 && x.Value.Name.Contains("x"));
 
-            query = (ICacheQueryable) distrQuery;
+            query = distrQuery.ToCacheQueryable();
 
             Assert.IsTrue(query.GetFieldsQuery().EnableDistributedJoins);
 
@@ -1424,6 +1425,69 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         }
 
         /// <summary>
+        /// Tests the RemoveAll extension.
+        /// </summary>
+        [Test]
+        public void TestRemoveAll()
+        {
+            // Use new cache to avoid touching static data.
+            var cache = Ignition.GetIgnite().CreateCache<int, Person>(new CacheConfiguration("deleteAllTest",
+                    new QueryEntity(typeof(int), typeof(Person))));
+
+            Enumerable.Range(1, 10).ToList().ForEach(x => cache.Put(x, new Person(x, x.ToString())));
+            
+            var queryable = cache.AsCacheQueryable();
+
+            Func<int[]> getKeys = () => cache.Select(x => x.Key).OrderBy(x => x).ToArray();
+
+            // Without predicate.
+            var res = queryable.Where(x => x.Key < 3).RemoveAll();
+            Assert.AreEqual(2, res);
+            Assert.AreEqual(Enumerable.Range(3, 8), getKeys());
+
+            // With predicate.
+            res = queryable.RemoveAll(x => x.Key < 7);
+            Assert.AreEqual(4, res);
+            Assert.AreEqual(Enumerable.Range(7, 4), getKeys());
+
+            // Subquery-style join.
+            var ids = GetPersonCache().AsCacheQueryable().Where(x => x.Key == 7).Select(x => x.Key);
+
+            res = queryable.Where(x => ids.Contains(x.Key)).RemoveAll();
+            Assert.AreEqual(1, res);
+            Assert.AreEqual(Enumerable.Range(8, 3), getKeys());
+
+            // Row number limit.
+            res = queryable.Take(2).RemoveAll();
+            Assert.AreEqual(2, res);
+            Assert.AreEqual(1, getKeys().Length);
+
+            // Unconditional.
+            queryable.RemoveAll();
+            Assert.AreEqual(0, cache.GetSize());
+
+            // Skip is not supported with DELETE.
+            var nex = Assert.Throws<NotSupportedException>(() => queryable.Skip(1).RemoveAll());
+            Assert.AreEqual(
+                "RemoveAll can not be combined with result operators (other than Take): SkipResultOperator",
+                nex.Message);
+
+            // Multiple result operators are not supported with DELETE.
+            nex = Assert.Throws<NotSupportedException>(() => queryable.Skip(1).Take(1).RemoveAll());
+            Assert.AreEqual(
+                "RemoveAll can not be combined with result operators (other than Take): SkipResultOperator, " +
+                "TakeResultOperator, RemoveAllResultOperator", nex.Message);
+
+            // Joins are not supported in H2.
+            var qry = queryable
+                .Where(x => x.Key == 7)
+                .Join(GetPersonCache().AsCacheQueryable(), p => p.Key, p => p.Key, (p1, p2) => p1);
+
+            var ex = Assert.Throws<IgniteException>(() => qry.RemoveAll());
+            Assert.AreEqual("Failed to parse query", ex.Message.Substring(0, 21));
+        }
+
+        /// <summary>
         /// Gets the person cache.
         /// </summary>
         /// <returns></returns>

http://git-wip-us.apache.org/repos/asf/ignite/blob/d38ca8b1/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj b/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj
index a7ec402..f4949d7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj
@@ -63,6 +63,8 @@
     <Compile Include="Impl\CacheQueryExpressionVisitor.cs" />
     <Compile Include="Impl\CacheQueryModelVisitor.cs" />
     <Compile Include="Impl\CacheQueryParser.cs" />
+    <Compile Include="Impl\Dml\RemoveAllExpressionNode.cs" />
+    <Compile Include="Impl\Dml\RemoveAllResultOperator.cs" />
     <Compile Include="Impl\ICacheQueryableInternal.cs" />
     <Compile Include="Impl\MethodVisitor.cs" />
     <Compile Include="Impl\QueryData.cs" />
@@ -83,6 +85,7 @@
       <Name>Apache.Ignite.Core</Name>
     </ProjectReference>
   </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/d38ca8b1/modules/platforms/dotnet/Apache.Ignite.Linq/CacheExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/CacheExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/CacheExtensions.cs
index 2c609c6..f759dbb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/CacheExtensions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/CacheExtensions.cs
@@ -17,11 +17,15 @@
 
 namespace Apache.Ignite.Linq
 {
+    using System;
+    using System.Diagnostics.CodeAnalysis;
     using System.Linq;
+    using System.Linq.Expressions;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Configuration;
     using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Linq.Impl;
+    using Apache.Ignite.Linq.Impl.Dml;
 
     /// <summary>
     /// Extensions methods for <see cref="ICache{TK,TV}"/>.
@@ -126,5 +130,66 @@ namespace Apache.Ignite.Linq
 
             return new CacheQueryable<TKey, TValue>(cache, queryOptions);
         }
+
+        /// <summary>
+        /// Casts this query to <see cref="ICacheQueryable"/>.
+        /// </summary>
+        public static ICacheQueryable ToCacheQueryable<T>(this IQueryable<T> query)
+        {
+            IgniteArgumentCheck.NotNull(query, "query");
+
+            return (ICacheQueryable) query;
+        }
+
+        /// <summary>
+        /// Removes all rows that are matched by the specified query.
+        /// <para />
+        /// This method results in "DELETE FROM" distributed SQL query, performing bulk delete 
+        /// (as opposed to fetching all rows locally).
+        /// </summary>
+        /// <typeparam name="TKey">Key type.</typeparam>
+        /// <typeparam name="TValue">Value type.</typeparam>
+        /// <param name="query">The query.</param>
+        /// <returns>Affected row count.</returns>
+        [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods",
+            Justification = "Validation is present.")]
+        public static int RemoveAll<TKey, TValue>(this IQueryable<ICacheEntry<TKey, TValue>> query)
+        {
+            IgniteArgumentCheck.NotNull(query, "query");
+
+            var method = RemoveAllExpressionNode.RemoveAllMethodInfo.MakeGenericMethod(typeof(TKey), typeof(TValue));
+
+            return query.Provider.Execute<int>(Expression.Call(null, method, query.Expression));
+        }
+
+        /// <summary>
+        /// Deletes all rows that are matched by the specified query.
+        /// <para />
+        /// This method results in "DELETE FROM" distributed SQL query, performing bulk delete
+        /// (as opposed to fetching all rows locally).
+        /// </summary>
+        /// <typeparam name="TKey">Key type.</typeparam>
+        /// <typeparam name="TValue">Value type.</typeparam>
+        /// <param name="query">The query.</param>
+        /// <param name="predicate">The predicate.</param>
+        /// <returns>
+        /// Affected row count.
+        /// </returns>
+        [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters",
+            Justification = "Only specified type of predicate is valid.")]
+        [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods",
+            Justification = "Validation is present.")]
+        public static int RemoveAll<TKey, TValue>(this IQueryable<ICacheEntry<TKey, TValue>> query, 
+            Expression<Func<ICacheEntry<TKey, TValue>, bool>> predicate)
+        {
+            IgniteArgumentCheck.NotNull(query, "query");
+            IgniteArgumentCheck.NotNull(predicate, "predicate");
+
+            var method = RemoveAllExpressionNode.RemoveAllPredicateMethodInfo
+                .MakeGenericMethod(typeof(TKey), typeof(TValue));
+
+            return query.Provider.Execute<int>(Expression.Call(null, method, query.Expression,
+                Expression.Quote(predicate)));
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d38ca8b1/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
index f566caa..12b9502 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
@@ -26,6 +26,7 @@ namespace Apache.Ignite.Linq.Impl
     using System.Linq;
     using System.Linq.Expressions;
     using System.Text;
+    using Apache.Ignite.Linq.Impl.Dml;
     using Remotion.Linq;
     using Remotion.Linq.Clauses;
     using Remotion.Linq.Clauses.Expressions;
@@ -100,22 +101,69 @@ namespace Apache.Ignite.Linq.Impl
         {
             _aliases.Push();
 
-            // SELECT
-            _builder.Append("select ");
+            var hasDelete = VisitRemoveOperator(queryModel);
 
-            // TOP 1 FLD1, FLD2
-            VisitSelectors(queryModel, includeAllFields);
+            if (!hasDelete)
+            {
+                // SELECT
+                _builder.Append("select ");
+
+                // TOP 1 FLD1, FLD2
+                VisitSelectors(queryModel, includeAllFields);
+            }
 
             // FROM ... WHERE ... JOIN ...
             base.VisitQueryModel(queryModel);
 
-            // UNION ...
-            ProcessResultOperatorsEnd(queryModel);
+            if (!hasDelete)
+            {
+                // UNION ...
+                ProcessResultOperatorsEnd(queryModel);
+            }
 
             _aliases.Pop();
         }
 
         /// <summary>
+        /// Visits the remove operator. Returns true if it is present.
+        /// </summary>
+        private bool VisitRemoveOperator(QueryModel queryModel)
+        {
+            var resultOps = queryModel.ResultOperators;
+
+            if (resultOps.LastOrDefault() is RemoveAllResultOperator)
+            {
+                _builder.Append("delete ");
+
+                if (resultOps.Count == 2)
+                {
+                    var resOp = resultOps[0] as TakeResultOperator;
+
+                    if (resOp == null)
+                    {
+                        throw new NotSupportedException(
+                            "RemoveAll can not be combined with result operators (other than Take): " +
+                            resultOps[0].GetType().Name);
+                    }
+
+                    _builder.Append("top ");
+                    BuildSqlExpression(resOp.Count);
+                    _builder.Append(" ");
+                }
+                else if (resultOps.Count > 2)
+                {
+                    throw new NotSupportedException(
+                        "RemoveAll can not be combined with result operators (other than Take): " +
+                        string.Join(", ", resultOps.Select(x => x.GetType().Name)));
+                }
+
+                return true;
+            }
+                
+            return false;
+        }
+
+        /// <summary>
         /// Visits the selectors.
         /// </summary>
         public void VisitSelectors(QueryModel queryModel, bool includeAllFields)

http://git-wip-us.apache.org/repos/asf/ignite/blob/d38ca8b1/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryParser.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryParser.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryParser.cs
index 794ef2e..17ec0a3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryParser.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryParser.cs
@@ -18,10 +18,12 @@
 namespace Apache.Ignite.Linq.Impl
 {
     using System.Threading;
+    using Apache.Ignite.Linq.Impl.Dml;
     using Remotion.Linq.Parsing.ExpressionVisitors.Transformation;
     using Remotion.Linq.Parsing.ExpressionVisitors.TreeEvaluation;
     using Remotion.Linq.Parsing.Structure;
     using Remotion.Linq.Parsing.Structure.ExpressionTreeProcessors;
+    using Remotion.Linq.Parsing.Structure.NodeTypeProviders;
 
     /// <summary>
     /// Cache query parser.
@@ -49,12 +51,29 @@ namespace Apache.Ignite.Linq.Impl
 
             var proc = CreateCompoundProcessor(transformerRegistry);
 
-            var parser = new ExpressionTreeParser(ExpressionTreeParser.CreateDefaultNodeTypeProvider(), proc);
+            var parser = new ExpressionTreeParser(CreateNodeTypeProvider(), proc);
 
             return new QueryParser(parser);
         }
 
         /// <summary>
+        /// Creates the node type provider.
+        /// </summary>
+        private static INodeTypeProvider CreateNodeTypeProvider()
+        {
+            var methodInfoRegistry = MethodInfoBasedNodeTypeRegistry.CreateFromRelinqAssembly();
+
+            methodInfoRegistry.Register(RemoveAllExpressionNode.GetSupportedMethods(), 
+                typeof(RemoveAllExpressionNode));
+
+            return new CompoundNodeTypeProvider(new INodeTypeProvider[]
+            {
+                methodInfoRegistry,
+                MethodNameBasedNodeTypeRegistry.CreateFromRelinqAssembly()
+            });
+        }
+
+        /// <summary>
         /// Creates CompoundExpressionTreeProcessor.
         /// </summary>
         private static CompoundExpressionTreeProcessor CreateCompoundProcessor(

http://git-wip-us.apache.org/repos/asf/ignite/blob/d38ca8b1/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/Dml/RemoveAllExpressionNode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/Dml/RemoveAllExpressionNode.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/Dml/RemoveAllExpressionNode.cs
new file mode 100644
index 0000000..53674ac
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/Dml/RemoveAllExpressionNode.cs
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Linq.Impl.Dml
+{
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
+    using System.Linq.Expressions;
+    using System.Reflection;
+    using Apache.Ignite.Core.Cache;
+    using Remotion.Linq.Clauses;
+    using Remotion.Linq.Parsing.Structure.IntermediateModel;
+
+    /// <summary>
+    /// Represents a <see cref="MethodCallExpression"/> for 
+    /// <see cref="CacheLinqExtensions.RemoveAll{TKey,TValue}(IQueryable{ICacheEntry{TKey,TValue}})"/>.
+    /// When user calls RemoveAll, this node is generated.
+    /// </summary>
+    internal sealed class RemoveAllExpressionNode : ResultOperatorExpressionNodeBase
+    {
+        /** */
+        private static readonly MethodInfo[] RemoveAllMethodInfos = typeof(CacheLinqExtensions)
+            .GetMethods().Where(x => x.Name == "RemoveAll").ToArray();
+
+        /// <summary>
+        /// The RemoveAll() method.
+        /// </summary>
+        public static readonly MethodInfo RemoveAllMethodInfo =
+            RemoveAllMethodInfos.Single(x => x.GetParameters().Length == 1);
+
+        /// <summary>
+        /// The RemoveAll(pred) method.
+        /// </summary>
+        public static readonly MethodInfo RemoveAllPredicateMethodInfo =
+            RemoveAllMethodInfos.Single(x => x.GetParameters().Length == 2);
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="RemoveAllExpressionNode"/> class.
+        /// </summary>
+        /// <param name="parseInfo">The parse information.</param>
+        /// <param name="optionalPredicate">The optional predicate.</param>
+        /// <param name="optionalSelector">The optional selector.</param>
+        public RemoveAllExpressionNode(MethodCallExpressionParseInfo parseInfo,
+            LambdaExpression optionalPredicate, LambdaExpression optionalSelector)
+            : base(parseInfo, optionalPredicate, optionalSelector)
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        [ExcludeFromCodeCoverage]
+        public override Expression Resolve(ParameterExpression inputParameter, Expression expressionToBeResolved,
+            ClauseGenerationContext clauseGenerationContext)
+        {
+            throw CreateResolveNotSupportedException();
+        }
+
+        /** <inheritdoc /> */
+        protected override ResultOperatorBase CreateResultOperator(ClauseGenerationContext clauseGenerationContext)
+        {
+            return new RemoveAllResultOperator();
+        }
+
+        /// <summary>
+        /// Gets the supported methods.
+        /// </summary>
+        public static IEnumerable<MethodInfo> GetSupportedMethods()
+        {
+            yield return RemoveAllMethodInfo;
+            yield return RemoveAllPredicateMethodInfo;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/d38ca8b1/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/Dml/RemoveAllResultOperator.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/Dml/RemoveAllResultOperator.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/Dml/RemoveAllResultOperator.cs
new file mode 100644
index 0000000..76789cb
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/Dml/RemoveAllResultOperator.cs
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Linq.Impl.Dml
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
+    using System.Linq.Expressions;
+    using Apache.Ignite.Core.Cache;
+    using Remotion.Linq.Clauses;
+    using Remotion.Linq.Clauses.ResultOperators;
+    using Remotion.Linq.Clauses.StreamedData;
+
+    /// <summary>
+    /// Represents an operator for <see cref="CacheLinqExtensions.RemoveAll{TK,TV}(IQueryable{ICacheEntry{TK,TV}})"/>.
+    /// </summary>
+    internal sealed class RemoveAllResultOperator : ValueFromSequenceResultOperatorBase
+    {
+        /** <inheritdoc /> */
+        public override IStreamedDataInfo GetOutputDataInfo(IStreamedDataInfo inputInfo)
+        {
+            return new StreamedScalarValueInfo(typeof(int));
+        }
+
+        /** <inheritdoc /> */
+        [ExcludeFromCodeCoverage]
+        public override ResultOperatorBase Clone(CloneContext cloneContext)
+        {
+            return new RemoveAllResultOperator();
+        }
+
+        /** <inheritdoc /> */
+        [ExcludeFromCodeCoverage]
+        public override void TransformExpressions(Func<Expression, Expression> transformation)
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        [ExcludeFromCodeCoverage]
+        public override StreamedValue ExecuteInMemory<T>(StreamedSequence sequence)
+        {
+            throw new NotSupportedException("RemoveAll is not supported for in-memory sequences.");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d38ca8b1/modules/platforms/dotnet/Apache.Ignite.sln.DotSettings
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.sln.DotSettings b/modules/platforms/dotnet/Apache.Ignite.sln.DotSettings
index 078e9fb..9d5b728 100644
--- a/modules/platforms/dotnet/Apache.Ignite.sln.DotSettings
+++ b/modules/platforms/dotnet/Apache.Ignite.sln.DotSettings
@@ -7,4 +7,5 @@
 	<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AddImportsToDeepestScope/@EntryValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">True</s:Boolean>
 	<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertClosureToMethodGroup/@EntryIndexedValue">DO_NOT_SHOW</s:String>
+	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EXml_002ECodeStyle_002EFormatSettingsUpgrade_002EXmlMoveToCommonFormatterSettingsUpgrade/@EntryIndexedValue">True</s:Boolean>
 </wpf:ResourceDictionary>
\ No newline at end of file


[18/24] ignite git commit: IGNITE-5313: Removed usages of H2Schema.cacheName with cache-agnostic analogs. The last usage is to be removed as a part of IGNITE-5319. This closes #2021.

Posted by sb...@apache.org.
IGNITE-5313: Removed usages of H2Schema.cacheName with cache-agnostic analogs. The last usage is to be removed as a part of IGNITE-5319. This closes #2021.


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

Branch: refs/heads/ignite-5075-cc
Commit: fb12f0facc13b90e701cd77d290dccdb827b13a4
Parents: aad3b0c
Author: devozerov <vo...@gridgain.com>
Authored: Sun May 28 14:20:03 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Sun May 28 14:20:03 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/GridKernalContext.java      |  1 +
 .../ignite/internal/GridKernalContextImpl.java  |  1 +
 .../internal/binary/BinaryEnumObjectImpl.java   |  6 +--
 .../internal/binary/BinaryObjectImpl.java       |  6 +--
 .../binary/BinaryObjectOffheapImpl.java         |  6 +--
 .../internal/processors/cache/CacheObject.java  |  6 +--
 .../cache/CacheObjectByteArrayImpl.java         |  6 +--
 .../processors/cache/CacheObjectImpl.java       |  6 +--
 .../processors/cache/GridCacheContext.java      |  8 ----
 .../processors/cache/KeyCacheObjectImpl.java    |  6 +--
 .../binary/CacheObjectBinaryProcessorImpl.java  | 23 +++++------
 .../processors/query/GridQueryProcessor.java    | 13 ++++++
 .../internal/GridAffinityNoCacheSelfTest.java   |  7 ++--
 .../IgniteIncompleteCacheObjectSelfTest.java    |  8 ++--
 .../database/FreeListImplSelfTest.java          |  7 ++--
 .../query/h2/DmlStatementsProcessor.java        |  5 ++-
 .../query/h2/H2ResultSetIterator.java           |  4 +-
 .../processors/query/h2/H2RowDescriptor.java    | 19 ++++-----
 .../processors/query/h2/H2TableDescriptor.java  | 22 +++++++---
 .../processors/query/h2/H2TableEngine.java      |  2 +-
 .../processors/query/h2/IgniteH2Indexing.java   | 42 +++++---------------
 .../query/h2/opt/GridH2ValueCacheObject.java    | 32 ++++++---------
 .../query/h2/twostep/GridMapQueryExecutor.java  | 16 +++-----
 .../h2/twostep/GridReduceQueryExecutor.java     |  2 +-
 .../query/h2/twostep/msg/GridH2CacheObject.java | 39 +++---------------
 .../h2/GridIndexingSpiAbstractSelfTest.java     |  6 +--
 26 files changed, 126 insertions(+), 173 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
index 7a01200..ef4001f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.managers.failover.GridFailoverManager;
 import org.apache.ignite.internal.managers.indexing.GridIndexingManager;
 import org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager;
 import org.apache.ignite.internal.processors.affinity.GridAffinityProcessor;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
 import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
 import org.apache.ignite.internal.processors.closure.GridClosureProcessor;

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index 262c5eb..42a9b2c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.managers.indexing.GridIndexingManager;
 import org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager;
 import org.apache.ignite.internal.processors.affinity.GridAffinityProcessor;
 import org.apache.ignite.internal.processors.cache.CacheConflictResolutionManager;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
 import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
 import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/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 6a1ad6e..12a0fc3 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
@@ -286,7 +286,7 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
     }
 
     /** {@inheritDoc} */
-    @Override public byte[] valueBytes(CacheObjectContext cacheCtx) throws IgniteCheckedException {
+    @Override public byte[] valueBytes(CacheObjectValueContext cacheCtx) throws IgniteCheckedException {
         if (valBytes != null)
             return valBytes;
 
@@ -335,12 +335,12 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
     }
 
     /** {@inheritDoc} */
-    @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+    @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         this.ctx = ((CacheObjectBinaryProcessorImpl)ctx.kernalContext().cacheObjects()).binaryContext();
     }
 
     /** {@inheritDoc} */
-    @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException {
         // No-op.
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
index d0d0699..adbb9cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
@@ -146,7 +146,7 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
     }
 
     /** {@inheritDoc} */
-    @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException {
         if (detached())
             return array();
 
@@ -188,12 +188,12 @@ public final class BinaryObjectImpl extends BinaryObjectExImpl implements Extern
     }
 
     /** {@inheritDoc} */
-    @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+    @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         this.ctx = ((CacheObjectBinaryProcessorImpl)ctx.kernalContext().cacheObjects()).binaryContext();
     }
 
     /** {@inheritDoc} */
-    @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException {
         // No-op.
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/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 0a0a7b1..3e73e58 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
@@ -450,7 +450,7 @@ public class BinaryObjectOffheapImpl extends BinaryObjectExImpl implements Exter
     }
 
     /** {@inheritDoc} */
-    @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException {
         throw new UnsupportedOperationException();
     }
 
@@ -460,12 +460,12 @@ public class BinaryObjectOffheapImpl extends BinaryObjectExImpl implements Exter
     }
 
     /** {@inheritDoc} */
-    @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+    @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
-    @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException {
         throw new UnsupportedOperationException();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
index 8faaa03..3bc2a6d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
@@ -50,7 +50,7 @@ public interface CacheObject extends Message {
      * @return Value bytes.
      * @throws IgniteCheckedException If failed.
      */
-    public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException;
+    public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException;
 
     /**
      * @param ctx Cache object context.
@@ -111,11 +111,11 @@ public interface CacheObject extends Message {
      * @param ldr Class loader.
      * @throws IgniteCheckedException If failed.
      */
-    public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException;
+    public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException;
 
     /**
      * @param ctx Context.
      * @throws IgniteCheckedException If failed.
      */
-    public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException;
+    public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
index 6a13f8d..414bebb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
@@ -57,7 +57,7 @@ public class CacheObjectByteArrayImpl implements CacheObject, Externalizable {
     }
 
     /** {@inheritDoc} */
-    @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+    @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         // No-op.
     }
 
@@ -70,7 +70,7 @@ public class CacheObjectByteArrayImpl implements CacheObject, Externalizable {
     }
 
     /** {@inheritDoc} */
-    @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException {
         return val;
     }
 
@@ -114,7 +114,7 @@ public class CacheObjectByteArrayImpl implements CacheObject, Externalizable {
     }
 
     /** {@inheritDoc} */
-    @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException {
         // No-op.
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
index 76f354a..2124a97 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
@@ -101,7 +101,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException {
         if (valBytes == null)
             valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val);
 
@@ -109,7 +109,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException {
         assert val != null || valBytes != null;
 
         if (valBytes == null)
@@ -117,7 +117,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+    @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         assert val != null || valBytes != null;
 
         if (val == null && ctx.storeValue())

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/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 e637122..4c1d615 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
@@ -1417,14 +1417,6 @@ public class GridCacheContext<K, V> implements Externalizable {
     }
 
     /**
-     * @return {@code True} if should use offheap (PageMemory) index.
-     */
-    public boolean offheapIndex() {
-        // TODO GG-10884.
-        return true;
-    }
-
-    /**
      * @return {@code True} if store read-through mode is enabled.
      */
     public boolean readThrough() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
index c50672b..1f4e790 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java
@@ -73,7 +73,7 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb
     }
 
     /** {@inheritDoc} */
-    @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException {
         if (valBytes == null)
             valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val);
 
@@ -178,13 +178,13 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb
     }
 
     /** {@inheritDoc} */
-    @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+    @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException {
         if (valBytes == null)
             valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val);
     }
 
     /** {@inheritDoc} */
-    @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+    @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         if (val == null) {
             assert valBytes != null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/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 5567809..a2d319f 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
@@ -499,7 +499,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
         BinaryMetadataHolder holder = metadataLocCache.get(typeId);
 
         if (ctx.clientNode()) {
-            if (holder == null || (holder != null && !holder.metadata().hasSchema(schemaId))) {
+            if (holder == null || !holder.metadata().hasSchema(schemaId)) {
                 try {
                     transport.requestUpToDateMetadata(typeId).get();
 
@@ -737,7 +737,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
 
     /** {@inheritDoc} */
     @Override public byte[] marshal(CacheObjectValueContext ctx, Object val) throws IgniteCheckedException {
-        if (!((CacheObjectBinaryContext)ctx).binaryEnabled() || binaryMarsh == null)
+        if (!ctx.binaryEnabled() || binaryMarsh == null)
             return super.marshal(ctx, val);
 
         byte[] arr = binaryMarsh.marshal(val);
@@ -750,20 +750,16 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     /** {@inheritDoc} */
     @Override public Object unmarshal(CacheObjectValueContext ctx, byte[] bytes, ClassLoader clsLdr)
         throws IgniteCheckedException {
-        if (!((CacheObjectBinaryContext)ctx).binaryEnabled() || binaryMarsh == null)
+        if (!ctx.binaryEnabled() || binaryMarsh == null)
             return super.unmarshal(ctx, bytes, clsLdr);
 
         return binaryMarsh.unmarshal(bytes, clsLdr);
     }
 
     /** {@inheritDoc} */
-    @Override public KeyCacheObject toCacheKeyObject(
-        CacheObjectContext ctx,
-        @Nullable GridCacheContext cctx,
-        Object obj,
-        boolean userObj
-    ) {
-        if (!((CacheObjectBinaryContext)ctx).binaryEnabled())
+    @Override public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, @Nullable GridCacheContext cctx,
+        Object obj, boolean userObj) {
+        if (!ctx.binaryEnabled())
             return super.toCacheKeyObject(ctx, cctx, obj, userObj);
 
         if (obj instanceof KeyCacheObject) {
@@ -794,7 +790,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     /** {@inheritDoc} */
     @Nullable @Override public CacheObject toCacheObject(CacheObjectContext ctx, @Nullable Object obj,
         boolean userObj) {
-        if (!((CacheObjectBinaryContext)ctx).binaryEnabled())
+        if (!ctx.binaryEnabled())
             return super.toCacheObject(ctx, obj, userObj);
 
         if (obj == null || obj instanceof CacheObject)
@@ -819,7 +815,8 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     }
 
     /** {@inheritDoc} */
-    @Override public KeyCacheObject toKeyCacheObject(CacheObjectContext ctx, byte type, byte[] bytes) throws IgniteCheckedException {
+    @Override public KeyCacheObject toKeyCacheObject(CacheObjectContext ctx, byte type, byte[] bytes)
+        throws IgniteCheckedException {
         if (type == BinaryObjectImpl.TYPE_BINARY)
             return new BinaryObjectImpl(binaryContext(), bytes, 0);
 
@@ -828,7 +825,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
 
     /** {@inheritDoc} */
     @Override public Object unwrapTemporary(GridCacheContext ctx, Object obj) throws BinaryObjectException {
-        if (!((CacheObjectBinaryContext)ctx.cacheObjectContext()).binaryEnabled())
+        if (!ctx.cacheObjectContext().binaryEnabled())
             return obj;
 
         if (obj instanceof BinaryObjectOffheapImpl)

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 65151c7..f3da6d0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -145,6 +145,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     /** */
     private final GridQueryIndexing idx;
 
+    /** Value object context. */
+    private final CacheQueryObjectValueContext valCtx;
+
     /** All indexes. */
     private final ConcurrentMap<QueryIndexKey, QueryIndexDescriptorImpl> idxs = new ConcurrentHashMap<>();
 
@@ -203,6 +206,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         else
             idx = INDEXING.inClassPath() ? U.<GridQueryIndexing>newInstance(INDEXING.className()) : null;
 
+        valCtx = new CacheQueryObjectValueContext(ctx);
+
         ioLsnr = new GridMessageListener() {
             @Override public void onMessage(UUID nodeId, Object msg) {
                 if (msg instanceof SchemaOperationStatusMessage) {
@@ -2375,6 +2380,14 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         }
     }
 
+
+    /**
+     * @return Value object context.
+     */
+    public CacheQueryObjectValueContext objectContext() {
+        return valCtx;
+    }
+
     /**
      * @param ver Version.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
index e144325..a974cdb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
@@ -243,7 +243,7 @@ public class GridAffinityNoCacheSelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+        @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException {
             throw new UnsupportedOperationException();
         }
 
@@ -284,12 +284,13 @@ public class GridAffinityNoCacheSelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+        @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr)
+            throws IgniteCheckedException {
             throw new UnsupportedOperationException();
         }
 
         /** {@inheritDoc} */
-        @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+        @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException {
             throw new UnsupportedOperationException();
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
index 77b6836..5b6d7f3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
@@ -107,7 +107,7 @@ public class IgniteIncompleteCacheObjectSelfTest extends GridCommonAbstractTest
         }
 
         /** {@inheritDoc} */
-        @Override public byte[] valueBytes(final CacheObjectContext ctx) throws IgniteCheckedException {
+        @Override public byte[] valueBytes(final CacheObjectValueContext ctx) throws IgniteCheckedException {
             return new byte[0];
         }
 
@@ -148,13 +148,13 @@ public class IgniteIncompleteCacheObjectSelfTest extends GridCommonAbstractTest
         }
 
         /** {@inheritDoc} */
-        @Override public void finishUnmarshal(final CacheObjectContext ctx,
-            final ClassLoader ldr) throws IgniteCheckedException {
+        @Override public void finishUnmarshal(final CacheObjectValueContext ctx, final ClassLoader ldr)
+            throws IgniteCheckedException {
             // No-op
         }
 
         /** {@inheritDoc} */
-        @Override public void prepareMarshal(final CacheObjectContext ctx) throws IgniteCheckedException {
+        @Override public void prepareMarshal(final CacheObjectValueContext ctx) throws IgniteCheckedException {
             // No-op
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
index a487218..7ccddb7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
@@ -469,7 +469,7 @@ public class FreeListImplSelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+        @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException {
             return data;
         }
 
@@ -517,12 +517,13 @@ public class FreeListImplSelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+        @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr)
+            throws IgniteCheckedException {
             assert false;
         }
 
         /** {@inheritDoc} */
-        @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+        @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException {
             assert false;
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
index 352fe85..d48c373 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
@@ -282,7 +282,8 @@ public class DmlStatementsProcessor {
             QueryCursorImpl<List<?>> stepCur = new QueryCursorImpl<>(new Iterable<List<?>>() {
                 @Override public Iterator<List<?>> iterator() {
                     try {
-                        return new GridQueryCacheObjectsIterator(res.iterator(), idx.valueContext(), cctx.keepBinary());
+                        return new GridQueryCacheObjectsIterator(res.iterator(), idx.objectContext(),
+                            cctx.keepBinary());
                     }
                     catch (IgniteCheckedException e) {
                         throw new IgniteException(e);
@@ -372,7 +373,7 @@ public class DmlStatementsProcessor {
             cur = new QueryCursorImpl<>(new Iterable<List<?>>() {
                 @Override public Iterator<List<?>> iterator() {
                     try {
-                        return new GridQueryCacheObjectsIterator(res.iterator(), idx.valueContext(), cctx.keepBinary());
+                        return new GridQueryCacheObjectsIterator(res.iterator(), idx.objectContext(), cctx.keepBinary());
                     }
                     catch (IgniteCheckedException e) {
                         throw new IgniteException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIterator.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIterator.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIterator.java
index 494f069..7b447dc 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIterator.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIterator.java
@@ -120,9 +120,7 @@ public abstract class H2ResultSetIterator<T> extends GridCloseableIteratorAdapte
                     if (val instanceof GridH2ValueCacheObject) {
                         GridH2ValueCacheObject valCacheObj = (GridH2ValueCacheObject)values[c];
 
-                        GridCacheContext cctx = valCacheObj.getCacheContext();
-
-                        row[c] = valCacheObj.getObject(cctx != null && cctx.needValueCopy());
+                        row[c] = valCacheObj.getObject(true);
                     }
                     else
                         row[c] = val.getObject();

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
index fbc9d6c..327ca14 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2RowDescriptor.java
@@ -218,9 +218,9 @@ public class H2RowDescriptor implements GridH2RowDescriptor {
             CacheObject co = (CacheObject)obj;
 
             if (type == Value.JAVA_OBJECT)
-                return new GridH2ValueCacheObject(idx.cacheContext(schema.cacheName()), co);
+                return new GridH2ValueCacheObject(co, idx.objectContext());
 
-            obj = co.value(idx.objectContext(schema.cacheName()), false);
+            obj = co.value(idx.objectContext(), false);
         }
 
         switch (type) {
@@ -280,8 +280,7 @@ public class H2RowDescriptor implements GridH2RowDescriptor {
 
     /** {@inheritDoc} */
     @Override public GridH2Row createRow(KeyCacheObject key, int partId, @Nullable CacheObject val,
-        GridCacheVersion ver,
-        long expirationTime) throws IgniteCheckedException {
+        GridCacheVersion ver, long expirationTime) throws IgniteCheckedException {
         GridH2Row row;
 
         try {
@@ -298,15 +297,11 @@ public class H2RowDescriptor implements GridH2RowDescriptor {
                 "or configure key type as common super class for all actual keys for this value type.", e);
         }
 
-        GridCacheContext cctx = idx.cacheContext(schema.cacheName());
+        row.ver = ver;
 
-        if (cctx.offheapIndex()) {
-            row.ver = ver;
-
-            row.key = key;
-            row.val = val;
-            row.partId = partId;
-        }
+        row.key = key;
+        row.val = val;
+        row.partId = partId;
 
         return row;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
index 2440788..eedfc3a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableDescriptor.java
@@ -59,6 +59,9 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
     /** */
     private final H2Schema schema;
 
+    /** Cache name. */
+    private final String cacheName;
+
     /** */
     private GridH2Table tbl;
 
@@ -74,11 +77,13 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
      * @param idx Indexing.
      * @param schema Schema.
      * @param type Type descriptor.
+     * @param cacheName Cache name.
      */
-    H2TableDescriptor(IgniteH2Indexing idx, H2Schema schema, GridQueryTypeDescriptor type) {
+    H2TableDescriptor(IgniteH2Indexing idx, H2Schema schema, GridQueryTypeDescriptor type, String cacheName) {
         this.idx = idx;
         this.type = type;
         this.schema = schema;
+        this.cacheName = cacheName;
 
         fullTblName = H2Utils.withQuotes(schema.schemaName()) + "." + H2Utils.withQuotes(type.tableName());
     }
@@ -140,6 +145,13 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
     }
 
     /**
+     * @return Cache name.
+     */
+    String cacheName() {
+        return cacheName;
+    }
+
+    /**
      * @return Type.
      */
     GridQueryTypeDescriptor type() {
@@ -167,7 +179,7 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
     H2RowFactory rowFactory(GridH2RowDescriptor rowDesc) {
         GridCacheContext cctx = schema.cacheContext();
 
-        if (cctx.affinityNode() && cctx.offheapIndex())
+        if (cctx.affinityNode())
             return new H2RowFactory(rowDesc, cctx);
 
         return null;
@@ -209,7 +221,7 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
 
         if (type().valueClass() == String.class) {
             try {
-                luceneIdx = new GridLuceneIndex(idx.kernalContext(), schema.offheap(), schema.cacheName(), type);
+                luceneIdx = new GridLuceneIndex(idx.kernalContext(), schema.offheap(), tbl.cacheName(), type);
             }
             catch (IgniteCheckedException e1) {
                 throw new IgniteException(e1);
@@ -222,7 +234,7 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
 
         if (textIdx != null) {
             try {
-                luceneIdx = new GridLuceneIndex(idx.kernalContext(), schema.offheap(), schema.cacheName(), type);
+                luceneIdx = new GridLuceneIndex(idx.kernalContext(), schema.offheap(), tbl.cacheName(), type);
             }
             catch (IgniteCheckedException e1) {
                 throw new IgniteException(e1);
@@ -319,7 +331,7 @@ public class H2TableDescriptor implements GridH2SystemIndexFactory {
     private Index createHashIndex(H2Schema schema, GridH2Table tbl, String idxName, List<IndexColumn> cols) {
         GridCacheContext cctx = schema.cacheContext();
 
-        if (cctx.affinityNode() && cctx.offheapIndex()) {
+        if (cctx.affinityNode()) {
             assert pkHashIdx == null : pkHashIdx;
 
             pkHashIdx = new H2PkHashIndex(cctx, tbl, idxName, cols);

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableEngine.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableEngine.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableEngine.java
index 4cf5166..db34064 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableEngine.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2TableEngine.java
@@ -82,7 +82,7 @@ public class H2TableEngine implements TableEngine {
 
     /** {@inheritDoc} */
     @Override public TableBase createTable(CreateTableData createTblData) {
-        resTbl0 = new GridH2Table(createTblData, rowDesc0, rowFactory0, tblDesc0, tblDesc0.schema().cacheName());
+        resTbl0 = new GridH2Table(createTblData, rowDesc0, rowFactory0, tblDesc0, tblDesc0.cacheName());
 
         return resTbl0;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 508c8be..1e19954 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -62,7 +62,6 @@ import org.apache.ignite.internal.jdbc2.JdbcSqlFieldsQuery;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
 import org.apache.ignite.internal.processors.cache.CacheObject;
-import org.apache.ignite.internal.processors.cache.CacheObjectContext;
 import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheAffinityManager;
@@ -579,27 +578,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             tbl.luceneIndex().store(k, v, ver, expirationTime);
     }
 
-    /**
-     * @param cacheName Cache name.
-     * @return Cache object context.
-     */
-    public CacheObjectContext objectContext(String cacheName) {
-        GridCacheContext cctx = cacheContext(cacheName);
-
-        return cctx != null ? cctx.cacheObjectContext() : null;
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @return Cache object context.
-     */
-    public GridCacheContext cacheContext(String cacheName) {
-        if (ctx == null)
-            return null;
-
-        return ctx.cache().internalCache(cacheName).context();
-    }
-
     /** {@inheritDoc} */
     @Override public void remove(String cacheName,
         GridQueryTypeDescriptor type,
@@ -1118,7 +1096,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             QueryCursorImpl<List<?>> cursor = new QueryCursorImpl<>(new Iterable<List<?>>() {
                 @Override public Iterator<List<?>> iterator() {
                     try {
-                        return new GridQueryCacheObjectsIterator(res.iterator(), valueContext(), keepBinary);
+                        return new GridQueryCacheObjectsIterator(res.iterator(), objectContext(), keepBinary);
                     }
                     catch (IgniteCheckedException e) {
                         throw new IgniteException(e);
@@ -1443,10 +1421,10 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                 if (tblCnt > 0) {
                     caches0.add(cctx.cacheId());
 
-                    for (QueryTable table : twoStepQry.tables()) {
-                        String tblCacheName = cacheName(table.schema());
+                    for (QueryTable tblKey : twoStepQry.tables()) {
+                        GridH2Table tbl = dataTable(tblKey);
 
-                        int cacheId = CU.cacheId(tblCacheName);
+                        int cacheId = CU.cacheId(tbl.cacheName());
 
                         caches0.add(cacheId);
                     }
@@ -1600,7 +1578,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
         H2Schema schema = schemas.get(schemaName);
 
-        H2TableDescriptor tbl = new H2TableDescriptor(this, schema, type);
+        H2TableDescriptor tbl = new H2TableDescriptor(this, schema, type, cacheName);
 
         try {
             Connection conn = connectionForThread(schemaName);
@@ -1837,7 +1815,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
         Cursor cursor = hashIdx.find((Session)null, null, null);
 
-        int cacheId = CU.cacheId(tbl.schema().cacheName());
+        int cacheId = CU.cacheId(cacheName);
 
         GridCacheContext cctx = ctx.cache().context().cacheContext(cacheId);
 
@@ -2036,10 +2014,10 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /**
-     * @return Value context.
+     * @return Value object context.
      */
-    public CacheObjectValueContext valueContext() {
-        return valCtx;
+    public CacheObjectValueContext objectContext() {
+        return ctx.query().objectContext();
     }
 
     /**
@@ -2243,7 +2221,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         H2Schema rmv = schemas.remove(schema);
 
         if (rmv != null) {
-            cacheName2schema.remove(rmv.cacheName());
+            cacheName2schema.remove(cacheName);
             mapQryExec.onCacheStop(cacheName);
             dmlProc.onCacheStop(cacheName);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ValueCacheObject.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ValueCacheObject.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ValueCacheObject.java
index a2f5c88..d18668f 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ValueCacheObject.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2ValueCacheObject.java
@@ -22,8 +22,7 @@ import java.sql.SQLException;
 import java.sql.Types;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.processors.cache.CacheObject;
-import org.apache.ignite.internal.processors.cache.CacheObjectContext;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.h2.message.DbException;
 import org.h2.util.JdbcUtils;
 import org.h2.util.Utils;
@@ -38,18 +37,20 @@ public class GridH2ValueCacheObject extends Value {
     /** */
     private CacheObject obj;
 
-    /** */
-    private GridCacheContext<?,?> cctx;
+    /** Object value context. */
+    private CacheObjectValueContext valCtx;
 
     /**
-     * @param cctx Cache context.
+     * Constructor.
+     *
      * @param obj Object.
+     * @param valCtx Object value context.
      */
-    public GridH2ValueCacheObject(GridCacheContext<?,?> cctx, CacheObject obj) {
+    public GridH2ValueCacheObject(CacheObject obj, CacheObjectValueContext valCtx) {
         assert obj != null;
 
         this.obj = obj;
-        this.cctx = cctx; // Allowed to be null in tests.
+        this.valCtx = valCtx;
     }
 
     /**
@@ -60,10 +61,10 @@ public class GridH2ValueCacheObject extends Value {
     }
 
     /**
-     * @return Cache context.
+     * @return Value context.
      */
-    public GridCacheContext<?,?> getCacheContext() {
-        return cctx;
+    public CacheObjectValueContext valueContext() {
+        return valCtx;
     }
 
     /** {@inheritDoc} */
@@ -96,19 +97,12 @@ public class GridH2ValueCacheObject extends Value {
         return Utils.cloneByteArray(getBytesNoCopy());
     }
 
-    /**
-     * @return Cache object context.
-     */
-    private CacheObjectContext objectContext() {
-        return cctx == null ? null : cctx.cacheObjectContext();
-    }
-
     /** {@inheritDoc} */
     @Override public byte[] getBytesNoCopy() {
         if (obj.cacheObjectType() == CacheObject.TYPE_REGULAR) {
             // Result must be the same as `marshaller.marshall(obj.value(coctx, false));`
             try {
-                return obj.valueBytes(objectContext());
+                return obj.valueBytes(valCtx);
             }
             catch (IgniteCheckedException e) {
                 throw DbException.convert(e);
@@ -129,7 +123,7 @@ public class GridH2ValueCacheObject extends Value {
      * @return Value.
      */
     public Object getObject(boolean cpy) {
-        return obj.isPlatformType() ? obj.value(objectContext(), cpy) : obj;
+        return obj.isPlatformType() ? obj.value(valCtx, cpy) : obj;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index b7bdde5..afaf68d 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -1146,17 +1146,13 @@ public class GridMapQueryExecutor {
                         if (val instanceof GridH2ValueCacheObject) {
                             GridH2ValueCacheObject valCacheObj = (GridH2ValueCacheObject)val;
 
-                            GridCacheContext cctx = valCacheObj.getCacheContext();
-
-                            if (cctx != null && cctx.needValueCopy()) {
-                                row[j] = new GridH2ValueCacheObject(valCacheObj.getCacheContext(), valCacheObj.getCacheObject()) {
-                                    @Override public Object getObject() {
-                                        return getObject(true);
-                                    }
-                                };
+                            row[j] = new GridH2ValueCacheObject(valCacheObj.getCacheObject(), h2.objectContext()) {
+                                @Override public Object getObject() {
+                                    return getObject(true);
+                                }
+                            };
 
-                                copied = true;
-                            }
+                            copied = true;
                         }
                     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index 8d9d953..9445534 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -818,7 +818,7 @@ public class GridReduceQueryExecutor {
                     continue;
                 }
 
-                return new GridQueryCacheObjectsIterator(resIter, h2.valueContext(), keepPortable);
+                return new GridQueryCacheObjectsIterator(resIter, h2.objectContext(), keepPortable);
             }
             catch (IgniteCheckedException | RuntimeException e) {
                 U.closeQuiet(r.connection());

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java
index d0e8cb6..bc3b7a3 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java
@@ -21,7 +21,7 @@ import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.cache.CacheObject;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2ValueCacheObject;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -32,9 +32,6 @@ import org.h2.value.Value;
  */
 public class GridH2CacheObject extends GridH2ValueMessage {
     /** */
-    private int cacheId;
-
-    /** */
     private CacheObject obj;
 
     /**
@@ -51,26 +48,16 @@ public class GridH2CacheObject extends GridH2ValueMessage {
     public GridH2CacheObject(GridH2ValueCacheObject v) throws IgniteCheckedException {
         this.obj = v.getCacheObject();
 
-        GridCacheContext<?,?> cctx = v.getCacheContext();
-
-        if (cctx != null) {
-            this.cacheId = cctx.cacheId();
-
-            obj.prepareMarshal(cctx.cacheObjectContext());
-        }
+        obj.prepareMarshal(v.valueContext());
     }
 
     /** {@inheritDoc} */
     @Override public Value value(GridKernalContext ctx) throws IgniteCheckedException {
-        GridCacheContext<?,?> cctx = null;
+        CacheObjectValueContext valCtx = ctx.query().objectContext();
 
-        if (ctx != null) {
-            cctx = ctx.cache().context().cacheContext(cacheId);
+        obj.finishUnmarshal(valCtx, ctx.cache().context().deploy().globalLoader());
 
-            obj.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader());
-        }
-
-        return new GridH2ValueCacheObject(cctx, obj);
+        return new GridH2ValueCacheObject(obj, valCtx);
     }
 
     /** {@inheritDoc} */
@@ -85,14 +72,6 @@ public class GridH2CacheObject extends GridH2ValueMessage {
 
         switch (reader.state()) {
             case 0:
-                cacheId = reader.readInt("cacheId");
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 1:
                 obj = reader.readMessage("obj");
 
                 if (!reader.isLastRead())
@@ -121,12 +100,6 @@ public class GridH2CacheObject extends GridH2ValueMessage {
 
         switch (writer.state()) {
             case 0:
-                if (!writer.writeInt("cacheId", cacheId))
-                    return false;
-
-                writer.incrementState();
-
-            case 1:
                 if (!writer.writeMessage("obj", obj))
                     return false;
 
@@ -144,7 +117,7 @@ public class GridH2CacheObject extends GridH2ValueMessage {
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 2;
+        return 1;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb12f0fa/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index 1f73dcb..73a7191 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -742,7 +742,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         }
 
         /** {@inheritDoc} */
-        @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+        @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException {
             return JdbcUtils.serialize(val, null);
         }
 
@@ -788,12 +788,12 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         }
 
         /** {@inheritDoc} */
-        @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+        @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException {
             throw new UnsupportedOperationException();
         }
 
         /** {@inheritDoc} */
-        @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+        @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException {
             throw new UnsupportedOperationException();
         }
 


[13/24] ignite git commit: IGNITE-5310: Fix to DML statement cache to decouple it from Ignite cache. This closes #2018.

Posted by sb...@apache.org.
IGNITE-5310: Fix to DML statement cache to decouple it from Ignite cache. This closes #2018.


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

Branch: refs/heads/ignite-5075-cc
Commit: b673bdb58ccf9bf5a959cf43423ba4316535caa6
Parents: 40851c7
Author: devozerov <vo...@gridgain.com>
Authored: Sat May 27 16:40:43 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Sat May 27 16:40:43 2017 +0300

----------------------------------------------------------------------
 .../query/h2/DmlStatementsProcessor.java        | 27 ++++----
 .../processors/query/h2/H2DmlPlanKey.java       | 66 ++++++++++++++++++++
 2 files changed, 79 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b673bdb5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
index 47b5ef4..0474aeb 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
@@ -30,7 +30,6 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.TimeUnit;
 import javax.cache.processor.EntryProcessor;
@@ -105,7 +104,8 @@ public class DmlStatementsProcessor {
     private static final int PLAN_CACHE_SIZE = 1024;
 
     /** Update plans cache. */
-    private final ConcurrentMap<String, ConcurrentMap<String, UpdatePlan>> planCache = new ConcurrentHashMap<>();
+    private final ConcurrentMap<H2DmlPlanKey, UpdatePlan> planCache =
+        new GridBoundedConcurrentLinkedHashMap<>(PLAN_CACHE_SIZE);
 
     /**
      * Constructor.
@@ -125,7 +125,14 @@ public class DmlStatementsProcessor {
      * @param cacheName Cache name.
      */
     public void onCacheStop(String cacheName) {
-        planCache.remove(idx.schema(cacheName));
+        Iterator<Map.Entry<H2DmlPlanKey, UpdatePlan>> iter = planCache.entrySet().iterator();
+
+        while (iter.hasNext()) {
+            UpdatePlan plan = iter.next().getValue();
+
+            if (F.eq(cacheName, plan.tbl.cacheName()))
+                iter.remove();
+        }
     }
 
     /**
@@ -408,17 +415,9 @@ public class DmlStatementsProcessor {
         throws IgniteCheckedException {
         Prepared p = GridSqlQueryParser.prepared(prepStmt);
 
-        ConcurrentMap<String, UpdatePlan> cachePlans = planCache.get(schema);
-
-        if (cachePlans == null) {
-            cachePlans = new GridBoundedConcurrentLinkedHashMap<>(PLAN_CACHE_SIZE);
-
-            cachePlans = U.firstNotNull(planCache.putIfAbsent(schema, cachePlans), cachePlans);
-        }
+        H2DmlPlanKey planKey = new H2DmlPlanKey(schema, p.getSQL());
 
-        // getSQL returns field value, so it's fast
-        // Don't look for re-runs in cache, we don't cache them
-        UpdatePlan res = (errKeysPos == null ? cachePlans.get(p.getSQL()) : null);
+        UpdatePlan res = (errKeysPos == null ? planCache.get(planKey) : null);
 
         if (res != null)
             return res;
@@ -427,7 +426,7 @@ public class DmlStatementsProcessor {
 
         // Don't cache re-runs
         if (errKeysPos == null)
-            return U.firstNotNull(cachePlans.putIfAbsent(p.getSQL(), res), res);
+            return U.firstNotNull(planCache.putIfAbsent(planKey, res), res);
         else
             return res;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b673bdb5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2DmlPlanKey.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2DmlPlanKey.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2DmlPlanKey.java
new file mode 100644
index 0000000..3a43ea1
--- /dev/null
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2DmlPlanKey.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.processors.query.h2;
+
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * H2 DML plan key.
+ */
+public class H2DmlPlanKey {
+    /** Schema name. */
+    private final String schemaName;
+
+    /** SQL. */
+    private final String sql;
+
+    /**
+     * Constructor.
+     *
+     * @param schemaName Schema name.
+     * @param sql SQL.
+     */
+    public H2DmlPlanKey(String schemaName, String sql) {
+        this.schemaName = schemaName;
+        this.sql = sql;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return 31 * (schemaName != null ? schemaName.hashCode() : 0) + (sql != null ? sql.hashCode() : 0);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        H2DmlPlanKey other = (H2DmlPlanKey)o;
+
+        return F.eq(sql, other.sql) && F.eq(schemaName, other.schemaName);
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(H2DmlPlanKey.class, this);
+    }
+}


[22/24] ignite git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/ignite

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


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

Branch: refs/heads/ignite-5075-cc
Commit: 172419b30b3e5523f426239c0d521c82639dfe3d
Parents: c68c146 88fd1a6
Author: Sergi Vladykin <se...@gmail.com>
Authored: Mon May 29 09:42:12 2017 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Mon May 29 09:42:12 2017 +0300

----------------------------------------------------------------------
 modules/web-console/frontend/.babelrc           |   9 +-
 modules/web-console/frontend/.gitignore         |   1 -
 modules/web-console/frontend/app/app.js         |  18 +-
 .../components/web-console-header/component.js  |   6 +-
 .../app/modules/agent/AgentManager.service.js   |   2 -
 .../frontend/gulpfile.babel.js/index.js         |  26 ---
 .../frontend/gulpfile.babel.js/paths.js         |  64 ------
 .../frontend/gulpfile.babel.js/tasks/build.js   |  21 --
 .../frontend/gulpfile.babel.js/tasks/bundle.js  |  36 ----
 .../frontend/gulpfile.babel.js/tasks/clean.js   |  32 ---
 .../frontend/gulpfile.babel.js/tasks/copy.js    |  33 ---
 .../gulpfile.babel.js/tasks/ignite-modules.js   |  55 -----
 .../frontend/gulpfile.babel.js/tasks/watch.js   |  30 ---
 .../gulpfile.babel.js/webpack/common.js         | 205 -------------------
 .../webpack/environments/development.js         |  60 ------
 .../webpack/environments/production.js          |  41 ----
 .../webpack/environments/test.js                |  44 ----
 .../frontend/gulpfile.babel.js/webpack/index.js |  36 ----
 .../frontend/ignite_modules/index.js            |   7 +-
 modules/web-console/frontend/package.json       | 104 ++++------
 .../frontend/test/karma.conf.babel.js           |  13 +-
 modules/web-console/frontend/test/karma.conf.js |   2 +-
 .../frontend/webpack/webpack.common.js          | 188 +++++++++++++++++
 .../frontend/webpack/webpack.dev.babel.js       | 100 +++++++++
 .../frontend/webpack/webpack.prod.babel.js      |  64 ++++++
 .../frontend/webpack/webpack.test.js            |  33 +++
 26 files changed, 449 insertions(+), 781 deletions(-)
----------------------------------------------------------------------



[08/24] ignite git commit: IGNITE-4575: Improved binary enums support. This closes #1968.

Posted by sb...@apache.org.
IGNITE-4575: Improved binary enums support. This closes #1968.


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

Branch: refs/heads/ignite-5075-cc
Commit: b5c7b6f5ed81a9cee242e3abb052c29ec571a9a9
Parents: d38ca8b
Author: Sergey Kalashnikov <sk...@gridgain.com>
Authored: Fri May 26 14:07:06 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri May 26 14:07:06 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteBinary.java    |  23 ++-
 .../org/apache/ignite/binary/BinaryObject.java  |   8 +
 .../org/apache/ignite/binary/BinaryType.java    |   5 +
 .../ignite/binary/BinaryTypeConfiguration.java  |  26 +++
 .../binary/BinaryCachingMetadataHandler.java    |   5 +
 .../internal/binary/BinaryClassDescriptor.java  |   4 +-
 .../ignite/internal/binary/BinaryContext.java   |  60 +++++--
 .../internal/binary/BinaryEnumObjectImpl.java   |  30 +++-
 .../internal/binary/BinaryFieldAccessor.java    |  10 ++
 .../ignite/internal/binary/BinaryMetadata.java  |  93 +++++++++-
 .../internal/binary/BinaryMetadataHandler.java  |   9 +
 .../binary/BinaryNoopMetadataHandler.java       |   5 +
 .../internal/binary/BinaryObjectExImpl.java     |   5 +
 .../internal/binary/BinaryReaderExImpl.java     |  18 ++
 .../ignite/internal/binary/BinaryTypeImpl.java  |  15 ++
 .../ignite/internal/binary/BinaryTypeProxy.java |   6 +
 .../ignite/internal/binary/BinaryUtils.java     | 104 ++++++++++-
 .../internal/binary/BinaryWriterExImpl.java     |  18 +-
 .../internal/binary/GridBinaryMarshaller.java   |   3 +
 .../binary/builder/BinaryBuilderSerializer.java |  10 +-
 .../binary/builder/BinaryObjectBuilderImpl.java |   2 +-
 .../binary/CacheObjectBinaryProcessor.java      |  21 ++-
 .../binary/CacheObjectBinaryProcessorImpl.java  |  72 +++++++-
 .../cache/binary/IgniteBinaryImpl.java          |  26 +++
 .../processors/cacheobject/NoOpBinary.java      |  12 ++
 .../platform/PlatformContextImpl.java           |  29 ++-
 .../binary/PlatformBinaryProcessor.java         |  25 +++
 .../internal/binary/BinaryEnumsSelfTest.java    | 146 ++++++++++++++-
 .../binary/TestCachingMetadataHandler.java      |   5 +
 .../platform/PlatformComputeEchoTask.java       |  13 ++
 .../Binary/BinaryBuilderSelfTest.cs             |  88 +++++++--
 .../Compute/ComputeApiTest.cs                   |  25 +++
 .../Binary/BinaryTypeConfiguration.cs           |   3 +-
 .../dotnet/Apache.Ignite.Core/Binary/IBinary.cs |  24 +++
 .../Apache.Ignite.Core/Binary/IBinaryObject.cs  |   8 +
 .../Apache.Ignite.Core/Binary/IBinaryType.cs    |   6 +
 .../Apache.Ignite.Core/Impl/Binary/Binary.cs    |  67 ++++++-
 .../Impl/Binary/BinaryEnum.cs                   |  11 +-
 .../Impl/Binary/BinaryObject.cs                 |  13 +-
 .../Impl/Binary/BinaryProcessor.cs              |  65 ++++++-
 .../Impl/Binary/BinaryReader.cs                 |  10 +-
 .../Impl/Binary/BinarySystemHandlers.cs         |  25 +--
 .../Impl/Binary/BinaryUtils.cs                  |  19 ++
 .../Impl/Binary/BinaryWriter.cs                 |   4 +-
 .../Impl/Binary/Marshaller.cs                   |  88 ++++-----
 .../Impl/Binary/Metadata/BinaryType.cs          | 179 ++++++++++++++++++-
 .../Impl/Binary/Metadata/BinaryTypeHolder.cs    |  44 +++--
 47 files changed, 1338 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java b/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
index 1d1c0c3..3550ff5 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
@@ -23,6 +23,7 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedList;
+import java.util.Map;
 import java.util.TreeMap;
 import java.util.UUID;
 import org.apache.ignite.binary.BinaryObjectBuilder;
@@ -374,11 +375,29 @@ public interface IgniteBinary {
     public Collection<BinaryType> types() throws BinaryObjectException;
 
     /**
-     * Create enum object.
+     * Create enum object using value.
      *
      * @param typeName Type name.
      * @param ord Ordinal.
      * @return Enum object.
      */
-    public BinaryObject buildEnum(String typeName, int ord);
+    public BinaryObject buildEnum(String typeName, int ord) throws BinaryObjectException;
+
+    /**
+     * Create enum object using name.
+     *
+     * @param typeName Type name.
+     * @param name Name.
+     * @return Enum object.
+     */
+    public BinaryObject buildEnum(String typeName, String name) throws BinaryObjectException;
+
+    /**
+     * Register enum type.
+     *
+     * @param typeName Type name.
+     * @param vals Mapping of enum constant names to ordinals.
+     * @return Binary type for registered enum.
+     */
+    public BinaryType registerEnum(String typeName, Map<String, Integer> vals) throws BinaryObjectException;
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
index 3d99757..b9e653f 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
@@ -162,4 +162,12 @@ public interface BinaryObject extends Serializable, Cloneable {
      * @throws BinaryObjectException If object is not enum.
      */
     public int enumOrdinal() throws BinaryObjectException;
+
+    /**
+     * Get name for this enum object. Use {@link BinaryType#isEnum()} to check if object is of enum type.
+     *
+     * @return Name.
+     * @throws BinaryObjectException If object is not enum.
+     */
+    public String enumName() throws BinaryObjectException;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/binary/BinaryType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryType.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryType.java
index f184a8c..f4bc206 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryType.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryType.java
@@ -79,4 +79,9 @@ public interface BinaryType {
      * @return {@code True} if type is enum.
      */
     public boolean isEnum();
+
+    /**
+     * @return Collection of enum values.
+     */
+    public Collection<BinaryObject> enumValues();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 54b853c..2d00bd2 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
@@ -23,6 +23,9 @@ import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 
+import java.util.LinkedHashMap;
+import java.util.Map;
+
 /**
  * Defines configuration properties for a specific binary type. Providing per-type
  * configuration is optional, as it is generally enough, and also optional, to provide global binary
@@ -46,6 +49,9 @@ public class BinaryTypeConfiguration {
     /** Enum flag. */
     private boolean isEnum;
 
+    /** Enum names to ordinals mapping. */
+    private Map<String, Integer> enumValues;
+
     /**
      * Constructor.
      */
@@ -64,6 +70,7 @@ public class BinaryTypeConfiguration {
         idMapper = other.idMapper;
         isEnum = other.isEnum;
         serializer = other.serializer;
+        enumValues = other.enumValues != null ? new LinkedHashMap<>(other.enumValues) : null;
         typeName = other.typeName;
     }
 
@@ -179,6 +186,25 @@ public class BinaryTypeConfiguration {
         return this;
     }
 
+    /**
+     * Set enum ordinal to names mapping.
+     *
+     * @param values Map of enum name to ordinal.
+     * @return {@code this} for chaining.
+     */
+    public BinaryTypeConfiguration setEnumValues(@Nullable Map<String, Integer> values) {
+        this.enumValues = values;
+
+        return this;
+    }
+
+    /**
+     * @return Enum name to ordinal mapping
+     */
+    @Nullable public Map<String, Integer> getEnumValues() {
+        return enumValues;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(BinaryTypeConfiguration.class, this, super.toString());

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryCachingMetadataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryCachingMetadataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryCachingMetadataHandler.java
index 24a393d..27cccaa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryCachingMetadataHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryCachingMetadataHandler.java
@@ -69,6 +69,11 @@ public class BinaryCachingMetadataHandler implements BinaryMetadataHandler {
     }
 
     /** {@inheritDoc} */
+    @Override public synchronized BinaryMetadata metadata0(int typeId) throws BinaryObjectException {
+        return ((BinaryTypeImpl)metas.get(typeId)).metadata();
+    }
+
+    /** {@inheritDoc} */
     @Override public synchronized BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException {
         BinaryTypeImpl type = (BinaryTypeImpl) metas.get(typeId);
         return type.metadata().hasSchema(schemaId) ? type : null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 7194f49..adfdcfc 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
@@ -758,7 +758,7 @@ public class BinaryClassDescriptor {
                                 BinarySchema newSchema = collector.schema();
 
                                 BinaryMetadata meta = new BinaryMetadata(typeId, typeName, collector.meta(),
-                                    affKeyFieldName, Collections.singleton(newSchema), false);
+                                    affKeyFieldName, Collections.singleton(newSchema), false, null);
 
                                 ctx.updateMetadata(typeId, meta);
 
@@ -779,7 +779,7 @@ public class BinaryClassDescriptor {
                 if (userType && !stableSchemaPublished) {
                     // Update meta before write object with new schema
                     BinaryMetadata meta = new BinaryMetadata(typeId, typeName, stableFieldsMeta,
-                        affKeyFieldName, Collections.singleton(stableSchema), false);
+                        affKeyFieldName, Collections.singleton(stableSchema), false, null);
 
                     ctx.updateMetadata(typeId, meta);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 da46496..70bc2f9 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
@@ -461,17 +461,17 @@ public class BinaryContext {
 
                     for (String clsName0 : classesInPackage(pkgName))
                         descs.add(clsName0, mapper, serializer, identity, affFields.get(clsName0),
-                            typeCfg.isEnum(), true);
+                            typeCfg.isEnum(), typeCfg.getEnumValues(), true);
                 }
                 else
                     descs.add(clsName, mapper, serializer, identity, affFields.get(clsName),
-                        typeCfg.isEnum(), false);
+                        typeCfg.isEnum(), typeCfg.getEnumValues(), false);
             }
         }
 
         for (TypeDescriptor desc : descs.descriptors())
             registerUserType(desc.clsName, desc.mapper, desc.serializer, desc.identity, desc.affKeyFieldName,
-                desc.isEnum);
+                desc.isEnum, desc.enumMap);
 
         BinaryInternalMapper globalMapper = resolveMapper(globalNameMapper, globalIdMapper);
 
@@ -649,7 +649,8 @@ public class BinaryContext {
                         desc0.typeName(),
                         desc0.fieldsMeta(),
                         desc0.affFieldKeyName(),
-                        schemas, desc0.isEnum());
+                        schemas, desc0.isEnum(),
+                        cls.isEnum() ? enumMap(cls) : null);
 
                     metaHnd.addMeta(desc0.typeId(), meta.wrap(this));
 
@@ -799,8 +800,8 @@ public class BinaryContext {
         );
 
         if (!deserialize)
-            metaHnd.addMeta(typeId,
-                new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), affFieldName, null, desc.isEnum()).wrap(this));
+            metaHnd.addMeta(typeId, new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), affFieldName, null,
+                desc.isEnum(), cls.isEnum() ? enumMap(cls) : null).wrap(this));
 
         descByCls.put(cls, desc);
 
@@ -1095,6 +1096,7 @@ public class BinaryContext {
      * @param identity Type identity.
      * @param affKeyFieldName Affinity key field name.
      * @param isEnum If enum.
+     * @param enumMap Enum name to ordinal mapping.
      * @throws BinaryObjectException In case of error.
      */
     @SuppressWarnings("ErrorNotRethrown")
@@ -1103,8 +1105,8 @@ public class BinaryContext {
         @Nullable BinarySerializer serializer,
         @Nullable BinaryIdentityResolver identity,
         @Nullable String affKeyFieldName,
-        boolean isEnum)
-        throws BinaryObjectException {
+        boolean isEnum,
+        @Nullable Map<String, Integer> enumMap) throws BinaryObjectException {
         assert mapper != null;
 
         Class<?> cls = null;
@@ -1172,7 +1174,8 @@ public class BinaryContext {
             predefinedTypes.put(id, desc);
         }
 
-        metaHnd.addMeta(id, new BinaryMetadata(id, typeName, fieldsMeta, affKeyFieldName, null, isEnum).wrap(this));
+        metaHnd.addMeta(id,
+            new BinaryMetadata(id, typeName, fieldsMeta, affKeyFieldName, null, isEnum, enumMap).wrap(this));
     }
 
     /**
@@ -1222,6 +1225,16 @@ public class BinaryContext {
     }
 
     /**
+     *
+     * @param typeId Type ID
+     * @return Meta data.
+     * @throws BinaryObjectException In case of error.
+     */
+    @Nullable public BinaryMetadata metadata0(int typeId) throws BinaryObjectException {
+        return metaHnd != null ? metaHnd.metadata0(typeId) : null;
+    }
+
+    /**
      * @param typeId Type ID.
      * @param schemaId Schema ID.
      * @return Meta data.
@@ -1351,6 +1364,24 @@ public class BinaryContext {
     }
 
     /**
+     *
+     * @param cls Class
+     * @return Enum name to ordinal mapping.
+     */
+    private static Map<String, Integer> enumMap(Class<?> cls) {
+        assert cls.isEnum();
+
+        Object[] enumVals = cls.getEnumConstants();
+
+        Map<String, Integer> enumMap = new LinkedHashMap<>(enumVals.length);
+
+        for (Object enumVal : enumVals)
+            enumMap.put(((Enum)enumVal).name(), ((Enum)enumVal).ordinal());
+
+        return enumMap;
+    }
+
+    /**
      * Type descriptors.
      */
     private static class TypeDescriptors {
@@ -1366,6 +1397,7 @@ public class BinaryContext {
          * @param identity Key hashing mode.
          * @param affKeyFieldName Affinity key field name.
          * @param isEnum Enum flag.
+         * @param enumMap Enum constants mapping.
          * @param canOverride Whether this descriptor can be override.
          * @throws BinaryObjectException If failed.
          */
@@ -1375,6 +1407,7 @@ public class BinaryContext {
             BinaryIdentityResolver identity,
             String affKeyFieldName,
             boolean isEnum,
+            Map<String, Integer> enumMap,
             boolean canOverride)
             throws BinaryObjectException {
             TypeDescriptor desc = new TypeDescriptor(clsName,
@@ -1383,6 +1416,7 @@ public class BinaryContext {
                 identity,
                 affKeyFieldName,
                 isEnum,
+                enumMap,
                 canOverride);
 
             TypeDescriptor oldDesc = descs.get(clsName);
@@ -1425,6 +1459,9 @@ public class BinaryContext {
         /** Enum flag. */
         private boolean isEnum;
 
+        /** Enum ordinal to name mapping. */
+        private Map<String, Integer> enumMap;
+
         /** Whether this descriptor can be override. */
         private boolean canOverride;
 
@@ -1436,17 +1473,19 @@ public class BinaryContext {
          * @param identity Key hashing mode.
          * @param affKeyFieldName Affinity key field name.
          * @param isEnum Enum type.
+         * @param enumMap Mapping of enum names to ordinals.
          * @param canOverride Whether this descriptor can be override.
          */
         private TypeDescriptor(String clsName, BinaryInternalMapper mapper,
             BinarySerializer serializer, BinaryIdentityResolver identity, String affKeyFieldName, boolean isEnum,
-            boolean canOverride) {
+            Map<String, Integer> enumMap, boolean canOverride) {
             this.clsName = clsName;
             this.mapper = mapper;
             this.serializer = serializer;
             this.identity = identity;
             this.affKeyFieldName = affKeyFieldName;
             this.isEnum = isEnum;
+            this.enumMap = enumMap;
             this.canOverride = canOverride;
         }
 
@@ -1465,6 +1504,7 @@ public class BinaryContext {
                 identity = other.identity;
                 affKeyFieldName = other.affKeyFieldName;
                 isEnum = other.isEnum;
+                enumMap = other.enumMap;
                 canOverride = other.canOverride;
             }
             else if (!other.canOverride)

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 cc9941e..f889e45 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
@@ -97,9 +97,18 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
     public BinaryEnumObjectImpl(BinaryContext ctx, byte[] arr) {
         assert ctx != null;
         assert arr != null;
-        assert arr[0] == GridBinaryMarshaller.ENUM;
 
-        valBytes = arr;
+        if (arr[0] == GridBinaryMarshaller.ENUM)
+            valBytes = arr;
+        else {
+            assert arr[0] == GridBinaryMarshaller.BINARY_ENUM;
+
+            valBytes = new byte[arr.length];
+
+            valBytes[0] = GridBinaryMarshaller.ENUM;
+
+            U.arrayCopy(arr, 1, valBytes, 1, arr.length - 1);
+        }
 
         this.ctx = ctx;
 
@@ -187,6 +196,23 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
     }
 
     /** {@inheritDoc} */
+    @Override public String enumName() throws BinaryObjectException {
+        BinaryMetadata metadata = ctx.metadata0(typeId);
+
+        if (metadata == null)
+            throw new BinaryObjectException("Failed to get metadata for enum [typeId=" +
+                typeId + ", typeName='" + clsName + "', ordinal=" + ord + "]");
+
+        String name = metadata.getEnumNameByOrdinal(ord);
+
+        if (name == null)
+            throw new BinaryObjectException("Unable to resolve enum constant name [typeId=" +
+                typeId + ", typeName='" + metadata.typeName() + "', ordinal=" + ord + "]");
+
+        return name;
+    }
+
+    /** {@inheritDoc} */
     @Override public int hashCode() {
         return 31 * typeId + ord;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 f7d35f0..567bee1 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
@@ -647,6 +647,11 @@ public abstract class BinaryFieldAccessor {
 
                     break;
 
+                case BINARY_ENUM:
+                    writer.doWriteBinaryEnum((BinaryEnumObjectImpl)val);
+
+                    break;
+
                 case ENUM_ARR:
                     writer.writeEnumArrayField((Object[])val);
 
@@ -863,6 +868,11 @@ public abstract class BinaryFieldAccessor {
 
                     break;
 
+                case BINARY_ENUM:
+                    val = reader.readBinaryEnum(id);
+
+                    break;
+
                 case BINARY:
                 case OBJECT:
                     val = reader.readObject(id);

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadata.java
index a8b7fcb..ead00b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadata.java
@@ -27,9 +27,12 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
+
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.jetbrains.annotations.Nullable;
@@ -41,6 +44,9 @@ public class BinaryMetadata implements Externalizable {
     /** */
     private static final long serialVersionUID = 0L;
 
+    /** */
+    private static final int VERSION = 1;
+
     /** Type ID. */
     @GridToStringInclude(sensitive = true)
     private int typeId;
@@ -67,6 +73,12 @@ public class BinaryMetadata implements Externalizable {
     /** Whether this is enum type. */
     private boolean isEnum;
 
+    /** Enum name to ordinal mapping. */
+    private Map<String, Integer> nameToOrdinal;
+
+    /** Enum ordinal to name mapping. */
+    private Map<Integer, String> ordinalToName;
+
     /**
      * For {@link Externalizable}.
      */
@@ -83,9 +95,11 @@ public class BinaryMetadata implements Externalizable {
      * @param affKeyFieldName Affinity key field name.
      * @param schemas Schemas.
      * @param isEnum Enum flag.
+     * @param enumMap Enum name to ordinal mapping.
      */
     public BinaryMetadata(int typeId, String typeName, @Nullable Map<String, BinaryFieldMetadata> fields,
-        @Nullable String affKeyFieldName, @Nullable Collection<BinarySchema> schemas, boolean isEnum) {
+        @Nullable String affKeyFieldName, @Nullable Collection<BinarySchema> schemas, boolean isEnum,
+        @Nullable Map<String, Integer> enumMap) {
         assert typeName != null;
 
         this.typeId = typeId;
@@ -104,6 +118,15 @@ public class BinaryMetadata implements Externalizable {
             schemaIds = Collections.emptySet();
 
         this.isEnum = isEnum;
+
+        if (enumMap != null) {
+            this.nameToOrdinal = new LinkedHashMap<>(enumMap);
+
+            this.ordinalToName = new LinkedHashMap<>(enumMap.size());
+
+            for (Map.Entry<String, Integer> e: nameToOrdinal.entrySet())
+                this.ordinalToName.put(e.getValue(), e.getKey());
+        }
     }
 
     /**
@@ -197,6 +220,7 @@ public class BinaryMetadata implements Externalizable {
      * @exception IOException Includes any I/O exceptions that may occur.
      */
     public void writeTo(DataOutput out) throws IOException {
+        out.writeByte(VERSION);
         out.writeInt(typeId);
 
         U.writeString(out, typeName);
@@ -224,6 +248,18 @@ public class BinaryMetadata implements Externalizable {
         }
 
         out.writeBoolean(isEnum);
+
+        if (isEnum) {
+            Map<String, Integer> map = enumMap();
+
+            out.writeInt(map.size());
+
+            for (Map.Entry<String, Integer> e : map.entrySet()) {
+                U.writeString(out, e.getKey());
+
+                out.writeInt(e.getValue());
+            }
+        }
     }
 
     /** {@inheritDoc} */
@@ -242,6 +278,8 @@ public class BinaryMetadata implements Externalizable {
      * @exception IOException if I/O errors occur.
      */
     public void readFrom(DataInput in) throws IOException {
+        in.readByte(); //skip version
+
         typeId = in.readInt();
         typeName = U.readString(in);
 
@@ -285,6 +323,59 @@ public class BinaryMetadata implements Externalizable {
         }
 
         isEnum = in.readBoolean();
+
+        if (isEnum) {
+            int size = in.readInt();
+
+            if (size >= 0) {
+                ordinalToName = new LinkedHashMap<>(size);
+                nameToOrdinal = new LinkedHashMap<>(size);
+
+                for (int idx = 0; idx < size; idx++) {
+                    String name = U.readString(in);
+
+                    int ord = in.readInt();
+
+                    ordinalToName.put(ord, name);
+                    nameToOrdinal.put(name, ord);
+                }
+            }
+        }
+    }
+
+    /**
+     * Gets enum constant name given its ordinal value.
+     *
+     * @param ord Enum constant ordinal value.
+     * @return Enum constant name.
+     */
+    public String getEnumNameByOrdinal(int ord) {
+        if (ordinalToName == null)
+            return null;
+
+        return ordinalToName.get(ord);
+    }
+
+    /**
+     * Gets enum constant ordinal value given its name.
+     *
+     * @param name Enum constant name.
+     * @return Enum constant ordinal value.
+     */
+    public Integer getEnumOrdinalByName(String name) {
+        assert name != null;
+
+        return nameToOrdinal.get(name);
+    }
+
+    /**
+     * @return Name to ordinal mapping.
+     */
+    public Map<String, Integer> enumMap() {
+        if (nameToOrdinal == null)
+            return Collections.emptyMap();
+
+        return nameToOrdinal;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataHandler.java
index 748a283..e565338 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataHandler.java
@@ -43,6 +43,15 @@ public interface BinaryMetadataHandler {
     public BinaryType metadata(int typeId) throws BinaryObjectException;
 
     /**
+     * Gets unwrapped meta data for provided type ID.
+     *
+     * @param typeId Type ID.
+     * @return Metadata.
+     * @throws BinaryObjectException In case of error.
+     */
+    public BinaryMetadata metadata0(int typeId) throws BinaryObjectException;
+
+    /**
      * Gets metadata for provided type ID and schema ID.
      *
      * @param typeId Type ID.

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryNoopMetadataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryNoopMetadataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryNoopMetadataHandler.java
index 770d9c8..39c942a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryNoopMetadataHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryNoopMetadataHandler.java
@@ -52,6 +52,11 @@ public class BinaryNoopMetadataHandler implements BinaryMetadataHandler {
     }
 
     /** {@inheritDoc} */
+    @Override public BinaryMetadata metadata0(int typeId) throws BinaryObjectException {
+        return null;
+    }
+
+    /** {@inheritDoc} */
     @Override public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
index ae9a160..b5e066b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
@@ -77,6 +77,11 @@ public abstract class BinaryObjectExImpl implements BinaryObjectEx {
         throw new BinaryObjectException("Object is not enum.");
     }
 
+    /** {@inheritDoc} */
+    @Override public String enumName() throws BinaryObjectException {
+        throw new BinaryObjectException("Object is not enum.");
+    }
+
     /**
      * Get offset of data begin.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 c8ca803..2b7964c 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
@@ -41,6 +41,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_ENUM;
 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;
@@ -1426,6 +1427,15 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
 
     /**
      * @param fieldId Field ID.
+     * @return Binary Enum
+     * @throws BinaryObjectException If failed.
+     */
+    @Nullable BinaryEnumObjectImpl readBinaryEnum(int fieldId) throws BinaryObjectException {
+        return findFieldById(fieldId) ? BinaryUtils.doReadBinaryEnum(in, ctx) : null;
+    }
+
+    /**
+     * @param fieldId Field ID.
      * @param cls Class.
      * @return Value.
      * @throws BinaryObjectException In case of error.
@@ -1930,6 +1940,14 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
 
                 break;
 
+            case BINARY_ENUM:
+                obj = BinaryUtils.doReadBinaryEnum(in, ctx);
+
+                if (!GridBinaryMarshaller.KEEP_BINARIES.get())
+                    obj = ((BinaryObject)obj).deserialize();
+
+                break;
+
             case CLASS:
                 obj = BinaryUtils.doReadClass(in, ctx, ldr);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeImpl.java
index 132702c..fac1ff9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeImpl.java
@@ -17,9 +17,12 @@
 
 package org.apache.ignite.internal.binary;
 
+import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryType;
 
+import java.util.ArrayList;
 import java.util.Collection;
+
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 
@@ -80,6 +83,18 @@ public class BinaryTypeImpl implements BinaryType {
         return meta.isEnum();
     }
 
+    /** {@inheritDoc} */
+    @Override public Collection<BinaryObject> enumValues() {
+        Collection<Integer> ordinals = meta.enumMap().values();
+
+        ArrayList<BinaryObject> enumValues = new ArrayList<>(ordinals.size());
+
+        for (Integer ord: ordinals)
+            enumValues.add(new BinaryEnumObjectImpl(ctx, typeId(), typeName(), ord));
+
+        return enumValues;
+    }
+
     /**
      * @return Context.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeProxy.java
index df9901e..3a51050 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeProxy.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.binary;
 
 import org.apache.ignite.binary.BinaryField;
+import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.binary.BinaryType;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -92,6 +93,11 @@ public class BinaryTypeProxy implements BinaryType {
         return target().isEnum();
     }
 
+    /** {@inheritDoc} */
+    @Override public Collection<BinaryObject> enumValues() {
+        return target().enumValues();
+    }
+
     /**
      * @return Target type.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index f36c137..00b15da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -266,6 +266,7 @@ public class BinaryUtils {
         FIELD_TYPE_NAMES[GridBinaryMarshaller.TIME_ARR] = "Time[]";
         FIELD_TYPE_NAMES[GridBinaryMarshaller.OBJ_ARR] = "Object[]";
         FIELD_TYPE_NAMES[GridBinaryMarshaller.ENUM_ARR] = "Enum[]";
+        FIELD_TYPE_NAMES[GridBinaryMarshaller.BINARY_ENUM] = "Enum";
 
         if (wrapTrees()) {
             CLS_TO_WRITE_REPLACER.put(TreeMap.class, new BinaryTreeMapWriteReplacer());
@@ -975,6 +976,14 @@ public class BinaryUtils {
 
             boolean changed = false;
 
+            Map<String, Integer> mergedEnumMap = null;
+
+            if (!F.isEmpty(newMeta.enumMap())) {
+                mergedEnumMap = mergeEnumValues(oldMeta.typeName(), oldMeta.enumMap(), newMeta.enumMap());
+
+                changed = mergedEnumMap.size() > oldMeta.enumMap().size();
+            }
+
             for (Map.Entry<String, BinaryFieldMetadata> newField : newFields.entrySet()) {
                 BinaryFieldMetadata oldFieldMeta = mergedFields.put(newField.getKey(), newField.getValue());
 
@@ -1005,7 +1014,7 @@ public class BinaryUtils {
 
             // Return either old meta if no changes detected, or new merged meta.
             return changed ? new BinaryMetadata(oldMeta.typeId(), oldMeta.typeName(), mergedFields,
-                oldMeta.affinityKeyFieldName(), mergedSchemas, oldMeta.isEnum()) : oldMeta;
+                oldMeta.affinityKeyFieldName(), mergedSchemas, oldMeta.isEnum(), mergedEnumMap) : oldMeta;
         }
     }
 
@@ -1106,6 +1115,8 @@ public class BinaryUtils {
             return BinaryWriteMode.MAP;
         else if (cls.isEnum())
             return BinaryWriteMode.ENUM;
+        else if (cls == BinaryEnumObjectImpl.class)
+            return BinaryWriteMode.BINARY_ENUM;
         else if (cls == Class.class)
             return BinaryWriteMode.CLASS;
         else if (Proxy.class.isAssignableFrom(cls))
@@ -1627,6 +1638,17 @@ public class BinaryUtils {
      *
      * @param in Input stream.
      * @param ctx Binary context.
+     * @return Enum.
+     */
+    public static BinaryEnumObjectImpl doReadBinaryEnum(BinaryInputStream in, BinaryContext ctx) {
+        return doReadBinaryEnum(in, ctx, doReadEnumType(in));
+    }
+
+    /**
+     * Read binary enum.
+     *
+     * @param in Input stream.
+     * @param ctx Binary context.
      * @param type Plain type.
      * @return Enum.
      */
@@ -1903,6 +1925,7 @@ public class BinaryUtils {
                 return doReadBinaryObject(in, ctx, detach);
 
             case GridBinaryMarshaller.ENUM:
+            case GridBinaryMarshaller.BINARY_ENUM:
                 return doReadBinaryEnum(in, ctx, doReadEnumType(in));
 
             case GridBinaryMarshaller.ENUM_ARR:
@@ -2356,6 +2379,85 @@ public class BinaryUtils {
     }
 
     /**
+     * Checks enum values mapping.
+     *
+     * @param typeName Name of the type.
+     * @param enumValues Enum name to ordinal mapping.
+     * @throws BinaryObjectException
+     */
+    public static void validateEnumValues(String typeName, @Nullable Map<String, Integer> enumValues)
+            throws BinaryObjectException {
+
+        if (enumValues == null)
+            return;
+
+        Map<Integer, String> tmpMap = new LinkedHashMap<>(enumValues.size());
+        for (Map.Entry<String, Integer> e: enumValues.entrySet()) {
+
+            String prevName = tmpMap.put(e.getValue(), e.getKey());
+
+            if (prevName != null)
+                throw new BinaryObjectException("Conflicting enum values. Name '" + e.getKey() +
+                        "' uses ordinal value (" + e.getValue() +
+                        ") that is also used for name '" + prevName +
+                        "' [typeName='" + typeName + "']");
+        }
+    }
+
+    /**
+     * Merges enum value mappings and checks for conflicts.
+     *
+     * Possible conflicts:
+     * - same name is used for different ordinal values.
+     * - ordinal value is used more than once.
+     *
+     * @param typeName Name of the type.
+     * @param oldValues Old enum value mapping.
+     * @param newValues New enum value mapping.
+     * @throws BinaryObjectException in case of name or value conflict.
+     */
+    public static Map<String, Integer> mergeEnumValues(String typeName,
+            @Nullable Map<String, Integer> oldValues,
+            Map<String, Integer> newValues)
+            throws BinaryObjectException {
+
+        assert newValues != null;
+
+        int size = (oldValues != null) ? oldValues.size() + newValues.size() : newValues.size();
+
+        Map<Integer, String> revMap = new LinkedHashMap<>(size);
+        Map<String, Integer> mergedMap = new LinkedHashMap<>(size);
+
+        if (oldValues != null) {
+            //assuming that old values were validated earlier once.
+            for (Map.Entry<String, Integer> e : oldValues.entrySet()) {
+                revMap.put(e.getValue(), e.getKey());
+                mergedMap.put(e.getKey(), e.getValue());
+            }
+        }
+
+        for (Map.Entry<String, Integer> e: newValues.entrySet()) {
+            String prevName = revMap.put(e.getValue(), e.getKey());
+
+            if (prevName != null && !prevName.equals(e.getKey()))
+                throw new BinaryObjectException("Conflicting enum values. Name '" + e.getKey() +
+                        "' uses ordinal value (" + e.getValue() +
+                        ") that is also used for name '" + prevName +
+                        "' [typeName='" + typeName + "']");
+
+            Integer prevVal = mergedMap.put(e.getKey(), e.getValue());
+
+            if (prevVal != null && !prevVal.equals(e.getValue()))
+                throw new BinaryObjectException("Conflicting enum values. Value (" + e.getValue() +
+                        ") has name '" + e.getKey() +
+                        "' that is also used for value '" + prevVal +
+                        "' [typeName='" + typeName + "']");
+        }
+
+        return mergedMap;
+    }
+
+    /**
      * Enum type.
      */
     private static class EnumType {

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 7efe4b3..f2ba779 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
@@ -820,15 +820,23 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
 
         int typeId = val.typeId();
 
-        out.unsafeEnsure(1 + 4);
+        if (typeId != GridBinaryMarshaller.UNREGISTERED_TYPE_ID) {
+            out.unsafeEnsure(1 + 4 + 4);
 
-        out.unsafeWriteByte(GridBinaryMarshaller.ENUM);
-        out.unsafeWriteInt(typeId);
+            out.unsafeWriteByte(GridBinaryMarshaller.BINARY_ENUM);
+            out.unsafeWriteInt(typeId);
+            out.unsafeWriteInt(val.enumOrdinal());
+        }
+        else {
+            out.unsafeEnsure(1 + 4);
+
+            out.unsafeWriteByte(GridBinaryMarshaller.BINARY_ENUM);
+            out.unsafeWriteInt(typeId);
 
-        if (typeId == GridBinaryMarshaller.UNREGISTERED_TYPE_ID)
             doWriteString(val.className());
 
-        out.writeInt(val.enumOrdinal());
+            out.writeInt(val.enumOrdinal());
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 d4b0ff4..291c638 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
@@ -153,6 +153,9 @@ public class GridBinaryMarshaller {
     /** Time array. */
     public static final byte TIME_ARR = 37;
 
+    /** Binary enum */
+    public static final byte BINARY_ENUM = 38;
+
     /** */
     public static final byte NULL = (byte)101;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 6974176..b1a8da9 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
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.binary.builder;
 
 import java.util.Collection;
 import java.util.IdentityHashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.internal.binary.BinaryMetadata;
@@ -115,7 +116,14 @@ class BinaryBuilderSerializer {
             int typeId = writer.context().typeId(clsName);
             String typeName = writer.context().userTypeName(clsName);
 
-            BinaryMetadata meta = new BinaryMetadata(typeId, typeName, null, null, null, true);
+            Object[] enumVals = val.getClass().getEnumConstants();
+
+            Map<String, Integer> enumMap = new LinkedHashMap<>(enumVals.length);
+
+            for (Object enumVal : enumVals)
+                enumMap.put(((Enum)enumVal).name(), ((Enum)enumVal).ordinal());
+
+            BinaryMetadata meta = new BinaryMetadata(typeId, typeName, null, null, null, true, enumMap);
 
             writer.context().updateMetadata(typeId, meta);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 02e06fd..d6cd5ca 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
@@ -350,7 +350,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
                 BinarySchema curSchema = writer.currentSchema();
 
                 ctx.updateMetadata(typeId, new BinaryMetadata(typeId, typeName, fieldsMeta,
-                    ctx.affinityKeyFieldName(typeId), Collections.singleton(curSchema), false));
+                    ctx.affinityKeyFieldName(typeId), Collections.singleton(curSchema), false, null));
 
                 schemaReg.addSchema(curSchema.schemaId(), curSchema);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessor.java
index 1564ff3..4d285ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessor.java
@@ -59,10 +59,12 @@ public interface CacheObjectBinaryProcessor extends IgniteCacheObjectProcessor {
      * @param affKeyFieldName Affinity key field name.
      * @param fieldTypeIds Fields map.
      * @param isEnum Enum flag.
+     * @param enumMap Enum name to ordinal mapping.
      * @throws IgniteException In case of error.
      */
     public void updateMetadata(int typeId, String typeName, @Nullable String affKeyFieldName,
-        Map<String, BinaryFieldMetadata> fieldTypeIds, boolean isEnum) throws IgniteException;
+        Map<String, BinaryFieldMetadata> fieldTypeIds, boolean isEnum, @Nullable Map<String, Integer> enumMap)
+        throws IgniteException;
 
     /**
      * @param typeId Type ID.
@@ -102,6 +104,23 @@ public interface CacheObjectBinaryProcessor extends IgniteCacheObjectProcessor {
     public BinaryObject buildEnum(String typeName, int ord) throws IgniteException;
 
     /**
+     * @param typeName Type name.
+     * @param name Name.
+     * @return Enum object.
+     * @throws IgniteException If failed.
+     */
+    public BinaryObject buildEnum(String typeName, String name) throws IgniteException;
+
+    /**
+     * Register enum type
+     *
+     * @param typeName Type name.
+     * @param vals Mapping of enum constant names to ordinals.
+     * @return Binary Type for registered enum.
+     */
+    public BinaryType registerEnum(String typeName, Map<String, Integer> vals) throws IgniteException;
+
+    /**
      * @return Binaries interface.
      * @throws IgniteException If failed.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 636d149..14947e9 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
@@ -71,6 +71,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.T1;
 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.U;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgniteClosure;
@@ -170,6 +171,10 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
                     return CacheObjectBinaryProcessorImpl.this.metadata(typeId);
                 }
 
+                @Override public BinaryMetadata metadata0(int typeId) throws BinaryObjectException {
+                    return CacheObjectBinaryProcessorImpl.this.metadata0(typeId);
+                }
+
                 @Override public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException {
                     return CacheObjectBinaryProcessorImpl.this.metadata(typeId, schemaId);
                 }
@@ -207,6 +212,9 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
                                     c.isEnum()
                                 )
                             );
+
+                            if (c.isEnum())
+                                BinaryUtils.validateEnumValues(c.getTypeName(), c.getEnumValues());
                         }
 
                         map.put("typeCfgs", typeCfgsMap);
@@ -399,8 +407,10 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
 
     /** {@inheritDoc} */
     @Override public void updateMetadata(int typeId, String typeName, @Nullable String affKeyFieldName,
-        Map<String, BinaryFieldMetadata> fieldTypeIds, boolean isEnum) throws BinaryObjectException {
-        BinaryMetadata meta = new BinaryMetadata(typeId, typeName, fieldTypeIds, affKeyFieldName, null, isEnum);
+        Map<String, BinaryFieldMetadata> fieldTypeIds, boolean isEnum, @Nullable Map<String, Integer> enumMap)
+        throws BinaryObjectException {
+        BinaryMetadata meta = new BinaryMetadata(typeId, typeName, fieldTypeIds, affKeyFieldName, null, isEnum,
+            enumMap);
 
         binaryCtx.updateMetadata(typeId, meta);
     }
@@ -433,6 +443,17 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
 
     /** {@inheritDoc} */
     @Nullable @Override public BinaryType metadata(final int typeId) {
+        BinaryMetadata meta = metadata0(typeId);
+
+        return meta != null ? meta.wrap(binaryCtx) : null;
+    }
+
+    /**
+     * @param typeId Type ID.
+     * @return Meta data.
+     * @throws IgniteException In case of error.
+     */
+    @Nullable public BinaryMetadata metadata0(final int typeId) {
         BinaryMetadataHolder holder = metadataLocCache.get(typeId);
 
         if (holder == null) {
@@ -466,7 +487,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
                 }
             }
 
-            return holder.metadata().wrap(binaryCtx);
+            return holder.metadata();
         }
         else
             return null;
@@ -547,17 +568,58 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     }
 
     /** {@inheritDoc} */
-    @Override public BinaryObject buildEnum(String typeName, int ord) throws IgniteException {
+    @Override public BinaryObject buildEnum(String typeName, int ord) throws BinaryObjectException {
+        A.notNullOrEmpty(typeName, "enum type name");
+
         int typeId = binaryCtx.typeId(typeName);
 
         typeName = binaryCtx.userTypeName(typeName);
 
-        updateMetadata(typeId, typeName, null, null, true);
+        updateMetadata(typeId, typeName, null, null, true, null);
 
         return new BinaryEnumObjectImpl(binaryCtx, typeId, null, ord);
     }
 
     /** {@inheritDoc} */
+    @Override public BinaryObject buildEnum(String typeName, String name) throws BinaryObjectException {
+        A.notNullOrEmpty(typeName, "enum type name");
+        A.notNullOrEmpty(name, "enum name");
+
+        int typeId = binaryCtx.typeId(typeName);
+
+        BinaryMetadata metadata = metadata0(typeId);
+
+        if (metadata == null)
+            throw new BinaryObjectException("Failed to get metadata for type [typeId=" +
+                    typeId + ", typeName='" + typeName + "']");
+
+        Integer ordinal = metadata.getEnumOrdinalByName(name);
+
+        typeName = binaryCtx.userTypeName(typeName);
+
+        if (ordinal == null)
+            throw new BinaryObjectException("Failed to resolve enum ordinal by name [typeId=" +
+                    typeId + ", typeName='" + typeName + "', name='" + name + "']");
+
+        return new BinaryEnumObjectImpl(binaryCtx, typeId, null, ordinal);
+    }
+
+    /** {@inheritDoc} */
+    @Override public BinaryType registerEnum(String typeName, Map<String, Integer> vals) throws BinaryObjectException {
+        A.notNullOrEmpty(typeName, "enum type name");
+
+        int typeId = binaryCtx.typeId(typeName);
+
+        typeName = binaryCtx.userTypeName(typeName);
+
+        BinaryUtils.validateEnumValues(typeName, vals);
+
+        updateMetadata(typeId, typeName, null, null, true, vals);
+
+        return binaryCtx.metadata(typeId);
+    }
+
+    /** {@inheritDoc} */
     @Override public IgniteBinary binary() throws IgniteException {
         return binaries;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/IgniteBinaryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/IgniteBinaryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/IgniteBinaryImpl.java
index 1a2d0a9..e88819b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/IgniteBinaryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/IgniteBinaryImpl.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.internal.processors.cache.binary;
 
 import java.util.Collection;
+import java.util.Map;
+
 import org.apache.ignite.IgniteBinary;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
@@ -155,6 +157,30 @@ public class IgniteBinaryImpl implements IgniteBinary {
         }
     }
 
+    /** {@inheritDoc} */
+    @Override public BinaryObject buildEnum(String typeName, String name) {
+        guard();
+
+        try {
+            return proc.buildEnum(typeName, name);
+        }
+        finally {
+            unguard();
+        }
+    }
+
+    /** {@inheritDoc} */
+    public BinaryType registerEnum(String typeName, Map<String, Integer> vals) {
+        guard();
+
+        try {
+            return proc.registerEnum(typeName, vals);
+        }
+        finally {
+            unguard();
+        }
+    }
+
     /**
      * @return Binary processor.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/NoOpBinary.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/NoOpBinary.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/NoOpBinary.java
index c1c8fed..32c3be6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/NoOpBinary.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/NoOpBinary.java
@@ -17,6 +17,8 @@
 package org.apache.ignite.internal.processors.cacheobject;
 
 import java.util.Collection;
+import java.util.Map;
+
 import org.apache.ignite.IgniteBinary;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
@@ -74,6 +76,16 @@ public class NoOpBinary implements IgniteBinary {
     }
 
     /** {@inheritDoc} */
+    @Override public BinaryObject buildEnum(String typeName, String name) {
+        throw unsupported();
+    }
+
+    /** {@inheritDoc} */
+    @Override public BinaryType registerEnum(String typeName, Map<String, Integer> vals) {
+        throw unsupported();
+    }
+
+    /** {@inheritDoc} */
     private BinaryObjectException unsupported() {
         return new BinaryObjectException("Binary marshaller is not configured.");
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index 090f382..f115a9c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -82,6 +82,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -371,8 +372,19 @@ public class PlatformContextImpl implements PlatformContext {
                             }
                         });
 
+                    Map<String, Integer> enumMap = null;
+
                     boolean isEnum = reader.readBoolean();
 
+                    if (isEnum) {
+                        int size = reader.readInt();
+
+                        enumMap = new LinkedHashMap<>(size);
+
+                        for (int idx = 0; idx < size; idx++)
+                            enumMap.put(reader.readString(), reader.readInt());
+                    }
+
                     // Read schemas
                     int schemaCnt = reader.readInt();
 
@@ -393,7 +405,7 @@ public class PlatformContextImpl implements PlatformContext {
                         }
                     }
 
-                    return new BinaryMetadata(typeId, typeName, fields, affKey, schemas, isEnum);
+                    return new BinaryMetadata(typeId, typeName, fields, affKey, schemas, isEnum, enumMap);
                 }
             }
         );
@@ -474,7 +486,20 @@ public class PlatformContextImpl implements PlatformContext {
                 writer.writeInt(e.getValue().fieldId());
             }
 
-            writer.writeBoolean(meta.isEnum());
+            if (meta.isEnum()) {
+                writer.writeBoolean(true);
+
+                Map<String, Integer> enumMap = meta0.enumMap();
+
+                writer.writeInt(enumMap.size());
+
+                for (Map.Entry<String, Integer> e: enumMap.entrySet()) {
+                    writer.writeString(e.getKey());
+                    writer.writeInt(e.getValue());
+                }
+            }
+            else
+                writer.writeBoolean(false);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/binary/PlatformBinaryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/binary/PlatformBinaryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/binary/PlatformBinaryProcessor.java
index 8d95ac8..be43848 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/binary/PlatformBinaryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/binary/PlatformBinaryProcessor.java
@@ -19,12 +19,16 @@ package org.apache.ignite.internal.processors.platform.binary;
 
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryType;
 import org.apache.ignite.internal.MarshallerPlatformIds;
 import org.apache.ignite.internal.binary.BinaryRawReaderEx;
 import org.apache.ignite.internal.binary.BinaryRawWriterEx;
 import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Platform binary processor.
  */
@@ -47,6 +51,9 @@ public class PlatformBinaryProcessor extends PlatformAbstractTarget {
     /** */
     private static final int OP_GET_TYPE = 6;
 
+    /** */
+    private static final int OP_REGISTER_ENUM = 7;
+
     /**
      * Constructor.
      *
@@ -122,6 +129,24 @@ public class PlatformBinaryProcessor extends PlatformAbstractTarget {
                 break;
             }
 
+            case OP_REGISTER_ENUM: {
+                String name = reader.readString();
+
+                int cnt = reader.readInt();
+
+                Map<String, Integer> vals = new HashMap<>(cnt);
+
+                for (int i = 0; i< cnt; i++) {
+                    vals.put(reader.readString(), reader.readInt());
+                }
+
+                BinaryType binaryType = platformCtx.kernalContext().grid().binary().registerEnum(name, vals);
+
+                platformCtx.writeMetadata(writer, binaryType.typeId());
+
+                break;
+            }
+
             default:
                 super.processInStreamOutStream(type, reader, writer);
                 break;

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/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 a223022..fd26d4a 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
@@ -19,10 +19,14 @@ package org.apache.ignite.internal.binary;
 
 import java.io.Serializable;
 import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.Callable;
+
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.binary.BinaryTypeConfiguration;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.configuration.BinaryConfiguration;
@@ -31,7 +35,9 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 /**
@@ -42,6 +48,9 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
     /** Cache name. */
     private static String CACHE_NAME = "cache";
 
+    /** Name of the node that starts with bad config */
+    private static String WRONG_CONF_NODE_NAME = "WrongConfNode";
+
     /** Whether to register types or not. */
     private boolean register;
 
@@ -81,8 +90,20 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
             BinaryConfiguration bCfg = new BinaryConfiguration();
 
             BinaryTypeConfiguration enumCfg = new BinaryTypeConfiguration(EnumType.class.getName());
+
             enumCfg.setEnum(true);
 
+            if (igniteInstanceName.equals(WRONG_CONF_NODE_NAME))
+                enumCfg.setEnumValues(F.asMap(EnumType.ONE.name(),
+                        EnumType.ONE.ordinal(),
+                        EnumType.TWO.name(),
+                        EnumType.ONE.ordinal()));
+            else
+                enumCfg.setEnumValues(F.asMap(EnumType.ONE.name(),
+                        EnumType.ONE.ordinal(),
+                        EnumType.TWO.name(),
+                        EnumType.TWO.ordinal()));
+
             bCfg.setTypeConfigurations(Arrays.asList(enumCfg, new BinaryTypeConfiguration(EnumHolder.class.getName())));
 
             cfg.setBinaryConfiguration(bCfg);
@@ -317,11 +338,14 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
     public void checkSimpleBuilder(boolean registered) throws Exception {
         startUp(registered);
 
-        BinaryObject binary = node1.binary().buildEnum(EnumType.class.getName(), EnumType.ONE.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, binary);
+        cacheBinary1.put(EnumType.ONE.ordinal(), binaryOne);
+        cacheBinary1.put(EnumType.TWO.ordinal(), binaryTwo);
 
-        validateSimple(1, EnumType.ONE, registered);
+        validateSimple(EnumType.ONE.ordinal(), EnumType.ONE, registered);
+        validateSimple(EnumType.TWO.ordinal(), EnumType.TWO, registered);
     }
 
     /**
@@ -409,6 +433,112 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * Checks ability to get a collection of binary enums from binary type
+     *
+     * @throws Exception
+     */
+    public void testBinaryTypeEnumValues() throws Exception {
+        startUp(false);
+
+        defineEnum();
+
+        BinaryObject binaryOne = node1.binary().buildEnum(EnumType.class.getName(), EnumType.ONE.ordinal());
+        BinaryObject binaryTwo = node1.binary().buildEnum(EnumType.class.getName(), EnumType.TWO.name());
+
+        Collection<BinaryObject> vals = binaryOne.type().enumValues();
+
+        assertEqualsCollections(F.asList(binaryOne, binaryTwo), vals);
+    }
+
+    /**
+     * Checks the enum configuration validation during start up
+     *
+     * @throws Exception
+     */
+    public void testEnumWrongBinaryConfig() throws Exception {
+        this.register = true;
+
+        GridTestUtils.assertThrows(log, new Callable<Object> (){
+            @Override public Object call() throws Exception {
+                startGrid(WRONG_CONF_NODE_NAME);
+
+                return null;
+            }
+        }, IgniteCheckedException.class, "Conflicting enum values");
+    }
+
+    /**
+     * Checks the enum validation during type registration
+     *
+     * @throws Exception
+     */
+    public void testEnumValidation() throws Exception {
+        startUp(false);
+
+        GridTestUtils.assertThrows(log, new Callable<Object> (){
+
+            @Override public Object call() throws Exception {
+
+                node1.binary().registerEnum("invalidEnumType1",
+                    F.asMap(EnumType.ONE.name(), EnumType.ONE.ordinal(),
+                    EnumType.TWO.name(), EnumType.ONE.ordinal()));
+
+                return null;
+            }
+        }, BinaryObjectException.class, "Conflicting enum values");
+    }
+
+    /**
+     * Checks the enum merge
+     *
+     * @throws Exception
+     */
+    public void testEnumMerge() throws Exception {
+        startUp(false);
+
+        final String enumName = "mergedEnum";
+
+        node1.binary().registerEnum(enumName,
+                F.asMap(EnumType.ONE.name(), EnumType.ONE.ordinal()));
+
+        GridTestUtils.assertThrows(log, new Callable<Object> (){
+
+            @Override public Object call() throws Exception {
+
+                node2.binary().registerEnum(enumName,
+                        F.asMap(EnumType.TWO.name(), EnumType.ONE.ordinal()));
+
+                return null;
+            }
+        }, BinaryObjectException.class, "Conflicting enum values. Name ");
+
+        GridTestUtils.assertThrows(log, new Callable<Object> (){
+            @Override public Object call() throws Exception {
+
+                node2.binary().registerEnum(enumName,
+                        F.asMap(EnumType.ONE.name(), EnumType.TWO.ordinal()));
+
+                return null;
+            }
+        }, BinaryObjectException.class, "Conflicting enum values. Value ");
+
+        node2.binary().registerEnum(enumName,
+                F.asMap(EnumType.ONE.name(), EnumType.ONE.ordinal(),
+                        EnumType.TWO.name(), EnumType.TWO.ordinal()));
+
+        Collection<BinaryObject> vals = node1.binary().type(enumName).enumValues();
+        BinaryObject[] values = vals.toArray(new BinaryObject[vals.size()]);
+
+        assertEquals(2, values.length);
+
+        assertEquals(EnumType.ONE.ordinal(), values[0].enumOrdinal());
+        assertEquals(EnumType.TWO.ordinal(), values[1].enumOrdinal());
+
+        assertEquals(EnumType.ONE.name(), values[0].enumName());
+        assertEquals(EnumType.TWO.name(), values[1].enumName());
+    }
+
+    /**
      * Validate simple array.
      *
      * @param registered Registered flag.
@@ -472,6 +602,16 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
         assertEquals(node2.binary().typeId(EnumType.class.getName()), obj.type().typeId());
 
         assertEquals(val.ordinal(), obj.enumOrdinal());
+
+        if (register)
+            assertEquals(val.name(), obj.enumName());
+    }
+
+    /** Register enum */
+    private void defineEnum() {
+        node1.binary().registerEnum(EnumType.class.getName(),
+                F.asMap(EnumType.ONE.name(), EnumType.ONE.ordinal(),
+                        EnumType.TWO.name(), EnumType.TWO.ordinal()));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/test/java/org/apache/ignite/internal/binary/TestCachingMetadataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/TestCachingMetadataHandler.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/TestCachingMetadataHandler.java
index 704c8f3..77cbffe 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/TestCachingMetadataHandler.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/TestCachingMetadataHandler.java
@@ -44,6 +44,11 @@ public class TestCachingMetadataHandler implements BinaryMetadataHandler {
     }
 
     /** {@inheritDoc} */
+    @Override public BinaryMetadata metadata0(int typeId) throws BinaryObjectException {
+        return null;
+    }
+
+    /** {@inheritDoc} */
     @Override public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
index a5a35c1..984cf62 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
@@ -110,6 +110,9 @@ public class PlatformComputeEchoTask extends ComputeTaskAdapter<Integer, Object>
     /** Type: ignite uuid. */
     private static final int TYPE_IGNITE_UUID = 22;
 
+    /** Type: binary enum. */
+    private static final int TYPE_BINARY_ENUM = 23;
+
     /** Default cache name. */
     public static final String DEFAULT_CACHE_NAME = "default";
 
@@ -228,6 +231,16 @@ public class PlatformComputeEchoTask extends ComputeTaskAdapter<Integer, Object>
                 case TYPE_IGNITE_UUID:
                     return ignite.cache(DEFAULT_CACHE_NAME).get(TYPE_IGNITE_UUID);
 
+                case TYPE_BINARY_ENUM: {
+                    Map<String, Integer> values = new HashMap<>(2);
+                    values.put("JavaFoo", 1);
+                    values.put("JavaBar", 2);
+
+                    ignite.binary().registerEnum("JavaDynEnum", values);
+
+                    return ignite.binary().buildEnum("JavaDynEnum", "JavaFoo");
+                }
+
                 default:
                     throw new IgniteException("Unknown type: " + type);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
index a7794c6..61f90a3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
@@ -1140,6 +1140,9 @@ namespace Apache.Ignite.Core.Tests.Binary
             Assert.AreEqual(new[] { TestEnum.Two }, obj.FEnumArr);
         }
 
+        /// <summary>
+        /// Tests the enum metadata.
+        /// </summary>
         [Test]
         public void TestEnumMeta()
         {
@@ -1148,14 +1151,21 @@ namespace Apache.Ignite.Core.Tests.Binary
             // Put to cache to populate metas
             var binEnum = bin.ToBinary<IBinaryObject>(TestEnumRegistered.One);
 
-            Assert.AreEqual(_marsh.GetDescriptor(typeof (TestEnumRegistered)).TypeId, binEnum.GetBinaryType().TypeId);
+            Assert.AreEqual(_marsh.GetDescriptor(typeof(TestEnumRegistered)).TypeId, binEnum.GetBinaryType().TypeId);
             Assert.AreEqual(0, binEnum.EnumValue);
+            Assert.AreEqual("One", binEnum.EnumName);
 
             var meta = binEnum.GetBinaryType();
 
             Assert.IsTrue(meta.IsEnum);
-            Assert.AreEqual(GetTypeName(typeof (TestEnumRegistered)), meta.TypeName);
+            Assert.AreEqual(GetTypeName(typeof(TestEnumRegistered)), meta.TypeName);
             Assert.AreEqual(0, meta.Fields.Count);
+
+            var enumValues = meta.GetEnumValues().OrderBy(x => x.EnumValue).ToArray();
+            Assert.AreEqual(0, enumValues[0].EnumValue);
+            Assert.AreEqual("One", enumValues[0].EnumName);
+            Assert.AreEqual(1, enumValues[1].EnumValue);
+            Assert.AreEqual("Two", enumValues[1].EnumName);
         }
 
         /// <summary>
@@ -1653,26 +1663,30 @@ namespace Apache.Ignite.Core.Tests.Binary
         {
             var binary = _grid.GetBinary();
 
-            int val = (int)TestEnumRegistered.Two;
+            var enumVal = TestEnumRegistered.Two;
+            var intVal = (int) enumVal;
             var typeName = GetTypeName(typeof(TestEnumRegistered));
             var typeId = BinaryUtils.GetStringHashCode(typeName);
 
             var binEnums = new[]
             {
-                binary.BuildEnum(typeof (TestEnumRegistered), val),
-                binary.BuildEnum(typeName, val)
+                binary.BuildEnum(typeof (TestEnumRegistered), intVal),
+                binary.BuildEnum(typeName, intVal),
+                binary.BuildEnum(typeof (TestEnumRegistered), enumVal.ToString()),
+                binary.BuildEnum(typeName, enumVal.ToString())
             };
 
             foreach (var binEnum in binEnums)
             {
                 Assert.IsTrue(binEnum.GetBinaryType().IsEnum);
 
-                Assert.AreEqual(val, binEnum.EnumValue);
+                Assert.AreEqual(intVal, binEnum.EnumValue);
+                Assert.AreEqual(enumVal.ToString(), binEnum.EnumName);
 
                 Assert.AreEqual(string.Format("{0} [typeId={1}, enumValue={2}, enumValueName={3}]",
-                    typeName, typeId, val, (TestEnumRegistered) val), binEnum.ToString());
+                    typeName, typeId, intVal, enumVal), binEnum.ToString());
 
-                Assert.AreEqual((TestEnumRegistered)val, binEnum.Deserialize<TestEnumRegistered>());
+                Assert.AreEqual(enumVal, binEnum.Deserialize<TestEnumRegistered>());
             }
 
             Assert.AreEqual(binEnums[0], binEnums[1]);
@@ -1687,6 +1701,60 @@ namespace Apache.Ignite.Core.Tests.Binary
         }
 
         /// <summary>
+        /// Tests enum registration.
+        /// </summary>
+        [Test]
+        public void TestRegisterEnum()
+        {
+            var binary = _grid.GetBinary();
+
+            // Register enum and verify resulting type.
+            const string typeName = "DotNetDynEnum";
+            var binType = binary.RegisterEnum(typeName, new Dictionary<string, int> {{"Baz", 3}, {"Bar", 4}});
+
+            Assert.AreEqual(typeName, binType.TypeName);
+            Assert.IsTrue(binType.IsEnum);
+
+            var enumFields = binType.GetEnumValues().OrderBy(x => x.EnumValue).ToArray();
+            Assert.AreEqual(new[] {3, 4}, enumFields.Select(x => x.EnumValue));
+            Assert.AreEqual(new[] {"Baz", "Bar"}, enumFields.Select(x => x.EnumName));
+
+            // Build enum values.
+            var binEnum1 = binary.BuildEnum(typeName, 3);
+            var binEnum2 = binary.BuildEnum(typeName, "Baz");
+
+            Assert.AreEqual(binEnum1, binEnum2);
+            Assert.AreEqual("Baz", binEnum1.EnumName);
+            Assert.AreEqual(3, binEnum2.EnumValue);
+
+            // Register additional value explicitly.
+            binary.RegisterEnum(typeName, new Dictionary<string, int> {{"Foo", 6}});
+            binary.RegisterEnum(typeName, new Dictionary<string, int> {{"Foo", 6}, {"Baz", 3}});
+            binType = binary.GetBinaryType(typeName);
+
+            Assert.AreEqual(typeName, binType.TypeName);
+            Assert.IsTrue(binType.IsEnum);
+
+            enumFields = binType.GetEnumValues().OrderBy(x => x.EnumValue).ToArray();
+            Assert.AreEqual(new[] { 3, 4, 6 }, enumFields.Select(x => x.EnumValue));
+            Assert.AreEqual(new[] { "Baz", "Bar", "Foo" }, enumFields.Select(x => x.EnumName));
+
+            // Register existing value with different name.
+            var ex = Assert.Throws<BinaryObjectException>(
+                () => binary.RegisterEnum(typeName, new Dictionary<string, int> {{"Baz1", 3}}));
+
+            Assert.AreEqual(string.Format("Conflicting enum values. Name 'Baz1' uses ordinal value (3) that " +
+                                          "is also used for name 'Baz' [typeName='{0}']", typeName), ex.Message);
+
+            // Register different value with existing name.
+            ex = Assert.Throws<BinaryObjectException>(
+                () => binary.RegisterEnum(typeName, new Dictionary<string, int> {{"Baz", 33}}));
+
+            Assert.AreEqual(string.Format("Conflicting enum values. Value (33) has name 'Baz' that is " +
+                                          "also used for value '3' [typeName='{0}']", typeName), ex.Message);
+        }
+
+        /// <summary>
         /// Tests the compact footer setting.
         /// </summary>
         [Test]
@@ -2102,13 +2170,13 @@ namespace Apache.Ignite.Core.Tests.Binary
         /** <inheritdoc /> */
         public int GetTypeId(string typeName)
         {
-            return typeName == TestTypeName ? TestTypeId : 0;
+            return typeName == TestTypeName ? TestTypeId : BinaryUtils.GetStringHashCode(typeName);
         }
 
         /** <inheritdoc /> */
         public int GetFieldId(int typeId, string fieldName)
         {
-            return 0;
+            return BinaryUtils.GetStringHashCode(fieldName);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index b9b7a04..1d8ceb9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -122,6 +122,9 @@ namespace Apache.Ignite.Core.Tests.Compute
         /** Echo type: IgniteUuid. */
         private const int EchoTypeIgniteUuid = 22;
 
+        /** Echo type: binary enum (created with builder). */
+        private const int EchoTypeBinaryEnum = 23;
+
         /** */
         private const string DefaultCacheName = "default";
 
@@ -940,6 +943,28 @@ namespace Apache.Ignite.Core.Tests.Compute
         /// Tests the echo task returning enum.
         /// </summary>
         [Test]
+        public void TestEchoTaskBinaryEnum()
+        {
+            var res = _grid1.GetCompute().WithKeepBinary()
+                .ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinaryEnum);
+
+            Assert.AreEqual("JavaFoo", res.EnumName);
+            Assert.AreEqual(1, res.EnumValue);
+
+            var binType = res.GetBinaryType();
+
+            Assert.IsTrue(binType.IsEnum);
+            Assert.AreEqual("JavaDynEnum", binType.TypeName);
+
+            var vals = binType.GetEnumValues().OrderBy(x => x.EnumValue).ToArray();
+            Assert.AreEqual(new[] {1, 2}, vals.Select(x => x.EnumValue));
+            Assert.AreEqual(new[] {"JavaFoo", "JavaBar"}, vals.Select(x => x.EnumName));
+        }
+
+        /// <summary>
+        /// Tests the echo task returning enum.
+        /// </summary>
+        [Test]
         public void TestEchoTaskEnumFromCache()
         {
             var cache = _grid1.GetCache<int, PlatformComputeEnum>(DefaultCacheName);

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
index c36b9fd..2d299f3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
@@ -18,6 +18,7 @@
 namespace Apache.Ignite.Core.Binary
 {
     using System;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Common;
 
     /// <summary>
@@ -51,7 +52,7 @@ namespace Apache.Ignite.Core.Binary
             IgniteArgumentCheck.NotNull(type, "type");
 
             TypeName = type.AssemblyQualifiedName;
-            IsEnum = type.IsEnum;
+            IsEnum = BinaryUtils.IsIgniteEnum(type);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c7b6f5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinary.cs
index f269681..671efa4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinary.cs
@@ -131,5 +131,29 @@ namespace Apache.Ignite.Core.Binary
         /// <param name="value">Enum int value.</param>
         /// <returns>Binary representation of the specified enum value.</returns>
         IBinaryObject BuildEnum(Type type, int value);
+
+        /// <summary>
+        /// Converts enum to a binary form.
+        /// </summary>
+        /// <param name="typeName">Enum type name.</param>
+        /// <param name="valueName">Enum value name.</param>
+        /// <returns>Binary representation of the specified enum value.</returns>
+        IBinaryObject BuildEnum(string typeName, string valueName);
+
+        /// <summary>
+        /// Converts enum to a binary form.
+        /// </summary>
+        /// <param name="type">Enum type.</param>
+        /// <param name="valueName">Enum value name.</param>
+        /// <returns>Binary representation of the specified enum value.</returns>
+        IBinaryObject BuildEnum(Type type, string valueName);
+
+        /// <summary>
+        /// Registers enum type.
+        /// </summary>
+        /// <param name="typeName">Name of the type.</param>
+        /// <param name="values">Mapping of enum value names to int values.</param>
+        /// <returns>Binary type for registered enum.</returns>
+        IBinaryType RegisterEnum(string typeName, IEnumerable<KeyValuePair<string, int>> values);
     }
 }