spring-boot - 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。我怎样才能做到这一点?
解决方案
如评论中所述,错误来自连接到集群的胖客户端(或另一台服务器),但代码来自瘦客户端。
如果您只是读取/写入数据并且不需要执行代码,那么瘦客户端是一个非常好的选择。
要使用胖客户端,您需要确保胖客户端和服务器具有相同的对等类加载配置。那将是:
<property name=“peerClassLoadingEnabled” value=“false” />
在你的 Spring 配置文件中。或者:
IgniteConfiguration cfg = new IgniteConfiguration()
...
.setPeerClassLoadingEnabled(false);
(我在false
这里使用的是您当前的服务器配置。话虽如此,您可能希望将其打开。)
推荐阅读
- python - 如何检查是否只有选定元素在数组中有重复
- javascript - 在 Angular 中使用 use `getfilterinstance`
- scala - java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps; 斯卡拉
- video-streaming - CEA 608/708:这些字幕能否以较小的字体显示在底部位置?
- python - python:权限被拒绝
- c# - JWT Fire base 验证 ID
- go - 使用 go-sqlmock 创建一个 gorm 数据库(运行时错误)
- sd-card - SPI SD 卡 32GB 从不通过 CMD55、ACMD41 初始化步骤
- python - Surprise API - 如何将特征加载到 Surprise 数据集中?
- markdown - 如何在 svelte kit 中导入 markdown 文件?