我正在尝试为 Apache Ignite 配置持久存储,以便我的 IgniteCache 实例不会在应用程序重启时丢失数据。我的设置是从我的代码开始的本地单节点集群,如下所示:
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setWorkDirectory("C:\\ignite");
// Ignite persistence configuration.
DataStorageConfiguration storageCfg = new DataStorageConfiguration();
storageCfg.setStoragePath("ignitedb/storage");
storageCfg.setWalPath("ignitedb/wal");
storageCfg.setWalArchivePath("ignitedb/wal/archive");
// Enabling the persistence.
storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(true);
// Applying settings.
cfg.setDataStorageConfiguration(storageCfg);
Ignite ignite = Ignition.getOrStart(cfg);
ignite.active(true);
// Get all server nodes that are already up and running.
Collection<ClusterNode> nodes = ignite.cluster().forServers().nodes();
// Set the baseline topology that is represented by these nodes.
ignite.cluster().setBaselineTopology(nodes);
return ignite;
缓存是这样创建的:
cacheConfiguration = new CacheConfiguration<>();
cacheConfiguration.setBackups(1);
cacheConfiguration.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cacheConfiguration.setName("UserCache");
cacheConfiguration.setCacheMode(CacheMode.LOCAL);
cacheConfiguration.setReadFromBackup(true);
cacheConfiguration.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheConfiguration.setIndexedTypes(String.class, User.class);
IgniteCache<String, User> cache = ignite.getOrCreateCache(cacheConfiguration);
User在缓存中存储对象有效。Ignite 在C:\ignite. 但是在应用程序重新启动时,所有数据都会丢失。我该如何正确配置?
慕桂英4014372
繁华开满天机
MMTTMM
相关分类