我有一个远程服务器节点,从本地客户端节点我发现该服务器节点。现在从客户端节点我想创建缓存 附: peerClassLoading已启用两种配置 我的代码正在关注
private final CacheConfiguration<> cacheConfiguration = SpringContextHolder.applicationContext
.getBean("cacheConfiguration", CacheConfiguration.class);
ignite.createCache((CacheConfiguration<>)new CacheConfiguration<>(cacheConfiguration).setName(CACHE_NAME)
.setReadThrough(true)
.setCacheLoaderFactory(new LoaderFactory())
.setExpiryPolicyFactory(EternalExpiryPolicy.factoryOf())))
public class LoaderFactory
implements Factory<Loader> {
public Loader create() {
return new Loader();
}
}
public class Loader implements CacheLoader<x,y> {
public Loader(){
}
....................................
}
during creating cache ,on remote node brings exception
class org.apache.ignite.IgniteCheckedException: Failed to find class with given class loader for unmarshalling (make sure same versions of all classes are available on all nodes or enable peer-class-loading): java.net.URLClassLoader@738defde at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal(JdkMarshaller.java:108)
at org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage.message(TcpDiscoveryCustomEventMessage.java:80)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.notifyDiscoveryListener(ServerImpl.java:4894) at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processCustomMessage(ServerImpl.java:4750)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2121)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.body(ServerImpl.java:2208)07)
at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
Caused by: java.lang.ClassNotFoundException: com.synisys.idm.apollo.internal.service.caching.loaders.LoaderFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.security.AccessController.doPrivileged(Native Method)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425):354)
at java.lang.Class.forName0(Native Method)ader.java:358)
at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8250)
at org.apache.ignite.marshaller.jdk.JdkMarshallerObjectInputStream.resolveClass(JdkMarshallerObjectInputStream.java:54)
如何解决这个问题?
答案 0 :(得分:1)
Denis Magda回答@magda 您好,
您还必须将加载程序工厂的类放在客户端的节点类路径中。这样做的主要原因是,当从客户端节点启动事务时(通常情况下),客户端首先将数据提交到存储,然后再提交到内存中。
此博客文章中讨论了存储的案例:http://gridgain.blogspot.ru/2014/09/two-phase-commit-for-in-memory-caches.html
- 丹尼斯·马格达