Top
Systemwalker Operation Manager  Reference Guide
FUJITSU Software

16.3.3 Job Submission API

This section explains the job submission API (Mp_SubmitJob).

Synopsis

[Windows]

#include "f3cuapi.h"
long Mp_SubmitJob (char *rhost,
           char *submitinf, 
           char *env[ ],
           char *jobhost,
           char *jobname,
           long *jobno)

[UNIX]

#include "mjesapi.h "
int Mp_SubmitJob (char *rhost,
          char *submitinf,
          char *env[ ],
          char *jobhost,
          char *jobname,
          int *jobno)

Description

This API submits a job to the server where Systemwalker Operation Manager has been installed. If the submission of a job completes successfully, the job submission host name, job name and job number identifying the job will be returned.

Parameters

rhost

Specify NULL here.

submitinf

Specify the arguments of the qsub command as the job submission information. The arguments can be described in the same way as specifying options and operands in the qsub command.

See qsub Job Submit Command for further details on the Synopsis of arguments in the 7.20 qsub Job Submit Command.

env[ ]

Specify the environment variable to be inherited by the job. When there is no need for inheritance, specify NULL.

This environment variable will only be inherited by the job if you specify "-x" in the submitinf option.

jobhost

If the submission of a job completes successfully, the job submission host name identifying the job will be returned. This name can be used as information identifying the job.

jobname

If the submission of the job completes successfully, the job name determined by Job Execution Control will be returned. This name can be used as information identifying the job. If you specify the job name during the job submission, then the job is submitted with that name. However, when the job name is omitted and is declared in the job file, you can find the job name of the submitted job by checking the job name that was returned to the area specified in this parameter.

jobno

If the submission of a job completes successfully, the job number assigned by Job Execution Control will be returned. This number can be used as information identifying the job. By using this job number, you can manipulate the job.

Return Values

Return Value

Meaning

Action

0

The job was submitted normally.

-

-1

A system error occurred.

Collect "Job Execution Control" information with the maintenance information collection tool and contact a Fujitsu SE.

-1000 or less

Submission processing was aborted because an error was detected in Job Execution Control. Error messages can be obtained using the error message acquisition API.

Use the error message acquisition API to obtain the error message and take whatever action is required.

Caution

When the argument is pointing to an invalid address, this function ends abnormally, and no operations will be defined.

Program Example

Below is an example program of the job submission API

[Windows]

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "f3cuapi.h"

int main (int argc, char **argv)
{
        char submitinf[1024+1];
        char jobhost [64+1];
        char jobname [64+1];
        long jobno = 0;
        long rtn = 0;
        char errmsg [256+1];

        /*
         * initialization working area
         */
        memset(submitinf, 0x00, sizeof(submitinf));
        memset(jobhost, 0x00, sizeof(jobhost));
        memset(jobname, 0x00, sizeof(jobname));
        memset(errmsg, 0x00, sizeof(errmsg));

         if (argc != 4) {
                printf ("Usage: %s <queue-name> <job-name> <job-file>\n", argv[0]);
                return (1);
        }

        /*
         * set submitinf 
         */
        sprintf(submitinf,"-q %s -j %s %s",argv[1],argv[2],argv[3]);

        /*
         * call Mp_SubmitJob() API 
         */
        rtn = Mp_SubmitJob (NULL, submitinf, NULL, jobhost, jobname, &jobno);

        /*
         * check return code of Mp_SubmitJob() API 
         */
        if (rtn == 0) {
                printf ("Job %s(%d.%s) was submitted.\n", jobname, jobno, jobhost);
                return (0);
        } else if (rtn == -1) {
                printf ("GetLastError() is %d.\n", GetLastError());
        } else if (rtn <= -1000) {
                printf ("Error code is %d.\n", rtn);
                Mp_GetMJESerror (errmsg);
                printf ("errmsg = %s\n", errmsg);
        }
        return (1);
}

[UNIX]

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "mjesapi.h"

int main (int argc, char **argv)
{
        char submitinf[1024+1];
        char jobhost [64+1];
        char jobname [64+1];
        int jobno = 0;
        int rtn = 0;
        char errmsg [256+1];

        /*
         * initialization working area
         */
        memset(submitinf, 0x00, sizeof(submitinf));
        memset(jobhost, 0x00, sizeof(jobhost));
        memset(jobname, 0x00, sizeof(jobname));
        memset(errmsg, 0x00, sizeof(errmsg));

        if (argc != 4) {
                printf ("Usage: %s <queue-name> <job-name> <job-file>\n", argv[0]);
                return (1);
        }

        /*
         * set submitinf
         */
        sprintf(submitinf,"-q %s -j %s %s",argv[1],argv[2],argv[3]);
        
        /*
         * call Mp_SubmitJob() API
         */
        rtn = Mp_SubmitJob (NULL, submitinf, NULL, jobhost, jobname, &jobno);

        /*
         * check return code of Mp_SubmitJob() API
         */
        if (rtn == 0) {
                printf ("Job %s(%d.%s) was submitted.\n", jobname, jobno, jobhost);
                return (0);
        } else if (rtn == -1) {
                printf ("errno is %d.\n", errno);
        } else if (rtn <= -1000) {
                printf ("Error code is %d.\n", rtn);
                Mp_GetMJESerror (errmsg);
                printf ("errmsg = %s\n", errmsg);
        }
        return (1);
}