Skip to content

Commit

Permalink
Merge pull request #18541 from shamser/issue31616
Browse files Browse the repository at this point in the history
HPCC-31616 Record WhenStarted for dfu file operations

Reviewed-by: Jake Smith <[email protected]>
Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Apr 26, 2024
2 parents 083f445 + e915cff commit d5c4ef2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
16 changes: 5 additions & 11 deletions esp/services/ws_fs/ws_fsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,13 @@ static void DeepAssign(IEspContext &context, IConstDFUWorkUnit *src, IEspDFUWork
dest.setStateMessage(statemsg.str());

CDateTime startAt;
CDateTime stoppAt;
CDateTime stopAt;
prog->getTimeStarted(startAt);
prog->getTimeStopped(stoppAt);
prog->getTimeStopped(stopAt);

StringBuffer tmpstr;
startAt.getDateString(tmpstr);
tmpstr.append(" ");
startAt.getTimeString(tmpstr);
dest.setTimeStarted(tmpstr.str());
tmpstr.clear();
stoppAt.getDateString(tmpstr);
tmpstr.append(" ");
stoppAt.getTimeString(tmpstr);
dest.setTimeStopped(tmpstr.str());
dest.setTimeStarted(startAt.getString(tmpstr).str());
dest.setTimeStopped(stopAt.getString(tmpstr.clear()).str());

StringBuffer prgmsg;
prog->formatProgressMessage(prgmsg);
Expand Down
26 changes: 24 additions & 2 deletions plugins/fileservices/fileservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ static void blockUntilComplete(const char * label, IClientFileSpray &server, ICo

VStringBuffer reason("Blocked by fileservice activity: %s, workunit: %s", label, wuid);
setWorkunitState(ctx, WUStateBlocked, reason.str());

bool isStartTimeRecorded = false;
while(true)
{

Expand All @@ -630,6 +630,7 @@ static void blockUntilComplete(const char * label, IClientFileSpray &server, ICo
}

IConstDFUWorkunit & dfuwu = result->getResult();
DFUstate state = (DFUstate)dfuwu.getState();
bool aborting = false;
Owned<IWorkUnit> wu = ctx->updateWorkUnit(); // may return NULL
if (wu.get()) { // if updatable (e.g. not hthor with no agent context)
Expand All @@ -645,11 +646,32 @@ static void blockUntilComplete(const char * label, IClientFileSpray &server, ICo
stat_type costFileAccess = money2cost_type(dfuwu.getFileAccessCost());
updateWorkunitStat(wu, SSTdfuworkunit, wuScope, StCostFileAccess, "", costFileAccess);
wu->setApplicationValue(label, dfuwu.getID(), dfuwu.getSummaryMessage(), true);
if (!isStartTimeRecorded)
{
switch (state)
{
case DFUstate_started:
case DFUstate_aborting:
case DFUstate_monitoring:
case DFUstate_aborted:
case DFUstate_failed:
case DFUstate_finished:

const char * whenStarted = dfuwu.getTimeStarted();
if (!isEmptyString(whenStarted))
{
CDateTime startedAt;
startedAt.setString(whenStarted);
updateWorkunitStat(wu, SSTdfuworkunit, wuScope, StWhenStarted, 0, startedAt.getTimeStamp());
isStartTimeRecorded = true;
}
break;
}
}
wu->commit();
wu.clear();
}

DFUstate state = (DFUstate)dfuwu.getState();
if (stateout)
stateout->clear().append(dfuwu.getStateMessage());
switch(state)
Expand Down

0 comments on commit d5c4ef2

Please sign in to comment.