首页 > 解决方案 > Apache ignite:禁用对等类加载

问题描述

我正在尝试从 Spring Boot 应用程序连接到 Apache Ignite 服务器。

示例代码:

ClientConfiguration cfg = new ClientConfiguration().setAddresses("127.0.0.1:10800");
try (IgniteClient client = Ignition.startClient(cfg)) {
    Object cachedName = client.query(
            new SqlFieldsQuery("SELECT name from Person WHERE id=?").setArgs("foo").setSchema("PUBLIC")
    ).getAll().iterator().next().iterator().next();
}

我收到此错误:

原因:类 org.apache.ignite.IgniteCheckedException:远程节点具有与本地不同的对等类加载启用标志 [locId8=459833a1, locPeerClassLoading=true, rmtId8=83ea88ca, rmtPeerClassLoading=false, rmtAddrs=[ignite-0.ignite.default .svc.cluster.local/0:0:0:0:0:0:0:1%lo, /10.4.2.49, /127.0.0.1], rmtNode=ClusterNode [id=83ea88ca-da77-4887-9357- 267ac7397767, order=1, addr=[0:0:0:0:0:0:0:1%lo, 10.xxx, 127.0.0.1], daemon=false]]

因此,需要在我的 Java 代码中停用 PeerClassLoading。我怎样才能做到这一点?

标签: spring-bootignite

解决方案


如评论中所述,错误来自连接到集群的胖客户端(或另一台服务器),但代码来自瘦客户端

如果您只是读取/写入数据并且不需要执行代码,那么瘦客户端是一个非常好的选择。

要使用胖客户端,您需要确保胖客户端和服务器具有相同的对等类加载配置。那将是:

<property name=“peerClassLoadingEnabled” value=“false” />

在你的 Spring 配置文件中。或者:

IgniteConfiguration cfg = new IgniteConfiguration()
            ...
            .setPeerClassLoadingEnabled(false);

(我在false这里使用的是您当前的服务器配置。话虽如此,您可能希望将其打开。)


推荐阅读