COMMON_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour} -lglite_security_gss_${nothrflavour} -lglite_lbu_trio
PLUGIN_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour} -lglite_lbu_trio \
- ${classadslib} -lstdc++ ${expatlib} -lexpat -lglite_lbu_db\
+ ${classadslib} -lstdc++ ${expatlib} -lexpat
PLUGIN_LOBJS:= lb_plugin.lo jobstat_supp.lo process_event.lo process_event_pbs.lo process_event_condor.lo
} edg_wll_IColumnRec;
void edg_wll_FreeIColumnRec(edg_wll_IColumnRec *);
+edg_wll_ErrorCode edg_wll_IColumnsSQLPart(edg_wll_Context, void *, edg_wll_JobStat*, int , char **, char **);
int yylex();
static void do_exit(edg_wll_Context,int);
static char *col_list(const edg_wll_QueryRec *);
static char *db_col_type(const edg_wll_QueryRec *);
+static edg_wll_ErrorCode edg_wll_RefreshIColumns(edg_wll_Context, void *);
/* XXX: don't bother with malloc() of arrays that are tiny in real life */
#define CI_MAX 200
* Set values of index columns in state table (after index reconfiguration)
*/
-edg_wll_ErrorCode edg_wll_RefreshIColumns(edg_wll_Context ctx, void *job_index_cols) {
+static edg_wll_ErrorCode edg_wll_RefreshIColumns(edg_wll_Context ctx, void *job_index_cols) {
glite_lbu_Statement sh;
int njobs, ret = -1;
"cannot decode int_status from states DB table");
}
- edg_wll_IColumnsSQLPart(ctx, job_index_cols, stat, 0, NULL, &icvalues);
+ edg_wll_IColumnsSQLPart(ctx, job_index_cols, &stat->pub, 0, NULL, &icvalues);
trio_asprintf(&stmt, "update states set seq=%s%s where jobid='%|Ss'", res[2], icvalues, res[0]);
ret = edg_wll_ExecSQL(ctx, stmt, NULL);
free(icrp->colname);
}
+
+/*
+ * Compute part of SQL command used for indexed state table columns
+ */
+
+edg_wll_ErrorCode edg_wll_IColumnsSQLPart(edg_wll_Context ctx,
+ void *job_index_cols_v,
+ edg_wll_JobStat *stat,
+ int is_insert,
+ char **names_out,
+ char **values_out)
+{
+ int i;
+ char *names, *values;
+ char *data;
+ char *tmp;
+ char *tmpval;
+ edg_wll_IColumnRec *job_index_cols = (edg_wll_IColumnRec *)job_index_cols_v;
+
+ edg_wll_ResetError(ctx);
+
+ if (is_insert) names = strdup(""); else names = NULL;
+ values = strdup("");
+
+ if (job_index_cols != NULL)
+ for (i=0; job_index_cols[i].colname; i++) {
+ data = NULL;
+ switch (job_index_cols[i].qrec.attr) {
+ case EDG_WLL_QUERY_ATTR_OWNER:
+ if (stat->owner) {
+ tmpval = edg_wll_gss_normalize_subj(stat->owner, 0);
+ trio_asprintf(&data, "'%|Ss'", tmpval);
+ free(tmpval);
+ } else data = strdup("''");
+ break;
+ case EDG_WLL_QUERY_ATTR_LOCATION:
+ if (stat->location)
+ trio_asprintf(&data, "'%|Ss'", stat->location);
+ else data = strdup("''");
+ break;
+ case EDG_WLL_QUERY_ATTR_DESTINATION:
+ if (stat->destination)
+ trio_asprintf(&data, "'%|Ss'", stat->destination);
+ else data = strdup("''");
+ break;
+ case EDG_WLL_QUERY_ATTR_DONECODE:
+ asprintf(&data, "%d", stat->done_code);
+ break;
+ case EDG_WLL_QUERY_ATTR_USERTAG:
+ if (stat->user_tags) {
+ int k;
+ for (k=0; stat->user_tags[k].tag &&
+ strcmp(stat->user_tags[k].tag,job_index_cols[i].qrec.attr_id.tag);
+ k++);
+ if (stat->user_tags[k].tag != NULL) {
+ trio_asprintf(&data, "'%|Ss'", stat->user_tags[k].value);
+ } else data = strdup("''");
+ } else data = strdup("''");
+ break;
+ case EDG_WLL_QUERY_ATTR_TIME:
+ if (stat->stateEnterTimes)
+ glite_lbu_TimeToDB(stat->stateEnterTimes[job_index_cols[i].qrec.attr_id.state+1], &data);
+ else data = strdup("0");
+ break;
+ case EDG_WLL_QUERY_ATTR_RESUBMITTED:
+ asprintf(&data, "%d", stat->resubmitted);
+ break;
+ case EDG_WLL_QUERY_ATTR_STATEENTERTIME:
+ glite_lbu_TimeToDB(stat->stateEnterTime.tv_sec, &data);
+ break;
+ case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
+ glite_lbu_TimeToDB(stat->lastUpdateTime.tv_sec, &data);
+ break;
+ case EDG_WLL_QUERY_ATTR_JDL_ATTR: // XXX: It's not clear how this is supposed to work
+ if (stat->jdl)
+ trio_asprintf(&data, "'%|Ss'", stat->destination);
+ else data = strdup("''");
+ break;
+/* case EDG_WLL_QUERY_ATTR_STATEENTERTIME: /// XXX: Which way of handling this is correct?
+ if (stat->stateEnterTime)
+ glite_lbu_TimeToDB(stat->stateEnterTime, &data);
+ else data = strdup("0");
+ break;
+ case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
+ if (stat->lastUpdateTime)
+ glite_lbu_TimeToDB(stat->lastUpdateTime, &data);
+ else data = strdup("0");
+ break;*/
+
+ /* XXX add more attributes when defined */
+ default:
+ /* do not use */
+ break;
+ }
+
+ if (!data) continue;
+
+ if (is_insert) {
+ asprintf(&tmp, "%s,`%s`", names, job_index_cols[i].colname);
+ free(names); names = tmp;
+ asprintf(&tmp, "%s,%s", values, data);
+ free(values); values = tmp;
+ } else {
+ /* update */
+ asprintf(&tmp, "%s,`%s`=%s", values, job_index_cols[i].colname, data);
+ free(values); values = tmp;
+ }
+ free(data);
+ }
+
+ if (is_insert) *names_out = names;
+ *values_out = values;
+
+ return edg_wll_Error(ctx, NULL, NULL);
+}
if (parent_md5 == NULL) parent_md5 = strdup("*no parent job*");
- edg_wll_IColumnsSQLPart(ctx, ctx->job_index_cols, stat, 0, NULL, &icvalues);
+ edg_wll_IColumnsSQLPart(ctx, ctx->job_index_cols, &stat->pub, 0, NULL, &icvalues);
trio_asprintf(&stmt,
"update states set "
if ((dbret = edg_wll_ExecSQL(ctx,stmt,NULL)) < 0) goto cleanup;
if (dbret == 0) {
- edg_wll_IColumnsSQLPart(ctx, ctx->job_index_cols, stat, 1, &icnames, &icvalues);
+ edg_wll_IColumnsSQLPart(ctx, ctx->job_index_cols, &stat->pub, 1, &icnames, &icvalues);
trio_asprintf(&stmt,
"insert into states"
"(jobid,status,seq,int_status,version"
void destroy_intJobStat_extension(intJobStat *p);
-edg_wll_ErrorCode edg_wll_IColumnsSQLPart(edg_wll_Context, void *, intJobStat *, int , char **, char **);
-edg_wll_ErrorCode edg_wll_RefreshIColumns(edg_wll_Context, void *);
int edg_wll_intJobStatus( edg_wll_Context, const edg_wlc_JobId, int, intJobStat *, int);
edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context, intJobStat *, int);
edg_wll_ErrorCode edg_wll_StoreIntStateEmbryonic(edg_wll_Context, edg_wlc_JobId, char *icnames, char *values, glite_lbu_bufInsert *bi);
return stat;
}
-/*
- * Compute part of SQL command used for indexed state table columns
- */
-
-edg_wll_ErrorCode edg_wll_IColumnsSQLPart(edg_wll_Context ctx,
- void *job_index_cols_v,
- intJobStat *stat,
- int is_insert,
- char **names_out,
- char **values_out)
-{
- int i;
- char *names, *values;
- char *data;
- char *tmp;
- char *tmpval;
- edg_wll_IColumnRec *job_index_cols = (edg_wll_IColumnRec *)job_index_cols_v;
-
- edg_wll_ResetError(ctx);
-
- if (is_insert) names = strdup(""); else names = NULL;
- values = strdup("");
-
- if (job_index_cols != NULL)
- for (i=0; job_index_cols[i].colname; i++) {
- data = NULL;
- switch (job_index_cols[i].qrec.attr) {
- case EDG_WLL_QUERY_ATTR_OWNER:
- if (stat->pub.owner) {
- tmpval = edg_wll_gss_normalize_subj(stat->pub.owner, 0);
- trio_asprintf(&data, "'%|Ss'", tmpval);
- free(tmpval);
- } else data = strdup("''");
- break;
- case EDG_WLL_QUERY_ATTR_LOCATION:
- if (stat->pub.location)
- trio_asprintf(&data, "'%|Ss'", stat->pub.location);
- else data = strdup("''");
- break;
- case EDG_WLL_QUERY_ATTR_DESTINATION:
- if (stat->pub.destination)
- trio_asprintf(&data, "'%|Ss'", stat->pub.destination);
- else data = strdup("''");
- break;
- case EDG_WLL_QUERY_ATTR_DONECODE:
- asprintf(&data, "%d", stat->pub.done_code);
- break;
- case EDG_WLL_QUERY_ATTR_USERTAG:
- if (stat->pub.user_tags) {
- int k;
- for (k=0; stat->pub.user_tags[k].tag &&
- strcmp(stat->pub.user_tags[k].tag,job_index_cols[i].qrec.attr_id.tag);
- k++);
- if (stat->pub.user_tags[k].tag != NULL) {
- trio_asprintf(&data, "'%|Ss'", stat->pub.user_tags[k].value);
- } else data = strdup("''");
- } else data = strdup("''");
- break;
- case EDG_WLL_QUERY_ATTR_TIME:
- if (stat->pub.stateEnterTimes)
- glite_lbu_TimeToDB(stat->pub.stateEnterTimes[job_index_cols[i].qrec.attr_id.state+1], &data);
- else data = strdup("0");
- break;
- case EDG_WLL_QUERY_ATTR_RESUBMITTED:
- asprintf(&data, "%d", stat->pub.resubmitted);
- break;
- case EDG_WLL_QUERY_ATTR_STATEENTERTIME:
- glite_lbu_TimeToDB(stat->pub.stateEnterTime.tv_sec, &data);
- break;
- case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
- glite_lbu_TimeToDB(stat->pub.lastUpdateTime.tv_sec, &data);
- break;
- case EDG_WLL_QUERY_ATTR_JDL_ATTR: // XXX: It's not clear how this is supposed to work
- if (stat->pub.jdl)
- trio_asprintf(&data, "'%|Ss'", stat->pub.destination);
- else data = strdup("''");
- break;
-/* case EDG_WLL_QUERY_ATTR_STATEENTERTIME: /// XXX: Which way of handling this is correct?
- if (stat->pub.stateEnterTime)
- glite_lbu_TimeToDB(stat->pub.stateEnterTime, &data);
- else data = strdup("0");
- break;
- case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
- if (stat->pub.lastUpdateTime)
- glite_lbu_TimeToDB(stat->pub.lastUpdateTime, &data);
- else data = strdup("0");
- break;*/
-
- /* XXX add more attributes when defined */
- default:
- /* do not use */
- break;
- }
-
- if (!data) continue;
-
- if (is_insert) {
- asprintf(&tmp, "%s,`%s`", names, job_index_cols[i].colname);
- free(names); names = tmp;
- asprintf(&tmp, "%s,%s", values, data);
- free(values); values = tmp;
- } else {
- /* update */
- asprintf(&tmp, "%s,`%s`=%s", values, job_index_cols[i].colname, data);
- free(values); values = tmp;
- }
- free(data);
- }
-
- if (is_insert) *names_out = names;
- *values_out = values;
-
- return edg_wll_Error(ctx, NULL, NULL);
-}
-
int component_seqcode(const char *a, edg_wll_Source index)
{
if (jobid_md5 == NULL || parent_md5 == NULL || stat_enc == NULL) goto err;
- if (edg_wll_IColumnsSQLPart(ctx, ctx->job_index_cols, stat, 1, icnames, &icvalues)) goto err;
+ if (edg_wll_IColumnsSQLPart(ctx, ctx->job_index_cols, stat->pub, 1, icnames, &icvalues)) goto err;
trio_asprintf(&stmt,
"'%|Ss',%d,%d,'%|Ss','%|Ss','%|Ss'%s",
jobid_md5, stat->pub.state, 1, stat_enc,