From: Zdeněk Šustr Date: Tue, 24 Oct 2006 15:22:45 +0000 (+0000) Subject: Child histogram saving/retreival. Retreival not tested yet. Encoding/Decoding works... X-Git-Tag: merge_connpool_dst~25 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=60518c215060c2442022c85c1c3631b6a92c6205;p=jra1mw.git Child histogram saving/retreival. Retreival not tested yet. Encoding/Decoding works all right. --- diff --git a/org.glite.lb.server/src/jobstat.c b/org.glite.lb.server/src/jobstat.c index 9a4efae..1eb5507 100644 --- a/org.glite.lb.server/src/jobstat.c +++ b/org.glite.lb.server/src/jobstat.c @@ -712,37 +712,32 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx, edg_wll_ErrorCode edg_wll_GetSubjobHistogram(edg_wll_Context ctx, edg_wlc_JobId parent_jobid, intJobStat **ijs) { - char *stmt = NULL,*out = NULL, *res_rest; + char *stmt = NULL,*out = NULL; edg_wll_Stmt sh; int f = -1; edg_wll_ResetError(ctx); - trio_asprintf(&stmt,"select int_status from states where jobid='%|Ss'", parent_jobid); + trio_asprintf(&stmt,"select int_status from states where (jobid='%|Ss') AND (version='%|Ss')", parent_jobid, INTSTAT_VERSION); if (stmt==NULL) { return edg_wll_SetError(ctx,ENOMEM, NULL); } +/* XXX: Untested */ + +/* XXX: This positively does not work, needs finishing: */ + if (edg_wll_ExecStmt(ctx,stmt,&sh) >= 0) { f=edg_wll_FetchRow(sh,&out); if (f == 0) { if (out) free(out); out = NULL; - return edg_wll_SetError(ctx, ENOENT, NULL); + edg_wll_SetError(ctx, ENOENT, NULL); } } edg_wll_FreeStmt(&sh); free(stmt); -/* XXX: Untested */ - - *ijs = dec_intJobStat(out, &res_rest); - if (res_rest == NULL) { - edg_wll_SetError(ctx, EDG_WLL_ERROR_DB_CALL, - "error decoding DB intJobStatus"); - } - - return edg_wll_Error(ctx, NULL, NULL); } @@ -766,6 +761,10 @@ edg_wll_ErrorCode edg_wll_SetSubjobHistogram(edg_wll_Context ctx, edg_wlc_JobId return edg_wll_SetError(ctx,ENOMEM, NULL); } +/* XXX: Untested */ + +//printf ("Would like to run SQL statament: %s\n", stmt); + if ((dbret = edg_wll_ExecStmt(ctx,stmt,NULL)) < 0) goto cleanup; assert(dbret); /* update should come through OK as the record exists */ diff --git a/org.glite.lb.server/src/jobstat_supp.c b/org.glite.lb.server/src/jobstat_supp.c index 1623536..8da4349 100644 --- a/org.glite.lb.server/src/jobstat_supp.c +++ b/org.glite.lb.server/src/jobstat_supp.c @@ -86,9 +86,16 @@ static char *enc_int_array(char *old, int *item, int itemsNo) { char *out; int index; - for (index=0; index <= itemsNo; index++) asprintf(&out,"%s%d%s", out, item[index],index==itemsNo?"":";"); - asprintf(&out,"%s%s ", old, out); + char *strpom; + + strpom=(char*)calloc(strlen(old)+1,sizeof(char)); + + for (index=0; index <= itemsNo; index++) sprintf(strpom,"%s%d%s", strpom, item[index],index==itemsNo?"":";"); + + asprintf(&out,"%s%s ", old, strpom); + free(strpom); free(old); + return out; } @@ -109,7 +116,7 @@ static int dec_int(char* in, char **rest) static int dec_int_array(char* in, char **rest, int *out) { - int charNo, itemsNo = 0, cindex, iindex = 0; + int charNo, itemsNo = 0, cindex, iindex = 0, lenindex; char *tempstr; /* Find out the number of items in the field first */ @@ -129,7 +136,6 @@ static int dec_int_array(char* in, char **rest, int *out) } else *rest = charNo + 1; -// out = (int*)calloc(itemsNo,sizeof(int)); tempstr = (char*)calloc(charNo+1,sizeof(char)); strcpy(tempstr,""); @@ -140,11 +146,16 @@ static int dec_int_array(char* in, char **rest, int *out) strcpy(tempstr,""); iindex++; } - else tempstr = strcat(tempstr, in[cindex]); + else { + lenindex=strlen(tempstr); + tempstr[lenindex]=in[cindex]; + tempstr[lenindex+1]=0; + } } if (in[cindex] != ' ') out[iindex] = atoi(tempstr); /* string not terminated with a separator */ free(tempstr); + *rest = in + charNo + 1; return out; } @@ -497,8 +508,8 @@ static edg_wll_JobStat* dec_JobStat(char *in, char **rest) stat = (edg_wll_JobStat *) calloc(1,sizeof(edg_wll_JobStat)); if (!stat) return stat; - tmp_in = in; + stat->state = dec_int(tmp_in, &tmp_in); if (tmp_in != NULL) stat->jobId = dec_jobid(tmp_in, &tmp_in); if (tmp_in != NULL) stat->owner = dec_string(tmp_in, &tmp_in); @@ -540,6 +551,7 @@ static edg_wll_JobStat* dec_JobStat(char *in, char **rest) dec_int_array(tmp_in, &tmp_in, stat->children_hist); } *rest = tmp_in; + return stat; } @@ -566,6 +578,7 @@ intJobStat* dec_intJobStat(char *in, char **rest) char *tmp_in; pubstat = dec_JobStat(in, &tmp_in); + if (tmp_in != NULL) { stat = (intJobStat *)calloc(1,sizeof(intJobStat)); }