ControlTier Inc. > CTL
 
Font size:      

Dispatch-Command

Description

dispatch-command iterates over the results of a context selector and calls the named command with selected paramaters.

Selectors are specified as nested elements, you must specify exactly one. The selectors are any data type that implements the IDispatchContextSelector java interface.

Attributes

AttributeDescriptionRequired
nameWorkflow namedefaults to ${command.name}
macroName of macro to execute for command. If a macro name is specified but has not been declared it is ignored.Defaults to dispatch-command-macro
requirematchRequires one or more matches. The task will fail if no match is made.true (default)
strategyExecution strategylocaldispatch or nodedispatch
threadcountNumber of threads to execute the workflowAny integer greater than 0

Parameters specified as nested elements

errorhandler

This task can optionally use an errorhandler. If an error occurs during the course of the execution, the errorhandler can be configured to handle the exception according to your specification.

selector

This task requires an IDispatchContextSelector nested element. This datatype is responsible for selecting matching object contexts. that will be the target of the dispatched command. Each implementation of the IDispatchContextSelector can lookup objects using its own algorithm. The task iterates over the matched objects and for each one executes the specified. command. One selector must be nested inside a <context></context> tag set.

The table below describes the standard attributes and elements common to all selectors:

AttributeDescriptionRequired
sortkeyThe sort key. All selectors support type and name sort keys.true
sortorderSort order (ascending or descending).Defaults to ascending.
depotProject depot.true.

include element

Selectors can use an include tag to specifie filter patterns to the selector:

nameObject name regexyes
typeType name regexyes
Example
 <include name=".*" type="Managed-[A-Z]+"/>

The table below describes the three existing selectors:

select-objectsSelects from locally installed objects
     <context>
	<select-objects sortkey="name" sortorder="ascending" depot="${context.depot}">
	  <include name=".*" type="Managed-Entity"/>
	</select-objects>
     </context>
	    
select-deploymentsSelects from registered objects in deployments.properties
     <context>
	<select-deployments sortkey="name" sortorder="ascending" depot="${context.depot}">
	  <include name="me[0-9]+" type="Managed-Entity"/>
	</select-deployments>
     </context>
	    
select-dependenciesSelects from object dependency data
This selector supports an open ended set of sortkey values typicaly of dependency data. The selector looks at the fourth string in the given the format: relationtype.type.name.sortkey. For example, "startup-rank" can be used as the sort key for this property: deployment.Service.me1.startup-rank.
    <!-- Define dependency data in the current command context -->
    <!-- format: relationtype.type.name.sortkey = value -->

    <property name="deployment.Service.me1.startup-rank" value="1"/>
    <property name="deployment.Service.me2.startup-rank" value="2"/>

    <context>
	<select-dependencies sortkey="startup-rank" depot="${context.depot}"
			     sortorder="descending"
			     relationtypes="deployment" source="context">
	  <include name="me.*" type="[^.]*"/>
	</select-dependencies>
    </context>
	  

Examples

Example: select-dependencies

This example shows the use of the select-dependencies selector to dispatch the Install command using "package-install-rank" as the sort key:

	<!-- define three package object dependencies -->
	<property name="package.war.headlines-1.0.package-install-rank" 
	    value="3"/>
	<property name="package.jar.hncore-1.2.package-install-rank" 
            value="2"/>
	<property name="package.zip.jakarta-tomcat-4.1.31.package-install-rank" 
            value="1"/>

	<!-- 
	  ** select the objects based on include patterns 
	  ** and sort by package-install-rank 
	  -->
	<dispatch-command name="Packages-Install" requirematch="false">
	  <command name="Install"/>
	  <arg line=""/>
	  <contexts>
            <select-dependencies source="context" 
	         sortkey="package-install-rank" sortorder="ascending"
		 depot="${context.depot}"
		 >
	         <include name=".*" type="(?:war|jar|zip)"/>
	       </select-dependencies>
	  </contexts>
	</dispatch-command>
      

Example: select-deployments

This example shows the use of the select-deployments selector to dispatch the Install command:

deployments.properties content:

object-deployment.default.SimpleAntBuilder.tutorial=build-1
object-deployment.default.SimpleApacheService.tutorial=web-1
object-deployment.default.SimpleTomcatService.simple=app-1
object-deployment.default.Site.simple=adminhost
object-deployment.default.Updater.simple=adminhost
      
	<dispatch-command name="Deploy" requirematch="false">
	  <command name="Deploy"/>
	  <arg line=""/>
	  <contexts>
            <select-deployments 
	         sortkey="type" sortorder="ascending"
		 depot="${context.depot}"
		 >
	         <include name=".*" type="(?:SimpleTomcatService|SimpleApacheService)"/>
	       </select-deployments>
	  </contexts>
	</dispatch-command>