Dynamic Host Matching

By default, hostnames are associated with nodes directly, when the node is specified:

node = CRNetworkNode("hostname")

This arrangement is the easiest to create; but it can be difficult to manage if the list of hosts participating in a Chromium session are not known when the config script is written.

As a config script is a fully functional Python script, it might be possible to use the full power of Python to make appropriate queries and determine the host names when the config script is run; this is one way to create a dynamic configuration that still appears to have well-defined static hostnames as far as Chromium is concerned.

It is also possible to use true dynamic hosts within Chromium. By using Chromium's own dynamic host matching, Chromium can automatically associate connecting servers with appropriate nodes, freeing the config file of the need to know all the server host names in advance.

Dynamic Host Syntax in Config Files

The syntax used to specify dynamic hosts is an extension of the syntax used to specify "normal" static hosts (or rather, static host syntax is a special case of the more general host syntax). For example:

node = CRNetworkNode("server1", "dynamic")

can be used to specify a dynamic host called server1. Note that server1 does not refer to a host named "server1"; it serves as a variable, or placeholder. When the mothership receives a connection from an appropriate process (in this case, a crserver process), the dynamic host reference server1 will be resolved to the name of whatever host connected to the mothership. From that point on, all dynamic nodes with a specified host identifier of "server1" will behave as though they were static nodes specified with the resolved hostname.

So if a second node were specified in the same way:

node2 = CRNetworkNode("server1", "dynamic")

the same host name has been specified, so a second crserver must connect from the same machine in order to be associated with the node.

More flexibly, if the second node were declared with a unique host identifier:

node2 = CRNetworkNode("server2", "dynamic")

then any connecting server host (including the same host that resolved server1) could be associated with the node. In other words, a single host identifier can only be associated with a single host name; but the same host name may be associated with multiple host identifiers, depending only on which servers connect to the mothership.

The easiest way, for example, to specify nodes in a config file that will dynamically match to whatever crserver processes connect to the mothership would be with something like:

for serverNumber in range(NUM_SERVERS):
    node = CRNetworkNode("server%d" % serverNumber, "dynamic")
    # configure the node, SPUs, etc.
    ...
    cr.AddNode(node)

Constraining Dynamic Matches

If you need more control over which servers are associated with which nodes, you can use additional constraint tests. In fact, all nodes have constraint tests; the "dynamic" test is a special case of a constraint test that matches any connecting host name. And the default constraint test, used for static node definitions, is called "name"; it matches any connecting host name that represents the same host (i.e. has the same network address) as the corresponding host identifier.

In general, constraint tests take a corresponding constraint argument (although the argument is not used for the "dynamic" and "name tests). Constraints are usually specified in the node constructor:

node = CRNetworkNode(hostIdentifier, constraintTest, constraintArg)

The following constraint tests are provided:

Constraint Test Constraint Argument Description Example
name None Matches only connecting host names that represent the same host as the specified host identifier. node = CRNetworkNode("mymachine")
dynamic None Matches any connecting host name. node = CRNetworkNode("server1", "dynamic")
regex pattern_string Matches connecting host names that match the regular expression specified in pattern_string. node = CRNetworkNode("server1", "regex", "abc[0-9]*")
pattern compiled_pattern Matches connecting host names that match the compiled regular expression specified in compiled_pattern. pattern = re.compile("abc[0-9]*")
node = CRNetworkNode("server1", "pattern", pattern)
regex_full pattern_string Matches connecting host names whose fully qualified domain names match the regular expression specified in pattern_string. node = CRNetworkNode("server1", "regex", ".*\.psc\.edu")
pattern_full compiled_pattern Matches connecting host names whose fully qualified domain names match the compiled regular expression specified in compiled_pattern. pattern = re.compile(".*\.psc\.edu")
node = CRNetworkNode("server1", "pattern_full", pattern)

Multiple Constraints

All nodes have at least one constraint associated with them. It is possible for nodes to have additional constraints added, with the AddConstraint(constraintTest, constraintArg) node method:

node = CRNetworkNode("server1", "regex", "abc[0-9]*")
node.AddConstraint("regex_full", ".*\.psc\.edu")