From 0b2d0570791cbb6f5715631c607b19b13cdde48a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Mula=C4=8D?= Date: Thu, 29 Mar 2007 14:42:52 +0000 Subject: [PATCH] update printstat() to support all new jobtypes --- org.glite.lb.server/examples/ws_jobstat.c | 191 +++++++++++++++++------------- 1 file changed, 110 insertions(+), 81 deletions(-) diff --git a/org.glite.lb.server/examples/ws_jobstat.c b/org.glite.lb.server/examples/ws_jobstat.c index e6f2cf9..2336b46 100644 --- a/org.glite.lb.server/examples/ws_jobstat.c +++ b/org.glite.lb.server/examples/ws_jobstat.c @@ -117,92 +117,121 @@ int main(int argc,char** argv) static void printstat(edg_wll_JobStat stat, int level) { - char *s, *j1, *j2, ind[10]; - int i; - time_t t; + char *s, *j1,*j2, ind[10]; + int i; - for (i=0; i < level; i++) - ind[i]='\t'; - ind[i]='\0'; - - s = edg_wll_StatToString(stat.state); + for (i=0; i < level; i++) + ind[i]='\t'; + ind[i]='\0'; + + s = edg_wll_StatToString(stat.state); /* print whole flat structure */ - printf("%sstate : %s\n", ind, s); - printf("%sjobId : %s\n", ind, j1 = edg_wlc_JobIdUnparse(stat.jobId)); - printf("%sowner : %s\n", ind, stat.owner); - printf("%sjobtype : %s\n", ind, (stat.jobtype ? "DAG" : "SIMPLE") ); - printf("%sparent_job : %s\n", ind, - j2 = edg_wlc_JobIdUnparse(stat.parent_job)); - if (stat.jobtype) {; - printf("%sseed : %s\n", ind, stat.seed); - printf("%schildren_num : %d\n", ind, stat.children_num); - printf("%schildren :\n", ind); - if (stat.children) - for (i=0; stat.children[i]; i++) - printf("%s\tchildren : %s\n", ind, stat.children[i]); - printf("%schildren_states :\n", ind); - if (stat.children_states) - for (i=0; stat.children_states[i].state; i++) - printstat(stat.children_states[i], level+1); - printf("%schildren_hist :\n",ind); - if (stat.children_hist) - for (i=1; i<=stat.children_hist[0]; i++) - printf("%s%14s %d\n", ind, edg_wll_StatToString(i-1),stat.children_hist[i]); - } - printf("%scondorId : %s\n", ind, stat.condorId); - printf("%sglobusId : %s\n", ind, stat.globusId); - printf("%slocalId : %s\n", ind, stat.localId); - printf("%sjdl : %s\n", ind, stat.jdl); - printf("%smatched_jdl : %s\n", ind, stat.matched_jdl); - printf("%sdestination : %s\n", ind, stat.destination); - printf("%snetwork server : %s\n", ind, stat.network_server); - printf("%scondor_jdl : %s\n", ind, stat.condor_jdl); - printf("%srsl : %s\n", ind, stat.rsl); - printf("%sreason : %s\n", ind, stat.reason); - printf("%slocation : %s\n", ind, stat.location); - printf("%sce_node : %s\n", ind, stat.ce_node); - printf("%ssubjob_failed : %d\n", ind, stat.subjob_failed); -// printf("%sdone_code : %d\n", ind, edg_wll_done_codeToString(stat.done_code)); - printf("%sdone_code : %d\n", ind, stat.done_code); - printf("%sexit_code : %d\n", ind, stat.exit_code); - printf("%sresubmitted : %d\n", ind, stat.resubmitted); - printf("%scancelling : %d\n", ind, stat.cancelling); - printf("%scancelReason : %s\n", ind, stat.cancelReason); - printf("%scpuTime : %d\n", ind, stat.cpuTime); - printf("%suser_tags :\n",ind); - if (stat.user_tags) - for (i=0; stat.user_tags[i].tag; i++) printf("%s%14s = \"%s\"\n", ind, - stat.user_tags[i].tag,stat.user_tags[i].value); - printf("%sstateEnterTime : %ld.%06ld\n", ind, stat.stateEnterTime.tv_sec,stat.stateEnterTime.tv_usec); - printf("%sstateEnterTimes : \n",ind); - if (stat.stateEnterTimes) for (i=1; i<=stat.stateEnterTimes[0]; i++) { - char *s; - - s = edg_wll_StatToString(i-1); - t = stat.stateEnterTimes[i]; - printf("%s%14s %s", ind, s, (stat.stateEnterTimes[i] == 0) ? - " - not available -\n" : ctime(&t)); - free(s); - } - printf("%slastUpdateTime : %ld.%06ld\n", ind, stat.lastUpdateTime.tv_sec,stat.lastUpdateTime.tv_usec); - printf("%sexpectUpdate : %d\n", ind, stat.expectUpdate); - printf("%sexpectFrom : %s\n", ind, stat.expectFrom); - printf("%sacl : %s\n", ind, stat.acl); - printf("%spayload_running: %d\n", ind, stat.payload_running); - if (stat.possible_destinations) { - printf("%spossible_destinations : \n", ind); - for (i=0; stat.possible_destinations[i]; i++) - printf("%s\t%s \n", ind, stat.possible_destinations[i]); - } - if (stat.possible_ce_nodes) { + printf("%sstate : %s\n", ind, s); + printf("%sjobId : %s\n", ind, j1 = edg_wlc_JobIdUnparse(stat.jobId)); + printf("%sowner : %s\n", ind, stat.owner); + switch (stat.jobtype) { + case EDG_WLL_STAT_SIMPLE: + printf("%sjobtype : SIMPLE\n", ind); + break; + case EDG_WLL_STAT_DAG: + printf("%sjobtype : DAG\n", ind); + break; + case EDG_WLL_STAT_COLLECTION: + printf("%sjobtype : COLLECTION\n", ind); + break; + case EDG_WLL_STAT_PBS: + printf("%sjobtype : PBS\n", ind); + break; + default: + break; + } + printf("%sparent_job : %s\n", ind, + j2 = edg_wlc_JobIdUnparse(stat.parent_job)); + if (stat.jobtype) {; + printf("%sseed : %s\n", ind, stat.seed); + printf("%schildren_num : %d\n", ind, stat.children_num); + printf("%schildren :\n", ind); + if (stat.children) + for (i=0; stat.children[i]; i++) + printf("%s\tchildren : %s\n", ind, stat.children[i]); + printf("%schildren_states :\n", ind); + if (stat.children_states) + for (i=0; stat.children_states[i].state; i++) + printstat(stat.children_states[i], level+1); + printf("%schildren_hist :\n",ind); + if (stat.children_hist) + for (i=1; i<=stat.children_hist[0]; i++) + printf("%s%14s %d\n", ind, edg_wll_StatToString(i-1),stat.children_hist[i]); + } + printf("%scondorId : %s\n", ind, stat.condorId); + printf("%sglobusId : %s\n", ind, stat.globusId); + printf("%slocalId : %s\n", ind, stat.localId); + printf("%sjdl : %s\n", ind, stat.jdl); + printf("%smatched_jdl : %s\n", ind, stat.matched_jdl); + printf("%sdestination : %s\n", ind, stat.destination); + printf("%snetwork server : %s\n", ind, stat.network_server); + printf("%scondor_jdl : %s\n", ind, stat.condor_jdl); + printf("%srsl : %s\n", ind, stat.rsl); + printf("%sreason : %s\n", ind, stat.reason); + printf("%slocation : %s\n", ind, stat.location); + printf("%sce_node : %s\n", ind, stat.ce_node); + printf("%ssubjob_failed : %d\n", ind, stat.subjob_failed); + printf("%sdone_code : %s\n", ind, edg_wll_done_codeToString(stat.done_code)); + printf("%sexit_code : %d\n", ind, stat.exit_code); + printf("%sresubmitted : %d\n", ind, stat.resubmitted); + printf("%scancelling : %d\n", ind, stat.cancelling); + printf("%scancelReason : %s\n", ind, stat.cancelReason); + printf("%scpuTime : %d\n", ind, stat.cpuTime); + printf("%suser_tags :\n",ind); + if (stat.user_tags) + for (i=0; stat.user_tags[i].tag; i++) printf("%s%14s = \"%s\"\n", ind, + stat.user_tags[i].tag,stat.user_tags[i].value); + printf("%sstateEnterTime : %ld.%06ld\n", ind, stat.stateEnterTime.tv_sec,stat.stateEnterTime.tv_usec); + printf("%sstateEnterTimes : \n",ind); + if (stat.stateEnterTimes) + for (i=1; i<=stat.stateEnterTimes[0]; i++) { + time_t st = stat.stateEnterTimes[i]; + + printf("%s%14s %s", ind, edg_wll_StatToString(i-1), st == 0 ? + " - not available -\n" : ctime(&st)); + } + printf("%slastUpdateTime : %ld.%06ld\n", ind, stat.lastUpdateTime.tv_sec,stat.lastUpdateTime.tv_usec); + printf("%sexpectUpdate : %d\n", ind, stat.expectUpdate); + printf("%sexpectFrom : %s\n", ind, stat.expectFrom); + printf("%sacl : %s\n", ind, stat.acl); + printf("%spayload_running: %d\n", ind, stat.payload_running); + if (stat.possible_destinations) { + printf("%spossible_destinations : \n", ind); + for (i=0; stat.possible_destinations[i]; i++) + printf("%s\t%s \n", ind, stat.possible_destinations[i]); + } + if (stat.possible_ce_nodes) { printf("%spossible_ce_nodes : \n", ind); for (i=0; stat.possible_ce_nodes[i]; i++) printf("%s\t%s \n", ind, stat.possible_ce_nodes[i]); - } - printf("\n"); + } + /* PBS state section */ + if (stat.jobtype == EDG_WLL_STAT_PBS) { + printf("%spbs_state : %s\n", ind, stat.pbs_state); + printf("%spbs_queue : %s\n", ind, stat.pbs_queue); + printf("%spbs_owner : %s\n", ind, stat.pbs_owner); + printf("%spbs_name : %s\n", ind, stat.pbs_name); + printf("%spbs_reason : %s\n", ind, stat.pbs_reason); + printf("%spbs_scheduler : %s\n", ind, stat.pbs_scheduler); + printf("%spbs_dest_host : %s\n", ind, stat.pbs_dest_host); + printf("%spbs_pid : %d\n", ind, stat.pbs_pid); + printf("%spbs_resource_usage : %s%s\n", ind, + (stat.pbs_resource_usage) ? "\n" : "", stat.pbs_resource_usage); + printf("%spbs_exit_status : %d\n", ind, stat.pbs_exit_status); + printf("%spbs_error_desc : %s%s\n", ind, + (stat.pbs_error_desc) ? "\n" : "", stat.pbs_error_desc); + } - free(j1); - free(j2); - free(s); + printf("\n"); + + free(j1); + free(j2); + free(s); } + -- 1.8.2.3