Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<>();
Expand Down Expand Up @@ -178,6 +178,8 @@ public FilePageStoreManager(GridKernalContext ctx) {
this.dsCfg = dsCfg;

pageStoreV1FileIoFactory = pageStoreFileIoFactory = dsCfg.getFileIOFactory();

marshaller = MarshallerUtils.jdkMarshaller(ctx.igniteInstanceName());
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -63,7 +65,9 @@ public void TearDown()
/// 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())
{
Expand Down Expand Up @@ -99,7 +103,12 @@ public void TestCacheDataSurvivesNodeRestart()
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.
Expand Down Expand Up @@ -348,5 +357,40 @@ private static IgniteConfiguration GetPersistentConfiguration()
}
};
}

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(); }
}
}
}
}