Browse Source

HPCC-17329 Change global scope to a blank

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 8 years ago
parent
commit
7db1d1cc46

+ 12 - 3
common/workunit/workunit.cpp

@@ -5877,7 +5877,7 @@ protected:
 
 void CLocalWorkUnit::setStatistic(StatisticCreatorType creatorType, const char * creator, StatisticScopeType scopeType, const char * scope, StatisticKind kind, const char * optDescription, unsigned __int64 value, unsigned __int64 count, unsigned __int64 maxValue, StatsMergeAction mergeAction)
 {
-    if (!scope || !*scope) scope = GLOBAL_SCOPE;
+    if (!scope) scope = GLOBAL_SCOPE;
 
     const char * kindName = queryStatisticName(kind);
     StatisticMeasure measure = queryMeasure(kind);
@@ -5941,7 +5941,7 @@ void CLocalWorkUnit::setStatistic(StatisticCreatorType creatorType, const char *
         else
             statTree->removeProp("@max");
     }
-    if (creatorType==SCTsummary && kind==StTimeElapsed && strsame(scope, GLOBAL_SCOPE))
+    if (creatorType==SCTsummary && kind==StTimeElapsed && isGlobalScope(scope))
     {
         StringBuffer t;
         formatTimeCollatable(t, value, false);
@@ -8844,7 +8844,7 @@ IStringVal & CLocalWUStatistic::getDescription(IStringVal & str, bool createDefa
 
         //Clean up the format of the scope when converting it to a description
         StringBuffer descriptionText;
-        if (streq(scope, GLOBAL_SCOPE))
+        if (isGlobalScope(scope))
         {
             const char * creator = p->queryProp("@creator");
             descriptionText.append(creator).append(":");
@@ -10759,7 +10759,16 @@ extern WORKUNIT_API void getWorkunitTotalTime(IConstWorkUnit* workunit, const ch
 {
     StatisticsFilter summaryTimeFilter(SCTsummary, creator, SSTglobal, GLOBAL_SCOPE, SMeasureTimeNs, StTimeElapsed);
     Owned<IConstWUStatistic> totalThorTime = getStatistic(workunit, summaryTimeFilter);
+    if (!totalThorTime)
+    {
+        StatisticsFilter legacySummaryTimeFilter(SCTsummary, creator, SSTglobal, LEGACY_GLOBAL_SCOPE, SMeasureTimeNs, StTimeElapsed);
+        totalThorTime.setown(getStatistic(workunit, legacySummaryTimeFilter));
+    }
+
     Owned<IConstWUStatistic> totalThisThorTime = workunit->getStatistic(queryStatisticsComponentName(), GLOBAL_SCOPE, StTimeElapsed);
+    if (!totalThisThorTime)
+        totalThisThorTime.setown(workunit->getStatistic(queryStatisticsComponentName(), LEGACY_GLOBAL_SCOPE, StTimeElapsed));
+
     if (totalThorTime)
         totalTimeNs = totalThorTime->getValue();
     else

+ 5 - 1
common/workunit/workunit.hpp

@@ -36,7 +36,8 @@
 #include "jutil.hpp"
 #include "jprop.hpp"
 
-#define GLOBAL_SCOPE "workunit"
+#define LEGACY_GLOBAL_SCOPE "workunit"
+#define GLOBAL_SCOPE ""
 
 #define CHEAP_UCHAR_DEF
 #ifdef _WIN32
@@ -1517,4 +1518,7 @@ extern WORKUNIT_API WUAction getWorkunitAction(const char * actionStr);
 extern WORKUNIT_API void addTimeStamp(IWorkUnit * wu, StatisticScopeType scopeType, const char * scope, StatisticKind kind);
 extern WORKUNIT_API IPropertyTree * getWUGraphProgress(const char * wuid, bool readonly);
 
+inline bool isGlobalScope(const char * scope) { return scope && (streq(scope, GLOBAL_SCOPE) || streq(scope, LEGACY_GLOBAL_SCOPE)); }
+
+
 #endif

+ 8 - 3
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -392,7 +392,7 @@ void WsWuInfo::doGetTimers(IArrayOf<IEspECLTimer>& timers)
             cur.getScope(scope);
 
             bool isThorTiming = false;//Should it be renamed as isClusterTiming?
-            if ((cur.getCreatorType() == SCTsummary) && (cur.getKind() == StTimeElapsed) && streq(scope.str(), GLOBAL_SCOPE))
+            if ((cur.getCreatorType() == SCTsummary) && (cur.getKind() == StTimeElapsed) && isGlobalScope(scope.str()))
             {
                 SCMStringBuffer creator;
                 cur.getCreator(creator);
@@ -915,11 +915,11 @@ void WsWuInfo::getEventScheduleFlag(IEspECLWorkunit &info)
     }
 }
 
-unsigned WsWuInfo::getTotalThorTime()
+unsigned WsWuInfo::getTotalThorTime(const char * scope)
 {
     StatisticsFilter filter;
     filter.setCreatorType(SCTsummary);
-    filter.setScope(GLOBAL_SCOPE);
+    filter.setScope(scope);
     filter.setKind(StTimeElapsed);
 
     //Should only be a single value
@@ -933,6 +933,11 @@ unsigned WsWuInfo::getTotalThorTime()
     return totalThorTimeMS;
 }
 
+unsigned WsWuInfo::getTotalThorTime()
+{
+    return getTotalThorTime(GLOBAL_SCOPE) + getTotalThorTime(LEGACY_GLOBAL_SCOPE);
+}
+
 unsigned WsWuInfo::getLegacyTotalThorTime()
 {
     //4.2.x backward compatibility - only scope depth and measure filters work

+ 1 - 0
esp/services/ws_workunits/ws_workunitsHelpers.hpp

@@ -211,6 +211,7 @@ public:
 protected:
     void addTimerToList(SCMStringBuffer& name, const char * scope, IConstWUStatistic & stat, IArrayOf<IEspECLTimer>& timers);
     unsigned getTotalThorTime();
+    unsigned getTotalThorTime(const char * scope);
     unsigned getLegacyTotalThorTime();
     bool hasSubGraphTimings();
     bool legacyHasSubGraphTimings();

+ 1 - 1
system/jlib/jstats.cpp

@@ -2206,7 +2206,7 @@ bool ScopedItemFilter::recurseChildScopes(const char * curScope) const
 
 void ScopedItemFilter::set(const char * _value)
 {
-    if (_value && *_value && !streq(_value, "*") )
+    if (_value && !streq(_value, "*") )
     {
         value.set(_value);
         minDepth = queryStatisticsDepth(_value);