You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2019/01/27 15:47:06 UTC
[ignite] branch master 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.
ptupitsyn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new f2c58ab IGNITE-10451 .NET: Fix failure on grid start with persistence and custom affinity
f2c58ab is described below
commit f2c58ab0f68b5e5f0b368401601c971c34242fba
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
---
.../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 e4178f7..6c008d6 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.X;
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<Integer, CacheStoreHolder> idxCacheStores = new ConcurrentHashMap<>();
@@ -178,6 +178,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(); }
+ }
+ }
}
}