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/master Commit: 341f12fb25b16206a82de32a96b900163cf4f043 Parents: 424cf89 Author: Pavel Tupitsyn <[email protected]> Authored: Mon May 16 11:47:39 2016 +0300 Committer: vozerov-gridgain <[email protected]> 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 @@ <Content Include="Config\Lifecycle\lifecycle-no-beans.xml"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> + <Content Include="Config\spring-test.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> <Content Include="Config\marshaller-default.xml"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> + <property name="localHost" value="127.0.0.1"/> + <property name="connectorConfiguration"><null/></property> + <property name="networkSendRetryDelay" value="765"/> + <property name="networkTimeout" value="2999" /> + + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> + <property name="addresses"> + <list> + <!-- In distributed environment, replace with actual host IP address. --> + <value>127.0.0.1:47500</value> + </list> + </property> + </bean> + </property> + <property name="socketTimeout" value="300" /> + </bean> + </property> + </bean> +</beans> 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 = @"<igniteConfig workDirectory='c:' JvmMaxMemoryMb='1024' MetricsLogFrequency='0:0:10' isDaemon='true' isLateAffinityAssignment='false'> + var xml = @"<igniteConfig workDirectory='c:' JvmMaxMemoryMb='1024' MetricsLogFrequency='0:0:10' isDaemon='true' isLateAffinityAssignment='false' springConfigUrl='c:\myconfig.xml'> <localhost>127.1.1.1</localhost> <binaryConfiguration compactFooter='false'> <defaultNameMapper type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+NameMapper, Apache.Ignite.Core.Tests' bar='testBar' /> @@ -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 @@ <Compile Include="Common\IgniteFutureCancelledException.cs" /> <Compile Include="Common\IgniteGuid.cs" /> <Compile Include="Common\Package-Info.cs" /> + <Compile Include="Impl\Binary\BinaryWriterExtensions.cs" /> <Compile Include="Impl\Common\Platform.cs" /> <Compile Include="Impl\Cache\Event\JavaCacheEntryEventFilter.cs" /> <Compile Include="Impl\Common\PlatformJavaObjectFactoryProxy.cs" /> 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 @@ /// </summary> 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; + /// <summary> /// Default network retry count. /// </summary> @@ -105,15 +134,6 @@ { JvmInitialMemoryMb = DefaultJvmInitMem; JvmMaxMemoryMb = DefaultJvmMaxMem; - - MetricsExpireTime = DefaultMetricsExpireTime; - MetricsHistorySize = DefaultMetricsHistorySize; - MetricsLogFrequency = DefaultMetricsLogFrequency; - MetricsUpdateFrequency = DefaultMetricsUpdateFrequency; - NetworkTimeout = DefaultNetworkTimeout; - NetworkSendRetryCount = DefaultNetworkSendRetryCount; - NetworkSendRetryDelay = DefaultNetworkSendRetryDelay; - IsLateAffinityAssignment = DefaultIsLateAffinityAssignment; } /// <summary> @@ -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); - } - - /// <summary> - /// Writes this instance to a writer. - /// </summary> - /// <param name="writer">The writer.</param> - private void WriteCore(BinaryWriter writer) - { // Simple properties - writer.WriteBoolean(ClientMode); + writer.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 @@ /// <summary> /// URL to Spring configuration file. /// <para /> - /// Ignite.NET can be configured natively without Spring. - /// Setting this property will ignore all other properties except <see cref="IgniteHome"/>, - /// <see cref="Assemblies"/>, <see cref="SuppressWarnings"/>, <see cref="LifecycleBeans"/>, - /// <see cref="JvmOptions"/>, <see cref="JvmDllPath"/>, <see cref="IgniteHome"/>, - /// <see cref="JvmInitialMemoryMb"/>, <see cref="JvmMaxMemoryMb"/>. + /// Spring configuration is loaded first, then <see cref="IgniteConfiguration"/> 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. + /// <para /> + /// 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. /// </summary> [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. /// </summary> - public bool ClientMode { get; set; } + public bool ClientMode + { + get { return _clientMode ?? default(bool); } + set { _clientMode = value; } + } /// <summary> /// Gets or sets a set of event types (<see cref="EventType" />) to be recorded by Ignite. @@ -521,20 +526,32 @@ /// Gets or sets the time after which a certain metric value is considered expired. /// </summary> [DefaultValue(typeof(TimeSpan), "10675199.02:48:05.4775807")] - public TimeSpan MetricsExpireTime { get; set; } + public TimeSpan MetricsExpireTime + { + get { return _metricsExpireTime ?? DefaultMetricsExpireTime; } + set { _metricsExpireTime = value; } + } /// <summary> /// Gets or sets the number of metrics kept in history to compute totals and averages. /// </summary> [DefaultValue(DefaultMetricsHistorySize)] - public int MetricsHistorySize { get; set; } + public int MetricsHistorySize + { + get { return _metricsHistorySize ?? DefaultMetricsHistorySize; } + set { _metricsHistorySize = value; } + } /// <summary> /// Gets or sets the frequency of metrics log print out. /// <see cref="TimeSpan.Zero"/> to disable metrics print out. /// </summary> [DefaultValue(typeof(TimeSpan), "00:01:00")] - public TimeSpan MetricsLogFrequency { get; set; } + public TimeSpan MetricsLogFrequency + { + get { return _metricsLogFrequency ?? DefaultMetricsLogFrequency; } + set { _metricsLogFrequency = value; } + } /// <summary> /// Gets or sets the job metrics update frequency. @@ -542,25 +559,41 @@ /// Negative value to never update metrics. /// </summary> [DefaultValue(typeof(TimeSpan), "00:00:02")] - public TimeSpan MetricsUpdateFrequency { get; set; } + public TimeSpan MetricsUpdateFrequency + { + get { return _metricsUpdateFrequency ?? DefaultMetricsUpdateFrequency; } + set { _metricsUpdateFrequency = value; } + } /// <summary> /// Gets or sets the network send retry count. /// </summary> [DefaultValue(DefaultNetworkSendRetryCount)] - public int NetworkSendRetryCount { get; set; } + public int NetworkSendRetryCount + { + get { return _networkSendRetryCount ?? DefaultNetworkSendRetryCount; } + set { _networkSendRetryCount = value; } + } /// <summary> /// Gets or sets the network send retry delay. /// </summary> [DefaultValue(typeof(TimeSpan), "00:00:01")] - public TimeSpan NetworkSendRetryDelay { get; set; } + public TimeSpan NetworkSendRetryDelay + { + get { return _networkSendRetryDelay ?? DefaultNetworkSendRetryDelay; } + set { _networkSendRetryDelay = value; } + } /// <summary> /// Gets or sets the network timeout. /// </summary> [DefaultValue(typeof(TimeSpan), "00:00:05")] - public TimeSpan NetworkTimeout { get; set; } + public TimeSpan NetworkTimeout + { + get { return _networkTimeout ?? DefaultNetworkTimeout; } + set { _networkTimeout = value; } + } /// <summary> /// 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. /// </summary> - public bool IsDaemon { get; set; } + public bool IsDaemon + { + get { return _isDaemon ?? default(bool); } + set { _isDaemon = value; } + } /// <summary> /// Gets or sets the user attributes for this node. @@ -634,6 +671,10 @@ /// If not provided, default value is <see cref="DefaultIsLateAffinityAssignment"/>. /// </summary> [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); } + + /// <summary> + /// Reads the nullable TimeSpan. + /// </summary> + public static TimeSpan? ReadTimeSpanNullable(this IBinaryRawReader reader) + { + return reader.ReadBoolean() ? reader.ReadLongAsTimespan() : (TimeSpan?) null; + } + + /// <summary> + /// Reads the nullable int. + /// </summary> + public static int? ReadIntNullable(this IBinaryRawReader reader) + { + return reader.ReadBoolean() ? reader.ReadInt() : (int?) null; + } + + /// <summary> + /// Reads the nullable bool. + /// </summary> + 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; + + /// <summary> + /// Writer extensions. + /// </summary> + internal static class BinaryWriterExtensions + { + /// <summary> + /// Writes the nullable boolean. + /// </summary> + public static void WriteBooleanNullable(this BinaryWriter writer, bool? value) + { + if (value != null) + { + writer.WriteBoolean(true); + writer.WriteBoolean(value.Value); + } + else + writer.WriteBoolean(false); + } + + /// <summary> + /// Writes the nullable boolean. + /// </summary> + public static void WriteIntNullable(this BinaryWriter writer, int? value) + { + if (value != null) + { + writer.WriteBoolean(true); + writer.WriteInt(value.Value); + } + else + writer.WriteBoolean(false); + } + + /// <summary> + /// Writes the timespan. + /// </summary> + public static void WriteTimeSpanAsLong(this BinaryWriter writer, TimeSpan value) + { + writer.WriteLong((long) value.TotalMilliseconds); + } + + /// <summary> + /// Writes the nullable boolean. + /// </summary> + 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;
