int store_job_server_proxy(edg_wll_Context ctx, edg_wll_Event *event, int *register_to_JP);
int register_subjobs_embryonic(edg_wll_Context,const edg_wll_RegJobEvent *);
edg_wll_ErrorCode intJobStat_embryonic(edg_wll_Context ctx, glite_jobid_const_t jobid, const edg_wll_RegJobEvent *e, intJobStat *stat);
-int edg_wll_jobsconnection_create(edg_wll_Context ctx, glite_jobid_const_t jobid_from, glite_jobid_const_t jobid_to, enum edg_wll_StatJobtype jobtype, enum edg_wll_JobConnectionType connectiontype);
-int edg_wll_jobsconnection_modify(edg_wll_Context ctx, glite_jobid_const_t jobid_from, glite_jobid_const_t jobid_to, enum edg_wll_JobConnectionType);
-int edg_wll_jobsconnection_modifyall(edg_wll_Context ctx, glite_jobid_const_t jobid, enum edg_wll_JobConnectionType oldtype, enum edg_wll_JobConnectionType newtype);
+int edg_wll_jobsconnection_create(edg_wll_Context ctx, glite_jobid_const_t jobid_from, glite_jobid_const_t jobid_to, enum edg_wll_StatJobtype jobtype, edg_wll_JobConnectionType connectiontype);
+int edg_wll_jobsconnection_modify(edg_wll_Context ctx, glite_jobid_const_t jobid_from, glite_jobid_const_t jobid_to, edg_wll_JobConnectionType);
+int edg_wll_jobsconnection_modifyall(edg_wll_Context ctx, glite_jobid_const_t jobid, edg_wll_JobConnectionType oldtype, edg_wll_JobConnectionType newtype);
int edg_wll_jobsconnection_purgeall(edg_wll_Context ctx, glite_jobid_const_t jobid);
int edg_wll_delete_event(edg_wll_Context,const char *, int);
}
-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) {
+edg_wll_ErrorCode edg_wll_getConnectedJobs(edg_wll_Context ctx, glite_jobid_const_t job, edg_wll_JobConnectionType connection, edg_wll_RelationshipRecord **connections) {
char *stmt;
glite_lbu_Statement sh = NULL;
- int i, n;
+ int i = 0, n;
char *job_u;
char *out_stat[3];
+ glite_jobid_t tempjobid;
+ edg_wll_RelationshipRecord *conns = NULL;
job_u = edg_wlc_JobIdGetUnique(job);
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) {
+ conns = (edg_wll_RelationshipRecord*)malloc((n+1)*sizeof(edg_wll_RelationshipRecord));
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]);
+ glite_jobid_recreate((const char*) ctx->srvName, ctx->srvPort, out_stat[0], &tempjobid);
+ conns[i].jobid = tempjobid;
+ conns[i].jobtype = atoi(out_stat[1]);
+ conns[i].reltype = atoi(out_stat[2]);
free(out_stat[0]);
free(out_stat[1]);
free(out_stat[2]);
i++;
}
+ conns[i].jobid = NULL;
+ conns[i].jobtype = -1;
+ conns[i].reltype = EDG_WLL_JOBCONNECTION_UNDEFINED;
}
- connected_jobs[i] = NULL;
- job_types[i] = EDG_WLL_NUMBER_OF_JOBTYPES; /* no undefined value */
- connection_types[i] = EDG_WLL_JOBCONNECTION_UNDEFINED;
+
+ *connections = conns;
return edg_wll_Error(ctx, NULL, NULL);
}
#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 *);
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);
+edg_wll_ErrorCode edg_wll_getConnectedJobs(edg_wll_Context ctx, glite_jobid_const_t job, edg_wll_JobConnectionType connection, edg_wll_RelationshipRecord **connections);
#endif /* GLITE_LB_LBS_JOBSTAT_H*/
#include "index.h"
#include "server_state.h"
#include "lb_authz.h"
+#include "jobstat.h"
#include "glite/lb/context-int.h"
#include "glite/lb/xml_conversions.h"
return strcmp(((JobIdSorter*)a)->id_unparsed, ((JobIdSorter*)b)->id_unparsed);
}
+int relationship_cmp (const void *a, const void *b) {
+ // This code should sort IDs by parent ID first, then by JobID.
+ if (((edg_wll_RelationshipRecord*)a)->reltype > ((edg_wll_RelationshipRecord*)b)->reltype) return (1);
+ if (((edg_wll_RelationshipRecord*)a)->reltype < ((edg_wll_RelationshipRecord*)b)->reltype) return (-1);
+ if (((edg_wll_RelationshipRecord*)a)->jobtype > ((edg_wll_RelationshipRecord*)b)->jobtype) return (1);
+ if (((edg_wll_RelationshipRecord*)a)->jobtype < ((edg_wll_RelationshipRecord*)b)->jobtype) return (-1);
+ return (0);
+}
+
int edg_wll_ConfigurationToHTML(edg_wll_Context ctx, int admin, char **message, int text){
char *a = NULL, *b, *header, *out, *out_tmp;
int i = 0;
/* construct Message-Body of Response-Line for edg_wll_JobStatus */
int edg_wll_GeneralJobStatusToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat stat, char **message, int text)
{
- char *out_tmp = NULL, *header = NULL, *out, *history = NULL, *jdl = NULL, *cream_jdl = NULL, *rsl = NULL, *children = NULL, *chtemp;
+ char *out_tmp = NULL, *header = NULL, *out, *history = NULL, *jdl = NULL, *cream_jdl = NULL, *rsl = NULL, *children = NULL, *relations = NULL, *chtemp;
time_t time;
char *pomA = NULL;
int i;
+ size_t linlen, outlen;
chtemp = edg_wlc_JobIdUnparse(stat.jobId);
}
}
- asprintf(&pomA, "%s%s%s%s%s%s%s",
+ if (!text) {
+ edg_wll_RelationshipRecord *connections;
+ int total = 0;
+
+ edg_wll_getConnectedJobs(ctx, stat.jobId, EDG_WLL_JOBCONNECTION_UNDEFINED, &connections);
+
+ if (connections) {
+ outlen = asprintf(&relations, "<h3>Related Jobs</h3>\n<UL>\n");
+ for( total = 0; connections[total].jobid; total++ );
+
+ qsort(connections, total, sizeof(edg_wll_RelationshipRecord), relationship_cmp);
+
+ for( i = 0; connections[i].jobid; i++ ) {
+ chtemp = edg_wlc_JobIdUnparse(connections[i].jobid);
+
+ linlen = asprintf(&pomA, "<li><a href=\"%s\">%s</a> <span class=\"jobtype\">— %s</span> <span class=\"jobstate\">%s</span></li>\n%s",
+ chtemp,
+ chtemp,
+ connections[i].jobtype >= 0 && connections[i].jobtype < EDG_WLL_NUMBER_OF_JOBTYPES ?
+ edg_wll_StatusJobtypeNames[connections[i].jobtype] : "Unknown!",
+ edg_wll_JobConnectionTypeNames[connections[i].reltype],
+ connections[i+1].jobid ? "" : "</UL>\n");
+
+ relations = realloc(relations, sizeof(char) * (outlen + linlen + 1));
+ strcat(relations, pomA);
+ outlen = outlen + linlen;
+ free(pomA);
+
+ free(chtemp);
+ edg_wlc_JobIdFree(connections[i].jobid);
+ }
+ free(connections);
+
+ }
+ }
+
+ asprintf(&pomA, "%s%s%s%s%s%s%s%s",
out,
+ relations ? relations : "",
history ? history : "",
jdl ? jdl : "",
cream_jdl ? cream_jdl : "",
free(jdl);
free(rsl);
free(children);
+ free(relations);
return 0;
}