From 1bca7066ec8071005c149a5721e3b19d3a49ae84 Mon Sep 17 00:00:00 2001 From: Pavel Tupitsyn Date: Thu, 24 Jan 2019 19:49:01 +0300 Subject: [PATCH 1/3] Reproducer added --- .../Cache/PersistenceTest.cs | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) 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 147e79f9bb2c7..11a43709c59d4 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; @@ -99,7 +101,11 @@ public void TestCacheDataSurvivesNodeRestart() ignite.GetCluster().SetActive(true); // Create cache with default region (persistence enabled), add data. - var cache = ignite.CreateCache(cacheName); + var cache = ignite.CreateCache(new CacheConfiguration + { + Name = cacheName, + CacheStoreFactory = new TestCacheStoreFactory() + }); cache[1] = 1; // Check some metrics. @@ -348,5 +354,31 @@ private static IgniteConfiguration GetPersistentConfiguration() } }; } + + private class TestCacheStoreFactory : IFactory + { + public ICacheStore CreateInstance() + { + return new TestStore(); + } + } + + private class TestStore : CacheStoreAdapter + { + public override object Load(object key) + { + return null; + } + + public override void Write(object key, object val) + { + throw new NotImplementedException(); + } + + public override void Delete(object key) + { + throw new NotImplementedException(); + } + } } } From 9954b848b6b15ea2ee6c616353f86b68b5ace959 Mon Sep 17 00:00:00 2001 From: Pavel Tupitsyn Date: Thu, 24 Jan 2019 19:56:33 +0300 Subject: [PATCH 2/3] Fix FilePageStoreManager --- .../cache/persistence/file/FilePageStoreManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 e4178f718b68c..6c008d66cd87f 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 @@ -76,7 +76,7 @@ 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; @@ -129,7 +129,7 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen FileSystems.getDefault().getPathMatcher("glob:**" + TMP_SUFFIX); /** Marshaller. */ - private static final Marshaller marshaller = new JdkMarshaller(); + private final Marshaller marshaller; /** */ private final Map idxCacheStores = new ConcurrentHashMap<>(); @@ -178,6 +178,8 @@ public FilePageStoreManager(GridKernalContext ctx) { this.dsCfg = dsCfg; pageStoreV1FileIoFactory = pageStoreFileIoFactory = dsCfg.getFileIOFactory(); + + marshaller = MarshallerUtils.jdkMarshaller(ctx.igniteInstanceName()); } /** {@inheritDoc} */ From 30a903b40db4c4eccbc731dd4ae3816ee9fe6c68 Mon Sep 17 00:00:00 2001 From: Pavel Tupitsyn Date: Thu, 24 Jan 2019 23:13:18 +0300 Subject: [PATCH 3/3] Improve tests --- .../Cache/PersistenceTest.cs | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) 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 11a43709c59d4..d602802854be2 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/PersistenceTest.cs @@ -65,7 +65,9 @@ public void TearDown() /// Tests that cache data survives node restart. /// [Test] - public void TestCacheDataSurvivesNodeRestart() + public void TestCacheDataSurvivesNodeRestart( + [Values(true, false)] bool withCacheStore, + [Values(true, false)] bool withCustomAffinity) { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { @@ -104,7 +106,8 @@ public void TestCacheDataSurvivesNodeRestart() var cache = ignite.CreateCache(new CacheConfiguration { Name = cacheName, - CacheStoreFactory = new TestCacheStoreFactory() + CacheStoreFactory = withCacheStore ? new CustomStoreFactory() : null, + AffinityFunction = withCustomAffinity ? new CustomAffinityFunction() : null }); cache[1] = 1; @@ -355,15 +358,15 @@ private static IgniteConfiguration GetPersistentConfiguration() }; } - private class TestCacheStoreFactory : IFactory + private class CustomStoreFactory : IFactory { public ICacheStore CreateInstance() { - return new TestStore(); + return new CustomStore(); } } - private class TestStore : CacheStoreAdapter + private class CustomStore : CacheStoreAdapter { public override object Load(object key) { @@ -372,12 +375,21 @@ public override object Load(object key) public override void Write(object key, object val) { - throw new NotImplementedException(); + // No-op. } public override void Delete(object key) { - throw new NotImplementedException(); + // No-op. + } + } + + private class CustomAffinityFunction : RendezvousAffinityFunction + { + public override int Partitions + { + get { return 10; } + set { throw new NotSupportedException(); } } } }