瀏覽代碼

HPCC-26868 WUQuery to return cost fields

Signed-off-by: Shamser Ahmed <shamser.ahmed@lexisnexis.com>
Shamser Ahmed 3 年之前
父節點
當前提交
ef6da79743

+ 21 - 0
common/workunit/workunit.cpp

@@ -3659,6 +3659,21 @@ public:
         appvalues.loadBranch(&p,"Application");
         totalThorTime = (unsigned)nanoToMilli(extractTimeCollatable(p.queryProp("@totalThorTime"), nullptr));
         _isProtected = p.getPropBool("@protected", false);
+
+        Owned<IPropertyTreeIterator> iterCostExecute = p.getElements("./Statistics/Statistic[@kind='CostExecute'][@scope='']");
+        costExecute = 0;
+        ForEach(*iterCostExecute)
+        {
+            IPropertyTree &stat = iterCostExecute->query();
+            costExecute += stat.getPropInt64("@value");
+        }
+        Owned<IPropertyTreeIterator> iterFileAccess = p.getElements("./Statistics/Statistic[@kind='CostFileAccess'][@scope='']");
+        costFileAccess = 0;
+        ForEach(*iterFileAccess)
+        {
+            IPropertyTree &stat = iterFileAccess->query();
+            costFileAccess += stat.getPropInt64("@value");
+        }
     }
     virtual const char *queryWuid() const { return wuid.str(); }
     virtual const char *queryUser() const { return user.str(); }
@@ -3673,6 +3688,8 @@ public:
     virtual const char *queryPriorityDesc() const { return getEnumText(priority, priorityClasses); }
     virtual int getPriorityLevel() const { return priorityLevel; }
     virtual bool isProtected() const { return _isProtected; }
+    virtual unsigned __int64 getExecuteCost() const { return costExecute; }
+    virtual unsigned __int64 getFileAccessCost() const { return costFileAccess; }
     virtual IJlibDateTime & getTimeScheduled(IJlibDateTime & val) const
     {
         if (timeScheduled.length())
@@ -3691,6 +3708,8 @@ protected:
     WUPriorityClass priority;
     int priorityLevel;
     bool _isProtected;
+    unsigned __int64 costExecute;
+    unsigned __int64 costFileAccess;
 };
 
 extern IConstWorkUnitInfo *createConstWorkUnitInfo(IPropertyTree &p)
@@ -8187,6 +8206,8 @@ void CLocalWorkUnit::copyWorkUnit(IConstWorkUnit *cached, bool copyStats, bool a
     p->setProp("@eclVersion", fromP->queryProp("@eclVersion"));
     p->setProp("@totalThorTime", fromP->queryProp("@totalThorTime"));
     p->setProp("@hash", fromP->queryProp("@hash"));
+    p->setProp("@executeCost", fromP->queryProp("@executeCost"));
+    p->setProp("@fileAccessCost", fromP->queryProp("@fileAccessCost"));
     p->setPropBool("@cloneable", true);
     p->setPropBool("@isClone", true);
     resetWorkflow();  // the source Workflow section may have had some parts already executed...

+ 2 - 0
common/workunit/workunit.hpp

@@ -1191,6 +1191,8 @@ interface IConstWorkUnitInfo : extends IInterface
     virtual const char *queryPriorityDesc() const = 0;
     virtual int getPriorityLevel() const = 0;
     virtual bool isProtected() const = 0;
+    virtual unsigned __int64 getExecuteCost() const = 0;
+    virtual unsigned __int64 getFileAccessCost() const = 0;
     virtual IJlibDateTime & getTimeScheduled(IJlibDateTime & val) const = 0;
 
     virtual unsigned getTotalThorTime() const = 0;

+ 4 - 0
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -994,6 +994,10 @@ void WsWuInfo::getCommon(IEspECLWorkunit &info, unsigned long flags)
     cw->getTimeScheduled(dt);
     if(dt.isValid())
         info.setDateTimeScheduled(dt.getString(s).str());
+    if (version>=1.84)
+        info.setExecuteCost(cost_type2money(cw->getExecuteCost()));
+    if (version>=1.85)
+        info.setFileAccessCost(cost_type2money(cw->getFileAccessCost()));
 }
 
 void WsWuInfo::setWUAbortTime(IEspECLWorkunit &info, unsigned __int64 abortTS)

+ 4 - 0
esp/services/ws_workunits/ws_workunitsService.cpp

@@ -1983,6 +1983,10 @@ void doWUQueryWithSort(IEspContext &context, IEspWUQueryRequest & req, IEspWUQue
             }
             info->setApplicationValues(av);
         }
+        if (version>=1.84)
+            info->setExecuteCost(cost_type2money(cw.getExecuteCost()));
+        if (version>=1.85)
+            info->setFileAccessCost(cost_type2money(cw.getFileAccessCost()));
         results.append(*info.getClear());
     }