This is an automated email from the ASF dual-hosted git repository. amashenkov pushed a commit to branch gg-17462 in repository https://gitbox.apache.org/repos/asf/ignite.git
commit 7515a2901e6a8ecef46fc3694b19dee9544a61df Author: Alexandr Shapkin <[email protected]> AuthorDate: Thu Apr 25 13:06:03 2019 +0300 GG-17352I .NET: Add baseline auto-adjust parameters (definition, run-time change) Signed-off-by: Dmitriy Govorukhin <[email protected]> --- .../processors/platform/PlatformProcessorImpl.java | 30 ++++++++++++++++++ .../Cache/PersistenceTest.cs | 37 ++++++++++++++++++++++ .../dotnet/Apache.Ignite.Core/Cluster/ICluster.cs | 24 ++++++++++++++ .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 31 +++++++++++++++++- 4 files changed, 121 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java index 32f50d5..12c660f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java @@ -171,6 +171,18 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf /** */ private static final int OP_NODE_VERSION = 31; + /** */ + private static final int OP_IS_BASELINE_AUTO_ADJ_ENABLED = 32; + + /** */ + private static final int OP_SET_BASELINE_AUTO_ADJ_ENABLED = 33; + + /** */ + private static final int OP_GET_BASELINE_AUTO_ADJ_TIMEOUT = 34; + + /** */ + private static final int OP_SET_BASELINE_AUTO_ADJ_TIMEOUT = 35; + /** Start latch. */ private final CountDownLatch startLatch = new CountDownLatch(1); @@ -445,6 +457,12 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf return 0; } + + case OP_SET_BASELINE_AUTO_ADJ_TIMEOUT: { + ctx.grid().cluster().baselineAutoAdjustTimeout(val); + + return 0; + } } return PlatformAbstractTarget.throwUnsupported(type); @@ -505,6 +523,18 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf case OP_IS_WAL_ENABLED: return ctx.grid().cluster().isWalEnabled(reader.readString()) ? TRUE : FALSE; + + case OP_IS_BASELINE_AUTO_ADJ_ENABLED: + return ctx.grid().cluster().isBaselineAutoAdjustEnabled() ? TRUE : FALSE; + + case OP_SET_BASELINE_AUTO_ADJ_ENABLED: + boolean isEnabled = reader.readBoolean(); + ctx.grid().cluster().baselineAutoAdjustEnabled(isEnabled); + + return 0; + + case OP_GET_BASELINE_AUTO_ADJ_TIMEOUT: + return ctx.grid().cluster().baselineAutoAdjustTimeout(); } return PlatformAbstractTarget.throwUnsupported(type); diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs index 6afc3aa..c703596 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs @@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Tests.Cache using Apache.Ignite.Core.Cache.Affinity.Rendezvous; using Apache.Ignite.Core.Cache.Configuration; using Apache.Ignite.Core.Cache.Store; + using Apache.Ignite.Core.Cluster; using Apache.Ignite.Core.Common; using Apache.Ignite.Core.Configuration; using NUnit.Framework; @@ -323,6 +324,42 @@ namespace Apache.Ignite.Core.Tests.Cache } /// <summary> + /// Test the configuration of IsBaselineAutoAdjustEnabled flag + /// </summary> + [Test] + public void TestBaselineTopologyAutoAdjustEnabledDisabled() + { + using (var ignite = Ignition.Start(GetPersistentConfiguration())) + { + ICluster cluster = ignite.GetCluster(); + cluster.SetActive(true); + + bool isEnabled = cluster.IsBaselineAutoAdjustEnabled(); + cluster.SetBaselineAutoAdjustEnabledFlag(!isEnabled); + + Assert.AreNotEqual(isEnabled, cluster.IsBaselineAutoAdjustEnabled()); + } + } + + /// <summary> + /// Test the configuration of BaselineAutoAdjustTimeout property + /// </summary> + [Test] + public void TestBaselineTopologyAutoAdjustTimeoutWriteRead() + { + const long newTimeout = 333000; + using (var ignite = Ignition.Start(GetPersistentConfiguration())) + { + ICluster cluster = ignite.GetCluster(); + cluster.SetActive(true); + + cluster.SetBaselineAutoAdjustTimeout(newTimeout); + + Assert.AreEqual(newTimeout, cluster.GetBaselineAutoAdjustTimeout()); + } + } + + /// <summary> /// Checks active state. /// </summary> private static void CheckIsActive(IIgnite ignite, bool isActive) diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs index ae1de71..84ed03d 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs @@ -160,5 +160,29 @@ namespace Apache.Ignite.Core.Cluster /// </summary> /// <param name="timeout"></param> void SetTxTimeoutOnPartitionMapExchange(TimeSpan timeout); + + /// <summary> + /// Returns value of manual baseline control or auto adjusting baseline. + /// </summary> + /// <returns><c>true</c> If cluster in auto-adjust. <c>false</c> If cluster in manual.</returns> + bool IsBaselineAutoAdjustEnabled(); + + /// <summary> + /// Sets the value of manual baseline control or auto adjusting baseline. + /// </summary> + /// <param name="isBaselineAutoAdjustEnabled"><c>true</c> If cluster in auto-adjust. <c>false</c> If cluster in manual.</param> + void SetBaselineAutoAdjustEnabledFlag(bool isBaselineAutoAdjustEnabled); + + /// <summary> + /// Gets the value of time which we would wait before the actual topology change since last server topology change(node join/left/fail). + /// </summary> + /// <returns>Timeout value</returns> + long GetBaselineAutoAdjustTimeout(); + + /// <summary> + /// Sets the value of time which we would wait before the actual topology change since last server topology change(node join/left/fail). + /// </summary> + /// <param name="baselineAutoAdjustTimeout">Timeout value</param> + void SetBaselineAutoAdjustTimeout(long baselineAutoAdjustTimeout); } } diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs index 03bc69f..e0f31f6 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs @@ -92,7 +92,11 @@ namespace Apache.Ignite.Core.Impl EnableWal = 28, IsWalEnabled = 29, SetTxTimeoutOnPartitionMapExchange = 30, - GetNodeVersion = 31 + GetNodeVersion = 31, + IsBaselineAutoAdjustmentEnabled = 32, + SetBaselineAutoAdjustmentEnabled = 33, + GetBaselineAutoAdjustTimeout = 34, + SetBaselineAutoAdjustTimeout = 35 } /** */ @@ -845,6 +849,7 @@ namespace Apache.Ignite.Core.Impl return DoOutOp((int) Op.IsWalEnabled, w => w.WriteString(cacheName)) == True; } + /** <inheritdoc /> */ public void SetTxTimeoutOnPartitionMapExchange(TimeSpan timeout) { DoOutOp((int) Op.SetTxTimeoutOnPartitionMapExchange, @@ -852,6 +857,30 @@ namespace Apache.Ignite.Core.Impl } /** <inheritdoc /> */ + public bool IsBaselineAutoAdjustEnabled() + { + return DoOutOp((int) Op.IsBaselineAutoAdjustmentEnabled, s => s.ReadBool()) == True; + } + + /** <inheritdoc /> */ + public void SetBaselineAutoAdjustEnabledFlag(bool isBaselineAutoAdjustEnabled) + { + DoOutOp((int) Op.SetBaselineAutoAdjustmentEnabled, w => w.WriteBoolean(isBaselineAutoAdjustEnabled)); + } + + /** <inheritdoc /> */ + public long GetBaselineAutoAdjustTimeout() + { + return DoOutOp((int) Op.GetBaselineAutoAdjustTimeout, s => s.ReadLong()); + } + + /** <inheritdoc /> */ + public void SetBaselineAutoAdjustTimeout(long baselineAutoAdjustTimeout) + { + DoOutInOp((int) Op.SetBaselineAutoAdjustTimeout, baselineAutoAdjustTimeout); + } + + /** <inheritdoc /> */ #pragma warning disable 618 public IPersistentStoreMetrics GetPersistentStoreMetrics() {
