You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2019/08/14 14:14:04 UTC

[ignite] branch ignite-2.7.6 updated: IGNITE-10451 .NET: Fix failure on grid start with persistence and custom affinity

This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch ignite-2.7.6
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/ignite-2.7.6 by this push:
     new 93d0f89  IGNITE-10451 .NET: Fix failure on grid start with persistence and custom affinity
93d0f89 is described below

commit 93d0f89cf59fa02b9e3dda2b463835d6608667a4
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Sun Jan 27 18:46:40 2019 +0300

    IGNITE-10451 .NET: Fix failure on grid start with persistence and custom affinity
    
    This closes #5919
    
    (cherry picked from commit f2c58ab0f68b5e5f0b368401601c971c34242fba)
---
 .../persistence/file/FilePageStoreManager.java     |  6 ++-
 .../Cache/PersistenceTest.cs                       | 48 +++++++++++++++++++++-
 2 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
index c6cd9e5..a0d327f 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
@@ -63,7 +63,7 @@ import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.marshaller.jdk.JdkMarshaller;
+import org.apache.ignite.marshaller.MarshallerUtils;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -111,7 +111,7 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
     public static final String META_STORAGE_NAME = "metastorage";
 
     /** Marshaller. */
-    private static final Marshaller marshaller = new JdkMarshaller();
+    private final Marshaller marshaller;
 
     /** */
     private final Map<Integer, CacheStoreHolder> idxCacheStores = new ConcurrentHashMap<>();
@@ -156,6 +156,8 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
         this.dsCfg = dsCfg;
 
         pageStoreV1FileIoFactory = pageStoreFileIoFactory = dsCfg.getFileIOFactory();
+
+        marshaller =  MarshallerUtils.jdkMarshaller(ctx.igniteInstanceName());
     }
 
     /** {@inheritDoc} */
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 147e79f..d602802 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs
@@ -20,7 +20,9 @@ namespace Apache.Ignite.Core.Tests.Cache
     using System;
     using System.IO;
     using System.Linq;
+    using Apache.Ignite.Core.Cache.Affinity.Rendezvous;
     using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Cache.Store;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Configuration;
     using NUnit.Framework;
@@ -63,7 +65,9 @@ namespace Apache.Ignite.Core.Tests.Cache
         /// Tests that cache data survives node restart.
         /// </summary>
         [Test]
-        public void TestCacheDataSurvivesNodeRestart()
+        public void TestCacheDataSurvivesNodeRestart(
+            [Values(true, false)] bool withCacheStore,
+            [Values(true, false)] bool withCustomAffinity)
         {
             var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
             {
@@ -99,7 +103,12 @@ namespace Apache.Ignite.Core.Tests.Cache
                 ignite.GetCluster().SetActive(true);
 
                 // Create cache with default region (persistence enabled), add data.
-                var cache = ignite.CreateCache<int, int>(cacheName);
+                var cache = ignite.CreateCache<int, int>(new CacheConfiguration
+                {
+                    Name = cacheName,
+                    CacheStoreFactory = withCacheStore ? new CustomStoreFactory() : null,
+                    AffinityFunction = withCustomAffinity ? new CustomAffinityFunction() : null
+                });
                 cache[1] = 1;
 
                 // Check some metrics.
@@ -348,5 +357,40 @@ namespace Apache.Ignite.Core.Tests.Cache
                 }
             };
         }
+
+        private class CustomStoreFactory : IFactory<ICacheStore>
+        {
+            public ICacheStore CreateInstance()
+            {
+                return new CustomStore();
+            }
+        }
+
+        private class CustomStore : CacheStoreAdapter<object, object>
+        {
+            public override object Load(object key)
+            {
+                return null;
+            }
+
+            public override void Write(object key, object val)
+            {
+                // No-op.
+            }
+
+            public override void Delete(object key)
+            {
+                // No-op.
+            }
+        }
+
+        private class CustomAffinityFunction : RendezvousAffinityFunction
+        {
+            public override int Partitions
+            {
+                get { return 10; }
+                set { throw new NotSupportedException(); }
+            }
+        }
     }
 }