From f641f895497c004064f240f43860b50b9c2149ff Mon Sep 17 00:00:00 2001 From: Shamser Ahmed Date: Wed, 3 Jan 2024 10:26:52 +0000 Subject: [PATCH] HPCC-31048 Fix the scope for SSTdfuworkunit Modify the scope for SSTdfuworkunit as follows 1) parent scope: "dfu" 2) dfu operation 3) dfu workunit id This fix ensures that the SSTdfuworkunit scopes are handled correctly by scope iterators and other related statistic features. Signed-off-by: Shamser Ahmed --- plugins/fileservices/fileservices.cpp | 3 ++- system/jlib/jstatcodes.h | 1 + system/jlib/jstats.cpp | 21 ++++++++++++++++++++- system/jlib/jstats.h | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/plugins/fileservices/fileservices.cpp b/plugins/fileservices/fileservices.cpp index cc91a866ded..d52da12b82b 100644 --- a/plugins/fileservices/fileservices.cpp +++ b/plugins/fileservices/fileservices.cpp @@ -635,7 +635,8 @@ static void blockUntilComplete(const char * label, IClientFileSpray &server, ICo if (wu.get()) { // if updatable (e.g. not hthor with no agent context) aborting = wu->aborting(); StringBuffer wuScope, ElapsedLabel, RemainingLabel; - wuScope.appendf("%s-%s", label, dfuwu.getID()); + StringBuffer labelbuf(label); + wuScope.appendf("dfu:%s:%s", labelbuf.toLowerCase().str(), dfuwu.getID()); ElapsedLabel.append(wuScope).append(" (Elapsed) "); RemainingLabel.append(wuScope).append(" (Remaining) "); //MORE: I think this are intended to replace the timing information, but will currently combine diff --git a/system/jlib/jstatcodes.h b/system/jlib/jstatcodes.h index 58035113488..85aaf9e31d3 100644 --- a/system/jlib/jstatcodes.h +++ b/system/jlib/jstatcodes.h @@ -28,6 +28,7 @@ #define ChildGraphScopePrefix "c" #define FileScopePrefix "p" #define ChannelScopePrefix "x" +#define DFUWorkunitScopePrefix "D" #define MATCHES_CONST_PREFIX(search, prefix) (strncmp(search, prefix, strlen(prefix)) == 0) diff --git a/system/jlib/jstats.cpp b/system/jlib/jstats.cpp index eab3a9f28f5..731985b73a2 100644 --- a/system/jlib/jstats.cpp +++ b/system/jlib/jstats.cpp @@ -1429,6 +1429,8 @@ StringBuffer & StatsScopeId::getScopeText(StringBuffer & out) const return out.append(FileScopePrefix).append(name); case SSTchannel: return out.append(ChannelScopePrefix).append(id); + case SSTdfuworkunit: + return out.append(DFUWorkunitScopePrefix).append(name); case SSTunknown: return out.append(name); case SSTglobal: @@ -1447,6 +1449,7 @@ unsigned StatsScopeId::getHash() const { case SSTfunction: case SSTunknown: + case SSTdfuworkunit: return hashcz((const byte *)name.get(), (unsigned)scopeType); default: return hashc((const byte *)&id, sizeof(id), (unsigned)scopeType); @@ -1496,6 +1499,7 @@ void StatsScopeId::describe(StringBuffer & description) const break; case SSTfile: case SSTfunction: + case SSTdfuworkunit: description.append(' ').append(name); break; default: @@ -1544,6 +1548,7 @@ void StatsScopeId::deserialize(MemoryBuffer & in, unsigned version) break; case SSTfile: case SSTfunction: + case SSTdfuworkunit: in.read(name); break; default: @@ -1571,6 +1576,7 @@ void StatsScopeId::serialize(MemoryBuffer & out) const break; case SSTfile: case SSTfunction: + case SSTdfuworkunit: out.append(name); break; default: @@ -1675,6 +1681,15 @@ bool StatsScopeId::setScopeText(const char * text, const char * * _next) return true; } break; + case DFUWorkunitScopePrefix[0]: + if (MATCHES_CONST_PREFIX(text, DFUWorkunitScopePrefix)) + { + setDfuWorkunitId(text+ strlen(DFUWorkunitScopePrefix)); + if (_next) + *_next = text + strlen(text); + return true; + } + break; case '\0': setId(SSTglobal, 0); return true; @@ -1740,7 +1755,11 @@ void StatsScopeId::setChildGraphId(unsigned _id) { setId(SSTchildgraph, _id); } - +void StatsScopeId::setDfuWorkunitId(const char * _name) +{ + scopeType = SSTdfuworkunit; + name.set(_name); +} //-------------------------------------------------------------------------------------------------------------------- enum diff --git a/system/jlib/jstats.h b/system/jlib/jstats.h index 86e3ff9163b..4fa1f8e08f0 100644 --- a/system/jlib/jstats.h +++ b/system/jlib/jstats.h @@ -87,7 +87,7 @@ class jlib_decl StatsScopeId void setSubgraphId(unsigned _id); void setWorkflowId(unsigned _id); void setChildGraphId(unsigned _id); - + void setDfuWorkunitId(const char * _name); int compare(const StatsScopeId & other) const; bool operator == (const StatsScopeId & other) const { return matches(other); }