source: experiments/5_3_job_status/a.c @ 16

Revision 16, 1.7 KB checked in by mmatloka, 14 years ago (diff)

add experiments

RevLine 
[16]1#include <stdio.h>
2#include <stdlib.h>
3
4#include <llapi.h>
5#include <unistd.h>
6#include <fcntl.h>
7#include <time.h>
8#include <string.h>
9#include <errno.h>
10
11#include <sys/types.h>
12#include <sys/stat.h>
13
14#define CHAR_BUFFER 256
15#define FILE_LENGTH 1024
16
17int main(int argc, char *argv[])
18{
19        char * name=NULL;
20        enum StepState step_state;
21        int rc;
22        int  obj_count,err_code;
23        LL_element * job=NULL,*data=NULL,*step=NULL;
24        char **host_list;
25       
26       
27        job = ll_query(JOBS);
28        if (!job) {
29                printf("Query JOBS: ll_query() returns NULL.\n"); exit(1);
30        }
31       
32        host_list = (char **)malloc(2*sizeof(char *));
33        host_list[0] = argv[1];//"l4f1n03.16525";
34        host_list[1] = NULL;
35
36        rc = ll_set_request(job,QUERY_JOBID,host_list,ALL_DATA);
37        if (rc) {
38                printf("Query JOBS: ll_set_request() return code is non-zero.\n"); exit(1);
39        }
40       
41
42        data = ll_get_objs(job, LL_SCHEDD, NULL, &obj_count, &err_code);
43        if (data == NULL) {
44                printf("Query JOBS: ll_get_objs() returns NULL. Error code = %d\n", err_code);
45        }
46        //printf("Number of jobs objects returned = %d\n", obj_count);
47
48        name=(char*)malloc(256*sizeof(char *));
49
50    ll_get_data(data, LL_JobGetFirstStep, &step);   
51
52        while(data) {
53                int n;
54                rc = ll_get_data(data, LL_JobName,&name);
55
56                if (!rc) {
57                        printf("Job name: %s\n",name);
58                        free(name);
59                }
60                       
61                        rc = ll_get_data(data, LL_JobStepCount, &n);
62                        printf("Job count: %d\n",n);
63                //free(step_state);
64                rc = ll_get_data(step, LL_StepState,&step_state);
65                if (rc) {
66                        printf("Query MACHINES: ll_get_data() return code is non-zero.\n");
67                        exit(1);
68                }
69
70               
71                if(!rc) {
72                        printf("State: %d\n",step_state);
73                       
74                }               
75
76                data = ll_next_obj(job);
77        }
78       
79
80       
81
82        ll_free_objs(job);
83        ll_deallocate(job);
84
85
86        return 0;
87}
Note: See TracBrowser for help on using the repository browser.