Use Additional Jobclass Directories

If you have an extensive Accelerator Plus setup, you may wish to manage jobclasses in a more-centralized way than placing their definitions into each vncNNN.swd/jobclass directory. The following example shows one way to accomplish this.

For this example, we want to implement a system where jobclasses are searched for first in the specific Accelerator queue, then in a site-specific directory, and finally in a global area.

We implement this by using the regular queue-specific directory, and two symlinks called jobclass_site, and jobclass_global under vncNNN.swd that resolve to the site-specific and global directories for jobclasses. You will need to arrange for the jobclass directories to be available and up to date at each site.

Additionally, some generic code is shown that may be dropped into vncNNN.swd to automatically compute the value of the VOV_JOBCLASS_DIRS environment variable.

Code to compute VOV_JOBCLASS_DIRS:
# This is file jcdirs.tcl
# NOTE: vovwait4server runs in vtclsh, and sources setup.tcl
# so vovGetProjectFileName may not be used here

# If env-var VNCSWD is set, use its value, it is much simpler
if { [info exists env(VNCSWD)] && [file isdirectory $env(VNCSWD)] } {
   set cfgdir [file join $env(VNCSWD) $env(VOV_PROJECT_NAME).swd]
} else {
    # compute path to the .swd directory
    # setup.tcl needs to be source-able in vtclsh, must use exec
    if { [catch {set sdp [exec vovsh -x {puts [vtk_server_dir -physical]}]} em] } {
        VovError "determining config directory -- $em"
    } else {
        set cfgdir [file join $sdp "$env(VOV_PROJECT_NAME).swd"]
    }
}

set jcdirs {}
foreach dn {jobclass jobclass_site jobclass_global} {
    set tdir [file join $cfgdir $dn]
    if { [file isdirectory $tdir] } {
        lappend jcdirs $tdir
        VovMessage "added jobclass dir '$tdir'" 3
    } else {
        VovMessage "non-existing jobclass dir '$tdir'" 3
    }
}
if { $jcdirs != {} } {
    setenv VOV_JOBCLASS_DIRS [join $jcdirs ":"]
}
The VOV_JOBCLASS_DIRS need to be set in all Accelerator-related processes. Sourcing the above script from vncNNN.swd/setup.tcl will arrange this for vovserver and the vovtaskers, which also inherit their environment from a shell that has sourced setup.tcl. To have it set in the clients, source it from vnc_policy.tcl, which is sourced by the top-level vnc command. The following example places the drop-in code in vncNNN.swd/scripts/:
# This is file jcdirs.tcl
# source the drop-in code for VncJobClassSearchPath{}
# compute the value of VOV_JOBCLASS_DIRS
if { [info exists env(VNCSWD)] } {
    set jcsetup $env(VNCSWD)/$env(VOV_PROJECT_NAME).swd/scripts/jcdirs.tcl
}
if { [file readable $jcsetup] } {
    if { [catch {source $jcsetup} smsg] } {
        VovError "jcsetup error -- $smsg"
    } else {
        VovMessage "jcsetup OK" 3
    }
} else {
    VovError "jcsetup not found -- $jcsetup"
}