From aa773e3f2201f2a26fb1525b29ddff53dcac3090 Mon Sep 17 00:00:00 2001 From: Shamser Ahmed Date: Tue, 16 Apr 2024 14:08:34 +0100 Subject: [PATCH] HPCC-31616 Record WhenStarted for dfu file operations Signed-off-by: Shamser Ahmed --- plugins/fileservices/fileservices.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/fileservices/fileservices.cpp b/plugins/fileservices/fileservices.cpp index f5e53b786d2..865abfd1b01 100644 --- a/plugins/fileservices/fileservices.cpp +++ b/plugins/fileservices/fileservices.cpp @@ -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) { @@ -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 wu = ctx->updateWorkUnit(); // may return NULL if (wu.get()) { // if updatable (e.g. not hthor with no agent context) @@ -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)