ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [21/50] ignite git commit: IGNITE-5507 .NET: IIgnite.Active
Date Fri, 16 Jun 2017 09:42:17 GMT
IGNITE-5507 .NET: IIgnite.Active


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

Branch: refs/heads/ignite-5267-1
Commit: 3f9221a30ae47f45ad319d1c90852c55ea3c047f
Parents: 64ded76
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Thu Jun 15 20:45:52 2017 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Thu Jun 15 20:45:52 2017 +0300

----------------------------------------------------------------------
 .../platform/cluster/PlatformClusterGroup.java  | 16 ++++
 .../Apache.Ignite.Core.Tests.csproj             |  1 +
 .../Cache/PersistentStoreTest.cs                | 90 ++++++++++++++++++++
 .../IgniteConfigurationTest.cs                  |  1 +
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        | 13 +++
 .../Impl/Cluster/ClusterGroupImpl.cs            | 25 ++++++
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    | 12 +++
 7 files changed, 158 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3f9221a3/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
index cd8d9b8..3e3aa3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
@@ -116,6 +116,12 @@ public class PlatformClusterGroup extends PlatformAbstractTarget {
     /** */
     private static final int OP_MEMORY_METRICS_BY_NAME = 27;
 
+    /** */
+    private static final int OP_SET_ACTIVE = 28;
+
+    /** */
+    private static final int OP_IS_ACTIVE = 29;
+
     /** Projection. */
     private final ClusterGroupEx prj;
 
@@ -377,6 +383,16 @@ public class PlatformClusterGroup extends PlatformAbstractTarget {
 
                 return TRUE;
             }
+
+            case OP_SET_ACTIVE: {
+                prj.ignite().active(val == TRUE);
+
+                return TRUE;
+            }
+
+            case OP_IS_ACTIVE: {
+                return prj.ignite().active() ? TRUE : FALSE;
+            }
         }
 
         return super.processInLongOutLong(type, val);

http://git-wip-us.apache.org/repos/asf/ignite/blob/3f9221a3/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 12b0b6a..09eac70 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
@@ -76,6 +76,7 @@
     <Compile Include="Binary\BinaryReaderWriterTest.cs" />
     <Compile Include="Binary\BinarySelfTestSimpleName.cs" />
     <Compile Include="Binary\EnumsTestOnline.cs" />
+    <Compile Include="Cache\PersistentStoreTest.cs" />
     <Compile Include="Deployment\GetAddressFunc.cs" />
     <Compile Include="Deployment\PeerAssemblyLoadingAllApisTest.cs" />
     <Compile Include="Deployment\PeerAssemblyLoadingVersioningTest.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/3f9221a3/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTest.cs
new file mode 100644
index 0000000..b7d21df
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistentStoreTest.cs
@@ -0,0 +1,90 @@
+/*
+ * 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.Tests.Cache
+{
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Configuration;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests the persistent store.
+    /// </summary>
+    public class PersistentStoreTest
+    {
+        /// <summary>
+        /// Tests the grid activation with persistence (inactive by default).
+        /// </summary>
+        [Test]
+        public void TestGridActivationWithPersistence()
+        {
+            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                PersistentStoreConfiguration = new PersistentStoreConfiguration()
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                CheckIsActive(ignite, false);
+
+                ignite.SetActive(true);
+                CheckIsActive(ignite, true);
+
+                ignite.SetActive(false);
+                CheckIsActive(ignite, false);
+            }
+        }
+        
+        /// <summary>
+        /// Tests the grid activation without persistence (active by default).
+        /// </summary>
+        [Test]
+        public void TestGridActivationNoPersistence()
+        {
+            using (var ignite = Ignition.Start(TestUtils.GetTestConfiguration()))
+            {
+                CheckIsActive(ignite, true);
+
+                ignite.SetActive(false);
+                CheckIsActive(ignite, false);
+
+                ignite.SetActive(true);
+                CheckIsActive(ignite, true);
+            }
+        }
+
+        /// <summary>
+        /// Checks active state.
+        /// </summary>
+        private static void CheckIsActive(IIgnite ignite, bool isActive)
+        {
+            Assert.AreEqual(isActive, ignite.IsActive());
+
+            if (isActive)
+            {
+                var cache = ignite.GetOrCreateCache<int, int>("default");
+                cache[1] = 1;
+                Assert.AreEqual(1, cache[1]);
+            }
+            else
+            {
+                var ex = Assert.Throws<IgniteException>(() => ignite.GetOrCreateCache<int,
int>("default"));
+                Assert.AreEqual("can not perform operation, because cluster inactive", ex.Message);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3f9221a3/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 c7a15ed..f12bbd3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -661,6 +661,7 @@ namespace Apache.Ignite.Core.Tests
                         }
                     }
                 },
+                // Skip cache check because with persistence the grid is not active by default.
                 PluginConfigurations = new[] { new TestIgnitePluginConfiguration{ SkipCacheCheck
= true } },
                 EventStorageSpi = new MemoryEventStorageSpi
                 {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3f9221a3/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 acf2064..8c4bee2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -346,5 +346,18 @@ namespace Apache.Ignite.Core
         /// </summary>
         /// <param name="memoryPolicyName">Name of the memory policy.</param>
         IMemoryMetrics GetMemoryMetrics(string memoryPolicyName);
+
+        /// <summary>
+        /// Changes Ignite grid state to active or inactive.
+        /// </summary>
+        void SetActive(bool isActive);
+
+        /// <summary>
+        /// Determines whether this grid is in active state.
+        /// </summary>
+        /// <returns>
+        ///   <c>true</c> if the grid is active; otherwise, <c>false</c>.
+        /// </returns>
+        bool IsActive();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3f9221a3/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
index d6947b2..37b4e79 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -124,6 +124,12 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /** */
         private const int OpMemoryMetricsByName = 27;
 
+        /** */
+        private const int OpSetActive = 28;
+
+        /** */
+        private const int OpIsActive = 29;
+
         /** Initial Ignite instance. */
         private readonly Ignite _ignite;
         
@@ -590,6 +596,25 @@ namespace Apache.Ignite.Core.Impl.Cluster
         }
 
         /// <summary>
+        /// Changes Ignite grid state to active or inactive.
+        /// </summary>
+        public void SetActive(bool isActive)
+        {
+            DoOutInOp(OpSetActive, isActive ? True : False);
+        }
+
+        /// <summary>
+        /// Determines whether this grid is in active state.
+        /// </summary>
+        /// <returns>
+        ///   <c>true</c> if the grid is active; otherwise, <c>false</c>.
+        /// </returns>
+        public bool IsActive()
+        {
+            return DoOutInOp(OpIsActive) == True;
+        }
+
+        /// <summary>
         /// Creates new Cluster Group from given native projection.
         /// </summary>
         /// <param name="prj">Native projection.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/3f9221a3/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 000968c..fc7894a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -745,6 +745,18 @@ namespace Apache.Ignite.Core.Impl
             return _prj.GetMemoryMetrics(memoryPolicyName);
         }
 
+        /** <inheritdoc /> */
+        public void SetActive(bool isActive)
+        {
+            _prj.SetActive(isActive);
+        }
+
+        /** <inheritdoc /> */
+        public bool IsActive()
+        {
+            return _prj.IsActive();
+        }
+
         /// <summary>
         /// Gets or creates near cache.
         /// </summary>


Mime
View raw message