是否可以将成员添加到 Aeron Cluster w/o 重新配置现有成员?

Is it possible to add members to Aeron Cluster w/o reconfiguring existing ones?

我正在寻找一种方法来将新成员添加到现有的 Aeron 集群而无需重新配置现有的

集群成员似乎已按照集群教程中的描述定义 statically during startup

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 中找到了这个(强调我的)

Key aspects of Raft:

  • there is a Strong Leader, which means that all log entries flow from the leader to followers
  • Raft makes use of randomized timers to elect leaders. This adds a few milliseconds to failover, but reduces the time to agree an elected leader (in Aeron Cluster, this is a maximum of the election timeout * 2).
  • the Raft protocol allows runtime configuration changes (i.e. adding new or removing nodes at runtime). At the time of writing, this feature is still pending in Aeron Cluster.

但是,我确实看到 类 类似于 io.aeron.cluster.DynamicJoin 及其在 io.aeron.cluster.ConsensusModuleAgent 中的用法,这让我认为动态添加节点是可能的,也许说明书已经过时了。

你知道在不接触现有节点的情况下加入更多节点的方法吗?

是的,这是可能的!上下文应该这样构建:

ConsensusModule.Context()
    .errorHandler(errorHandler("Consensus Module"))
    .clusterMemberId(Aeron.NULL_VALUE) // <1>
    .clusterMembers("") // <2>
    .memberEndpoints(memberEndpoints(hostnames[nodeId], nodeId)) // <3>
    .clusterConsensusEndpoints(consensusEndpoints(hostnames)) // <4>
    .clusterDir(File(baseDir, "consensus-module"))
    .ingressChannel("aeron:udp?term-length=64k")
    .logChannel("aeron:udp?term-length=64k")
    .replicationChannel(logReplicationChannel(hostname))
    .archiveContext(aeronArchiveContext.clone())
  1. clusterMemberId 必须设置为 Aeron.NULL_VALUE。会员ID会自动生成
  2. clusterMembers 应该是空的。动态节点不需要静态成员
  3. memberEndpoints是这个节点的通道配置。格式为 ingress:port,consensus:port,log:port,catchup:port,archive:port。与单个节点的 static clusterMembers configuration 非常相似,但前面没有成员 ID。
  4. clusterConsensusEndpoints 是逗号分隔的列表 consensus:port 已知集群成员的通道。我认为它类似于“bootstrap”要加入的主机列表。