Repository: ignite
Updated Branches:
  refs/heads/master 6bb6b3e51 -> 82554dd76


IGNITE-7493 .NET: WAL management API added


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

Branch: refs/heads/master
Commit: 82554dd766fc6de77331e533be6d0b7040d2c90a
Parents: 6bb6b3e
Author: Pavel Tupitsyn <[email protected]>
Authored: Tue Jan 23 14:24:37 2018 +0300
Committer: Pavel Tupitsyn <[email protected]>
Committed: Tue Jan 23 14:24:37 2018 +0300

----------------------------------------------------------------------
 .../platform/PlatformProcessorImpl.java         | 27 +++++++++++++-
 .../Cache/PersistenceTest.cs                    | 37 ++++++++++++++++++++
 .../Apache.Ignite.Core/Cluster/ICluster.cs      | 34 ++++++++++++++++++
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    | 29 ++++++++++++++-
 4 files changed, 125 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/82554dd7/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
----------------------------------------------------------------------
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 de51b3d..87ec97c 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
@@ -69,6 +69,9 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import static 
org.apache.ignite.internal.processors.platform.PlatformAbstractTarget.FALSE;
+import static 
org.apache.ignite.internal.processors.platform.PlatformAbstractTarget.TRUE;
+
 /**
  * GridGain platform processor.
  */
@@ -152,6 +155,15 @@ public class PlatformProcessorImpl extends 
GridProcessorAdapter implements Platf
     /** */
     private static final int OP_GET_BASELINE_TOPOLOGY = 26;
 
+    /** */
+    private static final int OP_DISABLE_WAL = 27;
+
+    /** */
+    private static final int OP_ENABLE_WAL = 28;
+
+    /** */
+    private static final int OP_IS_WAL_ENABLED = 29;
+
     /** Start latch. */
     private final CountDownLatch startLatch = new CountDownLatch(1);
 
@@ -412,7 +424,7 @@ public class PlatformProcessorImpl extends 
GridProcessorAdapter implements Platf
     @Override public long processInLongOutLong(int type, long val) throws 
IgniteCheckedException {
         switch (type) {
             case OP_LOGGER_IS_LEVEL_ENABLED: {
-                return loggerIsLevelEnabled((int) val) ? 
PlatformAbstractTarget.TRUE : PlatformAbstractTarget.FALSE;
+                return loggerIsLevelEnabled((int) val) ? TRUE : FALSE;
             }
 
             case OP_RELEASE_START: {
@@ -468,6 +480,19 @@ public class PlatformProcessorImpl extends 
GridProcessorAdapter implements Platf
                 ctx.grid().addCacheConfiguration(cfg);
 
                 return 0;
+
+            case OP_DISABLE_WAL:
+                ctx.grid().cluster().disableWal(reader.readString());
+
+                return 0;
+
+            case OP_ENABLE_WAL:
+                ctx.grid().cluster().enableWal(reader.readString());
+
+                return 0;
+
+            case OP_IS_WAL_ENABLED:
+                return ctx.grid().cluster().isWalEnabled(reader.readString()) 
? TRUE : FALSE;
         }
 
         return PlatformAbstractTarget.throwUnsupported(type);

http://git-wip-us.apache.org/repos/asf/ignite/blob/82554dd7/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs
----------------------------------------------------------------------
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 e3c0acf..1893a5a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs
@@ -275,6 +275,43 @@ namespace Apache.Ignite.Core.Tests.Cache
         }
 
         /// <summary>
+        /// Tests the wal disable/enable functionality.
+        /// </summary>
+        [Test]
+        public void TestWalDisableEnable()
+        {
+            using (var ignite = Ignition.Start(GetPersistentConfiguration()))
+            {
+                var cluster = ignite.GetCluster();
+                cluster.SetActive(true);
+
+                var cache = ignite.CreateCache<int, int>("foo");
+                Assert.IsTrue(cluster.IsWalEnabled(cache.Name));
+                cache[1] = 1;
+
+                cluster.DisableWal(cache.Name);
+                Assert.IsFalse(cluster.IsWalEnabled(cache.Name));
+                cache[2] = 2;
+
+                cluster.EnableWal(cache.Name);
+                Assert.IsTrue(cluster.IsWalEnabled(cache.Name));
+
+                Assert.AreEqual(1, cache[1]);
+                Assert.AreEqual(2, cache[2]);
+
+                // Check exceptions.
+                var ex = Assert.Throws<IgniteException>(() => 
cluster.IsWalEnabled("bar"));
+                Assert.AreEqual("Cache not found: bar", ex.Message);
+
+                ex = Assert.Throws<IgniteException>(() => 
cluster.DisableWal("bar"));
+                Assert.AreEqual("Cache doesn't exist: bar", ex.Message);
+
+                ex = Assert.Throws<IgniteException>(() => 
cluster.EnableWal("bar"));
+                Assert.AreEqual("Cache doesn't exist: bar", ex.Message);
+            }
+        }
+
+        /// <summary>
         /// Checks active state.
         /// </summary>
         private static void CheckIsActive(IIgnite ignite, bool isActive)

http://git-wip-us.apache.org/repos/asf/ignite/blob/82554dd7/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs 
b/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs
index f9bbdf7..45e22e9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs
@@ -121,5 +121,39 @@ namespace Apache.Ignite.Core.Cluster
         /// Returns null if <see cref="SetBaselineTopology(long)"/> has not 
been called.
         /// </summary>
         ICollection<IBaselineNode> GetBaselineTopology();
+
+        /// <summary>
+        /// Disables write-ahead logging for specified cache. When WAL is 
disabled, changes are not logged to disk.
+        /// This significantly improves cache update speed.The drawback is 
absence of local crash-recovery guarantees.
+        /// If node is crashed, local content of WAL-disabled cache will be 
cleared on restart
+        /// to avoid data corruption.
+        /// <para />
+        /// Internally this method will wait for all current cache operations 
to finish and prevent new cache 
+        /// operations from being executed.Then checkpoint is initiated to 
flush all data to disk.Control is returned
+        /// to the callee when all dirty pages are prepared for checkpoint, 
but not necessarily flushed to disk.
+        /// <para />
+        /// WAL state can be changed only for persistent caches.
+        /// </summary>
+        /// <param name="cacheName">Name of the cache.</param>
+        void DisableWal(string cacheName);
+
+        /// <summary>
+        /// Enables write-ahead logging for specified cache. Restoring 
crash-recovery guarantees of a previous call to
+        /// <see cref="DisableWal"/>.
+        /// <para />
+        /// Internally this method will wait for all current cache operations 
to finish and prevent new cache
+        /// operations from being executed. Then checkpoint is initiated to 
flush all data to disk.
+        /// Control is returned to the callee when all data is persisted to 
disk.
+        /// <para />
+        /// WAL state can be changed only for persistent caches.
+        /// </summary>
+        /// <param name="cacheName">Name of the cache.</param>
+        void EnableWal(string cacheName);
+
+        /// <summary>
+        /// Determines whether write-ahead logging is enabled for specified 
cache.
+        /// </summary>
+        /// <param name="cacheName">Name of the cache.</param>
+        bool IsWalEnabled(string cacheName);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/82554dd7/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 10b083b..ffab09f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -87,7 +87,10 @@ namespace Apache.Ignite.Core.Impl
             AddCacheConfiguration = 23,
             SetBaselineTopologyVersion = 24,
             SetBaselineTopologyNodes = 25,
-            GetBaselineTopology = 26
+            GetBaselineTopology = 26,
+            DisableWal = 27,
+            EnableWal = 28,
+            IsWalEnabled = 29
         }
 
         /** */
@@ -818,6 +821,30 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritdoc /> */
+        public void DisableWal(string cacheName)
+        {
+            IgniteArgumentCheck.NotNull(cacheName, "cacheName");
+
+            DoOutOp((int) Op.DisableWal, w => w.WriteString(cacheName));
+        }
+
+        /** <inheritdoc /> */
+        public void EnableWal(string cacheName)
+        {
+            IgniteArgumentCheck.NotNull(cacheName, "cacheName");
+            
+            DoOutOp((int) Op.EnableWal, w => w.WriteString(cacheName));
+        }
+
+        /** <inheritdoc /> */
+        public bool IsWalEnabled(string cacheName)
+        {
+            IgniteArgumentCheck.NotNull(cacheName, "cacheName");
+
+            return DoOutOp((int) Op.IsWalEnabled, w => 
w.WriteString(cacheName)) == True;
+        }
+
+        /** <inheritdoc /> */
 #pragma warning disable 618
         public IPersistentStoreMetrics GetPersistentStoreMetrics()
         {

Reply via email to