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 938F02009C6 for ; Mon, 16 May 2016 16:43:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 925EE160A19; Mon, 16 May 2016 14:43:00 +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 D47C3160A20 for ; Mon, 16 May 2016 16:42:58 +0200 (CEST) Received: (qmail 21110 invoked by uid 500); 16 May 2016 14:42:58 -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 21032 invoked by uid 99); 16 May 2016 14:42:58 -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; Mon, 16 May 2016 14:42:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C6A4EDFFA9; Mon, 16 May 2016 14:42:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dmagda@apache.org To: commits@ignite.apache.org Date: Mon, 16 May 2016 14:43:01 -0000 Message-Id: In-Reply-To: <84e312c5d256476ea504205a54f33432@git.apache.org> References: <84e312c5d256476ea504205a54f33432@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [05/21] ignite git commit: IGNITE-3112: .NET: Now top-level configuration could be merged with Spring beans. This closes #706. archived-at: Mon, 16 May 2016 14:43:00 -0000 IGNITE-3112: .NET: Now top-level configuration could be merged with Spring beans. This closes #706. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/341f12fb Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/341f12fb Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/341f12fb Branch: refs/heads/ignite-3098 Commit: 341f12fb25b16206a82de32a96b900163cf4f043 Parents: 424cf89 Author: Pavel Tupitsyn Authored: Mon May 16 11:47:39 2016 +0300 Committer: vozerov-gridgain Committed: Mon May 16 11:47:39 2016 +0300 ---------------------------------------------------------------------- .../utils/PlatformConfigurationUtils.java | 49 +++--- .../Apache.Ignite.Core.Tests.csproj | 3 + .../Binary/BinaryCompactFooterInteropTest.cs | 1 - .../Continuous/ContinuousQueryJavaFilterTest.cs | 1 - .../Cache/Store/CacheStoreTest.cs | 1 - .../Compute/ComputeApiTest.cs | 1 - .../Compute/MixedClusterTest.cs | 1 - .../Config/spring-test.xml | 46 +++++ .../Apache.Ignite.Core.Tests/DeploymentTest.cs | 1 - .../Apache.Ignite.Core.Tests/ExecutableTest.cs | 1 - .../IgniteConfigurationSerializerTest.cs | 3 +- .../IgniteConfigurationTest.cs | 20 ++- .../IgniteStartStopTest.cs | 1 - .../Apache.Ignite.Core.Tests/ReconnectTest.cs | 1 - .../Services/ServicesTest.cs | 1 - .../Apache.Ignite.Core.csproj | 1 + .../Apache.Ignite.Core/IgniteConfiguration.cs | 173 ++++++++++++------- .../dotnet/Apache.Ignite.Core/Ignition.cs | 1 - .../Impl/Binary/BinaryReaderExtensions.cs | 24 +++ .../Impl/Binary/BinaryWriterExtensions.cs | 78 +++++++++ .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 1 - 21 files changed, 298 insertions(+), 111 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/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 e462d40..a7b1b17 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 @@ -351,22 +351,19 @@ public class PlatformConfigurationUtils { * @param cfg Configuration. */ public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfiguration cfg) { - if (!in.readBoolean()) - return; // there is no config - - cfg.setClientMode(in.readBoolean()); - cfg.setIncludeEventTypes(in.readIntArray()); - cfg.setMetricsExpireTime(in.readLong()); - cfg.setMetricsHistorySize(in.readInt()); - cfg.setMetricsLogFrequency(in.readLong()); - cfg.setMetricsUpdateFrequency(in.readLong()); - cfg.setNetworkSendRetryCount(in.readInt()); - cfg.setNetworkSendRetryDelay(in.readLong()); - cfg.setNetworkTimeout(in.readLong()); - cfg.setWorkDirectory(in.readString()); - cfg.setLocalHost(in.readString()); - cfg.setDaemon(in.readBoolean()); - cfg.setLateAffinityAssignment(in.readBoolean()); + if (in.readBoolean()) cfg.setClientMode(in.readBoolean()); + int[] eventTypes = in.readIntArray(); if (eventTypes != null) cfg.setIncludeEventTypes(eventTypes); + if (in.readBoolean()) cfg.setMetricsExpireTime(in.readLong()); + if (in.readBoolean()) cfg.setMetricsHistorySize(in.readInt()); + if (in.readBoolean()) cfg.setMetricsLogFrequency(in.readLong()); + if (in.readBoolean()) cfg.setMetricsUpdateFrequency(in.readLong()); + if (in.readBoolean()) cfg.setNetworkSendRetryCount(in.readInt()); + if (in.readBoolean()) cfg.setNetworkSendRetryDelay(in.readLong()); + if (in.readBoolean()) cfg.setNetworkTimeout(in.readLong()); + String workDir = in.readString(); if (workDir != null) cfg.setWorkDirectory(workDir); + String localHost = in.readString(); if (localHost != null) cfg.setLocalHost(localHost); + if (in.readBoolean()) cfg.setDaemon(in.readBoolean()); + if (in.readBoolean()) cfg.setLateAffinityAssignment(in.readBoolean()); readCacheConfigurations(in, cfg); readDiscoveryConfiguration(in, cfg); @@ -721,19 +718,19 @@ public class PlatformConfigurationUtils { assert w != null; assert cfg != null; - w.writeBoolean(cfg.isClientMode()); + w.writeBoolean(true); w.writeBoolean(cfg.isClientMode()); w.writeIntArray(cfg.getIncludeEventTypes()); - w.writeLong(cfg.getMetricsExpireTime()); - w.writeInt(cfg.getMetricsHistorySize()); - w.writeLong(cfg.getMetricsLogFrequency()); - w.writeLong(cfg.getMetricsUpdateFrequency()); - w.writeInt(cfg.getNetworkSendRetryCount()); - w.writeLong(cfg.getNetworkSendRetryDelay()); - w.writeLong(cfg.getNetworkTimeout()); + w.writeBoolean(true); w.writeLong(cfg.getMetricsExpireTime()); + w.writeBoolean(true); w.writeInt(cfg.getMetricsHistorySize()); + w.writeBoolean(true); w.writeLong(cfg.getMetricsLogFrequency()); + w.writeBoolean(true); w.writeLong(cfg.getMetricsUpdateFrequency()); + w.writeBoolean(true); w.writeInt(cfg.getNetworkSendRetryCount()); + w.writeBoolean(true); w.writeLong(cfg.getNetworkSendRetryDelay()); + w.writeBoolean(true); w.writeLong(cfg.getNetworkTimeout()); w.writeString(cfg.getWorkDirectory()); w.writeString(cfg.getLocalHost()); - w.writeBoolean(cfg.isDaemon()); - w.writeBoolean(cfg.isLateAffinityAssignment()); + w.writeBoolean(true); w.writeBoolean(cfg.isDaemon()); + w.writeBoolean(true); w.writeBoolean(cfg.isLateAffinityAssignment()); CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration(); http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj index ef774af..b937d28 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj @@ -230,6 +230,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs index b01b65e..27b97fd 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs @@ -15,7 +15,6 @@ * limitations under the License. */ -#pragma warning disable 618 // SpringConfigUrl namespace Apache.Ignite.Core.Tests.Binary { using System.Collections; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs index 76be0fd..de829e2 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs @@ -16,7 +16,6 @@ */ // ReSharper disable UnusedAutoPropertyAccessor.Local -#pragma warning disable 618 // SpringConfigUrl namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous { using System; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs index 76ec384..d6a7f60 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs @@ -15,7 +15,6 @@ * limitations under the License. */ -#pragma warning disable 618 namespace Apache.Ignite.Core.Tests.Cache.Store { using System; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs index 45fb4b4..2c5b31e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs @@ -17,7 +17,6 @@ // ReSharper disable SpecifyACultureInStringConversionExplicitly // ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable 618 // SpringConfigUrl namespace Apache.Ignite.Core.Tests.Compute { using System; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs index 0688440..ab4e6ab 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs @@ -15,7 +15,6 @@ * limitations under the License. */ -#pragma warning disable 618 // SpringConfigUrl namespace Apache.Ignite.Core.Tests.Compute { using System; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/spring-test.xml ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/spring-test.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/spring-test.xml new file mode 100644 index 0000000..2bf7478 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/spring-test.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + 127.0.0.1:47500 + + + + + + + + + http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs index bc764c7..cd23724 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs @@ -17,7 +17,6 @@ #pragma warning disable 649 #pragma warning disable 169 -#pragma warning disable 618 namespace Apache.Ignite.Core.Tests { using System; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs index 9e6de05..299c987 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs @@ -18,7 +18,6 @@ // ReSharper disable UnusedVariable // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnusedAutoPropertyAccessor.Local -//#pragma warning disable 618 namespace Apache.Ignite.Core.Tests { using System; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/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 62690c3..b6ee5cb 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs @@ -56,7 +56,7 @@ namespace Apache.Ignite.Core.Tests [Test] public void TestPredefinedXml() { - var xml = @" + var xml = @" 127.1.1.1 @@ -130,6 +130,7 @@ namespace Apache.Ignite.Core.Tests cfg.BinaryConfiguration.Types.Single()); Assert.IsFalse(cfg.BinaryConfiguration.CompactFooter); Assert.AreEqual(new[] {42, EventType.TaskFailed, EventType.JobFinished}, cfg.IncludedEventTypes); + Assert.AreEqual(@"c:\myconfig.xml", cfg.SpringConfigUrl); Assert.AreEqual("secondCache", cfg.CacheConfiguration.Last().Name); http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/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 9657c9b..9d11ad3 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs @@ -15,7 +15,6 @@ * limitations under the License. */ -#pragma warning disable 618 // deprecated SpringConfigUrl namespace Apache.Ignite.Core.Tests { using System; @@ -168,16 +167,25 @@ namespace Apache.Ignite.Core.Tests [Test] public void TestSpringXml() { - // When Spring XML is used, all properties are ignored. - var cfg = GetCustomConfig(); - - cfg.SpringConfigUrl = "config\\marshaller-default.xml"; + // When Spring XML is used, .NET overrides Spring. + var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) + { + SpringConfigUrl = @"config\spring-test.xml", + NetworkSendRetryDelay = TimeSpan.FromSeconds(45), + MetricsHistorySize = 57 + }; using (var ignite = Ignition.Start(cfg)) { var resCfg = ignite.GetConfiguration(); - CheckDefaultProperties(resCfg); + Assert.AreEqual(45, resCfg.NetworkSendRetryDelay.TotalSeconds); // .NET overrides XML + Assert.AreEqual(2999, resCfg.NetworkTimeout.TotalMilliseconds); // Not set in .NET -> comes from XML + Assert.AreEqual(57, resCfg.MetricsHistorySize); // Only set in .NET + + var disco = resCfg.DiscoverySpi as TcpDiscoverySpi; + Assert.IsNotNull(disco); + Assert.AreEqual(TimeSpan.FromMilliseconds(300), disco.SocketTimeout); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs index 447c8b9..47212fc 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs @@ -15,7 +15,6 @@ * limitations under the License. */ -#pragma warning disable 618 // Deprecated SpringConfigUrl namespace Apache.Ignite.Core.Tests { using System; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs index 7803110..2f8b205 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs @@ -15,7 +15,6 @@ * limitations under the License. */ -#pragma warning disable 618 // Deprecated SpringConfigUrl namespace Apache.Ignite.Core.Tests { using Apache.Ignite.Core.Cache; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs index b06d6dd..3269651 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs @@ -15,7 +15,6 @@ * limitations under the License. */ -#pragma warning disable 618 // SpringConfigUrl namespace Apache.Ignite.Core.Tests.Services { using System; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/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 8943030..649de2e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj @@ -152,6 +152,7 @@ + http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/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 62cad19..a505cca 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs @@ -15,7 +15,6 @@ * limitations under the License. */ -#pragma warning disable 618 // deprecated SpringConfigUrl namespace Apache.Ignite.Core { using System; @@ -88,6 +87,36 @@ /// public static readonly TimeSpan DefaultNetworkSendRetryDelay = TimeSpan.FromMilliseconds(1000); + /** */ + private TimeSpan? _metricsExpireTime; + + /** */ + private int? _metricsHistorySize; + + /** */ + private TimeSpan? _metricsLogFrequency; + + /** */ + private TimeSpan? _metricsUpdateFrequency; + + /** */ + private int? _networkSendRetryCount; + + /** */ + private TimeSpan? _networkSendRetryDelay; + + /** */ + private TimeSpan? _networkTimeout; + + /** */ + private bool? _isDaemon; + + /** */ + private bool? _isLateAffinityAssignment; + + /** */ + private bool? _clientMode; + /// /// Default network retry count. /// @@ -105,15 +134,6 @@ { JvmInitialMemoryMb = DefaultJvmInitMem; JvmMaxMemoryMb = DefaultJvmMaxMem; - - MetricsExpireTime = DefaultMetricsExpireTime; - MetricsHistorySize = DefaultMetricsHistorySize; - MetricsLogFrequency = DefaultMetricsLogFrequency; - MetricsUpdateFrequency = DefaultMetricsUpdateFrequency; - NetworkTimeout = DefaultNetworkTimeout; - NetworkSendRetryCount = DefaultNetworkSendRetryCount; - NetworkSendRetryDelay = DefaultNetworkSendRetryDelay; - IsLateAffinityAssignment = DefaultIsLateAffinityAssignment; } /// @@ -130,7 +150,7 @@ { var marsh = new Marshaller(configuration.BinaryConfiguration); - configuration.WriteCore(marsh.StartMarshal(stream)); + configuration.Write(marsh.StartMarshal(stream)); stream.SynchronizeOutput(); @@ -157,40 +177,21 @@ { Debug.Assert(writer != null); - if (!string.IsNullOrEmpty(SpringConfigUrl)) - { - // Do not write details when there is Spring config. - writer.WriteBoolean(false); - return; - } - - writer.WriteBoolean(true); // details are present - - WriteCore(writer); - } - - /// - /// Writes this instance to a writer. - /// - /// The writer. - private void WriteCore(BinaryWriter writer) - { // Simple properties - writer.WriteBoolean(ClientMode); + writer.WriteBooleanNullable(_clientMode); writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray()); - writer.WriteLong((long) MetricsExpireTime.TotalMilliseconds); - writer.WriteInt(MetricsHistorySize); - writer.WriteLong((long) MetricsLogFrequency.TotalMilliseconds); - var metricsUpdateFreq = (long) MetricsUpdateFrequency.TotalMilliseconds; - writer.WriteLong(metricsUpdateFreq >= 0 ? metricsUpdateFreq : -1); - writer.WriteInt(NetworkSendRetryCount); - writer.WriteLong((long) NetworkSendRetryDelay.TotalMilliseconds); - writer.WriteLong((long) NetworkTimeout.TotalMilliseconds); + writer.WriteTimeSpanAsLongNullable(_metricsExpireTime); + writer.WriteIntNullable(_metricsHistorySize); + writer.WriteTimeSpanAsLongNullable(_metricsLogFrequency); + writer.WriteTimeSpanAsLongNullable(_metricsUpdateFrequency); + writer.WriteIntNullable(_networkSendRetryCount); + writer.WriteTimeSpanAsLongNullable(_networkSendRetryDelay); + writer.WriteTimeSpanAsLongNullable(_networkTimeout); writer.WriteString(WorkDirectory); writer.WriteString(Localhost); - writer.WriteBoolean(IsDaemon); - writer.WriteBoolean(IsLateAffinityAssignment); + writer.WriteBooleanNullable(_isDaemon); + writer.WriteBooleanNullable(_isLateAffinityAssignment); // Cache config var caches = CacheConfiguration; @@ -297,20 +298,19 @@ private void ReadCore(BinaryReader r) { // Simple properties - ClientMode = r.ReadBoolean(); + _clientMode = r.ReadBooleanNullable(); IncludedEventTypes = r.ReadIntArray(); - - MetricsExpireTime = r.ReadLongAsTimespan(); - MetricsHistorySize = r.ReadInt(); - MetricsLogFrequency = r.ReadLongAsTimespan(); - MetricsUpdateFrequency = r.ReadLongAsTimespan(); - NetworkSendRetryCount = r.ReadInt(); - NetworkSendRetryDelay = r.ReadLongAsTimespan(); - NetworkTimeout = r.ReadLongAsTimespan(); + _metricsExpireTime = r.ReadTimeSpanNullable(); + _metricsHistorySize = r.ReadIntNullable(); + _metricsLogFrequency = r.ReadTimeSpanNullable(); + _metricsUpdateFrequency = r.ReadTimeSpanNullable(); + _networkSendRetryCount = r.ReadIntNullable(); + _networkSendRetryDelay = r.ReadTimeSpanNullable(); + _networkTimeout = r.ReadTimeSpanNullable(); WorkDirectory = r.ReadString(); Localhost = r.ReadString(); - IsDaemon = r.ReadBoolean(); - IsLateAffinityAssignment = r.ReadBoolean(); + _isDaemon = r.ReadBooleanNullable(); + _isLateAffinityAssignment = r.ReadBooleanNullable(); // Cache config var cacheCfgCount = r.ReadInt(); @@ -425,11 +425,12 @@ /// /// URL to Spring configuration file. /// - /// Ignite.NET can be configured natively without Spring. - /// Setting this property will ignore all other properties except , - /// , , , - /// , , , - /// , . + /// Spring configuration is loaded first, then properties are applied. + /// Null property values do not override Spring values. + /// Value-typed properties are tracked internally: if setter was not called, Spring value won't be overwritten. + /// + /// This merging happens on the top level only; e. g. if there are cache configurations defined in Spring + /// and in .NET, .NET caches will overwrite Spring caches. /// [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] public string SpringConfigUrl { get; set; } @@ -509,7 +510,11 @@ /// Gets or sets a value indicating whether node should start in client mode. /// Client node cannot hold data in the caches. /// - public bool ClientMode { get; set; } + public bool ClientMode + { + get { return _clientMode ?? default(bool); } + set { _clientMode = value; } + } /// /// Gets or sets a set of event types () to be recorded by Ignite. @@ -521,20 +526,32 @@ /// Gets or sets the time after which a certain metric value is considered expired. /// [DefaultValue(typeof(TimeSpan), "10675199.02:48:05.4775807")] - public TimeSpan MetricsExpireTime { get; set; } + public TimeSpan MetricsExpireTime + { + get { return _metricsExpireTime ?? DefaultMetricsExpireTime; } + set { _metricsExpireTime = value; } + } /// /// Gets or sets the number of metrics kept in history to compute totals and averages. /// [DefaultValue(DefaultMetricsHistorySize)] - public int MetricsHistorySize { get; set; } + public int MetricsHistorySize + { + get { return _metricsHistorySize ?? DefaultMetricsHistorySize; } + set { _metricsHistorySize = value; } + } /// /// Gets or sets the frequency of metrics log print out. /// to disable metrics print out. /// [DefaultValue(typeof(TimeSpan), "00:01:00")] - public TimeSpan MetricsLogFrequency { get; set; } + public TimeSpan MetricsLogFrequency + { + get { return _metricsLogFrequency ?? DefaultMetricsLogFrequency; } + set { _metricsLogFrequency = value; } + } /// /// Gets or sets the job metrics update frequency. @@ -542,25 +559,41 @@ /// Negative value to never update metrics. /// [DefaultValue(typeof(TimeSpan), "00:00:02")] - public TimeSpan MetricsUpdateFrequency { get; set; } + public TimeSpan MetricsUpdateFrequency + { + get { return _metricsUpdateFrequency ?? DefaultMetricsUpdateFrequency; } + set { _metricsUpdateFrequency = value; } + } /// /// Gets or sets the network send retry count. /// [DefaultValue(DefaultNetworkSendRetryCount)] - public int NetworkSendRetryCount { get; set; } + public int NetworkSendRetryCount + { + get { return _networkSendRetryCount ?? DefaultNetworkSendRetryCount; } + set { _networkSendRetryCount = value; } + } /// /// Gets or sets the network send retry delay. /// [DefaultValue(typeof(TimeSpan), "00:00:01")] - public TimeSpan NetworkSendRetryDelay { get; set; } + public TimeSpan NetworkSendRetryDelay + { + get { return _networkSendRetryDelay ?? DefaultNetworkSendRetryDelay; } + set { _networkSendRetryDelay = value; } + } /// /// Gets or sets the network timeout. /// [DefaultValue(typeof(TimeSpan), "00:00:05")] - public TimeSpan NetworkTimeout { get; set; } + public TimeSpan NetworkTimeout + { + get { return _networkTimeout ?? DefaultNetworkTimeout; } + set { _networkTimeout = value; } + } /// /// Gets or sets the work directory. @@ -589,7 +622,11 @@ /// and needs to participate in the topology, but also needs to be excluded from the "normal" topology, /// so that it won't participate in the task execution or in-memory data grid storage. /// - public bool IsDaemon { get; set; } + public bool IsDaemon + { + get { return _isDaemon ?? default(bool); } + set { _isDaemon = value; } + } /// /// Gets or sets the user attributes for this node. @@ -634,6 +671,10 @@ /// If not provided, default value is . /// [DefaultValue(DefaultIsLateAffinityAssignment)] - public bool IsLateAffinityAssignment { get; set; } + public bool IsLateAffinityAssignment + { + get { return _isLateAffinityAssignment ?? DefaultIsLateAffinityAssignment; } + set { _isLateAffinityAssignment = value; } + } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs index 94dab88..c551735 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs @@ -15,7 +15,6 @@ * limitations under the License. */ -#pragma warning disable 618 // deprecated SpringConfigUrl namespace Apache.Ignite.Core { using System; http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs index f3f8457..87de0eb 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs @@ -67,5 +67,29 @@ namespace Apache.Ignite.Core.Impl.Binary return TimeSpan.FromMilliseconds(ms); } + + /// + /// Reads the nullable TimeSpan. + /// + public static TimeSpan? ReadTimeSpanNullable(this IBinaryRawReader reader) + { + return reader.ReadBoolean() ? reader.ReadLongAsTimespan() : (TimeSpan?) null; + } + + /// + /// Reads the nullable int. + /// + public static int? ReadIntNullable(this IBinaryRawReader reader) + { + return reader.ReadBoolean() ? reader.ReadInt() : (int?) null; + } + + /// + /// Reads the nullable bool. + /// + public static bool? ReadBooleanNullable(this IBinaryRawReader reader) + { + return reader.ReadBoolean() ? reader.ReadBoolean() : (bool?) null; + } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs new file mode 100644 index 0000000..b13a9ea --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Impl.Binary +{ + using System; + + /// + /// Writer extensions. + /// + internal static class BinaryWriterExtensions + { + /// + /// Writes the nullable boolean. + /// + public static void WriteBooleanNullable(this BinaryWriter writer, bool? value) + { + if (value != null) + { + writer.WriteBoolean(true); + writer.WriteBoolean(value.Value); + } + else + writer.WriteBoolean(false); + } + + /// + /// Writes the nullable boolean. + /// + public static void WriteIntNullable(this BinaryWriter writer, int? value) + { + if (value != null) + { + writer.WriteBoolean(true); + writer.WriteInt(value.Value); + } + else + writer.WriteBoolean(false); + } + + /// + /// Writes the timespan. + /// + public static void WriteTimeSpanAsLong(this BinaryWriter writer, TimeSpan value) + { + writer.WriteLong((long) value.TotalMilliseconds); + } + + /// + /// Writes the nullable boolean. + /// + public static void WriteTimeSpanAsLongNullable(this BinaryWriter writer, TimeSpan? value) + { + if (value != null) + { + writer.WriteBoolean(true); + writer.WriteTimeSpanAsLong(value.Value); + } + else + writer.WriteBoolean(false); + } + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs index d64f52c..0706966 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs @@ -15,7 +15,6 @@ * limitations under the License. */ -#pragma warning disable 618 // SpringConfigUrl namespace Apache.Ignite.Core.Impl { using System;