You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/10/25 12:55:21 UTC

[1/8] ignite git commit: IGNITE-6705 .NET: CacheConfiguration missing properties

Repository: ignite
Updated Branches:
  refs/heads/ignite-6748 31a8b9a14 -> 53a1ea971


IGNITE-6705 .NET: CacheConfiguration missing properties

This closes #2921


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

Branch: refs/heads/ignite-6748
Commit: 1816fb9205d533b38487918bddb0863b813f812b
Parents: 93be8ea
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Wed Oct 25 13:07:52 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Wed Oct 25 13:07:52 2017 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       |   2 +
 .../utils/PlatformConfigurationUtils.java       |  20 ++++
 .../ApiParity/CacheConfigurationParityTest.cs   |  12 +-
 .../Cache/CacheConfigurationTest.cs             |  37 +++++-
 .../Config/full-config.xml                      |   4 +-
 .../IgniteConfigurationSerializerTest.cs        |  19 ++-
 .../Cache/Configuration/CacheConfiguration.cs   | 115 ++++++++++++++++++-
 .../IgniteConfigurationSection.xsd              |  40 +++++++
 8 files changed, 233 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1816fb92/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 37a0677..e240df8 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
@@ -442,6 +442,8 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
         writeBehindFlushSize = cc.getWriteBehindFlushSize();
         writeBehindFlushThreadCnt = cc.getWriteBehindFlushThreadCount();
         writeSync = cc.getWriteSynchronizationMode();
+        storeConcurrentLoadAllThreshold = cc.getStoreConcurrentLoadAllThreshold();
+        maxQryIterCnt = cc.getMaxQueryIteratorsCount();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/1816fb92/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 981a231..28b6c60 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -202,6 +202,18 @@ public class PlatformConfigurationUtils {
             ccfg.setCacheStoreFactory(new PlatformDotNetCacheStoreFactoryNative(storeFactory));
 
         ccfg.setSqlIndexMaxInlineSize(in.readInt());
+        ccfg.setOnheapCacheEnabled(in.readBoolean());
+        ccfg.setStoreConcurrentLoadAllThreshold(in.readInt());
+        ccfg.setRebalanceOrder(in.readInt());
+        ccfg.setRebalanceBatchesPrefetchCount(in.readLong());
+        ccfg.setMaxQueryIteratorsCount(in.readInt());
+        ccfg.setQueryDetailMetricsSize(in.readInt());
+        ccfg.setQueryParallelism(in.readInt());
+
+        String sqlSchema = in.readString();
+        if (sqlSchema != null) {
+            ccfg.setSqlSchema(sqlSchema);
+        }
 
         int qryEntCnt = in.readInt();
 
@@ -903,6 +915,14 @@ public class PlatformConfigurationUtils {
             writer.writeObject(null);
 
         writer.writeInt(ccfg.getSqlIndexMaxInlineSize());
+        writer.writeBoolean(ccfg.isOnheapCacheEnabled());
+        writer.writeInt(ccfg.getStoreConcurrentLoadAllThreshold());
+        writer.writeInt(ccfg.getRebalanceOrder());
+        writer.writeLong(ccfg.getRebalanceBatchesPrefetchCount());
+        writer.writeInt(ccfg.getMaxQueryIteratorsCount());
+        writer.writeInt(ccfg.getQueryDetailMetricsSize());
+        writer.writeInt(ccfg.getQueryParallelism());
+        writer.writeString(ccfg.getSqlSchema());
 
         Collection<QueryEntity> qryEntities = ccfg.getQueryEntities();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/1816fb92/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheConfigurationParityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheConfigurationParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheConfigurationParityTest.cs
index 6bc5472..0467937 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheConfigurationParityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheConfigurationParityTest.cs
@@ -56,17 +56,7 @@ namespace Apache.Ignite.Core.Tests.ApiParity
         /** Properties that are missing on .NET side. */
         private static readonly string[] MissingProperties =
         {
-            "NodeFilter",  // IGNITE-2890
-
-            // IGNITE-6705
-            "IsOnheapCacheEnabled",
-            "StoreConcurrentLoadAllThreshold",
-            "RebalanceOrder",
-            "RebalanceBatchesPrefetchCount",
-            "MaxQueryIteratorsCount",
-            "QueryDetailMetricsSize",
-            "SqlSchema",
-            "QueryParallelism"
+            "NodeFilter"  // IGNITE-2890
         };
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1816fb92/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
index 5556807..b5d8367 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -167,6 +167,13 @@ namespace Apache.Ignite.Core.Tests.Cache
             // Check put-get
             cache[1] = new Entity { Foo = 1 };
             Assert.AreEqual(1, cache[1].Foo);
+
+            // Check another config
+            cacheName = Guid.NewGuid().ToString();
+            cfg = GetCustomCacheConfiguration2(cacheName);
+
+            cache = _ignite.CreateCache<int, Entity>(cfg);
+            AssertConfigsAreEqual(cfg, cache.GetConfiguration());
         }
 
         /// <summary>
@@ -269,6 +276,14 @@ namespace Apache.Ignite.Core.Tests.Cache
             Assert.AreEqual(CacheConfiguration.DefaultReadThrough, cfg.ReadThrough);
             Assert.AreEqual(CacheConfiguration.DefaultCopyOnRead, cfg.CopyOnRead);
             Assert.AreEqual(CacheConfiguration.DefaultKeepBinaryInStore, cfg.KeepBinaryInStore);
+            Assert.AreEqual(CacheConfiguration.DefaultStoreConcurrentLoadAllThreshold, 
+                cfg.StoreConcurrentLoadAllThreshold);
+            Assert.AreEqual(CacheConfiguration.DefaultRebalanceOrder, cfg.RebalanceOrder);
+            Assert.AreEqual(CacheConfiguration.DefaultRebalanceBatchesPrefetchCount, cfg.RebalanceBatchesPrefetchCount);
+            Assert.AreEqual(CacheConfiguration.DefaultMaxQueryIteratorsCount, cfg.MaxQueryIteratorsCount);
+            Assert.AreEqual(CacheConfiguration.DefaultQueryDetailMetricsSize, cfg.QueryDetailMetricsSize);
+            Assert.IsNull(cfg.SqlSchema);
+            Assert.AreEqual(CacheConfiguration.DefaultQueryParallelism, cfg.QueryParallelism);
         }
 
         /// <summary>
@@ -331,6 +346,15 @@ namespace Apache.Ignite.Core.Tests.Cache
             }
 
             TestUtils.AssertReflectionEqual(x.KeyConfiguration, y.KeyConfiguration);
+
+            Assert.AreEqual(x.OnheapCacheEnabled, y.OnheapCacheEnabled);
+            Assert.AreEqual(x.StoreConcurrentLoadAllThreshold, y.StoreConcurrentLoadAllThreshold);
+            Assert.AreEqual(x.RebalanceOrder, y.RebalanceOrder);
+            Assert.AreEqual(x.RebalanceBatchesPrefetchCount, y.RebalanceBatchesPrefetchCount);
+            Assert.AreEqual(x.MaxQueryIteratorsCount, y.MaxQueryIteratorsCount);
+            Assert.AreEqual(x.QueryDetailMetricsSize, y.QueryDetailMetricsSize);
+            Assert.AreEqual(x.QueryParallelism, y.QueryParallelism);
+            Assert.AreEqual(x.SqlSchema, y.SqlSchema);
         }
 
         /// <summary>
@@ -645,7 +669,15 @@ namespace Apache.Ignite.Core.Tests.Cache
                         TypeName = "foobar",
                         AffinityKeyFieldName = "barbaz"
                     }
-                }
+                },
+                OnheapCacheEnabled = true,
+                StoreConcurrentLoadAllThreshold = 7,
+                RebalanceOrder = 3,
+                RebalanceBatchesPrefetchCount = 4,
+                MaxQueryIteratorsCount = 512,
+                QueryDetailMetricsSize = 100,
+                QueryParallelism = 16,
+                SqlSchema = "foo" + name
             };
         }
         /// <summary>
@@ -725,7 +757,8 @@ namespace Apache.Ignite.Core.Tests.Cache
                     MaxSize = 26,
                     MaxMemorySize = 2501,
                     BatchSize = 33
-                },
+                }, 
+                OnheapCacheEnabled = true,  // Required with eviction policy
                 AffinityFunction = new RendezvousAffinityFunction
                 {
                     Partitions = 113,

http://git-wip-us.apache.org/repos/asf/ignite/blob/1816fb92/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
index 7ad5d48..03559bf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
@@ -51,7 +51,9 @@
         <iLifecycleHandler type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+LifecycleBean' foo='15' />
     </lifecycleHandlers>
     <cacheConfiguration>
-        <cacheConfiguration cacheMode='Replicated' readThrough='true' writeThrough='true' enableStatistics='true' writeBehindCoalescing='false' partitionLossPolicy='ReadWriteAll' groupName='fooGroup'>
+        <cacheConfiguration cacheMode='Replicated' readThrough='true' writeThrough='true' enableStatistics='true' writeBehindCoalescing='false' partitionLossPolicy='ReadWriteAll' groupName='fooGroup'
+                            onheapCacheEnabled='true' storeConcurrentLoadAllThreshold='8' rebalanceOrder='9' rebalanceBatchesPrefetchCount='10' maxQueryIteratorsCount='11' queryDetailMetricsSize='12'
+                            queryParallelism='13' sqlSchema='mySchema'>
             <queryEntities>
                 <queryEntity keyType='System.Int32' valueType='System.String' tableName='myTable'>
                     <fields>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1816fb92/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index 4be34c7..b8c1069 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -115,6 +115,15 @@ namespace Apache.Ignite.Core.Tests
             Assert.AreEqual("bar", cacheCfg.KeyConfiguration.Single().AffinityKeyFieldName);
             Assert.AreEqual("foo", cacheCfg.KeyConfiguration.Single().TypeName);
 
+            Assert.IsTrue(cacheCfg.OnheapCacheEnabled);
+            Assert.AreEqual(8, cacheCfg.StoreConcurrentLoadAllThreshold);
+            Assert.AreEqual(9, cacheCfg.RebalanceOrder);
+            Assert.AreEqual(10, cacheCfg.RebalanceBatchesPrefetchCount);
+            Assert.AreEqual(11, cacheCfg.MaxQueryIteratorsCount);
+            Assert.AreEqual(12, cacheCfg.QueryDetailMetricsSize);
+            Assert.AreEqual(13, cacheCfg.QueryParallelism);
+            Assert.AreEqual("mySchema", cacheCfg.SqlSchema);
+
             var queryEntity = cacheCfg.QueryEntities.Single();
             Assert.AreEqual(typeof(int), queryEntity.KeyType);
             Assert.AreEqual(typeof(string), queryEntity.ValueType);
@@ -733,7 +742,15 @@ namespace Apache.Ignite.Core.Tests
                                 AffinityKeyFieldName = "abc",
                                 TypeName = "def"
                             }, 
-                        }
+                        },
+                        OnheapCacheEnabled = true,
+                        StoreConcurrentLoadAllThreshold = 7,
+                        RebalanceOrder = 3,
+                        RebalanceBatchesPrefetchCount = 4,
+                        MaxQueryIteratorsCount = 512,
+                        QueryDetailMetricsSize = 100,
+                        QueryParallelism = 16,
+                        SqlSchema = "foo"
                     }
                 },
                 ClientMode = true,

http://git-wip-us.apache.org/repos/asf/ignite/blob/1816fb92/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
index f4af778..4880eb3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
@@ -28,7 +28,6 @@ namespace Apache.Ignite.Core.Cache.Configuration
     using System.IO;
     using System.Linq;
     using System.Xml.Serialization;
-    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Affinity;
     using Apache.Ignite.Core.Cache.Affinity.Rendezvous;
@@ -143,6 +142,24 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// <summary> Default value for <see cref="SqlIndexMaxInlineSize"/>. </summary>
         public const int DefaultSqlIndexMaxInlineSize = -1;
 
+        /// <summary> Default value for <see cref="StoreConcurrentLoadAllThreshold"/>. </summary>
+        public const int DefaultStoreConcurrentLoadAllThreshold = 5;
+
+        /// <summary> Default value for <see cref="RebalanceOrder"/>. </summary>
+        public const int DefaultRebalanceOrder = 0;
+
+        /// <summary> Default value for <see cref="RebalanceBatchesPrefetchCount"/>. </summary>
+        public const long DefaultRebalanceBatchesPrefetchCount = 2;
+
+        /// <summary> Default value for <see cref="MaxQueryIteratorsCount"/>. </summary>
+        public const int DefaultMaxQueryIteratorsCount = 1024;
+
+        /// <summary> Default value for <see cref="QueryDetailMetricsSize"/>. </summary>
+        public const int DefaultQueryDetailMetricsSize = 0;
+
+        /// <summary> Default value for <see cref="QueryParallelism"/>. </summary>
+        public const int DefaultQueryParallelism = 1;
+
         /// <summary>
         /// Gets or sets the cache name.
         /// </summary>
@@ -191,6 +208,11 @@ namespace Apache.Ignite.Core.Cache.Configuration
             WriteBehindCoalescing = DefaultWriteBehindCoalescing;
             PartitionLossPolicy = DefaultPartitionLossPolicy;
             SqlIndexMaxInlineSize = DefaultSqlIndexMaxInlineSize;
+            StoreConcurrentLoadAllThreshold = DefaultStoreConcurrentLoadAllThreshold;
+            RebalanceOrder = DefaultRebalanceOrder;
+            RebalanceBatchesPrefetchCount = DefaultRebalanceBatchesPrefetchCount;
+            MaxQueryIteratorsCount = DefaultMaxQueryIteratorsCount;
+            QueryParallelism = DefaultQueryParallelism;
         }
 
         /// <summary>
@@ -294,6 +316,14 @@ namespace Apache.Ignite.Core.Cache.Configuration
             GroupName = reader.ReadString();
             CacheStoreFactory = reader.ReadObject<IFactory<ICacheStore>>();
             SqlIndexMaxInlineSize = reader.ReadInt();
+            OnheapCacheEnabled = reader.ReadBoolean();
+            StoreConcurrentLoadAllThreshold = reader.ReadInt();
+            RebalanceOrder = reader.ReadInt();
+            RebalanceBatchesPrefetchCount = reader.ReadLong();
+            MaxQueryIteratorsCount = reader.ReadInt();
+            QueryDetailMetricsSize = reader.ReadInt();
+            QueryParallelism = reader.ReadInt();
+            SqlSchema = reader.ReadString();
 
             QueryEntities = reader.ReadCollectionRaw(r => new QueryEntity(r));
 
@@ -382,6 +412,14 @@ namespace Apache.Ignite.Core.Cache.Configuration
             writer.WriteString(GroupName);
             writer.WriteObject(CacheStoreFactory);
             writer.WriteInt(SqlIndexMaxInlineSize);
+            writer.WriteBoolean(OnheapCacheEnabled);
+            writer.WriteInt(StoreConcurrentLoadAllThreshold);
+            writer.WriteInt(RebalanceOrder);
+            writer.WriteLong(RebalanceBatchesPrefetchCount);
+            writer.WriteInt(MaxQueryIteratorsCount);
+            writer.WriteInt(QueryDetailMetricsSize);
+            writer.WriteInt(QueryParallelism);
+            writer.WriteString(SqlSchema);
 
             writer.WriteCollectionRaw(QueryEntities);
 
@@ -799,5 +837,80 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// </summary>
         [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public ICollection<CacheKeyConfiguration> KeyConfiguration { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether on-heap cache is enabled for the off-heap based page memory.
+        /// </summary>
+        public bool OnheapCacheEnabled { get; set; }
+
+        /// <summary>
+        /// Gets or sets the threshold to use when multiple keys are being loaded from an underlying cache store
+        /// (see <see cref="CacheStoreFactory"/>).
+        /// 
+        /// In the situation when several threads load the same or intersecting set of keys
+        /// and the total number of keys to load is less or equal to this threshold then there will be no
+        /// second call to the storage in order to load a key from thread A if the same key is already being
+        /// loaded by thread B.
+        ///
+        /// The threshold should be controlled wisely. On the one hand if it's set to a big value then the
+        /// interaction with a storage during the load of missing keys will be minimal.On the other hand the big
+        /// value may result in significant performance degradation because it is needed to check
+        /// for every key whether it's being loaded or not.
+        /// </summary>
+        [DefaultValue(DefaultStoreConcurrentLoadAllThreshold)]
+        public int StoreConcurrentLoadAllThreshold { get; set; }
+
+        /// <summary>
+        /// Gets or sets the cache rebalance order. Caches with bigger RebalanceOrder are rebalanced later than caches
+        /// with smaller RebalanceOrder.
+        /// <para />
+        /// Default is 0, which means unordered rebalance. All caches with RebalanceOrder=0 are rebalanced without any
+        /// delay concurrently.
+        /// <para />
+        /// This parameter is applicable only for caches with <see cref="RebalanceMode"/> of
+        /// <see cref="CacheRebalanceMode.Sync"/> and <see cref="CacheRebalanceMode.Async"/>.
+        /// </summary>
+        [DefaultValue(DefaultRebalanceOrder)]
+        public int RebalanceOrder { get; set; }
+
+        /// <summary>
+        /// Gets or sets the rebalance batches prefetch count.
+        /// <para />
+        /// Source node can provide more than one batch at rebalance start to improve performance.
+        /// Default is <see cref="DefaultRebalanceBatchesPrefetchCount"/>, minimum is 2.
+        /// </summary>
+        [DefaultValue(DefaultRebalanceBatchesPrefetchCount)]
+        public long RebalanceBatchesPrefetchCount { get; set; }
+
+        /// <summary>
+        /// Gets or sets the maximum number of active query iterators.
+        /// </summary>
+        [DefaultValue(DefaultMaxQueryIteratorsCount)]
+        public int MaxQueryIteratorsCount { get; set; }
+
+        /// <summary>
+        /// Gets or sets the size of the query detail metrics to be stored in memory.
+        /// <para />
+        /// 0 means disabled metrics.
+        /// </summary>
+        [DefaultValue(DefaultQueryDetailMetricsSize)]
+        public int QueryDetailMetricsSize { get; set; }
+
+        /// <summary>
+        /// Gets or sets the SQL schema.
+        /// Non-quoted identifiers are not case sensitive. Quoted identifiers are case sensitive.
+        /// <para />
+        /// Quoted <see cref="Name"/> is used by default.
+        /// </summary>
+        public string SqlSchema { get; set; }
+
+        /// <summary>
+        /// Gets or sets the desired query parallelism within a single node.
+        /// Query executor may or may not use this hint, depending on estimated query cost.
+        /// <para />
+        /// Default is <see cref="DefaultQueryParallelism"/>.
+        /// </summary>
+        [DefaultValue(DefaultQueryParallelism)]
+        public int QueryParallelism { get; set; }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/1816fb92/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index 82eb465..70b1fc4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -805,6 +805,46 @@
                                             <xs:documentation>Maximum size of SQL inline index. Part of indexed value will be placed directly to index pages, thus minimizing data page accesses and increasing query performance.</xs:documentation>
                                         </xs:annotation>
                                     </xs:attribute>
+                                    <xs:attribute name="onheapCacheEnabled" type="xs:boolean">
+                                        <xs:annotation>
+                                            <xs:documentation>Whether on-heap cache is enabled for the off-heap based page memory.</xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
+                                    <xs:attribute name="storeConcurrentLoadAllThreshold" type="xs:int">
+                                        <xs:annotation>
+                                            <xs:documentation>Threshold to use when multiple keys are being loaded from an underlying cache store.</xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
+                                    <xs:attribute name="rebalanceOrder" type="xs:int">
+                                        <xs:annotation>
+                                            <xs:documentation>Caches with bigger RebalanceOrder are rebalanced later than caches with smaller RebalanceOrder. 0 for unordered (immediate) rebalance.</xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
+                                    <xs:attribute name="rebalanceBatchesPrefetchCount" type="xs:int">
+                                        <xs:annotation>
+                                            <xs:documentation>Rebalance batches prefetch count.</xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
+                                    <xs:attribute name="maxQueryIteratorsCount" type="xs:int">
+                                        <xs:annotation>
+                                            <xs:documentation>Maximum number of active query iterators.</xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
+                                    <xs:attribute name="queryDetailMetricsSize" type="xs:int">
+                                        <xs:annotation>
+                                            <xs:documentation>Size of the query detail metrics to be stored in memory.</xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
+                                    <xs:attribute name="sqlSchema" type="xs:string">
+                                        <xs:annotation>
+                                            <xs:documentation>SQL schema. Non-quoted identifiers are not case sensitive. Quoted identifiers are case sensitive. Quoted cache name is used by default.</xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
+                                    <xs:attribute name="queryParallelism" type="xs:int">
+                                        <xs:annotation>
+                                            <xs:documentation>Desired query parallelism within a single node.</xs:documentation>
+                                        </xs:annotation>
+                                    </xs:attribute>
                                 </xs:complexType>
                             </xs:element>
                         </xs:sequence>


[4/8] ignite git commit: Merge remote-tracking branch 'origin/master'

Posted by ag...@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/f7aa443b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f7aa443b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f7aa443b

Branch: refs/heads/ignite-6748
Commit: f7aa443ba1ebe1fffdfede5a42028ac18485bb3a
Parents: ee6daae dde3486
Author: devozerov <vo...@gridgain.com>
Authored: Wed Oct 25 14:45:15 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Wed Oct 25 14:45:15 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteSpringBean.java     |  32 ++-
 .../GridSpringBeanSerializationSelfTest.java    |   4 +-
 .../ignite/internal/IgniteSpringBeanTest.java   |   2 +-
 .../GridServiceInjectionSpringResourceTest.java |  10 +-
 ...teSpringBeanSpringResourceInjectionTest.java | 215 +++++++++++++++++++
 .../ignite/spring/injection/spring-bean.xml     |  84 ++++++++
 .../testsuites/IgniteSpringTestSuite.java       |   2 +
 7 files changed, 334 insertions(+), 15 deletions(-)
----------------------------------------------------------------------



[7/8] ignite git commit: IGNITE-6748 Moved checkpoint page buffer to data region configuration

Posted by ag...@apache.org.
IGNITE-6748 Moved checkpoint page buffer to data region configuration


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

Branch: refs/heads/ignite-6748
Commit: 718f912fc67d9ae34b4be66409bbfe47c086f8cf
Parents: bbf4853
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Oct 25 12:38:58 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Oct 25 15:54:44 2017 +0300

----------------------------------------------------------------------
 .../configuration/DataRegionConfiguration.java  | 34 +++++++++-
 .../configuration/DataStorageConfiguration.java | 29 --------
 .../org/apache/ignite/internal/IgnitionEx.java  | 13 ++--
 .../discovery/GridDiscoveryManager.java         |  8 ++-
 .../GridCacheDatabaseSharedManager.java         | 71 +++++++-------------
 .../utils/PlatformConfigurationUtils.java       |  2 -
 .../node/VisorDataStorageConfiguration.java     |  1 -
 .../node/VisorPersistentStoreConfiguration.java |  1 -
 .../persistence/db/wal/IgnitePdsWalTlbTest.java |  7 +-
 .../pagemem/PagesWriteThrottleSandboxTest.java  |  2 +-
 .../pagemem/PagesWriteThrottleSmokeTest.java    |  2 +-
 11 files changed, 74 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/main/java/org/apache/ignite/configuration/DataRegionConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/DataRegionConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/DataRegionConfiguration.java
index 50edf5c..4ae87e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/DataRegionConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/DataRegionConfiguration.java
@@ -129,6 +129,9 @@ public final class DataRegionConfiguration implements Serializable {
      */
     private boolean persistenceEnabled = false;
 
+    /** Temporary buffer size for checkpoints in bytes. */
+    private long checkpointPageBufSize;
+
     /**
      * Gets data region name.
      *
@@ -212,11 +215,11 @@ public final class DataRegionConfiguration implements Serializable {
     /**
      * Sets a path to the memory-mapped files.
      *
-     * @param swapFilePath A Path to the memory mapped file.
+     * @param swapPath A Path to the memory mapped file.
      * @return {@code this} for chaining.
      */
-    public DataRegionConfiguration setSwapPath(String swapFilePath) {
-        this.swapPath = swapFilePath;
+    public DataRegionConfiguration setSwapPath(String swapPath) {
+        this.swapPath = swapPath;
 
         return this;
     }
@@ -403,4 +406,29 @@ public final class DataRegionConfiguration implements Serializable {
 
         return this;
     }
+
+    /**
+     * Gets amount of memory allocated for a checkpoint temporary buffer.
+     *
+     * @return Checkpoint page buffer size in bytes or {@code 0} for Ignite
+     *      to choose the buffer size automatically.
+     */
+    public long getCheckpointPageBufferSize() {
+        return checkpointPageBufSize;
+    }
+
+    /**
+     * Sets amount of memory allocated for the checkpoint temporary buffer. The buffer is used to create temporary
+     * copies of pages that are being written to disk and being update in parallel while the checkpoint is in
+     * progress.
+     *
+     * @param checkpointPageBufSize Checkpoint page buffer size in bytes or {@code 0} for Ignite to
+     *      choose the buffer size automatically.
+     * @return {@code this} for chaining.
+     */
+    public DataRegionConfiguration setCheckpointPageBufferSize(long checkpointPageBufSize) {
+        this.checkpointPageBufSize = checkpointPageBufSize;
+
+        return this;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/main/java/org/apache/ignite/configuration/DataStorageConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/DataStorageConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/DataStorageConfiguration.java
index bd314ab..8202ef8 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/DataStorageConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/DataStorageConfiguration.java
@@ -173,9 +173,6 @@ public class DataStorageConfiguration implements Serializable {
     private long lockWaitTime = DFLT_LOCK_WAIT_TIME;
 
     /** */
-    private long checkpointPageBufSize;
-
-    /** */
     private int checkpointThreads = DFLT_CHECKPOINT_THREADS;
 
     /** Checkpoint write order. */
@@ -425,32 +422,6 @@ public class DataStorageConfiguration implements Serializable {
     }
 
     /**
-     * Gets amount of memory allocated for a checkpoint temporary buffer.
-     *
-     * @return Checkpoint page buffer size in bytes or {@code 0} for Ignite
-     *      to choose the buffer size automatically.
-     */
-    public long getCheckpointPageBufferSize() {
-        return checkpointPageBufSize;
-    }
-
-    /**
-     * Sets amount of memory allocated for the checkpoint temporary buffer. The buffer is used to create temporary
-     * copies of pages that are being written to disk and being update in parallel while the checkpoint is in
-     * progress.
-     *
-     * @param checkpointPageBufSize Checkpoint page buffer size in bytes or {@code 0} for Ignite to
-     *      choose the buffer size automatically.
-     * @return {@code this} for chaining.
-     */
-    public DataStorageConfiguration setCheckpointPageBufferSize(long checkpointPageBufSize) {
-        this.checkpointPageBufSize = checkpointPageBufSize;
-
-        return this;
-    }
-
-
-    /**
      * Gets a number of threads to use for the checkpoint purposes.
      *
      * @return Number of checkpoint threads.

http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 36257e2..67c771b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -2779,7 +2779,9 @@ public class IgnitionEx {
      */
     private static void convertLegacyDataStorageConfigurationToNew(
         IgniteConfiguration cfg) throws IgniteCheckedException {
-        boolean persistenceEnabled = cfg.getPersistentStoreConfiguration() != null;
+        PersistentStoreConfiguration psCfg = cfg.getPersistentStoreConfiguration();
+
+        boolean persistenceEnabled = psCfg != null;
 
         DataStorageConfiguration dsCfg = new DataStorageConfiguration();
 
@@ -2814,6 +2816,9 @@ public class IgnitionEx {
                 region.setSwapPath(mpc.getSwapFilePath());
                 region.setMetricsEnabled(mpc.isMetricsEnabled());
 
+                if (persistenceEnabled)
+                    region.setCheckpointPageBufferSize(psCfg.getCheckpointingPageBufferSize());
+
                 if (mpc.getName() == null) {
                     throw new IgniteCheckedException(new IllegalArgumentException(
                         "User-defined MemoryPolicyConfiguration must have non-null and non-empty name."));
@@ -2829,7 +2834,8 @@ public class IgnitionEx {
         }
 
         if (!optionalDataRegions.isEmpty())
-            dsCfg.setDataRegionConfigurations(optionalDataRegions.toArray(new DataRegionConfiguration[optionalDataRegions.size()]));
+            dsCfg.setDataRegionConfigurations(optionalDataRegions.toArray(
+                new DataRegionConfiguration[optionalDataRegions.size()]));
 
         if (!customDfltPlc) {
             if (!DFLT_MEM_PLC_DEFAULT_NAME.equals(memCfg.getDefaultMemoryPolicyName())) {
@@ -2848,10 +2854,7 @@ public class IgnitionEx {
         }
 
         if (persistenceEnabled) {
-            PersistentStoreConfiguration psCfg = cfg.getPersistentStoreConfiguration();
-
             dsCfg.setCheckpointFrequency(psCfg.getCheckpointingFrequency());
-            dsCfg.setCheckpointPageBufferSize(psCfg.getCheckpointingPageBufferSize());
             dsCfg.setCheckpointThreads(psCfg.getCheckpointingThreads());
             dsCfg.setCheckpointWriteOrder(psCfg.getCheckpointWriteOrder());
             dsCfg.setFileIOFactory(psCfg.getFileIOFactory());

http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index a3b157d..77b0622 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -1543,14 +1543,16 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
         DataRegionConfiguration[] dataRegions = memCfg.getDataRegionConfigurations();
 
         if (dataRegions != null) {
-            for (DataRegionConfiguration dataReg : dataRegions)
+            for (DataRegionConfiguration dataReg : dataRegions) {
                 res += dataReg.getMaxSize();
+
+                res += GridCacheDatabaseSharedManager.checkpointBufferSize(dataReg);
+            }
         }
 
         res += memCfg.getDefaultDataRegionConfiguration().getMaxSize();
 
-        // Add persistence (if any).
-        res += GridCacheDatabaseSharedManager.checkpointBufferSize(ctx.config());
+        res += GridCacheDatabaseSharedManager.checkpointBufferSize(memCfg.getDefaultDataRegionConfiguration());
 
         return res;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
index de3b60a..920af17 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
@@ -156,8 +156,14 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
     /** */
     public static final String IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC = "IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC";
 
-    /** Default checkpointing page buffer size (may be adjusted by Ignite). */
-    public static final Long DFLT_CHECKPOINTING_PAGE_BUFFER_SIZE = 256L * 1024 * 1024;
+    /** */
+    private static final long GB = 1024L * 1024 * 1024;
+
+    /** Minimum checkpointing page buffer size (may be adjusted by Ignite). */
+    public static final Long DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE = GB / 4;
+
+    /** Default minimum checkpointing page buffer size (may be adjusted by Ignite). */
+    public static final Long DFLT_MAX_CHECKPOINTING_PAGE_BUFFER_SIZE = 2 * GB;
 
     /** Skip sync. */
     private final boolean skipSync = IgniteSystemProperties.getBoolean(IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC);
@@ -249,9 +255,6 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
     private long checkpointFreq;
 
     /** */
-    private long checkpointPageBufSize;
-
-    /** */
     private FilePageStoreManager storeMgr;
 
     /** Checkpoint metadata directory ("cp"), contains files with checkpoint start and end */
@@ -408,56 +411,27 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
                 30_000,
                 new LinkedBlockingQueue<Runnable>()
             );
-
-        checkpointPageBufSize = checkpointBufferSize(cctx.kernalContext().config());
     }
 
     /**
      * Get checkpoint buffer size for the given configuration.
      *
-     * @param cfg Configuration.
+     * @param regCfg Configuration.
      * @return Checkpoint buffer size.
      */
-    public static long checkpointBufferSize(IgniteConfiguration cfg) {
-        DataStorageConfiguration persistenceCfg = cfg.getDataStorageConfiguration();
-
-        if (persistenceCfg == null)
+    public static long checkpointBufferSize(DataRegionConfiguration regCfg) {
+        if (!regCfg.isPersistenceEnabled())
             return 0L;
 
-        long res = persistenceCfg.getCheckpointPageBufferSize();
+        long res = regCfg.getCheckpointPageBufferSize();
 
         if (res == 0L) {
-            res = DFLT_CHECKPOINTING_PAGE_BUFFER_SIZE;
-
-            DataStorageConfiguration memCfg = cfg.getDataStorageConfiguration();
-
-            assert memCfg != null;
-
-            long totalSize = memCfg.getSystemRegionMaxSize();
-
-            if (memCfg.getDataRegionConfigurations() == null)
-                totalSize += DataStorageConfiguration.DFLT_DATA_REGION_MAX_SIZE;
-            else {
-                for (DataRegionConfiguration memPlc : memCfg.getDataRegionConfigurations()) {
-                    if (Long.MAX_VALUE - memPlc.getMaxSize() > totalSize)
-                        totalSize += memPlc.getMaxSize();
-                    else {
-                        totalSize = Long.MAX_VALUE;
-
-                        break;
-                    }
-                }
-
-                assert totalSize > 0;
-            }
-
-            // Limit the checkpoint page buffer size by 2GB.
-            long dfltSize = 2 * 1024L * 1024L * 1024L;
-
-            long adjusted = Math.min(totalSize / 4, dfltSize);
-
-            if (res < adjusted)
-                res = adjusted;
+            if (regCfg.getMaxSize() < GB)
+                res = Math.min(DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE, regCfg.getMaxSize());
+            else if (regCfg.getMaxSize() < 8 * GB)
+                res = regCfg.getMaxSize() / 4;
+            else
+                res = DFLT_MAX_CHECKPOINTING_PAGE_BUFFER_SIZE;
         }
 
         return res;
@@ -689,13 +663,16 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
         long cacheSize = plcCfg.getMaxSize();
 
         // Checkpoint buffer size can not be greater than cache size, it does not make sense.
-        long chpBufSize = Math.min(checkpointPageBufSize, cacheSize);
+        long chpBufSize = checkpointBufferSize(plcCfg);
 
-        if (checkpointPageBufSize > cacheSize)
+        if (chpBufSize > cacheSize) {
             U.quietAndInfo(log,
-                "Checkpoint page buffer size is too big, setting to an adjusted cache size [size="
+                "Configured checkpoint page buffer size is too big, setting to the max region size [size="
                     + U.readableSize(cacheSize, false) + ",  memPlc=" + plcCfg.getName() + ']');
 
+            chpBufSize = cacheSize;
+        }
+
         boolean writeThrottlingEnabled = persistenceCfg.isWriteThrottlingEnabled();
 
         if (IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_OVERRIDE_WRITE_THROTTLING_ENABLED, false))

http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 28b6c60..92a084c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -1668,7 +1668,6 @@ public class PlatformConfigurationUtils {
         DataStorageConfiguration res = new DataStorageConfiguration()
                 .setStoragePath(in.readString())
                 .setCheckpointFrequency(in.readLong())
-                .setCheckpointPageBufferSize(in.readLong())
                 .setCheckpointThreads(in.readInt())
                 .setLockWaitTime((int) in.readLong())
                 .setWalHistorySize(in.readInt())
@@ -1763,7 +1762,6 @@ public class PlatformConfigurationUtils {
 
             w.writeString(cfg.getStoragePath());
             w.writeLong(cfg.getCheckpointFrequency());
-            w.writeLong(cfg.getCheckpointPageBufferSize());
             w.writeInt(cfg.getCheckpointThreads());
             w.writeLong(cfg.getLockWaitTime());
             w.writeInt(cfg.getWalHistorySize());

http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataStorageConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataStorageConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataStorageConfiguration.java
index 78bf1c5..72d3c11 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataStorageConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataStorageConfiguration.java
@@ -155,7 +155,6 @@ public class VisorDataStorageConfiguration extends VisorDataTransferObject {
         storagePath = cfg.getStoragePath();
         checkpointFreq = cfg.getCheckpointFrequency();
         lockWaitTime = cfg.getLockWaitTime();
-        checkpointPageBufSize = cfg.getCheckpointPageBufferSize();
         checkpointThreads = cfg.getCheckpointThreads();
         checkpointWriteOrder = cfg.getCheckpointWriteOrder();
         walHistSize = cfg.getWalHistorySize();

http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistentStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistentStoreConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistentStoreConfiguration.java
index f9d7a64..d26ab35 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistentStoreConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistentStoreConfiguration.java
@@ -103,7 +103,6 @@ public class VisorPersistentStoreConfiguration extends VisorDataTransferObject {
         persistenceStorePath = cfg.getStoragePath();
         checkpointingFreq = cfg.getCheckpointFrequency();
         lockWaitTime = cfg.getLockWaitTime();
-        checkpointingPageBufSize = cfg.getCheckpointPageBufferSize();
         checkpointingThreads = cfg.getCheckpointThreads();
         walHistSize = cfg.getWalHistorySize();
         walSegments = cfg.getWalSegments();

http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgnitePdsWalTlbTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgnitePdsWalTlbTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgnitePdsWalTlbTest.java
index 5700eb3..3b76b63 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgnitePdsWalTlbTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgnitePdsWalTlbTest.java
@@ -31,7 +31,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
-import static org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.DFLT_CHECKPOINTING_PAGE_BUFFER_SIZE;
+import static org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE;
 import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR;
 
 /**
@@ -54,9 +54,10 @@ public class IgnitePdsWalTlbTest extends GridCommonAbstractTest {
 
         DataStorageConfiguration memCfg = new DataStorageConfiguration()
             .setDefaultDataRegionConfiguration(
-                new DataRegionConfiguration().setMaxSize(100 * 1024 * 1024).setPersistenceEnabled(true))
+                new DataRegionConfiguration().setMaxSize(100 * 1024 * 1024)
+                    .setPersistenceEnabled(true)
+                    .setCheckpointPageBufferSize(DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE + 1))
             .setWalMode(WALMode.LOG_ONLY)
-            .setCheckpointPageBufferSize(DFLT_CHECKPOINTING_PAGE_BUFFER_SIZE + 1)
             .setWalThreadLocalBufferSize(640000000);
 
         cfg.setDataStorageConfiguration(memCfg);

http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSandboxTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSandboxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSandboxTest.java
index 30fb492..9529f59 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSandboxTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSandboxTest.java
@@ -68,12 +68,12 @@ public class PagesWriteThrottleSandboxTest extends GridCommonAbstractTest {
         DataStorageConfiguration dbCfg = new DataStorageConfiguration()
             .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
                 .setMaxSize(4000L * 1024 * 1024)
+                .setCheckpointPageBufferSize(1000L * 1000 * 1000)
                 .setName("dfltDataRegion")
                 .setMetricsEnabled(true)
                 .setPersistenceEnabled(true))
             .setWalMode(WALMode.BACKGROUND)
             .setCheckpointFrequency(20_000)
-            .setCheckpointPageBufferSize(1000L * 1000 * 1000)
             .setWriteThrottlingEnabled(true);
 
         cfg.setDataStorageConfiguration(dbCfg);

http://git-wip-us.apache.org/repos/asf/ignite/blob/718f912f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSmokeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSmokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSmokeTest.java
index ab7aab4..1875cfb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSmokeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSmokeTest.java
@@ -78,12 +78,12 @@ public class PagesWriteThrottleSmokeTest extends GridCommonAbstractTest {
         DataStorageConfiguration dbCfg = new DataStorageConfiguration()
             .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
                 .setMaxSize(400 * 1024 * 1024)
+                .setCheckpointPageBufferSize(200 * 1000 * 1000)
                 .setName("dfltDataRegion")
                 .setMetricsEnabled(true)
                 .setPersistenceEnabled(true))
             .setWalMode(WALMode.BACKGROUND)
             .setCheckpointFrequency(20_000)
-            .setCheckpointPageBufferSize(200 * 1000 * 1000)
             .setWriteThrottlingEnabled(true)
             .setCheckpointThreads(1)
             .setFileIOFactory(new SlowCheckpointFileIOFactory());


[5/8] ignite git commit: IGNITE-6512 Add an option to start caches in inactive state - fixing missed call of cache creation - Fixes #2913.

Posted by ag...@apache.org.
IGNITE-6512 Add an option to start caches in inactive state
- fixing missed call of cache creation - Fixes #2913.

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


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

Branch: refs/heads/ignite-6748
Commit: 70a57d57628778a018ae0c6eacf772a66b51e018
Parents: f7aa443
Author: Eduard Shangareev <es...@gridgain.com>
Authored: Wed Oct 25 14:55:02 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Oct 25 14:55:02 2017 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/70a57d57/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index ba42a95..bde7be2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -2864,7 +2864,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
             ctx.cache().dynamicStartCaches(cacheCfgs,
                 true,
                 true,
-                true).get();
+                false).get();
 
             List<IgniteCache> createdCaches = new ArrayList<>(cacheCfgs.size());
 
@@ -2955,7 +2955,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
             ctx.cache().dynamicStartCaches(cacheCfgs,
                 false,
                 true,
-                true).get();
+                false).get();
 
             List<IgniteCache> createdCaches = new ArrayList<>(cacheCfgs.size());
 


[6/8] ignite git commit: IGNITE-6511: Fixed SQLGetDiagRec behaviour in ODBC

Posted by ag...@apache.org.
IGNITE-6511: Fixed SQLGetDiagRec behaviour in ODBC


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

Branch: refs/heads/ignite-6748
Commit: bbf48533ca8f29961510d370be617ebbbc5cd5c9
Parents: 70a57d5
Author: Igor Sapego <is...@gridgain.com>
Authored: Wed Oct 25 15:07:06 2017 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Wed Oct 25 15:07:06 2017 +0300

----------------------------------------------------------------------
 .../cpp/odbc-test/src/api_robustness_test.cpp   | 25 ++++++++++-------
 modules/platforms/cpp/odbc/src/odbc.cpp         | 29 ++++++++++++++++----
 2 files changed, 38 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bbf48533/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp b/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
index 82f7274..c17e079 100644
--- a/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
@@ -976,26 +976,31 @@ BOOST_AUTO_TEST_CASE(TestSQLGetDiagField)
 
 BOOST_AUTO_TEST_CASE(TestSQLGetDiagRec)
 {
-    // There are no checks because we do not really care what is the result of these
-    // calls as long as they do not cause segmentation fault.
-
     Connect("DRIVER={Apache Ignite};address=127.0.0.1:11110;schema=cache");
 
-    // Should fail.
-    SQLRETURN ret = SQLGetTypeInfo(stmt, SQL_INTERVAL_MONTH);
-
-    BOOST_REQUIRE_EQUAL(ret, SQL_ERROR);
-
     SQLCHAR state[ODBC_BUFFER_SIZE];
     SQLINTEGER nativeError = 0;
     SQLCHAR message[ODBC_BUFFER_SIZE];
     SQLSMALLINT messageLen = 0;
 
-    // Everithing is ok
-    ret = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, state, &nativeError, message, sizeof(message), &messageLen);
+    // Generating error.
+    SQLRETURN ret = SQLGetTypeInfo(stmt, SQL_INTERVAL_MONTH);
+    BOOST_REQUIRE_EQUAL(ret, SQL_ERROR);
 
+    // Everithing is ok.
+    ret = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, state, &nativeError, message, sizeof(message), &messageLen);
     BOOST_REQUIRE_EQUAL(ret, SQL_SUCCESS);
 
+    // Should return error.
+    ret = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, state, &nativeError, message, -1, &messageLen);
+    BOOST_REQUIRE_EQUAL(ret, SQL_ERROR);
+
+    // Should return message length.
+    ret = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, state, &nativeError, message, 1, &messageLen);
+    BOOST_REQUIRE_EQUAL(ret, SQL_SUCCESS_WITH_INFO);
+
+    // There are no checks because we do not really care what is the result of these
+    // calls as long as they do not cause segmentation fault.
     SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, 0, &nativeError, message, sizeof(message), &messageLen);
     SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, state, 0, message, sizeof(message), &messageLen);
     SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, state, &nativeError, 0, sizeof(message), &messageLen);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbf48533/modules/platforms/cpp/odbc/src/odbc.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/odbc.cpp b/modules/platforms/cpp/odbc/src/odbc.cpp
index baa276a..8121a3b 100644
--- a/modules/platforms/cpp/odbc/src/odbc.cpp
+++ b/modules/platforms/cpp/odbc/src/odbc.cpp
@@ -984,16 +984,22 @@ namespace ignite
             {
                 Diagnosable *diag = reinterpret_cast<Diagnosable*>(handle);
 
+                if (!diag)
+                    return SQL_INVALID_HANDLE;
+
                 records = &diag->GetDiagnosticRecords();
 
                 break;
             }
 
             default:
-                break;
+                return SQL_INVALID_HANDLE;
         }
 
-        if (!records || recNum < 1 || recNum > records->GetStatusRecordsNumber())
+        if (recNum < 1 || msgBufferLen < 0)
+            return SQL_ERROR;
+
+        if (!records || recNum > records->GetStatusRecordsNumber())
             return SQL_NO_DATA;
 
         const DiagnosticRecord& record = records->GetStatusRecord(recNum);
@@ -1004,13 +1010,24 @@ namespace ignite
         if (nativeError)
             *nativeError = 0;
 
-        SqlLen outResLen;
-        ApplicationDataBuffer outBuffer(OdbcNativeType::AI_CHAR, msgBuffer, msgBufferLen, &outResLen);
+        const std::string& errMsg = record.GetMessageText();
 
-        outBuffer.PutString(record.GetMessageText());
+        if (!msgBuffer || msgBufferLen < static_cast<SQLSMALLINT>(errMsg.size() + 1))
+        {
+            if (!msgLen)
+                return SQL_ERROR;
+
+            CopyStringToBuffer(errMsg, reinterpret_cast<char*>(msgBuffer), static_cast<size_t>(msgBufferLen));
+
+            *msgLen = static_cast<SQLSMALLINT>(errMsg.size());
+
+            return SQL_SUCCESS_WITH_INFO;
+        }
+
+        CopyStringToBuffer(errMsg, reinterpret_cast<char*>(msgBuffer), static_cast<size_t>(msgBufferLen));
 
         if (msgLen)
-            *msgLen = static_cast<SQLSMALLINT>(outResLen);
+            *msgLen = static_cast<SQLSMALLINT>(errMsg.size());
 
         return SQL_SUCCESS;
     }


[8/8] ignite git commit: Merge branch 'ignite-6748' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-6748

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


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

Branch: refs/heads/ignite-6748
Commit: 53a1ea971d138042db51dffa5ed10ed0f88cb0fd
Parents: 718f912 31a8b9a
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Oct 25 15:55:11 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Oct 25 15:55:11 2017 +0300

----------------------------------------------------------------------
 .../platform/utils/PlatformConfigurationUtils.java   |  4 +++-
 .../visor/node/VisorDataRegionConfiguration.java     | 13 +++++++++++++
 .../visor/node/VisorDataStorageConfiguration.java    |  2 +-
 .../Apache.Ignite.Core.Tests/Config/full-config.xml  |  6 +++---
 .../IgniteConfigurationSerializerTest.cs             |  6 +++---
 .../IgniteConfigurationTest.cs                       |  6 +++---
 .../Configuration/DataRegionConfiguration.cs         |  8 ++++++++
 .../Configuration/DataStorageConfiguration.cs        |  9 ---------
 .../IgniteConfigurationSection.xsd                   | 15 ++++++++++-----
 modules/web-console/backend/app/mongo.js             |  6 ++++--
 .../generator/ConfigurationGenerator.js              |  5 ++++-
 .../generator/defaults/Cluster.service.js            |  3 ++-
 .../states/configuration/clusters/data-storage.pug   |  6 ++++++
 13 files changed, 60 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/53a1ea97/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/53a1ea97/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/full-config.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/53a1ea97/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/53a1ea97/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------


[2/8] ignite git commit: IGNITE-6555 When a CacheStore with a @SpringResource annotated field is configured Ignite fails to start via igniteSpringBean. This closes #2893.

Posted by ag...@apache.org.
IGNITE-6555 When a CacheStore with a @SpringResource annotated field is configured Ignite fails to start via igniteSpringBean. This closes #2893.

Signed-off-by: nikolay_tikhonov <nt...@gridgain.com>


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

Branch: refs/heads/ignite-6748
Commit: dde348607ed266f87bf594cb2a221ec39d84cfdb
Parents: 1816fb9
Author: Alexander Fedotov <al...@gmail.com>
Authored: Wed Oct 25 14:43:16 2017 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Wed Oct 25 14:43:16 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/IgniteSpringBean.java     |  32 ++-
 .../GridSpringBeanSerializationSelfTest.java    |   4 +-
 .../ignite/internal/IgniteSpringBeanTest.java   |   2 +-
 .../GridServiceInjectionSpringResourceTest.java |  10 +-
 ...teSpringBeanSpringResourceInjectionTest.java | 215 +++++++++++++++++++
 .../ignite/spring/injection/spring-bean.xml     |  84 ++++++++
 .../testsuites/IgniteSpringTestSuite.java       |   2 +
 7 files changed, 334 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dde34860/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
index 4cba76e..95fceec 100644
--- a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
+++ b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
@@ -38,9 +38,10 @@ import org.apache.ignite.plugin.PluginNotFoundException;
 import org.jetbrains.annotations.Nullable;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.SmartInitializingSingleton;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.event.ContextRefreshedEvent;
 
 /**
  * Ignite Spring bean allows to bypass {@link Ignition} methods.
@@ -48,9 +49,20 @@ import org.springframework.context.ApplicationContextAware;
  * Spring configuration file directly without invoking static
  * {@link Ignition} methods. This class can be wired directly from
  * Spring and can be referenced from within other Spring beans.
- * By virtue of implementing {@link DisposableBean} and {@link InitializingBean}
+ * By virtue of implementing {@link DisposableBean} and {@link SmartInitializingSingleton}
  * interfaces, {@code IgniteSpringBean} automatically starts and stops underlying
  * grid instance.
+ *
+ * <p>
+ * A note should be taken that Ignite instance is started after all other
+ * Spring beans have been initialized and right before Spring context is refreshed.
+ * That implies that it's not valid to reference IgniteSpringBean from
+ * any kind of Spring bean init methods like {@link javax.annotation.PostConstruct}.
+ * If it's required to reference IgniteSpringBean for other bean
+ * initialization purposes, it should be done from a {@link ContextRefreshedEvent}
+ * listener method declared in that bean.
+ * </p>
+ *
  * <p>
  * <h1 class="header">Spring Configuration Example</h1>
  * Here is a typical example of describing it in Spring file:
@@ -79,7 +91,7 @@ import org.springframework.context.ApplicationContextAware;
  * </pre>
  * <p>
  */
-public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBean,
+public class IgniteSpringBean implements Ignite, DisposableBean, SmartInitializingSingleton,
     ApplicationContextAware, Externalizable {
     /** */
     private static final long serialVersionUID = 0L;
@@ -145,7 +157,6 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
 
     /** {@inheritDoc} */
     @Override public void destroy() throws Exception {
-        // If there were some errors when afterPropertiesSet() was called.
         if (g != null) {
             // Do not cancel started tasks, wait for them.
             G.stop(g.name(), false);
@@ -153,11 +164,16 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
     }
 
     /** {@inheritDoc} */
-    @Override public void afterPropertiesSet() throws Exception {
+    @Override public void afterSingletonsInstantiated() {
         if (cfg == null)
             cfg = new IgniteConfiguration();
 
-        g = IgniteSpring.start(cfg, appCtx);
+        try {
+            g = IgniteSpring.start(cfg, appCtx);
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException("Failed to start IgniteSpringBean", e);
+        }
     }
 
     /** {@inheritDoc} */
@@ -620,7 +636,9 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
     protected void checkIgnite() throws IllegalStateException {
         if (g == null) {
             throw new IllegalStateException("Ignite is in invalid state to perform this operation. " +
-                "It either not started yet or has already being or have stopped " +
+                "It either not started yet or has already being or have stopped.\n" +
+                "Make sure that IgniteSpringBean is not referenced from any kind of Spring bean init methods " +
+                "like @PostConstruct}.\n" +
                 "[ignite=" + g + ", cfg=" + cfg + ']');
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/dde34860/modules/spring/src/test/java/org/apache/ignite/internal/GridSpringBeanSerializationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/GridSpringBeanSerializationSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/GridSpringBeanSerializationSelfTest.java
index 6f7d27a..6a72213 100644
--- a/modules/spring/src/test/java/org/apache/ignite/internal/GridSpringBeanSerializationSelfTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/internal/GridSpringBeanSerializationSelfTest.java
@@ -53,7 +53,7 @@ public class GridSpringBeanSerializationSelfTest extends GridCommonAbstractTest
 
         bean.setConfiguration(cfg);
 
-        bean.afterPropertiesSet();
+        bean.afterSingletonsInstantiated();
     }
 
     /**
@@ -97,4 +97,4 @@ public class GridSpringBeanSerializationSelfTest extends GridCommonAbstractTest
         assert bean0.cluster().localNode() != null;
         assert bean0.cluster().localNode().<Boolean>attribute(ATTR_KEY);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/dde34860/modules/spring/src/test/java/org/apache/ignite/internal/IgniteSpringBeanTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/IgniteSpringBeanTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/IgniteSpringBeanTest.java
index d465904..c7f0d59 100644
--- a/modules/spring/src/test/java/org/apache/ignite/internal/IgniteSpringBeanTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/internal/IgniteSpringBeanTest.java
@@ -31,7 +31,7 @@ public class IgniteSpringBeanTest extends GridCommonAbstractTest {
         try (IgniteSpringBean bean = new IgniteSpringBean()) {
             bean.setConfiguration(getConfiguration("test"));
 
-            bean.afterPropertiesSet();
+            bean.afterSingletonsInstantiated();
 
             bean.compute();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/dde34860/modules/spring/src/test/java/org/apache/ignite/spring/injection/GridServiceInjectionSpringResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/injection/GridServiceInjectionSpringResourceTest.java b/modules/spring/src/test/java/org/apache/ignite/spring/injection/GridServiceInjectionSpringResourceTest.java
index c6a6d05..891c42e 100644
--- a/modules/spring/src/test/java/org/apache/ignite/spring/injection/GridServiceInjectionSpringResourceTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/spring/injection/GridServiceInjectionSpringResourceTest.java
@@ -26,10 +26,11 @@ import org.apache.ignite.resources.SpringResource;
 import org.apache.ignite.services.Service;
 import org.apache.ignite.services.ServiceContext;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.event.EventListener;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.FileSystemXmlApplicationContext;
 
-import javax.annotation.PostConstruct;
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.IOException;
@@ -234,12 +235,11 @@ public class GridServiceInjectionSpringResourceTest extends GridCommonAbstractTe
         /**
          * @throws Exception If failed.
          */
-        @PostConstruct
-        public void init() throws Exception {
+        @EventListener
+        public void init(ContextRefreshedEvent evt) throws Exception {
             DummyService srv = ignite.services().serviceProxy(SERVICE_NAME, DummyService.class, false);
 
             assertNotNull(srv);
         }
     }
-
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/dde34860/modules/spring/src/test/java/org/apache/ignite/spring/injection/IgniteSpringBeanSpringResourceInjectionTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/injection/IgniteSpringBeanSpringResourceInjectionTest.java b/modules/spring/src/test/java/org/apache/ignite/spring/injection/IgniteSpringBeanSpringResourceInjectionTest.java
new file mode 100644
index 0000000..2a06deb
--- /dev/null
+++ b/modules/spring/src/test/java/org/apache/ignite/spring/injection/IgniteSpringBeanSpringResourceInjectionTest.java
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.spring.injection;
+
+import java.io.Serializable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import javax.cache.Cache;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.resources.SpringResource;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * Test checking injections of {@link SpringResource} annotated fields.
+ */
+public class IgniteSpringBeanSpringResourceInjectionTest extends GridCommonAbstractTest {
+    /** */
+    private static final String SPRING_CFG_LOCATION = "/org/apache/ignite/spring/injection/spring-bean.xml";
+
+    /** */
+    private static final String BEAN_TO_INJECT_NAME = "beanToInject";
+
+    /**
+     * Cache store with {@link SpringResource} fields to be injected.
+     */
+    public static class IgniteCacheStoreWithSpringResource<K, V> extends CacheStoreAdapter<K, V>
+        implements Serializable
+    {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
+        @SpringResource(resourceClass = Integer.class)
+        private transient Integer injectedSpringFld;
+
+        /**
+         * @return Injected Spring field.
+         */
+        public Integer getInjectedSpringField() {
+            return injectedSpringFld;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V load(K key) throws CacheLoaderException {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void write(Cache.Entry<? extends K, ? extends V> entry) throws CacheWriterException {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void delete(Object key) throws CacheWriterException {
+            // No-op.
+        }
+    }
+
+    /**
+     * Interface of a service with {@link SpringResource} fields to be injected.
+     */
+    public interface ServiceWithSpringResource {
+        /**
+         * @return Injected Spring field.
+         */
+        Integer getInjectedSpringField();
+    }
+
+    /**
+     * Service with {@link SpringResource} fields to be injected.
+     */
+    public static class ServiceWithSpringResourceImpl implements ServiceWithSpringResource, Service {
+        /** */
+        private static final long serialVersionUID = 0L;
+        /** */
+        @SpringResource(resourceClass = Integer.class)
+        private transient Integer injectedSpringFld;
+
+        /** {@inheritDoc} */
+        @Override public Integer getInjectedSpringField() {
+            return injectedSpringFld;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void cancel(ServiceContext ctx) {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void init(ServiceContext ctx) throws Exception {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void execute(ServiceContext ctx) throws Exception {
+            // No-op.
+        }
+    }
+
+    /**
+     *
+     */
+    private abstract static class TestSpringResourceInjectedRunnable implements Runnable {
+        /** */
+        private final String springCfgLocation;
+
+        /** */
+        private final String beanToInjectName;
+
+        /** */
+        protected BeanFactory appCtx;
+
+        /**
+         * Constructor.
+         *
+         * @param springCfgLocation Spring config location.
+         * @param beanToInjectName Bean to inject name.
+         */
+        protected TestSpringResourceInjectedRunnable(String springCfgLocation, String beanToInjectName) {
+            this.springCfgLocation = springCfgLocation;
+            this.beanToInjectName = beanToInjectName;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run() {
+            appCtx = new ClassPathXmlApplicationContext(springCfgLocation);
+
+            Integer beanToInject = (Integer)appCtx.getBean(beanToInjectName);
+
+            assertEquals(beanToInject, getInjectedBean());
+        }
+
+        /**
+         * @return Injected bean to check.
+         */
+        abstract Integer getInjectedBean();
+    }
+
+    /** */
+    private void doTestSpringResourceInjected(Runnable testRunnable) throws Exception {
+        ExecutorService executorSvc = Executors.newSingleThreadExecutor();
+
+        Future<?> fut = executorSvc.submit(testRunnable);
+
+        try {
+            fut.get(5, TimeUnit.SECONDS);
+        }
+        catch (TimeoutException ignored) {
+            fail("Failed to wait for completion. Deadlock is possible");
+        }
+        finally {
+            executorSvc.shutdownNow();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids(true);
+    }
+
+    /** */
+    public void testSpringResourceInjectedInCacheStore() throws Exception {
+        doTestSpringResourceInjected(
+            new TestSpringResourceInjectedRunnable(SPRING_CFG_LOCATION, BEAN_TO_INJECT_NAME) {
+                /** {@inheritDoc} */
+                @Override Integer getInjectedBean() {
+                    IgniteCacheStoreWithSpringResource cacheStore =
+                        appCtx.getBean(IgniteCacheStoreWithSpringResource.class);
+
+                    return cacheStore.getInjectedSpringField();
+                }
+            }
+        );
+    }
+
+    /** */
+    public void testSpringResourceInjectedInService() throws Exception {
+        doTestSpringResourceInjected(
+            new TestSpringResourceInjectedRunnable(SPRING_CFG_LOCATION, BEAN_TO_INJECT_NAME) {
+                /** {@inheritDoc} */
+                @Override Integer getInjectedBean() {
+                    Ignite ignite = appCtx.getBean(Ignite.class);
+                    ServiceWithSpringResource svc = ignite.services().service("ServiceWithSpringResource");
+
+                    return svc.getInjectedSpringField();
+                }
+            }
+        );
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/dde34860/modules/spring/src/test/java/org/apache/ignite/spring/injection/spring-bean.xml
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/injection/spring-bean.xml b/modules/spring/src/test/java/org/apache/ignite/spring/injection/spring-bean.xml
new file mode 100644
index 0000000..d40f152
--- /dev/null
+++ b/modules/spring/src/test/java/org/apache/ignite/spring/injection/spring-bean.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <bean id="beanToInject" class="java.lang.Integer">
+        <constructor-arg value="111" type="int"/>
+    </bean>
+
+    <bean id="cacheStore" class="org.apache.ignite.spring.injection.IgniteSpringBeanSpringResourceInjectionTest.IgniteCacheStoreWithSpringResource"/>
+
+    <bean id="serviceWithSpringResource"
+          class="org.apache.ignite.spring.injection.IgniteSpringBeanSpringResourceInjectionTest.ServiceWithSpringResourceImpl"/>
+
+    <bean id="igniteSpringBean" class="org.apache.ignite.IgniteSpringBean">
+        <property name="configuration">
+            <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+                <property name="peerClassLoadingEnabled" value="true"/>
+
+                <property name="cacheConfiguration">
+                    <list>
+                        <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                            <property name="name" value="cache1"/>
+                            <property name="cacheStoreFactory">
+                                <bean class="javax.cache.configuration.FactoryBuilder" factory-method="factoryOf">
+                                    <constructor-arg ref="cacheStore"/>
+                                </bean>
+                            </property>
+
+                            <property name="readThrough" value="true"/>
+                            <property name="writeThrough" value="true"/>
+                        </bean>
+                    </list>
+                </property>
+
+                <property name="serviceConfiguration">
+                    <list>
+                        <bean class="org.apache.ignite.services.ServiceConfiguration">
+                            <property name="name" value="ServiceWithSpringResource"/>
+                            <property name="maxPerNodeCount" value="1"/>
+                            <property name="totalCount" value="1"/>
+                            <property name="service">
+                                <ref bean="serviceWithSpringResource"/>
+                            </property>
+                        </bean>
+                    </list>
+                </property>
+
+                <property name="discoverySpi">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                        <property name="ipFinder">
+                            <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                                <property name="addresses">
+                                    <list>
+                                        <value>127.0.0.1:47500..47509</value>
+                                    </list>
+                                </property>
+                            </bean>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/dde34860/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
index 9ebb784..ff96c7b 100644
--- a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
+++ b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
 import org.apache.ignite.cache.spring.GridSpringCacheManagerSelfTest;
 import org.apache.ignite.cache.spring.SpringCacheManagerContextInjectionTest;
 import org.apache.ignite.cache.spring.SpringCacheTest;
+import org.apache.ignite.spring.injection.IgniteSpringBeanSpringResourceInjectionTest;
 import org.apache.ignite.internal.IgniteSpringBeanTest;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStoreFactorySelfTest;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactorySelfTest;
@@ -77,6 +78,7 @@ public class IgniteSpringTestSuite extends TestSuite {
         suite.addTestSuite(GridSpringTransactionManagerSelfTest.class);
 
         suite.addTestSuite(GridServiceInjectionSpringResourceTest.class);
+        suite.addTestSuite(IgniteSpringBeanSpringResourceInjectionTest.class);
 
         suite.addTestSuite(GridTransformSpringInjectionSelfTest.class);
 


[3/8] ignite git commit: IGNITE-6572: SQL: allowed many cache to share the same schema. This closes #2850.

Posted by ag...@apache.org.
IGNITE-6572: SQL: allowed many cache to share the same schema. This closes #2850.


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

Branch: refs/heads/ignite-6748
Commit: ee6daae5363bef96f3794cc8f6325fcdab275ec1
Parents: 1816fb9
Author: Denis Mekhanikov <dm...@gmail.com>
Authored: Wed Oct 25 14:44:51 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Wed Oct 25 14:44:51 2017 +0300

----------------------------------------------------------------------
 .../internal/processors/query/h2/H2Schema.java  | 21 +++++
 .../processors/query/h2/IgniteH2Indexing.java   | 39 +++++++---
 .../query/IgniteSqlSchemaIndexingTest.java      | 30 +++++++-
 .../processors/query/SqlSchemaSelfTest.java     | 80 ++++++++++++++++++--
 4 files changed, 150 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ee6daae5/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 f5cf0f2..2fdf32d 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
@@ -34,6 +34,9 @@ public class H2Schema {
     /** */
     private final ConcurrentMap<H2TypeKey, H2TableDescriptor> typeToTbl = new ConcurrentHashMap<>();
 
+    /** Usage count. */
+    private int usageCnt;
+
     /**
      * Constructor.
      *
@@ -51,6 +54,24 @@ public class H2Schema {
     }
 
     /**
+     * Increments counter for number of caches having this schema.
+     *
+     * @return New value of caches counter.
+     */
+    public int incrementUsageCount() {
+        return ++usageCnt;
+    }
+
+    /**
+     * Increments counter for number of caches having this schema.
+     *
+     * @return New value of caches counter.
+     */
+    public int decrementUsageCount() {
+        return --usageCnt;
+    }
+
+    /**
      * @return Tables.
      */
     public Collection<H2TableDescriptor> tables() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee6daae5/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 eed1f19..9321c85 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
@@ -259,6 +259,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     private GridSpinBusyLock busyLock;
 
     /** */
+    private final Object schemaMux = new Object();
+
+    /** */
     private final ConcurrentMap<Long, GridRunningQueryInfo> runs = new ConcurrentHashMap8<>();
 
     /** */
@@ -2286,10 +2289,18 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     @Override public void registerCache(String cacheName, String schemaName, GridCacheContext<?, ?> cctx)
         throws IgniteCheckedException {
         if (!isDefaultSchema(schemaName)) {
-            if (schemas.putIfAbsent(schemaName, new H2Schema(schemaName)) != null)
-                throw new IgniteCheckedException("Schema already registered: " + U.maskName(schemaName));
+            synchronized (schemaMux) {
+                H2Schema schema = new H2Schema(schemaName);
+
+                H2Schema oldSchema = schemas.putIfAbsent(schemaName, schema);
+
+                if (oldSchema == null)
+                    createSchema(schemaName);
+                else
+                    schema = oldSchema;
 
-            createSchema(schemaName);
+                schema.incrementUsageCount();
+            }
         }
 
         cacheName2schema.put(cacheName, schemaName);
@@ -2301,9 +2312,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     @Override public void unregisterCache(String cacheName, boolean destroy) {
         String schemaName = schema(cacheName);
 
-        boolean dflt = isDefaultSchema(schemaName);
-
-        H2Schema schema = dflt ? schemas.get(schemaName) : schemas.remove(schemaName);
+        H2Schema schema = schemas.get(schemaName);
 
         if (schema != null) {
             mapQryExec.onCacheStop(cacheName);
@@ -2334,12 +2343,18 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                 }
             }
 
-            if (!dflt) {
-                try {
-                    dropSchema(schemaName);
-                }
-                catch (IgniteCheckedException e) {
-                    U.error(log, "Failed to drop schema on cache stop (will ignore): " + cacheName, e);
+            if (!isDefaultSchema(schemaName)) {
+                synchronized (schemaMux) {
+                    if (schema.decrementUsageCount() == 0) {
+                        schemas.remove(schemaName);
+
+                        try {
+                            dropSchema(schemaName);
+                        }
+                        catch (IgniteCheckedException e) {
+                            U.error(log, "Failed to drop schema on cache stop (will ignore): " + cacheName, e);
+                        }
+                    }
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee6daae5/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 33e35e0..570d2db 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
@@ -105,7 +105,35 @@ public class IgniteSqlSchemaIndexingTest extends GridCommonAbstractTest {
 
                 return null;
             }
-        }, IgniteException.class, "Schema already registered: ");
+        }, IgniteException.class, "Duplicate index name");
+    }
+
+    /**
+     * Test collision of table names in different caches, sharing a single SQL schema.
+     *
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+    public void testCustomSchemaMultipleCachesTablesCollision() throws Exception {
+        //TODO: Rewrite with dynamic cache creation, and GRID start in #beforeTest after resolve of
+        //TODO: https://issues.apache.org/jira/browse/IGNITE-1094
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                final CacheConfiguration cfg = cacheConfig("cache1", true, Integer.class, Fact.class)
+                    .setSqlSchema("TEST_SCHEMA");
+
+                final CacheConfiguration collisionCfg = cacheConfig("cache2", true, Integer.class, Fact.class)
+                    .setSqlSchema("TEST_SCHEMA");
+
+                IgniteConfiguration icfg = new IgniteConfiguration()
+                    .setLocalHost("127.0.0.1")
+                    .setCacheConfiguration(cfg, collisionCfg);
+
+                Ignition.start(icfg);
+
+                return null;
+            }
+        }, IgniteException.class, "Failed to register query type");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee6daae5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSchemaSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSchemaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSchemaSelfTest.java
index 183a884..a4ee2e3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSchemaSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSchemaSelfTest.java
@@ -18,6 +18,9 @@
 package org.apache.ignite.internal.processors.query;
 
 import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
@@ -25,11 +28,9 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * Tests for schemas.
  */
@@ -197,6 +198,63 @@ public class SqlSchemaSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testCustomSchemaName() throws Exception {
+        IgniteCache<Long, Person> cache = registerQueryEntity("Person", CACHE_PERSON);
+
+        testQueryEntity(cache, "Person");
+    }
+
+    /**
+     * Test multiple caches having the same schema.
+     *
+     * @throws Exception If failed.
+     */
+    public void testCustomSchemaMultipleCaches() throws Exception {
+        for (int i = 1; i <= 3; i++) {
+            String tbl = "Person" + i;
+
+            IgniteCache<Long, Person> cache = registerQueryEntity(tbl, "PersonCache" + i);
+
+            testQueryEntity(cache, tbl);
+        }
+
+        for (int i = 1; i < 3; i++) {
+            IgniteCache<Long, Person> cache = node.cache("PersonCache" + i);
+
+            testQueryEntity(cache, "Person" + i);
+        }
+    }
+
+    /**
+     * Test concurrent schema creation and destruction.
+     *
+     * @throws Exception If failed.
+     */
+    public void testCustomSchemaConcurrentUse() throws Exception {
+        final AtomicInteger maxIdx = new AtomicInteger();
+
+        GridTestUtils.runMultiThreaded(new Runnable() {
+            @Override public void run() {
+                for (int i = 0; i < 100; i++) {
+                    int idx = maxIdx.incrementAndGet();
+                    
+                    String tbl = "Person" + idx;
+
+                    IgniteCache<Long, Person> cache = registerQueryEntity(tbl, "PersonCache" + idx);
+
+                    testQueryEntity(cache, tbl);
+
+                    cache.destroy();
+                }
+            }
+        }, 4, "schema-test");
+    }
+
+    /**
+     * @param tbl Table name.
+     * @param cacheName Cache name.
+     * @return Cache with registered query entity.
+     */
+    private IgniteCache<Long, Person> registerQueryEntity(String tbl, String cacheName) {
         QueryEntity qe = new QueryEntity()
             .setValueType(Person.class.getName())
             .setKeyType(Long.class.getName())
@@ -207,17 +265,25 @@ public class SqlSchemaSelfTest extends GridCommonAbstractTest {
             .addQueryField("name", String.class.getName(), null)
             .addQueryField("orgId", Long.class.getName(), null);
 
-        qe.setTableName("Person");
+        qe.setTableName(tbl);
 
-        IgniteCache<Long, Person> cache = node.createCache(new CacheConfiguration<Long, Person>()
-            .setName(CACHE_PERSON)
+        return node.createCache(new CacheConfiguration<Long, Person>()
+            .setName(cacheName)
             .setQueryEntities(Collections.singletonList(qe))
             .setSqlSchema("TEST"));
+    }
 
+    /**
+     * Uses SQL to retrieve data from cache.
+     *
+     * @param cache Cache.
+     * @param tbl Table.
+     */
+    private void testQueryEntity(IgniteCache<Long, Person> cache, String tbl) {
         cache.put(1L, new Person("Vasya", 2));
 
         assertEquals(1, node.context().query().querySqlFieldsNoCache(
-            new SqlFieldsQuery("SELECT id, name, orgId FROM TEST.Person where (id = ?)").setArgs(1L), false
+            new SqlFieldsQuery(String.format("SELECT id, name, orgId FROM TEST.%s where (id = %d)", tbl, 1)), false
         ).getAll().size());
     }