From 44871896266db7a8892feca91a5c24bd66b64e57 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Filipovi=C4=8D?= Date: Mon, 27 Aug 2012 14:07:16 +0000 Subject: [PATCH] - bug in DB schema fixed (allows to store more connections of same job) - added function for fetching job connections --- org.glite.lb.server/config/glite-lb-dbsetup.sql | 3 +- org.glite.lb.server/interface/store.h | 7 ----- org.glite.lb.server/src/jobstat.c | 42 +++++++++++++++++++++++++ org.glite.lb.server/src/jobstat.h | 10 +++++- 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/org.glite.lb.server/config/glite-lb-dbsetup.sql b/org.glite.lb.server/config/glite-lb-dbsetup.sql index c1c4c4b..38bceed 100644 --- a/org.glite.lb.server/config/glite-lb-dbsetup.sql +++ b/org.glite.lb.server/config/glite-lb-dbsetup.sql @@ -160,7 +160,6 @@ create table job_connections ( jobid_to char(32) binary not null, jobtype int not null, connection int not null, - primary key (jobid_from), - index (jobid_to) + primary key (jobid_from, jobid_to) ) engine=innodb; diff --git a/org.glite.lb.server/interface/store.h b/org.glite.lb.server/interface/store.h index 70f56be..77ff546 100644 --- a/org.glite.lb.server/interface/store.h +++ b/org.glite.lb.server/interface/store.h @@ -41,13 +41,6 @@ void edg_wll_StoreAnonymous( int /* IN (boolean) */ ); -enum edg_wll_JobConnectionType { - EDG_WLL_JOBCONNECTION_UNKNOWN, - EDG_WLL_JOBCONNECTION_ACTIVE, - EDG_WLL_JOBCONNECTION_INACTIVE, - EDG_WLL_JOBCONNECTION_CANCELLED -}; - int db_store(edg_wll_Context, char *); int db_parent_store(edg_wll_Context, edg_wll_Event *, intJobStat *); int handle_request(edg_wll_Context,char *); diff --git a/org.glite.lb.server/src/jobstat.c b/org.glite.lb.server/src/jobstat.c index 5769772..95c7f13 100644 --- a/org.glite.lb.server/src/jobstat.c +++ b/org.glite.lb.server/src/jobstat.c @@ -1542,3 +1542,45 @@ cleanup: } +edg_wll_ErrorCode edg_wll_getConnectedJobs(edg_wll_Context ctx, glite_jobid_const_t job, enum edg_wll_JobConnectionType connection, glite_jobid_t *connected_jobs, enum edg_wll_StatJobtype *job_types, enum edg_wll_JobConnectionType *connection_types) { + char *stmt; + glite_lbu_Statement sh = NULL; + int i, n; + char *job_u; + char *out_stat[3]; + + job_u = edg_wlc_JobIdGetUnique(job); + + if (connection == EDG_WLL_JOBCONNECTION_UNDEFINED) + trio_asprintf(&stmt, "SELECT jobid_to, jobtype, connection FROM job_connections WHERE jobid_from='%s'", job_u); + else + trio_asprintf(&stmt, "SELECT jobid_to, jobtype, connection FROM job_connections WHERE jobid_from='%s' AND connection=%i", job_u, connection); + glite_common_log_msg(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt); + free(job_u); + + n = edg_wll_ExecSQL(ctx,stmt,&sh); + free(stmt); + + connected_jobs = (glite_jobid_t*)malloc((n+1)*sizeof(glite_jobid_t)); + job_types = (enum edg_wll_StatJobtype*)malloc((n+1)*sizeof(enum edg_wll_StatJobtype)); + connection_types = (enum edg_wll_JobConnectionType*)malloc((n+1)*sizeof(enum edg_wll_JobConnectionType)); + + i = 0; + if (n > 0) { + while (edg_wll_FetchRow(ctx, sh, sizeof(out_stat)/sizeof(out_stat[0]), NULL, out_stat) == 3) { + glite_jobid_recreate((const char*) ctx->srvName, ctx->srvPort, out_stat[0], &(connected_jobs[i])); + job_types[i] = atoi(out_stat[1]); + connection_types[i] = atoi(out_stat[2]); + free(out_stat[0]); + free(out_stat[1]); + free(out_stat[2]); + i++; + } + } + connected_jobs[i] = NULL; + job_types[i] = EDG_WLL_NUMBER_OF_JOBTYPES; /* no undefined value */ + connection_types[i] = EDG_WLL_JOBCONNECTION_UNDEFINED; + + return edg_wll_Error(ctx, NULL, NULL); +} + diff --git a/org.glite.lb.server/src/jobstat.h b/org.glite.lb.server/src/jobstat.h index 04682a7..efd9fe7 100644 --- a/org.glite.lb.server/src/jobstat.h +++ b/org.glite.lb.server/src/jobstat.h @@ -33,6 +33,14 @@ limitations under the License. #define HISTORY_SEPARATOR ",\n" #define HISTORY_SEPARATOR_SIZE 2 + +enum edg_wll_JobConnectionType { + EDG_WLL_JOBCONNECTION_UNDEFINED, + EDG_WLL_JOBCONNECTION_ACTIVE, + EDG_WLL_JOBCONNECTION_INACTIVE, + EDG_WLL_JOBCONNECTION_CANCELLED +}; + int edg_wll_JobStatusServer(edg_wll_Context, glite_jobid_const_t, int, edg_wll_JobStat *); @@ -72,6 +80,6 @@ edg_wll_ErrorCode edg_wll_StoreSubjobHistogram(edg_wll_Context, glite_jobid_cons edg_wll_Event* fetch_history(edg_wll_Context ctx, edg_wll_JobStat *stat); int collate_history(edg_wll_Context ctx, edg_wll_JobStat *stat, edg_wll_Event* events, int authz_flags); //int clear_history(); - +edg_wll_ErrorCode edg_wll_getConnectedJobs(edg_wll_Context ctx, glite_jobid_const_t job, enum edg_wll_JobConnectionType connection, glite_jobid_t *connected_jobs, enum edg_wll_StatJobtype *job_types, enum edg_wll_JobConnectionType *connection_types); #endif /* GLITE_LB_LBS_JOBSTAT_H*/ -- 1.8.2.3