Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Apache Ignite ScanQuery on local node returns empty result

I have one server node and one client node. I create cache on the client node and put some objects there

CacheConfiguration<String, T> cfg = new CacheConfiguration<>();
cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cfg.setName("myCacheName");
cfg.setCacheMode(CacheMode.REPLICATED);
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cfg.setRebalanceMode(CacheRebalanceMode.SYNC);

NearCacheConfiguration<String, T> nearCacheCfg = new NearCacheConfiguration<>();
nearCacheCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(100_000));
cfg.setNearConfiguration(nearCacheCfg);
cache = ignite.getOrCreateCache(cfg);

Then I try to get all entries with ScanQuery and setLocal(true) option from the client node, but I get an empty result

try (var cursor = cache.query(new ScanQuery<>(null).setLocal(true))) {
    return cursor.getAll().stream()
        .map(Cache.Entry::getValue)
        .toList();
}

If I do this without setLocal(true) option, it works well, and I get all entiries.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If I use cache.localEntries(ALL).iterator(), I get all enitries too.

What’s wrong with ScanQuery?

>Solution :

  • Client nodes do not hold any data
  • The data is stored on server nodes (no matter if you put it from client node or not)

Therefore, local scan query always returns empty results on client node.

Local scan query makes sense on server nodes only (e.g. within a Compute task).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading