[英]Ignite cache becomes empty after system reboot
我正在玩ignite,並有簡單的測試應用程序來探索其持久性功能:
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();
}
}
}
}
一切都好。 在應用程序執行之間,數據保留在緩存中。 但是,如果我重新啟動系統,所有緩存數據都將消失。 我的第一個猜測是,由於默認情況下Temp目錄中的工作目錄,該問題會發生。 所以我決定將工作目錄移到自定義文件夾:
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"
}
};
那是沒有結果。
我已閱讀以下官方資源
https://apacheignite.readme.io/docs
但是我仍然不明白為什么我的緩存數據消失了。 我是否錯過了有關點燃持久性的重要事項?
我使用NuGet獲取Ignite並在計算機上安裝了Java 1.8.0_151
如果查看PersistentStorePath
文件夾的內容,則會看到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
文件夾(有關此處的名稱生成的更多詳細信息)。
重新啟動計算機會導致此ID更改,這是Ignite 2.1和2.2的一個已知問題 (即將在2.3中修復)。 解決方法是設置IgniteConfiguration.consistentId
屬性,但Ignite.NET
(2.3中也已添加)中不提供該Ignite.NET
。
因此,您的選擇是:
consistentId
,並使用IgniteConfiguration.SpringConfigUrl
屬性加載
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.