地图上的 Hazelcast 本地入口监听器
Hazelcast local entry listener on a Map
我一直在研究使用本地入口侦听器而不是普通入口侦听器,以便事件仅由单个侦听器处理。
我找到了关于此主题的各种帖子,例如 , this, this, this and 。看起来本地入口监听器确实是在多节点集群中只处理一次事件的方法。
但是,我不确定这样的本地入口侦听器在故障情况下如何运行。例如,如果作为该条目的主节点的节点不可用,驱逐事件会发生什么。备份会及时接收吗?还是由于 hazelcast 需要一些时间来确定主节点已关闭并应选举新的主节点而错过该事件?这在旧的 AP 系统和新的 CP 子系统之间有什么不同吗?
我们已避免使用本地条目侦听器。相反,我们现在使用 hazelcast 的 executorservice 来安排命名任务。这样我们就可以正确的响应集群的变化。看起来 hazelcast 确实有一个首选成员在其上执行任务,但这对我们来说不是问题。
来自 Hazelcast 文档:
Note that entries in distributed map are partitioned across the
cluster members; each member owns and manages the some portion of the
entries. Owned entries are called local entries. This listener will be
listening for the events of local entries. Let's say your cluster has
member1 and member2. On member2 you added a local listener and from
member1, you call {@code map.put(key2, value2)}. If the key2 is owned
by member2 then the local listener will be notified for the add/update
event. Also note that entries can migrate to other nodes for load
balancing and/or membership change.
关键部分是:“另请注意,条目可以迁移到其他节点以实现负载平衡 and/or 成员资格更改。”
我猜想如果原来的分区所有者失败,那么其他一些节点将成为这些条目(或其中的一部分,取决于重新分区完成后的集群状态)的新所有者,然后它成为新的所有者, 将 运行 本地入口监听器。
我一直在研究使用本地入口侦听器而不是普通入口侦听器,以便事件仅由单个侦听器处理。
我找到了关于此主题的各种帖子,例如
但是,我不确定这样的本地入口侦听器在故障情况下如何运行。例如,如果作为该条目的主节点的节点不可用,驱逐事件会发生什么。备份会及时接收吗?还是由于 hazelcast 需要一些时间来确定主节点已关闭并应选举新的主节点而错过该事件?这在旧的 AP 系统和新的 CP 子系统之间有什么不同吗?
我们已避免使用本地条目侦听器。相反,我们现在使用 hazelcast 的 executorservice 来安排命名任务。这样我们就可以正确的响应集群的变化。看起来 hazelcast 确实有一个首选成员在其上执行任务,但这对我们来说不是问题。
来自 Hazelcast 文档:
Note that entries in distributed map are partitioned across the cluster members; each member owns and manages the some portion of the entries. Owned entries are called local entries. This listener will be listening for the events of local entries. Let's say your cluster has member1 and member2. On member2 you added a local listener and from member1, you call {@code map.put(key2, value2)}. If the key2 is owned by member2 then the local listener will be notified for the add/update event. Also note that entries can migrate to other nodes for load balancing and/or membership change.
关键部分是:“另请注意,条目可以迁移到其他节点以实现负载平衡 and/or 成员资格更改。”
我猜想如果原来的分区所有者失败,那么其他一些节点将成为这些条目(或其中的一部分,取决于重新分区完成后的集群状态)的新所有者,然后它成为新的所有者, 将 运行 本地入口监听器。