【发布时间】:2021-04-08 06:41:27
【问题描述】:
我正在使用 Apache Ignite 2.10.0,我希望通过读取/写入功能将数据从第三方持久性加载/写入缓存中,为了做到这一点,我实现了扩展 CacheStoreAdapter 类的 PersonStore。我希望我的类(PersonStore、pojo 和其他类)能够从客户端节点远程自动部署到 Ignite 服务器节点,为此我在 CacheConfiguration 中启用了 peerClassLoading,在启动服务器时我看到了
java.lang.RuntimeException: Failed to create an instance of com.demoIgnite.adapter.PersonStore
at javax.cache.configuration.FactoryBuilder$ClassFactory.create(FactoryBuilder.java:134)
.....
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
at java.lang.Thread.run(Thread.java:745)
Caused by:java.lang.ClassNotFoundException: com.demoIgnite.adapter.PersonStore
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at javax.cache.configuration.FactoryBuilder$ClassFactory.create(FactoryBuilder.java:130)
但是,如果我手动尝试将 jar 放到 ignite 库中,它绝对可以正常工作。但是通过这种方法,每当有我想避免的代码修改时,我都必须重建、替换和重新启动 Ignite 服务器。 我是 Apache Ignite 的新手,在阅读了 ignite 文档后假设如果启用了 peerClassLoading,这可以自动处理,如果我在那里遗漏了什么,请帮助我。另外,请给我建议一种自动化的方法。
我的缓存配置:
CacheConfiguration
cachecfg = new CacheConfiguration (); cachecfg.setName("person-store"); cachecfg.setCacheMode(CacheMode.PARTITIONED); cachecfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); cachecfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cachecfg.setReadThrough(true); cachecfg.setWriteThrough(true); cachecfg.setCacheStoreFactory(FactoryBuilder.factoryOf(PersonStore.class));
点燃配置:
IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteInstanceName("我的点燃");
cfg.setClientMode(true); cfg.setPeerClassLoadingEnabled(true); cfg.setDeploymentMode(DeploymentMode.CONTINUOUS); cfg.setCacheConfiguration(cacheCfg); TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder(); ipFinder.setAddresses(Collections.singletonList("127.0.0.1:10800")); cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
【问题讨论】:
标签: spring-boot classloader ignite urlclassloader