drmaa2_msession_get_all_jobs
- drmaa2_msession_get_all_jobs, Returns all visible jobs in the system
#include "drmaa2.h"
drmaa2_j_list drmaa2_msession_get_all_jobs(const drmaa2_msession monitoring_session, const drmaa2_jinfo filter);
Returns a list of all jobs of the user currently stored in Grid Engine. The job list contains also jobs not submitted in Grid Engine. Calling this function does not necessarly trigger communication with Grid Engine master since all job related information is sent from Grid Engine master process to the DRMAA2 client as soon as there are job changes in the system. Hence it is safe to call drmaa2_msession_get_all_jobs(3) in short intervalls. The monitoring session given as argument must be valid, i.e. it must be opened with drmaa2_open_mession(3) before.
The second argument defines a filter for the jobs to be returned. If NULL is used as filter, all available jobs are returned otherwise only jobs which match the given filter. The filter is based on a drmaa2_jinfo object. After allocation with drmaa2_jinfo_create(3) all fields are UNSET, i.e. no filtering is applied. When setting fields with different values than UNSET the semantic for filtering is defined as follows:
jobId
:
The job id to filter for or DRMAA2_UNSET_STRING when all job ids should match.
exitStatus
Filter allows only finished jobs with the given exit status.
terminatingSignal
Filter allows only finsihed jobs with the given termination signal.
annotation
Ignored for filtering.
jobState
Filter allows only jobs with the given job state.
jobSubState
Currently unsupported by Univa(R) Grid Engine(TM).
allocatedMachines
Filter allows all jobs which have at least one slot allocated on one of the given machines.
submissionMachine
Filter allows all jobs which are submitted on the given machine.
jobOwner
Filter allows all jobs which are owned (i.e. submitted) by the given user.
slots
Filter allows all jobs which have this amount of slots granted.
queueName
Filter allows only jobs which have at least one part running in the given queue instance.
wallclockTime
Filter allows only jobs which are running the given amount of time (in seconds) or longer.
cpuTime
Filter allows only jobs which had consumed this amount of cpu time ore more.
submissionTime
Filter allows only jobs which are submitted at or after the given time.
dispatchTime
Filter allows only jobs which are started at or after the given time on the host.
finishTime
Filter allows only jobs which are finshed at or after the given time.
Returns a newly allocated list of jobs in a drmaa2_j_list
structure or NULL in case of an error. The job list was initialized with an appropriate callback function so that drmaa2_list_free(3) frees the complete list with all job objects inside. In case of an error the error number and error message can be fetched with drmaa2_lasterror(3) and drmaa2_lasterror_text(3).
drmaa2_jinfo filter = drmaa2_jinfo_create();
drmaa2_msession monitoring_session = drmaa2_open_msession(NULL);
/* filter only for jobs which consume one slot */
filter->slots = 1;
if (ms != NULL) {
drmaa2_j_list job_list = drmaa2_msession_get_all_jobs(monitoring_session, filter);
if (job_list == NULL) {
/* handle error */
drmaa2_string error = drmaa2_lasterror_text();
fprintf(stderr, "Error during fetching the job list from the monitoring session: %s\n", error);
drmaa2_string_free(&error);
} else {
int i;
size_t size = drmaa2_list_size(job_list);
fprintf(stdout, "There are %lld jobs in the system with 1 slot:\n", size);
for (i = 0; i < size; i++) {
drmaa2_j job = (drmaa2_j) drmaa2_list_get(job_list, i);
if (drmaa2_j_get_id(job) != NULL) {
fprintf(stdout, "Job with id %s.\n", (char *) drmaa2_j_get_id(job));
} else {
fprintf(stdout, "Job has unknown id.\n");
}
}
drmaa2_list_free(&job_list);
}
...
}
drmaa2_jinfo_free(&filter);
drmaa2_open_msession(3), drmaa2_close_msession(3), drmaa2_msession_free(3), drmaa2_msession_get_all_jobs(3), drmaa2_msession_get_all_queues(3), drmaa2_msession_get_all_machines(3), drmaa2_list_free(3), drmaa2_jinfo_create(3), drmaa2_jinfo_free(3), drmaa2_j_get_id(3) )
Copyright Univa Corporation 2013