diff --git a/dcapi/condor/condor_defs.h b/dcapi/condor/condor_defs.h index d4717fa88b..a7a15fa7cf 100644 --- a/dcapi/condor/condor_defs.h +++ b/dcapi/condor/condor_defs.h @@ -9,6 +9,8 @@ extern "C" { #endif +#include +#include #include #include "dc.h" @@ -16,6 +18,15 @@ extern "C" { extern char project_uuid_str[37]; +struct _DC_condor_event +{ + int event; + int cluster; + int proc; + int subproc; + struct tm time; +}; + struct _DC_Workunit { char *client_name; @@ -29,7 +40,8 @@ struct _DC_Workunit char *uuid_str; DC_WUState state; - char *condor_id; + /*char *condor_id;*/ + GArray *condor_events; char *workdir; GList *input_files; diff --git a/dcapi/condor/condor_log.cc b/dcapi/condor/condor_log.cc index 9029e5359b..13b4c1c01d 100644 --- a/dcapi/condor/condor_log.cc +++ b/dcapi/condor/condor_log.cc @@ -1,5 +1,81 @@ +/* Local variables: */ +/* c-file-style: "linux" */ +/* End: */ + +#include +#include #include +#include +#include +#include +#include #include "user_log.c++.h" +#include "dc.h" +#include "dc_common.h" + +#include "condor_defs.h" +#include "condor_log.h" + + +char * +_DC_wu_update_condor_events(DC_Workunit *wu) +{ + ReadUserLog log; + GString *fn_org, *fn_tmp; + char t[100]; + int res; + unsigned int i; + + if (!wu) + return(0); + + fn_org= g_string_new(wu->workdir); + fn_org= g_string_append(fn_org, "/internal_log.txt"); + strcpy(t, "/tmp/condor_dc_api_XXXXXX"); + res= mkstemp(t); + fn_tmp= g_string_new(t); + close(res); + _DC_copyFile(fn_org->str, fn_tmp->str); + res= log.initialize(fn_tmp->str); + if (!res) + { + DC_log(LOG_ERR, "Condor user log file reader " + "initialization failed for %s", fn_tmp->str); + g_string_free(fn_org, TRUE); + g_string_free(fn_tmp, TRUE); + return(0); + } + + i= 1; + ULogEvent *event; + while (log.readEvent(event) == ULOG_OK) + { + printf("%d %s\n", event->eventNumber, + ULogEventNumberNames[event->eventNumber]); + if (wu->condor_events->len < i) + { + struct _DC_condor_event e; + e.event= event->eventNumber; + e.cluster= event->cluster; + e.proc= event->proc; + e.subproc= event->subproc; + e.time= event->eventTime; + g_array_append_val(wu->condor_events, e); + DC_log(LOG_DEBUG, "Condor event %d %s", + event->eventNumber, + ULogEventNumberNames[event->eventNumber]); + } + delete event; + i++; + } + + unlink(fn_tmp->str); + g_string_free(fn_org, TRUE); + g_string_free(fn_tmp, TRUE); + return(0); +} + + /* End of condor_log.cc */ diff --git a/dcapi/condor/condor_log.h b/dcapi/condor/condor_log.h new file mode 100644 index 0000000000..4cc092c5b7 --- /dev/null +++ b/dcapi/condor/condor_log.h @@ -0,0 +1,24 @@ +/* Local variables: */ +/* c-file-style: "linux" */ +/* End: */ + +#ifndef _DC_API_CONDOR_LOG_H_ +#define _DC_API_CONDOR_LOG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "dc.h" + + +extern char *_DC_wu_update_condor_events(DC_Workunit *wu); + + +#ifdef __cplusplus +} +#endif + +#endif + +/* End of condor/condor_log.h */