Reputation: 6347
Im playing with ignite and have simple test app to explore its persistence features:
using System;
using Apache.Ignite.Core;
using Apache.Ignite.Core.PersistentStore;
namespace IgniteDemo
{
internal class Item
{
public int Number { get; set; }
public DateTime PointInTime { get; set; }
public override string ToString() => $"Item:{{Number={Number} ,PointInTime={PointInTime}}}";
}
class Program
{
static void Main(string[] args)
{
const string itemCacheName = @"Items";
var random = new Random();
var igniteConfig = new IgniteConfiguration{
JvmInitialMemoryMb = 1024,
PersistentStoreConfiguration = new PersistentStoreConfiguration()
};
using (var ignite = Ignition.Start(igniteConfig))
{
ignite.SetActive(true);
var cache = ignite.GetOrCreateCache<Guid, Item>(itemCacheName);
cache.LoadCache(null);
// put random item into cache
cache.Put(Guid.NewGuid(), new Item {Number = random.Next(), PointInTime = DateTime.Now});
//print all items in the cache
Console.WriteLine(@"Cache content:");
foreach (var cacheEntry in cache)
Console.WriteLine(cacheEntry);
Console.WriteLine("\nPress any key to Close");
Console.ReadKey();
}
}
}
}
Everything is ok. Data remains in the cache between application execution. But if I reboot my system, all cache data becomes disappeared. My first guess was that the problem happens due working directory in Temp folder by default. So i decided to move working directory to custom folder:
var igniteConfig = new IgniteConfiguration
{
JvmInitialMemoryMb = 1024,
WorkDirectory = @"D:\Store\Wd",
PersistentStoreConfiguration = new PersistentStoreConfiguration()
{
PersistentStorePath = @"D:\Store\Data",
WalStorePath = @"D:\Store\Wal",
WalArchivePath = @"D:\Store\Wal\Archive"
}
};
And that was gain no results.
I have read official resources listed below
https://apacheignite.readme.io/docs
But I still doesn't understand why my cache data disappears. Am I missed something important about Ignite persistance?
Im using NuGet to obtain Ignite and have Java 1.8.0_151 installed on my machine
Upvotes: 2
Views: 289
Reputation: 9006
If you look at contents of PersistentStorePath
folder, you'll see folders like 0_0_0_0_0_0_0_1_127_0_0_1_172_25_4_66_2001_0_9d38_6abd_388e_bade_3c6f_269_47500
(more details on name generation here).
Rebooting the machine causes this ID to change, this is a known issue with Ignite 2.1 and 2.2 (fixed in upcoming 2.3). Workaround is to set IgniteConfiguration.consistentId
property, but it is not available in Ignite.NET
(also added in 2.3).
So your options are:
consistentId
through Spring XML and load it with IgniteConfiguration.SpringConfigUrl
propertyUpvotes: 4