]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res/res_corosync: Raise a Stasis message on node join/leave events 81/3181/2
authorMatt Jordan <mjordan@digium.com>
Mon, 19 Oct 2015 23:55:33 +0000 (18:55 -0500)
committerMatt Jordan <mjordan@digium.com>
Wed, 13 Jul 2016 14:11:37 +0000 (09:11 -0500)
commitf12311ee696e4a623a4160aa0c2a83712088b5d3
treed0a73289b9ae41a2eecc6ad3eef0caee799c9e4d
parent73d8cb587d6515b707c9cafe334e18fbd7c24905
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