运行Ignite streamer字数计数示例时,无法查询出数据

运行Ignite streamer字数计数示例时,无法查询出数据,ignite,Ignite,我正在遵循中的步骤。探索Ignite流字计数示例。当我运行查询时,没有查询出任何数据。 以下是我的代码: public class CacheConfig { public static CacheConfiguration<String, Long> createWordCache() { CacheConfiguration<String, Long> cfg = new CacheConfiguration<String, Long&

我正在遵循中的步骤。探索Ignite流字计数示例。当我运行查询时,没有查询出任何数据。 以下是我的代码:

public class CacheConfig {

    public static CacheConfiguration<String, Long> createWordCache() {
        CacheConfiguration<String, Long> cfg = new CacheConfiguration<String, Long>("words");
        cfg.setIndexedTypes(String.class, Long.class);
        return cfg;
    }
}


public class WorkStreamIntoCache {
    public static void main(String[] args) throws Exception {
        Ignition.setClientMode(true);
        String configPath = "D:/apache-ignite-fabric-1.7.0-bin/config/default-config.xml";
        Ignite ignite = Ignition.start(configPath);
        IgniteCache<String, Long> cache = ignite.getOrCreateCache(CacheConfig.createWordCache());

        IgniteDataStreamer<String, Long> streamer = ignite.dataStreamer(cache.getName());

        streamer.allowOverwrite(true);


        streamer.receiver(StreamTransformer.from(new CacheEntryProcessor<String, Long, Object>() {

            public Object process(MutableEntry<String, Long> mutableEntry, Object... objects) throws EntryProcessorException {
                Long preValue = mutableEntry.getValue();
                if (preValue == null) {
                    mutableEntry.setValue(1L);
                } else {
                    mutableEntry.setValue(preValue + 1);
                }
                return null;
            }
        }));


        while (true) {
            InputStream in = WorkStreamIntoCache.class.getResourceAsStream("/words.txt");
            List<String> lines = IOUtils.readAsLines(in);
            for (String line : lines) {
                String[] words = line.split(" ");
                for (String word : words) {
                    word = word.trim();
                    if (word != null && word.length() > 0) {
                        streamer.addData(word, 1L);
                        System.out.println(word + " is writing to the cache @" + new SimpleDateFormat("yyyyMMdd HHmmss").format(new Date()));
                    }
                }
            }
            Thread.sleep(120 * 1000);
        }

    }
}

public class QueryWords {
    public static void main(String[] args) throws Exception {
        Ignition.setClientMode(true);

        String configPath = "D:/apache-ignite-fabric-1.7.0-bin/config/default-config.xml";
        Ignite ignite = Ignition.start(configPath);
        IgniteCache<String, Long> cache = ignite.getOrCreateCache(CacheConfig.createWordCache());

        SqlFieldsQuery sql = new SqlFieldsQuery("select * from Long");

        while (true) {
            List<List<?>> data = cache.query(sql).getAll();
            if (data == null || data.size() <= 0) {
                System.out.println("No data is found in the cache");
            }
            for (List<?> datum : data) {
                for (Object record : datum) {
                    System.out.println("record: " + record);
                }
            }
            Thread.sleep(3000);
        }
    }
}
运行该示例的步骤包括:

首先,我使用bin/ignite.bat D:/apache-ignite-fabric-1.7.0-bin/config/default-config.xml启动ignite服务器 然后在IDEA中,我运行WorkStreamIntoCache程序,我可以看到单词写入缓存的日志 当我运行QueryWords时,我无法查询出数据,只是在控制台中的缓存中找不到数据。
有人能帮忙解决问题吗?谢谢

有人能看看这个问题吗?谢谢。你分享完整的代码了吗?看起来缓存已被销毁或缓存项已过期,并且您正在运行数据查询。是的,这是所有代码。我在IDE中运行这两个主要类,ignite在客户端模式下启动,并在本地使用bin/ignite.bat D:/apache-ignite-fabric-1.7.0-bin/config/default-config.xml启动ignite服务器。我会花更多的时间在这上面,谢谢@a_gura你能创建一个小的GitHub项目,这样我或其他人就可以轻松地运行它并重现行为吗?这样一来,你就更容易知道自己做错了什么。