Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1DFDA200D4E for ; Tue, 24 Oct 2017 10:47:15 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1CD0F160BDB; Tue, 24 Oct 2017 08:47:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 87790160C02 for ; Tue, 24 Oct 2017 10:47:11 +0200 (CEST) Received: (qmail 31130 invoked by uid 500); 24 Oct 2017 08:47:10 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 30812 invoked by uid 99); 24 Oct 2017 08:47:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Oct 2017 08:47:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 89E02E038F; Tue, 24 Oct 2017 08:47:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Tue, 24 Oct 2017 08:47:34 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [27/50] [abbrv] ignite git commit: IGNITE-6515 .NET: Enable persistence on per-cache basis archived-at: Tue, 24 Oct 2017 08:47:15 -0000 http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs index 73636d1..c8c06b2 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs @@ -41,6 +41,7 @@ namespace Apache.Ignite.Core.Tests using Apache.Ignite.Core.Tests.Plugin; using Apache.Ignite.Core.Transactions; using NUnit.Framework; + using WalMode = Apache.Ignite.Core.PersistentStore.WalMode; /// /// Tests code-based configuration. @@ -64,6 +65,8 @@ namespace Apache.Ignite.Core.Tests { CheckDefaultProperties(new IgniteConfiguration()); CheckDefaultProperties(new PersistentStoreConfiguration()); + CheckDefaultProperties(new DataStorageConfiguration()); + CheckDefaultProperties(new DataRegionConfiguration()); CheckDefaultProperties(new ClientConnectorConfiguration()); CheckDefaultProperties(new SqlConnectorConfiguration()); } @@ -94,6 +97,8 @@ namespace Apache.Ignite.Core.Tests CheckDefaultValueAttributes(new PersistentStoreConfiguration()); CheckDefaultValueAttributes(new IgniteClientConfiguration()); CheckDefaultValueAttributes(new QueryIndex()); + CheckDefaultValueAttributes(new DataStorageConfiguration()); + CheckDefaultValueAttributes(new DataRegionConfiguration()); } /// @@ -219,33 +224,6 @@ namespace Apache.Ignite.Core.Tests Assert.AreEqual(eventCfg.ExpirationTimeout, resEventCfg.ExpirationTimeout); Assert.AreEqual(eventCfg.MaxEventCount, resEventCfg.MaxEventCount); - var memCfg = cfg.MemoryConfiguration; - var resMemCfg = resCfg.MemoryConfiguration; - Assert.IsNotNull(memCfg); - Assert.IsNotNull(resMemCfg); - Assert.AreEqual(memCfg.PageSize, resMemCfg.PageSize); - Assert.AreEqual(memCfg.ConcurrencyLevel, resMemCfg.ConcurrencyLevel); - Assert.AreEqual(memCfg.DefaultMemoryPolicyName, resMemCfg.DefaultMemoryPolicyName); - Assert.AreEqual(memCfg.SystemCacheInitialSize, resMemCfg.SystemCacheInitialSize); - Assert.AreEqual(memCfg.SystemCacheMaxSize, resMemCfg.SystemCacheMaxSize); - Assert.IsNotNull(memCfg.MemoryPolicies); - Assert.IsNotNull(resMemCfg.MemoryPolicies); - Assert.AreEqual(2, memCfg.MemoryPolicies.Count); - Assert.AreEqual(2, resMemCfg.MemoryPolicies.Count); - - for (var i = 0; i < memCfg.MemoryPolicies.Count; i++) - { - var plc = memCfg.MemoryPolicies.Skip(i).First(); - var resPlc = resMemCfg.MemoryPolicies.Skip(i).First(); - - Assert.AreEqual(plc.PageEvictionMode, resPlc.PageEvictionMode); - Assert.AreEqual(plc.MaxSize, resPlc.MaxSize); - Assert.AreEqual(plc.EmptyPagesPoolSize, resPlc.EmptyPagesPoolSize); - Assert.AreEqual(plc.EvictionThreshold, resPlc.EvictionThreshold); - Assert.AreEqual(plc.Name, resPlc.Name); - Assert.AreEqual(plc.SwapFilePath, resPlc.SwapFilePath); - } - var sql = cfg.SqlConnectorConfiguration; var resSql = resCfg.SqlConnectorConfiguration; @@ -258,30 +236,7 @@ namespace Apache.Ignite.Core.Tests Assert.AreEqual(sql.TcpNoDelay, resSql.TcpNoDelay); Assert.AreEqual(sql.ThreadPoolSize, resSql.ThreadPoolSize); - var pers = cfg.PersistentStoreConfiguration; - var resPers = resCfg.PersistentStoreConfiguration; - - Assert.AreEqual(pers.AlwaysWriteFullPages, resPers.AlwaysWriteFullPages); - Assert.AreEqual(pers.CheckpointingFrequency, resPers.CheckpointingFrequency); - Assert.AreEqual(pers.CheckpointingPageBufferSize, resPers.CheckpointingPageBufferSize); - Assert.AreEqual(pers.CheckpointingThreads, resPers.CheckpointingThreads); - Assert.AreEqual(pers.LockWaitTime, resPers.LockWaitTime); - Assert.AreEqual(pers.PersistentStorePath, resPers.PersistentStorePath); - Assert.AreEqual(pers.TlbSize, resPers.TlbSize); - Assert.AreEqual(pers.WalArchivePath, resPers.WalArchivePath); - Assert.AreEqual(pers.WalFlushFrequency, resPers.WalFlushFrequency); - Assert.AreEqual(pers.WalFsyncDelayNanos, resPers.WalFsyncDelayNanos); - Assert.AreEqual(pers.WalHistorySize, resPers.WalHistorySize); - Assert.AreEqual(pers.WalMode, resPers.WalMode); - Assert.AreEqual(pers.WalRecordIteratorBufferSize, resPers.WalRecordIteratorBufferSize); - Assert.AreEqual(pers.WalSegments, resPers.WalSegments); - Assert.AreEqual(pers.WalSegmentSize, resPers.WalSegmentSize); - Assert.AreEqual(pers.WalStorePath, resPers.WalStorePath); - Assert.AreEqual(pers.MetricsEnabled, resPers.MetricsEnabled); - Assert.AreEqual(pers.RateTimeInterval, resPers.RateTimeInterval); - Assert.AreEqual(pers.SubIntervals, resPers.SubIntervals); - Assert.AreEqual(pers.CheckpointWriteOrder, resPers.CheckpointWriteOrder); - Assert.AreEqual(pers.WriteThrottlingEnabled, resPers.WriteThrottlingEnabled); + TestUtils.AssertReflectionEqual(cfg.DataStorageConfiguration, resCfg.DataStorageConfiguration); } } @@ -311,24 +266,9 @@ namespace Apache.Ignite.Core.Tests Assert.IsNotNull(disco); Assert.AreEqual(TimeSpan.FromMilliseconds(300), disco.SocketTimeout); - // Check memory configuration defaults. - var mem = resCfg.MemoryConfiguration; - - Assert.IsNotNull(mem); - Assert.AreEqual("dfltPlc", mem.DefaultMemoryPolicyName); - Assert.AreEqual(MemoryConfiguration.DefaultSystemCacheInitialSize, mem.SystemCacheInitialSize); - Assert.AreEqual(MemoryConfiguration.DefaultSystemCacheMaxSize, mem.SystemCacheMaxSize); - - var plc = mem.MemoryPolicies.Single(); - Assert.AreEqual("dfltPlc", plc.Name); - Assert.AreEqual(MemoryPolicyConfiguration.DefaultEmptyPagesPoolSize, plc.EmptyPagesPoolSize); - Assert.AreEqual(MemoryPolicyConfiguration.DefaultEvictionThreshold, plc.EvictionThreshold); - Assert.AreEqual(MemoryPolicyConfiguration.DefaultMaxSize, plc.MaxSize); - Assert.AreEqual(MemoryPolicyConfiguration.DefaultSubIntervals, plc.SubIntervals); - Assert.AreEqual(MemoryPolicyConfiguration.DefaultRateTimeInterval, plc.RateTimeInterval); - - // Check PersistentStoreConfiguration defaults. - CheckDefaultProperties(resCfg.PersistentStoreConfiguration); + // DataStorage defaults. + CheckDefaultProperties(resCfg.DataStorageConfiguration); + CheckDefaultProperties(resCfg.DataStorageConfiguration.DefaultDataRegionConfiguration); // Connector defaults. CheckDefaultProperties(resCfg.ClientConnectorConfiguration); @@ -598,6 +538,54 @@ namespace Apache.Ignite.Core.Tests /// Checks the default properties. /// /// Config. + private static void CheckDefaultProperties(DataStorageConfiguration cfg) + { + Assert.AreEqual(DataStorageConfiguration.DefaultTlbSize, cfg.WalThreadLocalBufferSize); + Assert.AreEqual(DataStorageConfiguration.DefaultCheckpointFrequency, cfg.CheckpointFrequency); + Assert.AreEqual(DataStorageConfiguration.DefaultCheckpointThreads, cfg.CheckpointThreads); + Assert.AreEqual(default(long), cfg.CheckpointPageBufferSize); + Assert.AreEqual(DataStorageConfiguration.DefaultLockWaitTime, cfg.LockWaitTime); + Assert.AreEqual(DataStorageConfiguration.DefaultWalFlushFrequency, cfg.WalFlushFrequency); + Assert.AreEqual(DataStorageConfiguration.DefaultWalFsyncDelayNanos, cfg.WalFsyncDelayNanos); + Assert.AreEqual(DataStorageConfiguration.DefaultWalHistorySize, cfg.WalHistorySize); + Assert.AreEqual(DataStorageConfiguration.DefaultWalRecordIteratorBufferSize, + cfg.WalRecordIteratorBufferSize); + Assert.AreEqual(DataStorageConfiguration.DefaultWalSegmentSize, cfg.WalSegmentSize); + Assert.AreEqual(DataStorageConfiguration.DefaultWalSegments, cfg.WalSegments); + Assert.AreEqual(DataStorageConfiguration.DefaultWalMode, cfg.WalMode); + Assert.IsFalse(cfg.MetricsEnabled); + Assert.AreEqual(DataStorageConfiguration.DefaultMetricsSubIntervalCount, cfg.MetricsSubIntervalCount); + Assert.AreEqual(DataStorageConfiguration.DefaultMetricsRateTimeInterval, cfg.MetricsRateTimeInterval); + Assert.AreEqual(DataStorageConfiguration.DefaultWalPath, cfg.WalPath); + Assert.AreEqual(DataStorageConfiguration.DefaultWalArchivePath, cfg.WalArchivePath); + Assert.AreEqual(DataStorageConfiguration.DefaultCheckpointWriteOrder, cfg.CheckpointWriteOrder); + Assert.AreEqual(DataStorageConfiguration.DefaultWriteThrottlingEnabled, cfg.WriteThrottlingEnabled); + + Assert.AreEqual(DataStorageConfiguration.DefaultSystemRegionInitialSize, cfg.SystemRegionInitialSize); + Assert.AreEqual(DataStorageConfiguration.DefaultSystemRegionMaxSize, cfg.SystemRegionMaxSize); + Assert.AreEqual(DataStorageConfiguration.DefaultPageSize, cfg.PageSize); + Assert.AreEqual(DataStorageConfiguration.DefaultConcurrencyLevel, cfg.ConcurrencyLevel); + } + + /// + /// Checks the default properties. + /// + /// Config. + private static void CheckDefaultProperties(DataRegionConfiguration cfg) + { + Assert.AreEqual(DataRegionConfiguration.DefaultEmptyPagesPoolSize, cfg.EmptyPagesPoolSize); + Assert.AreEqual(DataRegionConfiguration.DefaultEvictionThreshold, cfg.EvictionThreshold); + Assert.AreEqual(DataRegionConfiguration.DefaultInitialSize, cfg.InitialSize); + Assert.AreEqual(DataRegionConfiguration.DefaultMaxSize, cfg.MaxSize); + Assert.AreEqual(DataRegionConfiguration.DefaultPersistenceEnabled, cfg.PersistenceEnabled); + Assert.AreEqual(DataRegionConfiguration.DefaultMetricsRateTimeInterval, cfg.MetricsRateTimeInterval); + Assert.AreEqual(DataRegionConfiguration.DefaultMetricsSubIntervalCount, cfg.MetricsSubIntervalCount); + } + + /// + /// Checks the default properties. + /// + /// Config. private static void CheckDefaultProperties(ClientConnectorConfiguration cfg) { Assert.AreEqual(ClientConnectorConfiguration.DefaultPort, cfg.Port); @@ -636,8 +624,7 @@ namespace Apache.Ignite.Core.Tests foreach (var prop in props.Where(p => p.Name != "SelectorsCount" && p.Name != "ReadStripesNumber" && !p.Name.Contains("ThreadPoolSize") && - !(p.Name == "MaxSize" && - p.DeclaringType == typeof(MemoryPolicyConfiguration)))) + p.Name != "MaxSize")) { var attr = prop.GetCustomAttributes(true).OfType().FirstOrDefault(); var propValue = prop.GetValue(obj, null); @@ -645,7 +632,7 @@ namespace Apache.Ignite.Core.Tests if (attr != null) Assert.AreEqual(attr.Value, propValue, string.Format("{0}.{1}", obj.GetType(), prop.Name)); else if (prop.PropertyType.IsValueType) - Assert.AreEqual(Activator.CreateInstance(prop.PropertyType), propValue); + Assert.AreEqual(Activator.CreateInstance(prop.PropertyType), propValue, prop.Name); else Assert.IsNull(propValue); } @@ -757,39 +744,6 @@ namespace Apache.Ignite.Core.Tests ExpirationTimeout = TimeSpan.FromSeconds(5), MaxEventCount = 10 }, - MemoryConfiguration = new MemoryConfiguration - { - ConcurrencyLevel = 3, - DefaultMemoryPolicyName = "myDefaultPlc", - PageSize = 2048, - SystemCacheInitialSize = 13 * 1024 * 1024, - SystemCacheMaxSize = 15 * 1024 * 1024, - MemoryPolicies = new[] - { - new MemoryPolicyConfiguration - { - Name = "myDefaultPlc", - PageEvictionMode = DataPageEvictionMode.Disabled, - InitialSize = 340 * 1024 * 1024, - MaxSize = 345 * 1024 * 1024, - EvictionThreshold = 0.88, - EmptyPagesPoolSize = 77, - SwapFilePath = "myPath1", - RateTimeInterval = TimeSpan.FromSeconds(35), - SubIntervals = 7 - }, - new MemoryPolicyConfiguration - { - Name = "customPlc", - PageEvictionMode = DataPageEvictionMode.Disabled, - MaxSize = 456 * 1024 * 1024, - EvictionThreshold = 0.77, - EmptyPagesPoolSize = 66, - SwapFilePath = "somePath2", - MetricsEnabled = true - } - } - }, PublicThreadPoolSize = 3, StripedThreadPoolSize = 5, ServiceThreadPoolSize = 6, @@ -810,31 +764,66 @@ namespace Apache.Ignite.Core.Tests TcpNoDelay = false, SocketSendBufferSize = 4096 }, - PersistentStoreConfiguration = new PersistentStoreConfiguration + ConsistentId = new MyConsistentId {Data = "abc"}, + DataStorageConfiguration = new DataStorageConfiguration { AlwaysWriteFullPages = true, - CheckpointingFrequency = TimeSpan.FromSeconds(25), - CheckpointingPageBufferSize = 28 * 1024 * 1024, - CheckpointingThreads = 2, + CheckpointFrequency = TimeSpan.FromSeconds(25), + CheckpointPageBufferSize = 28 * 1024 * 1024, + CheckpointThreads = 2, LockWaitTime = TimeSpan.FromSeconds(5), - PersistentStorePath = Path.GetTempPath(), - TlbSize = 64 * 1024, + StoragePath = Path.GetTempPath(), + WalThreadLocalBufferSize = 64 * 1024, WalArchivePath = Path.GetTempPath(), WalFlushFrequency = TimeSpan.FromSeconds(3), WalFsyncDelayNanos = 3, WalHistorySize = 10, - WalMode = WalMode.LogOnly, + WalMode = Configuration.WalMode.LogOnly, WalRecordIteratorBufferSize = 32 * 1024 * 1024, WalSegments = 6, WalSegmentSize = 5 * 1024 * 1024, - WalStorePath = Path.GetTempPath(), + WalPath = Path.GetTempPath(), MetricsEnabled = true, - SubIntervals = 7, - RateTimeInterval = TimeSpan.FromSeconds(9), - CheckpointWriteOrder = CheckpointWriteOrder.Random, - WriteThrottlingEnabled = true - }, - ConsistentId = new MyConsistentId {Data = "abc"} + MetricsSubIntervalCount = 7, + MetricsRateTimeInterval = TimeSpan.FromSeconds(9), + CheckpointWriteOrder = Configuration.CheckpointWriteOrder.Random, + WriteThrottlingEnabled = true, + SystemRegionInitialSize = 64 * 1024 * 1024, + SystemRegionMaxSize = 128 * 1024 * 1024, + ConcurrencyLevel = 1, + PageSize = 8 * 1024, + DefaultDataRegionConfiguration = new DataRegionConfiguration + { + Name = "reg1", + EmptyPagesPoolSize = 50, + EvictionThreshold = 0.8, + InitialSize = 100 * 1024 * 1024, + MaxSize = 150 * 1024 * 1024, + MetricsEnabled = true, + PageEvictionMode = Configuration.DataPageEvictionMode.Random2Lru, + PersistenceEnabled = false, + MetricsRateTimeInterval = TimeSpan.FromMinutes(2), + MetricsSubIntervalCount = 6, + SwapPath = IgniteUtils.GetTempDirectoryName() + }, + DataRegionConfigurations = new[] + { + new DataRegionConfiguration + { + Name = "reg2", + EmptyPagesPoolSize = 51, + EvictionThreshold = 0.7, + InitialSize = 101 * 1024 * 1024, + MaxSize = 151 * 1024 * 1024, + MetricsEnabled = false, + PageEvictionMode = Configuration.DataPageEvictionMode.RandomLru, + PersistenceEnabled = false, + MetricsRateTimeInterval = TimeSpan.FromMinutes(3), + MetricsSubIntervalCount = 7, + SwapPath = IgniteUtils.GetTempDirectoryName() + } + } + } }; } http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj index 446208a..20a54d0 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj @@ -94,6 +94,10 @@ + + + + @@ -105,6 +109,9 @@ + + + @@ -113,6 +120,7 @@ + @@ -120,6 +128,7 @@ + @@ -603,6 +612,7 @@ + http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/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 c6b81f0..e7252b2 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs @@ -27,6 +27,7 @@ namespace Apache.Ignite.Core.Cache.Configuration using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; + using System.Xml.Serialization; using Apache.Ignite.Core.Cache; using Apache.Ignite.Core.Cache.Affinity; using Apache.Ignite.Core.Cache.Affinity.Rendezvous; @@ -34,6 +35,7 @@ namespace Apache.Ignite.Core.Cache.Configuration using Apache.Ignite.Core.Cache.Expiry; using Apache.Ignite.Core.Cache.Store; using Apache.Ignite.Core.Common; + using Apache.Ignite.Core.Configuration; using Apache.Ignite.Core.Impl; using Apache.Ignite.Core.Impl.Binary; using Apache.Ignite.Core.Impl.Cache.Affinity; @@ -286,7 +288,7 @@ namespace Apache.Ignite.Core.Cache.Configuration ReadThrough = reader.ReadBoolean(); WriteThrough = reader.ReadBoolean(); EnableStatistics = reader.ReadBoolean(); - MemoryPolicyName = reader.ReadString(); + DataRegionName = reader.ReadString(); PartitionLossPolicy = (PartitionLossPolicy) reader.ReadInt(); GroupName = reader.ReadString(); CacheStoreFactory = reader.ReadObject>(); @@ -366,7 +368,7 @@ namespace Apache.Ignite.Core.Cache.Configuration writer.WriteBoolean(ReadThrough); writer.WriteBoolean(WriteThrough); writer.WriteBoolean(EnableStatistics); - writer.WriteString(MemoryPolicyName); + writer.WriteString(DataRegionName); writer.WriteInt((int) PartitionLossPolicy); writer.WriteString(GroupName); writer.WriteObject(CacheStoreFactory); @@ -747,7 +749,18 @@ namespace Apache.Ignite.Core.Cache.Configuration /// Gets or sets the name of the for this cache. /// See . /// - public string MemoryPolicyName { get; set; } + [Obsolete("Use DataRegionName.")] + [XmlIgnore] + public string MemoryPolicyName + { + get { return DataRegionName; } + set { DataRegionName = value; } + } + + /// + /// Gets or sets the name of the data region, see . + /// + public string DataRegionName { get; set; } /// /// Gets or sets write coalescing flag for write-behind cache store operations. @@ -770,7 +783,7 @@ namespace Apache.Ignite.Core.Cache.Configuration /// /// Since underlying cache is shared, the following configuration properties should be the same within group: /// , , , - /// + /// /// /// Grouping caches reduces overall overhead, since internal data structures are shared. /// http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/DataPageEvictionMode.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/DataPageEvictionMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/DataPageEvictionMode.cs index a6263d7..57e60d9 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/DataPageEvictionMode.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/DataPageEvictionMode.cs @@ -17,11 +17,14 @@ namespace Apache.Ignite.Core.Cache.Configuration { + using System; + /// /// Memory page eviction mode. /// Only data pages, that store key-value entries, are eligible for eviction. /// The other types of pages, like index or system pages, are not evictable. /// + [Obsolete("Use Apache.Ignite.Core.Configuration.DataPageEvictionMode")] public enum DataPageEvictionMode { /// http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs index 3be6012..12d0002 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs @@ -17,6 +17,7 @@ namespace Apache.Ignite.Core.Cache.Configuration { + using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; @@ -24,6 +25,7 @@ namespace Apache.Ignite.Core.Cache.Configuration using System.Linq; using Apache.Ignite.Core.Binary; using Apache.Ignite.Core.Common; + using Apache.Ignite.Core.Configuration; /// /// A page memory configuration for an Apache Ignite node. The page memory is a manageable off-heap based @@ -42,7 +44,10 @@ namespace Apache.Ignite.Core.Cache.Configuration /// eviction policies, swapping options, etc. Once you define a new memory region you can bind /// particular Ignite caches to it. /// To learn more about memory policies refer to documentation. + /// + /// Obsolete, use . /// + [Obsolete("Use DataStorageConfiguration.")] public class MemoryConfiguration { /// http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs index 16d8dcc..e204ee7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs @@ -21,12 +21,15 @@ namespace Apache.Ignite.Core.Cache.Configuration using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using Apache.Ignite.Core.Binary; + using Apache.Ignite.Core.Configuration; using Apache.Ignite.Core.Impl; using Apache.Ignite.Core.Impl.Binary; /// /// Defines page memory policy configuration. See . + /// Obsolete, use . /// + [Obsolete("Use DataRegionConfiguration.")] public class MemoryPolicyConfiguration { /// http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/Cache/IMemoryMetrics.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/IMemoryMetrics.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/IMemoryMetrics.cs index 0298c1f..ff8d64e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/IMemoryMetrics.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/IMemoryMetrics.cs @@ -17,9 +17,13 @@ namespace Apache.Ignite.Core.Cache { + using System; + /// /// Memory usage metrics. + /// Obsolete, use . /// + [Obsolete("See IDataRegionMetrics.")] public interface IMemoryMetrics { /// http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/CheckpointWriteOrder.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/CheckpointWriteOrder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/CheckpointWriteOrder.cs new file mode 100644 index 0000000..5243f4a --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/CheckpointWriteOrder.cs @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Configuration +{ + /// + /// Defines checkpoint pages order on disk. + /// + public enum CheckpointWriteOrder + { + /// + /// Pages are written in order provided by checkpoint pages collection iterator + /// (which is basically a hashtable). + /// + Random, + + /// + /// All checkpoint pages are collected into single list and sorted by page index. + /// Provides almost sequential disk writes, which can be much faster on some SSD models. + /// + Sequential + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataPageEvictionMode.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataPageEvictionMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataPageEvictionMode.cs new file mode 100644 index 0000000..ec835bb --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataPageEvictionMode.cs @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Configuration +{ + /// + /// Memory page eviction mode. + /// Only data pages, that store key-value entries, are eligible for eviction. + /// The other types of pages, like index or system pages, are not evictable. + /// + public enum DataPageEvictionMode + { + /// + /// Eviction is disabled. + /// + Disabled, + + /// + /// Random-LRU algorithm. + /// + /// Once a memory region defined by a memory policy is configured, an off-heap array is allocated to track + /// last usage timestamp for every individual data page. The size of the array equals to + /// / . + /// + /// When a data page is accessed, its timestamp gets updated in the tracking array. The page index in the + /// tracking array equals to pageAddress / . + /// + /// When some pages need to be evicted, the algorithm randomly chooses 5 indexes from the tracking array and + /// evicts a page with the latest timestamp. If some of the indexes point to non-data pages + /// (index or system pages) then the algorithm picks other pages. + /// + RandomLru, + + /// + /// Activates Random-2-LRU algorithm which is a scan resistant version of Random-LRU. + /// + /// This algorithm differs from Random-LRU only in a way that two latest access timestamps are stored for every + /// data page. At the eviction time, a minimum between two latest timestamps is taken for further + /// comparison with minimums of other pages that might be evicted. LRU-2 outperforms LRU by + /// resolving "one-hit wonder" problem - if a data page is accessed rarely, but accidentally accessed once, + /// its protected from eviction for a long time. + /// + Random2Lru + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataRegionConfiguration.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataRegionConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataRegionConfiguration.cs new file mode 100644 index 0000000..5c4240e --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataRegionConfiguration.cs @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Configuration +{ + using System; + using System.ComponentModel; + using System.Diagnostics.CodeAnalysis; + using Apache.Ignite.Core.Binary; + using Apache.Ignite.Core.Cache.Configuration; + using Apache.Ignite.Core.Impl; + using Apache.Ignite.Core.Impl.Binary; + + /// + /// Defines custom data region configuration for Apache Ignite page memory + /// (see ). + /// + /// For each configured data region Apache Ignite instantiates respective memory regions with different + /// parameters like maximum size, eviction policy, swapping options, etc. + /// An Apache Ignite cache can be mapped to a particular region using + /// method. + /// + public class DataRegionConfiguration + { + /// + /// Default value for . + /// + public const bool DefaultPersistenceEnabled = false; + + /// + /// The default eviction threshold. + /// + public const double DefaultEvictionThreshold = 0.9; + + /// + /// The default empty pages pool size. + /// + public const int DefaultEmptyPagesPoolSize = 100; + + /// + /// The default initial size. + /// + public const long DefaultInitialSize = 256 * 1024 * 1024; + + /// + /// The default maximum size, equals to 20% of total RAM. + /// + public static readonly long DefaultMaxSize = (long)((long)NativeMethods.GetTotalPhysicalMemory() * 0.2); + + /// + /// The default sub intervals. + /// + [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", + Justification = "Consistency with Java config")] + public const int DefaultMetricsSubIntervalCount = 5; + + /// + /// The default rate time interval. + /// + public static readonly TimeSpan DefaultMetricsRateTimeInterval = TimeSpan.FromSeconds(60); + + /// + /// Initializes a new instance of the class. + /// + public DataRegionConfiguration() + { + PersistenceEnabled = DefaultPersistenceEnabled; + EvictionThreshold = DefaultEvictionThreshold; + EmptyPagesPoolSize = DefaultEmptyPagesPoolSize; + InitialSize = DefaultInitialSize; + MaxSize = DefaultMaxSize; + MetricsSubIntervalCount = DefaultMetricsSubIntervalCount; + MetricsRateTimeInterval = DefaultMetricsRateTimeInterval; + } + + /// + /// Initializes a new instance of the class. + /// + /// The reader. + internal DataRegionConfiguration(IBinaryRawReader reader) + { + Name = reader.ReadString(); + PersistenceEnabled = reader.ReadBoolean(); + InitialSize = reader.ReadLong(); + MaxSize = reader.ReadLong(); + SwapPath = reader.ReadString(); + PageEvictionMode = (DataPageEvictionMode)reader.ReadInt(); + EvictionThreshold = reader.ReadDouble(); + EmptyPagesPoolSize = reader.ReadInt(); + MetricsEnabled = reader.ReadBoolean(); + MetricsSubIntervalCount = reader.ReadInt(); + MetricsRateTimeInterval = reader.ReadLongAsTimespan(); + } + + /// + /// Writes this instance to a writer. + /// + internal void Write(IBinaryRawWriter writer) + { + writer.WriteString(Name); + writer.WriteBoolean(PersistenceEnabled); + writer.WriteLong(InitialSize); + writer.WriteLong(MaxSize); + writer.WriteString(SwapPath); + writer.WriteInt((int)PageEvictionMode); + writer.WriteDouble(EvictionThreshold); + writer.WriteInt(EmptyPagesPoolSize); + writer.WriteBoolean(MetricsEnabled); + writer.WriteInt(MetricsSubIntervalCount); + writer.WriteTimeSpanAsLong(MetricsRateTimeInterval); + } + + /// + /// Gets or sets the data region name. + /// + public string Name { get; set; } + + /// + /// Gets or sets a value indicating whether disk persistence is enabled for this region. + /// Default is . + /// + [DefaultValue(DefaultPersistenceEnabled)] + public bool PersistenceEnabled { get; set; } + + /// + /// Gets or sets initial memory region size. + /// When the used memory size exceeds this value, new chunks of memory will be allocated. + /// + [DefaultValue(DefaultInitialSize)] + public long InitialSize { get; set; } + + /// + /// Sets maximum memory region size. The total size should not be less + /// than 10 MB due to internal data structures overhead. + /// + public long MaxSize { get; set; } + + /// + /// Gets or sets the the path to the directory for memory-mapped files. + /// + /// Null for no swap. + /// + public string SwapPath { get; set; } + + /// + /// Gets or sets the page eviction mode. If is used (default) + /// then an out of memory exception will be thrown if the memory region usage + /// goes beyond . + /// + public DataPageEvictionMode PageEvictionMode { get; set; } + + /// + /// Gets or sets the threshold for memory pages eviction initiation. For instance, if the threshold is 0.9 + /// it means that the page memory will start the eviction only after 90% of the memory region is occupied. + /// + [DefaultValue(DefaultEvictionThreshold)] + public double EvictionThreshold { get; set; } + + /// + /// Gets or sets the minimal number of empty pages to be present in reuse lists for this data region. + /// This parameter ensures that Ignite will be able to successfully evict old data entries when the size of + /// (key, value) pair is slightly larger than page size / 2. + /// Increase this parameter if cache can contain very big entries (total size of pages in this pool + /// should be enough to contain largest cache entry). + /// + [DefaultValue(DefaultEmptyPagesPoolSize)] + public int EmptyPagesPoolSize { get; set; } + + /// + /// Gets or sets a value indicating whether memory metrics should be enabled. + /// + /// Metrics can be retrieved with method. + /// + public bool MetricsEnabled { get; set; } + + /// + /// Gets or sets the rate time interval for + /// and monitoring purposes. + /// + /// For instance, after setting the interval to 60 seconds, subsequent calls + /// to will return average allocation + /// rate (pages per second) for the last minute. + /// + [DefaultValue(typeof(TimeSpan), "00:01:00")] + public TimeSpan MetricsRateTimeInterval { get; set; } + + /// + /// Gets or sets the number of sub intervals to split into to calculate + /// and . + /// + /// Bigger value results in more accurate metrics. + /// + [DefaultValue(DefaultMetricsSubIntervalCount)] + [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", + Justification = "Consistency with Java config")] + public int MetricsSubIntervalCount { get; set; } + + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataStorageConfiguration.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataStorageConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataStorageConfiguration.cs new file mode 100644 index 0000000..17b4ada --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/DataStorageConfiguration.cs @@ -0,0 +1,466 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Configuration +{ + using System; + using System.Collections.Generic; + using System.ComponentModel; + using System.Diagnostics; + using System.Diagnostics.CodeAnalysis; + using System.Linq; + using Apache.Ignite.Core.Binary; + using Apache.Ignite.Core.Common; + using Apache.Ignite.Core.Impl.Binary; + + /// + /// Data storage configuration for Ignite page memory. + /// + /// The page memory is a manageable off-heap based memory architecture that divides all expandable data + /// regions into pages of fixed size. An individual page can store one or many cache key-value entries + /// that allows reusing the memory in the most efficient way and avoid memory fragmentation issues. + /// + /// By default, the page memory allocates a single expandable data region. All the caches that will be + /// configured in an application will be mapped to this data region by default, thus, all the cache data + /// will reside in that data region. + /// + public class DataStorageConfiguration + { + /// + /// Default value for . + /// + public const int DefaultCheckpointThreads = 4; + + /// + /// Default name is assigned to default data region if no user-defined + /// is specified. + /// + public const string DefaultDataRegionName = "default"; + + /// + /// Default value for . + /// + public static readonly TimeSpan DefaultCheckpointFrequency = TimeSpan.FromSeconds(180); + + /// + /// Default value for . + /// + public static readonly TimeSpan DefaultLockWaitTime = TimeSpan.FromSeconds(10); + + /// + /// Default value for . + /// + public const int DefaultWalHistorySize = 20; + + /// + /// Default value for . + /// + public const int DefaultWalSegments = 10; + + /// + /// Default value for . + /// + public const int DefaultWalSegmentSize = 64 * 1024 * 1024; + + /// + /// Default value for . + /// + public const int DefaultTlbSize = 128 * 1024; + + /// + /// Default value for . + /// + public static readonly TimeSpan DefaultWalFlushFrequency = TimeSpan.FromSeconds(2); + + /// + /// Default value for . + /// + public const int DefaultWalRecordIteratorBufferSize = 64 * 1024 * 1024; + + /// + /// Default value for . + /// + public const long DefaultWalFsyncDelayNanos = 1000; + + /// + /// The default sub intervals. + /// + [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", + Justification = "Consistency with Java config")] + public const int DefaultMetricsSubIntervalCount = 5; + + /// + /// The default rate time interval. + /// + public static readonly TimeSpan DefaultMetricsRateTimeInterval = TimeSpan.FromSeconds(60); + + /// + /// Default value for . + /// + public const string DefaultWalPath = "db/wal"; + + /// + /// Default value for . + /// + public const string DefaultWalArchivePath = "db/wal/archive"; + + /// + /// Default value for . + /// + public const WalMode DefaultWalMode = WalMode.Default; + + /// + /// Default value for . + /// + public const CheckpointWriteOrder DefaultCheckpointWriteOrder = CheckpointWriteOrder.Sequential; + + /// + /// Default value for . + /// + public const bool DefaultWriteThrottlingEnabled = false; + + /// + /// Default size of a memory chunk reserved for system cache initially. + /// + public const long DefaultSystemRegionInitialSize = 40 * 1024 * 1024; + + /// + /// Default max size of a memory chunk for the system cache. + /// + public const long DefaultSystemRegionMaxSize = 100 * 1024 * 1024; + + /// + /// The default page size. + /// + public const int DefaultPageSize = 4 * 1024; + + /// + /// The default concurrency level. + /// + public const int DefaultConcurrencyLevel = 0; + + /// + /// Initializes a new instance of the class. + /// + public DataStorageConfiguration() + { + CheckpointThreads = DefaultCheckpointThreads; + CheckpointFrequency = DefaultCheckpointFrequency; + LockWaitTime = DefaultLockWaitTime; + WalHistorySize = DefaultWalHistorySize; + WalSegments = DefaultWalSegments; + WalSegmentSize = DefaultWalSegmentSize; + WalThreadLocalBufferSize = DefaultTlbSize; + WalFlushFrequency = DefaultWalFlushFrequency; + WalRecordIteratorBufferSize = DefaultWalRecordIteratorBufferSize; + WalFsyncDelayNanos = DefaultWalFsyncDelayNanos; + MetricsRateTimeInterval = DefaultMetricsRateTimeInterval; + MetricsSubIntervalCount = DefaultMetricsSubIntervalCount; + WalArchivePath = DefaultWalArchivePath; + WalPath = DefaultWalPath; + CheckpointWriteOrder = DefaultCheckpointWriteOrder; + WriteThrottlingEnabled = DefaultWriteThrottlingEnabled; + SystemRegionInitialSize = DefaultSystemRegionInitialSize; + SystemRegionMaxSize = DefaultSystemRegionMaxSize; + PageSize = DefaultPageSize; + } + + /// + /// Initializes a new instance of the class. + /// + /// The reader. + internal DataStorageConfiguration(IBinaryRawReader reader) + { + Debug.Assert(reader != null); + + StoragePath = reader.ReadString(); + CheckpointFrequency = reader.ReadLongAsTimespan(); + CheckpointPageBufferSize = reader.ReadLong(); + CheckpointThreads = reader.ReadInt(); + LockWaitTime = reader.ReadLongAsTimespan(); + WalHistorySize = reader.ReadInt(); + WalSegments = reader.ReadInt(); + WalSegmentSize = reader.ReadInt(); + WalPath = reader.ReadString(); + WalArchivePath = reader.ReadString(); + WalMode = (WalMode)reader.ReadInt(); + WalThreadLocalBufferSize = reader.ReadInt(); + WalFlushFrequency = reader.ReadLongAsTimespan(); + WalFsyncDelayNanos = reader.ReadLong(); + WalRecordIteratorBufferSize = reader.ReadInt(); + AlwaysWriteFullPages = reader.ReadBoolean(); + MetricsEnabled = reader.ReadBoolean(); + MetricsSubIntervalCount = reader.ReadInt(); + MetricsRateTimeInterval = reader.ReadLongAsTimespan(); + CheckpointWriteOrder = (CheckpointWriteOrder)reader.ReadInt(); + WriteThrottlingEnabled = reader.ReadBoolean(); + + SystemRegionInitialSize = reader.ReadLong(); + SystemRegionMaxSize = reader.ReadLong(); + PageSize = reader.ReadInt(); + ConcurrencyLevel = reader.ReadInt(); + + var count = reader.ReadInt(); + + if (count > 0) + { + DataRegionConfigurations = Enumerable.Range(0, count) + .Select(x => new DataRegionConfiguration(reader)) + .ToArray(); + } + + if (reader.ReadBoolean()) + { + DefaultDataRegionConfiguration = new DataRegionConfiguration(reader); + } + } + + /// + /// Writes this instance to the specified writer. + /// + /// The writer. + internal void Write(IBinaryRawWriter writer) + { + Debug.Assert(writer != null); + + writer.WriteString(StoragePath); + writer.WriteTimeSpanAsLong(CheckpointFrequency); + writer.WriteLong(CheckpointPageBufferSize); + writer.WriteInt(CheckpointThreads); + writer.WriteTimeSpanAsLong(LockWaitTime); + writer.WriteInt(WalHistorySize); + writer.WriteInt(WalSegments); + writer.WriteInt(WalSegmentSize); + writer.WriteString(WalPath); + writer.WriteString(WalArchivePath); + writer.WriteInt((int)WalMode); + writer.WriteInt(WalThreadLocalBufferSize); + writer.WriteTimeSpanAsLong(WalFlushFrequency); + writer.WriteLong(WalFsyncDelayNanos); + writer.WriteInt(WalRecordIteratorBufferSize); + writer.WriteBoolean(AlwaysWriteFullPages); + writer.WriteBoolean(MetricsEnabled); + writer.WriteInt(MetricsSubIntervalCount); + writer.WriteTimeSpanAsLong(MetricsRateTimeInterval); + writer.WriteInt((int)CheckpointWriteOrder); + writer.WriteBoolean(WriteThrottlingEnabled); + + writer.WriteLong(SystemRegionInitialSize); + writer.WriteLong(SystemRegionMaxSize); + writer.WriteInt(PageSize); + writer.WriteInt(ConcurrencyLevel); + + if (DataRegionConfigurations != null) + { + writer.WriteInt(DataRegionConfigurations.Count); + + foreach (var region in DataRegionConfigurations) + { + if (region == null) + { + throw new IgniteException( + "DataStorageConfiguration.DataRegionConfigurations must not contain null items."); + } + + region.Write(writer); + } + } + else + { + writer.WriteInt(0); + } + + if (DefaultDataRegionConfiguration != null) + { + writer.WriteBoolean(true); + DefaultDataRegionConfiguration.Write(writer); + } + else + { + writer.WriteBoolean(false); + } + } + + /// + /// Gets or sets the path where data and indexes will be persisted. + /// + public string StoragePath { get; set; } + + /// + /// Gets or sets the checkpointing frequency which is a minimal interval when the dirty pages will be written + /// to the Persistent Store. + /// + [DefaultValue(typeof(TimeSpan), "00:03:00")] + public TimeSpan CheckpointFrequency { get; set; } + + /// + /// Gets or sets the size of the checkpointing page buffer. + /// + /// Default is 0: Ignite will choose buffer size automatically. + /// + public long CheckpointPageBufferSize { get; set; } + + /// + /// Gets or sets the number of threads for checkpointing. + /// + [DefaultValue(DefaultCheckpointThreads)] + public int CheckpointThreads { get; set; } + + /// + /// Gets or sets the persistent manager file lock wait time. + /// + [DefaultValue(typeof(TimeSpan), "00:00:10")] + public TimeSpan LockWaitTime { get; set; } + + /// + /// Gets or sets the number of checkpoints to store in WAL (Write Ahead Log) history. + /// + [DefaultValue(DefaultWalHistorySize)] + public int WalHistorySize { get; set; } + + /// + /// Gets or sets a number of WAL (Write Ahead Log) segments to work with. + /// For performance reasons, the whole WAL is split into files of fixed length called segments. + /// + [DefaultValue(DefaultWalSegments)] + public int WalSegments { get; set; } + + /// + /// Gets or sets the size of the WAL (Write Ahead Log) segment. + /// For performance reasons, the whole WAL is split into files of fixed length called segments. + /// + [DefaultValue(DefaultWalSegmentSize)] + public int WalSegmentSize { get; set; } + + /// + /// Gets or sets the path to the directory where WAL (Write Ahead Log) is stored. + /// + [DefaultValue(DefaultWalPath)] + public string WalPath { get; set; } + + /// + /// Gets or sets the path to the directory where WAL (Write Ahead Log) archive is stored. + /// Every WAL segment will be fully copied to this directory before it can be reused for WAL purposes. + /// + [DefaultValue(DefaultWalArchivePath)] + public string WalArchivePath { get; set; } + + /// + /// Gets or sets the WAL (Write Ahead Log) mode. + /// + [DefaultValue(DefaultWalMode)] + public WalMode WalMode { get; set; } + + /// + /// Gets or sets the size of the TLB (Thread-Local Buffer), in bytes. + /// + [DefaultValue(DefaultTlbSize)] + public int WalThreadLocalBufferSize { get; set; } + + /// + /// Gets or sets the WAL (Write Ahead Log) flush frequency. + /// + [DefaultValue(typeof(TimeSpan), "00:00:02")] + public TimeSpan WalFlushFrequency { get; set; } + + /// + /// Gets or sets the WAL (Write Ahead Log) fsync (disk sync) delay, in nanoseconds + /// + [DefaultValue(DefaultWalFsyncDelayNanos)] + public long WalFsyncDelayNanos { get; set; } + + /// + /// Gets or sets the size of the WAL (Write Ahead Log) record iterator buffer, in bytes. + /// + [DefaultValue(DefaultWalRecordIteratorBufferSize)] + public int WalRecordIteratorBufferSize { get; set; } + + /// + /// Gets or sets a value indicating whether full pages should always be written. + /// + public bool AlwaysWriteFullPages { get; set; } + + /// + /// Gets or sets a value indicating whether to enable data storage metrics. + /// See . + /// + public bool MetricsEnabled { get; set; } + + /// + /// Gets or sets the length of the time interval for rate-based metrics. + /// This interval defines a window over which hits will be tracked. + /// + [DefaultValue(typeof(TimeSpan), "00:01:00")] + public TimeSpan MetricsRateTimeInterval { get; set; } + + /// + /// Number of sub-intervals to split the into to track the update history. + /// + [DefaultValue(DefaultMetricsSubIntervalCount)] + [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", + Justification = "Consistency with Java config")] + public int MetricsSubIntervalCount { get; set; } + + /// + /// Gets or sets the checkpoint page write order on disk. + /// + [DefaultValue(DefaultCheckpointWriteOrder)] + public CheckpointWriteOrder CheckpointWriteOrder { get; set; } + + /// + /// Gets or sets a value indicating whether threads that generate dirty + /// pages too fast during ongoing checkpoint will be throttled. + /// + [DefaultValue(DefaultWriteThrottlingEnabled)] + public bool WriteThrottlingEnabled { get; set; } + + /// + /// Gets or sets the size of a memory chunk reserved for system needs. + /// + [DefaultValue(DefaultSystemRegionInitialSize)] + public long SystemRegionInitialSize { get; set; } + + /// + /// Gets or sets the maximum memory region size reserved for system needs. + /// + [DefaultValue(DefaultSystemRegionMaxSize)] + public long SystemRegionMaxSize { get; set; } + + /// + /// Gets or sets the size of the memory page. + /// + [DefaultValue(DefaultPageSize)] + public int PageSize { get; set; } + + /// + /// Gets or sets the number of concurrent segments in Ignite internal page mapping tables. + /// + [DefaultValue(DefaultConcurrencyLevel)] + public int ConcurrencyLevel { get; set; } + + /// + /// Gets or sets the data region configurations. + /// + [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public ICollection DataRegionConfigurations { get; set; } + + /// + /// Gets or sets the default region configuration. + /// + public DataRegionConfiguration DefaultDataRegionConfiguration { get; set; } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/WalMode.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/WalMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/WalMode.cs new file mode 100644 index 0000000..d6e4532 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Configuration/WalMode.cs @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Configuration +{ + /// + /// Write Ahead Log mode. + /// + public enum WalMode + { + /// + /// Default mode: full-sync disk writes. These writes survive power loss scenarios. + /// + Default, + + /// + /// Log only mode: flushes application buffers. These writes survive process crash. + /// + LogOnly, + + /// + /// Background mode. Does not force application buffer flush. Data may be lost in case of process crash. + /// + Background, + + /// + /// WAL disabled. + /// + None + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/IDataRegionMetrics.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IDataRegionMetrics.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IDataRegionMetrics.cs new file mode 100644 index 0000000..0cb6192 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/IDataRegionMetrics.cs @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core +{ + /// + /// Memory usage metrics. + /// + public interface IDataRegionMetrics + { + /// + /// Gets the memory policy name. + /// + string Name { get; } + + /// + /// Gets the count of allocated pages. + /// + long TotalAllocatedPages { get; } + + /// + /// Gets the allocation rate, in pages per second. + /// + float AllocationRate { get; } + + /// + /// Gets the eviction rate, in pages per second. + /// + float EvictionRate { get; } + + /// + /// Gets the percentage of pages fully occupied by entries that are larger than page. + /// + float LargeEntriesPagesPercentage { get; } + + /// + /// Gets the page fill factor: free space to overall size ratio across all pages. + /// + float PageFillFactor { get; } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/IDataStorageMetrics.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IDataStorageMetrics.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IDataStorageMetrics.cs new file mode 100644 index 0000000..6f3562d --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/IDataStorageMetrics.cs @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core +{ + using System; + + /// + /// Persistent store metrics. + /// + public interface IDataStorageMetrics + { + /// + /// Gets the average number of WAL records per second written during the last time interval. + /// + float WalLoggingRate { get; } + + /// + /// Gets the average number of bytes per second written during the last time interval. + /// + float WalWritingRate { get; } + + /// + /// Gets the current number of WAL segments in the WAL archive. + /// + int WalArchiveSegments { get; } + + /// + /// Gets the average WAL fsync duration in microseconds over the last time interval. + /// + float WalFsyncTimeAverage { get; } + + /// + /// Gets the duration of the last checkpoint. + /// + TimeSpan LastCheckpointDuration { get; } + + /// + /// Gets the duration of last checkpoint lock wait. + /// + TimeSpan LastCheckpointLockWaitDuration { get; } + + /// + /// Gets the duration of last checkpoint mark phase. + /// + TimeSpan LastCheckpointMarkDuration { get; } + + /// + /// Gets the duration of last checkpoint pages write phase. + /// + TimeSpan LastCheckpointPagesWriteDuration { get; } + + /// + /// Gets the duration of the sync phase of the last checkpoint. + /// + TimeSpan LastCheckpointFsyncDuration { get; } + + /// + /// Gets the total number of pages written during the last checkpoint. + /// + long LastCheckpointTotalPagesNumber { get; } + + /// + /// Gets the number of data pages written during the last checkpoint. + /// + long LastCheckpointDataPagesNumber { get; } + + /// + /// Gets the number of pages copied to a temporary checkpoint buffer during the last checkpoint. + /// + long LastCheckpointCopiedOnWritePagesNumber { get; } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs index 9548aca..f61da06 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs @@ -26,6 +26,7 @@ namespace Apache.Ignite.Core using Apache.Ignite.Core.Cluster; using Apache.Ignite.Core.Common; using Apache.Ignite.Core.Compute; + using Apache.Ignite.Core.Configuration; using Apache.Ignite.Core.Datastream; using Apache.Ignite.Core.DataStructures; using Apache.Ignite.Core.Events; @@ -336,7 +337,10 @@ namespace Apache.Ignite.Core /// Gets a collection of memory metrics, one for each . /// /// Memory metrics should be enabled with . + /// + /// Obsolete, use . /// + [Obsolete("Use GetDataRegionMetrics.")] ICollection GetMemoryMetrics(); /// @@ -344,8 +348,11 @@ namespace Apache.Ignite.Core /// /// To get metrics for the default memory region, /// use . + /// + /// Obsolete, use . /// /// Name of the memory policy. + [Obsolete("Use GetDataRegionMetrics.")] IMemoryMetrics GetMemoryMetrics(string memoryPolicyName); /// @@ -367,6 +374,32 @@ namespace Apache.Ignite.Core /// To enable metrics set property /// in . /// + [Obsolete("Use GetDataStorageMetrics.")] IPersistentStoreMetrics GetPersistentStoreMetrics(); + + /// + /// Gets a collection of memory metrics, one for each + /// . + /// + /// Metrics should be enabled with . + /// + ICollection GetDataRegionMetrics(); + + /// + /// Gets the memory metrics for the specified data region. + /// + /// To get metrics for the default memory region, + /// use . + /// + /// Name of the data region. + IDataRegionMetrics GetDataRegionMetrics(string dataRegionName); + + /// + /// Gets the persistent store metrics. + /// + /// To enable metrics set property + /// in . + /// + IDataStorageMetrics GetDataStorageMetrics(); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/ab08be83/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs index b0fe0df..a6ff324 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs @@ -26,6 +26,7 @@ namespace Apache.Ignite.Core using System.Linq; using System.Text; using System.Xml; + using System.Xml.Serialization; using Apache.Ignite.Core.Binary; using Apache.Ignite.Core.Cache; using Apache.Ignite.Core.Cache.Configuration; @@ -439,6 +440,7 @@ namespace Apache.Ignite.Core memEventStorage.Write(writer); } +#pragma warning disable 618 // Obsolete if (MemoryConfiguration != null) { writer.WriteBoolean(true); @@ -448,6 +450,7 @@ namespace Apache.Ignite.Core { writer.WriteBoolean(false); } +#pragma warning restore 618 // SQL connector. #pragma warning disable 618 // Obsolete @@ -476,6 +479,7 @@ namespace Apache.Ignite.Core writer.WriteBoolean(ClientConnectorConfigurationEnabled); // Persistence. +#pragma warning disable 618 // Obsolete if (PersistentStoreConfiguration != null) { writer.WriteBoolean(true); @@ -485,6 +489,18 @@ namespace Apache.Ignite.Core { writer.WriteBoolean(false); } +#pragma warning restore 618 + + // Data storage. + if (DataStorageConfiguration != null) + { + writer.WriteBoolean(true); + DataStorageConfiguration.Write(writer); + } + else + { + writer.WriteBoolean(false); + } // Plugins (should be last). if (PluginConfigurations != null) @@ -675,7 +691,9 @@ namespace Apache.Ignite.Core if (r.ReadBoolean()) { +#pragma warning disable 618 // Obsolete MemoryConfiguration = new MemoryConfiguration(r); +#pragma warning restore 618 // Obsolete } // SQL. @@ -697,7 +715,15 @@ namespace Apache.Ignite.Core // Persistence. if (r.ReadBoolean()) { +#pragma warning disable 618 // Obsolete PersistentStoreConfiguration = new PersistentStoreConfiguration(r); +#pragma warning restore 618 + } + + // Data storage. + if (r.ReadBoolean()) + { + DataStorageConfiguration = new DataStorageConfiguration(r); } } @@ -793,6 +819,7 @@ namespace Apache.Ignite.Core /// This property is used to when there are multiple Ignite nodes in one process to distinguish them. /// [Obsolete("Use IgniteInstanceName instead.")] + [XmlIgnore] public string GridName { get { return IgniteInstanceName; } @@ -1243,10 +1270,18 @@ namespace Apache.Ignite.Core /// /// Gets or sets the page memory configuration. /// for more details. + /// + /// Obsolete, use . /// + [Obsolete("Use DataStorageConfiguration.")] public MemoryConfiguration MemoryConfiguration { get; set; } /// + /// Gets or sets the data storage configuration. + /// + public DataStorageConfiguration DataStorageConfiguration { get; set; } + + /// /// Gets or sets a value indicating how user assemblies should be loaded on remote nodes. /// /// For example, when executing , @@ -1374,14 +1409,17 @@ namespace Apache.Ignite.Core /// /// Gets or sets the persistent store configuration. + /// + /// Obsolete, use . /// + [Obsolete("Use DataStorageConfiguration.")] public PersistentStoreConfiguration PersistentStoreConfiguration { get; set; } /// /// Gets or sets a value indicating whether grid should be active on start. /// See also and . /// - /// This property is ignored when is present: + /// This property is ignored when is present: /// cluster is always inactive on start when Ignite Persistence is enabled. /// [DefaultValue(DefaultIsActiveOnStart)]