我正在使用Apache Ignite 2.4.0,官方示例中有很少的变化(下面的代码) . 我测试了以下场景:

public static void main(String[] args) throws IgniteException {
Ignition.setClientMode(true);
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
  CacheConfiguration cfg = new CacheConfiguration();
  cfg.setName(CACHE_NAME)
  .setAtomicityMode(CacheAtomicityMode.ATOMIC)
  .setCacheMode(CacheMode.PARTITIONED)
  .setBackups(1)               
  .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
  .setReadFromBackup(true);

  try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
                    putGet(cache);
  }
}
}
  • 与客户端,我使用putGet方法写和读:
private static void putGet(IgniteCache<Integer, String> cache) throws IgniteException {
System.out.println(">>> Cache put-get example started.");

// Store keys in cache.
for (int i = 0; i < 100; i++)
  cache.put(i, Integer.toString(i));

System.out.println(">>> Stored values in cache.");

int size = 0;
for (int i = 0; i < 100; i++) {
  if (cache.get(i) != null)
    size++;
}
System.out.println("Cache size:" + size);
}

当我第一次执行putGet方法时,输出当然是:

>>> Cache put-get example started.
>>> Stored values in cache.
Cache size:100
[01:35:21] Ignite node stopped OK [uptime=00:00:00.744]

然后我停止一个节点,然后再次执行putGet方法(这次只是读取部分) . 结果是:

>>> Cache put-get example started.
>>> Stored values in cache.
Cache size:48
[01:38:25] Ignite node stopped OK [uptime=00:00:00.406]

集群是否应该能够从其他两个节点上的备份恢复驻留在崩溃节点上的数据?备份的行为更准确是什么?是否需要持久模式?