Clustering
Clustering (Yate 2)
This module allows building clusters of servers for a single domain. All nodes are equivalent and they can be addressed from within the cluster by their Node Name.
When a user registers (on any protocol) the name of the server it registered to is added in front of the user's location. Later, when a call is to be made to an user the call will be initiated from the same server the user registered to. This avoids problems with firewalls and NAT and with calls accepted only from the registrar the endpoint is connected to.
The module works by selectively altering resource names in Yate's messages. Relevant parameters are prefixed with the node name of the server that should handle them.
When a resource is to be used (like for target of a call) the node name in the resource is compared with the local node name. If they are the same the call is for the local server so the cluster prefix and node name are simply removed from the resource name. If the resource is remote (node name is not empty and is not the local node name either) the call is forwarded inside the cluster to the desired server.
Additionally, cluster nodes can be allocated at call time by specifying * as node name. A cluster.locate message is issued to locate the node serving a specific resource (conference room, parking orbit, etc.) or optionally to allocate a new one
The following messages are examined:
- user.register - to add node name to the user's location so it will be known which server it registered with
- call.execute - so calls are forwarded to the server that can place them to the final target
- call.route - to detect internal calls within the cluster
[general] ; Global settings of the clustering module ; enabled: boolean: Enable clustering module operation ;enabled=true if regexp and callto are set, false if any of them is empty ; prefix: string: Prefix used for cluster resources ;prefix=cluster ; regexp: string: Regular expression describing node name match rules ;regexp= ; callto: string: Template for forwarding the call to target node ;callto= ; locate: string: Message used for locating dynamic resources on cluster nodes ;locate=cluster.locate [priorities] ; Handler priorities for each message ; call.route: int: Priority of route message handler (on target node) ;call.route=50 ; call.execute: int: Priority of execute message handler (on source node) ;call.execute=50 ; user.register: int: Priority of registration message handler (on registrar) ;user.register=50
Note: the prefix must be the same on all nodes in a cluster. It can be set to empty, in that case cluster resource names will start with a slash, like: /nodename/sip/sip:number@host
Example of regexp and callto settings
[general] regexp=^[[:alnum:].-]\+$ callto=sip/sip:cluster/${called}@\0.dom.ain
In the above configuration suppose that:
- We are node node1
- A call comes in for number 87654321
- Routing returns cluster/node2/sip/sip:321@192.168.0.2;user=phone
The prefix equals cluster/ but the node is not local. The node name node2 is found matching against the regexp so the callto is evaluated by replacing parameters and matched strings.
- The call is delivered to sip:cluster/321@node2.dom.ain
- On node2 the call can be routed using a regexroute.conf rule like:
[default] ^cluster/=${sip_x-callto};billid=${sip_x-billid}