Utilities for dealing with clusters of loosely-coupled systems.
Many enterprise applications will be run, rather than on a single
computer, in a loosely-coupled cluster of machines. A set of several
web-servers, for example. We have found the
clusterit tools to be very useful
in such situations. Clusterit, inspired by the tools provided in IBM's
PSSP, is simple to set up and use, if somewhat quirky in implementation.
PEAK supports the cluster definition file used by Clusterit-2.0, providing
the information contained therein via the properties mechanism. Note
that you don't have to have the Clusterit tools installed to make use of
this, or for it to be useful. Nor will anything break if you make use
of these properties in your application and they haven't been set up.
In the abscence of a cluster definition file, PEAK will behave as if
the local hostname was listed in the cluster file, without being part
of a group. In other words, in the abscence of other information, the
cluster consists of just the local machine.
Then environment variable
CLUSTER (or, in PEAK's case, the property
peak.running.cluster._filename, if it exists, else
__main__.CLUSTER, which falls back to
specifies a file defining the cluster. A cluster may be subdivided into
groups. In PEAK it is allowable for groups to have overlapping
membership. Let's look at a fairly complicated example:
PEAK treats this file as if it had seven groups. The existance and
memberships of the first four groups,
should be clear. A "lump" is a group defined in terms of other groups or
lumps. In this case the group
weird contains the union of the groups
prime. Note that one.baz.com is a member of both qux and prime.
weird will contain it only once, however -- duplicates are
removed automatically. Another group,
__orphans__, contains any hosts
that were listed at the beginning of the file before any
Lastly the group
__all__ contains all hosts listed in the file.
Each group is exported as a property
peak.running.cluster.groups.prime) with its value a tuple of
strings of the hostnames of the members.
peak.running.cluster.groups will contain a tuple of strings
naming each group except the
__all__ groups (that
is, it names all the explicitly-created groups).
peak.running.cluster.hosts.<hostname> will be a tuple of
strings of the names of all groups the host belongs to (except the
__all__ group). For example, in the example above,
("odd", "prime", "qux", "wierd").
peak.running.cluster.hosts is a shortcut for
peak.running.cluster.groups.__all__, listing all hosts in the cluster.
Finally, the property
peak.running.cluster.hostname is a string with
the local machine's network hostname (per
peak.running.cluster.shortname is the the same, truncated after the
".", if any.
from peak.api import *
from peak.util.Graph import Graph
from sets import Set
parseCluster ( prefix, file )