System information

specify the preferred order for database connections in case one fails. In func_odbc, you
can even specify different servers for reading data and writing data through the dialplan
functions you create. All of this flexibility allows you to provide a system that works
well for your business.
External programs can also be used for controlling failover between systems. The pen
application (http://siag.nu/pen/) is a load balancer for simple TCP applications such as
HTTP or SMTP, which allows several servers to appear as one. This means Asterisk
only needs to be configured to connect to a single IP address (or hostname); the pen
application will take care of controlling which server gets used for each request.
Asterisk and Distributed Device States
Device states in Asterisk are important both from a software standpoint (Asterisk might
need to know the state of a device or the line on a device in order to know whether a
call can be placed to it) and from a user’s perspective (for example, a light may be turned
on or off to signify whether a particular line is in use, or whether an agent is available
for any more calls). From the viewpoint of a queue, it is extremely important to know
the status of the device an agent is using in order to determine whether the next caller
in the queue can be distributed to that agent. Without knowledge of the device’s state,
the queue would simply place multiple calls to the same endpoint.
Once you start expanding your single system to multiple boxes (potentially in multiple
physical locations, such as remote or satellite offices), you will need to distribute the
device state of endpoints between the systems. The kind of implementation that is
required will depend on whether you’re distributing them between systems on the same
LAN (low-latency links) or over a WAN (higher-latency links). We’ll discuss two device
state distribution methods in this section: OpenAIS for low-latency links, and XMPP
for higher-latency links.
Distributing Device States over a LAN
The OpenAIS implementation (http://www.openais.org/doku.php) was first added to
Asterisk in the 1.6.1 branch, to enable distribution of device state information across
servers. The addition of OpenAIS provided great possibilities for distributed systems,
as device state awareness is an important aspect of such systems. Previous methods
required the use of GROUP() and GROUP_COUNT() for each channel, with that information
queried for over DUNDi. While this approach is useful in some scenarios (we could
use this functionality to look up the number of calls our systems are handling and direct
calls intelligently to systems handling fewer calls), as a mechanism for determining
device state information it is severely lacking.
OpenAIS did give us the first implementation of a system that allows the state of devices
and message waiting indications to be distributed among multiple Asterisk systems (see
Figure 22-6). The downside of the OpenAIS implementation is that it requires all the
496 | Chapter 22:Clustering