]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res/res_corosync: Raise a Stasis message on node join/leave events 09/3109/4
authorMatt Jordan <mjordan@digium.com>
Mon, 19 Oct 2015 23:55:33 +0000 (18:55 -0500)
committerMatt Jordan <mjordan@digium.com>
Wed, 6 Jul 2016 12:22:46 +0000 (07:22 -0500)
commit1ec4f8dd003b92c262a33f6e91c3dc538681bae5
tree88270af3b11b26733805d6f7636a63054cf596ae
parentac6824e4c32c49b8943fca85b318892ab4bb8df3
res/res_corosync: Raise a Stasis message on node join/leave events

When res_corosync detects that a node leaves or joins, it currently is
informed of this via Corosync callbacks. However, there are a few
limitations with the information presented:
(1) While we have information that Corosync is aware of - such as the
    Corosync nodeid - that information is really only useful inside of
    Corosync or res_corosync. There's no way to translate a Corosync
    nodeid to some other internally useful unique identifier for the
    Asterisk instance that just joined or left the cluster.
(2) While res_corosync is notified of the instance joining or leaving
    the cluster, it has no mechanism to inform the Asterisk core or
    other modules of this event. This limits the usefulness of res_corosync
    as a heartbeat mechanism for other modules.

This patch addresses both issues.

First, it adds the notion of a cluster discovery message both within the
Stasis message bus, as well as the binary event messages that
res_corosync uses to transmit data back and forth within the cluster.
When Asterisk joins the cluster, it sends a discovery message to the other
nodes in the cluster, which correlates the Corosync nodeid along with
the Asterisk EID. res_corosync now maintains a hash of Corosync nodeids
to Asterisk EIDs, such that it can map changes in cluster state with the
Asterisk instance that has that nodeid. Likewise, when an Asterisk
instance receives a discovery message from a node in the cluster, it now
sends its own discovery message back to the originating node with the
local Asterisk EID. This lets Asterisk instances within the cluster
build a complete picture of the other Asterisk instances within the
cluster.

Second, it publishes the discovery messages onto the Stasis message bus.
Said messages are published whenever a node joins or leaves the cluster.
Interested modules can subscribe for the ast_cluster_discovery_type()
message under the ast_system_topic() and be notified when changes in
cluster state occur.

Change-Id: I9015f418d6ae7f47e4994e04e18948df4d49b465
include/asterisk/event_defs.h
include/asterisk/stasis_system.h
main/stasis_system.c
res/res_corosync.c