Kill Script

Stop execution of the specified jobs in the DRM system.

This page discusses:

Description

The kill wrapper script should instruct the DRM system to kill the jobs identified by the IDs given. 3DOrchestrate writes the command arguments and command output to the 3DOrchestrate Distribution Server log file.

Syntax

<killPath> drmjobid1 ... drmjobidn

where:

<killPath> Command specified by the property fiper.system.<drm-name>.killCommandScriptPath (in the SMAExeServer.properties file).
drmjobid1 ... drmjobidn

List of unique job IDs (strings) that have been returned by the submit script.

Return

The kill script should return JavaScript Object Notation (JSON) in the following format:

[
{drmjobid:"<DRM_JOB_ID>",jobstatus:"<DRM_JOB_STATUS>",message:"<MESSAGE>"},
{drmjobid:"<DRM_JOB_ID>",jobstatus:"<DRM_JOB_STATUS>",message:"<MESSAGE>"},
...
{drmjobid:"<DRM_JOB_ID>",jobstatus:"<DRM_JOB_STATUS>",message:"<MESSAGE>"}
]

where:

<DRM_JOB_ID> ID string of the job.
<DRM_JOB_STATUS>

Job status: SUCCESS, FAILED, or UNKNOWN.

When <DRM_JOB_STATUS> is SUCCESS, 3DOrchestrate cancels the 3DOrchestrate job and records the DRM message in the job log.

When <DRM_JOB_STATUS> is FAILED, 3DOrchestrate cancels the 3DOrchestrate job and records the DRM ERROR/failure log message in the job log.

When <DRM_JOB_STATUS> is UNKNOWN, 3DOrchestrate cancels the 3DOrchestrate job and records the DRM ERROR log message in the job log.

<MESSAGE> Any message from the DRM system.
Note: If the kill script is erroneous, 3DOrchestrate fails the kill operation.

Example

An example Perl script for the kill command for IBM Spectrum LSF is shown below.

#!/usr/bin/env perl
#
#SCRIPT ARGUMENTS:  
#    $0 drmjobid1 ... drmjobidN
#
#DEBUG OUTPUT: 
#    written to catalina.out when fiper.system.<DRM_NAME>.debugLog=true
#
#SCRIPT OUTPUT
#
#  JSON:
#   [
#    {  drmjobid: "<DRM_JOB_ID>", jobstatus:"<DRM_JOB_STATUS>", message:  "<MESSAGE>"  },
#    {  drmjobid: "<DRM_JOB_ID>", jobstatus:"<DRM_JOB_STATUS>", message:  "<MESSAGE>"  },
#    {  drmjobid: "<DRM_JOB_ID>", jobstatus:"<DRM_JOB_STATUS>", message:  "<MESSAGE>"  }
#   ]
#  where:
#       <DRM_JOB_ID>     =    DRM Job ID
#       <DRM_JOB_STATUS> =    DRM Job Status, Status could be any of the following:
#	                              SUCCESS
#	                              FAILED
#       <MESSAGE>        =    DRM message

use strict;
use JSON;

my %jobInfo;

open(TMP,">/tmp/bkill_debug.$$.out");
print TMP "debug args:  " . join(",",@ARGV) . "\n";
close TMP;

open(BKILL, "bkill @ARGV 2>&1 |");
while(<BKILL>) {
   chomp;
   if (/Job\s+\<(\d+)\>\s+is\s+being\s+terminated/) {
        my $jobID = $1;
        $jobInfo{$jobID}{'drmjobid'} = $jobID;
        $jobInfo{$jobID}{'jobstatus'} = "SUCCESS";
        $jobInfo{$jobID}{'message'} = "Job is being terminated.";
   }   
   if (/Job\s+\<(\d+)\>\:\s+(.*)/) {
        my $jobID = $1;
        my $message = $2;
        $jobInfo{$jobID}{'drmjobid'} = $jobID;
        $jobInfo{$jobID}{'jobstatus'} = "FAILED";
        $jobInfo{$jobID}{'message'} = "$message";
   }   
}
close BKILL;

my $json = "\[";
foreach my $id (keys %jobInfo) {
   $json .= to_json \%{$jobInfo{$id}};
   $json .= ",";
}
$json =~ s/\,$//;
$json .= "\]";
print "$json\n";

exit 0;