change to running state when it is reported by condor

fix missing cal of subresult callback


git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@874 a7169a2c-3604-0410-bc95-c702d8d87f7a
This commit is contained in:
drdani 2006-08-25 11:05:59 +00:00 committed by Adam Visegradi
parent 3955c4b1aa
commit 53a12aa568
3 changed files with 68 additions and 26 deletions

View File

@ -89,6 +89,17 @@ _DC_wu_update_condor_events(DC_Workunit *wu)
g_strdup(ae->getReason()); g_strdup(ae->getReason());
} }
} }
if (e.event == ULOG_EXECUTE)
{
class ExecuteEvent *ae=
dynamic_cast<class ExecuteEvent *>
(event);
if (ae)
{
e.exec_info.host=
g_strdup(ae->executeHost);
}
}
g_array_append_val(wu->condor_events, e); g_array_append_val(wu->condor_events, e);
DC_log(LOG_DEBUG, "Condor event %d %s", DC_log(LOG_DEBUG, "Condor event %d %s",
event->eventNumber, event->eventNumber,
@ -123,9 +134,12 @@ _DC_wu_condor2api_event(DC_Workunit *wu)
if (!ce->reported) if (!ce->reported)
{ {
ce->reported= TRUE; ce->reported= TRUE;
DC_log(LOG_DEBUG, "Job terminated, "
"asked to susp=%d",
wu->asked_to_suspend);
if (wu->asked_to_suspend) if (wu->asked_to_suspend)
{ {
wu->state= DC_WU_SUSPENDED; _DC_wu_set_state(wu, DC_WU_SUSPENDED);
wu->asked_to_suspend= FALSE; wu->asked_to_suspend= FALSE;
} }
else else
@ -141,11 +155,19 @@ _DC_wu_condor2api_event(DC_Workunit *wu)
e->result= _DC_result_create(wu);*/ e->result= _DC_result_create(wu);*/
DC_log(LOG_DEBUG, "Result of the event: %p", DC_log(LOG_DEBUG, "Result of the event: %p",
e->result); e->result);
wu->state= DC_WU_FINISHED; _DC_wu_set_state(wu, DC_WU_FINISHED);
return(e); return(e);
} }
} }
} }
if (ce->event == ULOG_EXECUTE)
{
if (!ce->reported)
{
ce->reported= TRUE;
_DC_wu_set_state(wu, DC_WU_RUNNING);
}
}
} }
return(NULL); return(NULL);
} }

View File

@ -55,7 +55,7 @@ DC_submitWU(DC_Workunit *wu)
DC_log(LOG_DEBUG, "DC_submitWU(%p-\"%s\")", wu, wu->data.name); DC_log(LOG_DEBUG, "DC_submitWU(%p-\"%s\")", wu, wu->data.name);
if (wu->state != DC_WU_READY) if (wu->data.state != DC_WU_READY)
{ {
DC_log(LOG_INFO, "Re-submission of %s", wu->data.name); DC_log(LOG_INFO, "Re-submission of %s", wu->data.name);
return(DC_ERR_BADPARAM); return(DC_ERR_BADPARAM);
@ -79,7 +79,7 @@ DC_submitWU(DC_Workunit *wu)
sleep(1); sleep(1);
_DC_wu_update_condor_events(wu); _DC_wu_update_condor_events(wu);
} }
wu->state= DC_WU_RUNNING; /*_DC_wu_set_state(wu, DC_WU_RUNNING);*/
id= DC_getWUId(wu); id= DC_getWUId(wu);
DC_log(LOG_INFO, "Condor id of wu's job: %s", id); DC_log(LOG_INFO, "Condor id of wu's job: %s", id);
g_free(id); g_free(id);
@ -123,16 +123,16 @@ DC_cancelWU(DC_Workunit *wu)
DC_log(LOG_DEBUG, "DC_cancelWU(%p-\"%s\")", wu, wu->data.name); DC_log(LOG_DEBUG, "DC_cancelWU(%p-\"%s\")", wu, wu->data.name);
if (wu->state != DC_WU_RUNNING || if (wu->data.state != DC_WU_RUNNING ||
wu->state != DC_WU_SUSPENDED) wu->data.state != DC_WU_SUSPENDED)
{ {
DC_log(LOG_NOTICE, "Can not cancel a non-running/suspended wu"); DC_log(LOG_NOTICE, "Can not cancel a non-running/suspended wu");
return(DC_ERR_INTERNAL); return(DC_ERR_INTERNAL);
} }
ret= _DC_stop_condor_job(wu); ret= _DC_stop_condor_job(wu);
if (wu->state == DC_WU_SUSPENDED) if (wu->data.state == DC_WU_SUSPENDED)
ret= 0; ret= 0;
wu->state= DC_WU_ABORTED; _DC_wu_set_state(wu, DC_WU_ABORTED);
return((ret==0)?DC_OK:DC_ERR_BADPARAM); return((ret==0)?DC_OK:DC_ERR_BADPARAM);
} }
@ -146,7 +146,7 @@ DC_suspendWU(DC_Workunit *wu)
DC_log(LOG_DEBUG, "DC_suspendWU(%p-\"%s\")", wu, wu->data.name); DC_log(LOG_DEBUG, "DC_suspendWU(%p-\"%s\")", wu, wu->data.name);
if (wu->state != DC_WU_RUNNING) if (wu->data.state != DC_WU_RUNNING)
{ {
DC_log(LOG_NOTICE, "Can not suspend a non-running wu"); DC_log(LOG_NOTICE, "Can not suspend a non-running wu");
return(DC_ERR_INTERNAL); return(DC_ERR_INTERNAL);
@ -172,7 +172,7 @@ DC_resumeWU(DC_Workunit *wu)
DC_log(LOG_DEBUG, "DC_resumeWU(%p-\"%s\")", wu, wu->data.name); DC_log(LOG_DEBUG, "DC_resumeWU(%p-\"%s\")", wu, wu->data.name);
if (wu->state != DC_WU_SUSPENDED) if (wu->data.state != DC_WU_SUSPENDED)
{ {
DC_log(LOG_NOTICE, "Can not resume a non-suspended wu"); DC_log(LOG_NOTICE, "Can not resume a non-suspended wu");
return(DC_ERR_INTERNAL); return(DC_ERR_INTERNAL);
@ -186,7 +186,7 @@ DC_resumeWU(DC_Workunit *wu)
sleep(1); sleep(1);
_DC_wu_update_condor_events(wu); _DC_wu_update_condor_events(wu);
} }
wu->state= DC_WU_RUNNING; _DC_wu_set_state(wu, DC_WU_RUNNING);
id= DC_getWUId(wu); id= DC_getWUId(wu);
DC_log(LOG_INFO, "Condor id of wu's job: %s", id); DC_log(LOG_INFO, "Condor id of wu's job: %s", id);
g_free(id); g_free(id);

View File

@ -213,7 +213,7 @@ DC_createWU(const char *clientName,
_DC_wu_make_client_config(wu); _DC_wu_make_client_config(wu);
_DC_wu_make_client_executables(wu); _DC_wu_make_client_executables(wu);
wu->state= DC_WU_READY; _DC_wu_set_state(wu, DC_WU_READY);
return(wu); return(wu);
} }
@ -253,11 +253,11 @@ DC_destroyWU(DC_Workunit *wu)
i, wu->data.name); i, wu->data.name);
g_string_free(s, TRUE); g_string_free(s, TRUE);
if (wu->state == DC_WU_READY || if (wu->data.state == DC_WU_READY ||
wu->state == DC_WU_UNKNOWN) wu->data.state == DC_WU_UNKNOWN)
DC_log(LOG_NOTICE, "Destroying an unstarted wu: %s", wu->data.name); DC_log(LOG_NOTICE, "Destroying an unstarted wu: %s", wu->data.name);
if (wu->state == DC_WU_RUNNING || if (wu->data.state == DC_WU_RUNNING ||
wu->state == DC_WU_SUSPENDED) wu->data.state == DC_WU_SUSPENDED)
{ {
DC_log(LOG_NOTICE, "Destroying a started but not yet " DC_log(LOG_NOTICE, "Destroying a started but not yet "
"finished wu: %s", wu->data.name); "finished wu: %s", wu->data.name);
@ -392,7 +392,7 @@ DC_addWUInput(DC_Workunit *wu,
DC_log(LOG_DEBUG, "DC_addWUInput(%p-\"%s\", %s, %s, %d)", DC_log(LOG_DEBUG, "DC_addWUInput(%p-\"%s\", %s, %s, %d)",
wu, wu->data.name, logicalFileName, URL, fileMode); wu, wu->data.name, logicalFileName, URL, fileMode);
if (wu->state != DC_WU_READY) if (wu->data.state != DC_WU_READY)
{ {
DC_log(LOG_INFO, "Modifying started wu %s", wu->data.name); DC_log(LOG_INFO, "Modifying started wu %s", wu->data.name);
return(DC_ERR_BADPARAM); return(DC_ERR_BADPARAM);
@ -466,7 +466,7 @@ DC_addWUOutput(DC_Workunit *wu, const char *logicalFileName)
DC_log(LOG_DEBUG, "DC_addWUOutput(%p-\"%s\", %s)", DC_log(LOG_DEBUG, "DC_addWUOutput(%p-\"%s\", %s)",
wu, wu->data.name, logicalFileName); wu, wu->data.name, logicalFileName);
if (wu->state != DC_WU_READY) if (wu->data.state != DC_WU_READY)
{ {
DC_log(LOG_INFO, "Modifying started wu %s", wu->data.name); DC_log(LOG_INFO, "Modifying started wu %s", wu->data.name);
return(DC_ERR_BADPARAM); return(DC_ERR_BADPARAM);
@ -494,7 +494,7 @@ DC_setWUPriority(DC_Workunit *wu, int priority)
DC_log(LOG_DEBUG, "DC_setWUPriority(%p-\"%s\", %d)", DC_log(LOG_DEBUG, "DC_setWUPriority(%p-\"%s\", %d)",
wu, wu->data.name, priority); wu, wu->data.name, priority);
if (wu->state != DC_WU_READY) if (wu->data.state != DC_WU_READY)
{ {
DC_log(LOG_INFO, "Modifying started wu %s", wu->data.name); DC_log(LOG_INFO, "Modifying started wu %s", wu->data.name);
return(DC_ERR_BADPARAM); return(DC_ERR_BADPARAM);
@ -525,7 +525,7 @@ DC_getWUState(DC_Workunit *wu)
{ {
if (!_DC_wu_check(wu)) if (!_DC_wu_check(wu))
return(DC_WU_UNKNOWN); return(DC_WU_UNKNOWN);
return(wu->state); return(wu->data.state);
} }
@ -584,7 +584,7 @@ static void _DC_dd_check_state(void *key, void *value, void *ptr)
{ {
DC_Workunit *wu=(DC_Workunit *)value; DC_Workunit *wu=(DC_Workunit *)value;
int *count= (int *)ptr; int *count= (int *)ptr;
if (wu->state == _DC_dd_look_for_state) if (wu->data.state == _DC_dd_look_for_state)
++(*count); ++(*count);
} }
@ -608,6 +608,8 @@ _DC_process_event(DC_MasterEvent *event)
if (!event) if (!event)
return; return;
DC_log(LOG_DEBUG, "Processing an event %d, calling callback...",
event->type);
switch (event->type) switch (event->type)
{ {
case DC_MASTER_RESULT: case DC_MASTER_RESULT:
@ -619,6 +621,10 @@ _DC_process_event(DC_MasterEvent *event)
} }
case DC_MASTER_SUBRESULT: case DC_MASTER_SUBRESULT:
{ {
if (_DC_subresult_callback)
(*_DC_subresult_callback)(event->wu,
event->subresult->label,
event->subresult->path);
break; break;
} }
case DC_MASTER_MESSAGE: case DC_MASTER_MESSAGE:
@ -673,7 +679,10 @@ _DC_check_filtered_wu_event(gpointer wu_name, gpointer w, gpointer ptr)
if (filter && if (filter &&
((strcmp(DC_getWUTag(wu), filter) != 0))) ((strcmp(DC_getWUTag(wu), filter) != 0)))
return(FALSE); return(FALSE);
_DC_filtered_event= DC_waitWUEvent(wu, 0); if ((_DC_filtered_event= DC_waitWUEvent(wu, 0)) != NULL)
DC_log(LOG_DEBUG,
"DC_waitMasterEvent found an event for wu %s",
wu->data.name);
return(!_DC_filtered_event); return(!_DC_filtered_event);
} }
@ -728,9 +737,14 @@ DC_waitWUEvent(DC_Workunit *wu, int timeout)
wu, wu->data.name, timeout); wu, wu->data.name, timeout);
_DC_wu_update_condor_events(wu); _DC_wu_update_condor_events(wu);
me= _DC_wu_check_client_messages(wu); if ((me= _DC_wu_check_client_messages(wu)) != NULL)
DC_log(LOG_DEBUG, "DC_waitWUEvent found a message");
if (!me) if (!me)
me= _DC_wu_condor2api_event(wu); {
if ((me= _DC_wu_condor2api_event(wu)) != NULL)
DC_log(LOG_DEBUG,
"DC_waitWUEvent found a condor event");
}
if (me || timeout==0) if (me || timeout==0)
return(me); return(me);
start= time(NULL); start= time(NULL);
@ -739,9 +753,15 @@ DC_waitWUEvent(DC_Workunit *wu, int timeout)
{ {
sleep(1); sleep(1);
_DC_wu_update_condor_events(wu); _DC_wu_update_condor_events(wu);
me= _DC_wu_check_client_messages(wu); if ((me= _DC_wu_check_client_messages(wu)) != NULL)
DC_log(LOG_DEBUG, "DC_waitWUEvent found a message");
if (!me) if (!me)
me= _DC_wu_condor2api_event(wu); {
if ((me= _DC_wu_condor2api_event(wu)) != NULL)
DC_log(LOG_DEBUG,
"DC_waitWUEvent found a "
"condor event");
}
if (me) if (me)
return(me); return(me);
now= time(NULL); now= time(NULL);