【发布时间】:2018-08-06 22:29:13
【问题描述】:
我有一个测试工具,我试图用 IgniteCache 替换 ConcurrentHashMap DS。 我创建了一个 IgniteCache 和一个 CacheConfiguration 具有相同的数据结构,我希望我的新 IgniteCache 是。运行时,它会从开始到停止。在调试它显示在 ignite.getOrCreateCache(cfg);一步它抛出 NullPointerException
Notes:
1. I need to run this in embedded mode only without any external installations or external start stop service.
2. Added Ignite start and stop in spring lifecycle events of startup() and shutdown() functions.
3. I have added the entries in maven dependency and tested the sample run.
4. It asks for is IGNITE_HOME set? not sure where and what to do if I only want it in embedded mode
5. Default XML file not found on output screen. I added a sample xml file with configuration and imported it into my main sprint-integration.xml file.
代码sn-p:
public class HarnessCache {
Ignite ignite;
private IgniteCache<HarnessCacheKey, ConcurrentHashMap<HarnessDataGroupKey, Object>> harnessCacheMap;
private CacheConfiguration<HarnessCacheKey, ConcurrentHashMap<HarnessDataGroupKey, Object>> cfg;
// private ConcurrentHashMap<HarnessCacheKey, ConcurrentHashMap<HarnessDataGroupKey, Object>> _harnessCacheMap;
private ConcurrentHashMap<String, List<OutMessageDto>> harnessOutMessageMap;
public void startup() {
// Ignition.start("/mte-testharness/src/main/resources/spring-Ignite-cache-load.xml");
Ignition.start();
System.out.println("Test Harness Cache startup....");
cfg = new CacheConfiguration<>();
harnessCacheMap = ignite.getOrCreateCache(cfg);
harnessOutMessageMap = new ConcurrentHashMap<String, List<OutMessageDto>>();
System.out.println("Test Harness Cache ready....");
}
public void shutdown() {
System.out.println("Test Harness Cache shutting down....");
harnessCacheMap.clear();
harnessOutMessageMap.clear();
ignite.close();
}
}
Output console:
[14:05:25] Configured failure handler: [hnd=StopNodeOrHaltFailureHandler [tryStop=false, timeout=0]]
[14:05:25] Message queue limit is set to 0 which may lead to potential OOMEs when running cache operations in FULL_ASYNC or PRIMARY_SYNC modes due to message queues growth on sender and receiver sides.
[14:05:25] Security status [authentication=off, tls/ssl=off]
[14:05:28] Performance suggestions for grid (fix if possible)
[14:05:28] To disable, set -DIGNITE_PERFORMANCE_SUGGESTIONS_DISABLED=true
[14:05:28] ^-- Enable G1 Garbage Collector (add '-XX:+UseG1GC' to JVM options)
[14:05:28] ^-- Specify JVM heap max size (add '-Xmx<size>[g|G|m|M|k|K]' to JVM options)
[14:05:28] ^-- Set max direct memory size if getting 'OOME: Direct buffer memory' (add '-XX:MaxDirectMemorySize=<size>[g|G|m|M|k|K]' to JVM options)
[14:05:28] ^-- Disable processing of calls to System.gc() (add '-XX:+DisableExplicitGC' to JVM options)
[14:05:28] ^-- Disable assertions (remove '-ea' from JVM options)
[14:05:28] Refer to this page for more performance suggestions: https://apacheignite.readme.io/docs/jvm-and-system-tuning
[14:05:28]
[14:05:28] To start Console Management & Monitoring run ignitevisorcmd.{sh|bat}
[14:05:28]
[14:05:28] Ignite node started OK (id=a9e097dd)
[14:05:28] Topology snapshot [ver=1, servers=1, clients=0, CPUs=4, offheap=3.2GB, heap=3.5GB]
[14:05:28] ^-- Node [id=A9E097DD-64E1-4699-9237-65AF0E68D975, clusterState=ACTIVE]
[14:05:28] Data Regions Configured:
[14:05:28] ^-- default [initSize=256.0 MiB, maxSize=3.2 GiB, persistenceEnabled=false]
Test Harness Cache startup....
[14:05:28] (wrn) Default Spring XML file not found (is IGNITE_HOME set?): config/default-config.xml
[14:05:29] (wrn) Default Spring XML file not found (is IGNITE_HOME set?): config/default-config.xml
[14:05:29] (wrn) Default Spring XML file not found (is IGNITE_HOME set?): config/default-config.xml
[14:05:30] (wrn) Default Spring XML file not found (is IGNITE_HOME set?): config/default-config.xml
[14:05:30] (wrn) Default Spring XML file not found (is IGNITE_HOME set?): config/default-config.xml
[14:05:30] Ignite node stopped OK [uptime=00:00:02.341]
我是 Ignite 的新手,这是运行一些示例后的第一个应用程序。请提及我是否遗漏了任何明显的配置文件或设置。
谢谢你, 维杰
【问题讨论】:
标签: ignite