Tagging

It might be desirable to start given processes on specific hosts, and not on others. For example, imagine a process that scans a database table periodically, performs an action based on the data that is retrieved, and then deletes that data. Multiple such processes acting in parallel will pose a concurrency issue: the action will be performed redundantly. Thus, in such a case, one would want to make sure that this process is executed on a single host.

Basics

To support executing processes on a subset of hosts in a cluster, Corus has a so-called “tagging" feature: a tag is an arbitrary string that is used to determine if a process can be executed by a given corus instance. Concretely, it works has follows:

  1. The Corus descriptor may be enriched with tags: both the distribution and process elements of the descriptor support a tags attribute: the value of the attribute takes a comma-delimited list of tokens, each corresponding to an actual tag.
  2. A Corus server itself may be attributed with given tags: the conf command of the command-line interface may be used to add, list, and remove tags to/from a Corus server.
  3. Prior to starting a process, the Corus server will determine if the tags of that process match the ones it has configured: if the process and its distribution have no tags, the process is started; if all the tags assigned to a process and its distribution are contained in the set of tags of the server, the process is started; if all the tags assign to a process and its distribution are not contained in the set of tags of the server, the process is NOT started.

The example descriptor below shows how to configure tags: they can be specified as a comma-separated list on the <distribution> element:

<distribution xmlns="http://www.sapia-oss.org/xsd/corus/distribution-5.0.xsd" 
  name="id-generator" version="1.0" tags="singleton">
  <process name="server" 
           maxKillRetry="3" 
           shutdownTimeout="30000" 
           invoke="true">
    <java mainClass="org.myapp.IDGenerator"
	profile="test" vmType="server">
      <xoption name="ms" value="16M" />    
    </java>
  </process>  
</distribution>

The can also be specified on a per-process basis:

<distribution xmlns="http://www.sapia-oss.org/xsd/corus/distribution-5.0.xsd" name="id-generator" version="1.0">
  <process name="server" 
           maxKillRetry="3" 
           shutdownTimeout="30000" 
           invoke="true" tags="singleton">
    <java mainClass="org.myapp.IDGenerator"
	profile="test" vmType="server">
      <xoption name="ms" value="16M" />    
    </java>
  </process>  
</distribution>

At runtime, the Corus server will determine the tags of a process by merging the tags at the process level with the ones at the distribution level: it is thus the union of these tags that is used for validating against the server's own tags, according to the previously defined algorithm.

Remote Tag Update

The Corus command-line can be used to add, remove and list the tags of a Corus server. The following provides examples (see the documentation of the conf command – by typing man conf) for more details.

1) Adding tags

conf add -t someTag,someOtherTag

2) Listing tags

conf ls -t

3) Removing tags

conf del -t *