我正在寻找一种将新成员添加到现有 Aeron 集群而不重新配置现有成员的方法。
集群成员似乎是在启动期间静态定义 的,如集群教程中所述:
final ConsensusModule.Context consensusModuleContext = new ConsensusModule.Context()
.errorHandler(errorHandler("Consensus Module"))
.clusterMemberId(nodeId)
.clusterMembers(clusterMembers(Arrays.asList(hostnames))) // <------ HERE
.clusterDir(new File(baseDir, "consensus-module"))
.ingressChannel("aeron:udp?term-length=64k")
.logChannel(logControlChannel(nodeId, hostname, LOG_CONTROL_PORT_OFFSET))
.replicationChannel(logReplicationChannel(hostname))
.archiveContext(aeronArchiveContext.clone());
如果我理解正确,如果我想添加更多节点,我需要重新配置每个现有节点以包含新成员。
此外,我在Aeron Cookbook中找到了这个(重点是我的)
Raft 的关键方面:
- 有一个强领导者,这意味着所有日志条目都从领导者流向追随者
- Raft 利用随机定时器来选举领导者。这为故障转移增加了几毫秒,但减少了同意选出的领导者的时间(在 Aeron 集群中,这是选举超时 * 2 的最大值)。
- Raft 协议允许运行时配置更改(即在运行时添加新节点或删除节点)。在撰写本文时,此功能仍在 Aeron Cluster 中待定。
但是,我确实看到了类似的类io.aeron.cluster.DynamicJoin
及其用法,io.aeron.cluster.ConsensusModuleAgent
这让我认为动态添加节点是可能的,也许食谱已经过时了。
你知道在不触及现有节点的情况下加入更多节点的方法吗?