聊聊Election Algorithms
序 本文主要研究一下Election Algorithms Election Algorithms Election Algorithms大致有两类,一类是Garcia-Molina提出的Bully Election,一类是Chang & Roberts's Token Ring Election algorithm;对于大多数的election algorithms通常有如下几个假定: 完整的topology,信息可以在topology的nodes之间传递 每个node有唯一的id,而且对整个topology其他node可见 所有的通信网络是可靠的,只允许node fail,要求消息不丢失,不重复,不损坏 要求已经有fail detector机制来处理node fail的情况 Bully Election 当有node检测到leader fail之后,就发送election request给其他node,election request中带上自己的id 当node接收到election request时判断如果自己的id大于request中的id,则可以"bully"覆盖request中的id,如果小于则不改动,然后发送election request给其他node;当有node接收到election request的id是自己的node id时,则表明自己是leader