Define Policies for Taskers

Host Availability Policy

In a typical network, compute servers are available around the clock while workstations are available only during the off-hours (for example, from 8pm to 8am and on weekends). This can be easily defined in the taskers file vnc.swd/taskers.tcl by adding a line like the following:
vtk_tasker_define workstation1 -resources  "VovResources::Offhours res1 res2"

In the above example, "workstation1" offers the resource list "res1 res2" during the off-hours. During the work-hours of the week, such a tasker will be suspended in the sense that it will not accept any new jobs. All jobs running at the time the suspension begins are carried out to completion.

In another scenario, a workstation is available whenever the owner is not actively using it. You can specify the following in the vnc.swd/taskers.tcl file:
vtk_tasker_define workstation1 -resources "VovResources::Workstation 5m 30m"

Here, "5m" indicates the minimum idle time required before any job is to be dispatched to "workstation1" and "30m" indicates that the tasker will not accept jobs with duration longer than 30 minutes.

Define a Custom Tasker Policy

You can define a custom policy for a tasker by adding a new procedure to the file $VOVDIR/local/taskerRes.tcl.

The following is an example of a simple procedure called MyNight for a tasker that behaves differently at night than during the day. The procedure is defined in the namespace VovResources and can be used by specifying the argument VovResources::MyNight for the option -resources of vtk_tasker_define.
# Fragment from the file $VOVDIR/local/taskerRes.tcl
namespace eval VovResources {
    namespace export MyNight
    proc MyNight { args } {
        # During the night, the tasker accepts jobs up to 1 hour.
        # During the day, the tasker accepts jobs up to 2 minutes.
        set HH [clock format [clock seconds] -format "%H"]
        regsub {^0} $HH "" HH; # Strip leading 0.
        if { $HH >= 6 && $HH < $19 } {
            vtk_tasker_set_timeleft 120
        } else {
            vtk_tasker_set_timeleft 3600
        return "@STD@"
The following should be noted:
  • The resource list for the tasker is the value returned by the procedure
  • The procedure vtk_tasker_set_timeleft n controls the maximum expected duration of jobs dispatched to the tasker. The value for n must be non negative. If the value is zero, the tasker is in the "SUSPENDED" state, that is it temporarily refuses to accept new jobs.